Skip to content

Commit

Permalink
Add wxutil::getBitmap() helper function
Browse files Browse the repository at this point in the history
Add a simple utility function to replace the very common and somewhat verbose
combination of wxArtProvider::GetBitmap and IUIManager::ArtIdPrefix.
  • Loading branch information
Matthew Mott committed Jan 6, 2021
1 parent a338cde commit 9af13d3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
22 changes: 22 additions & 0 deletions libs/wxutil/bitmap.h
@@ -0,0 +1,22 @@
#pragma once

#include "iuimanager.h"

#include <wx/artprov.h>

namespace wxutil
{

/**
* \brief
* Get a wxBitmap from the art provider
*
* \param name
* Image file name with no prefix, e.g. "something.png"
*/
wxBitmap getBitmap(const std::string& name)
{
return wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + name);
}

}
4 changes: 2 additions & 2 deletions plugins/dm.gameconnection/GameConnection.cpp
Expand Up @@ -15,6 +15,7 @@
#include "imainframe.h"

#include "scene/Traverse.h"
#include "wxutil/bitmap.h"

#include <sigc++/signal.h>
#include <sigc++/connection.h>
Expand Down Expand Up @@ -310,8 +311,7 @@ void GameConnection::addToolbarItems()

// Add a toggle for the camera sync function
auto tool = camTB->AddTool(
wxID_ANY, "L",
wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + "sr_icon_communication.png"),
wxID_ANY, "L", wxutil::getBitmap("sr_icon_communication.png"),
_("Enable game camera sync with DarkRadiant camera")
);
_camSyncToggle->connectToolItem(tool);
Expand Down

0 comments on commit 9af13d3

Please sign in to comment.