gui updates

This commit is contained in:
IlyaShurupov 2024-06-24 22:21:10 +03:00
parent 05ac11b24c
commit b8f125b472
42 changed files with 1179 additions and 962 deletions

View file

@ -60,77 +60,22 @@ namespace tp {
using Parameter = WidgetConfig::Parameter;
public:
WidgetManager() { initGlobalParameters(); }
~WidgetManager() { mConfigurations.removeAll(); }
WidgetManager();
~WidgetManager();
const RGBA& getColor(const std::string& parameterId, const RGBA& defaultValue) {
WidgetConfig& config = getWidgetConfig(mActiveId);
Parameter& parameter = getParameter(config, parameterId, Parameter(defaultValue));
return parameter.color;
}
const RGBA& getColor(const std::string& parameterId, const RGBA& defaultValue);
const RGBA& getColor(const std::string& parameterId, const char* globalRef);
const RGBA& getColor(const std::string& parameterId, const char* globalRef) {
WidgetConfig& config = getWidgetConfig(mActiveId);
Parameter& parameter = getParameter(config, parameterId, Parameter(globalRef, Parameter::COL));
return parameter.color;
}
halnf getNumber(const std::string& parameterId, halnf defaultValue);
halnf getNumber(const std::string& parameterId, const char* globalRef);
halnf getNumber(const std::string& parameterId, halnf defaultValue) {
WidgetConfig& config = getWidgetConfig(mActiveId);
Parameter& parameter = getParameter(config, parameterId, Parameter(defaultValue));
return parameter.value;
}
halnf getNumber(const std::string& parameterId, const char* globalRef) {
WidgetConfig& config = getWidgetConfig(mActiveId);
Parameter& parameter = getParameter(config, parameterId, Parameter(globalRef, Parameter::VAL));
return parameter.value;
}
void setActiveId(const std::string& id) { mActiveId = id; }
void setActiveId(const std::string& id);
private:
WidgetConfig& getWidgetConfig(const std::string& id) {
auto idx = mConfigurations.presents(id);
if (idx) return mConfigurations.getSlotVal(idx);
mConfigurations.put(id, {});
return mConfigurations.get(id);
}
WidgetConfig& getWidgetConfig(const std::string& id);
Parameter& getParameter(WidgetConfig& config, const std::string& id, const Parameter& defaultValue);
Parameter& getParameter(WidgetConfig& config, const std::string& id, const Parameter& defaultValue) {
auto idx = config.mParameters.presents(id);
if (!idx) {
config.mParameters.put(id, defaultValue);
}
Parameter& parameter = config.mParameters.get(id);
if (parameter.globalReference) {
return mGlobalConfig.mParameters.get(parameter.globalId);
} else {
return parameter;
}
}
void initGlobalParameters() {
auto& params = mGlobalConfig.mParameters;
params.put("FontSize", Parameter(15.f));
params.put("FontSizeDim", Parameter(12.f));
params.put("Rounding", Parameter(5.f));
params.put("Padding", Parameter(5.f));
params.put("HandleSize", Parameter(5.f));
params.put("Background", Parameter(RGBA{ 0.03f, 0.03f, 0.03f, 1.f }));
params.put("Base", Parameter(RGBA{ 0.07f, 0.07f, 0.07f, 1.f }));
params.put("Accent", Parameter(RGBA{ 0.13f, 0.13f, 0.13f, 1.f }));
params.put("Interaction", Parameter(RGBA{ 0.33f, 0.33f, 0.3f, 1.f }));
params.put("Action", Parameter(RGBA{ 0.44f, 0.44f, 0.4f, 1.f }));
params.put("Front", Parameter(RGBA{ 1.f, 1.f, 1.f, 1.f }));
params.put("FrontDim", Parameter(RGBA{ 0.7f, 0.7f, 0.7f, 1.f }));
}
void initGlobalParameters();
private:
Map<std::string, WidgetConfig> mConfigurations;