add 'select' element (WIP)
This commit is contained in:
@@ -49,7 +49,7 @@ Button::Button(
|
||||
label = std::make_shared<Label>(gui, text);
|
||||
label->setAlign(Align::center);
|
||||
label->setSize(getContentSize());
|
||||
label->setInteractive(true);
|
||||
label->setInteractive(false);
|
||||
add(label);
|
||||
|
||||
setHoverColor({0.05f, 0.1f, 0.15f, 0.75f});
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#include "SelectBox.hpp"
|
||||
|
||||
#include "Label.hpp"
|
||||
|
||||
using namespace gui;
|
||||
|
||||
SelectBox::SelectBox(
|
||||
GUI& gui,
|
||||
std::vector<Element>&& elements,
|
||||
Element selected,
|
||||
int contentWidth,
|
||||
const glm::vec4& padding
|
||||
)
|
||||
: Button(gui, selected.text, padding, nullptr, glm::vec2(contentWidth, -1)),
|
||||
elements(std::move(elements)) {
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include "Button.hpp"
|
||||
|
||||
namespace gui {
|
||||
class Label;
|
||||
|
||||
class SelectBox : public Button {
|
||||
public:
|
||||
struct Element {
|
||||
std::string value;
|
||||
std::wstring text;
|
||||
};
|
||||
private:
|
||||
std::vector<Element> elements;
|
||||
Element selected {};
|
||||
public:
|
||||
SelectBox(
|
||||
GUI& gui,
|
||||
std::vector<Element>&& elements,
|
||||
Element selected,
|
||||
int contentWidth,
|
||||
const glm::vec4& padding
|
||||
);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user