Skip to content

Commit

Permalink
#5527: Replace all occurrences of wxArtProvider::GetBitmap(GlobalUIMa…
Browse files Browse the repository at this point in the history
…nager().getArtIdPrefix() + "bla") with wxutil::GetLocalBitmap("bla").

The UI manager module no longer exposes that prefix, now that wxutil::GetLocalBitmap is the only client.
  • Loading branch information
codereader committed Feb 7, 2021
1 parent ca89e71 commit 4a396dd
Show file tree
Hide file tree
Showing 47 changed files with 141 additions and 145 deletions.
13 changes: 2 additions & 11 deletions include/iuimanager.h
Expand Up @@ -2,9 +2,6 @@

#include "imodule.h"

// Forward declarations
class wxWindow;

// Forward declarations
class IGroupDialog; // see igroupdialog.h for definition

Expand All @@ -17,21 +14,15 @@ class IDialogManager; // see idialogmanager.h for definition

const char* const MODULE_UIMANAGER("UIManager");

/** greebo: The UI Manager abstract base class.
*
* The UIManager provides an interface to add UI items
* like menu commands.
/**
* greebo: The UI Manager gives access to the GroupDialog and the DialogManager.
*/
class IUIManager :
public RegisterableModule
{
public:
virtual IGroupDialog& getGroupDialog() = 0;
virtual ui::IDialogManager& getDialogManager() = 0;

// Returns the art provider prefix to acquire local bitmaps from the wxWidgets art provider
// Example: wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + "darkradiant_icon_64x64.png")
virtual const std::string& ArtIdPrefix() const = 0;
};

// This is the accessor for the UI manager
Expand Down
15 changes: 14 additions & 1 deletion libs/wxutil/Bitmap.h
@@ -1,7 +1,7 @@
#pragma once

#include "LocalBitmapArtProvider.h"
#include <wx/artprov.h>
#include "wxutil/Bitmap.h"

namespace wxutil
{
Expand All @@ -18,4 +18,17 @@ inline wxBitmap GetLocalBitmap(const std::string& name)
return wxArtProvider::GetBitmap(LocalBitmapArtProvider::ArtIdPrefix() + name);
}

/**
* \brief
* Get a wxBitmap from the local "darkradiant" art provider, passing the given
* art client along.
*
* \param name
* Image file name with no prefix, e.g. "something.png"
*/
inline wxBitmap GetLocalBitmap(const std::string& name, const wxArtClient& client)
{
return wxArtProvider::GetBitmap(LocalBitmapArtProvider::ArtIdPrefix() + name, client);
}

}
5 changes: 3 additions & 2 deletions libs/wxutil/EntityClassChooser.cpp
Expand Up @@ -15,6 +15,7 @@
#include <wx/button.h>
#include <wx/panel.h>
#include <wx/splitter.h>
#include "wxutil/Bitmap.h"

#include "string/string.h"
#include "eclass.h"
Expand Down Expand Up @@ -68,8 +69,8 @@ class EntityClassTreePopulator:
_columns(columns),
_folderKey(game::current::getValue<std::string>(FOLDER_KEY_PATH))
{
_folderIcon.CopyFromBitmap(wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + FOLDER_ICON));
_entityIcon.CopyFromBitmap(wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + ENTITY_ICON));
_folderIcon.CopyFromBitmap(wxutil::GetLocalBitmap(FOLDER_ICON));
_entityIcon.CopyFromBitmap(wxutil::GetLocalBitmap(ENTITY_ICON));

// Get the list of favourite eclasses
_favourites = GlobalFavouritesManager().getFavourites(decl::Type::EntityDef);
Expand Down
6 changes: 3 additions & 3 deletions libs/wxutil/dataview/ResourceTreeView.cpp
Expand Up @@ -6,7 +6,7 @@
#include "ifavourites.h"
#include "../menu/IconTextMenuItem.h"
#include "TreeViewItemStyle.h"
#include <wx/artprov.h>
#include "wxutil/Bitmap.h"

