2022-12-09 14:18:01 -05:00
// Copyright Epic Games, Inc. All Rights Reserved.
# include "RevisionControlStyle/RevisionControlStyle.h"
2023-11-07 06:18:43 -05:00
# if SOURCE_CONTROL_WITH_SLATE
2022-12-09 14:18:01 -05:00
# include "Styling/SlateStyleRegistry.h"
# include "Styling/SlateStyleMacros.h"
# include "Styling/CoreStyle.h"
# include "Styling/StyleColors.h"
# include "SlateGlobals.h"
# include "Framework/Application/SlateApplication.h"
TSharedPtr < class ISlateStyle > FRevisionControlStyleManager : : DefaultRevisionControlStyleInstance = nullptr ;
FName FRevisionControlStyleManager : : CurrentRevisionControlStyleName ;
FName FDefaultRevisionControlStyle : : StyleName ( " DefaultRevisionControlStyle " ) ;
// FRevisionControlStyleManager
void FRevisionControlStyleManager : : ReloadTextures ( )
{
FSlateApplication : : Get ( ) . GetRenderer ( ) - > ReloadTextureResources ( ) ;
}
const ISlateStyle & FRevisionControlStyleManager : : Get ( )
{
// If the default style instance doesn't exist (first call), create it and set it as active
if ( ! DefaultRevisionControlStyleInstance . IsValid ( ) )
{
DefaultRevisionControlStyleInstance = MakeShared < FDefaultRevisionControlStyle > ( ) ;
SetActiveRevisionControlStyle ( DefaultRevisionControlStyleInstance - > GetStyleSetName ( ) ) ;
}
// Find and get the currently active revision control style
if ( const ISlateStyle * RevisionControlStyle = FSlateStyleRegistry : : FindSlateStyle ( CurrentRevisionControlStyleName ) )
{
return * RevisionControlStyle ;
}
return * DefaultRevisionControlStyleInstance ;
}
FName FRevisionControlStyleManager : : GetStyleSetName ( )
{
return Get ( ) . GetStyleSetName ( ) ;
}
void FRevisionControlStyleManager : : SetActiveRevisionControlStyle ( FName InNewActiveRevisionControlStyleName )
{
// The style needs to be registered with the Slate Style Registry
if ( ! FSlateStyleRegistry : : FindSlateStyle ( InNewActiveRevisionControlStyleName ) )
{
UE_LOG ( LogSlate , Error , TEXT ( " Could not set the active revision control style, make sure the style you are setting exists and is registered with the FSlateStyleRegistry " ) ) ;
}
CurrentRevisionControlStyleName = InNewActiveRevisionControlStyleName ;
}
void FRevisionControlStyleManager : : ResetToDefaultRevisionControlStyle ( )
{
SetActiveRevisionControlStyle ( DefaultRevisionControlStyleInstance - > GetStyleSetName ( ) ) ;
}
// FDefaultRevisionControlStyle
FDefaultRevisionControlStyle : : FDefaultRevisionControlStyle ( ) : FSlateStyleSet ( StyleName )
{
FSlateStyleRegistry : : RegisterSlateStyle ( * this ) ;
SetContentRoot ( FPaths : : EngineContentDir ( ) / TEXT ( " Slate " ) ) ;
// Any new revision control icons should be added here instead of in StarshipStyle. Any icons there that don't exist here should be moved here and used by calling FRevisionControlStyleManager::Get()
// We use a custom teal color for the branched icons
BranchedColor = FLinearColor : : FromSRGBColor ( FColor : : FromHex ( " #00E4A0 " ) ) ;
2024-04-04 14:41:22 -04:00
StatusCheckedOutColor = FLinearColor : : FromSRGBColor ( FColor : : FromHex ( " #1FE44B " ) ) ;
StatusCheckedOutByOtherUserColor = FLinearColor : : FromSRGBColor ( FColor : : FromHex ( " #EF3535 " ) ) ;
StatusNotAtHeadRevisionColor = FLinearColor : : FromSRGBColor ( FColor : : FromHex ( " #E1FF3D " ) ) ;
2024-06-28 03:22:02 -04:00
SnapshotHistoryAdded = FStyleColors : : AccentBlue ;
2024-05-24 04:02:05 -04:00
SnapshotHistoryModified = FLinearColor : : FromSRGBColor ( FColor : : FromHex ( " #F0AD4E " ) ) ;
SnapshotHistoryRemoved = FLinearColor : : FromSRGBColor ( FColor : : FromHex ( " #CD3642 " ) ) ;
2022-12-09 14:18:01 -05:00
// Status icons
Set ( " RevisionControl.Icon " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/Status/RevisionControl " , CoreStyleConstants : : Icon16x16 ) ) ;
Set ( " RevisionControl.Icon.ConnectedBadge " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/Status/RevisionControlBadgeConnected " , CoreStyleConstants : : Icon16x16 , FStyleColors : : Success ) ) ;
Set ( " RevisionControl.Icon.WarningBadge " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/Status/RevisionControlBadgeWarning " , CoreStyleConstants : : Icon16x16 , FStyleColors : : Warning ) ) ;
// Icons for revision control actions
Set ( " RevisionControl.Actions.Sync " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_Sync " , CoreStyleConstants : : Icon16x16 ) ) ;
Set ( " RevisionControl.Actions.CheckOut " , new IMAGE_BRUSH_SVG ( " Starship/Common/check-circle " , CoreStyleConstants : : Icon16x16 ) ) ;
Set ( " RevisionControl.Actions.SyncAndCheckOut " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_SyncAndCheckOut " , CoreStyleConstants : : Icon16x16 ) ) ;
Set ( " RevisionControl.Actions.MakeWritable " , new IMAGE_BRUSH_SVG ( " Starship/Common/edit " , CoreStyleConstants : : Icon16x16 ) ) ;
Set ( " RevisionControl.Actions.Add " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_MarkedForAdd " , CoreStyleConstants : : Icon16x16 ) ) ;
Set ( " RevisionControl.Actions.Submit " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_CheckIn " , CoreStyleConstants : : Icon16x16 ) ) ;
Set ( " RevisionControl.Actions.History " , new IMAGE_BRUSH_SVG ( " Starship/Common/Recent " , CoreStyleConstants : : Icon16x16 ) ) ;
Set ( " RevisionControl.Actions.Diff " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_Diff " , CoreStyleConstants : : Icon16x16 ) ) ;
Set ( " RevisionControl.Actions.Revert " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/icon_SCC_Revert " , CoreStyleConstants : : Icon16x16 ) ) ;
Set ( " RevisionControl.Actions.Merge " , new IMAGE_BRUSH_SVG ( " Starship/Common/Merge " , CoreStyleConstants : : Icon16x16 ) ) ;
Set ( " RevisionControl.Actions.Refresh " , new IMAGE_BRUSH_SVG ( " Starship/Common/Update " , CoreStyleConstants : : Icon16x16 ) ) ;
Set ( " RevisionControl.Actions.ChangeSettings " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/icon_SCC_Change_Source_Control_Settings " , CoreStyleConstants : : Icon16x16 ) ) ;
2023-11-21 12:06:27 -05:00
Set ( " RevisionControl.Actions.Rewind " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_Rewind " , CoreStyleConstants : : Icon16x16 ) ) ;
2022-12-09 14:18:01 -05:00
// Icons representing the various revision control states
2024-02-09 07:47:48 -05:00
Set ( " RevisionControl.Locked " , new IMAGE_BRUSH_SVG ( " Starship/Common/lock " , CoreStyleConstants : : Icon16x16 ) ) ;
Set ( " RevisionControl.Unlocked " , new IMAGE_BRUSH_SVG ( " Starship/Common/lock-unlocked " , CoreStyleConstants : : Icon16x16 ) ) ;
2024-04-04 14:41:22 -04:00
Set ( " RevisionControl.CheckedOut " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/SCC_CheckedOut " , CoreStyleConstants : : Icon16x16 , StatusCheckedOutColor ) ) ;
2022-12-09 14:18:01 -05:00
2024-04-16 23:13:33 -04:00
Set ( " RevisionControl.OpenForAdd " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_MarkedForAdd " , CoreStyleConstants : : Icon16x16 , FStyleColors : : AccentBlue ) ) ;
2022-12-09 14:18:01 -05:00
Set ( " RevisionControl.MarkedForDelete " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/SCC_MarkedForDelete " , CoreStyleConstants : : Icon16x16 , FStyleColors : : Error ) ) ;
2024-04-04 14:41:22 -04:00
Set ( " RevisionControl.CheckedOutByOtherUser " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_CheckedOther " , CoreStyleConstants : : Icon16x16 , StatusCheckedOutByOtherUserColor ) ) ;
2022-12-09 14:18:01 -05:00
Set ( " RevisionControl.CheckedOutByOtherUserBadge " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_CheckedOtherBadge " , CoreStyleConstants : : Icon16x16 , FStyleColors : : AccentBlue ) ) ;
Set ( " RevisionControl.CheckedOutByOtherUserOtherBranch " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_CheckedBranch " , CoreStyleConstants : : Icon16x16 , BranchedColor ) ) ;
Set ( " RevisionControl.CheckedOutByOtherUserOtherBranchBadge " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_CheckedOtherBadge " , CoreStyleConstants : : Icon16x16 , FStyleColors : : Warning ) ) ;
Set ( " RevisionControl.ModifiedOtherBranch " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/SCC_ModifiedOtherBranch " , CoreStyleConstants : : Icon16x16 , BranchedColor ) ) ;
Set ( " RevisionControl.ModifiedBadge " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_BranchModifiedBadge " , CoreStyleConstants : : Icon16x16 , FStyleColors : : Warning ) ) ;
2023-03-20 21:00:06 -04:00
Set ( " RevisionControl.ModifiedLocally " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_ModifiedLocally " , CoreStyleConstants : : Icon16x16 , FStyleColors : : Foreground ) ) ;
2022-12-09 14:18:01 -05:00
2024-04-04 14:41:22 -04:00
Set ( " RevisionControl.NotAtHeadRevision " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_NewerVersion " , CoreStyleConstants : : Icon16x16 , StatusNotAtHeadRevisionColor ) ) ;
2022-12-09 14:18:01 -05:00
Set ( " RevisionControl.NotInDepot " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/SCC_NotInDepot " , CoreStyleConstants : : Icon16x16 , FStyleColors : : Warning ) ) ;
Set ( " RevisionControl.Branched " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/SCC_Branched " , CoreStyleConstants : : Icon16x16 , BranchedColor ) ) ;
2024-01-18 10:27:11 -05:00
Set ( " RevisionControl.Conflicted " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_Conflicted " , CoreStyleConstants : : Icon16x16 , FStyleColors : : Warning ) ) ;
2022-12-09 14:18:01 -05:00
// Misc Icons
Set ( " RevisionControl.ChangelistsTab " , new IMAGE_BRUSH_SVG ( " Starship/Common/check-circle " , CoreStyleConstants : : Icon16x16 ) ) ;
2024-02-26 06:30:11 -05:00
Set ( " RevisionControl.ConflictResolutionTab " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_Conflicted " , CoreStyleConstants : : Icon16x16 ) ) ;
Set ( " RevisionControl.SnapshotHistoryTab " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_Rewind " , CoreStyleConstants : : Icon16x16 ) ) ;
2023-02-20 21:07:58 -05:00
Set ( " RevisionControl.StatusBar.AtLatestRevision " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_StatusRemoteUpToDate " , CoreStyleConstants : : Icon16x16 ) ) ;
2024-04-04 14:41:22 -04:00
Set ( " RevisionControl.StatusBar.NotAtLatestRevision " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_StatusRemoteDownload " , CoreStyleConstants : : Icon16x16 , StatusNotAtHeadRevisionColor ) ) ;
2023-02-20 21:07:58 -05:00
Set ( " RevisionControl.StatusBar.NoLocalChanges " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_StatusLocalUpToDate " , CoreStyleConstants : : Icon16x16 ) ) ;
Set ( " RevisionControl.StatusBar.HasLocalChanges " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_StatusLocalUpload " , CoreStyleConstants : : Icon16x16 , FStyleColors : : AccentBlue ) ) ;
2024-01-09 04:08:55 -05:00
Set ( " RevisionControl.StatusBar.Conflicted " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_Conflicted " , CoreStyleConstants : : Icon16x16 , FStyleColors : : Warning ) ) ;
2024-02-01 13:58:40 -05:00
Set ( " RevisionControl.StatusBar.Promote " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_Promote " , CoreStyleConstants : : Icon16x16 ) ) ;
2024-03-29 07:24:47 -04:00
Set ( " RevisionControl.ShowMenu.CheckedOut " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/SCC_CheckedOut " , CoreStyleConstants : : Icon16x16 ) ) ;
Set ( " RevisionControl.ShowMenu.OpenForAdd " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_MarkedForAdd " , CoreStyleConstants : : Icon16x16 ) ) ;
Set ( " RevisionControl.ShowMenu.CheckedOutByOtherUser " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_CheckedOther " , CoreStyleConstants : : Icon16x16 ) ) ;
Set ( " RevisionControl.ShowMenu.NotAtHeadRevision " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_NewerVersion " , CoreStyleConstants : : Icon16x16 ) ) ;
2024-02-01 13:58:40 -05:00
Set ( " RevisionControl.Promote.Large " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_Promote_Large " , CoreStyleConstants : : Icon32x32 ) ) ;
2023-10-26 12:50:03 -04:00
Set ( " RevisionControl.ConflictResolution.OpenExternal " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_ConflictResolution_OpenExternal " , CoreStyleConstants : : Icon16x16 ) ) ;
2023-12-18 12:54:53 -05:00
Set ( " RevisionControl.ConflictResolution.Clear " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_ConflictResolution_Clear " , CoreStyleConstants : : Icon16x16 ) ) ;
2023-11-21 12:06:27 -05:00
2024-05-24 04:02:05 -04:00
Set ( " RevisionControl.SnapshotHistory.Added " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_Added " , CoreStyleConstants : : Icon14x14 , SnapshotHistoryAdded ) ) ;
Set ( " RevisionControl.SnapshotHistory.Modified " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_Modified " , CoreStyleConstants : : Icon14x14 , SnapshotHistoryModified ) ) ;
Set ( " RevisionControl.SnapshotHistory.Removed " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_Removed " , CoreStyleConstants : : Icon14x14 , SnapshotHistoryRemoved ) ) ;
2024-06-10 17:53:52 -04:00
Set ( " RevisionControl.SnapshotHistory.ToolTip.Added " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_Added " , CoreStyleConstants : : Icon14x14 ) ) ;
Set ( " RevisionControl.SnapshotHistory.ToolTip.Modified " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_Modified " , CoreStyleConstants : : Icon14x14 ) ) ;
Set ( " RevisionControl.SnapshotHistory.ToolTip.Removed " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_Removed " , CoreStyleConstants : : Icon14x14 ) ) ;
2023-11-21 12:06:27 -05:00
// Revision Control States
Set ( " RevisionControl.VerticalLine " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_VerticalLine " , CoreStyleConstants : : Icon26x26 ) ) ;
2023-11-30 10:36:24 -05:00
Set ( " RevisionControl.VerticalLineStart " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_VerticalLineStart " , CoreStyleConstants : : Icon26x26 ) ) ;
2023-11-21 12:06:27 -05:00
Set ( " RevisionControl.VerticalLineDashed " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_VerticalLineDashed " , CoreStyleConstants : : Icon26x26 ) ) ;
Set ( " RevisionControl.CheckCircleLine " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_CheckCircleLine " , CoreStyleConstants : : Icon26x26 ) ) ;
Set ( " RevisionControl.LineCircle " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_LineCircle " , CoreStyleConstants : : Icon26x26 ) ) ;
Set ( " RevisionControl.CheckInAvailable " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_CheckInAvailable " , CoreStyleConstants : : Icon26x26 ) ) ;
Set ( " RevisionControl.Rewound " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_Rewound " , CoreStyleConstants : : Icon26x26 ) ) ;
2023-12-01 08:23:59 -05:00
Set ( " RevisionControl.CheckInAvailableRewound " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_CheckInAvailableRewound " , CoreStyleConstants : : Icon26x26 ) ) ;
2023-12-22 14:15:22 -05:00
Set ( " RevisionControl.ConflictedState " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_ConflictedState " , CoreStyleConstants : : Icon26x26 ) ) ;
2024-01-12 14:34:43 -05:00
Set ( " RevisionControl.File " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_File " , CoreStyleConstants : : Icon6x8 ) ) ;
2024-03-04 19:56:50 -05:00
Set ( " RevisionControl.DiskSize " , new IMAGE_BRUSH_SVG ( " Starship/SourceControl/RC_DiskSize " , CoreStyleConstants : : Icon8x8 ) ) ;
2022-12-09 14:18:01 -05:00
}
FDefaultRevisionControlStyle : : ~ FDefaultRevisionControlStyle ( )
{
FSlateStyleRegistry : : UnRegisterSlateStyle ( * this ) ;
}
const FName & FDefaultRevisionControlStyle : : GetStyleSetName ( ) const
{
return StyleName ;
}
2023-11-07 06:18:43 -05:00
# endif //SOURCE_CONTROL_WITH_SLATE