diff options
author | 2020-05-26 16:11:49 -0500 | |
---|---|---|
committer | 2020-05-26 16:24:18 -0500 | |
commit | 334dd098170d56c004d7a97bdfbbffe6f63f0ebd (patch) | |
tree | e76e31606603f69785b81201d87f1c9ba0b22cb5 /native/src/widget/pane_grid/axis.rs | |
parent | 5324eb10242a7dd33f5271dc6fc9eeb09eb2cb50 (diff) | |
download | iced-334dd098170d56c004d7a97bdfbbffe6f63f0ebd.tar.gz iced-334dd098170d56c004d7a97bdfbbffe6f63f0ebd.tar.bz2 iced-334dd098170d56c004d7a97bdfbbffe6f63f0ebd.zip |
Pane Grid spacing applied prior to rounding
On low-DPI screens, the rounding order of operations made it impossible
to produce an odd-pixel spacing. Specifying 1, for instance, produced
zero space between panes.
This approach subtracts half the spacing from the first pane prior to
rounding and uses the whole spacing for the second pane size and
coordinate.
Diffstat (limited to 'native/src/widget/pane_grid/axis.rs')
-rw-r--r-- | native/src/widget/pane_grid/axis.rs | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/native/src/widget/pane_grid/axis.rs b/native/src/widget/pane_grid/axis.rs index f0e3f362..7181f9bf 100644 --- a/native/src/widget/pane_grid/axis.rs +++ b/native/src/widget/pane_grid/axis.rs @@ -14,37 +14,39 @@ impl Axis { &self, rectangle: &Rectangle, ratio: f32, - halved_spacing: f32, + spacing: f32, ) -> (Rectangle, Rectangle) { match self { Axis::Horizontal => { - let height_top = (rectangle.height * ratio).round(); - let height_bottom = rectangle.height - height_top; + let height_top = + (rectangle.height * ratio - spacing / 2.0).round(); + let height_bottom = rectangle.height - height_top - spacing; ( Rectangle { - height: height_top - halved_spacing, + height: height_top, ..*rectangle }, Rectangle { - y: rectangle.y + height_top + halved_spacing, - height: height_bottom - halved_spacing, + y: rectangle.y + height_top + spacing, + height: height_bottom, ..*rectangle }, ) } Axis::Vertical => { - let width_left = (rectangle.width * ratio).round(); - let width_right = rectangle.width - width_left; + let width_left = + (rectangle.width * ratio - spacing / 2.0).round(); + let width_right = rectangle.width - width_left - spacing; ( Rectangle { - width: width_left - halved_spacing, + width: width_left, ..*rectangle }, Rectangle { - x: rectangle.x + width_left + halved_spacing, - width: width_right - halved_spacing, + x: rectangle.x + width_left + spacing, + width: width_right, ..*rectangle }, ) |