Skip to content
This repository has been archived by the owner on May 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #19 from petzku/master
Browse files Browse the repository at this point in the history
Fix negative margin handling
  • Loading branch information
Ristellise authored Mar 2, 2021
2 parents 3b6cb10 + a3b84c8 commit d4e6c9a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/ass_dialogue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void AssDialogue::Parse(std::string const& raw) {
Style = tkn.next_str_trim();
Actor = tkn.next_str_trim();
for (int& margin : Margin)
margin = mid(0, boost::lexical_cast<int>(tkn.next_str()), 9999);
margin = mid(-9999, boost::lexical_cast<int>(tkn.next_str()), 99999);
Effect = tkn.next_str_trim();

std::string text{tkn.next_tok().begin(), str.end()};
Expand Down
6 changes: 3 additions & 3 deletions src/ass_style.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ AssStyle::AssStyle(std::string const& str, int version) {
if (version == 0)
alignment = SsaToAss(alignment);

Margin[0] = mid(0, p.next_int(), 9999);
Margin[1] = mid(0, p.next_int(), 9999);
Margin[2] = mid(0, p.next_int(), 9999);
Margin[0] = mid(-9999, p.next_int(), 99999);
Margin[1] = mid(-9999, p.next_int(), 99999);
Margin[2] = mid(-9999, p.next_int(), 99999);

// Skip alpha level
if (version == 0)
Expand Down
2 changes: 1 addition & 1 deletion src/dialog_resample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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, wxDefaultSize, wxSP_ARROW_KEYS, -9999, 9999, 0);
margin_ctrl[i] = new wxSpinCtrl(&d, -1, "0", wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -9999, 99999, 0);
margin_ctrl[i]->SetValidator(wxGenericValidator(&settings.margin[i]));
}

Expand Down
2 changes: 1 addition & 1 deletion src/dialog_style_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ DialogStyleEditor::DialogStyleEditor(wxWindow *parent, AssStyle *style, agi::Con
for (int i = 0; i < 3; i++) {
margin[i] = new wxSpinCtrl(this, -1, std::to_wstring(style->Margin[i]),
wxDefaultPosition, wxDefaultSize,
wxSP_ARROW_KEYS, 0, 9999, style->Margin[i]);
wxSP_ARROW_KEYS, -9999, 99999, style->Margin[i]);
#if wxCHECK_VERSION(3, 1, 3)
margin[i]->SetInitialSize(margin[i]->GetSizeFromText(wxS("0000")));
#else
Expand Down
10 changes: 5 additions & 5 deletions src/subs_edit_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,18 +271,18 @@ SubsEditBox::~SubsEditBox() {
}

wxTextCtrl *SubsEditBox::MakeMarginCtrl(wxString const& tooltip, int margin, wxString const& commit_msg) {
wxTextCtrl *ctrl = new wxTextCtrl(this, -1, "", wxDefaultPosition, wxDefaultSize, wxTE_CENTRE | wxTE_PROCESS_ENTER, IntValidator());
wxTextCtrl *ctrl = new wxTextCtrl(this, -1, "", wxDefaultPosition, wxDefaultSize, wxTE_CENTRE | wxTE_PROCESS_ENTER, IntValidator(0, true));
#if wxCHECK_VERSION(3, 1, 3)
ctrl->SetInitialSize(ctrl->GetSizeFromText(wxS("0000")));
ctrl->SetInitialSize(ctrl->GetSizeFromText(wxS("00000")));
#else
ctrl->SetInitialSize(ctrl->GetSizeFromTextSize(GetTextExtent(wxS("0000"))));
ctrl->SetInitialSize(ctrl->GetSizeFromTextSize(GetTextExtent(wxS("00000"))));
#endif
ctrl->SetMaxLength(4);
ctrl->SetMaxLength(5);
ctrl->SetToolTip(tooltip);
middle_left_sizer->Add(ctrl, wxSizerFlags().Expand());

Bind(wxEVT_TEXT, [=](wxCommandEvent&) {
int value = agi::util::mid(0, atoi(ctrl->GetValue().utf8_str()), 9999);
int value = agi::util::mid(-9999, atoi(ctrl->GetValue().utf8_str()), 99999);
SetSelectedRows([&](AssDialogue *d) { d->Margin[margin] = value; },
commit_msg, AssFile::COMMIT_DIAG_META);
}, ctrl->GetId());
Expand Down

0 comments on commit d4e6c9a

Please sign in to comment.