Skip to content

Commit 3ff95b5

Browse files
committed
merge: office commit merge
2 parents 13171e1 + c37125f commit 3ff95b5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+730
-374
lines changed

Cargo.lock

+3-3
Original file line numberDiff line numberDiff line change
@@ -4550,7 +4550,7 @@ version = "0.1.9"
45504550
source = "registry+https://github.com/rust-lang/crates.io-index"
45514551
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
45524552
dependencies = [
4553-
"windows-sys 0.59.0",
4553+
"windows-sys 0.48.0",
45544554
]
45554555

45564556
[[package]]
@@ -4848,9 +4848,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
48484848

48494849
[[package]]
48504850
name = "winit"
4851-
version = "0.30.5"
4851+
version = "0.30.7"
48524852
source = "registry+https://github.com/rust-lang/crates.io-index"
4853-
checksum = "0be9e76a1f1077e04a411f0b989cbd3c93339e1771cb41e71ac4aee95bfd2c67"
4853+
checksum = "dba50bc8ef4b6f1a75c9274fb95aa9a8f63fbc66c56f391bd85cf68d51e7b1a3"
48544854
dependencies = [
48554855
"ahash",
48564856
"android-activity",

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ web-sys = "0.3.70"
103103
web-time = "1.1.0" # Timekeeping for native and web
104104
wgpu = { version = "23.0.0", default-features = false }
105105
windows-sys = "0.59"
106-
winit = { version = "0.30.5", default-features = false }
106+
winit = { version = "0.30.7", default-features = false }
107107
once_cell = "1.20.2"
108108

109109
[workspace.lints.rust]

crates/egui/src/containers/area.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
//! It has no frame or own size. It is potentially movable.
33
//! It is the foundation for windows and popups.
44
5+
use emath::GuiRounding as _;
6+
57
use crate::{
68
emath, pos2, Align2, Context, Id, InnerResponse, LayerId, NumExt, Order, Pos2, Rect, Response,
79
Sense, Ui, UiBuilder, UiKind, UiStackInfo, Vec2, WidgetRect, WidgetWithState,
@@ -66,6 +68,7 @@ impl AreaState {
6668
pivot_pos.x - self.pivot.x().to_factor() * size.x,
6769
pivot_pos.y - self.pivot.y().to_factor() * size.y,
6870
)
71+
.round_ui()
6972
}
7073

7174
/// Move the left top positions of the area.
@@ -80,7 +83,7 @@ impl AreaState {
8083
/// Where the area is on screen.
8184
pub fn rect(&self) -> Rect {
8285
let size = self.size.unwrap_or_default();
83-
Rect::from_min_size(self.left_top_pos(), size)
86+
Rect::from_min_size(self.left_top_pos(), size).round_ui()
8487
}
8588
}
8689

@@ -493,12 +496,11 @@ impl Area {
493496

494497
if constrain {
495498
state.set_left_top_pos(
496-
ctx.constrain_window_rect_to_area(state.rect(), constrain_rect)
497-
.min,
499+
Context::constrain_window_rect_to_area(state.rect(), constrain_rect).min,
498500
);
499501
}
500502

501-
state.set_left_top_pos(ctx.round_pos_to_pixels(state.left_top_pos()));
503+
state.set_left_top_pos(state.left_top_pos());
502504

503505
// Update response with possibly moved/constrained rect:
504506
move_response.rect = state.rect();

crates/egui/src/containers/panel.rs

+25-14
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
//!
1616
//! Add your [`crate::Window`]:s after any top-level panels.
1717
18+
use emath::GuiRounding as _;
19+
1820
use crate::{
1921
lerp, vec2, Align, Context, CursorIcon, Frame, Id, InnerResponse, LayerId, Layout, NumExt,
2022
Rangef, Rect, Sense, Stroke, Ui, UiBuilder, UiKind, UiStackInfo, Vec2,
@@ -76,6 +78,13 @@ impl Side {
7678
Self::Right => rect.right(),
7779
}
7880
}
81+
82+
fn sign(self) -> f32 {
83+
match self {
84+
Self::Left => -1.0,
85+
Self::Right => 1.0,
86+
}
87+
}
7988
}
8089

8190
/// A panel that covers the entire left or right side of a [`Ui`] or screen.
@@ -264,6 +273,8 @@ impl SidePanel {
264273
}
265274
}
266275

