1
0
Fork 0

Remove icon size option from Windows

Windows now always use the default size, with correct HiDPI handling
This commit is contained in:
wangqr 2020-04-09 23:49:44 -04:00
parent 55f379e229
commit c1dca9cb1f
12 changed files with 79 additions and 29 deletions

View File

@ -68,11 +68,16 @@ AudioKaraoke::AudioKaraoke(wxWindow *parent, agi::Context *c)
{
using std::bind;
#if 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
cancel_button = new wxBitmapButton(this, -1, GETIMAGE(kara_split_cancel_16));
accept_button = new wxBitmapButton(this, -1, GETIMAGE(kara_split_accept_16));
#endif
cancel_button->SetToolTip(_("Discard all uncommitted splits"));
cancel_button->Bind(wxEVT_BUTTON, bind(&AudioKaraoke::CancelSplit, this));
accept_button = new wxBitmapButton(this, -1, GETIMAGE(kara_split_accept_16));
accept_button->SetToolTip(_("Commit splits"));
accept_button->Bind(wxEVT_BUTTON, bind(&AudioKaraoke::AcceptSplit, this));

View File

@ -24,6 +24,7 @@
#include <wx/intl.h>
#include <wx/string.h>
#include "../libresrc/libresrc.h"
#include <libaegisub/exception.h>
namespace agi { struct Context; }
@ -33,14 +34,7 @@ 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; }
#define CMD_ICON(icon) wxBitmap Icon(int size, wxLayoutDirection dir = wxLayout_LeftToRight) const override { \
if (size >= 64) return GETIMAGEDIR(icon##_64, dir); \
if (size >= 48) return GETIMAGEDIR(icon##_48, dir); \
if (size >= 32) return GETIMAGEDIR(icon##_32, dir); \
if (size >= 24) return GETIMAGEDIR(icon##_24, dir); \
return GETIMAGEDIR(icon##_16, dir); \
}
#define CMD_ICON(icon) wxBitmap Icon(int size, wxLayoutDirection dir = wxLayout_LeftToRight) const override { return CMD_ICON_GET(icon, dir, size); }
#define COMMAND_GROUP(cname, cmdname, menu, disp, help) \
struct cname final : public Command { \

View File

@ -585,7 +585,11 @@ 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__)
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)));
screen_dropper_icon = new wxStaticBitmap(this, -1, eyedropper_bitmap, wxDefaultPosition, wxDefaultSize, wxRAISED_BORDER);
screen_dropper = new ColorPickerScreenDropper(this, 7, 7, 8);
@ -1054,15 +1058,19 @@ void DialogColorPicker::OnRecentSelect(ValueEvent<agi::Color> &evt) {
void DialogColorPicker::OnDropperMouse(wxMouseEvent &evt) {
if (evt.LeftDown() && !screen_dropper_icon->HasCapture()) {
Freeze();
#ifdef WIN32
screen_dropper_icon->SetCursor(wxCursor("eyedropper_cursor"));
#else
screen_dropper_icon->SetCursor(*wxCROSS_CURSOR);
#endif
wxSize size = screen_dropper_icon->GetSize();
screen_dropper_icon->SetBitmap(wxNullBitmap);
screen_dropper_icon->SetSize(size);
screen_dropper_icon->CaptureMouse();
eyedropper_grab_point = evt.GetPosition();
eyedropper_is_grabbed = false;
Thaw();
}
if (evt.LeftUp()) {

View File

@ -186,11 +186,19 @@ wxSizer *make_move_buttons(wxWindow *parent, wxButton **up, wxButton **down, wxB
wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
sizer->AddStretchSpacer(1);
#if 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"));
*bottom = add_bitmap_button(parent, sizer, CMD_ICON_GET(arrow_down_stop, wxLayout_Default, parent->FromDIP(24)), _("Move style to bottom"));
*sort = add_bitmap_button(parent, sizer, CMD_ICON_GET(arrow_sort, wxLayout_Default, parent->FromDIP(24)), _("Sort styles alphabetically"));
#else
*up = add_bitmap_button(parent, sizer, GETIMAGE(arrow_up_24), _("Move style up"));
*down = add_bitmap_button(parent, sizer, GETIMAGE(arrow_down_24), _("Move style down"));
*top = add_bitmap_button(parent, sizer, GETIMAGE(arrow_up_stop_24), _("Move style to top"));
*bottom = add_bitmap_button(parent, sizer, GETIMAGE(arrow_down_stop_24), _("Move style to bottom"));
*sort = add_bitmap_button(parent, sizer, GETIMAGE(arrow_sort_24), _("Sort styles alphabetically"));
#endif
sizer->AddStretchSpacer(1);
return sizer;

View File

@ -20,11 +20,16 @@
#include <wx/intl.h>
#include <wx/mstream.h>
wxBitmap libresrc_getimage(const unsigned char *buff, size_t size, int dir) {
wxBitmap libresrc_getimage(const unsigned char *buff, size_t size) {
wxMemoryInputStream mem(buff, size);
return wxBitmap(wxImage(mem));
}
wxBitmap libresrc_getimage_resized(const unsigned char* buff, size_t size, int dir, int resize) {
wxMemoryInputStream mem(buff, size);
if (dir != wxLayout_RightToLeft)
return wxBitmap(wxImage(mem));
return wxBitmap(wxImage(mem).Mirror());
return wxBitmap(wxImage(mem).Scale(resize, resize));
return wxBitmap(wxImage(mem).Scale(resize, resize, wxIMAGE_QUALITY_HIGH).Mirror());
}
wxIcon libresrc_geticon(const unsigned char *buff, size_t size) {

View File

@ -21,10 +21,16 @@
class wxBitmap;
class wxIcon;
wxBitmap libresrc_getimage(const unsigned char *image, size_t size, int dir=0);
wxBitmap libresrc_getimage(const unsigned char *image, size_t size);
wxBitmap libresrc_getimage_resized(const unsigned char* image, size_t size, int dir, int resize);
wxIcon libresrc_geticon(const unsigned char *image, size_t size);
#define GETIMAGE(a) libresrc_getimage(a, sizeof(a))
#define GETIMAGEDIR(a, d) libresrc_getimage(a, sizeof(a), d)
#define GETIMAGEDIR(a, d, s) libresrc_getimage_resized(a, sizeof(a), d, s)
#define CMD_ICON_GET(icon, dir, size) ( \
(size) <= 16 ? GETIMAGEDIR(icon##_16, (dir), (size)) : \
(size) <= 24 ? GETIMAGEDIR(icon##_24, (dir), (size)) : \
(size) <= 32 ? GETIMAGEDIR(icon##_32, (dir), (size)) : \
(size) <= 48 ? GETIMAGEDIR(icon##_48, (dir), (size)) : GETIMAGEDIR(icon##_64, (dir), (size)) )
#define GETICON(a) libresrc_geticon(a, sizeof(a))
#define GET_DEFAULT_CONFIG(a) std::make_pair(reinterpret_cast<const char *>(a), sizeof(a))

View File

@ -46,6 +46,10 @@
#include <wx/menu.h>
#include <wx/menuitem.h>
#if defined(__WXMSW__) && wxCHECK_VERSION(3, 1, 3)
#include <wx/renderer.h>
#endif
#ifdef __WXMAC__
#include <wx/app.h>
#endif
@ -195,7 +199,17 @@ public:
menu_text += to_wx("\t" + hotkey::get_hotkey_str_first("Default", co->name()));
wxMenuItem *item = new wxMenuItem(parent, MENU_ID_BASE + items.size(), menu_text, co->StrHelp(), kind);
#ifndef __WXMAC__
#if defined(__WXMSW__)
#if wxCHECK_VERSION(3, 1, 3)
if (kind == wxITEM_NORMAL) {
int size = wxRendererNative::Get().GetCheckMarkSize(context->parent).GetWidth();
item->SetBitmap(co->Icon(size > 0 ? size : 16));
}
#else
if (kind == wxITEM_NORMAL)
item->SetBitmap(co->Icon(context->parent->FromDIP(16)));
#endif
#elif !defined(__WXMAC__)
/// @todo Maybe make this a configuration option instead?
if (kind == wxITEM_NORMAL)
item->SetBitmap(co->Icon(16));

View File

@ -67,7 +67,9 @@ void General(wxTreebook *book, Preferences *parent) {
p->OptionAdd(general, _("Save UI state in subtitles files"), "App/Save UI State");
p->CellSkip(general);
#ifndef __WXMSW__
p->OptionAdd(general, _("Toolbar Icon Size"), "App/Toolbar Icon Size");
#endif
wxString autoload_modes[] = { _("Never"), _("Always"), _("Ask") };
wxArrayString autoload_modes_arr(3, autoload_modes);
p->OptionChoice(general, _("Automatically load linked files"), autoload_modes_arr, "App/Auto/Load Linked Files");

View File

@ -300,7 +300,11 @@ TimeEdit *SubsEditBox::MakeTimeCtrl(wxString const& tooltip, TimeField field) {
void SubsEditBox::MakeButton(const char *cmd_name) {
cmd::Command *command = cmd::get(cmd_name);
#ifdef __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()));
#endif
ToolTipManager::Bind(btn, command->StrHelp(), "Subtitle Edit Box", cmd_name);
middle_right_sizer->Add(btn, wxSizerFlags().Expand());

View File

@ -171,7 +171,11 @@ namespace {
, context(c)
, ht_context(std::move(ht_context))
, retina_helper(parent)
#ifdef __WXMSW__
, icon_size(parent->FromDIP(16))
#else
, icon_size(OPT_GET("App/Toolbar Icon Size")->GetInt())
#endif
, icon_size_slot(OPT_SUB("App/Toolbar Icon Size", &Toolbar::OnIconSizeChange, this))
, hotkeys_changed_slot(hotkey::inst->AddHotkeyChangeListener(&Toolbar::RegenerateToolbar, this))
{
@ -186,7 +190,11 @@ namespace {
, ht_context(std::move(ht_context))
, retina_helper(parent)
#ifndef __WXMAC__
#ifdef __WXMSW__
, icon_size(parent->FromDIP(16))
#else
, icon_size(OPT_GET("App/Toolbar Icon Size")->GetInt())
#endif
, icon_size_slot(OPT_SUB("App/Toolbar Icon Size", &Toolbar::OnIconSizeChange, this))
#else
, icon_size(32 * retina_helper.GetScaleFactor())

View File

@ -42,13 +42,11 @@ static const DraggableFeatureType DRAG_ORIGIN = DRAG_BIG_TRIANGLE;
static const DraggableFeatureType DRAG_START = DRAG_BIG_SQUARE;
static const DraggableFeatureType DRAG_END = DRAG_BIG_CIRCLE;
#define ICON(name) ( \
OPT_GET("App/Toolbar Icon Size")->GetInt() >= 64 ? GETIMAGE(name##_64) : \
OPT_GET("App/Toolbar Icon Size")->GetInt() >= 48 ? GETIMAGE(name##_48) : \
OPT_GET("App/Toolbar Icon Size")->GetInt() >= 32 ? GETIMAGE(name##_32) : \
OPT_GET("App/Toolbar Icon Size")->GetInt() >= 24 ? GETIMAGE(name##_24) : \
GETIMAGE(name##_16) \
)
#ifdef __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())
#endif
VisualToolDrag::VisualToolDrag(VideoDisplay *parent, agi::Context *context)
: VisualTool<VisualToolDragDraggableFeature>(parent, context)

View File

@ -52,15 +52,13 @@ VisualToolVectorClip::VisualToolVectorClip(VideoDisplay *parent, agi::Context *c
void VisualToolVectorClip::SetToolbar(wxToolBar *toolBar) {
this->toolBar = toolBar;
#ifdef __WXMSW__
int icon_size = toolBar->FromDIP(16);
#else
int icon_size = OPT_GET("App/Toolbar Icon Size")->GetInt();
#endif
#define ICON(name) ( \
icon_size >= 64 ? GETIMAGE(name##_64) : \
icon_size >= 48 ? GETIMAGE(name##_48) : \
icon_size >= 32 ? GETIMAGE(name##_32) : \
icon_size >= 24 ? GETIMAGE(name##_24) : \
GETIMAGE(name##_16) \
)
#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);