namespace wxutil
{
Expand Down Expand Up @@ -62,7 +62,7 @@ ResourceTreeView::ResourceTreeView(wxWindow* parent, const TreeModel::Ptr& model
Bind(EV_TREEMODEL_POPULATION_FINISHED, &ResourceTreeView::_onTreeStorePopulationFinished, this);
Bind(EV_TREEMODEL_POPULATION_PROGRESS, &ResourceTreeView::_onTreeStorePopulationProgress, this);

_progressIcon.CopyFromBitmap(wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + ICON_LOADING));
_progressIcon.CopyFromBitmap(wxutil::GetLocalBitmap(ICON_LOADING));
}

ResourceTreeView::~ResourceTreeView()
Expand Down Expand Up @@ -129,7 +129,7 @@ void ResourceTreeView::SetupTreeModelFilter()
_emptyFavouritesLabel = row.getItem();

wxIcon icon;
icon.CopyFromBitmap(wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + ICON_LOADING));
icon.CopyFromBitmap(wxutil::GetLocalBitmap(ICON_LOADING));
row[_columns.iconAndName] = wxVariant(wxDataViewIconText(_("No favourites added so far"), icon));
row[_columns.isFavourite] = true;
row[_columns.isFolder] = false;
Expand Down
6 changes: 3 additions & 3 deletions libs/wxutil/dataview/ResourceTreeViewToolbar.cpp
Expand Up @@ -3,7 +3,7 @@
#include "i18n.h"
#include "iuimanager.h"

#include <wx/artprov.h>
#include "wxutil/Bitmap.h"
#include <wx/sizer.h>
#include <wx/statbmp.h>
#include <wx/textctrl.h>
Expand Down Expand Up @@ -45,10 +45,10 @@ ResourceTreeViewToolbar::ResourceTreeViewToolbar(wxWindow* parent, ResourceTreeV
_filterEntry->Bind(wxEVT_CHAR, &ResourceTreeViewToolbar::_onEntryChar, this);
_filterEntry->SetToolTip(_("Enter search text to filter the tree,\nuse arrow keys to navigate"));

auto nextImg = wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + "arrow_down.png");
auto nextImg = wxutil::GetLocalBitmap("arrow_down.png");
_findNextButton = new wxBitmapButton(this, wxID_ANY, nextImg);

auto prevImg = wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + "arrow_up.png");
auto prevImg = wxutil::GetLocalBitmap("arrow_up.png");
_findPrevButton = new wxBitmapButton(this, wxID_ANY, prevImg);

_findNextButton->SetSize(wxSize(16, 16));
Expand Down
6 changes: 3 additions & 3 deletions libs/wxutil/dataview/TreeView.cpp
Expand Up @@ -10,7 +10,7 @@
#include <wx/app.h>
#include <wx/sizer.h>
#include <wx/timer.h>
#include <wx/artprov.h>
#include "wxutil/Bitmap.h"
#include <wx/textctrl.h>

namespace wxutil
Expand Down Expand Up @@ -288,10 +288,10 @@ class TreeView::SearchPopupWindow :

_entry = new wxTextCtrl(this, wxID_ANY);

auto nextImg = wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + "arrow_down.png");
auto nextImg = wxutil::GetLocalBitmap("arrow_down.png");
auto nextButton = new wxBitmapButton(this, wxID_ANY, nextImg);

auto prevImg = wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + "arrow_up.png");
auto prevImg = wxutil::GetLocalBitmap("arrow_up.png");
auto prevButton = new wxBitmapButton(this, wxID_ANY, prevImg);

nextButton->SetSize(wxSize(16, 16));
Expand Down
4 changes: 2 additions & 2 deletions libs/wxutil/fsview/FileSystemView.cpp
Expand Up @@ -2,7 +2,7 @@

#include "i18n.h"
#include "iuimanager.h"
#include <wx/artprov.h>
#include "wxutil/Bitmap.h"

