blob: 475d2d0a165b9d336629510bca7fe54e218052d9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#pragma once
#include "../Editor.h"
#include "cru/ui/components/Select.h"
#include "cru/ui/controls/FlexLayout.h"
#include "cru/ui/controls/TextBlock.h"
namespace cru::theme_builder::components::properties {
class SelectPropertyEditor : public Editor {
public:
using PropertyType = Index;
SelectPropertyEditor();
~SelectPropertyEditor() override;
public:
ui::controls::Control* GetRootControl() override { return &container_; }
String GetLabel() const { return label_.GetText(); }
void SetLabel(String label) { label_.SetText(std::move(label)); }
Index GetSelectedIndex() const { return select_.GetSelectedIndex(); }
void SetSelectedIndex(Index index, bool trigger_change = true) {
if (trigger_change == false) SuppressNextChangeEvent();
select_.SetSelectedIndex(index);
}
std::vector<String> GetItems() const { return select_.GetItems(); }
void SetItems(std::vector<String> items) {
select_.SetItems(std::move(items));
}
Index GetValue() const { return GetSelectedIndex(); }
void SetValue(Index value, bool trigger_change = true) {
SetSelectedIndex(value, trigger_change);
}
private:
ui::controls::FlexLayout container_;
ui::controls::TextBlock label_;
ui::components::Select select_;
};
} // namespace cru::theme_builder::components::properties
|