1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//! Direct2D / DirectWrite layout helper for [`crate::TextDisplay`]
//! (issue #30).
//!
//! Painting moved to the shared [`crate::primitives::text_display::paint`]
//! (#810, PaintSurface Phase 2c) — see that fn's doc for the divergence
//! (this backend's `StyledSpan::bold` support via
//! `DWrite::measure_text_styled`/`draw_text_styled`, dropped since
//! `PaintSurface` has no weight parameter) resolved while unifying
//! `gtk::text_display::draw_text_display`,
//! `macos::text_display::draw_text_display` and
//! `win::text_display::draw_text_display` into one implementation. This
//! module now only carries [`win_text_display_layout`], the DIP-unit
//! layout query used for both hit-testing
//! (`WinBackend::text_display_layout`) and painting
//! (`WinBackend::draw_text_display`, via `Backend::text_display_layout`).
//!
//! Only compiled on `target_os = "windows"` — see `super::mod`'s
//! `#[cfg(target_os = "windows")] mod text_display;` and `backend.rs`'s
//! module docs.
use crateRect;
use crate;
/// Scrollbar gutter width in DIPs. Matches the GTK/macOS rasterisers'
/// 12-DIP gutter so the body width — and therefore the resolved layout
/// — stays parity-equivalent across every pixel backend.
const SCROLLBAR_GUTTER_DIP: f32 = 12.0;
/// Minimum scrollbar thumb length in DIPs.
const SCROLLBAR_MIN_THUMB_DIP: f32 = 8.0;
/// Compute the layout the Win-GUI rasteriser would produce for
/// `display` at `rect` with the supplied `line_height`. Hosts call this
/// to drive hit-testing for scrollbar drag interaction without
/// re-deriving metrics.
///
/// The returned layout's coordinates are **body-local** (y=0 at the top
/// of the body region). Title-bar painting consumes one `line_height`
/// strip above; the body height passed to the primitive shrinks by that
/// strip when `title` is present — same contract as
/// `gtk_text_display_layout` / `mac_text_display_layout`.
///
/// `char_width` is the backend's approximate average character width
/// (`Backend::char_width`) — see quadraui#905: this pure function has no
/// live `IDWriteTextLayout` to measure real glyph widths with, so it
/// approximates the wrap column budget from pixels the same way the
/// shared `paint` (`WinBackend::draw_text_display`) does, so a click
/// always resolves against the same row boundaries that were actually
/// painted.