From 25f4e4b4263f4f0cadb8d9412506ac14aee5950e Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Thu, 22 Dec 2011 21:23:07 +0000 Subject: [PATCH] Set the current frame in the Jump To dialog correctly Originally committed to SVN as r6088. --- aegisub/src/dialog_jumpto.cpp | 7 +++---- aegisub/src/dialog_resample.cpp | 4 ++-- aegisub/src/dialog_style_editor.cpp | 2 +- aegisub/src/validators.cpp | 14 ++++++++++++++ aegisub/src/validators.h | 12 +++++++++++- 5 files changed, 31 insertions(+), 8 deletions(-) diff --git a/aegisub/src/dialog_jumpto.cpp b/aegisub/src/dialog_jumpto.cpp index 9e516663c..f4a503776 100644 --- a/aegisub/src/dialog_jumpto.cpp +++ b/aegisub/src/dialog_jumpto.cpp @@ -55,7 +55,7 @@ #include "video_context.h" DialogJumpTo::DialogJumpTo(agi::Context *c) -: wxDialog(c->parent, -1, _("Jump to"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxWANTS_CHARS , "JumpTo") +: wxDialog(c->parent, -1, _("Jump to"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxWANTS_CHARS) , c(c) , jumpframe(c->videoController->GetFrameN()) { @@ -69,7 +69,7 @@ DialogJumpTo::DialogJumpTo(agi::Context *c) // Times wxStaticText *LabelFrame = new wxStaticText(this,-1,_("Frame: "),wxDefaultPosition,wxSize(60,20)); wxStaticText *LabelTime = new wxStaticText(this,-1,_("Time: "),wxDefaultPosition,wxSize(60,20)); - JumpFrame = new wxTextCtrl(this,-1,wxString::Format("%ld",jumpframe),wxDefaultPosition,wxSize(60,20),wxTE_PROCESS_ENTER, NumValidator()); + JumpFrame = new wxTextCtrl(this,-1,"",wxDefaultPosition,wxSize(60,20),wxTE_PROCESS_ENTER, NumValidator((int)jumpframe)); JumpFrame->SetMaxLength(maxLength.size()); JumpTime = new TimeEdit(this, -1, c, jumptime.GetASSFormated(), wxSize(60,20)); wxSizer *FrameSizer = new wxBoxSizer(wxHORIZONTAL); @@ -95,8 +95,7 @@ DialogJumpTo::DialogJumpTo(agi::Context *c) MainSizer->Add(ButtonSizer,0,wxEXPAND | wxLEFT | wxBOTTOM | wxRIGHT,5); // Set sizer - SetSizer(MainSizer); - MainSizer->SetSizeHints(this); + SetSizerAndFit(MainSizer); CenterOnParent(); Bind(wxEVT_COMMAND_TEXT_ENTER, &DialogJumpTo::OnOK, this); diff --git a/aegisub/src/dialog_resample.cpp b/aegisub/src/dialog_resample.cpp index bce2a90a6..10a00cd54 100644 --- a/aegisub/src/dialog_resample.cpp +++ b/aegisub/src/dialog_resample.cpp @@ -101,8 +101,8 @@ DialogResample::DialogResample(agi::Context *c) wxSizer *ResSizer = new wxBoxSizer(wxHORIZONTAL); int sw,sh; c->ass->GetResolution(sw,sh); - ResX = new wxTextCtrl(this,-1,"",wxDefaultPosition,wxSize(50,-1),0,NumValidator(wxString::Format("%i",sw))); - ResY = new wxTextCtrl(this,-1,"",wxDefaultPosition,wxSize(50,-1),0,NumValidator(wxString::Format("%i",sh))); + ResX = new wxTextCtrl(this,-1,"",wxDefaultPosition,wxSize(50,-1),0,NumValidator(sw)); + ResY = new wxTextCtrl(this,-1,"",wxDefaultPosition,wxSize(50,-1),0,NumValidator(sh)); wxStaticText *ResText = new wxStaticText(this,-1,_("x")); wxButton *FromVideo = new wxButton(this,BUTTON_DEST_FROM_VIDEO,_("From &video")); if (!c->videoController->IsLoaded()) FromVideo->Enable(false); diff --git a/aegisub/src/dialog_style_editor.cpp b/aegisub/src/dialog_style_editor.cpp index e14be528c..fbdfe7647 100644 --- a/aegisub/src/dialog_style_editor.cpp +++ b/aegisub/src/dialog_style_editor.cpp @@ -75,7 +75,7 @@ static wxSpinCtrl *spin_ctrl(wxWindow *parent, float value, int max_value) { } static wxTextCtrl *num_text_ctrl(wxWindow *parent, double value, wxSize size = wxSize(70, 20)) { - return new wxTextCtrl(parent, -1, "", wxDefaultPosition, size, 0, NumValidator(wxString::Format("%0.3g", value), true, false)); + return new wxTextCtrl(parent, -1, "", wxDefaultPosition, size, 0, NumValidator(value)); } DialogStyleEditor::DialogStyleEditor(wxWindow *parent, AssStyle *style, agi::Context *c, AssStyleStorage *store, bool copy_style) diff --git a/aegisub/src/validators.cpp b/aegisub/src/validators.cpp index 9c9721a11..987f67b6e 100644 --- a/aegisub/src/validators.cpp +++ b/aegisub/src/validators.cpp @@ -58,6 +58,20 @@ NumValidator::NumValidator(wxString val, bool isfloat, bool issigned) } } +NumValidator::NumValidator(int val, bool issigned) +: iValue(val) +, isFloat(false) +, isSigned(issigned) +{ +} + +NumValidator::NumValidator(double val, bool issigned) +: fValue(val) +, isFloat(true) +, isSigned(issigned) +{ +} + NumValidator::NumValidator(const NumValidator &from) : wxValidator() , fValue(from.fValue) diff --git a/aegisub/src/validators.h b/aegisub/src/validators.h index 78f87b608..763ce3913 100644 --- a/aegisub/src/validators.h +++ b/aegisub/src/validators.h @@ -75,7 +75,17 @@ public: /// @param val Initial value to set the associated control to /// @param isfloat Allow floats, or just ints? /// @param issigned Allow negative numbers? - NumValidator(wxString val = "", bool isfloat=false, bool issigned=false); + explicit NumValidator(wxString val = "", bool isfloat=false, bool issigned=false); + + /// Constructor + /// @param val Initial value to set the associated control to + /// @param issigned Allow negative numbers? + explicit NumValidator(int val, bool issigned=false); + + /// Constructor + /// @param val Initial value to set the associated control to + /// @param issigned Allow negative numbers? + explicit NumValidator(double val, bool issigned=false); /// Copy constructor NumValidator(const NumValidator& from);