Skip to content

Commit e53d6e4

Browse files
authored
Merge pull request #20859 from hrydgard/pin-icon
Replaces '+'/'-' with pin/unpin icons. Thanks Nabn00b.
2 parents 6efbdfc + 3917753 commit e53d6e4

File tree

3 files changed

+61
-20
lines changed

3 files changed

+61
-20
lines changed

UI/MainScreen.cpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ bool MainScreen::showHomebrewTab = false;
7878

7979
static void LaunchFile(ScreenManager *screenManager, Screen *currentScreen, const Path &path) {
8080
if (path.GetFileExtension() == ".zip") {
81-
// If it's a zip file, we have a screen for that.
81+
// If is a zip file, we have a screen for that.
8282
screenManager->push(new InstallZipScreen(path));
8383
} else {
8484
if (currentScreen) {
@@ -447,10 +447,15 @@ class DirButton : public UI::Button {
447447
return absolute_;
448448
}
449449

450+
void SetPinned(bool pin) {
451+
pinned_ = pin;
452+
}
453+
450454
private:
451455
Path path_;
452456
bool gridStyle_;
453457
bool absolute_;
458+
bool pinned_ = false;
454459
};
455460

456461
void DirButton::Draw(UIContext &dc) {
@@ -465,7 +470,7 @@ void DirButton::Draw(UIContext &dc) {
465470

466471
std::string_view text(GetText());
467472

468-
ImageID image = ImageID("I_FOLDER");
473+
ImageID image = ImageID(pinned_ ? "I_FOLDER_PINNED" : "I_FOLDER");
469474
if (text == "..") {
470475
image = ImageID("I_UP_DIRECTORY");
471476
}
@@ -481,7 +486,7 @@ void DirButton::Draw(UIContext &dc) {
481486
if (compact) {
482487
// No icon, except "up"
483488
dc.PushScissor(bounds_);
484-
if (image == ImageID("I_FOLDER")) {
489+
if (image == ImageID("I_FOLDER") || image == ImageID("I_FOLDER_PINNED")) {
485490
dc.DrawText(text, bounds_.x + 5, bounds_.centerY(), style.fgColor, ALIGN_VCENTER);
486491
} else {
487492
dc.Draw()->DrawImage(image, bounds_.centerX(), bounds_.centerY(), gridStyle_ ? g_Config.fGameGridScale : 1.0, style.fgColor, ALIGN_CENTER);
@@ -912,9 +917,12 @@ void GameBrowser::Refresh() {
912917
// Add any pinned paths before other directories.
913918
auto pinnedPaths = GetPinnedPaths();
914919
for (auto it = pinnedPaths.begin(), end = pinnedPaths.end(); it != end; ++it) {
915-
gameList_->Add(new DirButton(*it, GetBaseName((*it).ToString()), *gridStyle_, new UI::LinearLayoutParams(UI::FILL_PARENT, UI::FILL_PARENT)))->
916-
OnClick.Handle(this, &GameBrowser::NavigateClick);
920+
DirButton *pinnedDir = gameList_->Add(new DirButton(*it, GetBaseName((*it).ToString()), *gridStyle_, new UI::LinearLayoutParams(UI::FILL_PARENT, UI::FILL_PARENT)));
921+
pinnedDir->OnClick.Handle(this, &GameBrowser::NavigateClick);
922+
pinnedDir->SetPinned(true);
917923
}
924+
925+
// Add a separator?
918926
}
919927

920928
if (listingPending_) {
@@ -938,12 +946,13 @@ void GameBrowser::Refresh() {
938946

939947
// Show a button to toggle pinning at the very end.
940948
if ((browseFlags_ & BrowseFlags::PIN) && !path_.GetPath().empty()) {
941-
std::string caption = IsCurrentPathPinned() ? "-" : "+";
949+
std::string caption = ""; // IsCurrentPathPinned() ? "-" : "+";
942950
if (!*gridStyle_) {
943951
caption = IsCurrentPathPinned() ? mm->T("UnpinPath", "Unpin") : mm->T("PinPath", "Pin");
944952
}
945-
gameList_->Add(new UI::Button(caption, new UI::LinearLayoutParams(UI::FILL_PARENT, UI::FILL_PARENT)))->
946-
OnClick.Handle(this, &GameBrowser::PinToggleClick);
953+
UI::Button *pinButton = gameList_->Add(new UI::Button(caption, new UI::LinearLayoutParams(UI::FILL_PARENT, UI::FILL_PARENT)));
954+
pinButton->OnClick.Handle(this, &GameBrowser::PinToggleClick);
955+
pinButton->SetImageID(ImageID(IsCurrentPathPinned() ? "I_UNPIN" : "I_PIN"));
947956
}
948957

949958
if (path_.GetPath().empty()) {

UI/UIAtlas.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ static const std::string imageIDs[] = {
116116
"I_SPEAKER_OFF",
117117
"I_WINNER_CUP",
118118
"I_EMPTY",
119+
"I_PIN",
120+
"I_UNPIN",
121+
"I_FOLDER_PINNED",
119122
};
120123

121124
static std::string PNGNameFromID(std::string_view id) {

assets/ui_images/images.svg

Lines changed: 41 additions & 12 deletions
Loading

0 commit comments

Comments
 (0)