namespace wxutil
{
Expand Down Expand Up @@ -115,7 +115,7 @@ void FileSystemView::Populate(const std::string& preselectPath)

wxIcon loadingIcon;
loadingIcon.CopyFromBitmap(
wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + _fileIcon));
wxutil::GetLocalBitmap(_fileIcon));

row[Columns().filename] = wxVariant(wxDataViewIconText(_("Loading..."), loadingIcon));
row[Columns().isFolder] = false;
Expand Down
10 changes: 5 additions & 5 deletions libs/wxutil/fsview/Populator.cpp
Expand Up @@ -9,7 +9,7 @@
#include "os/filesize.h"
#include "gamelib.h"

#include <wx/artprov.h>
#include "wxutil/Bitmap.h"
#include <fmt/format.h>

namespace wxutil
Expand All @@ -36,9 +36,9 @@ Populator::Populator(const TreeColumns& columns,
_fileExtensions(fileExtensions)
{
_fileIcon.CopyFromBitmap(
wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + FILE_ICON));
wxutil::GetLocalBitmap(FILE_ICON));
_folderIcon.CopyFromBitmap(
wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + FOLDER_ICON));
wxutil::GetLocalBitmap(FOLDER_ICON));

_basePathItem = insertBasePathItem();
_treePopulator.setTopLevelItem(_basePathItem);
Expand All @@ -55,7 +55,7 @@ Populator::~Populator()

void Populator::SetDefaultFileIcon(const std::string& fileIcon)
{
_fileIcon.CopyFromBitmap(wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + fileIcon));
_fileIcon.CopyFromBitmap(wxutil::GetLocalBitmap(fileIcon));
}

void Populator::visitFile(const vfs::FileInfo& fileInfo)
Expand Down Expand Up @@ -177,7 +177,7 @@ const wxIcon& Populator::GetIconForFile(const std::string& path)
if (!iconName.empty())
{
wxIcon customIcon;
customIcon.CopyFromBitmap(wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + iconName));
customIcon.CopyFromBitmap(wxutil::GetLocalBitmap(iconName));

foundIcon = _iconsPerExtension.emplace(extension, customIcon).first;
}
Expand Down
4 changes: 2 additions & 2 deletions libs/wxutil/menu/IconTextMenuItem.h
@@ -1,7 +1,7 @@
#pragma once

#include "iuimanager.h"
#include <wx/artprov.h>
#include "wxutil/Bitmap.h"
#include <wx/menuitem.h>

namespace wxutil
Expand All @@ -15,7 +15,7 @@ class IconTextMenuItem :
IconTextMenuItem(const std::string& text, const std::string& localBitmapFilename) :
wxMenuItem(NULL, wxID_ANY, text, "")
{
SetBitmap(wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + localBitmapFilename));
SetBitmap(wxutil::GetLocalBitmap(localBitmapFilename));
}
};

Expand Down
10 changes: 5 additions & 5 deletions libs/wxutil/preview/ParticlePreview.cpp
Expand Up @@ -16,7 +16,7 @@
#include "wxutil/GLWidget.h"
#include "wxutil/dialog/MessageBox.h"

#include <wx/artprov.h>
#include "../Bitmap.h"

#include <fmt/format.h>
#include "string/predicate.h"
Expand Down Expand Up @@ -47,23 +47,23 @@ ParticlePreview::ParticlePreview(wxWindow* parent) :
toolbar->SetToolBitmapSize(wxSize(24, 24));

_showAxesButton = toolbar->AddCheckTool(TOOL_SHOW_AXES, "",
wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + "axes.png", wxART_TOOLBAR));
wxutil::GetLocalBitmap("axes.png", wxART_TOOLBAR));
_showAxesButton->SetShortHelp(_("Show coordinate axes"));
toolbar->Connect(_showAxesButton->GetId(), wxEVT_TOOL,
wxCommandEventHandler(ParticlePreview::onToolItemClickRefresh), NULL, this);

