From 85e12c45c0a468fa00dff682fc52207c4d05a76e Mon Sep 17 00:00:00 2001 From: tobid7 Date: Thu, 6 Mar 2025 20:22:13 +0100 Subject: [PATCH] # 0.2.7-1 **HOTFIX** - Fix nullptr->value access issue in UI7::Context - Add UI7MenuFlags_NoMove to disable window movement - Fix testapp to support the new DebugLabels standard --- include/pd/ui7/flags.hpp | 1 + include/pd/ui7/ui7.hpp | 2 +- source/ui7/menu.cpp | 36 +++++++++++++++++++----------------- source/ui7/ui7.cpp | 2 +- test/app/main.cpp | 4 ++-- 5 files changed, 24 insertions(+), 21 deletions(-) diff --git a/include/pd/ui7/flags.hpp b/include/pd/ui7/flags.hpp index 17779c9..e420ab8 100644 --- a/include/pd/ui7/flags.hpp +++ b/include/pd/ui7/flags.hpp @@ -38,6 +38,7 @@ enum UI7MenuFlags_ { UI7MenuFlags_NoBackground = 1 << 4, ///< Dont Render Menu Background UI7MenuFlags_NoClipRect = 1 << 5, ///< Disable clip render area of the Menu UI7MenuFlags_NoCollapse = 1 << 6, ///< Disable Menu Collapse + UI7MenuFlags_NoMove = 1 << 7, ///< Disable Window Movement // Enable Horizontal and Vertical Scrolling UI7MenuFlags_Scrolling = UI7MenuFlags_HzScrolling | UI7MenuFlags_VtScrolling, }; diff --git a/include/pd/ui7/ui7.hpp b/include/pd/ui7/ui7.hpp index 7c29ee4..bfe64be 100644 --- a/include/pd/ui7/ui7.hpp +++ b/include/pd/ui7/ui7.hpp @@ -36,7 +36,7 @@ SOFTWARE. * Major Minor Patch Build * 0x01010000 -> 1.1.0-0 */ -#define UI7_VERSION 0x00020700 +#define UI7_VERSION 0x00020701 namespace PD { namespace UI7 { diff --git a/source/ui7/menu.cpp b/source/ui7/menu.cpp index 07a4410..ff8aeb3 100644 --- a/source/ui7/menu.cpp +++ b/source/ui7/menu.cpp @@ -228,23 +228,25 @@ void UI7::Menu::PreHandler(UI7MenuFlags flags) { void UI7::Menu::PostHandler() { TT::Scope st("MPOS_" + name); - if (inp->IsDown(inp->Touch) && - LI::Renderer::InBox(inp->TouchPos(), - vec4(pos + vec2(18, 0), vec2(view_area.z(), tbh))) && - has_touch) { - mouse = inp->TouchPos(); - } else if (inp->IsUp(inp->Touch) && - LI::Renderer::InBox( - inp->TouchPos(), - vec4(pos + vec2(18, 0), vec2(view_area.z(), tbh))) && - has_touch) { - mouse = 0; - } else if (inp->IsHeld(inp->Touch) && - LI::Renderer::InBox( - inp->TouchPosLast(), - vec4(pos + vec2(18, 0), vec2(view_area.z(), tbh))) && - has_touch) { - pos = inp->TouchPos() - mouse; + if (!(flags & UI7MenuFlags_NoMove)) { + if (inp->IsDown(inp->Touch) && + LI::Renderer::InBox(inp->TouchPos(), vec4(pos + vec2(18, 0), + vec2(view_area.z(), tbh))) && + has_touch) { + mouse = inp->TouchPos(); + } else if (inp->IsUp(inp->Touch) && + LI::Renderer::InBox( + inp->TouchPos(), + vec4(pos + vec2(18, 0), vec2(view_area.z(), tbh))) && + has_touch) { + mouse = 0; + } else if (inp->IsHeld(inp->Touch) && + LI::Renderer::InBox( + inp->TouchPosLast(), + vec4(pos + vec2(18, 0), vec2(view_area.z(), tbh))) && + has_touch) { + pos = inp->TouchPos() - mouse; + } } if (scrolling[1]) { scroll_allowed[1] = (max[1] > 235); diff --git a/source/ui7/ui7.cpp b/source/ui7/ui7.cpp index fc0fa6a..90614bd 100644 --- a/source/ui7/ui7.cpp +++ b/source/ui7/ui7.cpp @@ -61,7 +61,7 @@ bool UI7::Context::BeginMenu(const ID& id, UI7MenuFlags flags) { if (!this->current->is_open) { this->current = nullptr; } - return this->current->is_open; + return this->current != nullptr; } UI7::Menu::Ref UI7::Context::GetCurrentMenu() { diff --git a/test/app/main.cpp b/test/app/main.cpp index 9847fea..fb85b67 100644 --- a/test/app/main.cpp +++ b/test/app/main.cpp @@ -57,7 +57,7 @@ class Test : public PD::App { UI7MenuFlags_Scrolling | UI7MenuFlags_CenterTitle)) { auto m = ui7->GetCurrentMenu(); m->SeparatorText("Menu Timings"); - m->DebugLabels(); + PD::UI7::Menu::DebugLabels(m); m->SeparatorText("Palladium Info"); m->PushAlignment(UI7Align_Center); m->Label("Version: " + PD::LibInfo::Version() + " [" + @@ -82,7 +82,7 @@ class Test : public PD::App { } m->SameLine(); if (m->Button("Palladium")) { - //sthis->FeatureDisable(AppFLags_UserLoop); + // sthis->FeatureDisable(AppFLags_UserLoop); Overlays()->Push(PD::New()); } m->SeparatorText("SeparatorText");