@@ -36,7 +36,7 @@ void SUnicodeBrowserWidget::Construct(FArguments const& InArgs)
36
36
37
37
UUnicodeBrowserOptions::Get ()->OnFontChanged .RemoveAll (this );
38
38
UUnicodeBrowserOptions::Get ()->OnFontChanged .AddLambda ([this , UnicodeBrowser = AsWeak ()]()
39
- {
39
+ {
40
40
if (UnicodeBrowser.IsValid ()){
41
41
if ( CurrentFont.FontObject != UUnicodeBrowserOptions::Get ()->GetFontInfo ().FontObject
42
42
|| CurrentFont.TypefaceFontName != UUnicodeBrowserOptions::Get ()->GetFontInfo ().TypefaceFontName )
@@ -250,8 +250,9 @@ void SUnicodeBrowserWidget::Construct(FArguments const& InArgs)
250
250
];
251
251
252
252
SetSidePanelVisibility (UUnicodeBrowserOptions::Get ()->bShowSidePanel );
253
-
254
- MarkDirty (static_cast <uint8>(EDirtyFlags::INIT) | static_cast <uint8>(EDirtyFlags::FONT));
253
+
254
+ MarkDirty (static_cast <uint8>(EDirtyFlags::INIT));
255
+ MarkDirty (static_cast <uint8>(EDirtyFlags::FONT));
255
256
}
256
257
257
258
UToolMenu* SUnicodeBrowserWidget::CreateMenuSection_Settings ()
@@ -351,27 +352,28 @@ UToolMenu* SUnicodeBrowserWidget::CreateMenuSection_Settings()
351
352
.AutoWidth ()
352
353
[
353
354
SNew (STextBlock)
354
- .Text (INVTEXT (" columns " ))
355
+ .Text (INVTEXT (" cell padding " ))
355
356
]
356
357
+SHorizontalBox::Slot ()
357
358
.Padding (10 , 0 , 10 , 0 )
358
359
.VAlign (VAlign_Center)
359
360
[
360
361
SNew (SSpinBox<int32>)
361
362
.Delta (1 )
362
- .MinValue (1 )
363
- .MaxValue (32 )
364
- .Value_Lambda ([this ]() { return UUnicodeBrowserOptions::Get ()->NumCols ; })
363
+ .MinValue (0 )
364
+ .MaxValue (25 )
365
+ .Value_Lambda ([this ]() { return UUnicodeBrowserOptions::Get ()->GridCellPadding ; })
365
366
.OnValueChanged_Lambda ([this ](int32 CurrentValue)
366
367
{
367
- UUnicodeBrowserOptions::Get ()->NumCols = CurrentValue;
368
+ UUnicodeBrowserOptions::Get ()->GridCellPadding = CurrentValue;
368
369
UUnicodeBrowserOptions::Get ()->TryUpdateDefaultConfigFile ();
369
370
CharactersTileView->RebuildList ();
371
+ MarkDirty (static_cast <uint8>(EDirtyFlags::FONT_STYLE));
370
372
})
371
373
]
372
374
];
373
375
374
- DisplaySettingsSection.AddEntry (FToolMenuEntry::InitWidget (" BrowserNumColumns " , Widget, FText::GetEmpty (), false , false , false , INVTEXT (" you can use CTRL + Shift + MouseWheel to adjust column count in the browser" )));
376
+ DisplaySettingsSection.AddEntry (FToolMenuEntry::InitWidget (" BrowserGridCellPadding " , Widget, FText::GetEmpty (), false , false , false , INVTEXT (" you can use CTRL + Shift + MouseWheel to adjust cell padding in the browser" )));
375
377
}
376
378
377
379
@@ -402,6 +404,7 @@ TSharedRef<ITableRow> SUnicodeBrowserWidget::GenerateItemRow(TSharedPtr<FUnicode
402
404
.UnicodeCharacter (CharacterData)
403
405
.OnMouseMove (this , &SUnicodeBrowserWidget::OnCharacterMouseMove, CharacterData)
404
406
.OnZoomFontSize (this , &SUnicodeBrowserWidget::HandleZoomFont)
407
+ .OnZoomCellPadding (this , &SUnicodeBrowserWidget::HandleZoomPadding)
405
408
];
406
409
}
407
410
@@ -410,6 +413,27 @@ void SUnicodeBrowserWidget::Tick(FGeometry const& AllottedGeometry, double const
410
413
{
411
414
if (DirtyFlags && IsConstructed ()) // wait for the widget to be constructed before updating
412
415
{
416
+ // grid size MUST be evaluated before the font, because FONT flag may set it dirty for the next tick
417
+ if (DirtyFlags & static_cast <uint8>(EDirtyFlags::TILEVIEW_GRID_SIZE))
418
+ {
419
+ double DesiredSize = 0 ;
420
+ for (int ChildIdx = 0 ; ChildIdx < CharactersTileView->GetNumGeneratedChildren (); ChildIdx++){
421
+ if (!CharactersTileView->GetGeneratedChildAt (ChildIdx).Get ()->NeedsPrepass ())
422
+ {
423
+ FVector2D ChildDesiredSize = CharactersTileView->GetGeneratedChildAt (ChildIdx).Get ()->GetDesiredSize ();
424
+ DesiredSize = FMath::Max (DesiredSize, FMath::Max (ChildDesiredSize.X , ChildDesiredSize.X ));
425
+ }
426
+ }
427
+
428
+ if (DesiredSize > 0 ){
429
+ CharactersTileView->SetItemWidth (FMath::Min (DesiredSize, CharactersTileView->GetCachedGeometry ().Size .X / 2.0 ));
430
+ CharactersTileView->SetItemHeight (FMath::Min (DesiredSize, CharactersTileView->GetCachedGeometry ().Size .Y / 2.0 ));
431
+ CharactersTileView->RebuildList ();
432
+ }
433
+
434
+ DirtyFlags &= ~static_cast <uint8>(EDirtyFlags::TILEVIEW_GRID_SIZE);
435
+ }
436
+
413
437
if (DirtyFlags & static_cast <uint8>(EDirtyFlags::FONT))
414
438
{
415
439
CurrentFont = UUnicodeBrowserOptions::Get ()->GetFontInfo ();
@@ -444,11 +468,12 @@ void SUnicodeBrowserWidget::Tick(FGeometry const& AllottedGeometry, double const
444
468
445
469
if (DirtyFlags & static_cast <uint8>(EDirtyFlags::FONT_STYLE))
446
470
{
447
- CharactersTileView->RebuildList ();
471
+ CharactersTileView->RebuildList ();
472
+ MarkDirty (static_cast <uint8>(EDirtyFlags::TILEVIEW_GRID_SIZE)); // set grid size dirty
448
473
DirtyFlags &= ~static_cast <uint8>(EDirtyFlags::FONT_STYLE);
449
474
}
450
475
}
451
-
476
+
452
477
if (DirtyFlags & static_cast <uint8>(EDirtyFlags::INIT)){
453
478
if (SidePanel.IsValid () && SidePanel->RangeSelector .IsValid ())
454
479
{
@@ -642,12 +667,14 @@ void SUnicodeBrowserWidget::HandleZoomFont(float Offset)
642
667
}
643
668
644
669
645
- void SUnicodeBrowserWidget::HandleZoomColumns (float Offset)
670
+ void SUnicodeBrowserWidget::HandleZoomPadding (float Offset)
646
671
{
647
- // we want inverted behavior for columns
648
- UUnicodeBrowserOptions::Get ()->NumCols = FMath::Max (1 , FMath::RoundToInt (UUnicodeBrowserOptions::Get ()->NumCols - Offset));
649
-
672
+ // we want inverted behavior for cellpadding
673
+ UUnicodeBrowserOptions::Get ()->GridCellPadding = FMath::Max (0 , FMath::RoundToInt (UUnicodeBrowserOptions::Get ()->GridCellPadding - Offset));
674
+ UUnicodeBrowserOptions::Get ()->TryUpdateDefaultConfigFile ();
675
+
650
676
CharactersTileView->RebuildList ();
677
+ MarkDirty (static_cast <uint8>(EDirtyFlags::FONT_STYLE));
651
678
}
652
679
653
680
END_SLATE_FUNCTION_BUILD_OPTIMIZATION
0 commit comments