1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-01 22:30:03 -04:00

Only lay out the active tab

This commit is contained in:
Emil Ernerfeldt
2023-05-02 18:11:33 +02:00
parent fa69d7a22b
commit f8ce589fd5
2 changed files with 26 additions and 18 deletions

View File

@@ -168,6 +168,7 @@ pub trait Behavior<Leaf> {
id: Id,
node_id: NodeId,
selected: bool,
is_being_dragged: bool,
) -> Response {
let text = self.tab_text_for_node(nodes, node_id);
let font_id = TextStyle::Button.resolve(ui.style());
@@ -175,8 +176,16 @@ pub trait Behavior<Leaf> {
let (_, rect) = ui.allocate_space(galley.size());
let response = ui.interact(rect, id, Sense::click_and_drag());
let widget_style = ui.style().interact_selectable(&response, selected);
ui.painter()
.galley_with_color(rect.min, galley.galley, widget_style.text_color());
// Show a gap when dragged
if ui.is_rect_visible(rect) && !is_being_dragged {
if selected {
ui.painter().rect_filled(rect, 0.0, widget_style.bg_fill);
}
ui.painter()
.galley_with_color(rect.min, galley.galley, widget_style.text_color());
}
response
}