Skip to content

Commit d868a76

Browse files
committed
[IMP] Don't rely on wxMaterialDesign library anymore
Avoid loading the whole library to build some SVG icons.
1 parent 6ed17ff commit d868a76

File tree

4 files changed

+71
-65
lines changed

4 files changed

+71
-65
lines changed

CMakeLists.txt

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -224,22 +224,6 @@ if (GO_BUILD_TESTING)
224224
message(STATUS " Coverage enabled")
225225
message(STATUS "============================================================================")
226226
endif()
227-
# include wxMaterialWidgets
228-
if(NOT WX_MATERIAL_PROVIDER_SRC_DIR)
229-
set(WX_MATERIAL_PROVIDER_SRC_DIR "${CMAKE_SOURCE_DIR}/submodules/wxMaterialDesignArtProvider")
230-
if(NOT EXISTS "${WX_MATERIAL_PROVIDER_SRC_DIR}/wxMaterialDesignIconsMain.h")
231-
message(
232-
FATAL_ERROR
233-
"${WX_MATERIAL_PROVIDER_SRC_DIR}/wxMaterialDesignIconsMain.h file does not exist."
234-
"Possible the wxMaterialDesign submodule has not been updated."
235-
"Try to execute 'git submodule update --init --recursive' in the source directory"
236-
)
237-
endif()
238-
endif()
239-
240-
set(WX_MATERIAL_DESIGN_SRC_DIR "${WX_MATERIAL_PROVIDER_SRC_DIR}/MaterialDesign")
241-
242-
add_subdirectory(src/wxMaterial)
243227

244228
add_subdirectory(src/build)
245229
add_subdirectory(src/images)

src/grandorgue/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ add_library(golib STATIC ${grandorgue_src})
257257
set(go_libs ${wxWidgets_LIBRARIES} ${WX_MATERIAL_DESIGN_SRC_DIR} ${YAML_CPP_LIBRARIES} ${RT_LIBRARIES} ${PORTAUDIO_LIBRARIES} ${FFTW_LIBRARIES} ${ZITACONVOLVER_LIBRARIES} CURL::libcurl)
258258
set(go_libdir ${wxWidgets_LIBRARY_DIRS} ${RT_LIBDIR} ${PORTAUDIO_LIBDIR} ${FFTW_LIBDIR})
259259
target_include_directories(golib PUBLIC ${YAML_CPP_INCLUDE_DIRS})
260-
target_link_libraries(golib wxMaterial GrandOrgueImages GrandOrgueCore ${go_libs})
260+
target_link_libraries(golib GrandOrgueImages GrandOrgueCore ${go_libs})
261261
link_directories(${go_libdir})
262262

263263
if (WIN32)

src/grandorgue/icons/GOIconManager.h

Lines changed: 70 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,62 @@
77
#ifndef GOICONMANAGER_H
88
#define GOICONMANAGER_H
99

