MCPcopy Create free account
hub / github.com/URLab-Sim/UnrealRoboticsLab / InitializeProperty

Method InitializeProperty

Source/URLab/Private/UI/MjPropertyRow.cpp:53–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51}
52
53void UMjPropertyRow::InitializeProperty(const FString& InName, EMjPropertyType InType, float InitialValue, FVector2D range, const FString& InDisplayName)
54{
55 PropertyName = InName;
56 PropertyType = InType;
57
58 if (PropertyLabel)
59 {
60 FString Display = InDisplayName.IsEmpty() ? InName : InDisplayName;
61 PropertyLabel->SetText(FText::FromString(Display));
62 }
63
64 // Set UI visibility based on type
65 if (PropertySlider)
66 {
67 PropertySlider->SetVisibility((PropertyType == EMjPropertyType::Slider) ? ESlateVisibility::Visible : ESlateVisibility::Collapsed);
68 SetSliderRange(range);
69 }
70
71 if (PropertyToggle)
72 {
73 PropertyToggle->SetVisibility(PropertyType == EMjPropertyType::Toggle ? ESlateVisibility::Visible : ESlateVisibility::Collapsed);
74 }
75
76 if (ValueDisplay)
77 {
78 ValueDisplay->SetVisibility((PropertyType == EMjPropertyType::Header) ? ESlateVisibility::Collapsed : ESlateVisibility::Visible);
79 }
80
81 // Aesthetic Styling
82 FSlateFontInfo LabelFont = PropertyLabel ? PropertyLabel->GetFont() : FSlateFontInfo();
83 LabelFont.Size = (PropertyType == EMjPropertyType::Header) ? 14 : 11;
84 LabelFont.TypefaceFontName = (PropertyType == EMjPropertyType::Header) ? TEXT("Bold") : TEXT("Regular");
85
86 FLinearColor TextColor = (PropertyType == EMjPropertyType::Header) ? FLinearColor(0.4f, 0.7f, 1.0f, 1.0f) : FLinearColor(0.9f, 0.9f, 0.9f, 1.0f);
87
88 if (PropertyLabel)
89 {
90 PropertyLabel->SetFont(LabelFont);
91 PropertyLabel->SetColorAndOpacity(FSlateColor(TextColor));
92 }
93
94 if (ValueDisplay)
95 {
96 FSlateFontInfo ValFont = ValueDisplay->GetFont();
97 ValFont.Size = 11;
98 ValFont.TypefaceFontName = TEXT("Regular");
99 ValueDisplay->SetFont(ValFont);
100 ValueDisplay->SetColorAndOpacity(FSlateColor(FLinearColor(0.6f, 1.0f, 0.6f, 1.0f))); // nice green for values
101 }
102
103 SetValue(InitialValue);
104
105 if (PropertySlider)
106 {
107 FSliderStyle Style = PropertySlider->GetWidgetStyle();
108 Style.BarThickness = 6.0f; // Make the bar thicker
109 // Create an image size for the thumb since we can't easily change it without a new brush
110 // but we can adjust the thumb image size if we have a default one. Just making the bar thicker often helps a lot.

Callers 1

Calls 1

IsEmptyMethod · 0.80

Tested by

no test coverage detected