@@ -30,11 +30,14 @@ private void DrawColorTablePairSelector(ColorTable table, bool disabled)
30
30
var buttonWidth = ( ImGui . GetContentRegionAvail ( ) . X - itemSpacing * 7.0f ) * 0.125f ;
31
31
var frameHeight = ImGui . GetFrameHeight ( ) ;
32
32
var highlighterSize = ImUtf8 . CalcIconSize ( FontAwesomeIcon . Crosshairs ) + framePadding * 2.0f ;
33
- var spaceWidth = ImUtf8 . CalcTextSize ( " "u8 ) . X ;
34
- var spacePadding = ( int ) MathF . Ceiling ( ( highlighterSize . X + framePadding . X + itemInnerSpacing ) / spaceWidth ) ;
35
33
36
34
using var font = ImRaii . PushFont ( UiBuilder . MonoFont ) ;
37
35
using var alignment = ImRaii . PushStyle ( ImGuiStyleVar . ButtonTextAlign , new Vector2 ( 0 , 0.5f ) ) ;
36
+
37
+ // This depends on the font being pushed for "proper" alignment of the pair indices in the buttons.
38
+ var spaceWidth = ImUtf8 . CalcTextSize ( " "u8 ) . X ;
39
+ var spacePadding = ( int ) MathF . Ceiling ( ( highlighterSize . X + framePadding . X + itemInnerSpacing ) / spaceWidth ) ;
40
+
38
41
for ( var i = 0 ; i < ColorTable . NumRows > > 1 ; i += 8 )
39
42
{
40
43
for ( var j = 0 ; j < 8 ; ++ j )
@@ -72,7 +75,7 @@ private void DrawColorTablePairSelector(ColorTable table, bool disabled)
72
75
var cursor = ImGui . GetCursorScreenPos ( ) ;
73
76
ImGui . SetCursorScreenPos ( rcMin with { Y = float . Lerp ( rcMin . Y , rcMax . Y , 0.5f ) - highlighterSize . Y * 0.5f } ) ;
74
77
font . Pop ( ) ;
75
- ColorTableHighlightButton ( pairIndex , disabled ) ;
78
+ ColorTablePairHighlightButton ( pairIndex , disabled ) ;
76
79
font . Push ( UiBuilder . MonoFont ) ;
77
80
ImGui . SetCursorScreenPos ( cursor ) ;
78
81
}
@@ -83,6 +86,8 @@ private bool DrawColorTablePairEditor(ColorTable table, ColorDyeTable? dyeTable,
83
86
{
84
87
var retA = false ;
85
88
var retB = false ;
89
+ var rowAIdx = _colorTableSelectedPair << 1 ;
90
+ var rowBIdx = rowAIdx | 1 ;
86
91
var dyeA = dyeTable ? [ _colorTableSelectedPair << 1 ] ?? default ;
87
92
var dyeB = dyeTable ? [ ( _colorTableSelectedPair << 1 ) | 1 ] ?? default ;
88
93
var previewDyeA = _stainService . GetStainCombo ( dyeA . Channel ) . CurrentSelection . Key ;
@@ -91,23 +96,15 @@ private bool DrawColorTablePairEditor(ColorTable table, ColorDyeTable? dyeTable,
91
96
var dyePackB = _stainService . GudStmFile . GetValueOrNull ( dyeB . Template , previewDyeB ) ;
92
97
using ( var columns = ImUtf8 . Columns ( 2 , "ColorTable"u8 ) )
93
98
{
94
- using ( ImUtf8 . PushId ( "ClipboardA "u8 ) )
99
+ using ( ImUtf8 . PushId ( "RowHeaderA "u8 ) )
95
100
{
96
- ColorTableCopyClipboardButton ( _colorTableSelectedPair << 1 ) ;
97
- ImUtf8 . SameLineInner ( ) ;
98
- retA |= ColorTablePasteFromClipboardButton ( _colorTableSelectedPair << 1 , disabled ) ;
101
+ retA |= DrawRowHeader ( rowAIdx , disabled ) ;
99
102
}
100
- ImGui . SameLine ( ) ;
101
- CenteredTextInRest ( $ "Row { _colorTableSelectedPair + 1 } A") ;
102
103
columns . Next ( ) ;
103
- using ( ImUtf8 . PushId ( "ClipboardB "u8 ) )
104
+ using ( ImUtf8 . PushId ( "RowHeaderB "u8 ) )
104
105
{
105
- ColorTableCopyClipboardButton ( ( _colorTableSelectedPair << 1 ) | 1 ) ;
106
- ImUtf8 . SameLineInner ( ) ;
107
- retB |= ColorTablePasteFromClipboardButton ( ( _colorTableSelectedPair << 1 ) | 1 , disabled ) ;
106
+ retB |= DrawRowHeader ( rowBIdx , disabled ) ;
108
107
}
109
- ImGui . SameLine ( ) ;
110
- CenteredTextInRest ( $ "Row { _colorTableSelectedPair + 1 } B") ;
111
108
}
112
109
113
110
DrawHeader ( " Colors"u8 ) ;
@@ -116,13 +113,13 @@ private bool DrawColorTablePairEditor(ColorTable table, ColorDyeTable? dyeTable,
116
113
using var dis = ImRaii . Disabled ( disabled ) ;
117
114
using ( ImUtf8 . PushId ( "ColorsA"u8 ) )
118
115
{
119
- retA |= DrawColors ( table , dyeTable , dyePackA , _colorTableSelectedPair << 1 ) ;
116
+ retA |= DrawColors ( table , dyeTable , dyePackA , rowAIdx ) ;
120
117
}
121
118
122
119
columns . Next ( ) ;
123
120
using ( ImUtf8 . PushId ( "ColorsB"u8 ) )
124
121
{
125
- retB |= DrawColors ( table , dyeTable , dyePackB , ( _colorTableSelectedPair << 1 ) | 1 ) ;
122
+ retB |= DrawColors ( table , dyeTable , dyePackB , rowBIdx ) ;
126
123
}
127
124
}
128
125
@@ -132,13 +129,13 @@ private bool DrawColorTablePairEditor(ColorTable table, ColorDyeTable? dyeTable,
132
129
using var dis = ImRaii . Disabled ( disabled ) ;
133
130
using ( ImUtf8 . PushId ( "PbrA"u8 ) )
134
131
{
135
- retA |= DrawPbr ( table , dyeTable , dyePackA , _colorTableSelectedPair << 1 ) ;
132
+ retA |= DrawPbr ( table , dyeTable , dyePackA , rowAIdx ) ;
136
133
}
137
134
138
135
columns . Next ( ) ;
139
136
using ( ImUtf8 . PushId ( "PbrB"u8 ) )
140
137
{
141
- retB |= DrawPbr ( table , dyeTable , dyePackB , ( _colorTableSelectedPair << 1 ) | 1 ) ;
138
+ retB |= DrawPbr ( table , dyeTable , dyePackB , rowBIdx ) ;
142
139
}
143
140
}
144
141
@@ -148,13 +145,13 @@ private bool DrawColorTablePairEditor(ColorTable table, ColorDyeTable? dyeTable,
148
145
using var dis = ImRaii . Disabled ( disabled ) ;
149
146
using ( ImUtf8 . PushId ( "SheenA"u8 ) )
150
147
{
151
- retA |= DrawSheen ( table , dyeTable , dyePackA , _colorTableSelectedPair << 1 ) ;
148
+ retA |= DrawSheen ( table , dyeTable , dyePackA , rowAIdx ) ;
152
149
}
153
150
154
151
columns . Next ( ) ;
155
152
using ( ImUtf8 . PushId ( "SheenB"u8 ) )
156
153
{
157
- retB |= DrawSheen ( table , dyeTable , dyePackB , ( _colorTableSelectedPair << 1 ) | 1 ) ;
154
+ retB |= DrawSheen ( table , dyeTable , dyePackB , rowBIdx ) ;
158
155
}
159
156
}
160
157
@@ -164,13 +161,13 @@ private bool DrawColorTablePairEditor(ColorTable table, ColorDyeTable? dyeTable,
164
161
using var dis = ImRaii . Disabled ( disabled ) ;
165
162
using ( ImUtf8 . PushId ( "BlendingA"u8 ) )
166
163
{
167
- retA |= DrawBlending ( table , dyeTable , dyePackA , _colorTableSelectedPair << 1 ) ;
164
+ retA |= DrawBlending ( table , dyeTable , dyePackA , rowAIdx ) ;
168
165
}
169
166
170
167
columns . Next ( ) ;
171
168
using ( ImUtf8 . PushId ( "BlendingB"u8 ) )
172
169
{
173
- retB |= DrawBlending ( table , dyeTable , dyePackB , ( _colorTableSelectedPair << 1 ) | 1 ) ;
170
+ retB |= DrawBlending ( table , dyeTable , dyePackB , rowBIdx ) ;
174
171
}
175
172
}
176
173
@@ -180,13 +177,13 @@ private bool DrawColorTablePairEditor(ColorTable table, ColorDyeTable? dyeTable,
180
177
using var dis = ImRaii . Disabled ( disabled ) ;
181
178
using ( ImUtf8 . PushId ( "TemplateA"u8 ) )
182
179
{
183
- retA |= DrawTemplate ( table , dyeTable , dyePackA , _colorTableSelectedPair << 1 ) ;
180
+ retA |= DrawTemplate ( table , dyeTable , dyePackA , rowAIdx ) ;
184
181
}
185
182
186
183
columns . Next ( ) ;
187
184
using ( ImUtf8 . PushId ( "TemplateB"u8 ) )
188
185
{
189
- retB |= DrawTemplate ( table , dyeTable , dyePackB , ( _colorTableSelectedPair << 1 ) | 1 ) ;
186
+ retB |= DrawTemplate ( table , dyeTable , dyePackB , rowBIdx ) ;
190
187
}
191
188
}
192
189
@@ -197,13 +194,13 @@ private bool DrawColorTablePairEditor(ColorTable table, ColorDyeTable? dyeTable,
197
194
using var dis = ImRaii . Disabled ( disabled ) ;
198
195
using ( ImUtf8 . PushId ( "DyeA"u8 ) )
199
196
{
200
- retA |= DrawDye ( dyeTable , dyePackA , _colorTableSelectedPair << 1 ) ;
197
+ retA |= DrawDye ( dyeTable , dyePackA , rowAIdx ) ;
201
198
}
202
199
203
200
columns . Next ( ) ;
204
201
using ( ImUtf8 . PushId ( "DyeB"u8 ) )
205
202
{
206
- retB |= DrawDye ( dyeTable , dyePackB , ( _colorTableSelectedPair << 1 ) | 1 ) ;
203
+ retB |= DrawDye ( dyeTable , dyePackB , rowBIdx ) ;
207
204
}
208
205
}
209
206
@@ -213,20 +210,20 @@ private bool DrawColorTablePairEditor(ColorTable table, ColorDyeTable? dyeTable,
213
210
using var dis = ImRaii . Disabled ( disabled ) ;
214
211
using ( ImUtf8 . PushId ( "FurtherA"u8 ) )
215
212
{
216
- retA |= DrawFurther ( table , dyeTable , dyePackA , _colorTableSelectedPair << 1 ) ;
213
+ retA |= DrawFurther ( table , dyeTable , dyePackA , rowAIdx ) ;
217
214
}
218
215
219
216
columns . Next ( ) ;
220
217
using ( ImUtf8 . PushId ( "FurtherB"u8 ) )
221
218
{
222
- retB |= DrawFurther ( table , dyeTable , dyePackB , ( _colorTableSelectedPair << 1 ) | 1 ) ;
219
+ retB |= DrawFurther ( table , dyeTable , dyePackB , rowBIdx ) ;
223
220
}
224
221
}
225
222
226
223
if ( retA )
227
- UpdateColorTableRowPreview ( _colorTableSelectedPair << 1 ) ;
224
+ UpdateColorTableRowPreview ( rowAIdx ) ;
228
225
if ( retB )
229
- UpdateColorTableRowPreview ( ( _colorTableSelectedPair << 1 ) | 1 ) ;
226
+ UpdateColorTableRowPreview ( rowBIdx ) ;
230
227
231
228
return retA | retB ;
232
229
}
@@ -239,6 +236,20 @@ private static void DrawHeader(ReadOnlySpan<byte> label)
239
236
ImUtf8 . CollapsingHeader ( label , ImGuiTreeNodeFlags . Leaf ) ;
240
237
}
241
238
239
+ private bool DrawRowHeader ( int rowIdx , bool disabled )
240
+ {
241
+ ColorTableCopyClipboardButton ( rowIdx ) ;
242
+ ImUtf8 . SameLineInner ( ) ;
243
+ var ret = ColorTablePasteFromClipboardButton ( rowIdx , disabled ) ;
244
+ ImUtf8 . SameLineInner ( ) ;
245
+ ColorTableRowHighlightButton ( rowIdx , disabled ) ;
246
+
247
+ ImGui . SameLine ( ) ;
248
+ CenteredTextInRest ( $ "Row { ( rowIdx >> 1 ) + 1 } { "AB" [ rowIdx & 1 ] } ") ;
249
+
250
+ return ret ;
251
+ }
252
+
242
253
private static bool DrawColors ( ColorTable table , ColorDyeTable ? dyeTable , DyePack ? dyePack , int rowIdx )
243
254
{
244
255
var dyeOffset = ImGui . GetContentRegionAvail ( ) . X
0 commit comments