From 1469f1499b4f0e1f765834cefa40eed4ff704d63 Mon Sep 17 00:00:00 2001 From: sepro <4618135+seproDev@users.noreply.github.com> Date: Fri, 19 Aug 2022 10:28:38 +0200 Subject: [PATCH 01/16] meson: apply custom manifest on windows Co-authored-by: arch1t3cht --- meson.build | 17 +++++++---------- src/res/aegisub.exe.manifest | 18 ++++++++++++++++++ tools/apply-manifest.py | 8 -------- 3 files changed, 25 insertions(+), 18 deletions(-) create mode 100644 src/res/aegisub.exe.manifest delete mode 100644 tools/apply-manifest.py diff --git a/meson.build b/meson.build index 1448c971a..767a1c6ed 100644 --- a/meson.build +++ b/meson.build @@ -337,8 +337,15 @@ subdir('tests') aegisub_cpp_pch = ['src/include/agi_pre.h'] aegisub_c_pch = ['src/include/agi_pre_c.h'] +link_args = [] +if host_machine.system() == 'windows' + manifest_file = configure_file(copy: true, input: 'src/res/aegisub.exe.manifest', output: 'aegisub.exe.manifest') + link_args += ['/MANIFEST:EMBED', '/MANIFESTINPUT:@0@'.format(manifest_file)] +endif + aegisub = executable('aegisub', aegisub_src, version_h, acconf, link_with: [libresrc, libluabins, libaegisub], + link_args: link_args, include_directories: [libaegisub_inc, libresrc_inc, version_inc, deps_inc, include_directories('src')], cpp_pch: aegisub_cpp_pch, c_pch: aegisub_c_pch, @@ -346,13 +353,3 @@ aegisub = executable('aegisub', aegisub_src, version_h, acconf, install_dir: bindir, dependencies: deps, win_subsystem: 'windows') - -if host_machine.system() == 'windows' - mt_exe = find_program('mt.exe') - apply_manifest = find_program(meson.project_source_root() / 'tools/apply-manifest.py') - custom_target('apply-manifest', - input: aegisub, - output: 'applied_manifest', - command: [apply_manifest, mt_exe, '@INPUT@'], - build_by_default: true) -endif diff --git a/src/res/aegisub.exe.manifest b/src/res/aegisub.exe.manifest new file mode 100644 index 000000000..e391b8eba --- /dev/null +++ b/src/res/aegisub.exe.manifest @@ -0,0 +1,18 @@ + + + Aegisub Subtitle Editor + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tools/apply-manifest.py b/tools/apply-manifest.py deleted file mode 100644 index 3ea84624d..000000000 --- a/tools/apply-manifest.py +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env python3 - -import sys, subprocess, pathlib, os - -mt_exe, executable = sys.argv[1:] - -subprocess.run([mt_exe, '-manifest', executable + '.manifest', '-outputresource:' + executable + ';1']) -pathlib.Path(os.path.join(os.path.dirname(executable), 'applied_manifest')).touch() From cc9d13d21a50ec7be5a80a3fc09f6ae4f1b8a542 Mon Sep 17 00:00:00 2001 From: arch1t3cht Date: Mon, 10 Oct 2022 01:17:23 +0200 Subject: [PATCH 02/16] fix --- src/res/aegisub.exe.manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/res/aegisub.exe.manifest b/src/res/aegisub.exe.manifest index e391b8eba..82c04598f 100644 --- a/src/res/aegisub.exe.manifest +++ b/src/res/aegisub.exe.manifest @@ -1,6 +1,6 @@ - Aegisub Subtitle Editor + Aegisub subtitle editor From e2ef1eb77f3fb8b4abac98b031dccf9245a44f22 Mon Sep 17 00:00:00 2001 From: sepro <4618135+seproDev@users.noreply.github.com> Date: Fri, 19 Aug 2022 10:29:43 +0200 Subject: [PATCH 03/16] windows: enable DPI awareness in manifest --- src/res/aegisub.exe.manifest | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/res/aegisub.exe.manifest b/src/res/aegisub.exe.manifest index 82c04598f..5867c4a13 100644 --- a/src/res/aegisub.exe.manifest +++ b/src/res/aegisub.exe.manifest @@ -15,4 +15,10 @@ + + + True/PM + PerMonitorV2,PerMonitor + + \ No newline at end of file From 5f3757525a088f6d11dbe57aa8bcd937023ba42b Mon Sep 17 00:00:00 2001 From: wangqr Date: Sun, 11 Nov 2018 20:37:39 -0500 Subject: [PATCH 04/16] Add DPI awareness * Removed most hard coded wxSize * Sub edit box now have DPI aware icons Co-authored-by: sepro <4618135+seproDev@users.noreply.github.com> --- src/dialog_about.cpp | 2 +- src/dialog_colorpicker.cpp | 9 +++++---- src/dialog_dummy_video.cpp | 5 +++-- src/dialog_export_ebu3264.cpp | 6 +++++- src/dialog_properties.cpp | 6 +++--- src/dialog_resample.cpp | 10 +++++----- src/dialog_style_editor.cpp | 10 ++++++---- src/export_framerate.cpp | 14 +++++++------- src/subs_edit_box.cpp | 25 ++++++++++++++----------- 9 files changed, 49 insertions(+), 38 deletions(-) diff --git a/src/dialog_about.cpp b/src/dialog_about.cpp index ebc3f8bdc..b998c9a54 100644 --- a/src/dialog_about.cpp +++ b/src/dialog_about.cpp @@ -131,7 +131,7 @@ void ShowAboutDialog(wxWindow *parent) { wxChar copySymbol = 0xA9; aboutString.Replace("(c)", wxString(copySymbol)); - wxTextCtrl *textctrl = new wxTextCtrl(&d, -1, aboutString, wxDefaultPosition, wxSize(-1, 200), wxTE_MULTILINE | wxTE_READONLY | wxBORDER_NONE); + wxTextCtrl *textctrl = new wxTextCtrl(&d, -1, aboutString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY | wxBORDER_NONE); wxSizer *MainSizer = new wxBoxSizer(wxVERTICAL); MainSizer->Add(new wxStaticBitmap(&d, -1, GETIMAGE(splash)), 0, wxCENTER, 0); diff --git a/src/dialog_colorpicker.cpp b/src/dialog_colorpicker.cpp index 510d2a6ce..45378c0ce 100644 --- a/src/dialog_colorpicker.cpp +++ b/src/dialog_colorpicker.cpp @@ -557,9 +557,10 @@ DialogColorPicker::DialogColorPicker(wxWindow *parent, agi::Color initial_color, wxString modes[] = { _("RGB/R"), _("RGB/G"), _("RGB/B"), _("HSL/L"), _("HSV/H") }; colorspace_choice = new wxChoice(this, -1, wxDefaultPosition, wxDefaultSize, 5, modes); - wxSize colorinput_size = GetTextExtent(" &H10117B& "); - colorinput_size.SetHeight(-1); - wxSize colorinput_labelsize(40, -1); + ass_input = new wxTextCtrl(this, -1); + wxSize colorinput_size = ass_input->GetSizeFromTextSize(GetTextExtent(wxS("&H10117B&"))); + ass_input->SetMinSize(colorinput_size); + ass_input->SetSize(colorinput_size); wxSizer *rgb_box = new wxStaticBoxSizer(wxHORIZONTAL, this, _("RGB color")); wxSizer *hsl_box = new wxStaticBoxSizer(wxVERTICAL, this, _("HSL color")); @@ -568,7 +569,7 @@ DialogColorPicker::DialogColorPicker(wxWindow *parent, agi::Color initial_color, for (auto& elem : rgb_input) elem = new wxSpinCtrl(this, -1, "", wxDefaultPosition, colorinput_size, wxSP_ARROW_KEYS, 0, 255); - ass_input = new wxTextCtrl(this, -1, "", wxDefaultPosition, colorinput_size); + // ass_input = new wxTextCtrl(this, -1, "", wxDefaultPosition, colorinput_size); html_input = new wxTextCtrl(this, -1, "", wxDefaultPosition, colorinput_size); alpha_input = new wxSpinCtrl(this, -1, "", wxDefaultPosition, colorinput_size, wxSP_ARROW_KEYS, 0, 255); diff --git a/src/dialog_dummy_video.cpp b/src/dialog_dummy_video.cpp index d6e61b6d6..dd00d41e4 100644 --- a/src/dialog_dummy_video.cpp +++ b/src/dialog_dummy_video.cpp @@ -80,13 +80,14 @@ static ResolutionShortcut resolutions[] = { }; wxSpinCtrl *spin_ctrl(wxWindow *parent, int min, int max, int *value) { - auto ctrl = new wxSpinCtrl(parent, -1, "", wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, min, max, *value); + auto ctrl = new wxSpinCtrl(parent, -1, "", wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, min, max, *value); ctrl->SetValidator(wxGenericValidator(value)); return ctrl; } +// FIXME: change the misleading function name, this is TextCtrl in fact wxControl *spin_ctrl(wxWindow *parent, double min, double max, double *value) { - return new wxTextCtrl(parent, -1, "", wxDefaultPosition, wxSize(50, -1), 0, DoubleValidator(value, min, max)); + return new wxTextCtrl(parent, -1, "", wxDefaultPosition, wxDefaultSize, 0, DoubleValidator(value, min, max)); } wxComboBox *resolution_shortcuts(wxWindow *parent, int width, int height) { diff --git a/src/dialog_export_ebu3264.cpp b/src/dialog_export_ebu3264.cpp index 77fb10fd3..c298c04e6 100644 --- a/src/dialog_export_ebu3264.cpp +++ b/src/dialog_export_ebu3264.cpp @@ -110,6 +110,8 @@ int ShowEbuExportConfigurationDialog(wxWindow *owner, EbuExportSettings &s) { wxRadioBox *tv_standard_box = new wxRadioBox(&d, -1, _("TV standard"), wxDefaultPosition, wxDefaultSize, 6, tv_standards, 0, wxRA_SPECIFY_ROWS); wxTextCtrl *timecode_offset_entry = new wxTextCtrl(&d, -1, "00:00:00:00"); + timecode_offset_entry->SetMinSize(timecode_offset_entry->GetSizeFromTextSize(timecode_offset_entry->GetTextExtent(wxS("00:00:00:00")))); + timecode_offset_entry->SetSize(timecode_offset_entry->GetSizeFromTextSize(timecode_offset_entry->GetTextExtent(wxS("00:00:00:00")))); wxCheckBox *inclusive_end_times_check = new wxCheckBox(&d, -1, _("Out-times are inclusive")); wxString text_encodings[] = { @@ -129,7 +131,9 @@ int ShowEbuExportConfigurationDialog(wxWindow *owner, EbuExportSettings &s) { _("Skip lines that are too long") }; - wxSpinCtrl *max_line_length_ctrl = new wxSpinCtrl(&d, -1, wxString(), wxDefaultPosition, wxSize(65, -1)); + wxSpinCtrl *max_line_length_ctrl = new wxSpinCtrl(&d, -1, wxString()); + max_line_length_ctrl->SetMinSize(max_line_length_ctrl->GetSizeFromTextSize(max_line_length_ctrl->GetTextExtent(wxS("00")))); + max_line_length_ctrl->SetSize(max_line_length_ctrl->GetSizeFromTextSize(max_line_length_ctrl->GetTextExtent(wxS("00")))); wxComboBox *wrap_mode_ctrl = new wxComboBox(&d, -1, wrap_modes[0], wxDefaultPosition, wxDefaultSize, 4, wrap_modes, wxCB_DROPDOWN | wxCB_READONLY); wxCheckBox *translate_alignments_check = new wxCheckBox(&d, -1, _("Translate alignments")); diff --git a/src/dialog_properties.cpp b/src/dialog_properties.cpp index 76d7477cd..bec1b784b 100644 --- a/src/dialog_properties.cpp +++ b/src/dialog_properties.cpp @@ -116,8 +116,8 @@ DialogProperties::DialogProperties(agi::Context *c) TopSizer->Add(TopSizerGrid,1,wxALL | wxEXPAND,0); // Resolution box - ResX = new wxTextCtrl(&d,-1,"",wxDefaultPosition,wxSize(50, -1),0,IntValidator(c->ass->GetScriptInfoAsInt("PlayResX"))); - ResY = new wxTextCtrl(&d,-1,"",wxDefaultPosition,wxSize(50, -1),0,IntValidator(c->ass->GetScriptInfoAsInt("PlayResY"))); + ResX = new wxTextCtrl(&d,-1,"",wxDefaultPosition,wxDefaultSize,0,IntValidator(c->ass->GetScriptInfoAsInt("PlayResX"))); + ResY = new wxTextCtrl(&d,-1,"",wxDefaultPosition,wxDefaultSize,0,IntValidator(c->ass->GetScriptInfoAsInt("PlayResY"))); wxButton *FromVideo = new wxButton(&d,-1,_("From &video")); if (!c->project->VideoProvider()) @@ -176,7 +176,7 @@ DialogProperties::DialogProperties(agi::Context *c) } void DialogProperties::AddProperty(wxSizer *sizer, wxString const& label, std::string const& property) { - wxTextCtrl *ctrl = new wxTextCtrl(&d, -1, to_wx(c->ass->GetScriptInfo(property)), wxDefaultPosition, wxSize(200, -1)); + wxTextCtrl *ctrl = new wxTextCtrl(&d, -1, to_wx(c->ass->GetScriptInfo(property))); sizer->Add(new wxStaticText(&d, -1, label), wxSizerFlags().Center().Left()); sizer->Add(ctrl, wxSizerFlags(1).Expand()); properties.push_back({property, ctrl}); diff --git a/src/dialog_resample.cpp b/src/dialog_resample.cpp index 2b7d40ee9..20264acc9 100644 --- a/src/dialog_resample.cpp +++ b/src/dialog_resample.cpp @@ -112,7 +112,7 @@ DialogResample::DialogResample(agi::Context *c, ResampleSettings &settings) // Create all controls and set validators for (size_t i = 0; i < 4; ++i) { - margin_ctrl[i] = new wxSpinCtrl(&d, -1, "0", wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, -9999, 9999, 0); + margin_ctrl[i] = new wxSpinCtrl(&d, -1, "0", wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -9999, 9999, 0); margin_ctrl[i]->SetValidator(wxGenericValidator(&settings.margin[i])); } @@ -122,12 +122,12 @@ DialogResample::DialogResample(agi::Context *c, ResampleSettings &settings) margin_ctrl[RIGHT]->Enable(false); margin_ctrl[BOTTOM]->Enable(false); - source_x = new wxSpinCtrl(&d, -1, "", wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, 1, INT_MAX); - source_y = new wxSpinCtrl(&d, -1, "", wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, 1, INT_MAX); + source_x = new wxSpinCtrl(&d, -1, "", wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, INT_MAX); + source_y = new wxSpinCtrl(&d, -1, "", wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, INT_MAX); source_matrix = new wxComboBox(&d, -1, "", wxDefaultPosition, wxDefaultSize, to_wx(MatrixNames()), wxCB_READONLY); - dest_x = new wxSpinCtrl(&d, -1, "", wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, 1, INT_MAX); - dest_y = new wxSpinCtrl(&d, -1, "", wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, 1, INT_MAX); + dest_x = new wxSpinCtrl(&d, -1, "", wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, INT_MAX); + dest_y = new wxSpinCtrl(&d, -1, "", wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, INT_MAX); dest_matrix = new wxComboBox(&d, -1, "", wxDefaultPosition, wxDefaultSize, to_wx(MatrixNames()), wxCB_READONLY); diff --git a/src/dialog_style_editor.cpp b/src/dialog_style_editor.cpp index b186e5fd7..fe79b6ef7 100644 --- a/src/dialog_style_editor.cpp +++ b/src/dialog_style_editor.cpp @@ -151,7 +151,7 @@ DialogStyleEditor::DialogStyleEditor(wxWindow *parent, AssStyle *style, agi::Con auto num_text_ctrl = [&](double *value, double min, double max, double step) -> wxSpinCtrlDouble * { auto scd = new wxSpinCtrlDouble(this, -1, "", wxDefaultPosition, - wxSize(75, -1), wxSP_ARROW_KEYS, min, max, *value, step); + wxDefaultSize, wxSP_ARROW_KEYS, min, max, *value, step); scd->SetValidator(DoubleSpinValidator(value)); scd->Bind(wxEVT_SPINCTRLDOUBLE, [=](wxSpinDoubleEvent &evt) { evt.Skip(); @@ -197,10 +197,12 @@ DialogStyleEditor::DialogStyleEditor(wxWindow *parent, AssStyle *style, agi::Con new ColourButton(this, wxSize(55, 16), true, style->outline, ColorValidator(&work->outline)), new ColourButton(this, wxSize(55, 16), true, style->shadow, ColorValidator(&work->shadow)) }; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { margin[i] = new wxSpinCtrl(this, -1, std::to_wstring(style->Margin[i]), - wxDefaultPosition, wxSize(60, -1), - wxSP_ARROW_KEYS, -9999, 99999, style->Margin[i]); + wxDefaultPosition, wxDefaultSize, + wxSP_ARROW_KEYS, -9999, 9999, style->Margin[i]); + margin[i]->SetInitialSize(margin[i]->GetSizeFromTextSize(GetTextExtent(wxS("0000")))); + } Alignment = new wxRadioBox(this, -1, _("Alignment"), wxDefaultPosition, wxDefaultSize, 9, alignValues, 3, wxRA_SPECIFY_COLS); auto Outline = num_text_ctrl(&work->outline_w, 0.0, 1000.0, 0.1); diff --git a/src/export_framerate.cpp b/src/export_framerate.cpp index 024489f64..f371e4c10 100644 --- a/src/export_framerate.cpp +++ b/src/export_framerate.cpp @@ -78,9 +78,9 @@ wxWindow *AssTransformFramerateFilter::GetConfigDialogWindow(wxWindow *parent, a initialInput = "23.976"; FromVideo->Enable(false); } - InputFramerate = new wxTextCtrl(base,-1,initialInput,wxDefaultPosition,wxSize(60,20)); - InputSizer->Add(InputFramerate,0,wxEXPAND | wxLEFT,5); - InputSizer->Add(FromVideo,0,wxEXPAND | wxLEFT,5); + InputFramerate = new wxTextCtrl(base,-1,initialInput); + InputSizer->Add(InputFramerate, 0, wxEXPAND); + InputSizer->Add(FromVideo, 0, wxEXPAND | wxLEFT, 5); InputSizer->AddStretchSpacer(1); // Output sizers @@ -90,7 +90,7 @@ wxWindow *AssTransformFramerateFilter::GetConfigDialogWindow(wxWindow *parent, a // Output top line RadioOutputVFR = new wxRadioButton(base,-1,_("V&ariable"),wxDefaultPosition,wxDefaultSize,wxRB_GROUP); - OutputSizerTop->Add(RadioOutputVFR,0,wxEXPAND,0); + OutputSizerTop->Add(RadioOutputVFR, wxEXPAND); // Output bottom line RadioOutputCFR = new wxRadioButton(base,-1,_("&Constant: ")); @@ -99,9 +99,9 @@ wxWindow *AssTransformFramerateFilter::GetConfigDialogWindow(wxWindow *parent, a RadioOutputVFR->Enable(false); RadioOutputCFR->SetValue(true); } - OutputFramerate = new wxTextCtrl(base,-1,initialOutput,wxDefaultPosition,wxSize(60,20)); - OutputSizerBottom->Add(RadioOutputCFR,0,wxEXPAND,0); - OutputSizerBottom->Add(OutputFramerate,0,wxEXPAND | wxLEFT,5); + OutputFramerate = new wxTextCtrl(base,-1,initialOutput); + OutputSizerBottom->Add(RadioOutputCFR, wxEXPAND); + OutputSizerBottom->Add(OutputFramerate, 0, wxEXPAND | wxLEFT, 5); OutputSizerBottom->AddStretchSpacer(1); // Reverse checkbox diff --git a/src/subs_edit_box.cpp b/src/subs_edit_box.cpp index 9c4bb1f49..68aceca34 100644 --- a/src/subs_edit_box.cpp +++ b/src/subs_edit_box.cpp @@ -124,8 +124,7 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context) style_box = MakeComboBox("Default", wxCB_READONLY, &SubsEditBox::OnStyleChange, _("Style for this line")); - style_edit_button = new wxButton(this, -1, _("Edit"), wxDefaultPosition, - wxSize(GetTextExtent(_("Edit")).GetWidth() + 20, -1)); + style_edit_button = new wxButton(this, -1, _("Edit"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); style_edit_button->Bind(wxEVT_BUTTON, [=](wxCommandEvent&) { if (active_style) { wxArrayString font_list = wxFontEnumerator::GetFacenames(); @@ -135,24 +134,26 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context) }); top_sizer->Add(style_edit_button, wxSizerFlags().Center().Border(wxRIGHT)); - actor_box = new Placeholder(this, _("Actor"), wxSize(110, -1), wxCB_DROPDOWN | wxTE_PROCESS_ENTER, _("Actor name for this speech. This is only for reference, and is mainly useless.")); + actor_box = new Placeholder(this, _("Actor"), wxDefaultSize, wxCB_DROPDOWN | wxTE_PROCESS_ENTER, _("Actor name for this speech. This is only for reference, and is mainly useless.")); Bind(wxEVT_TEXT, &SubsEditBox::OnActorChange, this, actor_box->GetId()); Bind(wxEVT_COMBOBOX, &SubsEditBox::OnActorChange, this, actor_box->GetId()); top_sizer->Add(actor_box, wxSizerFlags(2).Center().Border(wxRIGHT)); - effect_box = new Placeholder(this, _("Effect"), wxSize(80,-1), wxCB_DROPDOWN | wxTE_PROCESS_ENTER, _("Effect for this line. This can be used to store extra information for karaoke scripts, or for the effects supported by the renderer.")); + effect_box = new Placeholder(this, _("Effect"), wxDefaultSize, wxCB_DROPDOWN | wxTE_PROCESS_ENTER, _("Effect for this line. This can be used to store extra information for karaoke scripts, or for the effects supported by the renderer.")); Bind(wxEVT_TEXT, &SubsEditBox::OnEffectChange, this, effect_box->GetId()); Bind(wxEVT_COMBOBOX, &SubsEditBox::OnEffectChange, this, effect_box->GetId()); top_sizer->Add(effect_box, 3, wxALIGN_CENTER, 5); - char_count = new wxTextCtrl(this, -1, "0", wxDefaultPosition, wxSize(30, -1), wxTE_READONLY | wxTE_CENTER); + char_count = new wxTextCtrl(this, -1, "0", wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_CENTER); + char_count->SetInitialSize(char_count->GetSizeFromTextSize(GetTextExtent(wxS("000")))); char_count->SetToolTip(_("Number of characters in the longest line of this subtitle.")); top_sizer->Add(char_count, 0, wxALIGN_CENTER, 5); // Middle controls middle_left_sizer = new wxBoxSizer(wxHORIZONTAL); - layer = new wxSpinCtrl(this,-1,"",wxDefaultPosition,wxSize(50,-1), wxSP_ARROW_KEYS | wxTE_PROCESS_ENTER,0,0x7FFFFFFF,0); + layer = new wxSpinCtrl(this,-1,"",wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS | wxTE_PROCESS_ENTER,0,0x7FFFFFFF,0); + layer->SetInitialSize(layer->GetSizeFromTextSize(GetTextExtent(wxS("0")))); layer->SetToolTip(_("Layer number")); middle_left_sizer->Add(layer, wxSizerFlags().Center()); middle_left_sizer->AddSpacer(5); @@ -200,10 +201,10 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context) main_sizer->Add(middle_right_sizer,0,wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM,3); // Text editor - edit_ctrl = new SubsTextEditCtrl(this, wxSize(300,50), wxBORDER_SUNKEN, c); + edit_ctrl = new SubsTextEditCtrl(this, wxDefaultSize, wxBORDER_SUNKEN, c); edit_ctrl->Bind(wxEVT_CHAR_HOOK, &SubsEditBox::OnKeyDown, this); - secondary_editor = new wxTextCtrl(this, -1, "", wxDefaultPosition, wxSize(300,50), wxBORDER_SUNKEN | wxTE_MULTILINE | wxTE_READONLY); + secondary_editor = new wxTextCtrl(this, -1, "", wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN | wxTE_MULTILINE | wxTE_READONLY); main_sizer->Add(secondary_editor,1,wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM,3); main_sizer->Add(edit_ctrl,1,wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM,3); @@ -250,7 +251,8 @@ SubsEditBox::~SubsEditBox() { } wxTextCtrl *SubsEditBox::MakeMarginCtrl(wxString const& tooltip, int margin, wxString const& commit_msg) { - wxTextCtrl *ctrl = new wxTextCtrl(this, -1, "", wxDefaultPosition, wxSize(40,-1), wxTE_CENTRE | wxTE_PROCESS_ENTER, IntValidator(0, true)); + wxTextCtrl *ctrl = new wxTextCtrl(this, -1, "", wxDefaultPosition, wxDefaultSize, wxTE_CENTRE | wxTE_PROCESS_ENTER, IntValidator(0, true)); + ctrl->SetInitialSize(ctrl->GetSizeFromTextSize(GetTextExtent(wxS("0000")))); ctrl->SetMaxLength(5); ctrl->SetToolTip(tooltip); middle_left_sizer->Add(ctrl, wxSizerFlags().Center()); @@ -265,7 +267,8 @@ wxTextCtrl *SubsEditBox::MakeMarginCtrl(wxString const& tooltip, int margin, wxS } TimeEdit *SubsEditBox::MakeTimeCtrl(wxString const& tooltip, TimeField field) { - TimeEdit *ctrl = new TimeEdit(this, -1, c, "", wxSize(GetTextExtent(wxS(" 0:00:00.000 ")).GetWidth(),-1), field == TIME_END); + TimeEdit *ctrl = new TimeEdit(this, -1, c, "", wxDefaultSize, field == TIME_END); + ctrl->SetInitialSize(ctrl->GetSizeFromTextSize(GetTextExtent(wxS("0:00:00.000")))); ctrl->SetToolTip(tooltip); Bind(wxEVT_TEXT, [=](wxCommandEvent&) { CommitTimes(field); }, ctrl->GetId()); ctrl->Bind(wxEVT_CHAR_HOOK, time_edit_char_hook); @@ -293,7 +296,7 @@ wxButton *SubsEditBox::MakeBottomButton(const char *cmd_name) { wxComboBox *SubsEditBox::MakeComboBox(wxString const& initial_text, int style, void (SubsEditBox::*handler)(wxCommandEvent&), wxString const& tooltip) { wxString styles[] = { "Default" }; - wxComboBox *ctrl = new wxComboBox(this, -1, initial_text, wxDefaultPosition, wxSize(110,-1), 1, styles, style | wxTE_PROCESS_ENTER); + wxComboBox *ctrl = new wxComboBox(this, -1, initial_text, wxDefaultPosition, wxDefaultSize, 1, styles, style | wxTE_PROCESS_ENTER); ctrl->SetToolTip(tooltip); top_sizer->Add(ctrl, wxSizerFlags(2).Center().Border(wxRIGHT)); Bind(wxEVT_COMBOBOX, handler, this, ctrl->GetId()); From 6cb1a499435bd17c5251d28afb5dcea1cedbd33e Mon Sep 17 00:00:00 2001 From: wangqr Date: Fri, 17 May 2019 03:01:31 -0400 Subject: [PATCH 05/16] 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); From 0e0e04c94341ae4f48ed55244f9dd7bb03b06730 Mon Sep 17 00:00:00 2001 From: wangqr Date: Sun, 18 Aug 2019 22:17:08 -0400 Subject: [PATCH 06/16] Set the height of sub box back to 50px Revert the change made in ad15c53fb169e76df28edeb7fb560639d1cde11b. As a temporary solution for wangqr/Aegisub#4. --- src/subs_edit_box.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/subs_edit_box.cpp b/src/subs_edit_box.cpp index bd7ece76b..ee1625dd3 100644 --- a/src/subs_edit_box.cpp +++ b/src/subs_edit_box.cpp @@ -201,10 +201,10 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context) main_sizer->Add(middle_right_sizer,0,wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM,3); // Text editor - edit_ctrl = new SubsTextEditCtrl(this, wxDefaultSize, wxBORDER_SUNKEN, c); + edit_ctrl = new SubsTextEditCtrl(this, wxSize(-1, 50), wxBORDER_SUNKEN, c); edit_ctrl->Bind(wxEVT_CHAR_HOOK, &SubsEditBox::OnKeyDown, this); - secondary_editor = new wxTextCtrl(this, -1, "", wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN | wxTE_MULTILINE | wxTE_READONLY); + secondary_editor = new wxTextCtrl(this, -1, "", wxDefaultPosition, wxSize(-1, 50), wxBORDER_SUNKEN | wxTE_MULTILINE | wxTE_READONLY); main_sizer->Add(secondary_editor,1,wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM,3); main_sizer->Add(edit_ctrl,1,wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM,3); From af7cbb7730202d4e7f57b322f09c2610c5e3d79c Mon Sep 17 00:00:00 2001 From: wangqr Date: Sat, 24 Aug 2019 01:12:16 -0400 Subject: [PATCH 07/16] Set the height of sub box to the same as secondary_editor The secondary_editor is a wxTextCtrl, whose height is calculated from 2 rows of text. Using this height gives better consistency on screens with different DPIs, instead of using hard coded value like 50px --- src/subs_edit_box.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/subs_edit_box.cpp b/src/subs_edit_box.cpp index ee1625dd3..c042d32bf 100644 --- a/src/subs_edit_box.cpp +++ b/src/subs_edit_box.cpp @@ -201,10 +201,15 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context) main_sizer->Add(middle_right_sizer,0,wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM,3); // Text editor - edit_ctrl = new SubsTextEditCtrl(this, wxSize(-1, 50), wxBORDER_SUNKEN, c); + edit_ctrl = new SubsTextEditCtrl(this, wxDefaultSize, wxBORDER_SUNKEN, c); edit_ctrl->Bind(wxEVT_CHAR_HOOK, &SubsEditBox::OnKeyDown, this); - secondary_editor = new wxTextCtrl(this, -1, "", wxDefaultPosition, wxSize(-1, 50), wxBORDER_SUNKEN | wxTE_MULTILINE | wxTE_READONLY); + secondary_editor = new wxTextCtrl(this, -1, "", wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN | wxTE_MULTILINE | wxTE_READONLY); + // Here we use the height of secondary_editor as the initial size of edit_ctrl, + // which is more reasonable than the default given by wxWidgets. + // See: https://trac.wxwidgets.org/ticket/18471#ticket + // https://github.com/wangqr/Aegisub/issues/4 + edit_ctrl->SetInitialSize(secondary_editor->GetSize()); main_sizer->Add(secondary_editor,1,wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM,3); main_sizer->Add(edit_ctrl,1,wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM,3); From ed15252d69d33b9fb57b78144487276e2be8821e Mon Sep 17 00:00:00 2001 From: wangqr Date: Tue, 17 Sep 2019 20:12:38 -0400 Subject: [PATCH 08/16] Add workaround for wrong initial wxTextCtrl size in about dialog See https://trac.wxwidgets.org/ticket/18507 Fix wangqr/Aegisub#19 --- src/dialog_about.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/dialog_about.cpp b/src/dialog_about.cpp index b998c9a54..23c9b929b 100644 --- a/src/dialog_about.cpp +++ b/src/dialog_about.cpp @@ -132,6 +132,11 @@ void ShowAboutDialog(wxWindow *parent) { aboutString.Replace("(c)", wxString(copySymbol)); wxTextCtrl *textctrl = new wxTextCtrl(&d, -1, aboutString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY | wxBORDER_NONE); +#if defined(__WXGTK__) && !wxCHECK_VERSION(3, 1, 3) + // Workaround for https://trac.wxwidgets.org/ticket/18507 + textctrl->InvalidateBestSize(); + textctrl->SetInitialSize(); +#endif wxSizer *MainSizer = new wxBoxSizer(wxVERTICAL); MainSizer->Add(new wxStaticBitmap(&d, -1, GETIMAGE(splash)), 0, wxCENTER, 0); From 7fe4382d3861dd7737f0b0286050d88aa0e1bc84 Mon Sep 17 00:00:00 2001 From: wangqr Date: Mon, 28 Oct 2019 20:45:29 -0400 Subject: [PATCH 09/16] Remove hardcoded height of the slider Before this the slider is only partially displayed --- src/dialog_timing_processor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dialog_timing_processor.cpp b/src/dialog_timing_processor.cpp index e0b7dc00b..78fe1d878 100644 --- a/src/dialog_timing_processor.cpp +++ b/src/dialog_timing_processor.cpp @@ -197,7 +197,7 @@ DialogTimingProcessor::DialogTimingProcessor(agi::Context *c) make_ctrl(&d, adjBoxes, _("Max overlap:"), &adjOverlap, adjsEnable, _("Maximum overlap between the end and start time for two subtitles to be made continuous, in milliseconds")); - adjacentBias = new wxSlider(&d, -1, mid(0, OPT_GET("Tool/Timing Post Processor/Adjacent Bias")->GetDouble() * 100, 100), 0, 100, wxDefaultPosition, wxSize(-1,20)); + adjacentBias = new wxSlider(&d, -1, mid(0, OPT_GET("Tool/Timing Post Processor/Adjacent Bias")->GetDouble() * 100, 100), 0, 100); adjacentBias->SetToolTip(_("Sets how to set the adjoining of lines. If set totally to left, it will extend or shrink start time of the second line; if totally to right, it will extend or shrink the end time of the first line.")); auto adjSliderSizer = new wxBoxSizer(wxHORIZONTAL); From d55922d3cff3d5a940b42816eff569c32f91f1b4 Mon Sep 17 00:00:00 2001 From: wangqr Date: Thu, 21 Nov 2019 23:04:51 -0500 Subject: [PATCH 10/16] Don't shrink the size of layer SpinCtrl on GTK3 --- src/subs_edit_box.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/subs_edit_box.cpp b/src/subs_edit_box.cpp index c042d32bf..20606230e 100644 --- a/src/subs_edit_box.cpp +++ b/src/subs_edit_box.cpp @@ -153,7 +153,12 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context) middle_left_sizer = new wxBoxSizer(wxHORIZONTAL); layer = new wxSpinCtrl(this,-1,"",wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS | wxTE_PROCESS_ENTER,0,0x7FFFFFFF,0); +#ifndef __WXGTK3__ + // GTK3 has a bug that we cannot shrink the size of a widget, so do nothing there. See: + // http://gtk.10911.n7.nabble.com/gtk-widget-set-size-request-stopped-working-with-GTK3-td26274.html + // https://trac.wxwidgets.org/ticket/18568 layer->SetInitialSize(layer->GetSizeFromTextSize(GetTextExtent(wxS("0")))); +#endif layer->SetToolTip(_("Layer number")); middle_left_sizer->Add(layer, wxSizerFlags().Center()); middle_left_sizer->AddSpacer(5); From 53cc316e6f740a7d810f3b2b47990b5ff90f5aa0 Mon Sep 17 00:00:00 2001 From: wangqr Date: Tue, 10 Mar 2020 01:15:58 -0400 Subject: [PATCH 11/16] Expand layer SpinCtrl a little to compensate wxMac bug with GetSizeFromText --- src/subs_edit_box.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/subs_edit_box.cpp b/src/subs_edit_box.cpp index 20606230e..0f171cdfd 100644 --- a/src/subs_edit_box.cpp +++ b/src/subs_edit_box.cpp @@ -157,7 +157,7 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context) // GTK3 has a bug that we cannot shrink the size of a widget, so do nothing there. See: // http://gtk.10911.n7.nabble.com/gtk-widget-set-size-request-stopped-working-with-GTK3-td26274.html // https://trac.wxwidgets.org/ticket/18568 - layer->SetInitialSize(layer->GetSizeFromTextSize(GetTextExtent(wxS("0")))); + layer->SetInitialSize(layer->GetSizeFromTextSize(GetTextExtent(wxS("00")))); #endif layer->SetToolTip(_("Layer number")); middle_left_sizer->Add(layer, wxSizerFlags().Center()); From e69c4e9a8651c0e4673644e0cd61972396cb0a6a Mon Sep 17 00:00:00 2001 From: wangqr Date: Fri, 10 Apr 2020 00:24:49 -0400 Subject: [PATCH 12/16] Expand all widgets in SubsEditBox to get a consistent height --- src/subs_edit_box.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/subs_edit_box.cpp b/src/subs_edit_box.cpp index 0f171cdfd..a7c3b5ea8 100644 --- a/src/subs_edit_box.cpp +++ b/src/subs_edit_box.cpp @@ -120,7 +120,7 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context) // Only supported in wxgtk comment_box->SetCanFocus(false); #endif - top_sizer->Add(comment_box, 0, wxRIGHT | wxALIGN_CENTER, 5); + top_sizer->Add(comment_box, wxSizerFlags().Expand().Border(wxRIGHT, 5)); style_box = MakeComboBox("Default", wxCB_READONLY, &SubsEditBox::OnStyleChange, _("Style for this line")); @@ -132,22 +132,22 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context) DialogStyleEditor(this, active_style, c, nullptr, "", font_list).ShowModal(); } }); - top_sizer->Add(style_edit_button, wxSizerFlags().Center().Border(wxRIGHT)); + top_sizer->Add(style_edit_button, wxSizerFlags().Expand().Border(wxRIGHT)); actor_box = new Placeholder(this, _("Actor"), wxDefaultSize, wxCB_DROPDOWN | wxTE_PROCESS_ENTER, _("Actor name for this speech. This is only for reference, and is mainly useless.")); Bind(wxEVT_TEXT, &SubsEditBox::OnActorChange, this, actor_box->GetId()); Bind(wxEVT_COMBOBOX, &SubsEditBox::OnActorChange, this, actor_box->GetId()); - top_sizer->Add(actor_box, wxSizerFlags(2).Center().Border(wxRIGHT)); + top_sizer->Add(actor_box, wxSizerFlags(2).Expand().Border(wxRIGHT)); effect_box = new Placeholder(this, _("Effect"), wxDefaultSize, wxCB_DROPDOWN | wxTE_PROCESS_ENTER, _("Effect for this line. This can be used to store extra information for karaoke scripts, or for the effects supported by the renderer.")); Bind(wxEVT_TEXT, &SubsEditBox::OnEffectChange, this, effect_box->GetId()); Bind(wxEVT_COMBOBOX, &SubsEditBox::OnEffectChange, this, effect_box->GetId()); - top_sizer->Add(effect_box, 3, wxALIGN_CENTER, 5); + top_sizer->Add(effect_box, wxSizerFlags(3).Expand()); char_count = new wxTextCtrl(this, -1, "0", wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_CENTER); char_count->SetInitialSize(char_count->GetSizeFromTextSize(GetTextExtent(wxS("000")))); char_count->SetToolTip(_("Number of characters in the longest line of this subtitle.")); - top_sizer->Add(char_count, 0, wxALIGN_CENTER, 5); + top_sizer->Add(char_count, wxSizerFlags().Expand()); // Middle controls middle_left_sizer = new wxBoxSizer(wxHORIZONTAL); @@ -160,7 +160,7 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context) layer->SetInitialSize(layer->GetSizeFromTextSize(GetTextExtent(wxS("00")))); #endif layer->SetToolTip(_("Layer number")); - middle_left_sizer->Add(layer, wxSizerFlags().Center()); + middle_left_sizer->Add(layer, wxSizerFlags().Expand()); middle_left_sizer->AddSpacer(5); start_time = MakeTimeCtrl(_("Start time"), TIME_START); @@ -197,13 +197,13 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context) split_box = new wxCheckBox(this,-1,_("Show Original")); split_box->SetToolTip(_("Show the contents of the subtitle line when it was first selected above the edit box. This is sometimes useful when editing subtitles or translating subtitles into another language.")); split_box->Bind(wxEVT_CHECKBOX, &SubsEditBox::OnSplit, this); - middle_right_sizer->Add(split_box, wxSizerFlags().Center().Left()); + middle_right_sizer->Add(split_box, wxSizerFlags().Expand()); // Main sizer wxSizer *main_sizer = new wxBoxSizer(wxVERTICAL); - main_sizer->Add(top_sizer,0,wxEXPAND | wxALL,3); - main_sizer->Add(middle_left_sizer,0,wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM,3); - main_sizer->Add(middle_right_sizer,0,wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM,3); + main_sizer->Add(top_sizer, wxSizerFlags().Expand().Border(wxALL, 3)); + main_sizer->Add(middle_left_sizer, wxSizerFlags().Expand().Border(wxLEFT | wxRIGHT | wxBOTTOM, 3)); + main_sizer->Add(middle_right_sizer, wxSizerFlags().Expand().Border(wxLEFT | wxRIGHT | wxBOTTOM, 3)); // Text editor edit_ctrl = new SubsTextEditCtrl(this, wxDefaultSize, wxBORDER_SUNKEN, c); @@ -216,8 +216,8 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context) // https://github.com/wangqr/Aegisub/issues/4 edit_ctrl->SetInitialSize(secondary_editor->GetSize()); - main_sizer->Add(secondary_editor,1,wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM,3); - main_sizer->Add(edit_ctrl,1,wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM,3); + main_sizer->Add(secondary_editor, wxSizerFlags(1).Expand().Border(wxLEFT | wxRIGHT | wxBOTTOM, 3)); + main_sizer->Add(edit_ctrl, wxSizerFlags(1).Expand().Border(wxLEFT | wxRIGHT | wxBOTTOM, 3)); main_sizer->Hide(secondary_editor); bottom_sizer = new wxBoxSizer(wxHORIZONTAL); @@ -265,7 +265,7 @@ wxTextCtrl *SubsEditBox::MakeMarginCtrl(wxString const& tooltip, int margin, wxS ctrl->SetInitialSize(ctrl->GetSizeFromTextSize(GetTextExtent(wxS("0000")))); ctrl->SetMaxLength(5); ctrl->SetToolTip(tooltip); - middle_left_sizer->Add(ctrl, wxSizerFlags().Center()); + middle_left_sizer->Add(ctrl, wxSizerFlags().Expand()); Bind(wxEVT_TEXT, [=](wxCommandEvent&) { int value = agi::util::mid(-9999, atoi(ctrl->GetValue().utf8_str()), 99999); @@ -282,7 +282,7 @@ TimeEdit *SubsEditBox::MakeTimeCtrl(wxString const& tooltip, TimeField field) { ctrl->SetToolTip(tooltip); Bind(wxEVT_TEXT, [=](wxCommandEvent&) { CommitTimes(field); }, ctrl->GetId()); ctrl->Bind(wxEVT_CHAR_HOOK, time_edit_char_hook); - middle_left_sizer->Add(ctrl, wxSizerFlags().Center()); + middle_left_sizer->Add(ctrl, wxSizerFlags().Expand()); return ctrl; } @@ -308,7 +308,7 @@ wxComboBox *SubsEditBox::MakeComboBox(wxString const& initial_text, int style, v wxString styles[] = { "Default" }; wxComboBox *ctrl = new wxComboBox(this, -1, initial_text, wxDefaultPosition, wxDefaultSize, 1, styles, style | wxTE_PROCESS_ENTER); ctrl->SetToolTip(tooltip); - top_sizer->Add(ctrl, wxSizerFlags(2).Center().Border(wxRIGHT)); + top_sizer->Add(ctrl, wxSizerFlags(2).Expand().Border(wxRIGHT)); Bind(wxEVT_COMBOBOX, handler, this, ctrl->GetId()); return ctrl; } From 049c1c08d106dd8217a6673e2d96c2da22ca28bb Mon Sep 17 00:00:00 2001 From: IbarakiKasen Date: Sun, 3 Jul 2022 13:15:45 -0400 Subject: [PATCH 13/16] Fix wxFlexGridSizer flex grow Fix wangqr/Aegisub#143 --- src/dialog_shift_times.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/dialog_shift_times.cpp b/src/dialog_shift_times.cpp index 268e307ea..07dbed59a 100644 --- a/src/dialog_shift_times.cpp +++ b/src/dialog_shift_times.cpp @@ -190,11 +190,12 @@ DialogShiftTimes::DialogShiftTimes(agi::Context *context) shift_frames->Disable(); // Position controls - wxSizer *shift_amount_sizer = new wxFlexGridSizer(2, 2, 5, 5); + wxFlexGridSizer* shift_amount_sizer = new wxFlexGridSizer(2, 2, 5, 5); + shift_amount_sizer->AddGrowableCol(1, 1); shift_amount_sizer->Add(shift_by_time, wxSizerFlags(0).Align(wxALIGN_CENTER_VERTICAL)); - shift_amount_sizer->Add(shift_time, wxSizerFlags(1)); + shift_amount_sizer->Add(shift_time, wxSizerFlags().Expand()); shift_amount_sizer->Add(shift_by_frames, wxSizerFlags(0).Align(wxALIGN_CENTER_VERTICAL)); - shift_amount_sizer->Add(shift_frames, wxSizerFlags(1)); + shift_amount_sizer->Add(shift_frames, wxSizerFlags().Expand()); wxSizer *shift_direction_sizer = new wxBoxSizer(wxHORIZONTAL); shift_direction_sizer->Add(shift_forward, wxSizerFlags(1).Expand()); From 17831ca0f4caa1ce57653ff9b154b5d5f620aaaf Mon Sep 17 00:00:00 2001 From: arch1t3cht Date: Tue, 11 Oct 2022 15:15:40 +0200 Subject: [PATCH 14/16] video zoom: Fix visual tools with DPI scaling --- src/video_display.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/video_display.cpp b/src/video_display.cpp index f4d899847..3d91f5fcf 100644 --- a/src/video_display.cpp +++ b/src/video_display.cpp @@ -197,11 +197,11 @@ void VideoDisplay::Render() try { int client_w, client_h; GetClientSize(&client_w, &client_h); - E(glViewport(0, 0, client_w, client_h)); + E(glViewport(0, 0, client_w * scale_factor, client_h * scale_factor)); E(glMatrixMode(GL_PROJECTION)); E(glLoadIdentity()); - E(glOrtho(0.0f, client_w / scale_factor, client_h / scale_factor, 0.0f, -1000.0f, 1000.0f)); + E(glOrtho(0.0f, client_w, client_h, 0.0f, -1000.0f, 1000.0f)); if (OPT_GET("Video/Overscan Mask")->GetBool()) { double ar = con->videoController->GetAspectRatioValue(); From 0e89f32cfbf7f891402e57f13a1996b41d47e91f Mon Sep 17 00:00:00 2001 From: arch1t3cht Date: Tue, 11 Oct 2022 18:31:46 +0200 Subject: [PATCH 15/16] video zoom: Fix detached video with DPI scaling --- src/video_display.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/video_display.cpp b/src/video_display.cpp index 3d91f5fcf..c941f7294 100644 --- a/src/video_display.cpp +++ b/src/video_display.cpp @@ -276,9 +276,11 @@ void VideoDisplay::PositionVideo() { int client_w, client_h; GetClientSize(&client_w, &client_h); + client_w *= scale_factor; + client_h *= scale_factor; viewport_left = 0; - viewport_bottom = client_h * scale_factor - videoSize.GetHeight(); + viewport_bottom = client_h - videoSize.GetHeight(); viewport_top = 0; viewport_width = videoSize.GetWidth(); viewport_height = videoSize.GetHeight(); @@ -311,7 +313,7 @@ void VideoDisplay::PositionVideo() { viewport_bottom -= pan_y; if (tool) { - tool->SetClientSize(client_w * scale_factor, client_h * scale_factor); + tool->SetClientSize(client_w, client_h); tool->SetDisplayArea(viewport_left / scale_factor, viewport_top / scale_factor, viewport_width / scale_factor, viewport_height / scale_factor); } @@ -358,7 +360,7 @@ void VideoDisplay::OnSizeEvent(wxSizeEvent &event) { /* If the video is moving, we only need to update the size in this case */ else if (videoSize.GetWidth() == 0 && videoSize.GetHeight() == 0) videoSize = GetClientSize() * videoZoomValue * scale_factor; - windowZoomValue = double(GetClientSize().GetHeight()) / con->project->VideoProvider()->GetHeight(); + windowZoomValue = double(GetClientSize().GetHeight() * scale_factor) / con->project->VideoProvider()->GetHeight(); zoomBox->ChangeValue(fmt_wx("%g%%", windowZoomValue * 100.)); con->ass->Properties.video_zoom = windowZoomValue; UpdateSize(); From b38493ee68eb9c3a6e80af71d6ec499e21b25786 Mon Sep 17 00:00:00 2001 From: arch1t3cht Date: Tue, 11 Oct 2022 18:54:55 +0200 Subject: [PATCH 16/16] video zoom: Fix crash on windows when making detached video too small --- src/video_display.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video_display.cpp b/src/video_display.cpp index c941f7294..8361d1c6f 100644 --- a/src/video_display.cpp +++ b/src/video_display.cpp @@ -360,7 +360,7 @@ void VideoDisplay::OnSizeEvent(wxSizeEvent &event) { /* If the video is moving, we only need to update the size in this case */ else if (videoSize.GetWidth() == 0 && videoSize.GetHeight() == 0) videoSize = GetClientSize() * videoZoomValue * scale_factor; - windowZoomValue = double(GetClientSize().GetHeight() * scale_factor) / con->project->VideoProvider()->GetHeight(); + windowZoomValue = double(std::max(GetClientSize().GetHeight(), 1) * scale_factor) / con->project->VideoProvider()->GetHeight(); zoomBox->ChangeValue(fmt_wx("%g%%", windowZoomValue * 100.)); con->ass->Properties.video_zoom = windowZoomValue; UpdateSize();