From a00fa793b37550a8b44122192346eeeb1d692bf9 Mon Sep 17 00:00:00 2001 From: Jannis Weis <31143295+weisJ@users.noreply.github.com> Date: Sun, 21 Aug 2022 21:24:29 +0200 Subject: [PATCH] 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. --- Userland/Libraries/LibGUI/Breadcrumbbar.cpp | 2 ++ Userland/Libraries/LibGUI/Breadcrumbbar.h | 1 + 2 files changed, 3 insertions(+) diff --git a/Userland/Libraries/LibGUI/Breadcrumbbar.cpp b/Userland/Libraries/LibGUI/Breadcrumbbar.cpp index dfec0624ec..57366b6e63 100644 --- a/Userland/Libraries/LibGUI/Breadcrumbbar.cpp +++ b/Userland/Libraries/LibGUI/Breadcrumbbar.cpp @@ -146,6 +146,8 @@ void Breadcrumbbar::set_selected_segment(Optional index) auto& segment = m_segments[index.value()]; VERIFY(segment.button); segment.button->set_checked(true); + if (on_segment_change) + on_segment_change(index); relayout(); } diff --git a/Userland/Libraries/LibGUI/Breadcrumbbar.h b/Userland/Libraries/LibGUI/Breadcrumbbar.h index 93515eada3..0f403b5332 100644 --- a/Userland/Libraries/LibGUI/Breadcrumbbar.h +++ b/Userland/Libraries/LibGUI/Breadcrumbbar.h @@ -29,6 +29,7 @@ public: void set_selected_segment(Optional index); Optional selected_segment() const { return m_selected_segment; } + Function index)> on_segment_change; Function on_segment_click; Function on_segment_drop; Function on_segment_drag_enter;