Port DialogJumpTo to agi::Context
Originally committed to SVN as r5255.
This commit is contained in:
parent
e8b8f876bd
commit
1f79d89e5b
3 changed files with 49 additions and 114 deletions
|
@ -277,7 +277,7 @@ struct video_jump : public Command {
|
||||||
void operator()(agi::Context *c) {
|
void operator()(agi::Context *c) {
|
||||||
c->videoController->Stop();
|
c->videoController->Stop();
|
||||||
if (c->videoController->IsLoaded()) {
|
if (c->videoController->IsLoaded()) {
|
||||||
DialogJumpTo(c->parent).ShowModal();
|
DialogJumpTo(c).ShowModal();
|
||||||
c->videoBox->videoSlider->SetFocus();
|
c->videoBox->videoSlider->SetFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,43 +45,39 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "dialog_jumpto.h"
|
#include "dialog_jumpto.h"
|
||||||
|
|
||||||
|
#include "include/aegisub/context.h"
|
||||||
|
#include "ass_time.h"
|
||||||
#include "libresrc/libresrc.h"
|
#include "libresrc/libresrc.h"
|
||||||
|
#include "timeedit_ctrl.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "video_context.h"
|
#include "video_context.h"
|
||||||
|
|
||||||
/// Event IDs
|
DialogJumpTo::DialogJumpTo(agi::Context *c)
|
||||||
enum {
|
: wxDialog(c->parent, -1, _("Jump to"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxWANTS_CHARS , "JumpTo")
|
||||||
TEXT_JUMP_TIME = 1100,
|
, c(c)
|
||||||
TEXT_JUMP_FRAME
|
, jumpframe(c->videoController->GetFrameN())
|
||||||
};
|
|
||||||
|
|
||||||
/// @brief Constructor
|
|
||||||
/// @param parent
|
|
||||||
///
|
|
||||||
DialogJumpTo::DialogJumpTo (wxWindow *parent)
|
|
||||||
: wxDialog(parent, -1, _("Jump to"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxWANTS_CHARS , _T("JumpTo"))
|
|
||||||
{
|
{
|
||||||
SetIcon(BitmapToIcon(GETIMAGE(jumpto_button_24)));
|
SetIcon(BitmapToIcon(GETIMAGE(jumpto_button_24)));
|
||||||
|
|
||||||
// Set initial values
|
// Set initial values
|
||||||
ready = false;
|
AssTime jumptime;
|
||||||
jumpframe = VideoContext::Get()->GetFrameN();
|
jumptime.SetMS(c->videoController->TimeAtFrame(jumpframe));
|
||||||
jumptime.SetMS(VideoContext::Get()->TimeAtFrame(jumpframe));
|
wxString maxLength = wxString::Format("%i",c->videoController->GetLength() - 1);
|
||||||
wxString maxLength = wxString::Format(_T("%i"),VideoContext::Get()->GetLength()-1);
|
|
||||||
|
|
||||||
// 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,TEXT_JUMP_FRAME,wxString::Format(_T("%i"),jumpframe),wxDefaultPosition,wxSize(60,20),wxTE_PROCESS_ENTER);
|
JumpFrame = new wxTextCtrl(this,-1,wxString::Format("%i",jumpframe),wxDefaultPosition,wxSize(60,20),wxTE_PROCESS_ENTER);
|
||||||
JumpFrame->SetMaxLength(maxLength.Len());
|
JumpFrame->SetMaxLength(maxLength.size());
|
||||||
JumpTime = new TimeEdit(this,TEXT_JUMP_TIME,jumptime.GetASSFormated(),wxDefaultPosition,wxSize(60,20),wxTE_PROCESS_ENTER);
|
JumpTime = new TimeEdit(this,-1,jumptime.GetASSFormated(),wxDefaultPosition,wxSize(60,20),wxTE_PROCESS_ENTER);
|
||||||
wxSizer *FrameSizer = new wxBoxSizer(wxHORIZONTAL);
|
wxSizer *FrameSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
wxSizer *TimeSizer = new wxBoxSizer(wxHORIZONTAL);
|
wxSizer *TimeSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
FrameSizer->Add(LabelFrame,0,wxALIGN_CENTER_VERTICAL,0);
|
FrameSizer->Add(LabelFrame,0,wxALIGN_CENTER_VERTICAL,0);
|
||||||
FrameSizer->Add(JumpFrame,1,wxLEFT,5);
|
FrameSizer->Add(JumpFrame,1,wxLEFT,5);
|
||||||
TimeSizer->Add(LabelTime,0,wxALIGN_CENTER_VERTICAL,0);
|
TimeSizer->Add(LabelTime,0,wxALIGN_CENTER_VERTICAL,0);
|
||||||
TimeSizer->Add(JumpTime,1,wxLEFT,5);
|
TimeSizer->Add(JumpTime,1,wxLEFT,5);
|
||||||
wxSizer *TimesSizer = new wxStaticBoxSizer(wxVERTICAL, this, _T(""));
|
wxSizer *TimesSizer = new wxStaticBoxSizer(wxVERTICAL, this, "");
|
||||||
TimesSizer->Add(FrameSizer,0,wxEXPAND | wxBOTTOM,5);
|
TimesSizer->Add(FrameSizer,0,wxEXPAND | wxBOTTOM,5);
|
||||||
TimesSizer->Add(TimeSizer,0,wxEXPAND,0);
|
TimesSizer->Add(TimeSizer,0,wxEXPAND,0);
|
||||||
|
|
||||||
|
@ -101,75 +97,34 @@ DialogJumpTo::DialogJumpTo (wxWindow *parent)
|
||||||
SetSizer(MainSizer);
|
SetSizer(MainSizer);
|
||||||
MainSizer->SetSizeHints(this);
|
MainSizer->SetSizeHints(this);
|
||||||
CenterOnParent();
|
CenterOnParent();
|
||||||
ready = true;
|
|
||||||
|
Bind(wxEVT_COMMAND_TEXT_ENTER, &DialogJumpTo::OnOK, this);
|
||||||
|
Bind(wxEVT_COMMAND_BUTTON_CLICKED, &DialogJumpTo::OnOK, this, wxID_OK);
|
||||||
|
Bind(wxEVT_COMMAND_BUTTON_CLICKED, std::tr1::bind(&DialogJumpTo::EndModal, this, 0), wxID_CANCEL);
|
||||||
|
JumpTime->Bind(wxEVT_COMMAND_TEXT_UPDATED, &DialogJumpTo::OnEditTime, this);
|
||||||
|
JumpFrame->Bind(wxEVT_COMMAND_TEXT_UPDATED, &DialogJumpTo::OnEditFrame, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(DialogJumpTo, wxDialog)
|
void DialogJumpTo::OnOK(wxCommandEvent &) {
|
||||||
EVT_TEXT_ENTER(TEXT_JUMP_FRAME,DialogJumpTo::OnKey)
|
|
||||||
EVT_TEXT_ENTER(TEXT_JUMP_TIME,DialogJumpTo::OnKey)
|
|
||||||
EVT_BUTTON(wxID_CANCEL,DialogJumpTo::OnCloseButton)
|
|
||||||
EVT_BUTTON(wxID_OK,DialogJumpTo::OnOK)
|
|
||||||
EVT_TEXT(TEXT_JUMP_TIME, DialogJumpTo::OnEditTime)
|
|
||||||
EVT_TEXT(TEXT_JUMP_FRAME, DialogJumpTo::OnEditFrame)
|
|
||||||
END_EVENT_TABLE()
|
|
||||||
|
|
||||||
void DialogJumpTo::OnCloseButton (wxCommandEvent &) { OnClose(false); }
|
|
||||||
void DialogJumpTo::OnOK (wxCommandEvent &) { OnClose(true); }
|
|
||||||
|
|
||||||
/// @brief On Key pressed
|
|
||||||
void DialogJumpTo::OnKey(wxCommandEvent &) {
|
|
||||||
EndModal(0);
|
EndModal(0);
|
||||||
if (jumpframe > VideoContext::Get()->GetLength()-1) jumpframe = VideoContext::Get()->GetLength()-1;
|
c->videoController->JumpToFrame(std::min<int>(jumpframe, c->videoController->GetLength() - 1));
|
||||||
VideoContext::Get()->JumpToFrame(jumpframe);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief On OK button pressed
|
void DialogJumpTo::OnEditTime (wxCommandEvent &) {
|
||||||
/// @param ok
|
long newframe = c->videoController->FrameAtTime(JumpTime->time.GetMS());
|
||||||
void DialogJumpTo::OnClose(bool ok) {
|
|
||||||
EndModal(0);
|
|
||||||
if (jumpframe > VideoContext::Get()->GetLength()-1) jumpframe = VideoContext::Get()->GetLength()-1;
|
|
||||||
if (ok) VideoContext::Get()->JumpToFrame(jumpframe);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @brief Time editbox changed
|
|
||||||
/// @param event
|
|
||||||
///
|
|
||||||
void DialogJumpTo::OnEditTime (wxCommandEvent &event) {
|
|
||||||
if (ready) {
|
|
||||||
ready = false;
|
|
||||||
|
|
||||||
// Update frame
|
|
||||||
long newframe = VideoContext::Get()->FrameAtTime(JumpTime->time.GetMS());
|
|
||||||
if (jumpframe != newframe) {
|
if (jumpframe != newframe) {
|
||||||
jumpframe = newframe;
|
jumpframe = newframe;
|
||||||
JumpFrame->ChangeValue(wxString::Format(_T("%i"),jumpframe));
|
JumpFrame->ChangeValue(wxString::Format("%i", jumpframe));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ready = true;
|
|
||||||
}
|
|
||||||
else event.Skip();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @brief Frame editbox changed
|
|
||||||
/// @param event
|
|
||||||
///
|
|
||||||
void DialogJumpTo::OnEditFrame (wxCommandEvent &event) {
|
void DialogJumpTo::OnEditFrame (wxCommandEvent &event) {
|
||||||
if (ready) {
|
|
||||||
ready = false;
|
|
||||||
|
|
||||||
// Update frame
|
|
||||||
JumpFrame->GetValue().ToLong(&jumpframe);
|
JumpFrame->GetValue().ToLong(&jumpframe);
|
||||||
|
JumpFrame->ChangeValue(wxString::Format("%i", jumpframe));
|
||||||
|
|
||||||
JumpFrame->SetValue(wxString::Format(_T("%i"),jumpframe));
|
int newtime = c->videoController->TimeAtFrame(jumpframe);
|
||||||
|
if (JumpTime->time.GetMS() != newtime) {
|
||||||
// Update time
|
JumpTime->time.SetMS(newtime);
|
||||||
int newtime = VideoContext::Get()->TimeAtFrame(jumpframe);
|
JumpTime->ChangeValue(JumpTime->time.GetASSFormated());
|
||||||
if (jumptime.GetMS() != newtime) {
|
|
||||||
jumptime.SetMS(newtime);
|
|
||||||
JumpTime->ChangeValue(jumptime.GetASSFormated());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ready = true;
|
|
||||||
}
|
|
||||||
else event.Skip();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,14 +34,8 @@
|
||||||
/// @ingroup secondary_ui
|
/// @ingroup secondary_ui
|
||||||
///
|
///
|
||||||
|
|
||||||
|
class TimeEdit;
|
||||||
|
namespace agi { struct Context; }
|
||||||
|
|
||||||
///////////
|
|
||||||
// Headers
|
|
||||||
#include "ass_time.h"
|
|
||||||
#include "timeedit_ctrl.h"
|
|
||||||
|
|
||||||
|
|
||||||
/// DOCME
|
/// DOCME
|
||||||
/// @class DialogJumpTo
|
/// @class DialogJumpTo
|
||||||
|
@ -49,34 +43,20 @@
|
||||||
///
|
///
|
||||||
/// DOCME
|
/// DOCME
|
||||||
class DialogJumpTo : public wxDialog {
|
class DialogJumpTo : public wxDialog {
|
||||||
private:
|
agi::Context *c; ///< Project context
|
||||||
|
long jumpframe; ///< Target frame to jump to
|
||||||
|
TimeEdit *JumpTime; ///< Target time edit control
|
||||||
|
wxTextCtrl *JumpFrame; ///< Target frame edit control
|
||||||
|
|
||||||
/// DOCME
|
/// Enter/OK button handler
|
||||||
bool ready;
|
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
long jumpframe;
|
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
AssTime jumptime;
|
|
||||||
|
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
TimeEdit *JumpTime;
|
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
wxTextCtrl *JumpFrame;
|
|
||||||
|
|
||||||
void OnKey(wxCommandEvent &event);
|
|
||||||
void OnCloseButton(wxCommandEvent &event);
|
|
||||||
void OnOK(wxCommandEvent &event);
|
void OnOK(wxCommandEvent &event);
|
||||||
|
/// Update target frame on target time changed
|
||||||
void OnEditTime(wxCommandEvent &event);
|
void OnEditTime(wxCommandEvent &event);
|
||||||
|
/// Update target time on target frame changed
|
||||||
void OnEditFrame(wxCommandEvent &event);
|
void OnEditFrame(wxCommandEvent &event);
|
||||||
void OnClose(bool ok);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DialogJumpTo (wxWindow *parent);
|
/// Constructor
|
||||||
|
/// @param c Project context
|
||||||
|
DialogJumpTo(agi::Context *c);
|
||||||
DECLARE_EVENT_TABLE()
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue