diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 33cdcc79ad..a213026513 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -78,7 +78,7 @@ bool MainScreen::showHomebrewTab = false; static void LaunchFile(ScreenManager *screenManager, Screen *currentScreen, const Path &path) { if (path.GetFileExtension() == ".zip") { - // If it's a zip file, we have a screen for that. + // If is a zip file, we have a screen for that. screenManager->push(new InstallZipScreen(path)); } else { if (currentScreen) { @@ -447,10 +447,15 @@ public: return absolute_; } + void SetPinned(bool pin) { + pinned_ = pin; + } + private: Path path_; bool gridStyle_; bool absolute_; + bool pinned_ = false; }; void DirButton::Draw(UIContext &dc) { @@ -465,7 +470,7 @@ void DirButton::Draw(UIContext &dc) { std::string_view text(GetText()); - ImageID image = ImageID("I_FOLDER"); + ImageID image = ImageID(pinned_ ? "I_FOLDER_PINNED" : "I_FOLDER"); if (text == "..") { image = ImageID("I_UP_DIRECTORY"); } @@ -481,7 +486,7 @@ void DirButton::Draw(UIContext &dc) { if (compact) { // No icon, except "up" dc.PushScissor(bounds_); - if (image == ImageID("I_FOLDER")) { + if (image == ImageID("I_FOLDER") || image == ImageID("I_FOLDER_PINNED")) { dc.DrawText(text, bounds_.x + 5, bounds_.centerY(), style.fgColor, ALIGN_VCENTER); } else { 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() { // Add any pinned paths before other directories. auto pinnedPaths = GetPinnedPaths(); for (auto it = pinnedPaths.begin(), end = pinnedPaths.end(); it != end; ++it) { - gameList_->Add(new DirButton(*it, GetBaseName((*it).ToString()), *gridStyle_, new UI::LinearLayoutParams(UI::FILL_PARENT, UI::FILL_PARENT)))-> - OnClick.Handle(this, &GameBrowser::NavigateClick); + DirButton *pinnedDir = gameList_->Add(new DirButton(*it, GetBaseName((*it).ToString()), *gridStyle_, new UI::LinearLayoutParams(UI::FILL_PARENT, UI::FILL_PARENT))); + pinnedDir->OnClick.Handle(this, &GameBrowser::NavigateClick); + pinnedDir->SetPinned(true); } + + // Add a separator? } if (listingPending_) { @@ -938,12 +946,13 @@ void GameBrowser::Refresh() { // Show a button to toggle pinning at the very end. if ((browseFlags_ & BrowseFlags::PIN) && !path_.GetPath().empty()) { - std::string caption = IsCurrentPathPinned() ? "-" : "+"; + std::string caption = ""; // IsCurrentPathPinned() ? "-" : "+"; if (!*gridStyle_) { caption = IsCurrentPathPinned() ? mm->T("UnpinPath", "Unpin") : mm->T("PinPath", "Pin"); } - gameList_->Add(new UI::Button(caption, new UI::LinearLayoutParams(UI::FILL_PARENT, UI::FILL_PARENT)))-> - OnClick.Handle(this, &GameBrowser::PinToggleClick); + UI::Button *pinButton = gameList_->Add(new UI::Button(caption, new UI::LinearLayoutParams(UI::FILL_PARENT, UI::FILL_PARENT))); + pinButton->OnClick.Handle(this, &GameBrowser::PinToggleClick); + pinButton->SetImageID(ImageID(IsCurrentPathPinned() ? "I_UNPIN" : "I_PIN")); } if (path_.GetPath().empty()) { diff --git a/UI/UIAtlas.cpp b/UI/UIAtlas.cpp index fa37b7d65a..be5b6cf04a 100644 --- a/UI/UIAtlas.cpp +++ b/UI/UIAtlas.cpp @@ -116,6 +116,9 @@ static const std::string imageIDs[] = { "I_SPEAKER_OFF", "I_WINNER_CUP", "I_EMPTY", + "I_PIN", + "I_UNPIN", + "I_FOLDER_PINNED", }; static std::string PNGNameFromID(std::string_view id) { diff --git a/assets/ui_images/images.svg b/assets/ui_images/images.svg index 206b3ac134..384665aa3f 100644 --- a/assets/ui_images/images.svg +++ b/assets/ui_images/images.svg @@ -7,7 +7,7 @@ viewBox="0 0 158.75 158.75" version="1.1" id="svg1" - inkscape:version="1.4.2 (f4327f4, 2025-05-13)" + inkscape:version="1.4 (86a8ad7, 2024-10-11)" sodipodi:docname="images.svg" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" @@ -3741,17 +3741,6 @@ d="M -23.732181,30.229779 V 49.775586 H -4.4463411 V 30.229779 Z m 2.49666,2.529991 H -6.9405211 V 47.245604 H -21.235521 Z" style="fill:#ffffff;fill-opacity:1;stroke:none" transform="matrix(0.38768981,0,0,0.38768981,58.043664,46.774929)" /> -