10-
#include "wx/artprov.h"
11-
#include "wxMaterialDesignArtProvider.hpp"
12-
#include "wxMaterialTwoToneArt.hpp"
10+
#include <wx/artprov.h>
11+
// #include "wxMaterialDesignArtProvider.hpp"
12+
// #include "wxMaterialTwoToneArt.hpp"
1313
#include <string>
1414
#include <wx/bitmap.h>
1515
#include <wx/string.h>
16+
#include <wx/regex.h>
17+
18+
#ifndef wxART_DATA_SAVER_ON
19+
#define wxART_DATA_SAVER_ON wxART_MAKE_ART_ID(wxART_DATA_SAVER_ON)
20+
#endif
21+
static constexpr const char *SVG_MATERIAL_SHARP_DATA_SAVER_ON=
22+
R"rawsvg(<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M11 8v3H8v2h3v3h2v-3h3v-2h-3V8h-2zm2-5.95v3.03c3.39.49 6 3.39 6 6.92 0 .9-.18 1.75-.48 2.54l2.6 1.53c.56-1.24.88-2.62.88-4.07 0-5.18-3.95-9.45-9-9.95zM12 19c-3.87 0-7-3.13-7-7 0-3.53 2.61-6.43 6-6.92V2.05c-5.06.5-9 4.76-9 9.95 0 5.52 4.47 10 9.99 10 3.31 0 6.24-1.61 8.06-4.09l-2.6-1.53A6.95 6.95 0 0 1 12 19z"/></svg>)rawsvg"
23+
;
24+
25+
#ifndef wxART_SETTINGS_ETHERNET
26+
#define wxART_SETTINGS_ETHERNET wxART_MAKE_ART_ID(wxART_SETTINGS_ETHERNET)
27+
#endif
28+
static constexpr const char *SVG_MATERIAL_SHARP_SETTINGS_ETHERNET=
29+
R"rawsvg(<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M7.77 6.76 6.23 5.48.82 12l5.41 6.52 1.54-1.28L3.42 12l4.35-5.24zM7 13h2v-2H7v2zm10-2h-2v2h2v-2zm-6 2h2v-2h-2v2zm6.77-7.52-1.54 1.28L20.58 12l-4.35 5.24 1.54 1.28L23.18 12l-5.41-6.52z"/></svg>)rawsvg"
30+
;
31+
32+
#ifndef wxART_VOLUME_UP
33+
#define wxART_VOLUME_UP wxART_MAKE_ART_ID(wxART_VOLUME_UP)
34+
#endif
35+
static constexpr const char *SVG_MATERIAL_SHARP_VOLUME_UP=
36+
R"rawsvg(<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M3 9v6h4l5 5V4L7 9H3zm13.5 3A4.5 4.5 0 0 0 14 7.97v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z"/></svg>)rawsvg"
37+
;
38+
39+
#ifndef wxART_COMPARE_ARROWS
40+
#define wxART_COMPARE_ARROWS wxART_MAKE_ART_ID(wxART_COMPARE_ARROWS)
41+
#endif
42+
static constexpr const char *SVG_MATERIAL_SHARP_COMPARE_ARROWS=
43+
R"rawsvg(<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M9.01 14H2v2h7.01v3L13 15l-3.99-4v3zm5.98-1v-3H22V8h-7.01V5L11 9l3.99 4z"/></svg>)rawsvg"
44+
;
45+
46+
#ifndef wxART_LEAK_ADD
47+
#define wxART_LEAK_ADD wxART_MAKE_ART_ID(wxART_LEAK_ADD)
48+
#endif
49+
static constexpr const char *SVG_MATERIAL_SHARP_LEAK_ADD=
50+
R"rawsvg(<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M6 3H3v3c1.66 0 3-1.34 3-3zm8 0h-2a9 9 0 0 1-9 9v2c6.08 0 11-4.93 11-11zm-4 0H8c0 2.76-2.24 5-5 5v2c3.87 0 7-3.13 7-7zm0 18h2a9 9 0 0 1 9-9v-2c-6.07 0-11 4.93-11 11zm8 0h3v-3c-1.66 0-3 1.34-3 3zm-4 0h2c0-2.76 2.24-5 5-5v-2c-3.87 0-7 3.13-7 7z"/></svg>)rawsvg"
51+
;
52+
53+
#ifndef wxART_WARNING_AMBER
54+
#define wxART_WARNING_AMBER wxART_MAKE_ART_ID(wxART_WARNING_AMBER)
55+
#endif
56+
static constexpr const char *SVG_MATERIAL_SHARP_WARNING_AMBER=
57+
R"rawsvg(<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M12 5.99 19.53 19H4.47L12 5.99M12 2 1 21h22L12 2zm1 14h-2v2h2v-2zm0-6h-2v4h2v-4z"/></svg>)rawsvg"
58+
;
59+
60+
#ifndef wxART_PIANO
61+
#define wxART_PIANO wxART_MAKE_ART_ID(wxART_PIANO)
62+
#endif
63+
static constexpr const char *SVG_MATERIAL_SHARP_PIANO=
64+
R"rawsvg(<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M21 3H3v18h18V3zm-8 11.5h1.25V19h-4.5v-4.5H11V5h2v9.5zM5 5h2v9.5h1.25V19H5V5zm14 14h-3.25v-4.5H17V5h2v14z"/></svg>)rawsvg"
65+
;
1666

1767
/*
1868
* This is a class to manage icons through the application
@@ -28,33 +78,38 @@ class GOIconManager {
2878
* This returns the icon in char
2979
*/
3080
wxBitmap GetIcon(std::string icon_name) {
31-
wxString icon_id;
81+
wxString svg;
3282
if (icon_name == "set") {
33-
icon_id = wxART_DATA_SAVER_ON;
83+
svg = SVG_MATERIAL_SHARP_DATA_SAVER_ON;
3484
}
3585
if (icon_name == "level") {
36-
icon_id = wxART_SETTINGS_ETHERNET;
86+
svg = SVG_MATERIAL_SHARP_SETTINGS_ETHERNET;
3787
}
3888
if (icon_name == "volume") {
39-
icon_id = wxART_VOLUME_UP;
89+
svg = SVG_MATERIAL_SHARP_VOLUME_UP;
4090
}
4191
if (icon_name == "transpose") {
42-
icon_id = wxART_COMPARE_ARROWS;
92+
svg = SVG_MATERIAL_SHARP_COMPARE_ARROWS;
4393
}
4494
if (icon_name == "reverb") {
45-
icon_id = wxART_LEAK_ADD;
95+
svg = SVG_MATERIAL_SHARP_LEAK_ADD;
4696
}
4797
if (icon_name == "polyphony") {
48-
icon_id = wxART_PIANO;
98+
svg = SVG_MATERIAL_SHARP_PIANO;
4999
}
50100
if (icon_name == "panic") {
51-
icon_id = wxART_WARNING_AMBER;
101+
svg = SVG_MATERIAL_SHARP_WARNING_AMBER;
52102
}
103+
const wxSize& size = wxSize(24, 24);
104+
if (svg.IsEmpty()) return wxNullBitmap;
53105

54-
// wxArtProvider::Push(new wxMaterialDesignArtProvider);
55-
wxBitmap image = wxMaterialDesignArtProvider::GetBitmap(
56-
icon_id, wxART_CLIENT_MATERIAL_SHARP, wxSize(24, 24));
57-
return image;
106+
// Create bundle and get bitmap from it
107+
wxSize useSize = size==wxDefaultSize? wxSize(24,24) : size;
108+
wxBitmapBundle bundle = wxBitmapBundle::FromSVG(svg.mb_str(),useSize);
109+
if (!bundle.IsOk()) return wxNullBitmap;
110+
wxBitmap bmp = bundle.GetBitmap(useSize);
111+
if (!bmp.IsOk()) return wxNullBitmap;
112+
return bmp;
58113
};
59114
};
60115

src/wxMaterial/CMakeLists.txt

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)