Skip to content

Commit 2ccc576

Browse files
committed
Tweak style
1 parent 4964d76 commit 2ccc576

14 files changed

+291
-128
lines changed

egui/src/containers/collapsing_header.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -246,13 +246,16 @@ impl CollapsingHeader {
246246

247247
let visuals = ui.style().interact(&header_response);
248248
let text_color = visuals.text_color();
249-
ui.painter().add(Shape::Rect {
250-
rect: header_response.rect.expand(visuals.expansion),
251-
corner_radius: visuals.corner_radius,
252-
fill: visuals.bg_fill,
253-
stroke: visuals.bg_stroke,
254-
// stroke: Default::default(),
255-
});
249+
250+
if ui.visuals().collapsing_header_frame {
251+
ui.painter().add(Shape::Rect {
252+
rect: header_response.rect.expand(visuals.expansion),
253+
corner_radius: visuals.corner_radius,
254+
fill: visuals.bg_fill,
255+
stroke: visuals.bg_stroke,
256+
// stroke: Default::default(),
257+
});
258+
}
256259

257260
{
258261
let (mut icon_rect, _) = ui.spacing().icon_rectangles(header_response.rect);

egui/src/containers/combo_box.rs

+16-10
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ fn combo_box(
176176
) -> Response {
177177
let popup_id = button_id.with("popup");
178178

179-
let button_active = ui.memory().is_popup_open(popup_id);
180-
let button_response = button_frame(ui, button_id, button_active, Sense::click(), |ui| {
179+
let is_popup_open = ui.memory().is_popup_open(popup_id);
180+
let button_response = button_frame(ui, button_id, is_popup_open, Sense::click(), |ui| {
181181
// We don't want to change width when user selects something new
182182
let full_minimum_width = ui.spacing().slider_width;
183183
let icon_size = Vec2::splat(ui.spacing().icon_width);
@@ -193,10 +193,14 @@ fn combo_box(
193193
let (_, rect) = ui.allocate_space(Vec2::new(width, height));
194194
let button_rect = ui.min_rect().expand2(ui.spacing().button_padding);
195195
let response = ui.interact(button_rect, button_id, Sense::click());
196-
// response.active |= button_active;
196+
// response.active |= is_popup_open;
197197

198198
let icon_rect = Align2::RIGHT_CENTER.align_size_within_rect(icon_size, rect);
199-
let visuals = ui.style().interact(&response);
199+
let visuals = if is_popup_open {
200+
&ui.visuals().widgets.open
201+
} else {
202+
ui.style().interact(&response)
203+
};
200204
paint_icon(ui.painter(), icon_rect.expand(visuals.expansion), visuals);
201205

202206
let text_rect = Align2::LEFT_CENTER.align_size_within_rect(galley.size, rect);
@@ -207,9 +211,8 @@ fn combo_box(
207211
if button_response.clicked() {
208212
ui.memory().toggle_popup(popup_id);
209213
}
210-
const MAX_COMBO_HEIGHT: f32 = 128.0;
211214
crate::popup::popup_below_widget(ui, popup_id, &button_response, |ui| {
212-
ScrollArea::from_max_height(MAX_COMBO_HEIGHT).show(ui, menu_contents)
215+
ScrollArea::from_max_height(ui.spacing().combo_height).show(ui, menu_contents)
213216
});
214217

215218
button_response
@@ -218,7 +221,7 @@ fn combo_box(
218221
fn button_frame(
219222
ui: &mut Ui,
220223
id: Id,
221-
button_active: bool,
224+
is_popup_open: bool,
222225
sense: Sense,
223226
add_contents: impl FnOnce(&mut Ui),
224227
) -> Response {
@@ -237,9 +240,12 @@ fn button_frame(
237240
let mut outer_rect = content_ui.min_rect().expand2(margin);
238241
outer_rect.set_height(outer_rect.height().at_least(interact_size.y));
239242

240-
let mut response = ui.interact(outer_rect, id, sense);
241-
response.is_pointer_button_down_on |= button_active;
242-
let visuals = ui.style().interact(&response);
243+
let response = ui.interact(outer_rect, id, sense);
244+
let visuals = if is_popup_open {
245+
&ui.visuals().widgets.open
246+
} else {
247+
ui.style().interact(&response)
248+
};
243249

244250
ui.painter().set(
245251
where_to_put_background,

egui/src/containers/frame.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ impl Frame {
2424
pub fn group(style: &Style) -> Self {
2525
Self {
2626
margin: Vec2::new(8.0, 6.0),
27-
corner_radius: 4.0,
28-
stroke: style.visuals.window_stroke(),
27+
corner_radius: style.visuals.widgets.noninteractive.corner_radius,
28+
stroke: style.visuals.widgets.noninteractive.bg_stroke,
2929
..Default::default()
3030
}
3131
}
@@ -63,7 +63,7 @@ impl Frame {
6363
pub fn menu(style: &Style) -> Self {
6464
Self {
6565
margin: Vec2::splat(1.0),
66-
corner_radius: 2.0,
66+
corner_radius: style.visuals.widgets.noninteractive.corner_radius,
6767
shadow: Shadow::small(),
6868
fill: style.visuals.window_fill(),
6969
stroke: style.visuals.window_stroke(),
@@ -73,7 +73,7 @@ impl Frame {
7373
pub fn popup(style: &Style) -> Self {
7474
Self {
7575
margin: style.spacing.window_padding,
76-
corner_radius: 5.0,
76+
corner_radius: style.visuals.widgets.noninteractive.corner_radius,
7777
shadow: Shadow::small(),
7878
fill: style.visuals.window_fill(),
7979
stroke: style.visuals.window_stroke(),
@@ -84,7 +84,7 @@ impl Frame {
8484
pub fn dark_canvas(style: &Style) -> Self {
8585
Self {
8686
margin: Vec2::new(10.0, 10.0),
87-
corner_radius: 5.0,
87+
corner_radius: style.visuals.widgets.noninteractive.corner_radius,
8888
fill: Color32::from_black_alpha(250),
8989
stroke: style.visuals.window_stroke(),
9090
..Default::default()

egui/src/grid.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ impl GridLayout {
199199
let rect = rect.expand2(2.0 * Vec2::X); // HACK: just looks better with some spacing on the sides
200200

201201
let color = if self.style.visuals.dark_mode {
202-
Rgba::from_white_alpha(0.0075)
202+
Rgba::from_white_alpha(0.0065)
203203
} else {
204204
Rgba::from_black_alpha(0.075)
205205
};

egui/src/introspection.rs

+11-8
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,17 @@ impl Widget for &mut epaint::TessellationOptions {
132132
debug_paint_text_rects,
133133
debug_ignore_clip_rects,
134134
} = self;
135-
ui.checkbox(anti_alias, "Antialias");
136-
ui.checkbox(
137-
coarse_tessellation_culling,
138-
"Do coarse culling in the tessellator",
139-
);
140-
ui.checkbox(debug_ignore_clip_rects, "Ignore clip rectangles (debug)");
141-
ui.checkbox(debug_paint_clip_rects, "Paint clip rectangles (debug)");
142-
ui.checkbox(debug_paint_text_rects, "Paint text bounds (debug)");
135+
ui.checkbox(anti_alias, "Antialias")
136+
.on_hover_text("Turn off for small performance gain.");
137+
ui.collapsing("debug", |ui| {
138+
ui.checkbox(
139+
coarse_tessellation_culling,
140+
"Do coarse culling in the tessellator)",
141+
);
142+
ui.checkbox(debug_ignore_clip_rects, "Ignore clip rectangles");
143+
ui.checkbox(debug_paint_clip_rects, "Paint clip rectangles");
144+
ui.checkbox(debug_paint_text_rects, "Paint text bounds");
145+
});
143146
})
144147
.response
145148
}

egui/src/menu.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ fn menu_impl<'c>(ui: &mut Ui, title: impl ToString, add_contents: Box<dyn FnOnce
7575
let mut button = Button::new(title);
7676

7777
if bar_state.open_menu == Some(menu_id) {
78-
button = button.fill(Some(ui.visuals().selection.bg_fill));
78+
button = button.fill(Some(ui.visuals().widgets.open.bg_fill));
79+
button = button.stroke(Some(ui.visuals().widgets.open.bg_stroke));
7980
}
8081

8182
let button_response = ui.add(button);

0 commit comments

Comments
 (0)