tmp
This commit is contained in:
parent
86a41c1876
commit
e2072d257f
14 changed files with 594 additions and 341 deletions
|
|
@ -9,14 +9,7 @@ namespace tp {
|
|||
template <typename Events, typename Canvas>
|
||||
class TextInputWidget : public Widget<Events, Canvas> {
|
||||
public:
|
||||
TextInputWidget() {
|
||||
this->createConfig("TextInput");
|
||||
this->addColor("Accent", "Accent");
|
||||
this->addColor("Base", "Base");
|
||||
this->addValue("Rounding", "Rounding");
|
||||
this->addColor("Hovered", "Interaction");
|
||||
this->addValue("Padding", "Padding");
|
||||
}
|
||||
TextInputWidget() { this->mId = "TextInput"; }
|
||||
|
||||
void proc(const Events& events, const tp::RectF& areaParent, const tp::RectF& aArea) override {
|
||||
this->mArea = aArea;
|
||||
|
|
@ -29,8 +22,8 @@ namespace tp {
|
|||
|
||||
nChanged = false;
|
||||
|
||||
const auto col = this->getColor("Accent");
|
||||
const auto colSel = this->getColor("Hovered");
|
||||
const auto col = mAccentColor;
|
||||
const auto colSel = mHoveredColor;
|
||||
|
||||
ImGui::GetStyle().Colors[ImGuiCol_FrameBg] = { col.r, col.g, col.b, col.a };
|
||||
ImGui::GetStyle().Colors[ImGuiCol_TextSelectedBg] = { colSel.r, colSel.g, colSel.b, colSel.a };
|
||||
|
|
@ -38,8 +31,8 @@ namespace tp {
|
|||
ImGui::SetNextWindowPos({ this->mArea.x, this->mArea.y });
|
||||
ImGui::SetNextWindowSize({ this->mArea.z, this->mArea.w });
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, { 0, 0 });
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, this->getValue("Rounding") * 1.5f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, { this->getValue("Padding"), this->getValue("Padding") });
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, mRounding * 1.5f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, { mPadding, mPadding });
|
||||
|
||||
// ImGui::PushID((int) alni(this));
|
||||
ImGui::Begin(
|
||||
|
|
@ -65,11 +58,36 @@ namespace tp {
|
|||
ImGui::PopStyleVar(3);
|
||||
}
|
||||
|
||||
public:
|
||||
void setupConfig(WidgetManager& wm) {
|
||||
if (!wm.createWidgetConfig(this->mId)) return;
|
||||
wm.addReference(this->mId, "Accent", "Accent");
|
||||
wm.addReference(this->mId, "Base", "Base");
|
||||
wm.addReference(this->mId, "Rounding", "Rounding");
|
||||
wm.addReference(this->mId, "Hovered", "Accent");
|
||||
wm.addReference(this->mId, "Padding", "Padding");
|
||||
}
|
||||
|
||||
void updateConfigCache(const WidgetManager& wm) override {
|
||||
mAccentColor = wm.getColor(this->mId, "Accent");
|
||||
mBaseColor = wm.getColor(this->mId, "Base");
|
||||
mHoveredColor = wm.getColor(this->mId, "Hovered");
|
||||
mRounding = wm.getNumber(this->mId, "Rounding");
|
||||
mPadding = wm.getNumber(this->mId, "Padding");
|
||||
}
|
||||
|
||||
public:
|
||||
enum { mMaxBufferSize = 512 };
|
||||
char mBuff[mMaxBufferSize] = "";
|
||||
bool nChanged = false;
|
||||
std::string mValue;
|
||||
std::string mId = "id";
|
||||
bool mMultiline = false;
|
||||
|
||||
RGBA mAccentColor;
|
||||
RGBA mHoveredColor;
|
||||
RGBA mBaseColor;
|
||||
halnf mRounding = 0;
|
||||
halnf mPadding = 0;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue