Skip to content

Commit 6ed17ff

Browse files
committed
[IMP] Add IconManager to load icons from their GO name
1 parent 5239032 commit 6ed17ff

File tree

5 files changed

+59
-20
lines changed

5 files changed

+59
-20
lines changed

CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,6 @@ if(NOT WX_MATERIAL_PROVIDER_SRC_DIR)
239239

240240
set(WX_MATERIAL_DESIGN_SRC_DIR "${WX_MATERIAL_PROVIDER_SRC_DIR}/MaterialDesign")
241241

242-
include_directories(WX_MATERIAL_PROVIDER_SRC_DIR)
243-
include_directories(WX_MATERIAL_DESIGN_SRC_DIR)
244-
245242
add_subdirectory(src/wxMaterial)
246243

247244
add_subdirectory(src/build)

src/grandorgue/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ include_directories(${wxWidgets_INCLUDE_DIRS})
3737
include_directories(${JACK_INCLUDE_DIRS})
3838
include_directories(${YAML_CPP_INCLUDE_DIRS})
3939
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
40+
include_directories(${WX_MATERIAL_DESIGN_SRC_DIR})
4041

4142
set(grandorgue_src
4243
combinations/control/GOCombinationButtonSet.cpp

src/grandorgue/gui/frames/GOFrame.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -276,16 +276,19 @@ GOFrame::GOFrame(
276276

277277
m_ToolBar = CreateToolBar(wxNO_BORDER | wxTB_HORIZONTAL | wxTB_FLAT);
278278
m_ToolBar->SetToolBitmapSize(wxSize(16, 16));
279+
GOIconManager *m_icon = new GOIconManager();
280+
std::string set = "set";
279281
m_ToolBar->AddTool(
280282
ID_AUDIO_MEMSET,
281283
_("&Memory Set\tShift"),
282-
GetImage_set(),
284+
m_icon->GetIcon(set),
283285
_("Memory Set"),
284286
wxITEM_CHECK);
287+
std::string level = "level";
285288
m_ToolBar->AddTool(
286289
ID_MEMORY,
287290
_("&Memory Level"),
288-
GetImage_memory(),
291+
m_icon->GetIcon(level),
289292
_("Memory Level"),
290293
wxITEM_NORMAL);
291294
m_SetterPosition = new wxSpinCtrl(
@@ -299,7 +302,6 @@ GOFrame::GOFrame(
299302
999);
300303
m_ToolBar->AddControl(m_SetterPosition);
301304
m_SetterPosition->SetValue(0);
302-
GOIconManager *m_icon = new GOIconManager();
303305
std::string volume = "volume";
304306
// wxBitmap volume;
305307
// volume = m_icon->GetIcon("volume");
@@ -323,11 +325,11 @@ GOFrame::GOFrame(
323325
m_VolumeControlTool = m_ToolBar->AddControl(m_VolumeControl);
324326
AdjustVolumeControlWithSettings();
325327
m_Volume->SetValue(m_config.Volume());
326-
328+
std::string reverb = "reverb";
327329
m_ToolBar->AddTool(
328330
ID_RELEASELENGTH,
329331
_("&Release tail length"),
330-
GetImage_reverb(),
332+
m_icon->GetIcon(reverb),
331333
_("Release tail length"),
332334
wxITEM_NORMAL);
333335
choices.clear();
@@ -342,11 +344,11 @@ GOFrame::GOFrame(
342344
choices);
343345
m_ToolBar->AddControl(m_ReleaseLength);
344346
UpdateReleaseLength(0);
345-
347+
std::string transpose = "transpose";
346348
m_ToolBar->AddTool(
347349
ID_TRANSPOSE,
348350
_("&Transpose"),
349-
GetImage_transpose(),
351+
m_icon->GetIcon(transpose),
350352
_("Transpose"),
351353
wxITEM_NORMAL);
352354
m_Transpose = new wxSpinCtrl(
@@ -360,11 +362,11 @@ GOFrame::GOFrame(
360362
11);
361363
m_ToolBar->AddControl(m_Transpose);
362364
m_Transpose->SetValue(m_config.Transpose());
363-
365+
std::string polyphony = "polyphony";
364366
m_ToolBar->AddTool(
365367
ID_POLYPHONY,
366368
_("&Polyphony"),
367-
GetImage_polyphony(),
369+
m_icon->GetIcon(polyphony),
368370
_("Polyphony"),
369371
wxITEM_NORMAL);
370372
m_Polyphony = new wxSpinCtrl(
@@ -381,11 +383,11 @@ GOFrame::GOFrame(
381383
m_SamplerUsage = new GOAudioGauge(m_ToolBar, wxID_ANY, wxDefaultPosition);
382384
m_ToolBar->AddControl(m_SamplerUsage);
383385
m_Polyphony->SetValue(m_config.PolyphonyLimit());
384-
386+
std::string panic = "panic";
385387
m_ToolBar->AddTool(
386388
ID_AUDIO_PANIC,
387389
_("&Panic\tEscape"),
388-
GetImage_panic(),
390+
m_icon->GetIcon(panic),
389391
_("Panic"),
390392
wxITEM_NORMAL);
391393

src/grandorgue/icons/GOIconManager.h

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@
88
#define GOICONMANAGER_H
99

1010
#include "wx/artprov.h"
11+
#include "wxMaterialDesignArtProvider.hpp"
12+
#include "wxMaterialTwoToneArt.hpp"
1113
#include <string>
1214
#include <wx/bitmap.h>
13-
#include <wxMaterialFilledArt.hpp>
15+
#include <wx/string.h>
16+
1417
/*
1518
* This is a class to manage icons through the application
1619
* It is agnostic from any particular library
@@ -25,9 +28,32 @@ class GOIconManager {
2528
* This returns the icon in char
2629
*/
2730
wxBitmap GetIcon(std::string icon_name) {
28-
wxArtProvider::Push(new wxMaterialDesignArtProvider);
29-
wxBitmap image = wxArtProvider::GetBitmap(
30-
wxART_CLIENT_MATERIAL_TWOTONE, wxART_VOLUME_UP, wxSize(10, 10));
31+
wxString icon_id;
32+
if (icon_name == "set") {
33+
icon_id = wxART_DATA_SAVER_ON;
34+
}
35+
if (icon_name == "level") {
36+
icon_id = wxART_SETTINGS_ETHERNET;
37+
}
38+
if (icon_name == "volume") {
39+
icon_id = wxART_VOLUME_UP;
40+
}
41+
if (icon_name == "transpose") {
42+
icon_id = wxART_COMPARE_ARROWS;
43+
}
44+
if (icon_name == "reverb") {
45+
icon_id = wxART_LEAK_ADD;
46+
}
47+
if (icon_name == "polyphony") {
48+
icon_id = wxART_PIANO;
49+
}
50+
if (icon_name == "panic") {
51+
icon_id = wxART_WARNING_AMBER;
52+
}
53+
54+
// wxArtProvider::Push(new wxMaterialDesignArtProvider);
55+
wxBitmap image = wxMaterialDesignArtProvider::GetBitmap(
56+
icon_id, wxART_CLIENT_MATERIAL_SHARP, wxSize(24, 24));
3157
return image;
3258
};
3359
};

src/wxMaterial/CMakeLists.txt

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,25 @@ message(STATUS "wxMaterialDesign Art Provider configuration")
66
include(UsewxWidgets)
77
INCLUDE (CheckIncludeFileCXX)
88

9-
9+
set(wxMaterial_src
10+
${WX_MATERIAL_DESIGN_SRC_DIR}/wxAwesomeBrandsArt.cpp
11+
${WX_MATERIAL_DESIGN_SRC_DIR}/wxAwesomeRegularArt.cpp
12+
${WX_MATERIAL_DESIGN_SRC_DIR}/wxAwesomeSolidArt.cpp
13+
${WX_MATERIAL_DESIGN_SRC_DIR}/wxFluentuiFilledArt.cpp
14+
${WX_MATERIAL_DESIGN_SRC_DIR}/wxMaterialFilledArt.cpp
15+
${WX_MATERIAL_DESIGN_SRC_DIR}/wxFluentuiRegularArt.cpp
16+
${WX_MATERIAL_DESIGN_SRC_DIR}/wxMaterialDesignArtProvider.cpp
17+
${WX_MATERIAL_DESIGN_SRC_DIR}/wxMaterialOutlinedArt.cpp
18+
${WX_MATERIAL_DESIGN_SRC_DIR}/wxMaterialRoundArt.cpp
19+
${WX_MATERIAL_DESIGN_SRC_DIR}/wxMaterialSharpArt.cpp
20+
${WX_MATERIAL_DESIGN_SRC_DIR}/wxMaterialTwoToneArt.cpp
21+
${WX_MATERIAL_DESIGN_SRC_DIR}/wxSimpleIconsArt.cpp
22+
)
1023
set(wxMaterial_Source "${WX_MATERIAL_DESIGN_SRC_DIR}/wxMaterialDesignArtProvider.cpp")
1124

1225
include_directories(WX_MATERIAL_DESIGN_SRC_DIR)
1326

14-
add_library(wxMaterial STATIC ${wxMaterial_Source})
27+
add_library(wxMaterial STATIC ${wxMaterial_src})
1528
target_link_libraries(wxMaterial ${wxWidgets_LIBRARIES})
1629

1730

0 commit comments

Comments
 (0)