Rework bitmap system to load from archived PNGs

Bitmaps are now identified by an enum class instead of by pointers.
Bitmap loading and caching is now handled by a class in common, and
we no longer compile most bitmaps into the binary, so there is no
longer a bitmaps static library.

Instead, bitmaps are archived to a .tar.gz file which is installed
in ${KICAD_DATA}/resources/images.tar.gz

The source PNGs are checked in to Git as the original CPP files were,
so that people can build without the required dependencies to convert
SVGs to PNGs.

Initial support is also added for dark theme icons, although this
is not yet exposed in the GUI.

Stubs are present for multi-resolution image resources, but this is
not fully-baked yet and could use some refinement.
This commit is contained in:
Jon Evans
2021-03-11 08:37:35 -05:00
parent 4db10d419d
commit 18037e2f65
1642 changed files with 3723 additions and 25013 deletions
+6 -5
View File
@@ -23,6 +23,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <bitmaps.h>
#include <tool/conditional_menu.h>
#include <tool/action_menu.h>
#include <menus_helpers.h>
@@ -60,12 +61,12 @@ void CONDITIONAL_MENU::AddCheckItem( const TOOL_ACTION& aAction,
void CONDITIONAL_MENU::AddItem( int aId, const wxString& aText, const wxString& aTooltip,
BITMAP_DEF aIcon, const SELECTION_CONDITION& aCondition,
BITMAPS aIcon, const SELECTION_CONDITION& aCondition,
int aOrder )
{
wxMenuItem item( nullptr, aId, aText, aTooltip, wxITEM_NORMAL );
if( aIcon )
if( aIcon != BITMAPS::INVALID_BITMAP )
AddBitmapToMenuItem( &item, KiBitmap( aIcon ) );
addEntry( ENTRY( item, aIcon, aCondition, aOrder, false ) );
@@ -73,12 +74,12 @@ void CONDITIONAL_MENU::AddItem( int aId, const wxString& aText, const wxString&
void CONDITIONAL_MENU::AddCheckItem( int aId, const wxString& aText, const wxString& aTooltip,
BITMAP_DEF aIcon, const SELECTION_CONDITION& aCondition,
BITMAPS aIcon, const SELECTION_CONDITION& aCondition,
int aOrder )
{
wxMenuItem item( nullptr, aId, aText, aTooltip, wxITEM_CHECK );
if( aIcon )
if( aIcon != BITMAPS::INVALID_BITMAP )
AddBitmapToMenuItem( &item, KiBitmap( aIcon ) );
addEntry( ENTRY( item, aIcon, aCondition, aOrder, true ) );
@@ -159,7 +160,7 @@ void CONDITIONAL_MENU::Evaluate( SELECTION& aSelection )
entry.wxItem()->GetHelp(),
entry.wxItem()->GetKind() );
if( entry.GetIcon() )
if( entry.GetIcon() != BITMAPS::INVALID_BITMAP )
AddBitmapToMenuItem( menuItem, KiBitmap( entry.GetIcon() ) );
// the wxMenuItem must be append only after the bitmap is set: