mirror of
https://github.com/emilk/egui.git
synced 2026-06-26 22:53:14 -04:00
Refactor: don't call ctx.global_style more than once
This commit is contained in:
@@ -475,11 +475,11 @@ impl Window<'_> {
|
|||||||
fade_out,
|
fade_out,
|
||||||
} = self;
|
} = self;
|
||||||
|
|
||||||
let header_color = frame.map_or_else(
|
let style = ctx.global_style();
|
||||||
|| ctx.global_style().visuals.widgets.open.weak_bg_fill,
|
|
||||||
|f| f.fill,
|
let header_color =
|
||||||
);
|
frame.map_or_else(|| style.visuals.widgets.open.weak_bg_fill, |f| f.fill);
|
||||||
let mut window_frame = frame.unwrap_or_else(|| Frame::window(&ctx.global_style()));
|
let mut window_frame = frame.unwrap_or_else(|| Frame::window(&style));
|
||||||
|
|
||||||
let is_explicitly_closed = matches!(open, Some(false));
|
let is_explicitly_closed = matches!(open, Some(false));
|
||||||
let is_open = !is_explicitly_closed || ctx.memory(|mem| mem.everything_is_visible());
|
let is_open = !is_explicitly_closed || ctx.memory(|mem| mem.everything_is_visible());
|
||||||
@@ -511,7 +511,6 @@ impl Window<'_> {
|
|||||||
|
|
||||||
// Calculate roughly how much larger the full window inner size is compared to the content rect
|
// Calculate roughly how much larger the full window inner size is compared to the content rect
|
||||||
let (title_bar_height_with_margin, title_content_spacing) = if with_title_bar {
|
let (title_bar_height_with_margin, title_content_spacing) = if with_title_bar {
|
||||||
let style = ctx.global_style();
|
|
||||||
let title_bar_inner_height = ctx
|
let title_bar_inner_height = ctx
|
||||||
.fonts_mut(|fonts| title.font_height(fonts, &style))
|
.fonts_mut(|fonts| title.font_height(fonts, &style))
|
||||||
.at_least(style.spacing.interact_size.y);
|
.at_least(style.spacing.interact_size.y);
|
||||||
@@ -987,8 +986,10 @@ fn do_resize_interaction(
|
|||||||
|
|
||||||
let id = Id::new(layer_id).with("edge_drag");
|
let id = Id::new(layer_id).with("edge_drag");
|
||||||
|
|
||||||
let side_grab_radius = ctx.global_style().interaction.resize_grab_radius_side;
|
let style = ctx.global_style();
|
||||||
let corner_grab_radius = ctx.global_style().interaction.resize_grab_radius_corner;
|
|
||||||
|
let side_grab_radius = style.interaction.resize_grab_radius_side;
|
||||||
|
let corner_grab_radius = style.interaction.resize_grab_radius_corner;
|
||||||
|
|
||||||
let vetrtical_rect = |a: Pos2, b: Pos2| {
|
let vetrtical_rect = |a: Pos2, b: Pos2| {
|
||||||
Rect::from_min_max(a, b).expand2(vec2(side_grab_radius, -corner_grab_radius))
|
Rect::from_min_max(a, b).expand2(vec2(side_grab_radius, -corner_grab_radius))
|
||||||
|
|||||||
Reference in New Issue
Block a user