This commit is contained in:
dec05eba
2022-09-25 17:29:17 +02:00
parent 663a36df4a
commit 497217a3e0
14 changed files with 609 additions and 393 deletions

36
include/gui/ComboBox.hpp Normal file
View File

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