276+
panel_rect = panel_rect.round_ui();
277+
267278
let mut panel_ui = ui.new_child(
268279
UiBuilder::new()
269280
.id_salt(id)
@@ -345,12 +356,8 @@ impl SidePanel {
345356
// TODO(emilk): draw line on top of all panels in this ui when https://github.com/emilk/egui/issues/1516 is done
346357
let resize_x = side.opposite().side_x(rect);
347358

348-
// This makes it pixel-perfect for odd-sized strokes (width=1.0, width=3.0, etc)
349-
let resize_x = ui.painter().round_to_pixel_center(resize_x);
350-
351-
// We want the line exactly on the last pixel but rust rounds away from zero so we bring it back a bit for
352-
// left-side panels
353-
let resize_x = resize_x - if side == Side::Left { 1.0 } else { 0.0 };
359+
// Make sure the line is on the inside of the panel:
360+
let resize_x = resize_x + 0.5 * side.sign() * stroke.width;
354361
ui.painter().vline(resize_x, panel_rect.y_range(), stroke);
355362
}
356363

@@ -558,6 +565,13 @@ impl TopBottomSide {
558565
Self::Bottom => rect.bottom(),
559566
}
560567
}
568+
569+
fn sign(self) -> f32 {
570+
match self {
571+
Self::Top => -1.0,
572+
Self::Bottom => 1.0,
573+
}
574+
}
561575
}
562576

563577
/// A panel that covers the entire top or bottom of a [`Ui`] or screen.
@@ -756,6 +770,8 @@ impl TopBottomPanel {
756770
}
757771
}
758772

773+
panel_rect = panel_rect.round_ui();
774+
759775
let mut panel_ui = ui.new_child(
760776
UiBuilder::new()
761777
.id_salt(id)
@@ -837,12 +853,8 @@ impl TopBottomPanel {
837853
// TODO(emilk): draw line on top of all panels in this ui when https://github.com/emilk/egui/issues/1516 is done
838854
let resize_y = side.opposite().side_y(rect);
839855

840-
// This makes it pixel-perfect for odd-sized strokes (width=1.0, width=3.0, etc)
841-
let resize_y = ui.painter().round_to_pixel_center(resize_y);
842-
843-
// We want the line exactly on the last pixel but rust rounds away from zero so we bring it back a bit for
844-
// top-side panels
845-
let resize_y = resize_y - if side == TopBottomSide::Top { 1.0 } else { 0.0 };
856+
// Make sure the line is on the inside of the panel:
857+
let resize_y = resize_y + 0.5 * side.sign() * stroke.width;
846858
ui.painter().hline(panel_rect.x_range(), resize_y, stroke);
847859
}
848860

@@ -1130,15 +1142,14 @@ impl CentralPanel {
11301142
ctx: &Context,
11311143
add_contents: Box<dyn FnOnce(&mut Ui) -> R + 'c>,
11321144
) -> InnerResponse<R> {
1133-
let available_rect = ctx.available_rect();
11341145
let id = Id::new((ctx.viewport_id(), "central_panel"));
11351146

11361147
let mut panel_ui = Ui::new(
11371148
ctx.clone(),
11381149
id,
11391150
UiBuilder::new()
11401151
.layer_id(LayerId::background())
1141-
.max_rect(available_rect),
1152+
.max_rect(ctx.available_rect().round_ui()),
11421153
);
11431154
panel_ui.set_clip_rect(ctx.screen_rect());
11441155

crates/egui/src/containers/resize.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@ impl Resize {
221221
.at_most(self.max_size)
222222
.at_most(
223223
ui.ctx().screen_rect().size() - ui.spacing().window_margin.sum(), // hack for windows
224-
);
224+
)
225+
.round_ui();
225226

226227
State {
227228
desired_size: default_size,
@@ -233,7 +234,8 @@ impl Resize {
233234
state.desired_size = state
234235
.desired_size
235236
.at_least(self.min_size)
236-
.at_most(self.max_size);
237+
.at_most(self.max_size)
238+
.round_ui();
237239

238240
let mut user_requested_size = state.requested_size.take();
239241

@@ -383,6 +385,7 @@ impl Resize {
383385
}
384386
}
385387

388+
use emath::GuiRounding as _;
386389
use epaint::Stroke;
387390

388391
pub fn paint_resize_corner(ui: &Ui, response: &Response) {
@@ -397,7 +400,9 @@ pub fn paint_resize_corner_with_style(
397400
corner: Align2,
398401
) {
399402
let painter = ui.painter();
400-
let cp = painter.round_pos_to_pixels(corner.pos_in_rect(rect));
403+
let cp = corner
404+
.pos_in_rect(rect)
405+
.round_to_pixels(ui.pixels_per_point());
401406
let mut w = 2.0;
402407
let stroke = Stroke {
403408
width: 1.0, // Set width to 1.0 to prevent overlapping

0 commit comments

Comments
 (0)