Set the current frame in the Jump To dialog correctly

Originally committed to SVN as r6088.
This commit is contained in:
Thomas Goyne 2011-12-22 21:23:07 +00:00
parent b66357bfb8
commit 25f4e4b426
5 changed files with 31 additions and 8 deletions

View file

@ -55,7 +55,7 @@
#include "video_context.h" #include "video_context.h"
DialogJumpTo::DialogJumpTo(agi::Context *c) 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) , c(c)
, jumpframe(c->videoController->GetFrameN()) , jumpframe(c->videoController->GetFrameN())
{ {
@ -69,7 +69,7 @@ DialogJumpTo::DialogJumpTo(agi::Context *c)
// Times // Times
wxStaticText *LabelFrame = new wxStaticText(this,-1,_("Frame: "),wxDefaultPosition,wxSize(60,20)); wxStaticText *LabelFrame = new wxStaticText(this,-1,_("Frame: "),wxDefaultPosition,wxSize(60,20));
wxStaticText *LabelTime = new wxStaticText(this,-1,_("Time: "),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()); JumpFrame->SetMaxLength(maxLength.size());
JumpTime = new TimeEdit(this, -1, c, jumptime.GetASSFormated(), wxSize(60,20)); JumpTime = new TimeEdit(this, -1, c, jumptime.GetASSFormated(), wxSize(60,20));
wxSizer *FrameSizer = new wxBoxSizer(wxHORIZONTAL); wxSizer *FrameSizer = new wxBoxSizer(wxHORIZONTAL);
@ -95,8 +95,7 @@ DialogJumpTo::DialogJumpTo(agi::Context *c)
MainSizer->Add(ButtonSizer,0,wxEXPAND | wxLEFT | wxBOTTOM | wxRIGHT,5); MainSizer->Add(ButtonSizer,0,wxEXPAND | wxLEFT | wxBOTTOM | wxRIGHT,5);
// Set sizer // Set sizer
SetSizer(MainSizer); SetSizerAndFit(MainSizer);
MainSizer->SetSizeHints(this);
CenterOnParent(); CenterOnParent();
Bind(wxEVT_COMMAND_TEXT_ENTER, &DialogJumpTo::OnOK, this); Bind(wxEVT_COMMAND_TEXT_ENTER, &DialogJumpTo::OnOK, this);

View file

@ -101,8 +101,8 @@ DialogResample::DialogResample(agi::Context *c)
wxSizer *ResSizer = new wxBoxSizer(wxHORIZONTAL); wxSizer *ResSizer = new wxBoxSizer(wxHORIZONTAL);
int sw,sh; int sw,sh;
c->ass->GetResolution(sw,sh); c->ass->GetResolution(sw,sh);
ResX = new wxTextCtrl(this,-1,"",wxDefaultPosition,wxSize(50,-1),0,NumValidator(wxString::Format("%i",sw))); ResX = new wxTextCtrl(this,-1,"",wxDefaultPosition,wxSize(50,-1),0,NumValidator(sw));
ResY = new wxTextCtrl(this,-1,"",wxDefaultPosition,wxSize(50,-1),0,NumValidator(wxString::Format("%i",sh))); ResY = new wxTextCtrl(this,-1,"",wxDefaultPosition,wxSize(50,-1),0,NumValidator(sh));
wxStaticText *ResText = new wxStaticText(this,-1,_("x")); wxStaticText *ResText = new wxStaticText(this,-1,_("x"));
wxButton *FromVideo = new wxButton(this,BUTTON_DEST_FROM_VIDEO,_("From &video")); wxButton *FromVideo = new wxButton(this,BUTTON_DEST_FROM_VIDEO,_("From &video"));
if (!c->videoController->IsLoaded()) FromVideo->Enable(false); if (!c->videoController->IsLoaded()) FromVideo->Enable(false);

View file

@ -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)) { 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) DialogStyleEditor::DialogStyleEditor(wxWindow *parent, AssStyle *style, agi::Context *c, AssStyleStorage *store, bool copy_style)

View file

@ -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) NumValidator::NumValidator(const NumValidator &from)
: wxValidator() : wxValidator()
, fValue(from.fValue) , fValue(from.fValue)

View file

@ -75,7 +75,17 @@ public:
/// @param val Initial value to set the associated control to /// @param val Initial value to set the associated control to
/// @param isfloat Allow floats, or just ints? /// @param isfloat Allow floats, or just ints?
/// @param issigned Allow negative numbers? /// @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 /// Copy constructor
NumValidator(const NumValidator& from); NumValidator(const NumValidator& from);