From 65fe552a9dd30cb1c2ba2da60f37d12969896334 Mon Sep 17 00:00:00 2001 From: Denis Roussel Date: Sat, 10 Aug 2024 16:57:30 +0200 Subject: [PATCH 1/4] [IMP] wxWidgets: Allows to get Material Design icons --- .gitmodules | 3 +++ wxMaterialDesignArtProvider | 1 + 2 files changed, 4 insertions(+) create mode 160000 wxMaterialDesignArtProvider diff --git a/.gitmodules b/.gitmodules index a37fc3e62..c48a99dcf 100644 --- a/.gitmodules +++ b/.gitmodules @@ -12,3 +12,6 @@ [submodule "submodules/ZitaConvolver"] path = submodules/ZitaConvolver url = https://github.com/GrandOrgue/ZitaConvolver.git +[submodule "wxMaterialDesignArtProvider"] + path = wxMaterialDesignArtProvider + url = https://github.com/perazz/wxMaterialDesignArtProvider diff --git a/wxMaterialDesignArtProvider b/wxMaterialDesignArtProvider new file mode 160000 index 000000000..204363ed6 --- /dev/null +++ b/wxMaterialDesignArtProvider @@ -0,0 +1 @@ +Subproject commit 204363ed675fedc2b0a7e6cf335d5f5fa27758ea From 598db3a6495a034146288b398f659489d54266ea Mon Sep 17 00:00:00 2001 From: Denis Roussel Date: Sun, 11 Aug 2024 17:23:52 +0200 Subject: [PATCH 2/4] [IMP] Add wxMaterialDesign library --- .gitmodules | 3 ++ CMakeLists.txt | 19 ++++++++++ src/grandorgue/CMakeLists.txt | 5 +-- src/grandorgue/gui/frames/GOFrame.cpp | 11 ++++-- src/grandorgue/icons/GOIconManager.cpp | 11 ++++++ src/grandorgue/icons/GOIconManager.h | 35 +++++++++++++++++++ src/wxMaterial/CMakeLists.txt | 20 +++++++++++ .../wxMaterialDesignArtProvider | 0 8 files changed, 100 insertions(+), 4 deletions(-) create mode 100644 src/grandorgue/icons/GOIconManager.cpp create mode 100644 src/grandorgue/icons/GOIconManager.h create mode 100644 src/wxMaterial/CMakeLists.txt rename wxMaterialDesignArtProvider => submodules/wxMaterialDesignArtProvider (100%) diff --git a/.gitmodules b/.gitmodules index c48a99dcf..ee02026d2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -15,3 +15,6 @@ [submodule "wxMaterialDesignArtProvider"] path = wxMaterialDesignArtProvider url = https://github.com/perazz/wxMaterialDesignArtProvider +[submodule "submodules/wxMaterialDesignArtProvider"] + path = submodules/wxMaterialDesignArtProvider + url = https://github.com/perazz/wxMaterialDesignArtProvider diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e8692e17..e609f8427 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -224,6 +224,25 @@ if (GO_BUILD_TESTING) message(STATUS " Coverage enabled") message(STATUS "============================================================================") endif() +# include wxMaterialWidgets +if(NOT WX_MATERIAL_PROVIDER_SRC_DIR) + set(WX_MATERIAL_PROVIDER_SRC_DIR "${CMAKE_SOURCE_DIR}/submodules/wxMaterialDesignArtProvider") + if(NOT EXISTS "${WX_MATERIAL_PROVIDER_SRC_DIR}/wxMaterialDesignIconsMain.h") + message( + FATAL_ERROR + "${WX_MATERIAL_PROVIDER_SRC_DIR}/wxMaterialDesignIconsMain.h file does not exist." + "Possible the wxMaterialDesign submodule has not been updated." + "Try to execute 'git submodule update --init --recursive' in the source directory" + ) + endif() + endif() + +set(WX_MATERIAL_DESIGN_SRC_DIR "${WX_MATERIAL_PROVIDER_SRC_DIR}/MaterialDesign") + +include_directories(WX_MATERIAL_PROVIDER_SRC_DIR) +include_directories(WX_MATERIAL_DESIGN_SRC_DIR) + +add_subdirectory(src/wxMaterial) add_subdirectory(src/build) add_subdirectory(src/images) diff --git a/src/grandorgue/CMakeLists.txt b/src/grandorgue/CMakeLists.txt index e33374ebe..ae769bd4f 100644 --- a/src/grandorgue/CMakeLists.txt +++ b/src/grandorgue/CMakeLists.txt @@ -136,6 +136,7 @@ gui/wxcontrols/GORightVisiblePicker.cpp gui/wxcontrols/go_gui_utils.cpp help/GOHelpController.cpp help/GOHelpRequestor.cpp +icons/GOIconManager.cpp loader/GOFileStore.cpp loader/GOLoaderFilename.cpp loader/GOLoadThread.cpp @@ -252,10 +253,10 @@ if (USE_INTERNAL_ZITACONVOLVER) endif() add_library(golib STATIC ${grandorgue_src}) -set(go_libs ${wxWidgets_LIBRARIES} ${YAML_CPP_LIBRARIES} ${RT_LIBRARIES} ${PORTAUDIO_LIBRARIES} ${FFTW_LIBRARIES} ${ZITACONVOLVER_LIBRARIES} CURL::libcurl) +set(go_libs ${wxWidgets_LIBRARIES} ${WX_MATERIAL_DESIGN_SRC_DIR} ${YAML_CPP_LIBRARIES} ${RT_LIBRARIES} ${PORTAUDIO_LIBRARIES} ${FFTW_LIBRARIES} ${ZITACONVOLVER_LIBRARIES} CURL::libcurl) set(go_libdir ${wxWidgets_LIBRARY_DIRS} ${RT_LIBDIR} ${PORTAUDIO_LIBDIR} ${FFTW_LIBDIR}) target_include_directories(golib PUBLIC ${YAML_CPP_INCLUDE_DIRS}) -target_link_libraries(golib GrandOrgueImages GrandOrgueCore ${go_libs}) +target_link_libraries(golib wxMaterial GrandOrgueImages GrandOrgueCore ${go_libs}) link_directories(${go_libdir}) if (WIN32) diff --git a/src/grandorgue/gui/frames/GOFrame.cpp b/src/grandorgue/gui/frames/GOFrame.cpp index 418652a35..5051877dc 100644 --- a/src/grandorgue/gui/frames/GOFrame.cpp +++ b/src/grandorgue/gui/frames/GOFrame.cpp @@ -47,6 +47,8 @@ #include "temperaments/GOTemperament.h" #include "threading/GOMutexLocker.h" +#include "icons/GOIconManager.h" + #include "GOApp.h" #include "GODocument.h" #include "GOEvent.h" @@ -297,9 +299,14 @@ GOFrame::GOFrame( 999); m_ToolBar->AddControl(m_SetterPosition); m_SetterPosition->SetValue(0); - + GOIconManager *m_icon = new GOIconManager(); + std::string volume = "volume"; m_ToolBar->AddTool( - ID_VOLUME, _("&Volume"), GetImage_volume(), _("Volume"), wxITEM_NORMAL); + ID_VOLUME, + _("&Volume"), + m_icon->GetIcon(volume), + _("Volume"), + wxITEM_NORMAL); m_Volume = new wxSpinCtrl( m_ToolBar, ID_METER_AUDIO_SPIN, diff --git a/src/grandorgue/icons/GOIconManager.cpp b/src/grandorgue/icons/GOIconManager.cpp new file mode 100644 index 000000000..7b7e6dbb0 --- /dev/null +++ b/src/grandorgue/icons/GOIconManager.cpp @@ -0,0 +1,11 @@ +/* + * Copyright 2009-2024 GrandOrgue contributors (see AUTHORS) + * License GPL-2.0 or later + * (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html). + */ + +#include "GOIconManager.h" + +GOIconManager::GOIconManager(){}; + +GOIconManager::~GOIconManager(){}; diff --git a/src/grandorgue/icons/GOIconManager.h b/src/grandorgue/icons/GOIconManager.h new file mode 100644 index 000000000..26ce04e9d --- /dev/null +++ b/src/grandorgue/icons/GOIconManager.h @@ -0,0 +1,35 @@ +/* + * Copyright 2009-2024 GrandOrgue contributors (see AUTHORS) + * License GPL-2.0 or later + * (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html). + */ + +#ifndef GOICONMANAGER_H +#define GOICONMANAGER_H + +#include "wx/artprov.h" +#include +#include +#include +/* + * This is a class to manage icons through the application + * It is agnostic from any particular library + */ +class GOIconManager { + +public: + GOIconManager(); + ~GOIconManager(); + + /* + * This returns the icon in char + */ + wxBitmap GetIcon(std::string icon_name) { + wxArtProvider::Push(new wxMaterialDesignArtProvider); + wxBitmap image = wxArtProvider::GetBitmap( + wxART_CLIENT_MATERIAL_TWOTONE, wxART_VOLUME_UP, wxSize(10, 10)); + return image; + }; +}; + +#endif /* GOMIDI_H */ \ No newline at end of file diff --git a/src/wxMaterial/CMakeLists.txt b/src/wxMaterial/CMakeLists.txt new file mode 100644 index 000000000..e713ac805 --- /dev/null +++ b/src/wxMaterial/CMakeLists.txt @@ -0,0 +1,20 @@ +# Copyright 2009-2024 GrandOrgue contributors (see AUTHORS) +# License GPL-2.0 or later (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html). + +message(STATUS "wxMaterialDesign Art Provider configuration") + +include(UsewxWidgets) +INCLUDE (CheckIncludeFileCXX) + + +set(wxMaterial_Source "${WX_MATERIAL_DESIGN_SRC_DIR}/wxMaterialDesignArtProvider.cpp") + +include_directories(WX_MATERIAL_DESIGN_SRC_DIR) + +add_library(wxMaterial STATIC ${wxMaterial_Source}) +target_link_libraries(wxMaterial ${wxWidgets_LIBRARIES}) + + +# find_package(wxWidgets REQUIRED wxMaterial) + +message(STATUS "============================================================================") diff --git a/wxMaterialDesignArtProvider b/submodules/wxMaterialDesignArtProvider similarity index 100% rename from wxMaterialDesignArtProvider rename to submodules/wxMaterialDesignArtProvider From 838329a95d588d1135840a07b1a12160aedc6f17 Mon Sep 17 00:00:00 2001 From: Denis Roussel Date: Mon, 12 Aug 2024 11:57:12 +0200 Subject: [PATCH 3/4] [IMP] Add IconManager to load icons from their GO name --- CMakeLists.txt | 3 --- src/grandorgue/CMakeLists.txt | 1 + src/grandorgue/gui/frames/GOFrame.cpp | 24 ++++++++++--------- src/grandorgue/icons/GOIconManager.h | 34 +++++++++++++++++++++++---- src/wxMaterial/CMakeLists.txt | 17 ++++++++++++-- 5 files changed, 59 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e609f8427..0740d0020 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -239,9 +239,6 @@ if(NOT WX_MATERIAL_PROVIDER_SRC_DIR) set(WX_MATERIAL_DESIGN_SRC_DIR "${WX_MATERIAL_PROVIDER_SRC_DIR}/MaterialDesign") -include_directories(WX_MATERIAL_PROVIDER_SRC_DIR) -include_directories(WX_MATERIAL_DESIGN_SRC_DIR) - add_subdirectory(src/wxMaterial) add_subdirectory(src/build) diff --git a/src/grandorgue/CMakeLists.txt b/src/grandorgue/CMakeLists.txt index ae769bd4f..73b1004bd 100644 --- a/src/grandorgue/CMakeLists.txt +++ b/src/grandorgue/CMakeLists.txt @@ -37,6 +37,7 @@ include_directories(${wxWidgets_INCLUDE_DIRS}) include_directories(${JACK_INCLUDE_DIRS}) include_directories(${YAML_CPP_INCLUDE_DIRS}) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +include_directories(${WX_MATERIAL_DESIGN_SRC_DIR}) set(grandorgue_src combinations/control/GOCombinationButtonSet.cpp diff --git a/src/grandorgue/gui/frames/GOFrame.cpp b/src/grandorgue/gui/frames/GOFrame.cpp index 5051877dc..e295ecdef 100644 --- a/src/grandorgue/gui/frames/GOFrame.cpp +++ b/src/grandorgue/gui/frames/GOFrame.cpp @@ -276,16 +276,19 @@ GOFrame::GOFrame( m_ToolBar = CreateToolBar(wxNO_BORDER | wxTB_HORIZONTAL | wxTB_FLAT); m_ToolBar->SetToolBitmapSize(wxSize(16, 16)); + GOIconManager *m_icon = new GOIconManager(); + std::string set = "set"; m_ToolBar->AddTool( ID_AUDIO_MEMSET, _("&Memory Set\tShift"), - GetImage_set(), + m_icon->GetIcon(set), _("Memory Set"), wxITEM_CHECK); + std::string level = "level"; m_ToolBar->AddTool( ID_MEMORY, _("&Memory Level"), - GetImage_memory(), + m_icon->GetIcon(level), _("Memory Level"), wxITEM_NORMAL); m_SetterPosition = new wxSpinCtrl( @@ -299,7 +302,6 @@ GOFrame::GOFrame( 999); m_ToolBar->AddControl(m_SetterPosition); m_SetterPosition->SetValue(0); - GOIconManager *m_icon = new GOIconManager(); std::string volume = "volume"; m_ToolBar->AddTool( ID_VOLUME, @@ -321,11 +323,11 @@ GOFrame::GOFrame( m_VolumeControlTool = m_ToolBar->AddControl(m_VolumeControl); AdjustVolumeControlWithSettings(); m_Volume->SetValue(m_config.Volume()); - + std::string reverb = "reverb"; m_ToolBar->AddTool( ID_RELEASELENGTH, _("&Release tail length"), - GetImage_reverb(), + m_icon->GetIcon(reverb), _("Release tail length"), wxITEM_NORMAL); choices.clear(); @@ -340,11 +342,11 @@ GOFrame::GOFrame( choices); m_ToolBar->AddControl(m_ReleaseLength); UpdateReleaseLength(0); - + std::string transpose = "transpose"; m_ToolBar->AddTool( ID_TRANSPOSE, _("&Transpose"), - GetImage_transpose(), + m_icon->GetIcon(transpose), _("Transpose"), wxITEM_NORMAL); m_Transpose = new wxSpinCtrl( @@ -358,11 +360,11 @@ GOFrame::GOFrame( 11); m_ToolBar->AddControl(m_Transpose); m_Transpose->SetValue(m_config.Transpose()); - + std::string polyphony = "polyphony"; m_ToolBar->AddTool( ID_POLYPHONY, _("&Polyphony"), - GetImage_polyphony(), + m_icon->GetIcon(polyphony), _("Polyphony"), wxITEM_NORMAL); m_Polyphony = new wxSpinCtrl( @@ -379,11 +381,11 @@ GOFrame::GOFrame( m_SamplerUsage = new GOAudioGauge(m_ToolBar, wxID_ANY, wxDefaultPosition); m_ToolBar->AddControl(m_SamplerUsage); m_Polyphony->SetValue(m_config.PolyphonyLimit()); - + std::string panic = "panic"; m_ToolBar->AddTool( ID_AUDIO_PANIC, _("&Panic\tEscape"), - GetImage_panic(), + m_icon->GetIcon(panic), _("Panic"), wxITEM_NORMAL); diff --git a/src/grandorgue/icons/GOIconManager.h b/src/grandorgue/icons/GOIconManager.h index 26ce04e9d..69a324ec7 100644 --- a/src/grandorgue/icons/GOIconManager.h +++ b/src/grandorgue/icons/GOIconManager.h @@ -8,9 +8,12 @@ #define GOICONMANAGER_H #include "wx/artprov.h" +#include "wxMaterialDesignArtProvider.hpp" +#include "wxMaterialTwoToneArt.hpp" #include #include -#include +#include + /* * This is a class to manage icons through the application * It is agnostic from any particular library @@ -25,9 +28,32 @@ class GOIconManager { * This returns the icon in char */ wxBitmap GetIcon(std::string icon_name) { - wxArtProvider::Push(new wxMaterialDesignArtProvider); - wxBitmap image = wxArtProvider::GetBitmap( - wxART_CLIENT_MATERIAL_TWOTONE, wxART_VOLUME_UP, wxSize(10, 10)); + wxString icon_id; + if (icon_name == "set") { + icon_id = wxART_DATA_SAVER_ON; + } + if (icon_name == "level") { + icon_id = wxART_SETTINGS_ETHERNET; + } + if (icon_name == "volume") { + icon_id = wxART_VOLUME_UP; + } + if (icon_name == "transpose") { + icon_id = wxART_COMPARE_ARROWS; + } + if (icon_name == "reverb") { + icon_id = wxART_LEAK_ADD; + } + if (icon_name == "polyphony") { + icon_id = wxART_PIANO; + } + if (icon_name == "panic") { + icon_id = wxART_WARNING_AMBER; + } + + // wxArtProvider::Push(new wxMaterialDesignArtProvider); + wxBitmap image = wxMaterialDesignArtProvider::GetBitmap( + icon_id, wxART_CLIENT_MATERIAL_SHARP, wxSize(24, 24)); return image; }; }; diff --git a/src/wxMaterial/CMakeLists.txt b/src/wxMaterial/CMakeLists.txt index e713ac805..63954cf6d 100644 --- a/src/wxMaterial/CMakeLists.txt +++ b/src/wxMaterial/CMakeLists.txt @@ -6,12 +6,25 @@ message(STATUS "wxMaterialDesign Art Provider configuration") include(UsewxWidgets) INCLUDE (CheckIncludeFileCXX) - +set(wxMaterial_src +${WX_MATERIAL_DESIGN_SRC_DIR}/wxAwesomeBrandsArt.cpp +${WX_MATERIAL_DESIGN_SRC_DIR}/wxAwesomeRegularArt.cpp +${WX_MATERIAL_DESIGN_SRC_DIR}/wxAwesomeSolidArt.cpp +${WX_MATERIAL_DESIGN_SRC_DIR}/wxFluentuiFilledArt.cpp +${WX_MATERIAL_DESIGN_SRC_DIR}/wxMaterialFilledArt.cpp +${WX_MATERIAL_DESIGN_SRC_DIR}/wxFluentuiRegularArt.cpp +${WX_MATERIAL_DESIGN_SRC_DIR}/wxMaterialDesignArtProvider.cpp +${WX_MATERIAL_DESIGN_SRC_DIR}/wxMaterialOutlinedArt.cpp +${WX_MATERIAL_DESIGN_SRC_DIR}/wxMaterialRoundArt.cpp +${WX_MATERIAL_DESIGN_SRC_DIR}/wxMaterialSharpArt.cpp +${WX_MATERIAL_DESIGN_SRC_DIR}/wxMaterialTwoToneArt.cpp +${WX_MATERIAL_DESIGN_SRC_DIR}/wxSimpleIconsArt.cpp +) set(wxMaterial_Source "${WX_MATERIAL_DESIGN_SRC_DIR}/wxMaterialDesignArtProvider.cpp") include_directories(WX_MATERIAL_DESIGN_SRC_DIR) -add_library(wxMaterial STATIC ${wxMaterial_Source}) +add_library(wxMaterial STATIC ${wxMaterial_src}) target_link_libraries(wxMaterial ${wxWidgets_LIBRARIES}) From 57ad67adf7da929411e8f36b4ba6f3313bed28d3 Mon Sep 17 00:00:00 2001 From: Denis Roussel Date: Sun, 8 Jun 2025 16:52:09 +0200 Subject: [PATCH 4/4] [IMP] Don't rely on wxMaterialDesign library anymore Avoid loading the whole library to build some SVG icons. --- CMakeLists.txt | 18 +----- src/grandorgue/CMakeLists.txt | 2 +- src/grandorgue/icons/GOIconManager.h | 83 ++++++++++++++++++++++------ src/wxMaterial/CMakeLists.txt | 33 ----------- 4 files changed, 69 insertions(+), 67 deletions(-) delete mode 100644 src/wxMaterial/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 0740d0020..d68316629 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ # Copyright 2006 Milan Digital Audio LLC -# Copyright 2009-2024 GrandOrgue contributors (see AUTHORS) +# Copyright 2009-2025 GrandOrgue contributors (see AUTHORS) # License GPL-2.0 or later # (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html). @@ -224,22 +224,6 @@ if (GO_BUILD_TESTING) message(STATUS " Coverage enabled") message(STATUS "============================================================================") endif() -# include wxMaterialWidgets -if(NOT WX_MATERIAL_PROVIDER_SRC_DIR) - set(WX_MATERIAL_PROVIDER_SRC_DIR "${CMAKE_SOURCE_DIR}/submodules/wxMaterialDesignArtProvider") - if(NOT EXISTS "${WX_MATERIAL_PROVIDER_SRC_DIR}/wxMaterialDesignIconsMain.h") - message( - FATAL_ERROR - "${WX_MATERIAL_PROVIDER_SRC_DIR}/wxMaterialDesignIconsMain.h file does not exist." - "Possible the wxMaterialDesign submodule has not been updated." - "Try to execute 'git submodule update --init --recursive' in the source directory" - ) - endif() - endif() - -set(WX_MATERIAL_DESIGN_SRC_DIR "${WX_MATERIAL_PROVIDER_SRC_DIR}/MaterialDesign") - -add_subdirectory(src/wxMaterial) add_subdirectory(src/build) add_subdirectory(src/images) diff --git a/src/grandorgue/CMakeLists.txt b/src/grandorgue/CMakeLists.txt index 73b1004bd..79bb9eed0 100644 --- a/src/grandorgue/CMakeLists.txt +++ b/src/grandorgue/CMakeLists.txt @@ -257,7 +257,7 @@ add_library(golib STATIC ${grandorgue_src}) set(go_libs ${wxWidgets_LIBRARIES} ${WX_MATERIAL_DESIGN_SRC_DIR} ${YAML_CPP_LIBRARIES} ${RT_LIBRARIES} ${PORTAUDIO_LIBRARIES} ${FFTW_LIBRARIES} ${ZITACONVOLVER_LIBRARIES} CURL::libcurl) set(go_libdir ${wxWidgets_LIBRARY_DIRS} ${RT_LIBDIR} ${PORTAUDIO_LIBDIR} ${FFTW_LIBDIR}) target_include_directories(golib PUBLIC ${YAML_CPP_INCLUDE_DIRS}) -target_link_libraries(golib wxMaterial GrandOrgueImages GrandOrgueCore ${go_libs}) +target_link_libraries(golib GrandOrgueImages GrandOrgueCore ${go_libs}) link_directories(${go_libdir}) if (WIN32) diff --git a/src/grandorgue/icons/GOIconManager.h b/src/grandorgue/icons/GOIconManager.h index 69a324ec7..65c428f91 100644 --- a/src/grandorgue/icons/GOIconManager.h +++ b/src/grandorgue/icons/GOIconManager.h @@ -1,5 +1,5 @@ /* - * Copyright 2009-2024 GrandOrgue contributors (see AUTHORS) + * Copyright 2009-2025 GrandOrgue contributors (see AUTHORS) * License GPL-2.0 or later * (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html). */ @@ -7,13 +7,56 @@ #ifndef GOICONMANAGER_H #define GOICONMANAGER_H -#include "wx/artprov.h" -#include "wxMaterialDesignArtProvider.hpp" -#include "wxMaterialTwoToneArt.hpp" +#include +// #include "wxMaterialDesignArtProvider.hpp" +// #include "wxMaterialTwoToneArt.hpp" #include #include +#include #include +#ifndef wxART_DATA_SAVER_ON +#define wxART_DATA_SAVER_ON wxART_MAKE_ART_ID(wxART_DATA_SAVER_ON) +#endif +static constexpr const char *SVG_MATERIAL_SHARP_DATA_SAVER_ON + = R"rawsvg()rawsvg"; + +#ifndef wxART_SETTINGS_ETHERNET +#define wxART_SETTINGS_ETHERNET wxART_MAKE_ART_ID(wxART_SETTINGS_ETHERNET) +#endif +static constexpr const char *SVG_MATERIAL_SHARP_SETTINGS_ETHERNET + = R"rawsvg()rawsvg"; + +#ifndef wxART_VOLUME_UP +#define wxART_VOLUME_UP wxART_MAKE_ART_ID(wxART_VOLUME_UP) +#endif +static constexpr const char *SVG_MATERIAL_SHARP_VOLUME_UP + = R"rawsvg()rawsvg"; + +#ifndef wxART_COMPARE_ARROWS +#define wxART_COMPARE_ARROWS wxART_MAKE_ART_ID(wxART_COMPARE_ARROWS) +#endif +static constexpr const char *SVG_MATERIAL_SHARP_COMPARE_ARROWS + = R"rawsvg()rawsvg"; + +#ifndef wxART_LEAK_ADD +#define wxART_LEAK_ADD wxART_MAKE_ART_ID(wxART_LEAK_ADD) +#endif +static constexpr const char *SVG_MATERIAL_SHARP_LEAK_ADD + = R"rawsvg()rawsvg"; + +#ifndef wxART_WARNING_AMBER +#define wxART_WARNING_AMBER wxART_MAKE_ART_ID(wxART_WARNING_AMBER) +#endif +static constexpr const char *SVG_MATERIAL_SHARP_WARNING_AMBER + = R"rawsvg()rawsvg"; + +#ifndef wxART_PIANO +#define wxART_PIANO wxART_MAKE_ART_ID(wxART_PIANO) +#endif +static constexpr const char *SVG_MATERIAL_SHARP_PIANO + = R"rawsvg()rawsvg"; + /* * This is a class to manage icons through the application * It is agnostic from any particular library @@ -28,33 +71,41 @@ class GOIconManager { * This returns the icon in char */ wxBitmap GetIcon(std::string icon_name) { - wxString icon_id; + wxString svg; if (icon_name == "set") { - icon_id = wxART_DATA_SAVER_ON; + svg = SVG_MATERIAL_SHARP_DATA_SAVER_ON; } if (icon_name == "level") { - icon_id = wxART_SETTINGS_ETHERNET; + svg = SVG_MATERIAL_SHARP_SETTINGS_ETHERNET; } if (icon_name == "volume") { - icon_id = wxART_VOLUME_UP; + svg = SVG_MATERIAL_SHARP_VOLUME_UP; } if (icon_name == "transpose") { - icon_id = wxART_COMPARE_ARROWS; + svg = SVG_MATERIAL_SHARP_COMPARE_ARROWS; } if (icon_name == "reverb") { - icon_id = wxART_LEAK_ADD; + svg = SVG_MATERIAL_SHARP_LEAK_ADD; } if (icon_name == "polyphony") { - icon_id = wxART_PIANO; + svg = SVG_MATERIAL_SHARP_PIANO; } if (icon_name == "panic") { - icon_id = wxART_WARNING_AMBER; + svg = SVG_MATERIAL_SHARP_WARNING_AMBER; } + const wxSize &size = wxSize(24, 24); + if (svg.IsEmpty()) + return wxNullBitmap; - // wxArtProvider::Push(new wxMaterialDesignArtProvider); - wxBitmap image = wxMaterialDesignArtProvider::GetBitmap( - icon_id, wxART_CLIENT_MATERIAL_SHARP, wxSize(24, 24)); - return image; + // Create bundle and get bitmap from it + wxSize useSize = size == wxDefaultSize ? wxSize(24, 24) : size; + wxBitmapBundle bundle = wxBitmapBundle::FromSVG(svg.mb_str(), useSize); + if (!bundle.IsOk()) + return wxNullBitmap; + wxBitmap bmp = bundle.GetBitmap(useSize); + if (!bmp.IsOk()) + return wxNullBitmap; + return bmp; }; }; diff --git a/src/wxMaterial/CMakeLists.txt b/src/wxMaterial/CMakeLists.txt deleted file mode 100644 index 63954cf6d..000000000 --- a/src/wxMaterial/CMakeLists.txt +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright 2009-2024 GrandOrgue contributors (see AUTHORS) -# License GPL-2.0 or later (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html). - -message(STATUS "wxMaterialDesign Art Provider configuration") - -include(UsewxWidgets) -INCLUDE (CheckIncludeFileCXX) - -set(wxMaterial_src -${WX_MATERIAL_DESIGN_SRC_DIR}/wxAwesomeBrandsArt.cpp -${WX_MATERIAL_DESIGN_SRC_DIR}/wxAwesomeRegularArt.cpp -${WX_MATERIAL_DESIGN_SRC_DIR}/wxAwesomeSolidArt.cpp -${WX_MATERIAL_DESIGN_SRC_DIR}/wxFluentuiFilledArt.cpp -${WX_MATERIAL_DESIGN_SRC_DIR}/wxMaterialFilledArt.cpp -${WX_MATERIAL_DESIGN_SRC_DIR}/wxFluentuiRegularArt.cpp -${WX_MATERIAL_DESIGN_SRC_DIR}/wxMaterialDesignArtProvider.cpp -${WX_MATERIAL_DESIGN_SRC_DIR}/wxMaterialOutlinedArt.cpp -${WX_MATERIAL_DESIGN_SRC_DIR}/wxMaterialRoundArt.cpp -${WX_MATERIAL_DESIGN_SRC_DIR}/wxMaterialSharpArt.cpp -${WX_MATERIAL_DESIGN_SRC_DIR}/wxMaterialTwoToneArt.cpp -${WX_MATERIAL_DESIGN_SRC_DIR}/wxSimpleIconsArt.cpp -) -set(wxMaterial_Source "${WX_MATERIAL_DESIGN_SRC_DIR}/wxMaterialDesignArtProvider.cpp") - -include_directories(WX_MATERIAL_DESIGN_SRC_DIR) - -add_library(wxMaterial STATIC ${wxMaterial_src}) -target_link_libraries(wxMaterial ${wxWidgets_LIBRARIES}) - - -# find_package(wxWidgets REQUIRED wxMaterial) - -message(STATUS "============================================================================")