2006-01-16 22:02:54 +01:00
|
|
|
// Copyright (c) 2005, Rodrigo Braz Monteiro
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer in the documentation
|
|
|
|
// and/or other materials provided with the distribution.
|
|
|
|
// * Neither the name of the Aegisub Group nor the names of its contributors
|
|
|
|
// may be used to endorse or promote products derived from this software
|
|
|
|
// without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
// POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
//
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// AEGISUB
|
|
|
|
//
|
|
|
|
// Website: http://aegisub.cellosoft.com
|
|
|
|
// Contact: mailto:zeratul@cellosoft.com
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
///////////
|
|
|
|
// Headers
|
|
|
|
#include "dialog_jumpto.h"
|
|
|
|
#include "vfr.h"
|
2007-01-21 18:01:22 +01:00
|
|
|
#include "video_context.h"
|
2007-07-05 01:09:40 +02:00
|
|
|
#include "utils.h"
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
|
2007-06-23 08:07:32 +02:00
|
|
|
///////
|
|
|
|
// IDs
|
|
|
|
enum {
|
|
|
|
TEXT_JUMP_TIME = 1100,
|
|
|
|
TEXT_JUMP_FRAME
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
///////////////
|
|
|
|
// Constructor
|
2007-01-21 18:01:22 +01:00
|
|
|
DialogJumpTo::DialogJumpTo (wxWindow *parent)
|
2006-01-16 22:02:54 +01:00
|
|
|
: wxDialog(parent, -1, _("Jump to"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("JumpTo"))
|
|
|
|
{
|
2007-07-05 01:09:40 +02:00
|
|
|
// Set icon
|
|
|
|
SetIcon(BitmapToIcon(wxBITMAP(jumpto_button)));
|
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
// Set initial values
|
|
|
|
ready = false;
|
2007-01-21 07:30:19 +01:00
|
|
|
jumpframe = VideoContext::Get()->GetFrameN();
|
2006-01-16 22:02:54 +01:00
|
|
|
jumptime.SetMS(VFR_Output.GetTimeAtFrame(jumpframe));
|
|
|
|
|
|
|
|
// Times
|
|
|
|
wxStaticText *LabelFrame = new wxStaticText(this,-1,_("Frame: "),wxDefaultPosition,wxSize(60,20));
|
2007-04-08 01:50:31 +02:00
|
|
|
wxStaticText *LabelTime = new wxStaticText(this,-1,_("Time: "),wxDefaultPosition,wxSize(60,20));
|
2006-01-16 22:02:54 +01:00
|
|
|
JumpFrame = new wxTextCtrl(this,TEXT_JUMP_FRAME,wxString::Format(_T("%i"),jumpframe),wxDefaultPosition,wxSize(60,20));
|
2007-06-23 08:07:32 +02:00
|
|
|
JumpTime = new TimeEdit(this,TEXT_JUMP_TIME,jumptime.GetASSFormated(),wxDefaultPosition,wxSize(60,20));
|
2006-01-16 22:02:54 +01:00
|
|
|
wxSizer *FrameSizer = new wxBoxSizer(wxHORIZONTAL);
|
2007-04-08 01:50:31 +02:00
|
|
|
wxSizer *TimeSizer = new wxBoxSizer(wxHORIZONTAL);
|
2006-01-16 22:02:54 +01:00
|
|
|
FrameSizer->Add(LabelFrame,0,wxALIGN_CENTER_VERTICAL,0);
|
|
|
|
FrameSizer->Add(JumpFrame,1,wxLEFT,5);
|
2007-04-08 01:50:31 +02:00
|
|
|
TimeSizer->Add(LabelTime,0,wxALIGN_CENTER_VERTICAL,0);
|
|
|
|
TimeSizer->Add(JumpTime,1,wxLEFT,5);
|
2006-01-16 22:02:54 +01:00
|
|
|
wxSizer *TimesSizer = new wxStaticBoxSizer(wxVERTICAL, this, _T(""));
|
2007-04-08 01:50:31 +02:00
|
|
|
TimesSizer->Add(FrameSizer,0,wxEXPAND | wxBOTTOM,5);
|
2006-01-16 22:02:54 +01:00
|
|
|
TimesSizer->Add(TimeSizer,0,wxEXPAND,0);
|
|
|
|
|
|
|
|
// Buttons
|
|
|
|
wxButton *OKButton = new wxButton(this,wxID_OK);
|
2007-08-16 01:17:42 +02:00
|
|
|
wxButton *CancelButton = new wxButton(this,wxID_CANCEL);
|
2006-01-16 22:02:54 +01:00
|
|
|
wxSizer *ButtonSizer = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
ButtonSizer->Add(OKButton,1,wxRIGHT,5);
|
|
|
|
ButtonSizer->Add(CancelButton,0,0,0);
|
|
|
|
|
|
|
|
// General layout
|
|
|
|
wxSizer *MainSizer = new wxBoxSizer(wxVERTICAL);
|
|
|
|
MainSizer->Add(TimesSizer,0,wxEXPAND | wxLEFT | wxBOTTOM | wxRIGHT,5);
|
|
|
|
MainSizer->Add(ButtonSizer,0,wxEXPAND | wxLEFT | wxBOTTOM | wxRIGHT,5);
|
|
|
|
|
|
|
|
// Set sizer
|
|
|
|
SetSizer(MainSizer);
|
|
|
|
MainSizer->SetSizeHints(this);
|
|
|
|
CenterOnParent();
|
|
|
|
ready = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-23 08:07:32 +02:00
|
|
|
///////////////
|
|
|
|
// Event table
|
|
|
|
BEGIN_EVENT_TABLE(DialogJumpTo, wxDialog)
|
|
|
|
EVT_KEY_DOWN(DialogJumpTo::OnKey)
|
2007-06-24 21:03:42 +02:00
|
|
|
EVT_BUTTON(wxID_CANCEL,DialogJumpTo::OnCloseButton)
|
2007-06-23 08:07:32 +02:00
|
|
|
EVT_BUTTON(wxID_OK,DialogJumpTo::OnOK)
|
|
|
|
EVT_TEXT(TEXT_JUMP_TIME, DialogJumpTo::OnEditTime)
|
|
|
|
EVT_TEXT(TEXT_JUMP_FRAME, DialogJumpTo::OnEditFrame)
|
2006-01-16 22:02:54 +01:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
2007-06-23 08:07:32 +02:00
|
|
|
|
|
|
|
/////////
|
|
|
|
// Close
|
2007-06-24 21:03:42 +02:00
|
|
|
void DialogJumpTo::OnCloseButton (wxCommandEvent &event) { OnClose(false); }
|
2007-06-23 08:07:32 +02:00
|
|
|
void DialogJumpTo::OnOK (wxCommandEvent &event) { OnClose(true); }
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
|
|
|
|
//////////////////
|
|
|
|
// On Key pressed
|
|
|
|
void DialogJumpTo::OnKey(wxKeyEvent &event) {
|
|
|
|
int key = event.GetKeyCode();
|
|
|
|
if (key == WXK_RETURN) {
|
2007-01-21 07:30:19 +01:00
|
|
|
VideoContext::Get()->JumpToFrame(jumpframe);
|
2006-01-16 22:02:54 +01:00
|
|
|
EndModal(0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////
|
|
|
|
// On OK button pressed
|
|
|
|
void DialogJumpTo::OnClose(bool ok) {
|
2007-01-21 07:30:19 +01:00
|
|
|
if (ok) VideoContext::Get()->JumpToFrame(jumpframe);
|
2006-01-16 22:02:54 +01:00
|
|
|
EndModal(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////
|
|
|
|
// Time editbox changed
|
|
|
|
void DialogJumpTo::OnEditTime (wxCommandEvent &event) {
|
|
|
|
if (ready) {
|
|
|
|
ready = false;
|
|
|
|
|
|
|
|
// Update frame
|
2007-06-23 08:07:32 +02:00
|
|
|
long newframe = VFR_Output.GetFrameAtTime(JumpTime->time.GetMS());
|
2006-01-16 22:02:54 +01:00
|
|
|
if (jumpframe != newframe) {
|
|
|
|
jumpframe = newframe;
|
|
|
|
JumpFrame->SetValue(wxString::Format(_T("%i"),jumpframe));
|
|
|
|
}
|
|
|
|
|
|
|
|
ready = true;
|
|
|
|
}
|
|
|
|
else event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////
|
|
|
|
// Frame editbox changed
|
|
|
|
void DialogJumpTo::OnEditFrame (wxCommandEvent &event) {
|
|
|
|
if (ready) {
|
|
|
|
ready = false;
|
|
|
|
|
|
|
|
// Update frame
|
|
|
|
JumpFrame->GetValue().ToLong(&jumpframe);
|
|
|
|
JumpFrame->SetValue(wxString::Format(_T("%i"),jumpframe));
|
|
|
|
|
|
|
|
// Update time
|
|
|
|
int newtime = VFR_Output.GetTimeAtFrame(jumpframe);
|
|
|
|
if (jumptime.GetMS() != newtime) {
|
|
|
|
jumptime.SetMS(newtime);
|
|
|
|
JumpTime->SetValue(jumptime.GetASSFormated());
|
|
|
|
}
|
|
|
|
|
|
|
|
ready = true;
|
|
|
|
}
|
|
|
|
else event.Skip();
|
|
|
|
}
|