From 74b9353038d21b091c7e0d344e042eafb6f2a592 Mon Sep 17 00:00:00 2001 From: arch1t3cht Date: Wed, 30 Nov 2022 22:40:16 +0100 Subject: [PATCH] Allow higher decimal precision in style editor Also, allow negative fsp. This doesn't change the behaviour of the SpinCtrl increment/decrement buttons, just the precision that can manually be set. Small values of fsp can be useful as a hack to disable all ligatures. Precise values of fscx/fscy can be useful to compensate for anamorphic resolutions. The other fields were made more precise for consistency. --- src/dialog_style_editor.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/dialog_style_editor.cpp b/src/dialog_style_editor.cpp index b186e5fd7..03c7629fe 100644 --- a/src/dialog_style_editor.cpp +++ b/src/dialog_style_editor.cpp @@ -149,9 +149,10 @@ DialogStyleEditor::DialogStyleEditor(wxWindow *parent, AssStyle *style, agi::Con sizer->Add(ctrl, wxSizerFlags(1).Left().Expand()); }; - auto num_text_ctrl = [&](double *value, double min, double max, double step) -> wxSpinCtrlDouble * { + auto num_text_ctrl = [&](double *value, double min, double max, double step, int precision) -> wxSpinCtrlDouble * { auto scd = new wxSpinCtrlDouble(this, -1, "", wxDefaultPosition, wxSize(75, -1), wxSP_ARROW_KEYS, min, max, *value, step); + scd->SetDigits(precision); scd->SetValidator(DoubleSpinValidator(value)); scd->Bind(wxEVT_SPINCTRLDOUBLE, [=](wxSpinDoubleEvent &evt) { evt.Skip(); @@ -186,7 +187,7 @@ DialogStyleEditor::DialogStyleEditor(wxWindow *parent, AssStyle *style, agi::Con // Create controls StyleName = new wxTextCtrl(this, -1, to_wx(style->name)); FontName = new wxComboBox(this, -1, to_wx(style->font), wxDefaultPosition, wxSize(150, -1), 0, nullptr, wxCB_DROPDOWN); - auto FontSize = num_text_ctrl(&work->fontsize, 0, 10000.0, 1.0); + auto FontSize = num_text_ctrl(&work->fontsize, 0, 10000.0, 1.0, 0); BoxBold = new wxCheckBox(this, -1, _("&Bold")); BoxItalic = new wxCheckBox(this, -1, _("&Italic")); BoxUnderline = new wxCheckBox(this, -1, _("&Underline")); @@ -203,13 +204,13 @@ DialogStyleEditor::DialogStyleEditor(wxWindow *parent, AssStyle *style, agi::Con wxSP_ARROW_KEYS, -9999, 99999, style->Margin[i]); 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); - auto Shadow = num_text_ctrl(&work->shadow_w, 0.0, 1000.0, 0.1); + auto Outline = num_text_ctrl(&work->outline_w, 0.0, 1000.0, 0.1, 2); + auto Shadow = num_text_ctrl(&work->shadow_w, 0.0, 1000.0, 0.1, 2); OutlineType = new wxCheckBox(this, -1, _("&Opaque box")); - auto ScaleX = num_text_ctrl(&work->scalex, 0.0, 10000.0, 1.0); - auto ScaleY = num_text_ctrl(&work->scaley, 0.0, 10000.0, 1.0); - auto Angle = num_text_ctrl(&work->angle, -360.0, 360.0, 1.0); - auto Spacing = num_text_ctrl(&work->spacing, 0.0, 1000.0, 0.1); + auto ScaleX = num_text_ctrl(&work->scalex, 0.0, 10000.0, 1, 2); + auto ScaleY = num_text_ctrl(&work->scaley, 0.0, 10000.0, 1, 2); + auto Angle = num_text_ctrl(&work->angle, -360.0, 360.0, 1.0, 2); + auto Spacing = num_text_ctrl(&work->spacing, -1000.0, 1000.0, 0.1, 3); Encoding = new wxComboBox(this, -1, "", wxDefaultPosition, wxDefaultSize, encodingStrings, wxCB_READONLY); // Set control tooltips