Skip to content

Commit

Permalink
Improve the UI for changing the egui theme (#4257)
Browse files Browse the repository at this point in the history
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">
  • Loading branch information
emilk authored Mar 28, 2024
1 parent e183655 commit 3dba73e
Show file tree
Hide file tree
Showing 23 changed files with 633 additions and 332 deletions.
1 change: 1 addition & 0 deletions crates/egui/src/containers/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ use epaint::*;
/// Note that you cannot change the margins after calling `begin`.
#[doc(alias = "border")]
#[derive(Clone, Copy, Debug, Default, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[must_use = "You should call .show()"]
pub struct Frame {
/// Margin within the painted frame.
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1567,7 +1567,7 @@ impl Context {

/// The [`Style`] used by all new windows, panels etc.
///
/// You can also change this using [`Self::style_mut]`
/// You can also change this using [`Self::style_mut`]
///
/// You can use [`Ui::style_mut`] to change the style of a single [`Ui`].
pub fn set_style(&self, style: impl Into<Arc<Style>>) {
Expand Down
44 changes: 24 additions & 20 deletions crates/egui/src/introspection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,23 +150,33 @@ impl Widget for &mut epaint::TessellationOptions {
validate_meshes,
} = self;

ui.checkbox(feathering, "Feathering (antialias)")
.on_hover_text("Apply feathering to smooth out the edges of shapes. Turn off for small performance gain.");
let feathering_slider = crate::Slider::new(feathering_size_in_pixels, 0.0..=10.0)
.smallest_positive(0.1)
.logarithmic(true)
.text("Feathering size in pixels");
ui.add_enabled(*feathering, feathering_slider);
ui.horizontal(|ui| {
ui.checkbox(feathering, "Feathering (antialias)")
.on_hover_text("Apply feathering to smooth out the edges of shapes. Turn off for small performance gain.");

if *feathering {
ui.add(crate::DragValue::new(feathering_size_in_pixels).clamp_range(0.0..=10.0).speed(0.1).suffix(" px"));
}
});

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

ui.add(
crate::widgets::Slider::new(bezier_tolerance, 0.0001..=10.0)
.logarithmic(true)
.show_value(true)
.text("Spline Tolerance"),
);
ui.collapsing("debug", |ui| {
ui.horizontal(|ui| {
ui.label("Spline tolerance");
let speed = 0.01 * *bezier_tolerance;
ui.add(
crate::DragValue::new(bezier_tolerance).clamp_range(0.0001..=10.0)
.speed(speed)
);
});

ui.add_enabled(epaint::HAS_RAYON, crate::Checkbox::new(parallel_tessellation, "Parallelize tessellation")
).on_hover_text("Only available if epaint was compiled with the rayon feature")
.on_disabled_hover_text("epaint was not compiled with the rayon feature");

ui.checkbox(validate_meshes, "Validate meshes").on_hover_text("Check that incoming meshes are valid, i.e. that all indices are in range, etc.");

ui.collapsing("Debug", |ui| {
ui.checkbox(
coarse_tessellation_culling,
"Do coarse culling in the tessellator",
Expand All @@ -178,12 +188,6 @@ impl Widget for &mut epaint::TessellationOptions {
ui.checkbox(debug_paint_clip_rects, "Paint clip rectangles");
ui.checkbox(debug_paint_text_rects, "Paint text bounds");
});

ui.add_enabled(epaint::HAS_RAYON, crate::Checkbox::new(parallel_tessellation, "Parallelize tessellation")
).on_hover_text("Only available if epaint was compiled with the rayon feature")
.on_disabled_hover_text("epaint was not compiled with the rayon feature");

ui.checkbox(validate_meshes, "Validate meshes").on_hover_text("Check that incoming meshes are valid, i.e. that all indices are in range, etc.");
})
.response
}
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ pub use epaint::{
text::{FontData, FontDefinitions, FontFamily, FontId, FontTweak},
textures::{TextureFilter, TextureOptions, TextureWrapMode, TexturesDelta},
ClippedPrimitive, ColorImage, FontImage, ImageData, Margin, Mesh, PaintCallback,
PaintCallbackInfo, Rounding, Shape, Stroke, TextureHandle, TextureId,
PaintCallbackInfo, Rounding, Shadow, Shape, Stroke, TextureHandle, TextureId,
};

pub mod text {
Expand Down
8 changes: 5 additions & 3 deletions crates/egui/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,15 @@ impl Options {
});

CollapsingHeader::new("✒ Painting")
.default_open(true)
.default_open(false)
.show(ui, |ui| {
tessellation_options.ui(ui);
ui.vertical_centered(|ui| crate::reset_button(ui, tessellation_options));
ui.vertical_centered(|ui| {
crate::reset_button(ui, tessellation_options, "Reset paint settings");
});
});

ui.vertical_centered(|ui| crate::reset_button(ui, self));
ui.vertical_centered(|ui| crate::reset_button(ui, self, "Reset all"));
}
}

Expand Down
Loading

0 comments on commit 3dba73e

Please sign in to comment.