From d07185d69ce1f935a702db683b60ec7a4e793f97 Mon Sep 17 00:00:00 2001 From: ueshita Date: Tue, 9 Apr 2024 09:26:59 +0900 Subject: [PATCH 1/4] Move the dock panel toolbar to the menu area --- .../GUI/Dock/AdvancedRenderCommonValues.cs | 2 - .../Effekseer/GUI/Dock/BehaviorValues.cs | 1 - .../Effekseer/GUI/Dock/CollisionsValues.cs | 1 - Dev/Editor/Effekseer/GUI/Dock/CommonValues.cs | 1 - Dev/Editor/Effekseer/GUI/Dock/Culling.cs | 1 - Dev/Editor/Effekseer/GUI/Dock/DepthValues.cs | 1 - Dev/Editor/Effekseer/GUI/Dock/Dynamic.cs | 2 - Dev/Editor/Effekseer/GUI/Dock/Environment.cs | 1 - .../GUI/Dock/GenerationLocationValues.cs | 1 - Dev/Editor/Effekseer/GUI/Dock/GlobalValues.cs | 1 - Dev/Editor/Effekseer/GUI/Dock/LOD.cs | 2 - .../Effekseer/GUI/Dock/LocationAbsValues.cs | 1 - Dev/Editor/Effekseer/GUI/Dock/Network.cs | 2 - .../Effekseer/GUI/Dock/ProceduralModel.cs | 2 - Dev/Editor/Effekseer/GUI/Dock/Profiler.cs | 2 - Dev/Editor/Effekseer/GUI/Dock/Recorder.cs | 2 - .../GUI/BindableComponent/Utils.cs | 8 +- .../EffekseerCoreGUI/GUI/Dock/DockPanel.cs | 54 ++++---- .../EffekseerCoreGUI/GUI/Dock/FileBrowser.cs | 118 +++++++++--------- Dev/Editor/EffekseerCoreGUI/GUI/Icons.cs | 7 ++ 20 files changed, 101 insertions(+), 109 deletions(-) diff --git a/Dev/Editor/Effekseer/GUI/Dock/AdvancedRenderCommonValues.cs b/Dev/Editor/Effekseer/GUI/Dock/AdvancedRenderCommonValues.cs index 4b6ef7eadb..451f7a2078 100644 --- a/Dev/Editor/Effekseer/GUI/Dock/AdvancedRenderCommonValues.cs +++ b/Dev/Editor/Effekseer/GUI/Dock/AdvancedRenderCommonValues.cs @@ -52,8 +52,6 @@ protected override void UpdateInternal() if (isFirstUpdate) { } - - Manager.NativeManager.Separator(); } object GetTargetObject() diff --git a/Dev/Editor/Effekseer/GUI/Dock/BehaviorValues.cs b/Dev/Editor/Effekseer/GUI/Dock/BehaviorValues.cs index d629357047..a29e868f7f 100644 --- a/Dev/Editor/Effekseer/GUI/Dock/BehaviorValues.cs +++ b/Dev/Editor/Effekseer/GUI/Dock/BehaviorValues.cs @@ -46,7 +46,6 @@ protected override void UpdateInternal() { } - Manager.NativeManager.Separator(); paramerterList.Update(); } diff --git a/Dev/Editor/Effekseer/GUI/Dock/CollisionsValues.cs b/Dev/Editor/Effekseer/GUI/Dock/CollisionsValues.cs index 2e781a485a..d18c45e168 100644 --- a/Dev/Editor/Effekseer/GUI/Dock/CollisionsValues.cs +++ b/Dev/Editor/Effekseer/GUI/Dock/CollisionsValues.cs @@ -50,7 +50,6 @@ protected override void UpdateInternal() { } - Manager.NativeManager.Separator(); paramerterList.Update(); } diff --git a/Dev/Editor/Effekseer/GUI/Dock/CommonValues.cs b/Dev/Editor/Effekseer/GUI/Dock/CommonValues.cs index 4f8cad3729..8b0a4847b6 100644 --- a/Dev/Editor/Effekseer/GUI/Dock/CommonValues.cs +++ b/Dev/Editor/Effekseer/GUI/Dock/CommonValues.cs @@ -56,7 +56,6 @@ protected override void UpdateInternal() { } - Manager.NativeManager.Separator(); paramerterList_Node.Update(); paramerterList_Common.Update(); } diff --git a/Dev/Editor/Effekseer/GUI/Dock/Culling.cs b/Dev/Editor/Effekseer/GUI/Dock/Culling.cs index b70007642e..e9975384ff 100644 --- a/Dev/Editor/Effekseer/GUI/Dock/Culling.cs +++ b/Dev/Editor/Effekseer/GUI/Dock/Culling.cs @@ -44,7 +44,6 @@ protected override void UpdateInternal() { } - Manager.NativeManager.Separator(); paramerterList.Update(); } diff --git a/Dev/Editor/Effekseer/GUI/Dock/DepthValues.cs b/Dev/Editor/Effekseer/GUI/Dock/DepthValues.cs index 4973b2d513..b497b0e6f5 100644 --- a/Dev/Editor/Effekseer/GUI/Dock/DepthValues.cs +++ b/Dev/Editor/Effekseer/GUI/Dock/DepthValues.cs @@ -50,7 +50,6 @@ protected override void UpdateInternal() { } - Manager.NativeManager.Separator(); paramerterList.Update(); } diff --git a/Dev/Editor/Effekseer/GUI/Dock/Dynamic.cs b/Dev/Editor/Effekseer/GUI/Dock/Dynamic.cs index e01527c1f7..b03fd5c52b 100644 --- a/Dev/Editor/Effekseer/GUI/Dock/Dynamic.cs +++ b/Dev/Editor/Effekseer/GUI/Dock/Dynamic.cs @@ -63,8 +63,6 @@ public override void OnDisposed() protected override void UpdateInternal() { - Manager.NativeManager.Separator(); - Manager.NativeManager.Text(MultiLanguageTextProvider.GetText("DynamicInput")); paramerterListInput.Update(); diff --git a/Dev/Editor/Effekseer/GUI/Dock/Environment.cs b/Dev/Editor/Effekseer/GUI/Dock/Environment.cs index 11efd4cda2..7d93bc4d51 100644 --- a/Dev/Editor/Effekseer/GUI/Dock/Environment.cs +++ b/Dev/Editor/Effekseer/GUI/Dock/Environment.cs @@ -48,7 +48,6 @@ protected override void UpdateInternal() isFiestUpdate = false; } - Manager.NativeManager.Separator(); paramerterList.Update(); } diff --git a/Dev/Editor/Effekseer/GUI/Dock/GenerationLocationValues.cs b/Dev/Editor/Effekseer/GUI/Dock/GenerationLocationValues.cs index daa7b36208..3a0eabc7f0 100644 --- a/Dev/Editor/Effekseer/GUI/Dock/GenerationLocationValues.cs +++ b/Dev/Editor/Effekseer/GUI/Dock/GenerationLocationValues.cs @@ -51,7 +51,6 @@ protected override void UpdateInternal() { } - Manager.NativeManager.Separator(); paramerterList.Update(); } diff --git a/Dev/Editor/Effekseer/GUI/Dock/GlobalValues.cs b/Dev/Editor/Effekseer/GUI/Dock/GlobalValues.cs index 9c44513913..26b1cb8a61 100644 --- a/Dev/Editor/Effekseer/GUI/Dock/GlobalValues.cs +++ b/Dev/Editor/Effekseer/GUI/Dock/GlobalValues.cs @@ -44,7 +44,6 @@ protected override void UpdateInternal() { } - Manager.NativeManager.Separator(); paramerterList.Update(); } diff --git a/Dev/Editor/Effekseer/GUI/Dock/LOD.cs b/Dev/Editor/Effekseer/GUI/Dock/LOD.cs index 75edf86055..cc9dc1d203 100644 --- a/Dev/Editor/Effekseer/GUI/Dock/LOD.cs +++ b/Dev/Editor/Effekseer/GUI/Dock/LOD.cs @@ -65,8 +65,6 @@ private bool ShowLevel(int level, Data.Value.Boolean levelEnabled, Data.Value.Fl protected override void UpdateInternal() { - Manager.NativeManager.Separator(); - LevelParameter[] levels = new LevelParameter[] { new LevelParameter(0, Core.LodValues.Lod0Enabled, Core.LodValues.Distance0), diff --git a/Dev/Editor/Effekseer/GUI/Dock/LocationAbsValues.cs b/Dev/Editor/Effekseer/GUI/Dock/LocationAbsValues.cs index fb62b5028c..56e80151ed 100644 --- a/Dev/Editor/Effekseer/GUI/Dock/LocationAbsValues.cs +++ b/Dev/Editor/Effekseer/GUI/Dock/LocationAbsValues.cs @@ -50,7 +50,6 @@ protected override void UpdateInternal() { } - Manager.NativeManager.Separator(); paramerterList.Update(); } diff --git a/Dev/Editor/Effekseer/GUI/Dock/Network.cs b/Dev/Editor/Effekseer/GUI/Dock/Network.cs index 955be32894..d04d58f6ff 100644 --- a/Dev/Editor/Effekseer/GUI/Dock/Network.cs +++ b/Dev/Editor/Effekseer/GUI/Dock/Network.cs @@ -18,8 +18,6 @@ public Network() protected override void UpdateInternal() { - Manager.NativeManager.Separator(); - var target = Manager.Network.Target; var port = new int[] { Manager.Network.Port }; var autoConnect = new bool[] { Manager.Network.AutoConnect }; diff --git a/Dev/Editor/Effekseer/GUI/Dock/ProceduralModel.cs b/Dev/Editor/Effekseer/GUI/Dock/ProceduralModel.cs index 3116e24daf..b331df92a5 100644 --- a/Dev/Editor/Effekseer/GUI/Dock/ProceduralModel.cs +++ b/Dev/Editor/Effekseer/GUI/Dock/ProceduralModel.cs @@ -44,8 +44,6 @@ public override void OnDisposed() protected override void UpdateInternal() { - Manager.NativeManager.Separator(); - float width = Manager.NativeManager.GetContentRegionAvail().X; Manager.NativeManager.PushItemWidth(width - Manager.NativeManager.GetTextLineHeight() * 5.5f); diff --git a/Dev/Editor/Effekseer/GUI/Dock/Profiler.cs b/Dev/Editor/Effekseer/GUI/Dock/Profiler.cs index 83ba808d51..57816c189d 100644 --- a/Dev/Editor/Effekseer/GUI/Dock/Profiler.cs +++ b/Dev/Editor/Effekseer/GUI/Dock/Profiler.cs @@ -420,8 +420,6 @@ protected override void UpdateInternal() { var gui = Manager.NativeManager; - gui.Separator(); - if (gui.BeginTabBar("Mode")) { if (gui.BeginTabItem("Editor")) diff --git a/Dev/Editor/Effekseer/GUI/Dock/Recorder.cs b/Dev/Editor/Effekseer/GUI/Dock/Recorder.cs index 65e92cf567..eb9799c28a 100644 --- a/Dev/Editor/Effekseer/GUI/Dock/Recorder.cs +++ b/Dev/Editor/Effekseer/GUI/Dock/Recorder.cs @@ -83,8 +83,6 @@ public override void OnDisposed() protected override void UpdateInternal() { - Manager.NativeManager.Separator(); - var mainRenderer = Manager.Viewer.EffectRenderer; mainRenderer.GuideWidth = Core.Recording.RecordingWidth.Value; mainRenderer.GuideHeight = Core.Recording.RecordingHeight.Value; diff --git a/Dev/Editor/EffekseerCoreGUI/GUI/BindableComponent/Utils.cs b/Dev/Editor/EffekseerCoreGUI/GUI/BindableComponent/Utils.cs index 42ea1506ca..f0b908eb93 100644 --- a/Dev/Editor/EffekseerCoreGUI/GUI/BindableComponent/Utils.cs +++ b/Dev/Editor/EffekseerCoreGUI/GUI/BindableComponent/Utils.cs @@ -126,14 +126,14 @@ public CopyAndPaste(string elementName, Func getter, Action valueChanged public void Update() { float dpiScale = Manager.DpiScale; - swig.Vec2 size = new swig.Vec2(18 * dpiScale, 18 * dpiScale); + swig.Vec2 size = new swig.Vec2(20 * dpiScale, 20 * dpiScale); if (!Images.Icons.ContainsKey("Copy")) { ErrorUtils.ThrowFileNotfound(); } - if (Manager.NativeManager.ImageButton(Images.Icons["Copy"], size.X, size.Y)) + if (Manager.NativeManager.IconButton(Icons.Copy)) { var o = getter(); if (o != null) @@ -147,9 +147,7 @@ public void Update() Manager.NativeManager.SetTooltip(MultiLanguageTextProvider.GetText("Panel_Copy_Desc")); } - Manager.NativeManager.SameLine(); - - if (Manager.NativeManager.ImageButton(Images.Icons["Paste"], size.X, size.Y)) + if (Manager.NativeManager.IconButton(Icons.Paste)) { var str = Manager.NativeManager.GetClipboardText(); diff --git a/Dev/Editor/EffekseerCoreGUI/GUI/Dock/DockPanel.cs b/Dev/Editor/EffekseerCoreGUI/GUI/Dock/DockPanel.cs index a2f682bbd7..d235af466b 100644 --- a/Dev/Editor/EffekseerCoreGUI/GUI/Dock/DockPanel.cs +++ b/Dev/Editor/EffekseerCoreGUI/GUI/Dock/DockPanel.cs @@ -78,6 +78,8 @@ public override void Update() { if (Manager.IsDockMode()) { + float dpiScale = Manager.DpiScale; + if (IsInitialized < 0) { IsInitialized++; @@ -96,7 +98,14 @@ public override void Update() flags = swig.WindowFlags.NoScrollbar; } - if (NoPadding) Manager.NativeManager.PushStyleVar(swig.ImGuiStyleVarFlags.WindowPadding, new swig.Vec2(0.0f, 0.0f)); + var windowPadding = (NoPadding) ? new swig.Vec2(0.0f, 0.0f) : new swig.Vec2(4.0f * dpiScale, 4.0f * dpiScale); + + Manager.NativeManager.PushStyleVar(swig.ImGuiStyleVarFlags.WindowPadding, windowPadding); + + if (HasToolBar()) + { + flags |= swig.WindowFlags.MenuBar; + } bool dockEnabled = Manager.NativeManager.BeginDock( Label, TabLabel, ref opened, Visibled && Windowed && !NoCloseButton, flags); @@ -104,7 +113,7 @@ public override void Update() Visibled = Manager.NativeManager.IsDockVisibled(); Windowed = Manager.NativeManager.IsDockWindowed(); - if (NoPadding) Manager.NativeManager.PopStyleVar(); + Manager.NativeManager.PopStyleVar(); if (dockEnabled) { @@ -130,7 +139,6 @@ public override void Update() { UpdateInternal(); - Controls.Lock(); foreach (var c in Controls.Internal) @@ -178,36 +186,36 @@ protected virtual void UpdateInternal() protected virtual void UpdateToolbar() { - bool hasItem = false; - - if (CopyAndPaste != null) + if (Manager.NativeManager.BeginMenuBar()) { - CopyAndPaste.Update(); - hasItem = true; - } + Manager.NativeManager.PushStyleColor(swig.ImGuiColFlags.Button, 0); - if (!string.IsNullOrEmpty(DocPage)) - { - if (hasItem) + if (CopyAndPaste != null) { - Manager.NativeManager.SameLine(); + CopyAndPaste.Update(); } - float dpiScale = Manager.DpiScale; - swig.Vec2 size = new swig.Vec2(18 * dpiScale, 18 * dpiScale); - - if (Manager.NativeManager.ImageButton(Images.Icons["Help"], size.X, size.Y)) + if (!string.IsNullOrEmpty(DocPage)) { - Commands.ShowURL(DocURL); - } + if (Manager.NativeManager.IconButton(Icons.Help)) + { + Commands.ShowURL(DocURL); + } - if (Functions.CanShowTip()) - { - Manager.NativeManager.SetTooltip(MultiLanguageTextProvider.GetText("Panel_Help_Desc")); + if (Functions.CanShowTip()) + { + Manager.NativeManager.SetTooltip(MultiLanguageTextProvider.GetText("Panel_Help_Desc")); + } } - hasItem = true; + Manager.NativeManager.PopStyleColor(); + Manager.NativeManager.EndMenuBar(); } } + + private bool HasToolBar() + { + return (CopyAndPaste != null) || !string.IsNullOrEmpty(DocPage); + } } } \ No newline at end of file diff --git a/Dev/Editor/EffekseerCoreGUI/GUI/Dock/FileBrowser.cs b/Dev/Editor/EffekseerCoreGUI/GUI/Dock/FileBrowser.cs index 0d62bc071f..0a8f014cf5 100644 --- a/Dev/Editor/EffekseerCoreGUI/GUI/Dock/FileBrowser.cs +++ b/Dev/Editor/EffekseerCoreGUI/GUI/Dock/FileBrowser.cs @@ -75,11 +75,6 @@ protected override void UpdateInternal() Manager.NativeManager.PushItemWidth(-1); - // Address bar - UpdateAddressBar(dpiScale, regionSize, spacing); - - Manager.NativeManager.Separator(); - // Display all files UpdateFileView(dpiScale, regionSize, spacing); @@ -96,76 +91,83 @@ protected override void UpdateInternal() protected override void UpdateToolbar() { - } - - void UpdateAddressBar(float dpiScale, swig.Vec2 regionSize, swig.Vec2 spacing) - { - float buttonWidth = Manager.NativeManager.GetTextLineHeight() + Manager.NativeManager.GetStyleVar2(swig.ImGuiStyleVarFlags.FramePadding).X * 2; - - // Back directory - if (Manager.NativeManager.Button("↑", buttonWidth) && - !String.IsNullOrEmpty(CurrentPath)) + if (Manager.NativeManager.BeginMenuBar()) { - UpdateFileListWithProjectPath(CurrentPath); - } - - Manager.NativeManager.SameLine(); + Manager.NativeManager.PushStyleColor(swig.ImGuiColFlags.Button, 0); + //Manager.NativeManager.SetCursorPosY(Manager.NativeManager.GetCursorPosY() + 4); - // Display current directory - if (addressActivated || addressEditing) - { - Manager.NativeManager.PushItemWidth(regionSize.X - buttonWidth * 3 - spacing.X * 3); + var padding = Manager.NativeManager.GetStyleVar2(swig.ImGuiStyleVarFlags.WindowPadding); + var windowSize = Manager.NativeManager.GetWindowSize(); + float regionWidth = windowSize.X - padding.X * 2.0f; + float buttonSize = 20 * Manager.DpiScale; + float spacing = Manager.NativeManager.GetStyleVar2(swig.ImGuiStyleVarFlags.ItemSpacing).X; - if (addressActivated) + // Back directory + if (Manager.NativeManager.IconButton(Icons.ArrowUp) && + !String.IsNullOrEmpty(CurrentPath)) { - Manager.NativeManager.SetKeyboardFocusHere(); - addressEditing = true; - addressActivated = false; + UpdateFileListWithProjectPath(CurrentPath); } - if (Manager.NativeManager.InputText("###AddressText", addressText)) + // Display current directory + if (addressActivated || addressEditing) { - addressText = Manager.NativeManager.GetInputTextResult(); - UpdateFileList(addressText); + Manager.NativeManager.PushItemWidth(regionWidth - buttonSize * 3 - spacing * 3); + + if (addressActivated) + { + Manager.NativeManager.SetKeyboardFocusHere(); + addressEditing = true; + addressActivated = false; + } + + if (Manager.NativeManager.InputText("###AddressText", addressText)) + { + addressText = Manager.NativeManager.GetInputTextResult(); + UpdateFileList(addressText); + } + if (Manager.NativeManager.IsItemDeactivated()) + { + addressEditing = false; + addressText = CurrentPath; + } + + Manager.NativeManager.PopItemWidth(); } - if (Manager.NativeManager.IsItemDeactivated()) + else { - addressEditing = false; - addressText = CurrentPath; - } + string label = Path.GetFileName(CurrentPath) + "###AddressButton"; - Manager.NativeManager.PopItemWidth(); - } - else - { - string label = Path.GetFileName(CurrentPath) + "###AddressButton"; - if (Manager.NativeManager.Button(label, regionSize.X - buttonWidth * 3 - spacing.X * 3)) - { - addressActivated = true; - } - } + Manager.NativeManager.PushStyleColor(swig.ImGuiColFlags.Button, 0x20FFFFFF); - Manager.NativeManager.SameLine(); + if (Manager.NativeManager.Button(label, regionWidth - buttonSize * 3 - spacing * 3)) + { + addressActivated = true; + } - if (Manager.NativeManager.Button(Icons.NavMenu, buttonWidth)) - { - Manager.NativeManager.OpenPopup(OptionMenuPopupId); - } + Manager.NativeManager.PopStyleColor(); + } - UpdateOptionMenu(); + if (Manager.NativeManager.IconButton(Icons.NavMenu)) + { + Manager.NativeManager.OpenPopup(OptionMenuPopupId); + } - Manager.NativeManager.SameLine(); + UpdateOptionMenu(); - if (Manager.NativeManager.Button("?", buttonWidth)) - { - Commands.ShowURL(DocURL); - } + if (Manager.NativeManager.IconButton(Icons.Help)) + { + Commands.ShowURL(DocURL); + } - if (BindableComponent.Functions.CanShowTip()) - { - Manager.NativeManager.SetTooltip(MultiLanguageTextProvider.GetText("Panel_Help_Desc")); - } + if (BindableComponent.Functions.CanShowTip()) + { + Manager.NativeManager.SetTooltip(MultiLanguageTextProvider.GetText("Panel_Help_Desc")); + } + Manager.NativeManager.PopStyleColor(); + Manager.NativeManager.EndMenuBar(); + } } void UpdateOptionMenu() diff --git a/Dev/Editor/EffekseerCoreGUI/GUI/Icons.cs b/Dev/Editor/EffekseerCoreGUI/GUI/Icons.cs index c1663fa5d2..96c9237c46 100644 --- a/Dev/Editor/EffekseerCoreGUI/GUI/Icons.cs +++ b/Dev/Editor/EffekseerCoreGUI/GUI/Icons.cs @@ -61,5 +61,12 @@ public static class Icons public const string NavFilter = "\xec41"; public const string FileView = "\xec42"; public const string Remove = "\xec43"; + public const string Help = "\xec44"; + public const string Copy = "\xec45"; + public const string Paste = "\xec46"; + public const string ArrowUp = "\xec47"; + public const string ArrowDown = "\xec48"; + public const string ArrowLeft = "\xec49"; + public const string ArrowRight = "\xec4a"; } } \ No newline at end of file From 42e8ca570f22803cfcf8d2be7eb0a0f9e7effe8d Mon Sep 17 00:00:00 2001 From: ueshita Date: Tue, 9 Apr 2024 09:27:55 +0900 Subject: [PATCH 2/4] Replace the visibility button icon in node tree --- Dev/Cpp/Viewer/GUI/efk.GUIManager.cpp | 10 +++++----- Dev/Cpp/Viewer/GUI/efk.GUIManager.h | 2 +- Dev/Cpp/Viewer/dll_cs.cxx | 18 +++++++++++++++++- Dev/Editor/Effekseer/GUI/Dock/NodeTreeView.cs | 6 ++++-- Dev/Editor/EffekseerCoreGUI/GUI/Icons.cs | 2 ++ Dev/Editor/EffekseerCoreGUI/Images.cs | 3 --- .../swig/EffekseerNativePINVOKE.cs | 7 +++++-- Dev/Editor/EffekseerCoreGUI/swig/GUIManager.cs | 7 ++++++- 8 files changed, 40 insertions(+), 15 deletions(-) diff --git a/Dev/Cpp/Viewer/GUI/efk.GUIManager.cpp b/Dev/Cpp/Viewer/GUI/efk.GUIManager.cpp index fdbfe14e73..3285cd888c 100644 --- a/Dev/Cpp/Viewer/GUI/efk.GUIManager.cpp +++ b/Dev/Cpp/Viewer/GUI/efk.GUIManager.cpp @@ -1180,14 +1180,14 @@ bool GUIManager::ImageButtonOriginal(std::shared_ptr use return ImGui::ImageButton(ToImTextureID(user_texture_id), ImVec2(x, y), ImVec2(0, 0), ImVec2(1, 1), 0, ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1)); } -bool GUIManager::IconButton(const char16_t* icon) +bool GUIManager::IconButton(const char16_t* icon, float size) { const auto& style = ImGui::GetStyle(); const float fontSize = ImGui::GetFontSize(); - const float frameHeight = ImGui::GetFrameHeight(); - const float padding = (frameHeight - fontSize) * 0.5f; - ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(padding, style.FramePadding.y)); - bool result = ImGui::Button(utf8str<16>(icon), ImVec2(frameHeight, frameHeight)); + size = (size > 0.0f) ? size : ImGui::GetFrameHeight(); + const float padding = (size - fontSize) * 0.5f; + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(padding, padding)); + bool result = ImGui::Button(utf8str<16>(icon), ImVec2(size, size)); ImGui::PopStyleVar(); return result; } diff --git a/Dev/Cpp/Viewer/GUI/efk.GUIManager.h b/Dev/Cpp/Viewer/GUI/efk.GUIManager.h index bb6cf1d6d6..bc67d00396 100644 --- a/Dev/Cpp/Viewer/GUI/efk.GUIManager.h +++ b/Dev/Cpp/Viewer/GUI/efk.GUIManager.h @@ -731,7 +731,7 @@ class GUIManager bool ImageButtonOriginal(std::shared_ptr user_texture_id, float x, float y); - bool IconButton(const char16_t* icon); + bool IconButton(const char16_t* icon, float size = 0.0f); bool Checkbox(const char16_t* label, bool* v); diff --git a/Dev/Cpp/Viewer/dll_cs.cxx b/Dev/Cpp/Viewer/dll_cs.cxx index 219eeac2af..f562d2f33d 100644 --- a/Dev/Cpp/Viewer/dll_cs.cxx +++ b/Dev/Cpp/Viewer/dll_cs.cxx @@ -7422,7 +7422,23 @@ SWIGEXPORT unsigned int SWIGSTDCALL CSharp_Effekseerfswig_GUIManager_ImageButton } -SWIGEXPORT unsigned int SWIGSTDCALL CSharp_Effekseerfswig_GUIManager_IconButton___(void * jarg1, void * jarg2) { +SWIGEXPORT unsigned int SWIGSTDCALL CSharp_Effekseerfswig_GUIManager_IconButton__SWIG_0___(void * jarg1, void * jarg2, float jarg3) { + unsigned int jresult ; + efk::GUIManager *arg1 = (efk::GUIManager *) 0 ; + char16_t *arg2 = (char16_t *) 0 ; + float arg3 ; + bool result; + + arg1 = (efk::GUIManager *)jarg1; + arg2 = (char16_t *)jarg2; + arg3 = (float)jarg3; + result = (bool)(arg1)->IconButton((char16_t const *)arg2,arg3); + jresult = result; + return jresult; +} + + +SWIGEXPORT unsigned int SWIGSTDCALL CSharp_Effekseerfswig_GUIManager_IconButton__SWIG_1___(void * jarg1, void * jarg2) { unsigned int jresult ; efk::GUIManager *arg1 = (efk::GUIManager *) 0 ; char16_t *arg2 = (char16_t *) 0 ; diff --git a/Dev/Editor/Effekseer/GUI/Dock/NodeTreeView.cs b/Dev/Editor/Effekseer/GUI/Dock/NodeTreeView.cs index 7cd95399e5..88a05a2fa8 100644 --- a/Dev/Editor/Effekseer/GUI/Dock/NodeTreeView.cs +++ b/Dev/Editor/Effekseer/GUI/Dock/NodeTreeView.cs @@ -521,7 +521,7 @@ void UpdateVisibleButton() var visible = Node.IsRendered; float buttonSize = Manager.NativeManager.GetTextLineHeight(); - if (Manager.NativeManager.ImageButton(Images.GetIcon(visible ? "VisibleShow" : "VisibleHide"), buttonSize, buttonSize)) + if (Manager.NativeManager.IconButton(visible ? Icons.VisibleShow : Icons.VisibleHide, buttonSize)) { int LEFT_SHIFT = 340; int RIGHT_SHIFT = 344; @@ -614,6 +614,8 @@ public void Update() Manager.NativeManager.TableSetColumnIndex(1); + Manager.NativeManager.SetCursorPosY(Manager.NativeManager.GetCursorPosY() + 5); + UpdateLODButton(); Manager.NativeManager.SameLine(); @@ -633,7 +635,7 @@ public void Update() if (Children.Count != 0) { - Children.Internal.Last().UpdateDDTargetSeparator(true); + //Children.Internal.Last().UpdateDDTargetSeparator(true); } // pair with TreeNodeEx diff --git a/Dev/Editor/EffekseerCoreGUI/GUI/Icons.cs b/Dev/Editor/EffekseerCoreGUI/GUI/Icons.cs index 96c9237c46..7784e0c00e 100644 --- a/Dev/Editor/EffekseerCoreGUI/GUI/Icons.cs +++ b/Dev/Editor/EffekseerCoreGUI/GUI/Icons.cs @@ -68,5 +68,7 @@ public static class Icons public const string ArrowDown = "\xec48"; public const string ArrowLeft = "\xec49"; public const string ArrowRight = "\xec4a"; + public const string VisibleShow = "\xec4b"; + public const string VisibleHide = "\xec4c"; } } \ No newline at end of file diff --git a/Dev/Editor/EffekseerCoreGUI/Images.cs b/Dev/Editor/EffekseerCoreGUI/Images.cs index a1100dcf69..4169c71d9d 100644 --- a/Dev/Editor/EffekseerCoreGUI/Images.cs +++ b/Dev/Editor/EffekseerCoreGUI/Images.cs @@ -61,9 +61,6 @@ public static void Load(swig.GraphicsDevice graphicsDevice) Icons["AppIcon"] = LoadAppResource(graphicsDevice, "resources/icons/AppIcon.png"); - Icons["VisibleShow"] = LoadAppResource(graphicsDevice, "resources/icons/Visible_Show.png"); - Icons["VisibleHide"] = LoadAppResource(graphicsDevice, "resources/icons/Visible_Hide.png"); - Icons["EnlargeAnchor"] = LoadAppResource(graphicsDevice, "resources/icons/EnlargeAnchor.png"); Icons["ShrinkAnchor"] = LoadAppResource(graphicsDevice, "resources/icons/ShrinkAnchor.png"); diff --git a/Dev/Editor/EffekseerCoreGUI/swig/EffekseerNativePINVOKE.cs b/Dev/Editor/EffekseerCoreGUI/swig/EffekseerNativePINVOKE.cs index bdc655063f..c24e08ccc6 100644 --- a/Dev/Editor/EffekseerCoreGUI/swig/EffekseerNativePINVOKE.cs +++ b/Dev/Editor/EffekseerCoreGUI/swig/EffekseerNativePINVOKE.cs @@ -1870,8 +1870,11 @@ static SWIGWStringHelper() { [global::System.Runtime.InteropServices.DllImport("Viewer", EntryPoint="CSharp_Effekseerfswig_GUIManager_ImageButtonOriginal___")] public static extern bool GUIManager_ImageButtonOriginal(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, float jarg3, float jarg4); - [global::System.Runtime.InteropServices.DllImport("Viewer", EntryPoint="CSharp_Effekseerfswig_GUIManager_IconButton___")] - public static extern bool GUIManager_IconButton(global::System.Runtime.InteropServices.HandleRef jarg1, [global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]string jarg2); + [global::System.Runtime.InteropServices.DllImport("Viewer", EntryPoint="CSharp_Effekseerfswig_GUIManager_IconButton__SWIG_0___")] + public static extern bool GUIManager_IconButton__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1, [global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]string jarg2, float jarg3); + + [global::System.Runtime.InteropServices.DllImport("Viewer", EntryPoint="CSharp_Effekseerfswig_GUIManager_IconButton__SWIG_1___")] + public static extern bool GUIManager_IconButton__SWIG_1(global::System.Runtime.InteropServices.HandleRef jarg1, [global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]string jarg2); [global::System.Runtime.InteropServices.DllImport("Viewer", EntryPoint="CSharp_Effekseerfswig_GUIManager_Checkbox___")] public static extern bool GUIManager_Checkbox(global::System.Runtime.InteropServices.HandleRef jarg1, [global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]string jarg2, [global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.Out, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray,ArraySubType=System.Runtime.InteropServices.UnmanagedType.I1)]bool[] jarg3); diff --git a/Dev/Editor/EffekseerCoreGUI/swig/GUIManager.cs b/Dev/Editor/EffekseerCoreGUI/swig/GUIManager.cs index 51c77eed33..d4137ae061 100644 --- a/Dev/Editor/EffekseerCoreGUI/swig/GUIManager.cs +++ b/Dev/Editor/EffekseerCoreGUI/swig/GUIManager.cs @@ -563,8 +563,13 @@ public bool ImageButtonOriginal(Image user_texture_id, float x, float y) { return ret; } + public bool IconButton(string icon, float size) { + bool ret = EffekseerNativePINVOKE.GUIManager_IconButton__SWIG_0(swigCPtr, icon, size); + return ret; + } + public bool IconButton(string icon) { - bool ret = EffekseerNativePINVOKE.GUIManager_IconButton(swigCPtr, icon); + bool ret = EffekseerNativePINVOKE.GUIManager_IconButton__SWIG_1(swigCPtr, icon); return ret; } From 72acd731be0ada8cf25c016b1c53206a1923e691 Mon Sep 17 00:00:00 2001 From: ueshita Date: Sun, 14 Apr 2024 15:35:07 +0900 Subject: [PATCH 3/4] Modify to hide unusable buttons from NodeRoot --- Dev/Editor/Effekseer/GUI/Dock/NodeTreeView.cs | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/Dev/Editor/Effekseer/GUI/Dock/NodeTreeView.cs b/Dev/Editor/Effekseer/GUI/Dock/NodeTreeView.cs index 88a05a2fa8..5b82e64f39 100644 --- a/Dev/Editor/Effekseer/GUI/Dock/NodeTreeView.cs +++ b/Dev/Editor/Effekseer/GUI/Dock/NodeTreeView.cs @@ -598,29 +598,36 @@ public void Update() treeView.Popup(); - // D&D Source - if (Manager.NativeManager.BeginDragDropSource()) + if (Node is Data.NodeRoot) { - byte[] idBuf = BitConverter.GetBytes(UniqueID); - if (Manager.NativeManager.SetDragDropPayload(treeView.treePyloadName, idBuf, idBuf.Length)) + UpdateDDTargetNode(); + } + else if (Node is Data.Node) + { + // D&D Source + if (Manager.NativeManager.BeginDragDropSource()) { - } - Manager.NativeManager.Text(this.Node.Name); + byte[] idBuf = BitConverter.GetBytes(UniqueID); + if (Manager.NativeManager.SetDragDropPayload(treeView.treePyloadName, idBuf, idBuf.Length)) + { + } + Manager.NativeManager.Text(this.Node.Name); - Manager.NativeManager.EndDragDropSource(); - } + Manager.NativeManager.EndDragDropSource(); + } - UpdateDDTargetNode(); + UpdateDDTargetNode(); - Manager.NativeManager.TableSetColumnIndex(1); + Manager.NativeManager.TableSetColumnIndex(1); - Manager.NativeManager.SetCursorPosY(Manager.NativeManager.GetCursorPosY() + 5); + Manager.NativeManager.SetCursorPosY(Manager.NativeManager.GetCursorPosY() + 5); - UpdateLODButton(); + UpdateLODButton(); - Manager.NativeManager.SameLine(); + Manager.NativeManager.SameLine(); - UpdateVisibleButton(); + UpdateVisibleButton(); + } if (IsExpanding) { From b83e2431743bdfedb654b340814d14cb6ce7b768 Mon Sep 17 00:00:00 2001 From: ueshita Date: Sun, 14 Apr 2024 15:37:25 +0900 Subject: [PATCH 4/4] Replace the new Table API to the parameter list. --- Dev/Editor/Effekseer/GUI/Dock/CommonValues.cs | 3 ++ .../GUI/BindableComponent/ParameterList.cs | 41 ++++++++----------- .../EffekseerCoreGUI/GUI/Dock/DockPanel.cs | 2 +- 3 files changed, 21 insertions(+), 25 deletions(-) diff --git a/Dev/Editor/Effekseer/GUI/Dock/CommonValues.cs b/Dev/Editor/Effekseer/GUI/Dock/CommonValues.cs index 8b0a4847b6..747aa72d2b 100644 --- a/Dev/Editor/Effekseer/GUI/Dock/CommonValues.cs +++ b/Dev/Editor/Effekseer/GUI/Dock/CommonValues.cs @@ -57,6 +57,9 @@ protected override void UpdateInternal() } paramerterList_Node.Update(); + + Manager.NativeManager.Separator(); + paramerterList_Common.Update(); } diff --git a/Dev/Editor/EffekseerCoreGUI/GUI/BindableComponent/ParameterList.cs b/Dev/Editor/EffekseerCoreGUI/GUI/BindableComponent/ParameterList.cs index 679702a755..f1fe7b56cd 100644 --- a/Dev/Editor/EffekseerCoreGUI/GUI/BindableComponent/ParameterList.cs +++ b/Dev/Editor/EffekseerCoreGUI/GUI/BindableComponent/ParameterList.cs @@ -4,6 +4,7 @@ using System.Text; using System.Threading.Tasks; using System.Reflection; +using Effekseer.swig; namespace Effekseer.GUI.BindableComponent { @@ -35,8 +36,9 @@ public class ParameterList : GroupControl, IControl, IDroppableControl static void ChangeColumns2WithLabelWidth() { var regionAvail = Manager.NativeManager.GetContentRegionAvail(); - Manager.NativeManager.Columns(2); - Manager.NativeManager.SetColumnWidth(0, (int)(regionAvail.X * 0.3f)); + Manager.NativeManager.BeginTable("ParameterList", 2, TableFlags.BordersInner); + Manager.NativeManager.TableSetupColumn("Label", TableColumnFlags.NoResize | TableColumnFlags.WidthFixed, regionAvail.X * 0.3f); + Manager.NativeManager.TableSetupColumn("Parameter"); } public ParameterList() @@ -45,6 +47,9 @@ public ParameterList() public override void Update() { + float dpiScale = Manager.DpiScale; + + Manager.NativeManager.PushStyleVar(ImGuiStyleVarFlags.CellPadding, new swig.Vec2(3.0f * dpiScale, 3.0f * dpiScale)); ChangeColumns2WithLabelWidth(); var indent = new IndentInformation(); @@ -52,7 +57,8 @@ public override void Update() indent.IsSelecter = false; collection.Update(indent); - Manager.NativeManager.Columns(1); + Manager.NativeManager.EndTable(); + Manager.NativeManager.PopStyleVar(); isFirstUpdate = false; } @@ -136,6 +142,8 @@ public IndentInformation Update(IndentInformation indent, object groupLabel = nu controlRows.Lock(); + float dpiScale = Manager.DpiScale; + for (int i = 0; i < controlRows.Internal.Count; i++) { var ctrl = controlRows.Internal[i].Control; @@ -162,8 +170,7 @@ public IndentInformation Update(IndentInformation indent, object groupLabel = nu if (item.BindingValue is Data.Group.IToggleMode) { // CollapsingHeader with toggle - Manager.NativeManager.Columns(1); - Manager.NativeManager.Spacing(); + Manager.NativeManager.EndTable(); var toggleId = "###" + item.TreeNodeID + "_toggle"; var toggleMode = item.BindingValue as Data.Group.IToggleMode; @@ -191,8 +198,7 @@ public IndentInformation Update(IndentInformation indent, object groupLabel = nu } else if (item.TreeNodeType == Data.TreeNodeType.Large) { - Manager.NativeManager.Columns(1); - Manager.NativeManager.Spacing(); + Manager.NativeManager.EndTable(); var valueChanged = item.Children.IsValueChangedFromDefault; @@ -219,19 +225,13 @@ public IndentInformation Update(IndentInformation indent, object groupLabel = nu { var flag = swig.TreeNodeFlags.SpanFullWidth; - Manager.NativeManager.Columns(1); + Manager.NativeManager.EndTable(); if (Manager.NativeManager.TreeNodeEx(label, flag)) { ChangeColumns2WithLabelWidth(); currentIndent = item.Children.Update(currentIndent); - - // Avoid Tree node bug - Manager.NativeManager.Columns(1); - Manager.NativeManager.TreePop(); - Manager.NativeManager.Spacing(); - Manager.NativeManager.Columns(2); } else { @@ -252,15 +252,10 @@ public IndentInformation Update(IndentInformation indent, object groupLabel = nu } else { - if ( - (currentIndent.Indent > controlRows[i].SelectorIndent || - controlRows[i].IsSelector || - (currentIndent.Indent == controlRows[i].SelectorIndent && currentIndent.IsSelecter))) - { - Manager.NativeManager.Separator(); - } + Manager.NativeManager.TableNextColumn(); // Show a label + Manager.NativeManager.SetCursorPosX(Manager.NativeManager.GetCursorPosX() + 4.0f * dpiScale); Manager.NativeManager.SetCursorPosY(Manager.NativeManager.GetCursorPosY() + Manager.TextOffsetY); // TODO : Make better imeplementation @@ -284,15 +279,13 @@ public IndentInformation Update(IndentInformation indent, object groupLabel = nu Manager.NativeManager.EndTooltip(); } - Manager.NativeManager.NextColumn(); + Manager.NativeManager.TableNextColumn(); // Show a content Manager.NativeManager.PushItemWidth(-1); ctrl.Update(); Manager.NativeManager.PopItemWidth(); - Manager.NativeManager.NextColumn(); - currentIndent.Indent = controlRows[i].SelectorIndent; currentIndent.IsSelecter = controlRows[i].IsSelector; } diff --git a/Dev/Editor/EffekseerCoreGUI/GUI/Dock/DockPanel.cs b/Dev/Editor/EffekseerCoreGUI/GUI/Dock/DockPanel.cs index d235af466b..38301607a5 100644 --- a/Dev/Editor/EffekseerCoreGUI/GUI/Dock/DockPanel.cs +++ b/Dev/Editor/EffekseerCoreGUI/GUI/Dock/DockPanel.cs @@ -98,7 +98,7 @@ public override void Update() flags = swig.WindowFlags.NoScrollbar; } - var windowPadding = (NoPadding) ? new swig.Vec2(0.0f, 0.0f) : new swig.Vec2(4.0f * dpiScale, 4.0f * dpiScale); + var windowPadding = (NoPadding) ? new swig.Vec2(0.0f, 0.0f) : new swig.Vec2(4.0f * dpiScale, 2.0f * dpiScale); Manager.NativeManager.PushStyleVar(swig.ImGuiStyleVarFlags.WindowPadding, windowPadding);