@@ -196,6 +196,41 @@ namespace AzToolsFramework
196
196
return { (m_enforceMinWidth ? cumulativeWidth : 0 ), minimumHeight };
197
197
}
198
198
199
+ void DPELayout::CloseColumn (
200
+ QHBoxLayout* currentColumnLayout,
201
+ QRect& itemGeometry,
202
+ int & currentColumnCount,
203
+ const int columnWidth,
204
+ bool allWidgetsUnstretched,
205
+ bool startSpacer,
206
+ bool endSpacer
207
+ )
208
+ {
209
+ // if all widgets in this shared column take up only their minimum width, set the appropriate alignment with spacers
210
+ if (allWidgetsUnstretched)
211
+ {
212
+ if (startSpacer)
213
+ {
214
+ currentColumnLayout->insertSpacerItem (0 , new QSpacerItem (columnWidth, 1 , QSizePolicy::Expanding, QSizePolicy::Fixed));
215
+ }
216
+ if (endSpacer)
217
+ {
218
+ currentColumnLayout->addSpacerItem (new QSpacerItem (columnWidth, 1 , QSizePolicy::Expanding, QSizePolicy::Fixed));
219
+ }
220
+ }
221
+
222
+ // Correctly set the geometry based on the column.
223
+ if (currentColumnCount > 0 )
224
+ {
225
+ itemGeometry.setLeft (itemGeometry.right () + 1 );
226
+ itemGeometry.setRight (itemGeometry.left () + columnWidth);
227
+ }
228
+ currentColumnLayout->setGeometry (itemGeometry);
229
+
230
+ // Count completed columns.
231
+ ++currentColumnCount;
232
+ }
233
+
199
234
void DPELayout::setGeometry (const QRect& rect)
200
235
{
201
236
QLayout::setGeometry (rect);
@@ -310,34 +345,15 @@ namespace AzToolsFramework
310
345
// Close previous column.
311
346
if (!isFirstColumn)
312
347
{
313
- // if all widgets in this shared column take up only their minimum width, set the appropriate alignment with spacers
314
- if (currentColumnNonStretchedWidgetsCount == currentColumnWidgetsCount)
315
- {
316
- QSpacerItem* spacer = new QSpacerItem (columnWidth, 1 , QSizePolicy::Expanding, QSizePolicy::Fixed);
317
- if (startSpacer)
318
- {
319
- currentColumnLayout->insertSpacerItem (0 , spacer);
320
- }
321
- if (endSpacer)
322
- {
323
- currentColumnLayout->addSpacerItem (spacer);
324
- }
325
- }
326
-
327
- // Correctly set the geometry based on the column.
328
- if (currentColumnCount == 0 )
329
- {
330
- currentColumnLayout->setGeometry (itemGeometry);
331
- }
332
- else
333
- {
334
- itemGeometry.setLeft (itemGeometry.right () + 1 );
335
- itemGeometry.setRight (itemGeometry.left () + columnWidth);
336
- currentColumnLayout->setGeometry (itemGeometry);
337
- }
338
-
339
- // Count completed columns.
340
- ++currentColumnCount;
348
+ CloseColumn (
349
+ currentColumnLayout,
350
+ itemGeometry,
351
+ currentColumnCount,
352
+ columnWidth,
353
+ (currentColumnNonStretchedWidgetsCount == currentColumnWidgetsCount),
354
+ startSpacer,
355
+ endSpacer
356
+ );
341
357
}
342
358
343
359
// Create new column.
@@ -370,38 +386,15 @@ namespace AzToolsFramework
370
386
}
371
387
372
388
// Close the last column
373
- // TODO - Avoid repeated code...
374
- // TODO - Check for edge cases of already closed column just in case...
375
- {
376
- // if all widgets in this shared column take up only their minimum width, set the appropriate alignment with spacers
377
- if (currentColumnNonStretchedWidgetsCount == currentColumnWidgetsCount)
378
- {
379
- QSpacerItem* spacer = new QSpacerItem (columnWidth, 1 , QSizePolicy::Expanding, QSizePolicy::Fixed);
380
- if (startSpacer)
381
- {
382
- currentColumnLayout->insertSpacerItem (0 , spacer);
383
- }
384
- if (endSpacer)
385
- {
386
- currentColumnLayout->addSpacerItem (spacer);
387
- }
388
- }
389
-
390
- // Correctly set the geometry based on the column.
391
- if (currentColumnCount == 0 )
392
- {
393
- currentColumnLayout->setGeometry (itemGeometry);
394
- }
395
- else
396
- {
397
- itemGeometry.setLeft (itemGeometry.right () + 1 );
398
- itemGeometry.setRight (itemGeometry.left () + columnWidth);
399
- currentColumnLayout->setGeometry (itemGeometry);
400
- }
401
-
402
- // Count completed columns.
403
- ++currentColumnCount;
404
- }
389
+ CloseColumn (
390
+ currentColumnLayout,
391
+ itemGeometry,
392
+ currentColumnCount,
393
+ columnWidth,
394
+ (currentColumnNonStretchedWidgetsCount == currentColumnWidgetsCount),
395
+ startSpacer,
396
+ endSpacer
397
+ );
405
398
}
406
399
407
400
Qt::Orientations DPELayout::expandingDirections () const
@@ -942,8 +935,6 @@ namespace AzToolsFramework
942
935
childWidget->hide ();
943
936
m_columnLayout->removeWidget (childWidget);
944
937
DocumentPropertyEditor::ReleaseHandler (handlerInfo);
945
- // TODO - Check if we still need something here!
946
- // m_columnLayout->RemoveSharePriorColumn(childIndex);
947
938
948
939
// Replace the existing handler widget with one appropriate for the new type
949
940
auto replacementWidget = theDPE->CreateWidgetForHandler (handlerId, valueAtSubPath);
0 commit comments