diff --git a/src/audio_karaoke.cpp b/src/audio_karaoke.cpp index 0a503ecf22..2ca0d1ecd5 100644 --- a/src/audio_karaoke.cpp +++ b/src/audio_karaoke.cpp @@ -68,7 +68,10 @@ AudioKaraoke::AudioKaraoke(wxWindow *parent, agi::Context *c) { using std::bind; -#if defined(__WXMSW__) +#if wxCHECK_VERSION(3, 1, 6) + cancel_button = new wxBitmapButton(this, -1, CMD_BITMAP_BUNDLE_GET(kara_split_cancel, wxLayout_Default, 16)); + accept_button = new wxBitmapButton(this, -1, CMD_BITMAP_BUNDLE_GET(kara_split_accept, wxLayout_Default, 16)); +#elif defined(__WXMSW__) cancel_button = new wxBitmapButton(this, -1, CMD_ICON_GET(kara_split_cancel, wxLayout_Default, FromDIP(16))); accept_button = new wxBitmapButton(this, -1, CMD_ICON_GET(kara_split_accept, wxLayout_Default, FromDIP(16))); #else diff --git a/src/command/command.h b/src/command/command.h index 6b7a3868db..0fee0e5d04 100644 --- a/src/command/command.h +++ b/src/command/command.h @@ -34,7 +34,11 @@ namespace agi { struct Context; } #define STR_DISP(a) wxString StrDisplay(const agi::Context *) const override { return _(a); } #define STR_HELP(a) wxString StrHelp() const override { return _(a); } #define CMD_TYPE(a) int Type() const override { using namespace cmd; return a; } +#if wxCHECK_VERSION(3, 1, 6) +#define CMD_ICON(icon) wxBitmapBundle Icon(wxLayoutDirection dir = wxLayout_LeftToRight) const override { return CMD_BITMAP_BUNDLE_GET(icon, dir, 16); } +#else #define CMD_ICON(icon) wxBitmap Icon(int size, wxLayoutDirection dir = wxLayout_LeftToRight) const override { return CMD_ICON_GET(icon, dir, size); } +#endif #define COMMAND_GROUP(cname, cmdname, menu, disp, help) \ struct cname final : public Command { \ @@ -101,7 +105,11 @@ DEFINE_EXCEPTION(CommandNotFound, CommandError); /// Request icon. /// @param size Icon size. +#if wxCHECK_VERSION(3, 1, 6) + virtual wxBitmapBundle Icon(wxLayoutDirection = wxLayout_LeftToRight) const { return wxBitmapBundle{}; } +#else virtual wxBitmap Icon(int size, wxLayoutDirection = wxLayout_LeftToRight) const { return wxBitmap{}; } +#endif /// Command function virtual void operator()(agi::Context *c)=0; diff --git a/src/dialog_colorpicker.cpp b/src/dialog_colorpicker.cpp index dd8f24c1e3..2f0a03479d 100644 --- a/src/dialog_colorpicker.cpp +++ b/src/dialog_colorpicker.cpp @@ -460,7 +460,11 @@ class DialogColorPicker final : public wxDialog { wxSpinCtrl *alpha_input; /// The eyedropper is set to a blank icon when it's clicked, so store its normal bitmap +#if wxCHECK_VERSION(3, 1, 6) + wxBitmapBundle eyedropper_bitmap; +#else wxBitmap eyedropper_bitmap; +#endif /// The point where the eyedropper was click, used to make it possible to either /// click the eyedropper or drag the eyedropper @@ -600,12 +604,14 @@ DialogColorPicker::DialogColorPicker(wxWindow *parent, agi::Color initial_color, preview_box = new wxStaticBitmap(this, -1, wxBitmap(40, 40, 24), wxDefaultPosition, wxSize(40, 40), STATIC_BORDER_FLAG); recent_box = new ColorPickerRecent(this, 8, 4, 16); -#if defined(__WXMSW__) +#if wxCHECK_VERSION(3, 1, 6) + eyedropper_bitmap = CMD_BITMAP_BUNDLE_GET(eyedropper_tool, wxLayout_Default, 24); +#elif defined(__WXMSW__) eyedropper_bitmap = CMD_ICON_GET(eyedropper_tool, wxLayout_Default, FromDIP(24)); #else eyedropper_bitmap = GETIMAGE(eyedropper_tool_24); #endif - eyedropper_bitmap.SetMask(new wxMask(eyedropper_bitmap, wxColour(255, 0, 255))); + // eyedropper_bitmap.SetMask(new wxMask(eyedropper_bitmap, wxColour(255, 0, 255))); #if wxCHECK_VERSION(3, 1, 0) && defined(__WXMAC__) screen_dropper_icon = new wxGenericStaticBitmap(this, -1, eyedropper_bitmap, wxDefaultPosition, wxDefaultSize, wxRAISED_BORDER); #else diff --git a/src/dialog_style_manager.cpp b/src/dialog_style_manager.cpp index 0703a381f6..51d88fe281 100644 --- a/src/dialog_style_manager.cpp +++ b/src/dialog_style_manager.cpp @@ -175,7 +175,11 @@ class DialogStyleManager final : public wxDialog { DialogStyleManager(agi::Context *context); }; +#if wxCHECK_VERSION(3, 1, 6) +wxBitmapButton* add_bitmap_button(wxWindow* parent, wxSizer* sizer, wxBitmapBundle const& img, wxString const& tooltip) { +#else wxBitmapButton *add_bitmap_button(wxWindow *parent, wxSizer *sizer, wxBitmap const& img, wxString const& tooltip) { +#endif wxBitmapButton *btn = new wxBitmapButton(parent, -1, img); btn->SetToolTip(tooltip); sizer->Add(btn, wxSizerFlags().Expand()); @@ -186,7 +190,13 @@ wxSizer *make_move_buttons(wxWindow *parent, wxButton **up, wxButton **down, wxB wxSizer *sizer = new wxBoxSizer(wxVERTICAL); sizer->AddStretchSpacer(1); -#if defined(__WXMSW__) +#if wxCHECK_VERSION(3, 1, 6) + *up = add_bitmap_button(parent, sizer, CMD_BITMAP_BUNDLE_GET(arrow_up, wxLayout_Default, 24), _("Move style up")); + *down = add_bitmap_button(parent, sizer, CMD_BITMAP_BUNDLE_GET(arrow_down, wxLayout_Default, 24), _("Move style down")); + *top = add_bitmap_button(parent, sizer, CMD_BITMAP_BUNDLE_GET(arrow_up_stop, wxLayout_Default, 24), _("Move style to top")); + *bottom = add_bitmap_button(parent, sizer, CMD_BITMAP_BUNDLE_GET(arrow_down_stop, wxLayout_Default, 24), _("Move style to bottom")); + *sort = add_bitmap_button(parent, sizer, CMD_BITMAP_BUNDLE_GET(arrow_sort, wxLayout_Default, 24), _("Sort styles alphabetically")); +#elif defined(__WXMSW__) *up = add_bitmap_button(parent, sizer, CMD_ICON_GET(arrow_up, wxLayout_Default, parent->FromDIP(24)), _("Move style up")); *down = add_bitmap_button(parent, sizer, CMD_ICON_GET(arrow_down, wxLayout_Default, parent->FromDIP(24)), _("Move style down")); *top = add_bitmap_button(parent, sizer, CMD_ICON_GET(arrow_up_stop, wxLayout_Default, parent->FromDIP(24)), _("Move style to top")); diff --git a/src/hotkey_data_view_model.cpp b/src/hotkey_data_view_model.cpp index 0c4924a824..bd5586bc05 100644 --- a/src/hotkey_data_view_model.cpp +++ b/src/hotkey_data_view_model.cpp @@ -85,6 +85,9 @@ class HotkeyModelCombo final : public HotkeyModelItem { if (col == 0) variant = to_wx(combo.Str()); else if (col == 1) { +#if wxCHECK_VERSION(3, 1, 6) + variant << wxDataViewIconText(to_wx(combo.CmdName()), cmd::get(combo.CmdName())->Icon()); +#else wxIcon icon; try { auto icon_bmp = cmd::get(combo.CmdName())->Icon(16); @@ -95,6 +98,7 @@ class HotkeyModelCombo final : public HotkeyModelItem { // Just use no icon; error is reported in the description column } variant << wxDataViewIconText(to_wx(combo.CmdName()), icon); +#endif } else if (col == 2) { try { diff --git a/src/libresrc/libresrc.h b/src/libresrc/libresrc.h index d6c066f0ac..e11f2e14bf 100644 --- a/src/libresrc/libresrc.h +++ b/src/libresrc/libresrc.h @@ -11,10 +11,13 @@ // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +#pragma once #include #include +#include + #include "bitmap.h" #include "default_config.h" @@ -33,4 +36,22 @@ wxIcon libresrc_geticon(const unsigned char *image, size_t size); (size) <= 48 ? GETIMAGEDIR(icon##_48, (dir), (size)) : GETIMAGEDIR(icon##_64, (dir), (size)) ) #define GETICON(a) libresrc_geticon(a, sizeof(a)) +#if wxCHECK_VERSION(3, 1, 6) +#include +template +wxBitmapBundle libresrc_getbitmapbundle(wxBitmap image16, wxBitmap image24, wxBitmap image32, wxBitmap image48, wxBitmap image64) { + wxVector bitmaps; + if (size <= 16) bitmaps.push_back(image16); + if (size <= 24) bitmaps.push_back(image24); + if (size <= 32) bitmaps.push_back(image32); + if (size <= 48) bitmaps.push_back(image48); + bitmaps.push_back(image64); + return wxBitmapBundle::FromBitmaps(bitmaps); +} +#define CMD_BITMAP_BUNDLE_GET(icon, dir, size) libresrc_getbitmapbundle( \ + GETIMAGEDIR(icon##_16, (dir), 16) , GETIMAGEDIR(icon##_24, (dir), 24) , \ + GETIMAGEDIR(icon##_32, (dir), 32) , GETIMAGEDIR(icon##_48, (dir), 48) , \ + GETIMAGEDIR(icon##_64, (dir), 64) ) +#endif + #define GET_DEFAULT_CONFIG(a) std::make_pair(reinterpret_cast(a), sizeof(a)) diff --git a/src/menu.cpp b/src/menu.cpp index 4f620aca03..912bb9801e 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -202,7 +202,10 @@ class CommandManager { menu_text += to_wx("\t" + hotkey::get_hotkey_str_first("Default", co->name())); wxMenuItem *item = new wxMenuItem(parent, id_base + items.size(), menu_text, co->StrHelp(), kind); -#if defined(__WXMSW__) +#if wxCHECK_VERSION(3, 1, 6) + if (kind == wxITEM_NORMAL) + item->SetBitmap(co->Icon()); +#elif defined(__WXMSW__) #if wxCHECK_VERSION(3, 1, 3) if (kind == wxITEM_NORMAL) { int size = wxRendererNative::Get().GetCheckMarkSize(context->parent).GetWidth(); diff --git a/src/subs_edit_box.cpp b/src/subs_edit_box.cpp index bc01946794..6095ae8d52 100644 --- a/src/subs_edit_box.cpp +++ b/src/subs_edit_box.cpp @@ -355,7 +355,9 @@ TimeEdit *SubsEditBox::MakeTimeCtrl(wxString const& tooltip, TimeField field) { void SubsEditBox::MakeButton(const char *cmd_name) { cmd::Command *command = cmd::get(cmd_name); -#ifdef __WXMSW__ +#if wxCHECK_VERSION(3, 1, 6) + wxBitmapButton* btn = new wxBitmapButton(this, -1, command->Icon()); +#elif defined(__WXMSW__) wxBitmapButton* btn = new wxBitmapButton(this, -1, command->Icon(FromDIP(16))); #else wxBitmapButton *btn = new wxBitmapButton(this, -1, command->Icon(OPT_GET("App/Toolbar Icon Size")->GetInt())); diff --git a/src/toggle_bitmap.cpp b/src/toggle_bitmap.cpp index 71de3ca576..b168224e72 100644 --- a/src/toggle_bitmap.cpp +++ b/src/toggle_bitmap.cpp @@ -45,10 +45,19 @@ ToggleBitmap::ToggleBitmap(wxWindow *parent, agi::Context *context, const char * : wxControl(parent, -1, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER) , context(context) , command(*cmd::get(cmd_name)) +#if wxCHECK_VERSION(3, 1, 6) +, img(command.Icon()) +#else , img(command.Icon(icon_size)) +#endif { +#if wxCHECK_VERSION(3, 1, 6) + int w = size.GetWidth() != -1 ? size.GetWidth() : img.GetPreferredLogicalSizeFor(this).GetWidth(); + int h = size.GetHeight() != -1 ? size.GetHeight() : img.GetPreferredLogicalSizeFor(this).GetWidth(); +#else int w = size.GetWidth() != -1 ? size.GetWidth() : img.GetWidth(); int h = size.GetHeight() != -1 ? size.GetHeight() : img.GetHeight(); +#endif SetClientSize(w, h); GetSize(&w, &h); SetSizeHints(w, h, w, h); @@ -81,6 +90,12 @@ void ToggleBitmap::OnPaint(wxPaintEvent &) { dc.SetBrush(wxBrush(bgColor)); dc.DrawRectangle(wxPoint(0, 0), GetClientSize()); +#if wxCHECK_VERSION(3, 1, 6) + wxBitmap bitmap = img.GetBitmapFor(this); + wxSize excess = (GetClientSize() - FromPhys(bitmap.GetSize())) / 2; + dc.DrawBitmap(bitmap, excess.GetX(), excess.GetY(), true); +#else wxSize excess = (GetClientSize() - img.GetSize()) / 2; dc.DrawBitmap(img, excess.GetX(), excess.GetY(), true); +#endif } diff --git a/src/toggle_bitmap.h b/src/toggle_bitmap.h index fec8fa3163..9a37854cd7 100644 --- a/src/toggle_bitmap.h +++ b/src/toggle_bitmap.h @@ -41,7 +41,11 @@ namespace cmd { class Command; } class ToggleBitmap final : public wxControl { agi::Context *context; cmd::Command &command; +#if wxCHECK_VERSION(3, 1, 6) + wxBitmapBundle img; +#else wxBitmap img; +#endif void OnMouseEvent(wxMouseEvent &evt); void OnPaint(wxPaintEvent &evt); diff --git a/src/toolbar.cpp b/src/toolbar.cpp index 00741d9f85..2ecb17e958 100644 --- a/src/toolbar.cpp +++ b/src/toolbar.cpp @@ -139,7 +139,11 @@ namespace { flags & cmd::COMMAND_TOGGLE ? wxITEM_CHECK : wxITEM_NORMAL; +#if wxCHECK_VERSION(3, 1, 6) + wxBitmapBundle const& bitmap = command->Icon(GetLayoutDirection()); +#else wxBitmap const& bitmap = command->Icon(icon_size, GetLayoutDirection()); +#endif AddTool(TOOL_ID_BASE + commands.size(), command->StrDisplay(context), bitmap, GetTooltip(command), kind); commands.push_back(command); @@ -171,7 +175,9 @@ namespace { , context(c) , ht_context(std::move(ht_context)) , retina_helper(parent) -#ifdef __WXMSW__ +#if wxCHECK_VERSION(3, 1, 6) + , icon_size(16) +#elif defined(__WXMSW__) , icon_size(parent->FromDIP(16)) #else , icon_size(OPT_GET("App/Toolbar Icon Size")->GetInt()) @@ -190,7 +196,9 @@ namespace { , ht_context(std::move(ht_context)) , retina_helper(parent) #ifndef __WXMAC__ -#ifdef __WXMSW__ +#if wxCHECK_VERSION(3, 1, 6) + , icon_size(16) +#elif defined(__WXMSW__) , icon_size(parent->FromDIP(16)) #else , icon_size(OPT_GET("App/Toolbar Icon Size")->GetInt()) diff --git a/src/visual_tool_drag.cpp b/src/visual_tool_drag.cpp index f2a3ea6fbd..0a5917f71e 100644 --- a/src/visual_tool_drag.cpp +++ b/src/visual_tool_drag.cpp @@ -42,7 +42,9 @@ static const DraggableFeatureType DRAG_ORIGIN = DRAG_BIG_TRIANGLE; static const DraggableFeatureType DRAG_START = DRAG_BIG_SQUARE; static const DraggableFeatureType DRAG_END = DRAG_BIG_CIRCLE; -#ifdef __WXMSW__ +#if wxCHECK_VERSION(3, 1, 6) +#define ICON(name) CMD_BITMAP_BUNDLE_GET(name, wxLayout_Default, 16) +#elif defined(__WXMSW__) #define ICON(name) CMD_ICON_GET(name, wxLayout_Default, toolbar->FromDIP(16)) #else #define ICON(name) CMD_ICON_GET(name, wxLayout_Default, OPT_GET("App/Toolbar Icon Size")->GetInt()) diff --git a/src/visual_tool_vector_clip.cpp b/src/visual_tool_vector_clip.cpp index f262561922..27a10a8fb4 100644 --- a/src/visual_tool_vector_clip.cpp +++ b/src/visual_tool_vector_clip.cpp @@ -53,13 +53,14 @@ void VisualToolVectorClip::SetToolbar(wxToolBar *toolBar) { this->toolBar = toolBar; toolBar->AddSeparator(); -#ifdef __WXMSW__ - int icon_size = toolBar->FromDIP(16); + +#if wxCHECK_VERSION(3, 1, 6) +#define ICON(name) CMD_BITMAP_BUNDLE_GET(name, wxLayout_Default, 16) +#elif defined(__WXMSW__) +#define ICON(name) CMD_ICON_GET(name, wxLayout_Default, toolbar->FromDIP(16)) #else - int icon_size = OPT_GET("App/Toolbar Icon Size")->GetInt(); +#define ICON(name) CMD_ICON_GET(name, wxLayout_Default, OPT_GET("App/Toolbar Icon Size")->GetInt()) #endif - -#define ICON(name) CMD_ICON_GET(name, wxLayout_Default, icon_size) toolBar->AddTool(BUTTON_DRAG, _("Drag"), ICON(visual_vector_clip_drag), _("Drag control points"), wxITEM_CHECK); toolBar->AddTool(BUTTON_LINE, _("Line"), ICON(visual_vector_clip_line), _("Appends a line"), wxITEM_CHECK); toolBar->AddTool(BUTTON_BICUBIC, _("Bicubic"), ICON(visual_vector_clip_bicubic), _("Appends a bezier bicubic curve"), wxITEM_CHECK);