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.
This commit is contained in:
arch1t3cht 2022-11-30 22:40:16 +01:00
parent 3b7cb30e1f
commit 74b9353038
1 changed files with 9 additions and 8 deletions

View File

@ -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