Code editor demo: nice syntax highlighting with customizable theme

This commit is contained in:
Emil Ernerfeldt
2021-10-01 21:29:33 +02:00
parent 96557a4fa6
commit f0868c2f07
5 changed files with 202 additions and 71 deletions
+1 -1
View File
@@ -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()
+7 -3
View File
@@ -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;
}
}