_showWireFrameButton = toolbar->AddCheckTool(TOOL_SHOW_WIREFRAME, "",
wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + "wireframe.png", wxART_TOOLBAR));
wxutil::GetLocalBitmap("wireframe.png", wxART_TOOLBAR));
_showWireFrameButton->SetShortHelp(_("Show wireframe"));
toolbar->Connect(_showWireFrameButton->GetId(), wxEVT_TOOL,
wxCommandEventHandler(ParticlePreview::onToolItemClickRefresh), NULL, this);

_automaticLoopButton = toolbar->AddCheckTool(TOOL_AUTO_LOOP, _("Auto Loop"),
wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + "loop.png", wxART_TOOLBAR));
wxutil::GetLocalBitmap("loop.png", wxART_TOOLBAR));
_automaticLoopButton->SetShortHelp(_("Auto Loop"));

_reloadButton = toolbar->AddTool(TOOL_REFRESH, "",
wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + "refresh.png", wxART_TOOLBAR));
wxutil::GetLocalBitmap("refresh.png", wxART_TOOLBAR));
_reloadButton->SetShortHelp(_("Reload Particle Defs"));
IEventPtr ev = GlobalEventManager().findEvent("ReloadParticles");
ev->connectToolItem(_reloadButton);
Expand Down
3 changes: 2 additions & 1 deletion libs/wxutil/preview/RenderPreview.cpp
Expand Up @@ -18,6 +18,7 @@
#include <wx/sizer.h>
#include <wx/menu.h>
#include <wx/dcclient.h>
#include "../Bitmap.h"

#include <fmt/format.h>
#include <functional>
Expand Down Expand Up @@ -100,7 +101,7 @@ void RenderPreview::setupToolbars(bool enableAnimation)
wxToolBar* filterToolbar = findNamedObject<wxToolBar>(_mainPanel, "RenderPreviewFilterToolbar");

wxToolBarToolBase* filterTool = filterToolbar->AddTool(wxID_ANY, _("Filters"),
wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + "iconFilter16.png"),
wxutil::GetLocalBitmap("iconFilter16.png"),
_("Filters"), wxITEM_DROPDOWN);

// By setting a drodown menu the toolitem will take ownership and delete the menu on destruction
Expand Down
5 changes: 2 additions & 3 deletions libs/wxutil/window/TransientWindow.cpp
Expand Up @@ -3,7 +3,7 @@
#include "iuimanager.h"
#include "imainframe.h"
#include "iregistry.h"
#include <wx/artprov.h>
#include "wxutil/Bitmap.h"

namespace wxutil
{
Expand All @@ -21,8 +21,7 @@ TransientWindow::TransientWindow(const std::string& title, wxWindow* parent, boo

// Set the window icon
wxIcon appIcon;
appIcon.CopyFromBitmap(wxArtProvider::GetBitmap(
GlobalUIManager().ArtIdPrefix() + "darkradiant_icon_64x64.png"));
appIcon.CopyFromBitmap(wxutil::GetLocalBitmap("darkradiant_icon_64x64.png"));
SetIcon(appIcon);
}

Expand Down
6 changes: 3 additions & 3 deletions plugins/dm.conversation/CommandArgumentItem.cpp
Expand Up @@ -12,7 +12,7 @@
#include <wx/textctrl.h>
#include <wx/panel.h>
#include <wx/sizer.h>
#include <wx/artprov.h>
#include "wxutil/Bitmap.h"
#include <wx/bmpbuttn.h>

#include "wxutil/ChoiceHelper.h"
Expand Down Expand Up @@ -153,7 +153,7 @@ SoundShaderArgument::SoundShaderArgument(CommandEditor& owner,

// Create the icon button to open the ShaderChooser
wxButton* selectShaderButton = new wxBitmapButton(_soundShaderPanel, wxID_ANY,
wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + FOLDER_ICON));
wxutil::GetLocalBitmap(FOLDER_ICON));

