ini
This commit is contained in:
parent
f7f0d6e5be
commit
83d51d3e83
30 changed files with 1186 additions and 208 deletions
64
Widgets/public/WidgetBase.hpp
Normal file
64
Widgets/public/WidgetBase.hpp
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
#pragma once
|
||||
|
||||
#include "WidgetConfig.hpp"
|
||||
|
||||
namespace tp {
|
||||
|
||||
template <typename Events, typename Canvas>
|
||||
class Widget {
|
||||
public:
|
||||
Widget() = default;
|
||||
|
||||
[[nodiscard]] const RGBA& getColor(const String& name) const {
|
||||
const auto& node = cfg->values.get(name);
|
||||
if (node.type == WidgetConfig::Node::REF) {
|
||||
return globalCfg->configs.get(node.refGroup).values.get(node.refName).color;
|
||||
}
|
||||
return cfg->values.get(name).color;
|
||||
}
|
||||
|
||||
[[nodiscard]] halnf getValue(const String& name) const {
|
||||
const auto& node = cfg->values.get(name);
|
||||
if (node.type == WidgetConfig::Node::REF) {
|
||||
return globalCfg->configs.get(node.refGroup).values.get(node.refName).value;
|
||||
}
|
||||
return cfg->values.get(name).value;
|
||||
}
|
||||
|
||||
void addColor(const String& name, const RGBA& val) { cfg->values.put(name, WidgetConfig::Node(val)); }
|
||||
void addValue(const String& name, halnf val) { cfg->values.put(name, WidgetConfig::Node(val)); }
|
||||
|
||||
void addColor(const String& name, const String& presetName) {
|
||||
cfg->values.put(name, WidgetConfig::Node(presetName));
|
||||
}
|
||||
void addValue(const String& name, const String& presetName) {
|
||||
cfg->values.put(name, WidgetConfig::Node(presetName));
|
||||
}
|
||||
|
||||
void createConfig(const String& name) {
|
||||
globalCfg->configs.put(name, {});
|
||||
cfg = &globalCfg->configs.get(name);
|
||||
}
|
||||
|
||||
virtual void proc(const Events& events, const tp::RectF& areaParent, const tp::RectF& aArea) {
|
||||
mVisible = areaParent.isOverlap(aArea);
|
||||
if (!mVisible) {
|
||||
return;
|
||||
}
|
||||
|
||||
this->mArea = aArea;
|
||||
}
|
||||
|
||||
virtual void draw(Canvas& canvas) const {
|
||||
if (!mVisible) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
GlobalGUIConfig* globalCfg = gGlobalGUIConfig;
|
||||
WidgetConfig* cfg = nullptr;
|
||||
RectF mArea;
|
||||
bool mVisible = false;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue