diff --git a/CMakeModules/BuildSteps/CreateBitmapInfo.cmake b/CMakeModules/BuildSteps/CreateBitmapInfo.cmake
deleted file mode 100644
index 68a7fa1d7f..0000000000
--- a/CMakeModules/BuildSteps/CreateBitmapInfo.cmake
+++ /dev/null
@@ -1,76 +0,0 @@
-# This program source code file is part of KiCad, a free EDA CAD application.
-#
-# Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
-#
-# This program is free software: you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the
-# Free Software Foundation, either version 3 of the License, or (at your
-# option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program. If not, see .
-
-# Creates the bitmap_info header file from a temporary file created by bitmaps_png/CMakeLists.txt
-
-# Invoke with the following parameters:
-# inputFile: Path to the temporary file containing the contents of the bitmap info list
-# outputFile: Path to write the header to
-
-set( header_content "
-/*
- * This program source code file is part of KiCad, a free EDA CAD application.
- *
- * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
- *
- * This program is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation, either version 3 of the License, or (at your
- * option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see .
- */
-
-/**
- * This file is auto-generated by CMake when MAINTAIN_PNGS is on. Do not edit by hand!
- */
-
-#ifndef KICAD_BITMAP_INFO_H
-#define KICAD_BITMAP_INFO_H
-
-#include
-#include
-
-struct BITMAP_INFO
-{
- BITMAPS id;
- wxString filename;
- int height;
- wxString theme;
-};
-
-
-const std::vector g_BitmapInfo = {
-" )
-
-set( footer_content "
-};
-
-#endif // KICAD_BITMAP_INFO_H
-" )
-
-file( READ "${inputFile}" file_content )
-
-file( WRITE "${outputFile}" "${header_content}" )
-file( APPEND "${outputFile}" "${file_content}" )
-file( APPEND "${outputFile}" "${footer_content}" )
diff --git a/bitmaps_png/CMakeLists.txt b/bitmaps_png/CMakeLists.txt
index 500f7676e3..f6cd0ba8b0 100644
--- a/bitmaps_png/CMakeLists.txt
+++ b/bitmaps_png/CMakeLists.txt
@@ -594,7 +594,8 @@ set( TMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/tmp" )
set( CREATE_LOG_FILES true )
set( BITMAP_INFO_FILE "${CMAKE_SOURCE_DIR}/include/bitmaps/bitmap_info.h" )
-set( BITMAP_INFO_TEMP_FILE ${TMP_DIR}/bitmap_info_contents.h )
+set( BITMAP_INFO_TEMPLATE "${CMAKE_SOURCE_DIR}/include/bitmaps/bitmap_info.h.in" )
+set( BITMAP_INFO_LIST "" )
set( ALL_PNGS "" )
@@ -662,7 +663,7 @@ endfunction()
# Function bitmap_dir
# converts all the basenames in bmapList found in hardcoded 'sources' dir
# and and puts them into cpp_${pngHeight} and png_${pngHeight} directories.
-function( bitmap_dir pngWidth pngHeight bmapList theme )
+function( bitmap_dir pngWidth pngHeight bmapList )
set( pngDir "${CMAKE_CURRENT_SOURCE_DIR}/png" )
@@ -686,6 +687,7 @@ function( bitmap_dir pngWidth pngHeight bmapList theme )
set( tmpFile "${TMP_DIR}/${pngFile}" )
if( NOT EXISTS ${svgFile} )
+ message( "Warning: Source SVG ${svgFile} does not exist!" )
continue()
endif()
@@ -695,32 +697,21 @@ function( bitmap_dir pngWidth pngHeight bmapList theme )
#png2png( inputFile outFile )
png2png( ${tmpFile} ${pngPath} )
- set( bitmapInfo " { BITMAPS::${bmn}, wxT( \"${pngFile}\" ), "
- "${pngHeight}, wxT( \"${theme}\" ) },\n" )
- file( APPEND ${BITMAP_INFO_TEMP_FILE} ${bitmapInfo} )
+ set( bitmapInfo
+ " { BITMAPS::${bmn}, wxT( \"${pngFile}\" ), ${pngHeight}, wxT( \"${theme}\" ) },\n"
+ )
+
+ set( BITMAP_INFO_LIST "${BITMAP_INFO_LIST}${bitmapInfo}" )
list( APPEND ALL_PNGS ${pngPath} )
endforeach()
endforeach()
set( ALL_PNGS ${ALL_PNGS} PARENT_SCOPE )
+ set( BITMAP_INFO_LIST ${BITMAP_INFO_LIST} PARENT_SCOPE )
endfunction()
-# Creates the bitmap_info header file after creating all PNGs
-function( generate_bitmap_info inputFile outputFile )
- add_custom_command(
- OUTPUT ${outputFile}
-
- COMMAND ${CMAKE_COMMAND} -DinputFile=${inputFile} -DoutputFile=${outputFile}
- -P ${CMAKE_MODULE_PATH}/BuildSteps/CreateBitmapInfo.cmake
-
- DEPENDS ${inputFile} ${CMAKE_MODULE_PATH}/BuildSteps/CreateBitmapInfo.cmake
- COMMENT "Creating ${outputFile}"
- VERBATIM
- )
-endfunction()
-
include( FindUnixCommands )
set( BITMAP_ARCHIVE_PATH ${CMAKE_BINARY_DIR}/resources/images.tar.gz )
@@ -787,43 +778,30 @@ if( MAINTAIN_PNGS )
endif( NOT pngcrush_EXECUTABLE )
endif( NOT pngcrush_FOUND )
- if( NOT KICAD_ICON_THEME )
- set( KICAD_ICON_THEME "light" CACHE STRING "Name of the theme directory for icon sources" )
- endif()
-
- message( STATUS "Creating icons for ${KICAD_ICON_THEME} theme" )
-
- file( WRITE ${BITMAP_INFO_TEMP_FILE} )
-
# these 3 cmake commands for each desired bitmap size set, repeat as needed:
- bitmap_dir( 16 16 "${BMAPS_SMALL}" ${KICAD_ICON_THEME} )
+ bitmap_dir( 16 16 "${BMAPS_SMALL}" )
- bitmap_dir( 24 24 "${BMAPS_MID}" ${KICAD_ICON_THEME} )
+ bitmap_dir( 24 24 "${BMAPS_MID}" )
- bitmap_dir( 32 32 "${BMAPS_32}" ${KICAD_ICON_THEME} )
+ bitmap_dir( 32 32 "${BMAPS_32}" )
- bitmap_dir( 22 22 "${BMAPS_22}" ${KICAD_ICON_THEME} )
+ bitmap_dir( 22 22 "${BMAPS_22}" )
- bitmap_dir( 24 24 "${BMAPS_24}" ${KICAD_ICON_THEME} )
+ bitmap_dir( 24 24 "${BMAPS_24}" )
- bitmap_dir( 64 64 "${BMAPS_64}" ${KICAD_ICON_THEME} )
+ bitmap_dir( 64 64 "${BMAPS_64}" )
- bitmap_dir( 128 128 "${BMAPS_128}" ${KICAD_ICON_THEME} )
+ bitmap_dir( 128 128 "${BMAPS_128}" )
- bitmap_dir( 48 48 "${BMAPS_BIG}" ${KICAD_ICON_THEME} )
+ bitmap_dir( 48 48 "${BMAPS_BIG}" )
- generate_bitmap_info( ${BITMAP_INFO_TEMP_FILE} ${BITMAP_INFO_FILE} )
+ configure_file( ${BITMAP_INFO_TEMPLATE} ${BITMAP_INFO_FILE} NEWLINE_STYLE UNIX )
add_custom_target( generate_pngs ALL
DEPENDS ${ALL_PNGS}
COMMENT "Creating PNGs from SVGs"
)
- add_custom_target( bitmap_info ALL
- DEPENDS ${BITMAP_INFO_FILE}
- COMMENT "Creating bitmap_info header"
- )
-
- add_dependencies( bitmap_archive generate_pngs bitmap_info )
+ add_dependencies( bitmap_archive generate_pngs )
endif( MAINTAIN_PNGS )
diff --git a/common/tool/action_menu.cpp b/common/tool/action_menu.cpp
index 988a10e3a5..e9f708051c 100644
--- a/common/tool/action_menu.cpp
+++ b/common/tool/action_menu.cpp
@@ -126,7 +126,7 @@ void ACTION_MENU::DisplayTitle( bool aDisplay )
InsertSeparator( 0 );
Insert( 0, new wxMenuItem( this, wxID_NONE, m_title, wxEmptyString, wxITEM_NORMAL ) );
- if( m_icon != BITMAPS::INVALID_BITMAP )
+ if( !!m_icon )
AddBitmapToMenuItem( FindItemByPosition( 0 ), KiBitmap( m_icon ) );
m_titleDisplayed = true;
@@ -141,7 +141,7 @@ wxMenuItem* ACTION_MENU::Add( const wxString& aLabel, int aId, BITMAPS aIcon )
wxMenuItem* item = new wxMenuItem( this, aId, aLabel, wxEmptyString, wxITEM_NORMAL );
- if( aIcon != BITMAPS::INVALID_BITMAP )
+ if( !!aIcon )
AddBitmapToMenuItem( item, KiBitmap( aIcon ) );
return Append( item );
@@ -156,7 +156,7 @@ wxMenuItem* ACTION_MENU::Add( const wxString& aLabel, const wxString& aTooltip,
wxMenuItem* item = new wxMenuItem( this, aId, aLabel, aTooltip,
aIsCheckmarkEntry ? wxITEM_CHECK : wxITEM_NORMAL );
- if( aIcon != BITMAPS::INVALID_BITMAP )
+ if( !!aIcon )
AddBitmapToMenuItem( item, KiBitmap( aIcon ) );
return Append( item );
@@ -171,7 +171,7 @@ wxMenuItem* ACTION_MENU::Add( const TOOL_ACTION& aAction, bool aIsCheckmarkEntry
wxMenuItem* item = new wxMenuItem( this, aAction.GetUIId(), aAction.GetMenuItem(),
aAction.GetDescription(),
aIsCheckmarkEntry ? wxITEM_CHECK : wxITEM_NORMAL );
- if( icon != BITMAPS::INVALID_BITMAP )
+ if( !!icon )
AddBitmapToMenuItem( item, KiBitmap( icon ) );
m_toolActions[aAction.GetUIId()] = &aAction;
@@ -187,7 +187,7 @@ wxMenuItem* ACTION_MENU::Add( ACTION_MENU* aMenu )
wxASSERT_MSG( !menuCopy->m_title.IsEmpty(), "Set a title for ACTION_MENU using SetTitle()" );
- if( aMenu->m_icon != BITMAPS::INVALID_BITMAP )
+ if( !!aMenu->m_icon )
{
wxMenuItem* newItem = new wxMenuItem( this, -1, menuCopy->m_title );
AddBitmapToMenuItem( newItem, KiBitmap( aMenu->m_icon ) );
diff --git a/common/tool/conditional_menu.cpp b/common/tool/conditional_menu.cpp
index 1a2067180a..9ca5f740c7 100644
--- a/common/tool/conditional_menu.cpp
+++ b/common/tool/conditional_menu.cpp
@@ -66,7 +66,7 @@ void CONDITIONAL_MENU::AddItem( int aId, const wxString& aText, const wxString&
{
wxMenuItem item( nullptr, aId, aText, aTooltip, wxITEM_NORMAL );
- if( aIcon != BITMAPS::INVALID_BITMAP )
+ if( !!aIcon )
AddBitmapToMenuItem( &item, KiBitmap( aIcon ) );
addEntry( ENTRY( item, aIcon, aCondition, aOrder, false ) );
@@ -79,7 +79,7 @@ void CONDITIONAL_MENU::AddCheckItem( int aId, const wxString& aText, const wxStr
{
wxMenuItem item( nullptr, aId, aText, aTooltip, wxITEM_CHECK );
- if( aIcon != BITMAPS::INVALID_BITMAP )
+ if( !!aIcon )
AddBitmapToMenuItem( &item, KiBitmap( aIcon ) );
addEntry( ENTRY( item, aIcon, aCondition, aOrder, true ) );
@@ -160,7 +160,7 @@ void CONDITIONAL_MENU::Evaluate( SELECTION& aSelection )
entry.wxItem()->GetHelp(),
entry.wxItem()->GetKind() );
- if( entry.GetIcon() != BITMAPS::INVALID_BITMAP )
+ if( !!entry.GetIcon() )
AddBitmapToMenuItem( menuItem, KiBitmap( entry.GetIcon() ) );
// the wxMenuItem must be append only after the bitmap is set:
diff --git a/eeschema/dialogs/panel_setup_pinmap.cpp b/eeschema/dialogs/panel_setup_pinmap.cpp
index 019c693d70..48ba4fee06 100644
--- a/eeschema/dialogs/panel_setup_pinmap.cpp
+++ b/eeschema/dialogs/panel_setup_pinmap.cpp
@@ -180,7 +180,7 @@ void PANEL_SETUP_PINMAP::setDRCMatrixButtonState( wxBitmapButton *aButton, PIN_E
break;
}
- if( bitmap_butt != BITMAPS::INVALID_BITMAP )
+ if( !!bitmap_butt )
{
aButton->SetBitmap( KiBitmap( bitmap_butt ) );
aButton->SetToolTip( tooltip );
diff --git a/include/bitmaps/bitmap_info.h.in b/include/bitmaps/bitmap_info.h.in
new file mode 100644
index 0000000000..26c1139edb
--- /dev/null
+++ b/include/bitmaps/bitmap_info.h.in
@@ -0,0 +1,44 @@
+
+/*
+ * This program source code file is part of KiCad, a free EDA CAD application.
+ *
+ * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
+
+/**
+ * This file is auto-generated by CMake when MAINTAIN_PNGS is on. Do not edit by hand!
+ */
+
+#ifndef KICAD_BITMAP_INFO_H
+#define KICAD_BITMAP_INFO_H
+
+#include
+#include
+
+struct BITMAP_INFO
+{
+ BITMAPS id;
+ wxString filename;
+ int height;
+ wxString theme;
+};
+
+
+const std::vector g_BitmapInfo = {
+${BITMAP_INFO_LIST}
+};
+
+#endif // KICAD_BITMAP_INFO_H
diff --git a/include/bitmaps/bitmaps_list.h b/include/bitmaps/bitmaps_list.h
index d4da8f28ac..56ebb8ff45 100644
--- a/include/bitmaps/bitmaps_list.h
+++ b/include/bitmaps/bitmaps_list.h
@@ -561,4 +561,7 @@ enum class BITMAPS : unsigned int
sim_add_signal
};
+
+inline bool operator!( const BITMAPS& aBitmap ) { return aBitmap == BITMAPS::INVALID_BITMAP; }
+
#endif // BITMAPS_PNG_BITMAPS_LIST__H