summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2025-09-29 15:08:51 -0400
committerJonathan Bradley <jcb@pikum.xyz>2025-09-29 15:08:51 -0400
commit8b021376680ec055b387a53d23c316b8a4bc63f0 (patch)
tree033aa1f89a53370faaedb4b08b0e2eb7c84551f5
parent38118ca060f28749eb7be02c83b2e109cdb63b52 (diff)
PkeEditor: add ui text buttons + delete ui boxes
-rw-r--r--editor/editor.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/editor/editor.cpp b/editor/editor.cpp
index 2476f40..8445b3f 100644
--- a/editor/editor.cpp
+++ b/editor/editor.cpp
@@ -1359,6 +1359,7 @@ void RecordImGuiUITree_inner(pke_ui_box *box) {
}
void RecordImGuiUITree() {
pke_ui_box *box;
+ bool clicked = false;
static bool is_creating_new_box = false;
static bool is_child = false;
PKE_UI_BOX_TYPE type = PKE_UI_BOX_TYPE(-1);
@@ -1379,7 +1380,20 @@ void RecordImGuiUITree() {
is_creating_new_box = true;
is_child = true;
}
+ ImGui::SameLine();
+ ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, .2, .2, 1));
+ clicked = ImGui::Button("Delete");
+ ImGui::PopStyleColor();
ImGui::EndDisabled();
+ if (clicked) {
+ ECS_MarkForRemoval(selected_ui_box);
+ if (selected_ui_box->internal.parent == nullptr) {
+ pke_level_unregister_root_ui_box(pkeSettings.rt.activeLevel, selected_ui_box);
+ }
+ selected_ui_box = selected_ui_box->internal.parent;
+ ImGui::End();
+ return;
+ }
if (is_creating_new_box) {
ImGui::Text("Select Type:");
@@ -1390,6 +1404,9 @@ void RecordImGuiUITree() {
if (ImGui::Button("Text")) {
type = PKE_UI_BOX_TYPE_TEXT;
}
+ if (ImGui::Button("Button: Text")) {
+ type = PKE_UI_BOX_TYPE_BUTTON_TEXT;
+ }
if (ImGui::Button("Button: Image")) {
type = PKE_UI_BOX_TYPE_BUTTON_IMAGE;
}
@@ -1404,10 +1421,13 @@ void RecordImGuiUITree() {
box->flags |= PKE_UI_BOX_FLAG_CENTER_BOTH;
box->max_size = glm::vec2(.6, .6);
selected_ui_box = box;
+ FontRenderSettings frs{};
if (type == PKE_UI_BOX_TYPE_TEXT) {
- FontRenderSettings frs{};
box->type_data->text.font_render_handle = FontType_AddStringRender(FontTypeIndex(0), std::move(cstring_to_pk_cstr("")), &frs, box);
}
+ if (type == PKE_UI_BOX_TYPE_BUTTON_TEXT) {
+ box->type_data->button_text.font_render_handle = FontType_AddStringRender(FontTypeIndex(0), std::move(cstring_to_pk_cstr("")), &frs, box);
+ }
is_creating_new_box = false;
is_child = false;
type = PKE_UI_BOX_TYPE(-1);
@@ -1456,12 +1476,14 @@ void RecordImGuiUIEdit() {
ImGui::Text("Position Type:");
ImGui::BeginDisabled(PK_HAS_FLAG(selected_ui_box->flags, PKE_UI_BOX_FLAG_POSITION_TYPE_FLEX));
+ ImGui::BeginDisabled(selected_ui_box->internal.parent == nullptr);
if (ImGui::Button("Flex")) {
selected_ui_box->flags &= ~(const_cast<PKE_UI_BOX_FLAG&>(PKE_UI_BOX_FLAG_POSITION_TYPE_ALL));
selected_ui_box->flags |= PKE_UI_BOX_FLAG_POSITION_TYPE_FLEX;
changed = true;
}
ImGui::EndDisabled();
+ ImGui::EndDisabled();
ImGui::SameLine();
ImGui::BeginDisabled(PK_HAS_FLAG(selected_ui_box->flags, PKE_UI_BOX_FLAG_POSITION_TYPE_STATIC));
if (ImGui::Button("Static")) {
@@ -1496,7 +1518,9 @@ void RecordImGuiUIEdit() {
changed = ImGui::InputScalarN("pos_top_left", ImGuiDataType_Float, &selected_ui_box->pos_top_left, 2, nullptr, nullptr, nullptr, 0) || changed;
changed = ImGui::InputScalarN("min_size", ImGuiDataType_Float, &selected_ui_box->min_size, 2, nullptr, nullptr, nullptr, 0) || changed;
changed = ImGui::InputScalarN("max_size", ImGuiDataType_Float, &selected_ui_box->max_size, 2, nullptr, nullptr, nullptr, 0) || changed;
- changed = ImGui::InputScalarN("flex_weight", ImGuiDataType_Float, &selected_ui_box->flex_weight, 1, nullptr, nullptr, nullptr, 0) || changed;
+ if (PK_HAS_FLAG(selected_ui_box->flags, PKE_UI_BOX_FLAG_POSITION_TYPE_FLEX)) {
+ changed = ImGui::InputScalarN("flex_weight", ImGuiDataType_Float, &selected_ui_box->flex_weight, 1, nullptr, nullptr, nullptr, 0) || changed;
+ }
changed = ImGui::InputScalarN("flex_direction", ImGuiDataType_U8, &selected_ui_box->flex_direction, 1, nullptr, nullptr, nullptr, 0) || changed;
changed = ImGui::InputScalarN("layer", ImGuiDataType_U8, &selected_ui_box->layer, 1, nullptr, nullptr, nullptr, 0) || changed;
if (PK_HAS_FLAG(selected_ui_box->flags, PKE_UI_BOX_FLAG_VISIBILITY_INVISIBLE) == false) {