gui updates
This commit is contained in:
parent
a55a5ec5cc
commit
4a557d7e5c
42 changed files with 1179 additions and 962 deletions
|
|
@ -2,64 +2,15 @@
|
|||
|
||||
#include "WidgetBase.hpp"
|
||||
|
||||
#include "imgui.h"
|
||||
#include "imgui_internal.h"
|
||||
|
||||
namespace tp {
|
||||
template <typename Events, typename Canvas>
|
||||
class TextInputWidget : public Widget<Events, Canvas> {
|
||||
class TextInputWidget : public Widget {
|
||||
public:
|
||||
TextInputWidget() = default;
|
||||
TextInputWidget();
|
||||
|
||||
void eventDraw(Canvas&) override {
|
||||
nChanged = false;
|
||||
|
||||
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 };
|
||||
|
||||
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, mRounding * 1.5f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, { mPadding, mPadding });
|
||||
|
||||
// ImGui::PushID((int) alni(this));
|
||||
ImGui::Begin(
|
||||
mId.c_str(),
|
||||
0,
|
||||
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoBackground |
|
||||
ImGuiWindowFlags_NoResize
|
||||
);
|
||||
|
||||
if (mMultiline) {
|
||||
if (ImGui::InputTextMultiline("input", mBuff, mMaxBufferSize, { this->mArea.z, this->mArea.w })) {
|
||||
mValue = mBuff;
|
||||
nChanged = true;
|
||||
}
|
||||
} else {
|
||||
if (ImGui::InputTextEx("input", mId.c_str(), mBuff, mMaxBufferSize, { this->mArea.z, this->mArea.w }, 0)) {
|
||||
mValue = mBuff;
|
||||
nChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
ImGui::PopStyleVar(3);
|
||||
}
|
||||
void eventDraw(Canvas&) override;
|
||||
|
||||
public:
|
||||
void eventUpdateConfiguration(WidgetManager& wm) override {
|
||||
wm.setActiveId("TextInput");
|
||||
|
||||
mAccentColor = wm.getColor("Accent", "Accent");
|
||||
mBaseColor = wm.getColor("Base", "Base");
|
||||
mRounding = wm.getNumber("Rounding", "Rounding");
|
||||
mHoveredColor = wm.getColor("Hovered", "Accent");
|
||||
mPadding = wm.getNumber("Padding", "Padding");
|
||||
}
|
||||
void eventUpdateConfiguration(WidgetManager& wm) override;
|
||||
|
||||
public:
|
||||
enum { mMaxBufferSize = 512 };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue