TSharedRef<SWidget> UEditableText::RebuildWidget() { FString FontPath = FPaths::GameContentDir() / Font.FontName.ToString(); if ( !FPaths::FileExists(FontPath) ) { FontPath = FPaths::EngineContentDir() / Font.FontName.ToString(); } MyEditableText = SNew(SEditableText) .Style(&WidgetStyle) .Font(FSlateFontInfo(FontPath, Font.Size)) .MinDesiredWidth(MinimumDesiredWidth) .IsCaretMovedWhenGainFocus(IsCaretMovedWhenGainFocus) .SelectAllTextWhenFocused(SelectAllTextWhenFocused) .RevertTextOnEscape(RevertTextOnEscape) .ClearKeyboardFocusOnCommit(ClearKeyboardFocusOnCommit) .SelectAllTextOnCommit(SelectAllTextOnCommit) .OnTextChanged(BIND_UOBJECT_DELEGATE(FOnTextChanged, HandleOnTextChanged)) .OnTextCommitted(BIND_UOBJECT_DELEGATE(FOnTextCommitted, HandleOnTextCommitted)) ; return BuildDesignTimeWidget( MyEditableText.ToSharedRef() ); }
void SARActionItemWidget::Construct(const FArguments& InArgs) { OwnerHUD = InArgs._OwnerHUD; MyPC = InArgs._MyPC; CurrentAbility = InArgs._CurrentAbility; SlotType = InArgs._SlotType; AbilityComp = InArgs._AbilityComp; ActionData = nullptr; DrawAbility(); ChildSlot [ SNew(SBox) .WidthOverride(50) .HeightOverride(50) [ SNew(SOverlay) + SOverlay::Slot() [ SNew(SImage) .Image(this, &SARActionItemWidget::GetAbilityIcon) //SNew(STextBlock) //.Text(FText::FromName("Buton")) ] + SOverlay::Slot() [ SNew(STextBlock) .ShadowColorAndOpacity(FLinearColor::Black) .ColorAndOpacity(FLinearColor::White) .ShadowOffset(FIntPoint(-1, 1)) .Font(FSlateFontInfo("Veranda", 16)) .Text(this, &SARActionItemWidget::GetCurrentCooldown) ] ] ]; }
UMultiLineEditableTextBox::UMultiLineEditableTextBox(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) { ForegroundColor_DEPRECATED = FLinearColor::Black; BackgroundColor_DEPRECATED = FLinearColor::White; ReadOnlyForegroundColor_DEPRECATED = FLinearColor::Black; SMultiLineEditableTextBox::FArguments Defaults; WidgetStyle = *Defaults._Style; TextStyle = *Defaults._TextStyle; AllowContextMenu = Defaults._AllowContextMenu.Get(); AutoWrapText = true; if (!IsRunningDedicatedServer()) { static ConstructorHelpers::FObjectFinder<UFont> RobotoFontObj(TEXT("/Engine/EngineFonts/Roboto")); Font_DEPRECATED = FSlateFontInfo(RobotoFontObj.Object, 12, FName("Bold")); WidgetStyle.SetFont(Font_DEPRECATED); WidgetStyle.SetForegroundColor(ForegroundColor_DEPRECATED); WidgetStyle.SetBackgroundColor(BackgroundColor_DEPRECATED); WidgetStyle.SetReadOnlyForegroundColor(ReadOnlyForegroundColor_DEPRECATED); } }
UEditableTextBox::UEditableTextBox(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) { ForegroundColor = FLinearColor::Black; BackgroundColor = FLinearColor::White; ReadOnlyForegroundColor = FLinearColor::Black; static ConstructorHelpers::FObjectFinder<UFont> RobotoFontObj(TEXT("/Engine/EngineFonts/Roboto")); Font = FSlateFontInfo(RobotoFontObj.Object, 12, FName("Bold")); // Grab other defaults from slate arguments. SEditableTextBox::FArguments Defaults; IsReadOnly = Defaults._IsReadOnly.Get(); IsPassword = Defaults._IsPassword.Get(); MinimumDesiredWidth = Defaults._MinDesiredWidth.Get(); Padding = Defaults._Padding.Get(); IsCaretMovedWhenGainFocus = Defaults._IsCaretMovedWhenGainFocus.Get(); SelectAllTextWhenFocused = Defaults._SelectAllTextWhenFocused.Get(); RevertTextOnEscape = Defaults._RevertTextOnEscape.Get(); ClearKeyboardFocusOnCommit = Defaults._ClearKeyboardFocusOnCommit.Get(); SelectAllTextOnCommit = Defaults._SelectAllTextOnCommit.Get(); WidgetStyle = *Defaults._Style; }
UEditableTextBox::UEditableTextBox(const FPostConstructInitializeProperties& PCIP) : Super(PCIP) { ForegroundColor = FLinearColor::Black; BackgroundColor = FLinearColor::White; ReadOnlyForegroundColor = FLinearColor::Black; // HACK Special font initialization hack since there are no font assets yet for slate. Font = FSlateFontInfo(TEXT("Slate/Fonts/Roboto-Bold.ttf"), 12); // Grab other defaults from slate arguments. SEditableTextBox::FArguments Defaults; IsReadOnly = Defaults._IsReadOnly.Get(); IsPassword = Defaults._IsReadOnly.Get(); MinimumDesiredWidth = Defaults._MinDesiredWidth.Get(); Padding = Defaults._Padding.Get(); IsCaretMovedWhenGainFocus = Defaults._IsCaretMovedWhenGainFocus.Get(); SelectAllTextWhenFocused = Defaults._SelectAllTextWhenFocused.Get(); RevertTextOnEscape = Defaults._RevertTextOnEscape.Get(); ClearKeyboardFocusOnCommit = Defaults._ClearKeyboardFocusOnCommit.Get(); SelectAllTextOnCommit = Defaults._SelectAllTextOnCommit.Get(); WidgetStyle = *Defaults._Style; }
void SAuthorizingPlugin::Construct(const FArguments& InArgs, const TSharedRef<SWindow>& InParentWindow, const FText& InPluginFriendlyName, const FString& InPluginItemId, const FString& InPluginOfferId, TFunction<void()> InAuthorizedCallback) { CurrentState = EPluginAuthorizationState::Initializing; WaitingTime = 0; ParentWindow = InParentWindow; PluginFriendlyName = InPluginFriendlyName; PluginItemId = InPluginItemId; PluginOfferId = InPluginOfferId; AuthorizedCallback = InAuthorizedCallback; InParentWindow->SetOnWindowClosed(FOnWindowClosed::CreateSP(this, &SAuthorizingPlugin::OnWindowClosed)); bUserInterrupted = true; RegisterActiveTimer(0.f, FWidgetActiveTimerDelegate::CreateSP(this, &SAuthorizingPlugin::RefreshStatus)); ChildSlot [ SNew(SBox) .MinDesiredWidth(500) [ SNew(SBorder) .BorderImage(FEditorStyle::GetBrush("ToolPanel.GroupBorder")) [ SNew(SVerticalBox) + SVerticalBox::Slot() .FillHeight(1.0f) .Padding(10, 30, 10, 20) [ SNew(SHorizontalBox) + SHorizontalBox::Slot() .AutoWidth() .VAlign(VAlign_Center) [ SNew(SThrobber) ] + SHorizontalBox::Slot() .AutoWidth() .VAlign(VAlign_Center) .Padding(10, 0) [ SNew(STextBlock) .Text(this, &SAuthorizingPlugin::GetWaitingText) .Font(FSlateFontInfo(FPaths::EngineContentDir() / TEXT("Slate/Fonts/Roboto-Bold.ttf"), 12)) ] ] + SVerticalBox::Slot() .AutoHeight() .HAlign(HAlign_Right) .Padding(10) [ SNew(SButton) .Text(LOCTEXT("CancelText", "Cancel")) .OnClicked(this, &SAuthorizingPlugin::OnCancel) ] ] ] ]; TSharedRef<IPortalServiceLocator> ServiceLocator = GEditor->GetServiceLocator(); PortalWindowService = ServiceLocator->GetServiceRef<IPortalApplicationWindow>(); PortalUserService = ServiceLocator->GetServiceRef<IPortalUser>(); PortalUserLoginService = ServiceLocator->GetServiceRef<IPortalUserLogin>(); }
TSharedRef< FSlateStyleSet > FFriendsAndChatModuleStyle::Create(FFriendsAndChatStyle FriendStyle) { TSharedRef< FSlateStyleSet > Style = MakeShareable(new FSlateStyleSet("FriendsAndChatStyle")); const FTextBlockStyle DefaultText = FTextBlockStyle(FriendStyle.FriendsChatStyle.TextStyle) .SetFont(FriendStyle.FriendsNormalFontStyle.FriendsFontSmall); // Name Style const FTextBlockStyle GlobalChatFont = FTextBlockStyle(DefaultText) .SetFont(FriendStyle.FriendsNormalFontStyle.FriendsFontNormalBold) .SetColorAndOpacity(FriendStyle.FriendsChatStyle.GlobalChatColor); const FTextBlockStyle GameChatFont = FTextBlockStyle(DefaultText) .SetFont(FriendStyle.FriendsNormalFontStyle.FriendsFontNormalBold) .SetColorAndOpacity(FriendStyle.FriendsChatStyle.GameChatColor); const FTextBlockStyle PartyChatFont = FTextBlockStyle(DefaultText) .SetFont(FriendStyle.FriendsNormalFontStyle.FriendsFontNormalBold) .SetColorAndOpacity(FriendStyle.FriendsChatStyle.PartyChatColor); const FTextBlockStyle WhisperChatFont = FTextBlockStyle(DefaultText) .SetFont(FriendStyle.FriendsNormalFontStyle.FriendsFontNormalBold) .SetColorAndOpacity(FriendStyle.FriendsChatStyle.WhisplerChatColor); const FButtonStyle UserNameButton = FButtonStyle() .SetNormal(FSlateNoResource()) .SetPressed(FSlateNoResource()) .SetHovered(FSlateNoResource()); const FHyperlinkStyle GlobalChatHyperlink = FHyperlinkStyle() .SetUnderlineStyle(UserNameButton) .SetTextStyle(GlobalChatFont) .SetPadding(FMargin(0.0f)); const FHyperlinkStyle GameChatHyperlink = FHyperlinkStyle() .SetUnderlineStyle(UserNameButton) .SetTextStyle(GameChatFont) .SetPadding(FMargin(0.0f)); const FHyperlinkStyle PartyChatHyperlink = FHyperlinkStyle() .SetUnderlineStyle(UserNameButton) .SetTextStyle(PartyChatFont) .SetPadding(FMargin(0.0f)); const FHyperlinkStyle WhisperChatHyperlink = FHyperlinkStyle() .SetUnderlineStyle(UserNameButton) .SetTextStyle(WhisperChatFont) .SetPadding(FMargin(0.0f)); const FHyperlinkStyle DefaultChatHyperlink = FHyperlinkStyle() .SetUnderlineStyle(UserNameButton) .SetTextStyle(DefaultText) .SetPadding(FMargin(0.0f)); Style->Set("UserNameTextStyle.Default", DefaultText); Style->Set("UserNameTextStyle.GlobalHyperlink", GlobalChatHyperlink); Style->Set("UserNameTextStyle.GameHyperlink", GameChatHyperlink); Style->Set("UserNameTextStyle.PartyHyperlink", GameChatHyperlink); Style->Set("UserNameTextStyle.Whisperlink", WhisperChatHyperlink); Style->Set("UserNameTextStyle.DefaultHyperlink", DefaultChatHyperlink); Style->Set("UserNameTextStyle.GlobalTextStyle", GlobalChatFont); Style->Set("UserNameTextStyle.GameTextStyle", GameChatFont); Style->Set("UserNameTextStyle.PartyTextStyle", PartyChatFont); Style->Set("UserNameTextStyle.WhisperTextStyle", WhisperChatFont); Style->Set("MessageBreak", FTextBlockStyle(DefaultText) .SetFont(FSlateFontInfo( FriendStyle.FriendsNormalFontStyle.FriendsFontSmall.FontObject, 6, FriendStyle.FriendsNormalFontStyle.FriendsFontSmall.TypefaceFontName ))); Style->Set("GlobalChatIcon", FInlineTextImageStyle() .SetImage(FriendStyle.FriendsChatStyle.ChatGlobalBrush) .SetBaseline(0)); Style->Set("WhisperChatIcon", FInlineTextImageStyle() .SetImage(FriendStyle.FriendsChatStyle.ChatWhisperBrush) .SetBaseline(0)); Style->Set("PartyChatIcon", FInlineTextImageStyle() .SetImage(FriendStyle.FriendsChatStyle.ChatGameBrush) .SetBaseline(0)); return Style; }
int32 SColorGradientEditor::OnPaint( const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled ) const { const TSharedRef< FSlateFontMeasure > FontMeasureService = FSlateApplication::Get().GetRenderer()->GetFontMeasureService(); if( CurveOwner ) { // Split the geometry into areas for stops and the gradient FGeometry ColorMarkAreaGeometry = GetColorMarkAreaGeometry( AllottedGeometry ); FGeometry AlphaMarkAreaGeometry = GetAlphaMarkAreaGeometry( AllottedGeometry ); FGeometry GradientAreaGeometry = AllottedGeometry.MakeChild( FVector2D(0.0f, 16.0f), FVector2D( AllottedGeometry.Size.X, AllottedGeometry.Size.Y - 30.0f ) ); bool bEnabled = ShouldBeEnabled( bParentEnabled ); ESlateDrawEffect::Type DrawEffects = bEnabled ? ESlateDrawEffect::None : ESlateDrawEffect::DisabledEffect; // Pixel to value input converter FTrackScaleInfo ScaleInfo(ViewMinInput.Get(), ViewMaxInput.Get(), 0.0f, 1.0f, GradientAreaGeometry.Size); // The start and end location in slate units of the area to draw int32 Start = 0; int32 Finish = FMath::TruncToInt( AllottedGeometry.Size.X ); TArray<FSlateGradientStop> Stops; // If no alpha keys are available, treat the curve as being completely opaque for drawing purposes bool bHasAnyAlphaKeys = CurveOwner->HasAnyAlphaKeys(); // If any transpareny (A < 1) is found, we'll draw a checkerboard to visualize the color with alpha bool bHasTransparency = false; // Sample the curve every 2 units. THe curve could be non-linear so sampling at each stop would display an incorrect gradient for( int32 CurrentStep = Start; CurrentStep < Finish; CurrentStep+=2 ) { // Figure out the time from the current screen unit float Time = ScaleInfo.LocalXToInput(CurrentStep); // Sample the curve FLinearColor Color = CurveOwner->GetLinearColorValue( Time ); if( !bHasAnyAlphaKeys ) { // Only show alpha if there is at least one key. For some curves, alpha may not be important Color.A = 1.0f; bHasTransparency = false; } else { bHasTransparency |= (Color.A < 1.0f); } Stops.Add( FSlateGradientStop( FVector2D( CurrentStep, 0.0f ), Color ) ); } if( Stops.Num() > 0 ) { if( bHasTransparency ) { // Draw a checkerboard behind there is any transparency visible FSlateDrawElement::MakeBox ( OutDrawElements, LayerId, GradientAreaGeometry.ToPaintGeometry(), FEditorStyle::GetBrush("Checkerboard"), MyClippingRect, DrawEffects ); } // Draw the color gradient FSlateDrawElement::MakeGradient ( OutDrawElements, LayerId, GradientAreaGeometry.ToPaintGeometry(), Stops, Orient_Vertical, MyClippingRect, DrawEffects, false ); } // Get actual editable stop marks TArray<FGradientStopMark> ColorMarks; TArray<FGradientStopMark> AlphaMarks; GetGradientStopMarks( ColorMarks, AlphaMarks ); // Draw each color stop for( int32 ColorIndex = 0; ColorIndex < ColorMarks.Num(); ++ColorIndex ) { const FGradientStopMark& Mark = ColorMarks[ColorIndex]; float XVal = ScaleInfo.InputToLocalX( Mark.Time ); // Dont draw stops which are not visible if( XVal >= 0 && XVal <= ColorMarkAreaGeometry.Size.X ) { FLinearColor Color = CurveOwner->GetLinearColorValue( Mark.Time ); Color.A = 1.0f; DrawGradientStopMark( Mark, ColorMarkAreaGeometry, XVal, Color, OutDrawElements, LayerId, MyClippingRect, DrawEffects, true, InWidgetStyle ); } } // Draw each alpha stop for( int32 ColorIndex = 0; ColorIndex < AlphaMarks.Num(); ++ColorIndex ) { const FGradientStopMark& Mark = AlphaMarks[ColorIndex]; float XVal = ScaleInfo.InputToLocalX( Mark.Time ); // Dont draw stops which are not visible if( XVal >= 0 && XVal <= AlphaMarkAreaGeometry.Size.X ) { float Alpha = CurveOwner->GetLinearColorValue( Mark.Time ).A; DrawGradientStopMark( Mark, AlphaMarkAreaGeometry, XVal, FLinearColor( Alpha, Alpha, Alpha, 1.0f ), OutDrawElements, LayerId, MyClippingRect, DrawEffects, false, InWidgetStyle ); } } // Draw some hint messages about how to add stops if no stops exist if( ColorMarks.Num() == 0 && AlphaMarks.Num() == 0 && IsEditingEnabled.Get() == true ) { static FString GradientColorMessage( LOCTEXT("ClickToAddColorStop", "Click in this area add color stops").ToString() ); static FString GradientAlphaMessage( LOCTEXT("ClickToAddAlphaStop", "Click in this area add opacity stops").ToString() ); // Draw the text centered in the color region { FVector2D StringSize = FontMeasureService->Measure( GradientColorMessage, FSlateFontInfo( FPaths::EngineContentDir() / TEXT("Slate/Fonts/Roboto-Regular.ttf"), 8 ) ); FPaintGeometry PaintGeom = ColorMarkAreaGeometry.ToPaintGeometry(FSlateLayoutTransform(FVector2D((ColorMarkAreaGeometry.Size.X - StringSize.X) * 0.5f, 1.0f))); FSlateDrawElement::MakeText ( OutDrawElements, LayerId, PaintGeom, GradientColorMessage, FSlateFontInfo( FPaths::EngineContentDir() / TEXT("Slate/Fonts/Roboto-Regular.ttf"), 8 ), MyClippingRect, DrawEffects, FLinearColor( .5f, .5f, .5f, .85f ) ); } // Draw the text centered in the alpha region { FVector2D StringSize = FontMeasureService->Measure( GradientAlphaMessage, FSlateFontInfo( FPaths::EngineContentDir() / TEXT("Slate/Fonts/Roboto-Regular.ttf"), 8 ) ); FPaintGeometry PaintGeom = AlphaMarkAreaGeometry.ToPaintGeometry(FSlateLayoutTransform(FVector2D((AlphaMarkAreaGeometry.Size.X - StringSize.X) * 0.5f, 1.0f))); FSlateDrawElement::MakeText ( OutDrawElements, LayerId, PaintGeom, GradientAlphaMessage, FSlateFontInfo( FPaths::EngineContentDir() / TEXT("Slate/Fonts/Roboto-Regular.ttf"), 8 ), MyClippingRect, DrawEffects, FLinearColor( .5f, .5f, .5f, .85f ) ); } } } return LayerId; }
TSharedRef< FSlateStyleSet > FFriendsAndChatModuleStyle::Create(FFriendsAndChatStyle FriendStyle) { TSharedRef< FSlateStyleSet > Style = MakeShareable(new FSlateStyleSet("FriendsAndChatStyle")); const FButtonStyle UserNameButton = FButtonStyle() .SetNormal(FSlateNoResource()) .SetPressed(FSlateNoResource()) .SetHovered(FSlateNoResource()); // Small { const FTextBlockStyle DefaultTextSmall = FTextBlockStyle(FriendStyle.FriendsChatStyle.TextStyle) .SetFont(FriendStyle.ChatFontStyle.FriendsFontSmallBold); const FTextBlockStyle GlobalChatFontSmall = FTextBlockStyle(DefaultTextSmall) .SetColorAndOpacity(FriendStyle.FriendsChatStyle.GlobalHyperlinkChatColor); const FTextBlockStyle GameChatFontSmall = FTextBlockStyle(DefaultTextSmall) .SetColorAndOpacity(FriendStyle.FriendsChatStyle.GameHyperlinkChatColor); const FTextBlockStyle TeamChatFontSmall = FTextBlockStyle(DefaultTextSmall) .SetColorAndOpacity(FriendStyle.FriendsChatStyle.TeamHyperlinkChatColor); const FTextBlockStyle PartyChatFontSmall = FTextBlockStyle(DefaultTextSmall) .SetColorAndOpacity(FriendStyle.FriendsChatStyle.PartyHyperlinkChatColor); const FTextBlockStyle WhisperChatFontSmall = FTextBlockStyle(DefaultTextSmall) .SetColorAndOpacity(FriendStyle.FriendsChatStyle.WhisperHyperlinkChatColor); const FHyperlinkStyle GlobalChatHyperlinkSmall = FHyperlinkStyle() .SetUnderlineStyle(UserNameButton) .SetTextStyle(GlobalChatFontSmall) .SetPadding(FMargin(0.0f)); const FHyperlinkStyle GameChatHyperlinkSmall = FHyperlinkStyle() .SetUnderlineStyle(UserNameButton) .SetTextStyle(GameChatFontSmall) .SetPadding(FMargin(0.0f)); const FHyperlinkStyle TeamChatHyperlinkSmall = FHyperlinkStyle() .SetUnderlineStyle(UserNameButton) .SetTextStyle(TeamChatFontSmall) .SetPadding(FMargin(0.0f)); const FHyperlinkStyle PartyChatHyperlinkSmall = FHyperlinkStyle() .SetUnderlineStyle(UserNameButton) .SetTextStyle(PartyChatFontSmall) .SetPadding(FMargin(0.0f)); const FHyperlinkStyle WhisperChatHyperlinkSmall = FHyperlinkStyle() .SetUnderlineStyle(UserNameButton) .SetTextStyle(WhisperChatFontSmall) .SetPadding(FMargin(0.0f)); const FHyperlinkStyle DefaultChatHyperlinkSmall = FHyperlinkStyle() .SetUnderlineStyle(UserNameButton) .SetTextStyle(DefaultTextSmall) .SetPadding(FMargin(0.0f)); Style->Set("UserNameTextStyle.DefaultSmall", DefaultTextSmall); Style->Set("UserNameTextStyle.GlobalHyperlinkSmall", GlobalChatHyperlinkSmall); Style->Set("UserNameTextStyle.GameHyperlinkSmall", GameChatHyperlinkSmall); Style->Set("UserNameTextStyle.TeamHyperlinkSmall", TeamChatHyperlinkSmall); Style->Set("UserNameTextStyle.PartyHyperlinkSmall", PartyChatHyperlinkSmall); Style->Set("UserNameTextStyle.WhisperlinkSmall", WhisperChatHyperlinkSmall); Style->Set("UserNameTextStyle.DefaultHyperlinkSmall", DefaultChatHyperlinkSmall); Style->Set("UserNameTextStyle.GlobalTextStyleSmall", GlobalChatFontSmall); Style->Set("UserNameTextStyle.GameTextStyleSmall", GameChatFontSmall); Style->Set("UserNameTextStyle.TeamTextStyleSmall", TeamChatFontSmall); Style->Set("UserNameTextStyle.PartyTextStyleSmall", PartyChatFontSmall); Style->Set("UserNameTextStyle.WhisperTextStyleSmall", WhisperChatFontSmall); Style->Set("MessageBreak", FTextBlockStyle(DefaultTextSmall) .SetFont(FSlateFontInfo( FriendStyle.FriendsNormalFontStyle.FriendsFontSmall.FontObject, 6, FriendStyle.FriendsNormalFontStyle.FriendsFontSmall.TypefaceFontName ))); } // Normal { const FTextBlockStyle DefaultText = FTextBlockStyle(FriendStyle.FriendsChatStyle.TextStyle) .SetFont(FriendStyle.ChatFontStyle.FriendsFontNormalBold); const FTextBlockStyle GlobalChatFont = FTextBlockStyle(DefaultText) .SetColorAndOpacity(FriendStyle.FriendsChatStyle.GlobalHyperlinkChatColor); const FTextBlockStyle GameChatFont = FTextBlockStyle(DefaultText) .SetColorAndOpacity(FriendStyle.FriendsChatStyle.GameHyperlinkChatColor); const FTextBlockStyle TeamChatFont = FTextBlockStyle(DefaultText) .SetColorAndOpacity(FriendStyle.FriendsChatStyle.TeamHyperlinkChatColor); const FTextBlockStyle PartyChatFont = FTextBlockStyle(DefaultText) .SetColorAndOpacity(FriendStyle.FriendsChatStyle.PartyHyperlinkChatColor); const FTextBlockStyle WhisperChatFont = FTextBlockStyle(DefaultText) .SetColorAndOpacity(FriendStyle.FriendsChatStyle.WhisperHyperlinkChatColor); const FHyperlinkStyle GlobalChatHyperlink = FHyperlinkStyle() .SetUnderlineStyle(UserNameButton) .SetTextStyle(GlobalChatFont) .SetPadding(FMargin(0.0f)); const FHyperlinkStyle GameChatHyperlink = FHyperlinkStyle() .SetUnderlineStyle(UserNameButton) .SetTextStyle(GameChatFont) .SetPadding(FMargin(0.0f)); const FHyperlinkStyle TeamChatHyperlink = FHyperlinkStyle() .SetUnderlineStyle(UserNameButton) .SetTextStyle(TeamChatFont) .SetPadding(FMargin(0.0f)); const FHyperlinkStyle PartyChatHyperlink = FHyperlinkStyle() .SetUnderlineStyle(UserNameButton) .SetTextStyle(PartyChatFont) .SetPadding(FMargin(0.0f)); const FHyperlinkStyle WhisperChatHyperlink = FHyperlinkStyle() .SetUnderlineStyle(UserNameButton) .SetTextStyle(WhisperChatFont) .SetPadding(FMargin(0.0f)); const FHyperlinkStyle DefaultChatHyperlink = FHyperlinkStyle() .SetUnderlineStyle(UserNameButton) .SetTextStyle(DefaultText) .SetPadding(FMargin(0.0f)); Style->Set("UserNameTextStyle.Default", DefaultText); Style->Set("UserNameTextStyle.GlobalHyperlink", GlobalChatHyperlink); Style->Set("UserNameTextStyle.GameHyperlink", GameChatHyperlink); Style->Set("UserNameTextStyle.TeamHyperlink", TeamChatHyperlink); Style->Set("UserNameTextStyle.PartyHyperlink", PartyChatHyperlink); Style->Set("UserNameTextStyle.Whisperlink", WhisperChatHyperlink); Style->Set("UserNameTextStyle.DefaultHyperlink", DefaultChatHyperlink); Style->Set("UserNameTextStyle.GlobalTextStyle", GlobalChatFont); Style->Set("UserNameTextStyle.GameTextStyle", GameChatFont); Style->Set("UserNameTextStyle.TeamTextStyle", TeamChatFont); Style->Set("UserNameTextStyle.PartyTextStyle", PartyChatFont); Style->Set("UserNameTextStyle.WhisperTextStyle", WhisperChatFont); } // Large { const FTextBlockStyle DefaultTextLarge = FTextBlockStyle(FriendStyle.FriendsChatStyle.TextStyle) .SetFont(FriendStyle.ChatFontStyle.FriendsFontLargeBold); const FTextBlockStyle GlobalChatFontLarge = FTextBlockStyle(DefaultTextLarge) .SetColorAndOpacity(FriendStyle.FriendsChatStyle.GlobalHyperlinkChatColor); const FTextBlockStyle GameChatFontLarge = FTextBlockStyle(DefaultTextLarge) .SetColorAndOpacity(FriendStyle.FriendsChatStyle.GameHyperlinkChatColor); const FTextBlockStyle TeamChatFontLarge = FTextBlockStyle(DefaultTextLarge) .SetColorAndOpacity(FriendStyle.FriendsChatStyle.TeamHyperlinkChatColor); const FTextBlockStyle PartyChatFontLarge = FTextBlockStyle(DefaultTextLarge) .SetColorAndOpacity(FriendStyle.FriendsChatStyle.PartyHyperlinkChatColor); const FTextBlockStyle WhisperChatFontLarge = FTextBlockStyle(DefaultTextLarge) .SetColorAndOpacity(FriendStyle.FriendsChatStyle.WhisperHyperlinkChatColor); const FHyperlinkStyle GlobalChatHyperlinkLarge = FHyperlinkStyle() .SetUnderlineStyle(UserNameButton) .SetTextStyle(GlobalChatFontLarge) .SetPadding(FMargin(0.0f)); const FHyperlinkStyle GameChatHyperlinkLarge = FHyperlinkStyle() .SetUnderlineStyle(UserNameButton) .SetTextStyle(GameChatFontLarge) .SetPadding(FMargin(0.0f)); const FHyperlinkStyle TeamChatHyperlinkLarge = FHyperlinkStyle() .SetUnderlineStyle(UserNameButton) .SetTextStyle(TeamChatFontLarge) .SetPadding(FMargin(0.0f)); const FHyperlinkStyle PartyChatHyperlinkLarge = FHyperlinkStyle() .SetUnderlineStyle(UserNameButton) .SetTextStyle(PartyChatFontLarge) .SetPadding(FMargin(0.0f)); const FHyperlinkStyle WhisperChatHyperlinkLarge = FHyperlinkStyle() .SetUnderlineStyle(UserNameButton) .SetTextStyle(WhisperChatFontLarge) .SetPadding(FMargin(0.0f)); const FHyperlinkStyle DefaultChatHyperlinkLarge = FHyperlinkStyle() .SetUnderlineStyle(UserNameButton) .SetTextStyle(DefaultTextLarge) .SetPadding(FMargin(0.0f)); Style->Set("UserNameTextStyle.DefaultLarge", DefaultTextLarge); Style->Set("UserNameTextStyle.GlobalHyperlinkLarge", GlobalChatHyperlinkLarge); Style->Set("UserNameTextStyle.GameHyperlinkLarge", GameChatHyperlinkLarge); Style->Set("UserNameTextStyle.TeamHyperlinkLarge", TeamChatHyperlinkLarge); Style->Set("UserNameTextStyle.PartyHyperlinkLarge", PartyChatHyperlinkLarge); Style->Set("UserNameTextStyle.WhisperlinkLarge", WhisperChatHyperlinkLarge); Style->Set("UserNameTextStyle.DefaultHyperlinkLarge", DefaultChatHyperlinkLarge); Style->Set("UserNameTextStyle.GlobalTextStyleLarge", GlobalChatFontLarge); Style->Set("UserNameTextStyle.GameTextStyleLarge", GameChatFontLarge); Style->Set("UserNameTextStyle.TeamTextStyleLarge", TeamChatFontLarge); Style->Set("UserNameTextStyle.PartyTextStyleLarge", PartyChatFontLarge); Style->Set("UserNameTextStyle.WhisperTextStyleLarge", WhisperChatFontLarge); } return Style; }
void SKeySelector::Construct(const FArguments& InArgs) { SearchText = FText::GetEmpty(); OnKeyChanged = InArgs._OnKeyChanged; CurrentKey = InArgs._CurrentKey; TMap<FName, FKeyTreeItem> TreeRootsForCatgories; // Ensure that Gamepad, Keyboard, and Mouse will appear at the top of the list, other categories will dynamically get added as the keys are encountered TreeRootsForCatgories.Add(EKeys::NAME_GamepadCategory, *new (KeyTreeRoot) FKeyTreeItem(MakeShareable(new FKeyTreeInfo(EKeys::GetMenuCategoryDisplayName(EKeys::NAME_GamepadCategory), nullptr)))); TreeRootsForCatgories.Add(EKeys::NAME_KeyboardCategory, *new (KeyTreeRoot) FKeyTreeItem(MakeShareable(new FKeyTreeInfo(EKeys::GetMenuCategoryDisplayName(EKeys::NAME_KeyboardCategory), nullptr)))); TreeRootsForCatgories.Add(EKeys::NAME_MouseCategory, *new (KeyTreeRoot) FKeyTreeItem(MakeShareable(new FKeyTreeInfo(EKeys::GetMenuCategoryDisplayName(EKeys::NAME_MouseCategory), nullptr)))); TArray<FKey> AllKeys; EKeys::GetAllKeys(AllKeys); for (FKey Key : AllKeys) { if (!InArgs._FilterBlueprintBindable || Key.IsBindableInBlueprints()) { const FName KeyMenuCategory = Key.GetMenuCategory(); FKeyTreeItem* KeyCategory = TreeRootsForCatgories.Find(KeyMenuCategory); if (KeyCategory == nullptr) { KeyCategory = new (KeyTreeRoot) FKeyTreeItem(MakeShareable(new FKeyTreeInfo(EKeys::GetMenuCategoryDisplayName(KeyMenuCategory), nullptr))); TreeRootsForCatgories.Add(KeyMenuCategory, *KeyCategory); } (*KeyCategory)->Children.Add(MakeShareable(new FKeyTreeInfo(FText(), MakeShareable(new FKey(Key))))); } } TreeViewWidth = InArgs._TreeViewWidth; TreeViewHeight = InArgs._TreeViewHeight; CategoryFont = FSlateFontInfo( FPaths::EngineContentDir() / TEXT("Slate/Fonts/Roboto-Bold.ttf"), 9 ); KeyFont = FSlateFontInfo( FPaths::EngineContentDir() / TEXT("Slate/Fonts/Roboto-Regular.ttf"), 10); bHasMultipleValues = InArgs._HasMultipleValues; FilteredKeyTreeRoot = KeyTreeRoot; this->ChildSlot [ SAssignNew(KeyComboButton, SComboButton) .OnGetMenuContent(this, &SKeySelector::GetMenuContent) .ContentPadding(0) .ToolTipText(LOCTEXT("KeySelector", "Select the key value.")) .ButtonContent() [ SNew(SHorizontalBox) + SHorizontalBox::Slot() .AutoWidth() .VAlign(VAlign_Center) .HAlign(HAlign_Center) [ SNew(SImage) .Image(this, &SKeySelector::GetKeyIconImage) ] + SHorizontalBox::Slot() .AutoWidth() .VAlign(VAlign_Center) .HAlign(HAlign_Left) [ SNew(STextBlock) .Text(this, &SKeySelector::GetKeyDescription) .Font(InArgs._Font) ] ] ]; }
/** Construct this widget */ void Construct( const FArguments& InArgs ) { OnCancelClickedDelegate = InArgs._OnCancelClickedDelegate; WeakStack = InArgs._ScopeStack; // This is a temporary widget that needs to be updated over its entire lifespan => has an active timer registered for its entire lifespan RegisterActiveTimer( 0.f, FWidgetActiveTimerDelegate::CreateSP( this, &SSlowTaskWidget::UpdateProgress ) ); TSharedRef<SVerticalBox> VerticalBox = SNew(SVerticalBox) // Construct the main progress bar and text + SVerticalBox::Slot() .AutoHeight() [ SNew(SVerticalBox) + SVerticalBox::Slot() .AutoHeight() .Padding(FMargin(0, 0, 0, 5.f)) .VAlign(VAlign_Center) [ SNew(SBox) .HeightOverride(24.f) [ SNew(SHorizontalBox) + SHorizontalBox::Slot() [ SNew( STextBlock ) .AutoWrapText(true) .Text( this, &SSlowTaskWidget::GetProgressText, 0 ) // The main font size dynamically changes depending on the content .Font( this, &SSlowTaskWidget::GetMainTextFont ) ] + SHorizontalBox::Slot() .Padding(FMargin(5.f, 0, 0, 0)) .AutoWidth() [ SNew( STextBlock ) .Text( this, &SSlowTaskWidget::GetPercentageText ) // The main font size dynamically changes depending on the content .Font( FSlateFontInfo( FPaths::EngineContentDir() / TEXT("Slate/Fonts/Roboto-Light.ttf"), 14, EFontHinting::AutoLight ) ) ] ] ] + SVerticalBox::Slot() .AutoHeight() [ SNew(SBox) .HeightOverride(MainBarHeight) [ SNew(SProgressBar) .BorderPadding(FVector2D::ZeroVector) .Percent( this, &SSlowTaskWidget::GetProgressFraction, 0 ) .BackgroundImage( FEditorStyle::GetBrush("ProgressBar.ThinBackground") ) .FillImage( FEditorStyle::GetBrush("ProgressBar.ThinFill") ) ] ] ] // Secondary progress bars + SVerticalBox::Slot() .Padding(FMargin(0.f, 8.f, 0.f, 0.f)) [ SAssignNew(SecondaryBars, SVerticalBox) ]; if ( OnCancelClickedDelegate.IsBound() ) { VerticalBox->AddSlot() .AutoHeight() .HAlign(HAlign_Center) .Padding(10.0f, 7.0f) [ SNew(SButton) .Text( NSLOCTEXT("FeedbackContextProgress", "Cancel", "Cancel") ) .HAlign(EHorizontalAlignment::HAlign_Center) .OnClicked(this, &SSlowTaskWidget::OnCancel) ]; } SBorder::Construct( SBorder::FArguments() .BorderImage(FEditorStyle::GetBrush("Menu.Background")) .VAlign(VAlign_Center) .Padding(FMargin(FixedPaddingH)) [ SNew(SBox).WidthOverride(FixedWidth) [ VerticalBox ] ] ); // Make sure all our bars are set up UpdateDynamicProgressBars(); }
void SEditorViewportToolbarMenu::Construct( const FArguments& Declaration ) { const TAttribute<FString>& Label = Declaration._Label; const FName ImageName = Declaration._Image; const FSlateBrush* ImageBrush = FEditorStyle::GetBrush( ImageName ); LabelIconBrush = Declaration._LabelIcon; ParentToolBar = Declaration._ParentToolBar; checkf(ParentToolBar.IsValid(), TEXT("The parent toolbar must be specified") ); TSharedPtr<SWidget> ButtonContent; // Create the content for the button. We always use an image over a label if it is valid if( ImageName != NAME_None ) { ButtonContent = SNew( SImage ) .Image( ImageBrush ) .ColorAndOpacity( FSlateColor::UseForeground() ); } else { if( LabelIconBrush.IsBound() || LabelIconBrush.Get() != NULL ) { // Label with an icon to the left const float MenuIconSize = 16.0f; ButtonContent = SNew( SHorizontalBox ) +SHorizontalBox::Slot() .AutoWidth() .Padding( 0.0f, 0.0f, 3.0f, 0.0f ) [ SNew( SBox ) .Visibility( this, &SEditorViewportToolbarMenu::GetLabelIconVisibility ) .WidthOverride( MenuIconSize ) .HeightOverride( MenuIconSize ) [ SNew( SImage ) .Image( LabelIconBrush ) ] ] +SHorizontalBox::Slot() .FillWidth( 1.0f ) [ SNew( STextBlock ) .Font( FSlateFontInfo( FPaths::EngineContentDir() / TEXT("Slate/Fonts/Roboto-Bold.ttf"), 9 ) ) .Text( Label ) ]; } else { // Just the label text, no icon ButtonContent = SNew( STextBlock ) .Font( FSlateFontInfo( FPaths::EngineContentDir() / TEXT("Slate/Fonts/Roboto-Bold.ttf"), 9 ) ) .Text( Label ); } } ChildSlot [ SAssignNew( MenuAnchor, SMenuAnchor ) .Placement( MenuPlacement_BelowAnchor ) [ SNew( SButton ) // Allows users to drag with the mouse to select options after opening the menu */ .ClickMethod( EButtonClickMethod::MouseDown ) .ContentPadding( FMargin( 5.0f, 2.0f ) ) .VAlign( VAlign_Center ) .ButtonStyle( FEditorStyle::Get(), "EditorViewportToolBar.MenuButton" ) .OnClicked( this, &SEditorViewportToolbarMenu::OnMenuClicked ) [ ButtonContent.ToSharedRef() ] ] .OnGetMenuContent( Declaration._OnGetMenuContent ) ]; }
void SGraphTitleBar::Construct( const FArguments& InArgs ) { EdGraphObj = InArgs._EdGraphObj; OnDifferentGraphCrumbClicked = InArgs._OnDifferentGraphCrumbClicked; check(EdGraphObj); Kismet2Ptr = InArgs._Kismet2; check(Kismet2Ptr.IsValid()); // Set-up shared breadcrumb defaults FMargin BreadcrumbTrailPadding = FMargin(4.f, 2.f); const FSlateBrush* BreadcrumbButtonImage = FEditorStyle::GetBrush("BreadcrumbTrail.Delimiter"); this->ChildSlot [ SNew(SBorder) .BorderImage( FEditorStyle::GetBrush( TEXT("Graph.TitleBackground") ) ) .HAlign(HAlign_Fill) .AddMetaData<FTagMetaData>(FTagMetaData(TEXT("EventGraphTitleBar"))) [ SNew(SVerticalBox) // Title text/icon +SVerticalBox::Slot() .AutoHeight() [ SNew(SHorizontalBox) +SHorizontalBox::Slot() .AutoWidth() [ InArgs._HistoryNavigationWidget.ToSharedRef() ] +SHorizontalBox::Slot() .HAlign(HAlign_Center) .FillWidth(1.f) [ SNew(SHorizontalBox) +SHorizontalBox::Slot() .AutoWidth() .Padding( 10,5 ) .VAlign(VAlign_Center) [ SNew(SImage) .Image( this, &SGraphTitleBar::GetTypeGlyph ) ] // show fake 'root' breadcrumb for the title +SHorizontalBox::Slot() .AutoWidth() .VAlign(VAlign_Center) .Padding(BreadcrumbTrailPadding) [ SNew(STextBlock) .Text(this, &SGraphTitleBar::GetBlueprintTitle ) .TextStyle( FEditorStyle::Get(), TEXT("GraphBreadcrumbButtonText") ) .Visibility( this, &SGraphTitleBar::IsGraphBlueprintNameVisible ) ] +SHorizontalBox::Slot() .AutoWidth() .VAlign(VAlign_Center) [ SNew(SImage) .Image( BreadcrumbButtonImage ) .Visibility( this, &SGraphTitleBar::IsGraphBlueprintNameVisible ) ] // New style breadcrumb +SHorizontalBox::Slot() .AutoWidth() .VAlign(VAlign_Center) [ SAssignNew(BreadcrumbTrail, SBreadcrumbTrail<UEdGraph*>) .ButtonStyle(FEditorStyle::Get(), "GraphBreadcrumbButton") .TextStyle(FEditorStyle::Get(), "GraphBreadcrumbButtonText") .ButtonContentPadding( BreadcrumbTrailPadding ) .DelimiterImage( BreadcrumbButtonImage ) .PersistentBreadcrumbs( true ) .OnCrumbClicked( this, &SGraphTitleBar::OnBreadcrumbClicked ) ] +SHorizontalBox::Slot() .AutoWidth() .VAlign(VAlign_Center) [ SNew(STextBlock) .Font( FSlateFontInfo(FPaths::EngineContentDir() / TEXT("Slate/Fonts/Roboto-Regular.ttf"), 14 ) ) .ColorAndOpacity( FLinearColor(1,1,1,0.5) ) .Text( this, &SGraphTitleBar::GetTitleExtra ) ] ] ] ] ]; RebuildBreadcrumbTrail(); UBlueprint* BlueprintObj = FBlueprintEditorUtils::FindBlueprintForGraph(this->EdGraphObj); if (BlueprintObj) { bShowBlueprintTitle = true; BlueprintTitle = FText::FromString(BlueprintObj->GetFriendlyName()); // Register for notifications to refresh UI if( Kismet2Ptr.IsValid() ) { Kismet2Ptr.Pin()->OnRefresh().AddRaw(this, &SGraphTitleBar::Refresh); } } }
void SARInventoryItem::Construct(const FArguments& InArgs) { //////////////////////////////////////////////////////////////////////////////////////////////////// /////Get handle on game resources from GameModule //MyUIResources = FModuleManager::GetModuleChecked<ActionRPGGame>(FName("ActionRPGGame")).GetSlateGameResources(); MyUIResources = FSlateGameResources::New("Batons", "/Game/UI", "/Game/UI"); //////////////////////////////////////////////////////////////////////////////////////////////////// /////Get handle on spell_heal Slate Brush /////name: member_icon Icon = MyUIResources->GetBrush(FName("Inactive_Brush")); ImageColor = FSlateColor(FLinearColor(0, 1, 0, 1)); OwnerHUD = InArgs._OwnerHUD; MyPC = InArgs._MyPC; Inventory = InArgs._Inventory; TextTest = FText::FromName("Leave"); //SyncInventory(); ChildSlot .VAlign(VAlign_Bottom) .HAlign(HAlign_Fill) [ SNew(SOverlay) //.VAlign(VAlign_Bottom) //.HAlign(HAlign_Fill) //.Padding(3) //.WidthOverride(50) //.HeightOverride(50) +SOverlay::Slot() [ SAssignNew(ActionGrid, SGridPanel) //SNew(SImage) //.Image(this, &SARInventoryItem::GetImage) //.ColorAndOpacity(this, &SARInventoryItem::GetColor) //SNew(STextBlock) //.Text(this, &SARInventoryItem::GetText) //.ColorAndOpacity(FSlateColor(FLinearColor(0, 1, 0, 1))) //.Image() //SAssignNew(TileView, STileView<TSharedPtr<FARItemInfo>>) //.ListItemsSource(&ClonedInventory) //.OnGenerateTile(this, &SARInventoryItem::MakeTileViewWidget) //.ListItemSource(&ClonedInventory) ] ]; if (Inventory.Num() > 0) { for (int32 i = 0; i < 5; i++) { for (int32 j = 0; j < 10; j++) { ActionGrid->AddSlot(i, j) .HAlign(HAlign_Center) .VAlign(VAlign_Center) [ SNew(STextBlock) .Text(FText::FromName("Test")) .Font(FSlateFontInfo("Veranda", 16)) //SNew(SARInventoryItem) //.OwnerHUD(OwnerHUD) //.MyPC(MyPC) //.Inventory(&ClonedInventory) //.OnMouseEnter(this, &SARButtonWidget::DoNothing) //.OnMouseLeave(this, &SARButtonWidget::DoNothing) ]; } } } }