Skip to content

Commit 9ffcd1f

Browse files
committed
ImGui clean up
1 parent 1201b6b commit 9ffcd1f

15 files changed

Lines changed: 59 additions & 96 deletions

DelvCD/Config/AboutPage.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ public void DrawConfig(IConfigurable parent, Vector2 size, float padX, float pad
3232
drawList.AddImage(Plugin.IconTexture.Handle, pos, pos + iconSize);
3333
Vector2 textPos = ImGui.GetWindowPos().AddX(size.X / 2 - textSize.X / 2).AddY(iconSize.Y);
3434
drawList.AddText(textPos, 0xFFFFFFFF, versionText);
35-
ImGui.End();
3635
}
36+
ImGui.EndChild();
3737
}
3838

3939
ImGui.SetCursorPosY(ImGui.GetCursorPosY() + headerSize.Y);
@@ -44,8 +44,8 @@ public void DrawConfig(IConfigurable parent, Vector2 size, float padX, float pad
4444
if (ImGui.BeginChild("##Changelog", changeLogSize, true))
4545
{
4646
ImGui.Text(Plugin.Changelog);
47-
ImGui.EndChild();
4847
}
48+
ImGui.EndChild();
4949
}
5050

5151
ImGui.EndChild();

DelvCD/Config/ElementListConfig.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ private void DrawCreateMenu(Vector2 size, float padX)
6262
ImGui.SameLine();
6363
DrawHelpers.DrawButton(string.Empty, FontAwesomeIcon.Download, () => ImportUIElement(), "Import new Element or Group from Clipboard", buttonSize);
6464
ImGui.PopItemWidth();
65-
66-
ImGui.EndChild();
6765
}
66+
67+
ImGui.EndChild();
6868
}
6969

7070
private unsafe void DrawUIElementTable(Vector2 size, float padX)
@@ -103,7 +103,7 @@ private unsafe void DrawUIElementTable(Vector2 size, float padX)
103103
continue;
104104
}
105105

106-
ImGui.PushID(i.ToString());
106+
ImGui.PushID($"##UIElements_Table_Row_{i}");
107107

108108
ImGui.TableNextRow(ImGuiTableRowFlags.None, 28);
109109

DelvCD/Config/FontConfig.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public void DrawConfig(IConfigurable parent, Vector2 size, float padX, float pad
103103

104104
for (int i = 0; i < Fonts.Keys.Count; i++)
105105
{
106-
ImGui.PushID(i.ToString());
106+
ImGui.PushID($"##Font_Table_Row_{i}");
107107
ImGui.TableNextRow(ImGuiTableRowFlags.None, 28);
108108

109109
string key = Fonts.Keys.ElementAt(i);

DelvCD/Config/GroupConfig.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,9 @@ public void DrawConfig(IConfigurable parent, Vector2 size, float padX, float pad
104104
group.ScaleResolution(new(_mX, _mY), _positionOnly);
105105
}
106106
}
107-
108-
109-
ImGui.EndChild();
110107
}
108+
109+
ImGui.EndChild();
111110
}
112111
}
113112
}

DelvCD/Config/LabelListConfig.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ private void DrawLabelTable(Vector2 size, float padX)
8888
int i = 0;
8989
for (; i < Labels.Count; i++)
9090
{
91-
ImGui.PushID(i.ToString());
91+
ImGui.PushID($"##Label_Table_Row_{i}");
9292
ImGui.TableNextRow(ImGuiTableRowFlags.None, 28);
9393

9494
Label label = Labels[i];
@@ -112,7 +112,7 @@ private void DrawLabelTable(Vector2 size, float padX)
112112
}
113113
}
114114

115-
ImGui.PushID((i + 1).ToString());
115+
ImGui.PushID($"##Label_Table_Row_{i + 1}");
116116
ImGui.TableNextRow(ImGuiTableRowFlags.None, 28);
117117
if (ImGui.TableSetColumnIndex(0))
118118
{

DelvCD/Config/Styles/IconStyleConfig.cs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -164,22 +164,25 @@ public void DrawConfig(IConfigurable parent, Vector2 size, float padX, float pad
164164
}
165165
ImGui.PopItemWidth();
166166

167-
if (_iconSearchResults.Any() && ImGui.BeginChild("##IconPicker", new Vector2(size.X - padX * 2, 60 * _scale), true))
167+
if (_iconSearchResults.Any())
168168
{
169-
List<uint> icons = _iconSearchResults.Select(t => t.Icon).Distinct().ToList();
170-
for (int i = 0; i < icons.Count; i++)
169+
if (ImGui.BeginChild("##IconPicker", new Vector2(size.X - padX * 2, 60 * _scale), true))
171170
{
172-
Vector2 iconPos = ImGui.GetWindowPos().AddX(10 * _scale) + new Vector2(i * (40 * _scale + padX), padY);
173-
Vector2 iconSize = new Vector2(40 * _scale, 40 * _scale);
174-
DrawIconPreview(iconPos, iconSize, icons[i], CropIcon, false, true);
175-
176-
if (ImGui.IsMouseHoveringRect(iconPos, iconPos + iconSize))
171+
List<uint> icons = _iconSearchResults.Select(t => t.Icon).Distinct().ToList();
172+
for (int i = 0; i < icons.Count; i++)
177173
{
178-
if (ImGui.IsMouseClicked(ImGuiMouseButton.Left))
174+
Vector2 iconPos = ImGui.GetWindowPos().AddX(10 * _scale) + new Vector2(i * (40 * _scale + padX), padY);
175+
Vector2 iconSize = new Vector2(40 * _scale, 40 * _scale);
176+
DrawIconPreview(iconPos, iconSize, icons[i], CropIcon, false, true);
177+
178+
if (ImGui.IsMouseHoveringRect(iconPos, iconPos + iconSize))
179179
{
180-
CustomIcon = icons[i];
181-
_iconSearchResults.Clear();
182-
_iconSearchInput = string.Empty;
180+
if (ImGui.IsMouseClicked(ImGuiMouseButton.Left))
181+
{
182+
CustomIcon = icons[i];
183+
_iconSearchResults.Clear();
184+
_iconSearchInput = string.Empty;
185+
}
183186
}
184187
}
185188
}

DelvCD/Config/Styles/LabelStyleConfig.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ public void DrawConfig(IConfigurable parent, Vector2 size, float padX, float pad
100100
OutlineColor.Vector = outlineColor;
101101
}
102102
}
103+
103104
ImGui.EndChild();
104105
}
105106

