From 6cb1a499435bd17c5251d28afb5dcea1cedbd33e Mon Sep 17 00:00:00 2001 From: wangqr Date: Fri, 17 May 2019 03:01:31 -0400 Subject: [PATCH] Fix High DPI issue on GTK * Use icon size in the config --- src/subs_edit_box.cpp | 2 +- src/utils.cpp | 10 ++++++++-- src/visual_tool_drag.cpp | 8 +++++++- src/visual_tool_vector_clip.cpp | 8 +++++++- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/subs_edit_box.cpp b/src/subs_edit_box.cpp index 68aceca34..bd7ece76b 100644 --- a/src/subs_edit_box.cpp +++ b/src/subs_edit_box.cpp @@ -278,7 +278,7 @@ TimeEdit *SubsEditBox::MakeTimeCtrl(wxString const& tooltip, TimeField field) { void SubsEditBox::MakeButton(const char *cmd_name) { cmd::Command *command = cmd::get(cmd_name); - wxBitmapButton *btn = new wxBitmapButton(this, -1, command->Icon(16, retina_helper->GetScaleFactor())); + wxBitmapButton *btn = new wxBitmapButton(this, -1, command->Icon(OPT_GET("App/Toolbar Icon Size")->GetInt(), retina_helper->GetScaleFactor())); ToolTipManager::Bind(btn, command->StrHelp(), "Subtitle Edit Box", cmd_name); middle_right_sizer->Add(btn, wxSizerFlags().Expand()); diff --git a/src/utils.cpp b/src/utils.cpp index a014b0a29..c7118d966 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -214,9 +214,15 @@ void AddFullScreenButton(wxWindow *) { } void SetFloatOnParent(wxWindow *) { } // OS X implementation in retina_helper.mm -RetinaHelper::RetinaHelper(wxWindow *) { } +RetinaHelper::RetinaHelper(wxWindow* w) { window = w; } RetinaHelper::~RetinaHelper() { } -int RetinaHelper::GetScaleFactor() const { return 1; } +int RetinaHelper::GetScaleFactor() const { +#ifdef __WXGTK__ + return int(window->GetContentScaleFactor()); +#else + return 1; +#endif +} #endif wxString FontFace(std::string opt_prefix) { diff --git a/src/visual_tool_drag.cpp b/src/visual_tool_drag.cpp index 96212da7f..40404d12b 100644 --- a/src/visual_tool_drag.cpp +++ b/src/visual_tool_drag.cpp @@ -42,7 +42,13 @@ 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() == 16 ? GETIMAGE(name ## _16) : GETIMAGE(name ## _24)) +#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) \ +) VisualToolDrag::VisualToolDrag(VideoDisplay *parent, agi::Context *context) : VisualTool(parent, context) diff --git a/src/visual_tool_vector_clip.cpp b/src/visual_tool_vector_clip.cpp index 701937798..0b8a3eb19 100644 --- a/src/visual_tool_vector_clip.cpp +++ b/src/visual_tool_vector_clip.cpp @@ -56,7 +56,13 @@ void VisualToolVectorClip::SetToolbar(wxToolBar *toolBar) { int icon_size = OPT_GET("App/Toolbar Icon Size")->GetInt(); -#define ICON(name) icon_size == 16 ? GETIMAGE(name ## _16) : GETIMAGE(name ## _24) +#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) \ +) 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);