summaryrefslogtreecommitdiff
path: root/Libraries/LibGUI/GSpinBox.h
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-07-04 16:16:50 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-07-04 16:16:50 +0200
commit04b9dc2d30cfc9b383029f6a4b02e2725108b0ae (patch)
treee117a998173b767f9fd009d49c4f8573d8b85432 /Libraries/LibGUI/GSpinBox.h
parent63814ffebf16291419745cd8ba29a4d2fd888563 (diff)
downloadserenity-04b9dc2d30cfc9b383029f6a4b02e2725108b0ae.zip
Libraries: Create top level directory for libraries.
Things were getting a little crowded in the project root, so this patch moves the Lib*/ directories into Libraries/.
Diffstat (limited to 'Libraries/LibGUI/GSpinBox.h')
-rw-r--r--Libraries/LibGUI/GSpinBox.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/Libraries/LibGUI/GSpinBox.h b/Libraries/LibGUI/GSpinBox.h
new file mode 100644
index 0000000000..c32e1d697d
--- /dev/null
+++ b/Libraries/LibGUI/GSpinBox.h
@@ -0,0 +1,37 @@
+#pragma once
+
+#include <LibGUI/GWidget.h>
+
+class GButton;
+class GTextEditor;
+
+class GSpinBox : public GWidget {
+public:
+ GSpinBox(GWidget* parent = nullptr);
+ virtual ~GSpinBox() override;
+
+ int value() const { return m_value; }
+ void set_value(int);
+
+ int min() const { return m_min; }
+ int max() const { return m_max; }
+ void set_min(int min) { set_range(min, max()); }
+ void set_max(int max) { set_range(min(), max); }
+ void set_range(int min, int max);
+
+ Function<void(int value)> on_change;
+
+ virtual const char* class_name() const override { return "GSpinBox"; }
+
+protected:
+ virtual void resize_event(GResizeEvent&) override;
+
+private:
+ GTextEditor* m_editor { nullptr };
+ GButton* m_increment_button { nullptr };
+ GButton* m_decrement_button { nullptr };
+
+ int m_min { 0 };
+ int m_max { 100 };
+ int m_value { 0 };
+};