Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve UIs #1010

Merged
merged 4 commits into from
Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Dev/Cpp/Viewer/GUI/efk.GUIManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1180,14 +1180,14 @@ bool GUIManager::ImageButtonOriginal(std::shared_ptr<Effekseer::Tool::Image> 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;
}
Expand Down
2 changes: 1 addition & 1 deletion Dev/Cpp/Viewer/GUI/efk.GUIManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ class GUIManager

bool ImageButtonOriginal(std::shared_ptr<Effekseer::Tool::Image> 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);

Expand Down
18 changes: 17 additions & 1 deletion Dev/Cpp/Viewer/dll_cs.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;
Expand Down
2 changes: 0 additions & 2 deletions Dev/Editor/Effekseer/GUI/Dock/AdvancedRenderCommonValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ protected override void UpdateInternal()
if (isFirstUpdate)
{
}

Manager.NativeManager.Separator();
}

object GetTargetObject()
Expand Down
1 change: 0 additions & 1 deletion Dev/Editor/Effekseer/GUI/Dock/BehaviorValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ protected override void UpdateInternal()
{
}

Manager.NativeManager.Separator();
paramerterList.Update();
}

Expand Down
1 change: 0 additions & 1 deletion Dev/Editor/Effekseer/GUI/Dock/CollisionsValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ protected override void UpdateInternal()
{
}

Manager.NativeManager.Separator();
paramerterList.Update();
}

Expand Down
4 changes: 3 additions & 1 deletion Dev/Editor/Effekseer/GUI/Dock/CommonValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ protected override void UpdateInternal()
{
}

Manager.NativeManager.Separator();
paramerterList_Node.Update();

Manager.NativeManager.Separator();

paramerterList_Common.Update();
}

Expand Down
1 change: 0 additions & 1 deletion Dev/Editor/Effekseer/GUI/Dock/Culling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ protected override void UpdateInternal()
{
}

Manager.NativeManager.Separator();
paramerterList.Update();
}

Expand Down
1 change: 0 additions & 1 deletion Dev/Editor/Effekseer/GUI/Dock/DepthValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ protected override void UpdateInternal()
{
}

Manager.NativeManager.Separator();
paramerterList.Update();
}

Expand Down
2 changes: 0 additions & 2 deletions Dev/Editor/Effekseer/GUI/Dock/Dynamic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ public override void OnDisposed()

protected override void UpdateInternal()
{
Manager.NativeManager.Separator();

Manager.NativeManager.Text(MultiLanguageTextProvider.GetText("DynamicInput"));

paramerterListInput.Update();
Expand Down
1 change: 0 additions & 1 deletion Dev/Editor/Effekseer/GUI/Dock/Environment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ protected override void UpdateInternal()
isFiestUpdate = false;
}

Manager.NativeManager.Separator();
paramerterList.Update();
}

Expand Down
1 change: 0 additions & 1 deletion Dev/Editor/Effekseer/GUI/Dock/GenerationLocationValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ protected override void UpdateInternal()
{
}

Manager.NativeManager.Separator();
paramerterList.Update();
}

Expand Down
1 change: 0 additions & 1 deletion Dev/Editor/Effekseer/GUI/Dock/GlobalValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ protected override void UpdateInternal()
{
}

Manager.NativeManager.Separator();
paramerterList.Update();
}

Expand Down
2 changes: 0 additions & 2 deletions Dev/Editor/Effekseer/GUI/Dock/LOD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 0 additions & 1 deletion Dev/Editor/Effekseer/GUI/Dock/LocationAbsValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ protected override void UpdateInternal()
{
}

Manager.NativeManager.Separator();
paramerterList.Update();
}

Expand Down
2 changes: 0 additions & 2 deletions Dev/Editor/Effekseer/GUI/Dock/Network.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down
37 changes: 23 additions & 14 deletions Dev/Editor/Effekseer/GUI/Dock/NodeTreeView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -598,27 +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())
{
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.Text(this.Node.Name);

Manager.NativeManager.EndDragDropSource();
}
UpdateDDTargetNode();

UpdateDDTargetNode();
Manager.NativeManager.TableSetColumnIndex(1);

Manager.NativeManager.TableSetColumnIndex(1);
Manager.NativeManager.SetCursorPosY(Manager.NativeManager.GetCursorPosY() + 5);

UpdateLODButton();
UpdateLODButton();

Manager.NativeManager.SameLine();
Manager.NativeManager.SameLine();

UpdateVisibleButton();
UpdateVisibleButton();
}

if (IsExpanding)
{
Expand All @@ -633,7 +642,7 @@ public void Update()

if (Children.Count != 0)
{
Children.Internal.Last().UpdateDDTargetSeparator(true);
//Children.Internal.Last().UpdateDDTargetSeparator(true);
}

// pair with TreeNodeEx
Expand Down
2 changes: 0 additions & 2 deletions Dev/Editor/Effekseer/GUI/Dock/ProceduralModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions Dev/Editor/Effekseer/GUI/Dock/Profiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,6 @@ protected override void UpdateInternal()
{
var gui = Manager.NativeManager;

gui.Separator();

if (gui.BeginTabBar("Mode"))
{
if (gui.BeginTabItem("Editor"))
Expand Down
2 changes: 0 additions & 2 deletions Dev/Editor/Effekseer/GUI/Dock/Recorder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
41 changes: 17 additions & 24 deletions Dev/Editor/EffekseerCoreGUI/GUI/BindableComponent/ParameterList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
using Effekseer.swig;

namespace Effekseer.GUI.BindableComponent
{
Expand Down Expand Up @@ -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()
Expand All @@ -45,14 +47,18 @@ 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();
indent.Indent = 0;
indent.IsSelecter = false;
collection.Update(indent);

Manager.NativeManager.Columns(1);
Manager.NativeManager.EndTable();
Manager.NativeManager.PopStyleVar();

isFirstUpdate = false;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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
{
Expand All @@ -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
Expand All @@ -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;
}
Expand Down
Loading
Loading