Forráskód Böngészése

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.
Jannis Weis 2 éve
szülő
commit
a00fa793b3

+ 2 - 0
Userland/Libraries/LibGUI/Breadcrumbbar.cpp

@@ -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();
 }
 

+ 1 - 0
Userland/Libraries/LibGUI/Breadcrumbbar.h

@@ -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;