-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from PlasticSCM/1003832-display-current-branch
Displaying the name of the current branch in the status bar
- Loading branch information
Showing
4 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
Source/PlasticSourceControl/Private/SPlasticSourceControlStatusBar.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Copyright (c) 2023 Unity Technologies | ||
|
||
#include "SPlasticSourceControlStatusBar.h" | ||
|
||
#include "PlasticSourceControlModule.h" | ||
|
||
#include "Runtime/Launch/Resources/Version.h" | ||
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 1 | ||
#include "Styling/AppStyle.h" | ||
#else | ||
#include "EditorStyleSet.h" | ||
#endif | ||
#include "Styling\SlateTypes.h" | ||
|
||
#define LOCTEXT_NAMESPACE "PlasticSourceControl" | ||
|
||
void SPlasticSourceControlStatusBar::Construct(const FArguments& InArgs) | ||
{ | ||
ChildSlot | ||
[ | ||
SNew(SButton) | ||
.ContentPadding(FMargin(6.0f, 0.0f)) | ||
.ToolTipText(LOCTEXT("PlasticBranches_Tooltip", "Current branch")) | ||
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 1 | ||
.ButtonStyle(FAppStyle::Get(), "SimpleButton") | ||
#else | ||
.ButtonStyle(FEditorStyle::Get(), "SimpleButton") | ||
#endif | ||
.OnClicked(this, &SPlasticSourceControlStatusBar::OnClicked) | ||
[ | ||
SNew(SHorizontalBox) | ||
+ SHorizontalBox::Slot() | ||
.AutoWidth() | ||
.VAlign(VAlign_Center) | ||
.HAlign(HAlign_Center) | ||
[ | ||
SNew(SImage) | ||
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 1 | ||
.Image(FAppStyle::GetBrush("SourceControl.Branch")) | ||
#else | ||
.Image(FEditorStyle::GetBrush("SourceControl.Branch")) | ||
#endif | ||
] | ||
+ SHorizontalBox::Slot() | ||
.AutoWidth() | ||
.VAlign(VAlign_Center) | ||
.Padding(FMargin(5, 0, 0, 0)) | ||
[ | ||
SNew(STextBlock) | ||
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 1 | ||
.TextStyle(&FAppStyle::Get().GetWidgetStyle<FTextBlockStyle>("NormalText")) | ||
#else | ||
.TextStyle(&FEditorStyle::Get().GetWidgetStyle<FTextBlockStyle>("NormalText")) | ||
#endif | ||
.Text_Lambda([this]() { return GetStatusBarText(); }) | ||
] | ||
] | ||
]; | ||
} | ||
|
||
FText SPlasticSourceControlStatusBar::GetStatusBarText() const | ||
{; | ||
return FText::FromString(FPlasticSourceControlModule::Get().GetProvider().GetBranchName()); | ||
} | ||
|
||
FReply SPlasticSourceControlStatusBar::OnClicked() | ||
{ | ||
return FReply::Handled(); | ||
} | ||
|
||
#undef LOCTEXT_NAMESPACE |
24 changes: 24 additions & 0 deletions
24
Source/PlasticSourceControl/Private/SPlasticSourceControlStatusBar.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) 2023 Unity Technologies | ||
|
||
#pragma once | ||
|
||
#include "CoreMinimal.h" | ||
|
||
#include "Widgets/SCompoundWidget.h" | ||
|
||
/** | ||
* Status bar displaying the name of the current branch | ||
*/ | ||
class SPlasticSourceControlStatusBar : public SCompoundWidget | ||
{ | ||
public: | ||
SLATE_BEGIN_ARGS(SPlasticSourceControlStatusBar) {} | ||
SLATE_END_ARGS() | ||
|
||
void Construct(const FArguments& InArgs); | ||
|
||
private: | ||
FText GetStatusBarText() const; | ||
|
||
FReply OnClicked(); | ||
}; |