From 55d99cd90c2ad0512df6511be3e91ca8509e9929 Mon Sep 17 00:00:00 2001 From: aiekick Date: Sun, 21 Jul 2024 23:36:25 +0200 Subject: [PATCH] [FIX] : fix the display of error/warning pane --- 3rdparty/SoGLSL | 2 +- src/Backends/MainBackend.h | 4 +- src/Gui/MainFrame.cpp | 2 +- src/Gui/MainToolBar.cpp | 155 +++++++------- src/Headers/NoodlesPlateBuild.h | 4 +- src/Panes/ConfigSwitcherPane.cpp | 2 +- src/Panes/ConfigSwitcherPane.h | 2 +- src/Panes/MessagePane.cpp | 355 ++++++++++++++----------------- 8 files changed, 251 insertions(+), 275 deletions(-) diff --git a/3rdparty/SoGLSL b/3rdparty/SoGLSL index d224d4f..728c0a7 160000 --- a/3rdparty/SoGLSL +++ b/3rdparty/SoGLSL @@ -1 +1 @@ -Subproject commit d224d4ff821ff7676a3a62d826a1b13dbbecd047 +Subproject commit 728c0a7d3a3a61a4aec826d67b7f1d39ef808600 diff --git a/src/Backends/MainBackend.h b/src/Backends/MainBackend.h index bd00a59..b45ce09 100644 --- a/src/Backends/MainBackend.h +++ b/src/Backends/MainBackend.h @@ -21,8 +21,8 @@ #include #include #include -#include -#include +#include +#include #include #include diff --git a/src/Gui/MainFrame.cpp b/src/Gui/MainFrame.cpp index aae77f9..dbdb70a 100644 --- a/src/Gui/MainFrame.cpp +++ b/src/Gui/MainFrame.cpp @@ -264,7 +264,7 @@ void MainFrame::Display(ct::ivec2 vSize) { SettingsDlg::Instance()->DrawDialog(); VersionSystem::Instance()->DrawNewVersionDialog(); ShadertoyBackupFileImportDlg::Instance()->DrawDialog(); - LayoutManager::Instance()->DrawDialogsAndPopups(0U, size); + LayoutManager::Instance()->DrawDialogsAndPopups(0U, ImRect(ImVec2(), size)); DrawErrorDialog(); DoAbout(); diff --git a/src/Gui/MainToolBar.cpp b/src/Gui/MainToolBar.cpp index 26387e0..23a0b4d 100644 --- a/src/Gui/MainToolBar.cpp +++ b/src/Gui/MainToolBar.cpp @@ -4,7 +4,7 @@ // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -54,12 +54,12 @@ static const float& font_scale_ratio = 1.0f / 3.5f; bool MainToolBar::Init() { static ImFontConfig icons_config3; - icons_config3.MergeMode = false; - icons_config3.PixelSnapH = true; + icons_config3.MergeMode = false; + icons_config3.PixelSnapH = true; static const ImWchar icons_ranges3[] = {ICON_MIN_NDPTB, ICON_MAX_NDPTB, 0}; - const float& font_size = 20.0f / font_scale_ratio; - MainToolBar::puFont = ImGui::GetIO().Fonts->AddFontFromMemoryCompressedBase85TTF(FONT_ICON_BUFFER_NAME_NDPTB, font_size, &icons_config3, icons_ranges3); - MainToolBar::puFont->Scale = font_scale_ratio; + const float& font_size = 20.0f / font_scale_ratio; + MainToolBar::puFont = ImGui::GetIO().Fonts->AddFontFromMemoryCompressedBase85TTF(FONT_ICON_BUFFER_NAME_NDPTB, font_size, &icons_config3, icons_ranges3); + MainToolBar::puFont->Scale = font_scale_ratio; return (MainToolBar::puFont != nullptr); } @@ -72,11 +72,11 @@ void MainToolBar::DrawCoolBar() { const float& toolbar_width = 35.0f; static ImGui::ImCoolBarConfig _config; - _config.normal_size = 30.0f; + _config.normal_size = 30.0f; _config.hovered_size = 75.0f; - _config.anchor = ImVec2(0.0f, 0.5f); - _config.anim_step = 0.2f; - + _config.anchor = ImVec2(0.0f, 0.5f); + _config.anim_step = 0.2f; + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2()); bool left_bar_opened = ImGui::BeginLeftToolBar(toolbar_width); ImGui::PopStyleVar(); @@ -85,27 +85,27 @@ void MainToolBar::DrawCoolBar() { ImGui::SetNextWindowViewport(ImGui::GetMainViewport()->ID); ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2()); - bool _opened = ImGui::BeginCoolBar("##coolbar", ImCoolBarFlags_Vertical, _config); - auto window = ImGui::GetCurrentWindow(); + bool _opened = ImGui::BeginCoolBar("##coolbar", ImCoolBarFlags_Vertical, _config); + auto window = ImGui::GetCurrentWindow(); if (window) { // correct the rect of the window. maybe a bug on imgui.. - // the workrect can cause issue when clikc a timeline + // the workrect can cause issue when clikc a timeline // channel close button when close to the toolbar // this thing correct the issue - const auto& rc = window->Rect(); - window->WorkRect = rc; - window->OuterRectClipped = rc; - window->InnerRect = rc; - window->InnerClipRect = rc; - window->ParentWorkRect = rc; - window->ClipRect = rc; + const auto& rc = window->Rect(); + window->WorkRect = rc; + window->OuterRectClipped = rc; + window->InnerRect = rc; + window->InnerClipRect = rc; + window->ParentWorkRect = rc; + window->ClipRect = rc; window->ContentRegionRect = rc; } ImGui::PopStyleVar(2); if (_opened) { if (ImGui::CoolBarItem()) { - const auto aw = ImGui::GetCoolBarItemWidth(); + const auto aw = ImGui::GetCoolBarItemWidth(); const auto colBtn = ImGui::ColorButton("##BackGround", MainBackend::Instance()->puBackgroundColor, 0, ImVec2(aw, aw)); if (colBtn) { // Store current color and open a picker @@ -118,10 +118,12 @@ void MainToolBar::DrawCoolBar() { } if (ImGui::BeginPopup("picker")) { - const auto picker_flags_to_forward = ImGuiColorEditFlags_DataTypeMask_ | ImGuiColorEditFlags_PickerMask_ | ImGuiColorEditFlags_InputMask_ | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaBar; - const auto picker_flags = (0 & picker_flags_to_forward) | ImGuiColorEditFlags_DisplayMask_ | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_AlphaPreviewHalf; - auto& g = *GImGui; - NeedOneFrameUpdate = ImGui::ColorPicker4("##picker", &MainBackend::Instance()->puBackgroundColor.x, picker_flags, &g.ColorPickerRef.x); + const auto picker_flags_to_forward = ImGuiColorEditFlags_DataTypeMask_ | ImGuiColorEditFlags_PickerMask_ | ImGuiColorEditFlags_InputMask_ | + ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaBar; + const auto picker_flags = + (0 & picker_flags_to_forward) | ImGuiColorEditFlags_DisplayMask_ | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_AlphaPreviewHalf; + auto& g = *GImGui; + NeedOneFrameUpdate = ImGui::ColorPicker4("##picker", &MainBackend::Instance()->puBackgroundColor.x, picker_flags, &g.ColorPickerRef.x); ImGui::EndPopup(); } } @@ -138,21 +140,21 @@ void MainToolBar::DrawCoolBar() { */ if (ImGui::CoolBarItem()) { - const auto aw = ImGui::GetCoolBarItemWidth(); + const auto aw = ImGui::GetCoolBarItemWidth(); MainToolBar::puFont->Scale = font_scale_ratio * ImGui::GetCoolBarItemScale(); ImGui::RadioButtonLabeled_BitWize(ImVec2(aw, aw), - ICON_NDPTB_VIEW_LIST "##Config", - "Config", - &LayoutManager::Instance()->pane_Shown, - ConfigPane::Instance()->GetFlag(), - false, - true, - 0, - false, - MainToolBar::puFont); + ICON_NDPTB_VIEW_LIST "##Config", + "Config", + &LayoutManager::Instance()->pane_Shown, + ConfigPane::Instance()->GetFlag(), + false, + true, + 0, + false, + MainToolBar::puFont); } if (ImGui::CoolBarItem()) { - const auto aw = ImGui::GetCoolBarItemWidth(); + const auto aw = ImGui::GetCoolBarItemWidth(); MainToolBar::puFont->Scale = font_scale_ratio * ImGui::GetCoolBarItemScale(); ImGui::RadioButtonLabeled_BitWize(ImVec2(aw, aw), ICON_NDPTB_TUNE "##Uniforms", @@ -167,7 +169,7 @@ void MainToolBar::DrawCoolBar() { } if (ImGui::CoolBarItem()) { - const auto aw = ImGui::GetCoolBarItemWidth(); + const auto aw = ImGui::GetCoolBarItemWidth(); MainToolBar::puFont->Scale = font_scale_ratio * ImGui::GetCoolBarItemScale(); ImGui::RadioButtonLabeled_BitWize(ImVec2(aw, aw), ICON_NDPTB_VECTOR_CURVE "##TimeLine", @@ -178,10 +180,10 @@ void MainToolBar::DrawCoolBar() { true, 0, false, - MainToolBar::puFont); + MainToolBar::puFont); } if (ImGui::CoolBarItem()) { - const auto aw = ImGui::GetCoolBarItemWidth(); + const auto aw = ImGui::GetCoolBarItemWidth(); MainToolBar::puFont->Scale = font_scale_ratio * ImGui::GetCoolBarItemScale(); ImGui::RadioButtonLabeled_BitWize(ImVec2(aw, aw), ICON_NDPTB_LAYERS_TRIPLE "##TuningSwitcher", @@ -191,12 +193,13 @@ void MainToolBar::DrawCoolBar() { false, true, 0, - false, MainToolBar::puFont); + false, + MainToolBar::puFont); } // #ifdef _DEBUG if (ImGui::CoolBarItem()) { - const auto aw = ImGui::GetCoolBarItemWidth(); + const auto aw = ImGui::GetCoolBarItemWidth(); MainToolBar::puFont->Scale = font_scale_ratio * ImGui::GetCoolBarItemScale(); ImGui::RadioButtonLabeled_BitWize(ImVec2(aw, aw), ICON_NDPTB_FILE_DOCUMENT_EDIT "##Code", @@ -212,10 +215,10 @@ void MainToolBar::DrawCoolBar() { // #endif if (ImGui::CoolBarItem()) { - const auto aw = ImGui::GetCoolBarItemWidth(); + const auto aw = ImGui::GetCoolBarItemWidth(); MainToolBar::puFont->Scale = font_scale_ratio * ImGui::GetCoolBarItemScale(); ImGui::RadioButtonLabeled_BitWize(ImVec2(aw, aw), - ICON_NDPTB_FILE_DOCUMENT_BOX "##Notes", + ICON_NDPTB_FILE_DOCUMENT "##Notes", "Notes", &LayoutManager::Instance()->pane_Shown, InfosPane::Instance()->GetFlag(), @@ -228,7 +231,7 @@ void MainToolBar::DrawCoolBar() { #ifdef USE_HELP_IN_APP if (ImGui::CoolBarItem()) { - const auto aw = ImGui::GetCoolBarItemWidth(); + const auto aw = ImGui::GetCoolBarItemWidth(); MainToolBar::puFont->Scale = font_scale_ratio * ImGui::GetCoolBarItemScale(); ImGui::RadioButtonLabeled_BitWize(ImVec2(aw, aw), ICON_NDPTB_COMMENT_QUESTION "##Help", @@ -244,7 +247,7 @@ void MainToolBar::DrawCoolBar() { #endif if (ImGui::CoolBarItem()) { - const auto aw = ImGui::GetCoolBarItemWidth(); + const auto aw = ImGui::GetCoolBarItemWidth(); MainToolBar::puFont->Scale = font_scale_ratio * ImGui::GetCoolBarItemScale(); ImGui::RadioButtonLabeled_BitWize(ImVec2(aw, aw), ICON_NDPTB_CLIPBOARD_PULSE "##Profiler", @@ -255,7 +258,7 @@ void MainToolBar::DrawCoolBar() { true, 0, false, - MainToolBar::puFont); + MainToolBar::puFont); } #ifdef USE_GPU_METRIC @@ -263,9 +266,9 @@ void MainToolBar::DrawCoolBar() { ImVec2 lp, np; static bool s_ShowMetricInToolBar = false; if (ImGui::CoolBarItem()) { - const auto aw = ImGui::GetCoolBarItemWidth(); + const auto aw = ImGui::GetCoolBarItemWidth(); MainToolBar::puFont->Scale = font_scale_ratio * ImGui::GetCoolBarItemScale(); - lp = ImGui::GetCursorScreenPos(); + lp = ImGui::GetCursorScreenPos(); ImGui::RadioButtonLabeled(ImVec2(aw, aw), ICON_NDPTB_THERMOMETER "##Metrics", "Metrics (GPU 0)", &s_ShowMetricInToolBar, false, MainToolBar::puFont); np = ImGui::GetCursorScreenPos(); } @@ -279,10 +282,10 @@ void MainToolBar::DrawCoolBar() { #ifdef _DEBUG if (ImGui::CoolBarItem()) { - const auto aw = ImGui::GetCoolBarItemWidth(); + const auto aw = ImGui::GetCoolBarItemWidth(); MainToolBar::puFont->Scale = font_scale_ratio * ImGui::GetCoolBarItemScale(); ImGui::RadioButtonLabeled_BitWize(ImVec2(aw, aw), - ICON_NDPTB_ATOM_VARIANT "##Inspector", + ICON_NDPTB_ORBIT "##Inspector", "Inspector", &LayoutManager::Instance()->pane_Shown, InspectorPane::Instance()->GetFlag(), @@ -290,11 +293,11 @@ void MainToolBar::DrawCoolBar() { true, 0, false, - MainToolBar::puFont); + MainToolBar::puFont); } #endif if (ImGui::CoolBarItem()) { - const auto aw = ImGui::GetCoolBarItemWidth(); + const auto aw = ImGui::GetCoolBarItemWidth(); MainToolBar::puFont->Scale = font_scale_ratio * ImGui::GetCoolBarItemScale(); ImGui::RadioButtonLabeled_BitWize(ImVec2(aw, aw), ICON_NDPTB_VIEW_GRID "##BufferPreview", @@ -305,11 +308,11 @@ void MainToolBar::DrawCoolBar() { true, 0, false, - MainToolBar::puFont); + MainToolBar::puFont); } if (ImGui::CoolBarItem()) { - const auto aw = ImGui::GetCoolBarItemWidth(); + const auto aw = ImGui::GetCoolBarItemWidth(); MainToolBar::puFont->Scale = font_scale_ratio * ImGui::GetCoolBarItemScale(); ImGui::RadioButtonLabeled_BitWize(ImVec2(aw, aw), ICON_NDPTB_COMMENT_TEXT_MULTIPLE "##Console", @@ -320,29 +323,28 @@ void MainToolBar::DrawCoolBar() { true, 0, false, - MainToolBar::puFont); + MainToolBar::puFont); } MessagePane::Instance()->DrawToolBarButtons(0.0f, MainToolBar::puFont); if (ImGui::CoolBarItem()) { - const auto aw = ImGui::GetCoolBarItemWidth(); + const auto aw = ImGui::GetCoolBarItemWidth(); MainToolBar::puFont->Scale = font_scale_ratio * ImGui::GetCoolBarItemScale(); - NeedOneFrameUpdate |= ImGui::RadioButtonLabeled(ImVec2(aw, aw), ICON_NDPTB_GRID "##3DSpace", "3D Space", - &MainBackend::Instance()->puShow3DSpace, false, MainToolBar::puFont); + NeedOneFrameUpdate |= ImGui::RadioButtonLabeled( + ImVec2(aw, aw), ICON_NDPTB_GRID "##3DSpace", "3D Space", &MainBackend::Instance()->puShow3DSpace, false, MainToolBar::puFont); } if (ImGui::CoolBarItem()) { - const auto aw = ImGui::GetCoolBarItemWidth(); + const auto aw = ImGui::GetCoolBarItemWidth(); MainToolBar::puFont->Scale = font_scale_ratio * ImGui::GetCoolBarItemScale(); - NeedOneFrameUpdate |= - ImGui::RadioButtonLabeled(ImVec2(aw, aw), ICON_NDPTB_CUBE_OUTLINE "##3DMesh", "Mesh", &MainBackend::Instance()->puShowMesh, - false, MainToolBar::puFont); + NeedOneFrameUpdate |= ImGui::RadioButtonLabeled( + ImVec2(aw, aw), ICON_NDPTB_CUBE_OUTLINE "##3DMesh", "Mesh", &MainBackend::Instance()->puShowMesh, false, MainToolBar::puFont); } #ifdef USE_VR if (ImGui::CoolBarItem()) { - const auto aw = ImGui::GetCoolBarItemWidth(); + const auto aw = ImGui::GetCoolBarItemWidth(); MainToolBar::puFont->Scale = font_scale_ratio * ImGui::GetCoolBarItemScale(); if (ImGui::RadioButtonLabeled(ImVec2(aw, aw), ICON_NDPTB_GOOGLE_CARDBOARD "##VR", "Vr", VRBackend::Instance()->IsLoaded(), false, MainToolBar::puFont)) { MainBackend::Instance()->StartOrStopVR(); @@ -350,38 +352,41 @@ void MainToolBar::DrawCoolBar() { } #endif if (ImGui::CoolBarItem()) { - const auto aw = ImGui::GetCoolBarItemWidth(); + const auto aw = ImGui::GetCoolBarItemWidth(); MainToolBar::puFont->Scale = font_scale_ratio * ImGui::GetCoolBarItemScale(); - NeedOneFrameUpdate |= ImGui::RadioButtonLabeled(ImVec2(aw, aw), ICON_NDPTB_CAMCORDER "##Camera", "Camera", - &MainBackend::Instance()->puCanWeTuneCamera, false, MainToolBar::puFont); + NeedOneFrameUpdate |= ImGui::RadioButtonLabeled( + ImVec2(aw, aw), ICON_NDPTB_CAMCORDER "##Camera", "Camera", &MainBackend::Instance()->puCanWeTuneCamera, false, MainToolBar::puFont); } if (ImGui::CoolBarItem()) { - const auto aw = ImGui::GetCoolBarItemWidth(); + const auto aw = ImGui::GetCoolBarItemWidth(); MainToolBar::puFont->Scale = font_scale_ratio * ImGui::GetCoolBarItemScale(); - NeedOneFrameUpdate |= ImGui::RadioButtonLabeled(ImVec2(aw, aw), ICON_NDPTB_MOUSE "##Mouse", "Mouse", - &MainBackend::Instance()->puCanWeTuneMouse, false, MainToolBar::puFont); + NeedOneFrameUpdate |= ImGui::RadioButtonLabeled( + ImVec2(aw, aw), ICON_NDPTB_MOUSE "##Mouse", "Mouse", &MainBackend::Instance()->puCanWeTuneMouse, false, MainToolBar::puFont); } if (ImGui::CoolBarItem()) { - const auto aw = ImGui::GetCoolBarItemWidth(); + const auto aw = ImGui::GetCoolBarItemWidth(); MainToolBar::puFont->Scale = font_scale_ratio * ImGui::GetCoolBarItemScale(); - if (ImGui::RadioButtonLabeled(ImVec2(aw, aw), ICON_NDPTB_AXIS_ARROW "##Gizmo", "Gizmo", &GizmoSystem::Instance()->puActivated, false, MainToolBar::puFont)) { + if (ImGui::RadioButtonLabeled( + ImVec2(aw, aw), ICON_NDPTB_AXIS_ARROW "##Gizmo", "Gizmo", &GizmoSystem::Instance()->puActivated, false, MainToolBar::puFont)) { GizmoSystem::Instance()->SetActivation(GizmoSystem::Instance()->puActivated); NeedOneFrameUpdate = true; } } if (ImGui::CoolBarItem()) { - const auto aw = ImGui::GetCoolBarItemWidth(); + const auto aw = ImGui::GetCoolBarItemWidth(); MainToolBar::puFont->Scale = font_scale_ratio * ImGui::GetCoolBarItemScale(); - NeedOneFrameUpdate |= ImGui::RadioButtonLabeled(ImVec2(aw, aw), ICON_NDPTB_GOOGLE_CONTROLLER "##GamePad", "GamePad", &GamePadSystem::Instance()->puActivated, false, MainToolBar::puFont); + NeedOneFrameUpdate |= ImGui::RadioButtonLabeled( + ImVec2(aw, aw), ICON_NDPTB_GOOGLE_CONTROLLER "##GamePad", "GamePad", &GamePadSystem::Instance()->puActivated, false, MainToolBar::puFont); } if (ImGui::CoolBarItem()) { - const auto aw = ImGui::GetCoolBarItemWidth(); + const auto aw = ImGui::GetCoolBarItemWidth(); MainToolBar::puFont->Scale = font_scale_ratio * ImGui::GetCoolBarItemScale(); - NeedOneFrameUpdate |= ImGui::RadioButtonLabeled(ImVec2(aw, aw), ICON_NDPTB_MUSIC_NOTE "##Sound", "Sound", &SoundSystem::Instance()->puActivated, false, MainToolBar::puFont); + NeedOneFrameUpdate |= ImGui::RadioButtonLabeled( + ImVec2(aw, aw), ICON_NDPTB_MUSIC_NOTE "##Sound", "Sound", &SoundSystem::Instance()->puActivated, false, MainToolBar::puFont); } MainBackend::Instance()->NeedRefresh(NeedOneFrameUpdate); diff --git a/src/Headers/NoodlesPlateBuild.h b/src/Headers/NoodlesPlateBuild.h index 5b4a676..d2b43dd 100644 --- a/src/Headers/NoodlesPlateBuild.h +++ b/src/Headers/NoodlesPlateBuild.h @@ -1,7 +1,7 @@ #pragma once #define NoodlesPlate_Prefix "NoodlesPlate" -#define NoodlesPlate_BuildNumber 782 +#define NoodlesPlate_BuildNumber 786 #define NoodlesPlate_MinorNumber 7 #define NoodlesPlate_MajorNumber 0 -#define NoodlesPlate_BuildId "0.7.782" +#define NoodlesPlate_BuildId "0.7.786" diff --git a/src/Panes/ConfigSwitcherPane.cpp b/src/Panes/ConfigSwitcherPane.cpp index 8e13750..6c4f004 100644 --- a/src/Panes/ConfigSwitcherPane.cpp +++ b/src/Panes/ConfigSwitcherPane.cpp @@ -94,7 +94,7 @@ bool ConfigSwitcherPane::DrawPanes(const uint32_t& /*vCurrentFrame*/, bool* vOpe return false; } -bool ConfigSwitcherPane::DrawDialogsAndPopups(const uint32_t& /*vCurrentFrame*/, const ImVec2& /*vMaxSize*/, ImGuiContext* /*vContextPtr*/, void* /*vUserDatas*/) { +bool ConfigSwitcherPane::DrawDialogsAndPopups(const uint32_t& /*vCurrentFrame*/, const ImRect& vMaxRect /*vMaxSize*/, ImGuiContext* /*vContextPtr*/, void* /*vUserDatas*/) { ShaderKeyConfigSwitcherUnified::Instance()->DrawDialog(); return false; } diff --git a/src/Panes/ConfigSwitcherPane.h b/src/Panes/ConfigSwitcherPane.h index 2fd7c1d..90d48d8 100644 --- a/src/Panes/ConfigSwitcherPane.h +++ b/src/Panes/ConfigSwitcherPane.h @@ -28,7 +28,7 @@ class ConfigSwitcherPane : public AbstractPane, public conf::ConfigAbstract bool Init() override; void Unit() override; bool DrawPanes(const uint32_t& /*vCurrentFrame*/, bool* vOpened, ImGuiContext* /*vContextPtr*/ = nullptr, void* vUserDatas = nullptr) override; - bool DrawDialogsAndPopups(const uint32_t& /*vCurrentFrame*/, const ImVec2& vMaxSize, ImGuiContext* vContextPtr = nullptr, void* vUserDatas = nullptr) override; + bool DrawDialogsAndPopups(const uint32_t& /*vCurrentFrame*/, const ImRect& vMaxRect, ImGuiContext* vContextPtr = nullptr, void* vUserDatas = nullptr) override; // configuration std::string getXml(const std::string& vOffset, const std::string& vUserDatas = "") override; diff --git a/src/Panes/MessagePane.cpp b/src/Panes/MessagePane.cpp index 243699d..604ac07 100644 --- a/src/Panes/MessagePane.cpp +++ b/src/Panes/MessagePane.cpp @@ -4,7 +4,7 @@ // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -30,7 +30,7 @@ #include -#include // printf zu +#include // printf zu MessagePane::MessagePane() = default; MessagePane::~MessagePane() = default; @@ -39,249 +39,220 @@ MessagePane::~MessagePane() = default; //// OVERRIDES //////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////// -bool MessagePane::Init() -{ - return true; +bool MessagePane::Init() { + return true; } -void MessagePane::Unit() -{ - +void MessagePane::Unit() { } -bool MessagePane::DrawPanes(const uint32_t& /*vCurrentFrame*/, bool* vOpened, ImGuiContext* /*vContextPtr*/, void* /*vUserDatas*/) -{ - IsThereSomeMessages(false); - - if ((puIsThereSomeShaderErrors && puShowErrors) || (puIsThereSomeShaderWarnings && puShowWarnings)) - { - LayoutManager::Instance()->ShowSpecificPane(GetFlag()); // open the message pane - } - else - { - LayoutManager::Instance()->HideSpecificPane(GetFlag()); - } - - if (vOpened && *vOpened) - { - static ImGuiWindowFlags flags = - ImGuiWindowFlags_NoCollapse | - ImGuiWindowFlags_NoBringToFrontOnFocus | - ImGuiWindowFlags_MenuBar; - if (ImGui::Begin(GetName().c_str(), vOpened, flags)) - { +bool MessagePane::DrawPanes(const uint32_t& /*vCurrentFrame*/, bool* vOpened, ImGuiContext* /*vContextPtr*/, void* /*vUserDatas*/) { + if (vOpened && *vOpened) { + static ImGuiWindowFlags flags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_MenuBar; + if (ImGui::Begin(GetName().c_str(), vOpened, flags)) { #ifdef USE_DECORATIONS_FOR_RESIZE_CHILD_WINDOWS - auto win = ImGui::GetCurrentWindowRead(); - if (win->Viewport->Idx != 0) - flags |= ImGuiWindowFlags_NoResize;// | ImGuiWindowFlags_NoTitleBar; - else - flags = ImGuiWindowFlags_NoCollapse | - ImGuiWindowFlags_NoBringToFrontOnFocus | - ImGuiWindowFlags_MenuBar; + auto win = ImGui::GetCurrentWindowRead(); + if (win->Viewport->Idx != 0) + flags |= ImGuiWindowFlags_NoResize; // | ImGuiWindowFlags_NoTitleBar; + else + flags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_MenuBar; #endif - if (ProjectFile::Instance()->IsLoaded()) {} + if (ProjectFile::Instance()->IsLoaded()) { + } - if (ImGui::BeginMenuBar()) - { - ImGui::MenuItem("Errors", "", &puShowErrors); - ImGui::MenuItem("Warnings", "", &puShowWarnings); + if (ImGui::BeginMenuBar()) { + ImGui::MenuItem("Errors", "", &puShowErrors); + ImGui::MenuItem("Warnings", "", &puShowWarnings); - ImGui::EndMenuBar(); - } + ImGui::EndMenuBar(); + } - const auto codeTree = MainBackend::Instance()->puCodeTree; - const auto showDebug = MainFrame::Instance()->puShowDebug; - const auto show3DSpace = MainBackend::Instance()->puShow3DSpace; - const auto showMesh = MainBackend::Instance()->puShowMesh; + const auto codeTree = MainBackend::Instance()->puCodeTree; + const auto showDebug = MainFrame::Instance()->puShowDebug; + const auto show3DSpace = MainBackend::Instance()->puShow3DSpace; + const auto showMesh = MainBackend::Instance()->puShowMesh; const auto showCulling = GizmoSystem::Instance()->UseCulling(); - if (puIsThereSomeShaderErrors && puShowErrors) - { - ImGui::Separator(); - - ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "Shaders (GLSL) Errors :"); + if (puIsThereSomeShaderErrors && puShowErrors) { + ImGui::Separator(); - InterfacePanes::Instance()->DisplayMessageOfRenderPack(MainBackend::sMainThread, false, codeTree, MainBackend::Instance()->puDisplay_RenderPack, showDebug, true, true); + ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "Shaders (GLSL) Errors :"); - if (show3DSpace) - { - InterfacePanes::Instance()->DisplayMessageOfRenderPack(MainBackend::sMainThread, false, codeTree, MainBackend::Instance()->pu3dAxis_RenderPack, showDebug, true, true); - InterfacePanes::Instance()->DisplayMessageOfRenderPack(MainBackend::sMainThread, false, codeTree, MainBackend::Instance()->pu3dGrid_RenderPack, showDebug, true, true); - } + InterfacePanes::Instance()->DisplayMessageOfRenderPack( + MainBackend::sMainThread, false, codeTree, MainBackend::Instance()->puDisplay_RenderPack, showDebug, true, true); - if (showMesh) - { - InterfacePanes::Instance()->DisplayMessageOfRenderPack(MainBackend::sMainThread, false, codeTree, MainBackend::Instance()->puMesh_RenderPack, showDebug, true, true); - } + if (show3DSpace) { + InterfacePanes::Instance()->DisplayMessageOfRenderPack( + MainBackend::sMainThread, false, codeTree, MainBackend::Instance()->pu3dAxis_RenderPack, showDebug, true, true); + InterfacePanes::Instance()->DisplayMessageOfRenderPack( + MainBackend::sMainThread, false, codeTree, MainBackend::Instance()->pu3dGrid_RenderPack, showDebug, true, true); + } - if (showCulling) - { - InterfacePanes::Instance()->DisplayMessageOfRenderPack(MainBackend::sMainThread, false, codeTree, GizmoSystem::Instance()->GetRenderPack(), showDebug, true, true); + if (showMesh) { + InterfacePanes::Instance()->DisplayMessageOfRenderPack( + MainBackend::sMainThread, false, codeTree, MainBackend::Instance()->puMesh_RenderPack, showDebug, true, true); } - } - if (puIsThereSomeShaderWarnings && puShowWarnings) - { - ImGui::Separator(); + if (showCulling) { + InterfacePanes::Instance()->DisplayMessageOfRenderPack( + MainBackend::sMainThread, false, codeTree, GizmoSystem::Instance()->GetRenderPack(), showDebug, true, true); + } + } - ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "Shaders (GLSL) Warnings :"); + if (puIsThereSomeShaderWarnings && puShowWarnings) { + ImGui::Separator(); - InterfacePanes::Instance()->DisplayMessageOfRenderPack(MainBackend::sMainThread, false, codeTree, MainBackend::Instance()->puDisplay_RenderPack, showDebug, true, true); + ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "Shaders (GLSL) Warnings :"); - if (show3DSpace) - { - InterfacePanes::Instance()->DisplayMessageOfRenderPack(MainBackend::sMainThread, false, codeTree, MainBackend::Instance()->pu3dAxis_RenderPack, showDebug, true, true); - InterfacePanes::Instance()->DisplayMessageOfRenderPack(MainBackend::sMainThread, false, codeTree, MainBackend::Instance()->pu3dGrid_RenderPack, showDebug, true, true); - } + InterfacePanes::Instance()->DisplayMessageOfRenderPack( + MainBackend::sMainThread, false, codeTree, MainBackend::Instance()->puDisplay_RenderPack, showDebug, true, true); - if (showMesh) - { - InterfacePanes::Instance()->DisplayMessageOfRenderPack(MainBackend::sMainThread, false, codeTree, MainBackend::Instance()->puMesh_RenderPack, showDebug, true, true); - } + if (show3DSpace) { + InterfacePanes::Instance()->DisplayMessageOfRenderPack( + MainBackend::sMainThread, false, codeTree, MainBackend::Instance()->pu3dAxis_RenderPack, showDebug, true, true); + InterfacePanes::Instance()->DisplayMessageOfRenderPack( + MainBackend::sMainThread, false, codeTree, MainBackend::Instance()->pu3dGrid_RenderPack, showDebug, true, true); + } - if (showCulling) - { - InterfacePanes::Instance()->DisplayMessageOfRenderPack(MainBackend::sMainThread, false, codeTree, GizmoSystem::Instance()->GetRenderPack(), showDebug, true, true); + if (showMesh) { + InterfacePanes::Instance()->DisplayMessageOfRenderPack( + MainBackend::sMainThread, false, codeTree, MainBackend::Instance()->puMesh_RenderPack, showDebug, true, true); } - } - } - MainFrame::sAnyWindowsHovered |= ImGui::IsWindowHovered(); + if (showCulling) { + InterfacePanes::Instance()->DisplayMessageOfRenderPack( + MainBackend::sMainThread, false, codeTree, GizmoSystem::Instance()->GetRenderPack(), showDebug, true, true); + } + } + } - ImGui::End(); - } + MainFrame::sAnyWindowsHovered |= ImGui::IsWindowHovered(); + + ImGui::End(); + } - return false; + return false; } -std::string MessagePane::getXml(const std::string& vOffset, const std::string& vUserDatas) -{ - UNUSED(vOffset); - UNUSED(vUserDatas); +std::string MessagePane::getXml(const std::string& vOffset, const std::string& vUserDatas) { + UNUSED(vOffset); + UNUSED(vUserDatas); - std::string str; + std::string str; - str += vOffset + "" + (puShowErrors ? "true" : "false") + "\n"; - str += vOffset + "" + (puShowWarnings ? "true" : "false") + "\n"; + str += vOffset + "" + (puShowErrors ? "true" : "false") + "\n"; + str += vOffset + "" + (puShowWarnings ? "true" : "false") + "\n"; - return str; + return str; } -bool MessagePane::setFromXml(tinyxml2::XMLElement* vElem, tinyxml2::XMLElement* vParent, const std::string& vUserDatas) -{ - UNUSED(vUserDatas); +bool MessagePane::setFromXml(tinyxml2::XMLElement* vElem, tinyxml2::XMLElement* vParent, const std::string& vUserDatas) { + UNUSED(vUserDatas); - // The value of this child identifies the name of this element - std::string strName; - std::string strValue; - std::string strParentName; + // The value of this child identifies the name of this element + std::string strName; + std::string strValue; + std::string strParentName; - strName = vElem->Value(); - if (vElem->GetText()) - strValue = vElem->GetText(); - if (vParent != nullptr) - strParentName = vParent->Value(); + strName = vElem->Value(); + if (vElem->GetText()) + strValue = vElem->GetText(); + if (vParent != nullptr) + strParentName = vParent->Value(); - if (strName == "showerrors") - puShowErrors = ct::ivariant(strValue).GetB(); + if (strName == "showerrors") + puShowErrors = ct::ivariant(strValue).GetB(); - if (strName == "showwarnings") - puShowWarnings = ct::ivariant(strValue).GetB(); + if (strName == "showwarnings") + puShowWarnings = ct::ivariant(strValue).GetB(); - return true; + return true; } - /////////////////////////////////////////////////////// //// ERRORS / HELP /////////////////////////////////// /////////////////////////////////////////////////////// -bool MessagePane::IsThereSomeMessages(bool vCheckOnlyErrors) -{ - const auto show3DSpace = MainBackend::Instance()->puShow3DSpace; - const auto showMesh = MainBackend::Instance()->puShowMesh; +bool MessagePane::IsThereSomeMessages(bool vCheckOnlyErrors) { + const auto show3DSpace = MainBackend::Instance()->puShow3DSpace; + const auto showMesh = MainBackend::Instance()->puShowMesh; const auto showCulling = GizmoSystem::Instance()->UseCulling(); - puIsThereSomeShaderErrors = MainBackend::Instance()->puMain_RenderPack->IsTheseSomeErrors(); - if (show3DSpace) - { - puIsThereSomeShaderErrors |= MainBackend::Instance()->pu3dAxis_RenderPack->IsTheseSomeErrors(); - puIsThereSomeShaderErrors |= MainBackend::Instance()->pu3dGrid_RenderPack->IsTheseSomeErrors(); - } - if (showMesh) - { - puIsThereSomeShaderErrors |= MainBackend::Instance()->puMesh_RenderPack->IsTheseSomeErrors(); - } - if (showCulling) - { - auto gzPtr = GizmoSystem::Instance()->GetRenderPack().lock(); - if (gzPtr) - { - puIsThereSomeShaderErrors |= gzPtr->IsTheseSomeErrors(); - } + puIsThereSomeShaderErrors = MainBackend::Instance()->puMain_RenderPack->IsTheseSomeErrors(); + if (show3DSpace) { + puIsThereSomeShaderErrors |= MainBackend::Instance()->pu3dAxis_RenderPack->IsTheseSomeErrors(); + puIsThereSomeShaderErrors |= MainBackend::Instance()->pu3dGrid_RenderPack->IsTheseSomeErrors(); + } + if (showMesh) { + puIsThereSomeShaderErrors |= MainBackend::Instance()->puMesh_RenderPack->IsTheseSomeErrors(); + } + if (showCulling) { + auto gzPtr = GizmoSystem::Instance()->GetRenderPack().lock(); + if (gzPtr) { + puIsThereSomeShaderErrors |= gzPtr->IsTheseSomeErrors(); + } } - if (!vCheckOnlyErrors) - { - puIsThereSomeShaderWarnings = MainBackend::Instance()->puMain_RenderPack->IsTheseSomeWarnings(); - if (show3DSpace) - { - puIsThereSomeShaderWarnings |= MainBackend::Instance()->pu3dAxis_RenderPack->IsTheseSomeWarnings(); - puIsThereSomeShaderWarnings |= MainBackend::Instance()->pu3dGrid_RenderPack->IsTheseSomeWarnings(); - } - if (showMesh) - { - puIsThereSomeShaderWarnings |= MainBackend::Instance()->puMesh_RenderPack->IsTheseSomeWarnings(); - } - if (showCulling) - { - auto gzPtr = GizmoSystem::Instance()->GetRenderPack().lock(); - if (gzPtr) - { - puIsThereSomeShaderWarnings |= gzPtr->IsTheseSomeWarnings(); - } + if (!vCheckOnlyErrors) { + puIsThereSomeShaderWarnings = MainBackend::Instance()->puMain_RenderPack->IsTheseSomeWarnings(); + if (show3DSpace) { + puIsThereSomeShaderWarnings |= MainBackend::Instance()->pu3dAxis_RenderPack->IsTheseSomeWarnings(); + puIsThereSomeShaderWarnings |= MainBackend::Instance()->pu3dGrid_RenderPack->IsTheseSomeWarnings(); + } + if (showMesh) { + puIsThereSomeShaderWarnings |= MainBackend::Instance()->puMesh_RenderPack->IsTheseSomeWarnings(); } - } + if (showCulling) { + auto gzPtr = GizmoSystem::Instance()->GetRenderPack().lock(); + if (gzPtr) { + puIsThereSomeShaderWarnings |= gzPtr->IsTheseSomeWarnings(); + } + } + } - return puIsThereSomeShaderErrors || (!vCheckOnlyErrors && puIsThereSomeShaderWarnings); + return puIsThereSomeShaderErrors || (!vCheckOnlyErrors && puIsThereSomeShaderWarnings); } void MessagePane::DrawToolBarButtons(float /*vWidth*/, ImFont* vFontSymbol) { - if (puIsThereSomeShaderErrors) - { - ImGui::Separator(); - - if (ImGui::CoolBarItem()) { + if (puIsThereSomeShaderErrors) { + ImGui::Separator(); + if (ImGui::CoolBarItem()) { const auto aw = ImGui::GetCoolBarItemWidth(); - ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.9f, 0.9f, 0.9f, 1.0f)); // bg when puShowErrors is false - ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(0.9f, 0.9f, 0.9f, 1.0f)); // bg when puShowErrors is false - ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(0.9f, 0.9f, 0.9f, 1.0f)); // bg when puShowErrors is false - ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.8f, 0.1f, 0.1f, 1.0f)); // text color when puShowErrors is false - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.8f, 0.3f, 0.3f, 1.0f)); // button color when puShowErrors is true - ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.8f, 0.2f, 0.2f, 1.0f)); // button color when puShowErrors is true - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.8f, 0.1f, 0.1f, 1.0f)); // button color when puShowErrors is true - ImGui::PushStyleColor(ImGuiCol_TextDisabled, ImVec4(1.0f, 1.0f, 1.0f, 1.0f)); // text color when puShowErrors is true - ImGui::RadioButtonLabeled(ImVec2(aw, aw), ICON_NDPTB_COMMENT_REMOVE "##Errors", "Errors", &puShowErrors, false, vFontSymbol); - ImGui::PopStyleColor(8); - } - } - - if (puIsThereSomeShaderWarnings) - { - ImGui::Separator(); - - if (ImGui::CoolBarItem()) { + ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.9f, 0.9f, 0.9f, 1.0f)); // bg when puShowErrors is false + ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(0.9f, 0.9f, 0.9f, 1.0f)); // bg when puShowErrors is false + ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(0.9f, 0.9f, 0.9f, 1.0f)); // bg when puShowErrors is false + ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.8f, 0.1f, 0.1f, 1.0f)); // text color when puShowErrors is false + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.8f, 0.3f, 0.3f, 1.0f)); // button color when puShowErrors is true + ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.8f, 0.2f, 0.2f, 1.0f)); // button color when puShowErrors is true + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.8f, 0.1f, 0.1f, 1.0f)); // button color when puShowErrors is true + ImGui::PushStyleColor(ImGuiCol_TextDisabled, ImVec4(1.0f, 1.0f, 1.0f, 1.0f)); // text color when puShowErrors is true + ImGui::RadioButtonLabeled(ImVec2(aw, aw), ICON_NDPTB_COMMENT_REMOVE "##Errors", "Errors", &puShowErrors, false, vFontSymbol); + ImGui::PopStyleColor(8); + } + } + + if (puIsThereSomeShaderWarnings) { + ImGui::Separator(); + if (ImGui::CoolBarItem()) { const auto aw = ImGui::GetCoolBarItemWidth(); - ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.9f, 0.9f, 0.9f, 1.0f)); // bg when puShowErrors is false - ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(0.9f, 0.9f, 0.9f, 1.0f)); // bg when puShowErrors is false - ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(0.9f, 0.9f, 0.9f, 1.0f)); // bg when puShowErrors is false - ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.5f, 0.5f, 0.1f, 1.0f)); // text color when puShowErrors is false - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.5f, 0.5f, 0.3f, 1.0f)); // button color when puShowErrors is true - ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.5f, 0.5f, 0.2f, 1.0f)); // button color when puShowErrors is true - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.5f, 0.5f, 0.1f, 1.0f)); // button color when puShowErrors is true - ImGui::PushStyleColor(ImGuiCol_TextDisabled, ImVec4(1.0f, 1.0f, 1.0f, 1.0f)); // text color when puShowErrors is true - ImGui::RadioButtonLabeled(ImVec2(aw, aw), ICON_NDPTB_COMMENT_ALERT "##Warnings", "Warnings", &puShowWarnings, false, vFontSymbol); - ImGui::PopStyleColor(8); - } - } + ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.9f, 0.9f, 0.9f, 1.0f)); // bg when puShowErrors is false + ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(0.9f, 0.9f, 0.9f, 1.0f)); // bg when puShowErrors is false + ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(0.9f, 0.9f, 0.9f, 1.0f)); // bg when puShowErrors is false + ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.5f, 0.5f, 0.1f, 1.0f)); // text color when puShowErrors is false + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.5f, 0.5f, 0.3f, 1.0f)); // button color when puShowErrors is true + ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.5f, 0.5f, 0.2f, 1.0f)); // button color when puShowErrors is true + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.5f, 0.5f, 0.1f, 1.0f)); // button color when puShowErrors is true + ImGui::PushStyleColor(ImGuiCol_TextDisabled, ImVec4(1.0f, 1.0f, 1.0f, 1.0f)); // text color when puShowErrors is true + ImGui::RadioButtonLabeled(ImVec2(aw, aw), ICON_NDPTB_COMMENT_ALERT "##Warnings", "Warnings", &puShowWarnings, false, vFontSymbol); + ImGui::PopStyleColor(8); + } + } + + IsThereSomeMessages(false); + + if ((puIsThereSomeShaderErrors && puShowErrors) || (puIsThereSomeShaderWarnings && puShowWarnings)) { + LayoutManager::Instance()->ShowSpecificPane(GetFlag()); // open the message pane + } else { + LayoutManager::Instance()->HideSpecificPane(GetFlag()); + } } \ No newline at end of file