Skip to content

Commit 3dba73e

Browse files
authored
Improve the UI for changing the egui theme (#4257)
I added a new demo - a `Frame` editor: ![frame-editor](https://github.com/emilk/egui/assets/1148717/d0bec169-c211-45a3-9f53-5059fb8fc224) This whole menu is now just a a bit nicer to use: <img width="406" alt="Screenshot 2024-03-28 at 09 49 16" src="https://github.com/emilk/egui/assets/1148717/32d12067-7cf0-4312-aa12-42909a5ed5ac">
1 parent e183655 commit 3dba73e

23 files changed

+633
-332
lines changed

crates/egui/src/containers/frame.rs

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ use epaint::*;
5252
/// Note that you cannot change the margins after calling `begin`.
5353
#[doc(alias = "border")]
5454
#[derive(Clone, Copy, Debug, Default, PartialEq)]
55+
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
5556
#[must_use = "You should call .show()"]
5657
pub struct Frame {
5758
/// Margin within the painted frame.

crates/egui/src/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1567,7 +1567,7 @@ impl Context {
15671567

15681568
/// The [`Style`] used by all new windows, panels etc.
15691569
///
1570-
/// You can also change this using [`Self::style_mut]`
1570+
/// You can also change this using [`Self::style_mut`]
15711571
///
15721572
/// You can use [`Ui::style_mut`] to change the style of a single [`Ui`].
15731573
pub fn set_style(&self, style: impl Into<Arc<Style>>) {

crates/egui/src/introspection.rs

+24-20
Original file line numberDiff line numberDiff line change
@@ -150,23 +150,33 @@ impl Widget for &mut epaint::TessellationOptions {
150150
validate_meshes,
151151
} = self;
152152

153-
ui.checkbox(feathering, "Feathering (antialias)")
154-
.on_hover_text("Apply feathering to smooth out the edges of shapes. Turn off for small performance gain.");
155-
let feathering_slider = crate::Slider::new(feathering_size_in_pixels, 0.0..=10.0)
156-
.smallest_positive(0.1)
157-
.logarithmic(true)
158-
.text("Feathering size in pixels");
159-
ui.add_enabled(*feathering, feathering_slider);
153+
ui.horizontal(|ui| {
154+
ui.checkbox(feathering, "Feathering (antialias)")
155+
.on_hover_text("Apply feathering to smooth out the edges of shapes. Turn off for small performance gain.");
156+
157+
if *feathering {
158+
ui.add(crate::DragValue::new(feathering_size_in_pixels).clamp_range(0.0..=10.0).speed(0.1).suffix(" px"));
159+
}
160+
});
160161

161162
ui.checkbox(prerasterized_discs, "Speed up filled circles with pre-rasterization");
162163

163-
ui.add(
164-
crate::widgets::Slider::new(bezier_tolerance, 0.0001..=10.0)
165-
.logarithmic(true)
166-
.show_value(true)
167-
.text("Spline Tolerance"),
168-
);
169-
ui.collapsing("debug", |ui| {
164+
ui.horizontal(|ui| {
165+
ui.label("Spline tolerance");
166+
let speed = 0.01 * *bezier_tolerance;
167+
ui.add(
168+
crate::DragValue::new(bezier_tolerance).clamp_range(0.0001..=10.0)
169+
.speed(speed)
170+
);
171+
});
172+
173+
ui.add_enabled(epaint::HAS_RAYON, crate::Checkbox::new(parallel_tessellation, "Parallelize tessellation")
174+
).on_hover_text("Only available if epaint was compiled with the rayon feature")
175+
.on_disabled_hover_text("epaint was not compiled with the rayon feature");
176+
177+
ui.checkbox(validate_meshes, "Validate meshes").on_hover_text("Check that incoming meshes are valid, i.e. that all indices are in range, etc.");
178+
179+
ui.collapsing("Debug", |ui| {
170180
ui.checkbox(
171181
coarse_tessellation_culling,
172182
"Do coarse culling in the tessellator",
@@ -178,12 +188,6 @@ impl Widget for &mut epaint::TessellationOptions {
178188
ui.checkbox(debug_paint_clip_rects, "Paint clip rectangles");
179189
ui.checkbox(debug_paint_text_rects, "Paint text bounds");
180190
});
181-
182-
ui.add_enabled(epaint::HAS_RAYON, crate::Checkbox::new(parallel_tessellation, "Parallelize tessellation")
183-
).on_hover_text("Only available if epaint was compiled with the rayon feature")
184-
.on_disabled_hover_text("epaint was not compiled with the rayon feature");
185-
186-
ui.checkbox(validate_meshes, "Validate meshes").on_hover_text("Check that incoming meshes are valid, i.e. that all indices are in range, etc.");
187191
})
188192
.response
189193
}

crates/egui/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ pub use epaint::{
431431
text::{FontData, FontDefinitions, FontFamily, FontId, FontTweak},
432432
textures::{TextureFilter, TextureOptions, TextureWrapMode, TexturesDelta},
433433
ClippedPrimitive, ColorImage, FontImage, ImageData, Margin, Mesh, PaintCallback,
434-
PaintCallbackInfo, Rounding, Shape, Stroke, TextureHandle, TextureId,
434+
PaintCallbackInfo, Rounding, Shadow, Shape, Stroke, TextureHandle, TextureId,
435435
};
436436

437437
pub mod text {

crates/egui/src/memory.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -278,13 +278,15 @@ impl Options {
278278
});
279279

280280
CollapsingHeader::new("✒ Painting")
281-
.default_open(true)
281+
.default_open(false)
282282
.show(ui, |ui| {
283283
tessellation_options.ui(ui);
284-
ui.vertical_centered(|ui| crate::reset_button(ui, tessellation_options));
284+
ui.vertical_centered(|ui| {
285+
crate::reset_button(ui, tessellation_options, "Reset paint settings");
286+
});
285287
});
286288

287-
ui.vertical_centered(|ui| crate::reset_button(ui, self));
289+
ui.vertical_centered(|ui| crate::reset_button(ui, self, "Reset all"));
288290
}
289291
}
290292

0 commit comments

Comments
 (0)