selectShaderButton->SetToolTip(_("Browse Sound Shaders"));

Expand Down Expand Up @@ -210,7 +210,7 @@ AnimationArgument::AnimationArgument(CommandEditor& owner,

// Create the icon button to open the
wxButton* selectButton = new wxBitmapButton(_animPanel, wxID_ANY,
wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + FOLDER_ICON));
wxutil::GetLocalBitmap(FOLDER_ICON));

selectButton->SetToolTip(_("Browse Animations"));

Expand Down
4 changes: 2 additions & 2 deletions plugins/dm.editing/AIEditingPanel.cpp
Expand Up @@ -17,7 +17,7 @@
#include <wx/stattext.h>
#include <wx/sizer.h>
#include <wx/button.h>
#include <wx/artprov.h>
#include "wxutil/Bitmap.h"
#include <wx/frame.h>
#include <wx/panel.h>
#include <wx/scrolwin.h>
Expand Down Expand Up @@ -229,7 +229,7 @@ void AIEditingPanel::createChooserRow(wxSizer* table, const std::string& rowLabe

// Create the skin browse button
wxButton* browseButton = new wxButton(_mainPanel, wxID_ANY, buttonLabel);
browseButton->SetBitmap(wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + buttonIcon));
browseButton->SetBitmap(wxutil::GetLocalBitmap(buttonIcon));
browseButton->Bind(wxEVT_BUTTON, std::bind(&AIEditingPanel::onBrowseButton, this, std::placeholders::_1, key));

table->Add(browseButton, 0, wxALIGN_RIGHT);
Expand Down
4 changes: 2 additions & 2 deletions plugins/dm.editing/AIHeadPropertyEditor.cpp
Expand Up @@ -7,7 +7,7 @@

#include <wx/panel.h>
#include <wx/button.h>
#include <wx/artprov.h>
#include "wxutil/Bitmap.h"
#include <wx/sizer.h>

#include "AIHeadChooserDialog.h"
Expand All @@ -29,7 +29,7 @@ AIHeadPropertyEditor::AIHeadPropertyEditor(wxWindow* parent, Entity* entity, con

// Create the browse button
wxButton* browseButton = new wxButton(_widget, wxID_ANY, _("Choose AI head..."));
browseButton->SetBitmap(wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + "icon_model.png"));
browseButton->SetBitmap(wxutil::GetLocalBitmap("icon_model.png"));
browseButton->Bind(wxEVT_BUTTON, &AIHeadPropertyEditor::onChooseButton, this);

_widget->GetSizer()->Add(browseButton, 0, wxALIGN_CENTER_VERTICAL);
Expand Down
6 changes: 3 additions & 3 deletions plugins/dm.editing/AIVocalSetPreview.cpp
Expand Up @@ -10,7 +10,7 @@
#include <time.h>

#include <wx/sizer.h>
#include <wx/artprov.h>
#include "wxutil/Bitmap.h"
#include <wx/button.h>
#include <wx/stattext.h>

Expand All @@ -35,10 +35,10 @@ void AIVocalSetPreview::createControlPanel()

// Create the playback button
_playButton = new wxButton(this, wxID_ANY);
_playButton->SetBitmap(wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + "media-playback-start-ltr.png"));
_playButton->SetBitmap(wxutil::GetLocalBitmap("media-playback-start-ltr.png"));

_stopButton = new wxButton(this, wxID_ANY);
_stopButton->SetBitmap(wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + "media-playback-stop.png"));
_stopButton->SetBitmap(wxutil::GetLocalBitmap("media-playback-stop.png"));

_playButton->Connect(wxEVT_BUTTON, wxCommandEventHandler(AIVocalSetPreview::onPlay), NULL, this);
_stopButton->Connect(wxEVT_BUTTON, wxCommandEventHandler(AIVocalSetPreview::onStop), NULL, this);
Expand Down

0 comments on commit 4a396dd

Please sign in to comment.