@@ -121,9 +122,8 @@ public void DrawConfig(IConfigurable parent, Vector2 size, float padX, float pad
121122
_selectedTextTagCategory = i;
122123
}
123124
}
124-
125-
ImGui.EndChild();
126125
}
126+
ImGui.EndChild();
127127

128128
ImGui.SetCursorPos(new Vector2(200 * _scale, 8 * _scale));
129129
if (ImGui.BeginChild("##DelvCD_TextTags_List", new Vector2(180 * _scale, 284 * _scale), true))
@@ -136,9 +136,8 @@ public void DrawConfig(IConfigurable parent, Vector2 size, float padX, float pad
136136
selectedTag = tag;
137137
}
138138
}
139-
140-
ImGui.EndChild();
141139
}
140+
ImGui.EndChild();
142141

143142
ImGui.EndPopup();
144143
}

DelvCD/Config/Styles/StyleConditions.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,19 +196,19 @@ public void DrawConfig(IConfigurable parent, Vector2 size, float padX, float pad
196196

197197
for (int i = 0; i < Conditions.Count; i++)
198198
{
199-
ImGui.PushID(i.ToString());
199+
ImGui.PushID($"##Conditions_Table_Row_{i}");
200200
ImGui.TableNextRow(ImGuiTableRowFlags.None, 28);
201201

202202
DrawStyleConditionRow(i);
203203
}
204204

205-
ImGui.PushID(Conditions.Count.ToString());
205+
ImGui.PushID($"##Conditions_Table_Row_{Conditions.Count}");
206206
ImGui.TableNextRow(ImGuiTableRowFlags.None, 28);
207207
ImGui.TableSetColumnIndex(5);
208208
DrawHelpers.DrawButton(string.Empty, FontAwesomeIcon.Plus, () => Conditions.Add(new StyleCondition<T>(_defaultStyle)), "New Condition", buttonSize);
209-
}
210209

211-
ImGui.EndTable();
210+
ImGui.EndTable();
211+
}
212212

213213
if (_swapX < Conditions.Count && _swapX >= 0 &&
214214
_swapY < Conditions.Count && _swapY >= 0)
@@ -222,7 +222,6 @@ public void DrawConfig(IConfigurable parent, Vector2 size, float padX, float pad
222222
}
223223
}
224224

225-
226225
ImGui.EndChild();
227226
}
228227

DelvCD/Config/TriggerConfig.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System.Linq;
99
using System.Numerics;
1010
using System.Runtime.CompilerServices;
11+
using FFXIVClientStructs.FFXIV.Client.Game;
1112

1213
namespace DelvCD.Config
1314
{
@@ -146,13 +147,13 @@ public void DrawConfig(IConfigurable parent, Vector2 size, float padX, float pad
146147

147148
for (int i = 0; i < TriggerOptions.Count; i++)
148149
{
149-
ImGui.PushID(i.ToString());
150+
ImGui.PushID($"##Conditions_Table_Row_{i}");
150151
ImGui.TableNextRow(ImGuiTableRowFlags.None, 28);
151152

152153
DrawTriggerRow(i);
153154
}
154155

155-
ImGui.PushID(TriggerOptions.Count.ToString());
156+
ImGui.PushID($"##Conditions_Table_Row_{TriggerOptions.Count}");
156157
ImGui.TableNextRow(ImGuiTableRowFlags.None, 28);
157158
ImGui.TableSetColumnIndex(3);
158159
DrawHelpers.DrawButton(string.Empty, FontAwesomeIcon.Plus, () => AddTrigger(), "New Trigger", buttonSize);

DelvCD/Config/VisibilityConfig.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ public void DrawConfig(IConfigurable parent, Vector2 size, float padX, float pad
181181
DrawHelpers.DrawSpacing();
182182
ImGui.Checkbox("Enable Window Clipping", ref Clip);
183183
}
184-
185-
ImGui.EndChild();
186184
}
185+
186+
ImGui.EndChild();
187187
}
188188
}
189189
}

0 commit comments

Comments
 (0)