Add ui.set_enabled(false) to disable all widgets in a Ui

Closes https://github.com/emilk/egui/issues/50
This commit is contained in:
Emil Ernerfeldt
2021-02-07 10:55:45 +01:00
parent d07a17ac6a
commit bca722ddf8
20 changed files with 303 additions and 77 deletions
+10 -6
View File
@@ -51,20 +51,24 @@ pub fn drop_target<R>(
let style = if is_being_dragged && can_accept_what_is_being_dragged && response.hovered() {
ui.visuals().widgets.active
} else if is_being_dragged && can_accept_what_is_being_dragged {
ui.visuals().widgets.inactive
} else if is_being_dragged && !can_accept_what_is_being_dragged {
ui.visuals().widgets.disabled
} else {
ui.visuals().widgets.inactive
};
let mut fill = style.bg_fill;
let mut stroke = style.bg_stroke;
if is_being_dragged && !can_accept_what_is_being_dragged {
// gray out:
fill = color::tint_color_towards(fill, ui.visuals().window_fill());
stroke.color = color::tint_color_towards(stroke.color, ui.visuals().window_fill());
}
ui.painter().set(
where_to_put_background,
Shape::Rect {
corner_radius: style.corner_radius,
fill: style.bg_fill,
stroke: style.bg_stroke,
fill,
stroke,
rect,
},
);