aboutsummaryrefslogtreecommitdiff
path: root/include/gui/ComboBox.hpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-09-25 17:29:17 +0200
committerdec05eba <dec05eba@protonmail.com>2022-09-25 17:29:17 +0200
commit497217a3e09b577f650aaf503356588515067ca8 (patch)
tree2fd43b747957510c55d66caf81df30732c39c398 /include/gui/ComboBox.hpp
parent663a36df4aaea583e7cd56ad35b26d05f6151746 (diff)
widgets
Diffstat (limited to 'include/gui/ComboBox.hpp')
-rw-r--r--include/gui/ComboBox.hpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/include/gui/ComboBox.hpp b/include/gui/ComboBox.hpp
new file mode 100644
index 0000000..5c899a7
--- /dev/null
+++ b/include/gui/ComboBox.hpp
@@ -0,0 +1,36 @@
+#pragma once
+
+#include "Widget.hpp"
+#include <mglpp/graphics/Text.hpp>
+#include <string>
+#include <vector>
+
+namespace gsr {
+ class ComboBox : public Widget {
+ public:
+ ComboBox(mgl::Font *font);
+ ComboBox(const ComboBox&) = delete;
+ ComboBox& operator=(const ComboBox&) = delete;
+
+ bool on_event(mgl::Event &event, mgl::Window &window) override;
+ void draw(mgl::Window &window) override;
+
+ void add_item(const std::string &text, const std::string &id);
+
+ mgl::vec2f get_size();
+ private:
+ void update_if_dirty();
+ private:
+ struct Item {
+ mgl::Text text;
+ std::string id;
+ };
+
+ mgl::vec2f max_size;
+ mgl::Font *font;
+ std::vector<Item> items;
+ bool dirty = true;
+ bool show_dropdown = false;
+ size_t selected_item = 0;
+ };
+} \ No newline at end of file