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.
|
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// Aegisub Project http://www.aegisub.org/
|
|
|
|
|
|
|
|
/// @file dialog_jumpto.cpp
|
|
|
|
/// @brief Dialogue box to enter a time to seek video to
|
|
|
|
/// @ingroup secondary_ui
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2009-01-04 07:31:48 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
#include "dialog_jumpto.h"
|
2011-01-21 05:57:28 +01:00
|
|
|
|
|
|
|
#include "include/aegisub/context.h"
|
|
|
|
#include "ass_time.h"
|
2009-09-10 15:06:40 +02:00
|
|
|
#include "libresrc/libresrc.h"
|
2011-01-21 05:57:28 +01:00
|
|
|
#include "timeedit_ctrl.h"
|
2011-12-01 01:43:48 +01:00
|
|
|
#include "validators.h"
|
2007-01-21 18:01:22 +01:00
|
|
|
#include "video_context.h"
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2013-06-13 01:14:56 +02:00
|
|
|
#include <wx/button.h>
|
|
|
|
#include <wx/sizer.h>
|
|
|
|
#include <wx/stattext.h>
|
|
|
|
#include <wx/textctrl.h>
|
|
|
|
|
2011-01-21 05:57:28 +01:00
|
|
|
DialogJumpTo::DialogJumpTo(agi::Context *c)
|
2011-12-22 22:23:07 +01:00
|
|
|
: wxDialog(c->parent, -1, _("Jump to"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxWANTS_CHARS)
|
2011-01-21 05:57:28 +01:00
|
|
|
, c(c)
|
|
|
|
, jumpframe(c->videoController->GetFrameN())
|
2006-01-16 22:02:54 +01:00
|
|
|
{
|
2012-04-03 22:40:24 +02:00
|
|
|
SetIcon(GETICON(jumpto_button_16));
|
2007-07-05 01:09:40 +02:00
|
|
|
|
2013-06-13 01:14:56 +02:00
|
|
|
auto LabelFrame = new wxStaticText(this, -1, _("Frame: "));
|
|
|
|
auto LabelTime = new wxStaticText(this, -1, _("Time: "));
|
2012-05-15 16:07:05 +02:00
|
|
|
|
2013-10-14 21:11:50 +02:00
|
|
|
JumpFrame = new wxTextCtrl(this,-1,"",wxDefaultPosition,wxSize(-1,-1),wxTE_PROCESS_ENTER, IntValidator((int)jumpframe));
|
2013-06-13 01:14:56 +02:00
|
|
|
JumpFrame->SetMaxLength(std::to_string(c->videoController->GetLength() - 1).size());
|
2012-10-12 03:52:36 +02:00
|
|
|
JumpTime = new TimeEdit(this, -1, c, AssTime(c->videoController->TimeAtFrame(jumpframe)).GetAssFormated(), wxSize(-1,-1));
|
2012-05-15 16:07:05 +02:00
|
|
|
|
2013-11-21 18:13:36 +01:00
|
|
|
auto TimesSizer = new wxGridSizer(2, 5, 5);
|
2012-05-15 16:07:05 +02:00
|
|
|
|
|
|
|
TimesSizer->Add(LabelFrame, 1, wxALIGN_CENTER_VERTICAL);
|
|
|
|
TimesSizer->Add(JumpFrame, wxEXPAND);
|
|
|
|
|
|
|
|
TimesSizer->Add(LabelTime, 1, wxALIGN_CENTER_VERTICAL);
|
|
|
|
TimesSizer->Add(JumpTime, wxEXPAND);
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2013-06-13 01:14:56 +02:00
|
|
|
auto ButtonSizer = CreateStdDialogButtonSizer(wxOK | wxCANCEL);
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
// General layout
|
2013-06-13 01:14:56 +02:00
|
|
|
auto MainSizer = new wxBoxSizer(wxVERTICAL);
|
2012-05-15 16:11:30 +02:00
|
|
|
MainSizer->Add(TimesSizer, 0, wxALL | wxALIGN_CENTER, 5);
|
2013-06-13 01:14:56 +02:00
|
|
|
MainSizer->Add(ButtonSizer, 0, wxEXPAND | wxLEFT | wxBOTTOM | wxRIGHT, 5);
|
2011-12-22 22:23:07 +01:00
|
|
|
SetSizerAndFit(MainSizer);
|
2006-01-16 22:02:54 +01:00
|
|
|
CenterOnParent();
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2012-01-17 03:47:37 +01:00
|
|
|
Bind(wxEVT_INIT_DIALOG, &DialogJumpTo::OnInitDialog, this);
|
2011-01-21 05:57:28 +01:00
|
|
|
Bind(wxEVT_COMMAND_TEXT_ENTER, &DialogJumpTo::OnOK, this);
|
|
|
|
Bind(wxEVT_COMMAND_BUTTON_CLICKED, &DialogJumpTo::OnOK, this, wxID_OK);
|
|
|
|
JumpTime->Bind(wxEVT_COMMAND_TEXT_UPDATED, &DialogJumpTo::OnEditTime, this);
|
|
|
|
JumpFrame->Bind(wxEVT_COMMAND_TEXT_UPDATED, &DialogJumpTo::OnEditFrame, this);
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
2012-01-17 03:47:37 +01:00
|
|
|
void DialogJumpTo::OnInitDialog(wxInitDialogEvent&) {
|
|
|
|
TransferDataToWindow();
|
|
|
|
UpdateWindowUI(wxUPDATE_UI_RECURSE);
|
|
|
|
|
|
|
|
// This can't simply be done in the constructor as the value hasn't been set yet
|
|
|
|
JumpFrame->SetFocus();
|
|
|
|
JumpFrame->SelectAll();
|
|
|
|
}
|
|
|
|
|
2011-01-21 05:57:28 +01:00
|
|
|
void DialogJumpTo::OnOK(wxCommandEvent &) {
|
2006-01-16 22:02:54 +01:00
|
|
|
EndModal(0);
|
2011-01-21 05:57:28 +01:00
|
|
|
c->videoController->JumpToFrame(std::min<int>(jumpframe, c->videoController->GetLength() - 1));
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
2011-01-21 05:57:28 +01:00
|
|
|
void DialogJumpTo::OnEditTime (wxCommandEvent &) {
|
2011-12-22 22:28:51 +01:00
|
|
|
long newframe = c->videoController->FrameAtTime(JumpTime->GetTime());
|
2011-01-21 05:57:28 +01:00
|
|
|
if (jumpframe != newframe) {
|
|
|
|
jumpframe = newframe;
|
2012-05-15 16:07:10 +02:00
|
|
|
JumpFrame->ChangeValue(wxString::Format("%li", jumpframe));
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DialogJumpTo::OnEditFrame (wxCommandEvent &event) {
|
2011-01-21 05:57:28 +01:00
|
|
|
JumpFrame->GetValue().ToLong(&jumpframe);
|
2011-12-22 22:28:51 +01:00
|
|
|
JumpTime->SetTime(c->videoController->TimeAtFrame(jumpframe));
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|