Code editor demo: nice syntax highlighting with customizable theme
This commit is contained in:
@@ -23,7 +23,7 @@ impl Frame {
|
||||
/// For when you want to group a few widgets together within a frame.
|
||||
pub fn group(style: &Style) -> Self {
|
||||
Self {
|
||||
margin: Vec2::new(8.0, 6.0),
|
||||
margin: Vec2::splat(6.0), // symmetric looks best in corners when nesting
|
||||
corner_radius: style.visuals.widgets.noninteractive.corner_radius,
|
||||
stroke: style.visuals.widgets.noninteractive.bg_stroke,
|
||||
..Default::default()
|
||||
|
||||
@@ -81,12 +81,16 @@ where
|
||||
/// Show a button to reset a value to its default.
|
||||
/// The button is only enabled if the value does not already have its original value.
|
||||
pub fn reset_button<T: Default + PartialEq>(ui: &mut Ui, value: &mut T) {
|
||||
let def = T::default();
|
||||
reset_button_with(ui, value, T::default());
|
||||
}
|
||||
/// Show a button to reset a value to its default.
|
||||
/// The button is only enabled if the value does not already have its original value.
|
||||
pub fn reset_button_with<T: PartialEq>(ui: &mut Ui, value: &mut T, reset_value: T) {
|
||||
if ui
|
||||
.add(Button::new("Reset").enabled(*value != def))
|
||||
.add(Button::new("Reset").enabled(*value != reset_value))
|
||||
.clicked()
|
||||
{
|
||||
*value = def;
|
||||
*value = reset_value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user