LibGUI: Add on_segment_change handler to Breadcrumbbar

This allows programs to respond to any selection changes of the
Breadcrumbbar, not just ones made by clicking one of the buttons.
This commit is contained in:
Jannis Weis 2022-08-21 21:24:29 +02:00 committed by Andreas Kling
parent f86b671de2
commit a00fa793b3
Notes: sideshowbarker 2024-07-17 08:05:04 +09:00
2 changed files with 3 additions and 0 deletions

View File

@ -146,6 +146,8 @@ void Breadcrumbbar::set_selected_segment(Optional<size_t> index)
auto& segment = m_segments[index.value()];
VERIFY(segment.button);
segment.button->set_checked(true);
if (on_segment_change)
on_segment_change(index);
relayout();
}

View File

@ -29,6 +29,7 @@ public:
void set_selected_segment(Optional<size_t> index);
Optional<size_t> selected_segment() const { return m_selected_segment; }
Function<void(Optional<size_t> index)> on_segment_change;
Function<void(size_t index)> on_segment_click;
Function<void(size_t index, DropEvent&)> on_segment_drop;
Function<void(size_t index, DragEvent&)> on_segment_drag_enter;