summaryrefslogtreecommitdiff
path: root/libs/widgets/widgets/searchbar.h
diff options
context:
space:
mode:
Diffstat (limited to 'libs/widgets/widgets/searchbar.h')
-rw-r--r--libs/widgets/widgets/searchbar.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/libs/widgets/widgets/searchbar.h b/libs/widgets/widgets/searchbar.h
new file mode 100644
index 0000000000..2b3957f38f
--- /dev/null
+++ b/libs/widgets/widgets/searchbar.h
@@ -0,0 +1,40 @@
+#pragma once
+
+#include <gtkmm/entry.h>
+#include <string>
+
+#include "widgets/visibility.h"
+
+namespace ArdourWidgets {
+
+class LIBWIDGETS_API SearchBar : public Gtk::Entry
+{
+public:
+ SearchBar (
+ const std::string& placeholder_text = "Search...",
+ bool icon_click_resets = true);
+
+ /** resets the searchbar to the initial state */
+ void reset ();
+
+ /* emitted when the filter has been updated */
+ sigc::signal<void, const std::string&> signal_search_string_updated () { return sig_search_string_updated; }
+
+protected:
+ bool focus_in_event (GdkEventFocus*);
+ bool focus_out_event (GdkEventFocus*);
+
+ bool key_press_event (GdkEventKey*);
+ void icon_clicked_event (Gtk::EntryIconPosition, const GdkEventButton*);
+
+ const std::string placeholder_text;
+ sigc::signal<void, const std::string&> sig_search_string_updated;
+
+private:
+ void search_string_changed () const;
+
+ Glib::RefPtr<Gdk::Pixbuf> icon;
+ bool icon_click_resets;
+};
+
+} /* end namespace */