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/
|
2006-01-16 22:02:54 +01:00
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// $Id$
|
|
|
|
|
|
|
|
/// @file video_slider.cpp
|
|
|
|
/// @brief Seek-bar control for video
|
|
|
|
/// @ingroup custom_control
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
|
|
|
|
////////////
|
|
|
|
// Includes
|
2009-01-04 07:31:48 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
2009-09-10 15:06:40 +02:00
|
|
|
#ifndef AGI_PRE
|
2006-01-16 22:02:54 +01:00
|
|
|
#include <wx/settings.h>
|
2009-09-10 15:06:40 +02:00
|
|
|
#endif
|
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
#include "ass_dialogue.h"
|
|
|
|
#include "options.h"
|
2009-09-10 15:06:40 +02:00
|
|
|
#include "subs_edit_box.h"
|
|
|
|
#include "subs_grid.h"
|
2006-02-20 23:15:34 +01:00
|
|
|
#include "utils.h"
|
2009-09-10 15:06:40 +02:00
|
|
|
#include "vfr.h"
|
|
|
|
#include "video_context.h"
|
|
|
|
#include "video_display.h"
|
|
|
|
#include "video_slider.h"
|
2006-01-16 22:02:54 +01:00
|
|
|
|
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
|
|
|
|
|
|
|
/// @brief Constructor
|
|
|
|
/// @param parent
|
|
|
|
/// @param id
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
VideoSlider::VideoSlider (wxWindow* parent, wxWindowID id)
|
2006-01-20 23:56:15 +01:00
|
|
|
: wxWindow (parent,id,wxDefaultPosition,wxDefaultSize,wxWANTS_CHARS | wxFULL_REPAINT_ON_RESIZE)
|
2006-01-16 22:02:54 +01:00
|
|
|
{
|
2008-11-25 03:07:07 +01:00
|
|
|
val = 0;
|
|
|
|
min = 0;
|
|
|
|
max = 1;
|
2006-01-16 22:02:54 +01:00
|
|
|
Display = NULL;
|
|
|
|
SetClientSize(20,25);
|
|
|
|
locked = false;
|
2006-02-19 15:19:26 +01:00
|
|
|
SetRange(0,1);
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
/// @brief Get value
|
|
|
|
/// @return
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
int VideoSlider::GetValue() {
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
/// @brief Set value
|
|
|
|
/// @param value
|
|
|
|
/// @return
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
void VideoSlider::SetValue(int value) {
|
|
|
|
if (locked) return;
|
|
|
|
val = value;
|
|
|
|
if (val < min) val = min;
|
|
|
|
if (val > max) val = max;
|
|
|
|
Refresh(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
/// @brief Set range
|
|
|
|
/// @param from
|
|
|
|
/// @param to
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
void VideoSlider::SetRange(int from,int to) {
|
2007-01-21 07:30:19 +01:00
|
|
|
if (from > to) from = to;
|
2006-01-16 22:02:54 +01:00
|
|
|
locked = false;
|
|
|
|
min = from;
|
|
|
|
max = to;
|
2007-01-21 07:30:19 +01:00
|
|
|
if (val < from) val = from;
|
|
|
|
if (val > to) val = to;
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
/// @brief Get value at X
|
|
|
|
/// @param x
|
|
|
|
/// @return
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
int VideoSlider::GetValueAtX(int x) {
|
|
|
|
// Get dimensions
|
|
|
|
int w,h;
|
|
|
|
GetClientSize(&w,&h);
|
|
|
|
|
|
|
|
// Special case
|
|
|
|
if (w <= 10) return 0;
|
|
|
|
|
|
|
|
// Calculate
|
2007-08-31 16:11:35 +02:00
|
|
|
return (int64_t)(x-5)*(int64_t)(max-min)/(int64_t)(w-10)+min;
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
/// @brief Get X at value
|
|
|
|
/// @param value
|
|
|
|
/// @return
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
int VideoSlider::GetXAtValue(int value) {
|
|
|
|
// Get dimensions
|
|
|
|
int w,h;
|
|
|
|
GetClientSize(&w,&h);
|
|
|
|
|
|
|
|
// Special case
|
|
|
|
if (max-min <= 0) return 0;
|
|
|
|
|
|
|
|
// Calculate
|
2007-08-31 16:11:35 +02:00
|
|
|
return (int64_t)(value-min)*(int64_t)(w-10)/(int64_t)(max-min)+5;
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
/// @brief Next frame hotkey
|
|
|
|
/// @return
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
void VideoSlider::NextFrame() {
|
2007-01-21 07:30:19 +01:00
|
|
|
if (VideoContext::Get()->IsPlaying()) return;
|
2006-02-19 15:28:03 +01:00
|
|
|
|
|
|
|
//don't request out of range frames
|
2007-01-21 07:30:19 +01:00
|
|
|
if (GetValue() < max) VideoContext::Get()->JumpToFrame(GetValue()+1);
|
|
|
|
Refresh(false);
|
|
|
|
Update();
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
/// @brief Previous frame hotkey
|
|
|
|
/// @return
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
void VideoSlider::PrevFrame() {
|
2007-01-21 07:30:19 +01:00
|
|
|
if (VideoContext::Get()->IsPlaying()) return;
|
2006-02-19 15:28:03 +01:00
|
|
|
|
|
|
|
//don't request out of range frames
|
2007-01-21 07:30:19 +01:00
|
|
|
if (GetValue() > min) VideoContext::Get()->JumpToFrame(GetValue()-1);
|
|
|
|
Refresh(false);
|
|
|
|
Update();
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////
|
|
|
|
// Event table
|
|
|
|
BEGIN_EVENT_TABLE(VideoSlider, wxWindow)
|
|
|
|
EVT_MOUSE_EVENTS(VideoSlider::OnMouse)
|
|
|
|
EVT_KEY_DOWN(VideoSlider::OnKeyDown)
|
|
|
|
EVT_PAINT(VideoSlider::OnPaint)
|
|
|
|
EVT_SET_FOCUS(VideoSlider::OnFocus)
|
|
|
|
EVT_KILL_FOCUS(VideoSlider::OnFocus)
|
2007-01-21 07:30:19 +01:00
|
|
|
EVT_ERASE_BACKGROUND(VideoSlider::OnEraseBackground)
|
2006-01-16 22:02:54 +01:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
/// @brief Change position
|
|
|
|
/// @return
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
void VideoSlider::UpdateVideo() {
|
|
|
|
if (Display) {
|
2007-01-21 07:30:19 +01:00
|
|
|
if (VideoContext::Get()->IsPlaying()) return;
|
2006-01-16 22:02:54 +01:00
|
|
|
locked = true;
|
2007-01-21 07:30:19 +01:00
|
|
|
VideoContext::Get()->JumpToFrame(GetValue());
|
2006-01-16 22:02:54 +01:00
|
|
|
locked = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
/// @brief Mouse events
|
|
|
|
/// @param event
|
|
|
|
/// @return
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
void VideoSlider::OnMouse(wxMouseEvent &event) {
|
|
|
|
// Coordinates
|
|
|
|
int x = event.GetX();
|
2007-01-24 04:54:32 +01:00
|
|
|
//int y = event.GetY();
|
2006-01-16 22:02:54 +01:00
|
|
|
bool shift = event.m_shiftDown;
|
|
|
|
|
|
|
|
// Left click
|
|
|
|
if (event.ButtonIsDown(wxMOUSE_BTN_LEFT)) {
|
|
|
|
// Check if it's OK to drag
|
|
|
|
bool canDrag = wxWindow::FindFocus() == this;
|
|
|
|
if (!canDrag) {
|
|
|
|
int tolerance = 4;
|
|
|
|
int curX = GetXAtValue(GetValue());
|
|
|
|
if (x-curX < -tolerance || x-curX > tolerance) canDrag = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Drag
|
|
|
|
if (canDrag) {
|
|
|
|
// Shift click to snap to keyframe
|
|
|
|
if (shift && Display) {
|
2007-01-21 07:30:19 +01:00
|
|
|
wxArrayInt KeyFrames = VideoContext::Get()->GetKeyFrames();
|
2006-12-18 05:53:40 +01:00
|
|
|
int keys = KeyFrames.Count();
|
2006-01-16 22:02:54 +01:00
|
|
|
int clickedFrame = GetValueAtX(x);
|
|
|
|
int closest = 0;
|
|
|
|
int cur;
|
|
|
|
|
|
|
|
// Find closest
|
|
|
|
for (int i=0;i<keys;i++) {
|
2006-12-18 05:53:40 +01:00
|
|
|
cur = KeyFrames[i];
|
2006-01-16 22:02:54 +01:00
|
|
|
if (abs(cur-clickedFrame) < abs(closest-clickedFrame)) {
|
|
|
|
closest = cur;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Jump to frame
|
|
|
|
if (closest == GetValue()) return;
|
|
|
|
SetValue(closest);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Normal click
|
|
|
|
else {
|
|
|
|
int go = GetValueAtX(x);
|
|
|
|
if (go == GetValue()) return;
|
|
|
|
SetValue(go);
|
|
|
|
}
|
|
|
|
Refresh(false);
|
|
|
|
|
|
|
|
// Playing?
|
2007-01-21 07:30:19 +01:00
|
|
|
if (VideoContext::Get()->IsPlaying()) {
|
|
|
|
VideoContext::Get()->Stop();
|
2006-01-16 22:02:54 +01:00
|
|
|
UpdateVideo();
|
2007-01-21 07:30:19 +01:00
|
|
|
VideoContext::Get()->Play();
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
else UpdateVideo();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get focus
|
|
|
|
SetFocus();
|
|
|
|
}
|
|
|
|
|
2006-03-05 05:41:59 +01:00
|
|
|
// Right/middle click
|
|
|
|
if (event.ButtonDown(wxMOUSE_BTN_RIGHT) || event.ButtonDown(wxMOUSE_BTN_MIDDLE)) {
|
|
|
|
SetFocus();
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Something else
|
2007-01-21 07:30:19 +01:00
|
|
|
else if (!VideoContext::Get()->IsPlaying()) event.Skip();
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
/// @brief Key down event
|
|
|
|
/// @param event
|
|
|
|
/// @return
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
void VideoSlider::OnKeyDown(wxKeyEvent &event) {
|
2007-01-21 07:30:19 +01:00
|
|
|
if (VideoContext::Get()->IsPlaying()) return;
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
// Get flags
|
|
|
|
int key = event.GetKeyCode();
|
2007-09-22 00:56:44 +02:00
|
|
|
#ifdef __APPLE__
|
|
|
|
bool ctrl = event.m_metaDown;
|
|
|
|
#else
|
2006-01-16 22:02:54 +01:00
|
|
|
bool ctrl = event.m_controlDown;
|
2007-09-22 00:56:44 +02:00
|
|
|
#endif
|
2006-01-16 22:02:54 +01:00
|
|
|
bool alt = event.m_altDown;
|
|
|
|
bool shift = event.m_shiftDown;
|
|
|
|
int direction = 0;
|
|
|
|
|
|
|
|
// Pick direction
|
|
|
|
if (key == WXK_LEFT) direction = -1;
|
|
|
|
else if (key == WXK_RIGHT) direction = 1;
|
|
|
|
|
|
|
|
// If a direction was actually pressed
|
|
|
|
if (direction) {
|
|
|
|
// Standard move
|
|
|
|
if (!ctrl && !shift && !alt) {
|
|
|
|
if (direction == 1) NextFrame();
|
|
|
|
else PrevFrame();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-02-20 23:15:34 +01:00
|
|
|
// Fast move
|
|
|
|
if (!ctrl && !shift && alt) {
|
2007-01-21 07:30:19 +01:00
|
|
|
if (VideoContext::Get()->IsPlaying()) return;
|
2006-02-20 23:15:34 +01:00
|
|
|
int target = MID(min,GetValue() + direction * Options.AsInt(_T("Video Fast Jump Step")),max);
|
2007-01-21 07:30:19 +01:00
|
|
|
if (target != GetValue()) VideoContext::Get()->JumpToFrame(target);
|
2006-02-20 23:15:34 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
// Boundaries
|
|
|
|
if (ctrl && !shift && !alt) {
|
|
|
|
// Prepare
|
|
|
|
wxArrayInt sel = grid->GetSelection();
|
|
|
|
int cur;
|
|
|
|
if (sel.Count() > 0) cur = sel[0];
|
|
|
|
else {
|
|
|
|
grid->editBox->SetToLine(0);
|
|
|
|
grid->SelectRow(0);
|
|
|
|
cur = 0;
|
|
|
|
}
|
|
|
|
AssDialogue *curDiag = grid->GetDialogue(cur);
|
|
|
|
if (!curDiag) return;
|
|
|
|
|
|
|
|
// Jump to next sub boundary
|
|
|
|
if (direction != 0) {
|
2006-02-24 17:45:10 +01:00
|
|
|
int target1 = VFR_Output.GetFrameAtTime(curDiag->Start.GetMS(),true);
|
|
|
|
int target2 = VFR_Output.GetFrameAtTime(curDiag->End.GetMS(),false);
|
2006-01-16 22:02:54 +01:00
|
|
|
bool drawn = false;
|
|
|
|
|
|
|
|
// Forward
|
|
|
|
if (direction == 1) {
|
2007-01-21 07:30:19 +01:00
|
|
|
if (VideoContext::Get()->GetFrameN() < target1) VideoContext::Get()->JumpToFrame(target1);
|
|
|
|
else if (VideoContext::Get()->GetFrameN() < target2) VideoContext::Get()->JumpToFrame(target2);
|
2006-01-16 22:02:54 +01:00
|
|
|
else {
|
|
|
|
if (cur+1 >= grid->GetRows()) return;
|
|
|
|
grid->editBox->SetToLine(cur+1);
|
|
|
|
grid->SelectRow(cur+1);
|
|
|
|
grid->MakeCellVisible(cur+1,0);
|
2006-02-22 05:59:39 +01:00
|
|
|
grid->SetVideoToSubs(true);
|
|
|
|
grid->Refresh(false);
|
2006-01-16 22:02:54 +01:00
|
|
|
drawn = true;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Backward
|
|
|
|
else {
|
2007-01-21 07:30:19 +01:00
|
|
|
if (VideoContext::Get()->GetFrameN() > target2) VideoContext::Get()->JumpToFrame(target2);
|
|
|
|
else if (VideoContext::Get()->GetFrameN() > target1) VideoContext::Get()->JumpToFrame(target1);
|
2006-01-16 22:02:54 +01:00
|
|
|
else {
|
|
|
|
if (cur-1 < 0) return;
|
|
|
|
grid->editBox->SetToLine(cur-1);
|
|
|
|
grid->SelectRow(cur-1);
|
|
|
|
grid->MakeCellVisible(cur-1,0);
|
2006-02-22 05:59:39 +01:00
|
|
|
grid->SetVideoToSubs(false);
|
|
|
|
grid->Refresh(false);
|
2006-01-16 22:02:54 +01:00
|
|
|
drawn = true;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Snap to keyframe
|
|
|
|
if (shift && !ctrl && !alt) {
|
|
|
|
if (direction != 0) {
|
|
|
|
// Prepare
|
|
|
|
int prevKey = 0;
|
2007-01-21 07:30:19 +01:00
|
|
|
int nextKey = VideoContext::Get()->GetLength()-1;
|
|
|
|
wxArrayInt KeyFrames = VideoContext::Get()->GetKeyFrames();
|
2006-12-18 05:53:40 +01:00
|
|
|
int keys = KeyFrames.Count();
|
2007-01-21 07:30:19 +01:00
|
|
|
int cur = VideoContext::Get()->GetFrameN();
|
2006-01-16 22:02:54 +01:00
|
|
|
int i;
|
|
|
|
int temp;
|
|
|
|
|
|
|
|
// Find previous keyframe
|
|
|
|
// This algorithm does unnecessary loops, but it ensures it works even if keyframes are out of order.
|
|
|
|
for (i=0;i<keys;i++) {
|
2006-12-18 05:53:40 +01:00
|
|
|
temp = KeyFrames[i];
|
2006-01-16 22:02:54 +01:00
|
|
|
if (temp < cur && temp > prevKey) prevKey = temp;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Find next keyframe
|
|
|
|
for (i=0;i<keys;i++) {
|
2006-12-18 05:53:40 +01:00
|
|
|
temp = KeyFrames[i];
|
|
|
|
if (temp > cur && temp < nextKey) nextKey = KeyFrames[i];
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
2007-01-21 07:30:19 +01:00
|
|
|
if (direction == -1) VideoContext::Get()->JumpToFrame(prevKey);
|
|
|
|
if (direction == 1) VideoContext::Get()->JumpToFrame(nextKey);
|
2006-01-16 22:02:54 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-22 03:25:45 +01:00
|
|
|
// Forward up/down to grid
|
|
|
|
if (key == WXK_UP || key == WXK_DOWN) {
|
2009-06-12 01:30:33 +02:00
|
|
|
grid->GetEventHandler()->ProcessEvent(event);
|
2006-02-22 03:25:45 +01:00
|
|
|
grid->SetFocus();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
/// @brief Paint event
|
|
|
|
/// @param event
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
void VideoSlider::OnPaint(wxPaintEvent &event) {
|
|
|
|
wxPaintDC dc(this);
|
|
|
|
DrawImage(dc);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
/// @brief Draw image
|
|
|
|
/// @param destdc
|
|
|
|
///
|
2007-01-21 07:30:19 +01:00
|
|
|
void VideoSlider::DrawImage(wxDC &destdc) {
|
2006-01-16 22:02:54 +01:00
|
|
|
// Get dimensions
|
|
|
|
int w,h;
|
|
|
|
GetClientSize(&w,&h);
|
|
|
|
|
2007-01-21 07:30:19 +01:00
|
|
|
// Back buffer
|
|
|
|
wxMemoryDC dc;
|
|
|
|
wxBitmap bmp(w,h);
|
|
|
|
dc.SelectObject(bmp);
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
// Colors
|
|
|
|
wxColour shad = wxSystemSettings::GetColour(wxSYS_COLOUR_3DDKSHADOW);
|
|
|
|
wxColour high = wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT);
|
|
|
|
wxColour face = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
|
|
|
|
wxColour sel(123,251,232);
|
|
|
|
wxColour notSel(sel.Red()*2/5,sel.Green()*2/5,sel.Blue()*2/5);
|
|
|
|
wxColour bord(0,0,0);
|
|
|
|
int x1,x2,y1,y2;
|
|
|
|
|
2007-01-21 07:30:19 +01:00
|
|
|
// Background
|
|
|
|
dc.SetPen(*wxTRANSPARENT_PEN);
|
|
|
|
dc.SetBrush(face);
|
|
|
|
dc.DrawRectangle(0,0,w,h);
|
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
// Selection border
|
|
|
|
bool selected = wxWindow::FindFocus() == this;
|
|
|
|
if (selected) {
|
|
|
|
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
|
|
|
dc.SetPen(wxPen(shad,1,wxDOT));
|
|
|
|
dc.DrawRectangle(0,0,w,h);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Draw slider
|
|
|
|
x1 = 5;
|
|
|
|
x2 = w-5;
|
|
|
|
y1 = 8;
|
|
|
|
y2 = h-8;
|
|
|
|
dc.SetPen(wxPen(shad));
|
|
|
|
dc.DrawLine(x1,y1,x2,y1);
|
|
|
|
dc.DrawLine(x1,y1,x1,y2);
|
|
|
|
dc.SetPen(wxPen(high));
|
|
|
|
dc.DrawLine(x1,y2,x2,y2);
|
|
|
|
dc.DrawLine(x2,y1,x2,y2);
|
|
|
|
|
|
|
|
// Draw keyframes
|
|
|
|
int curX;
|
|
|
|
if (Display && Options.AsBool(_T("Show keyframes on video slider"))) {
|
|
|
|
dc.SetPen(wxPen(shad));
|
2007-01-21 07:30:19 +01:00
|
|
|
wxArrayInt KeyFrames = VideoContext::Get()->GetKeyFrames();
|
2006-12-18 05:53:40 +01:00
|
|
|
int keys = KeyFrames.Count();
|
2006-01-16 22:02:54 +01:00
|
|
|
for (int i=0;i<keys;i++) {
|
2006-12-18 05:53:40 +01:00
|
|
|
curX = GetXAtValue(KeyFrames[i]);
|
2006-01-16 22:02:54 +01:00
|
|
|
dc.DrawLine(curX,2,curX,8);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Draw cursor
|
|
|
|
curX = GetXAtValue(GetValue());
|
|
|
|
|
|
|
|
// Fill bg
|
|
|
|
dc.SetBrush(wxBrush(face));
|
|
|
|
dc.SetPen(*wxTRANSPARENT_PEN);
|
|
|
|
dc.DrawRectangle(curX-2,y1-1,4,y2-y1+5);
|
|
|
|
dc.SetBrush(wxNullBrush);
|
|
|
|
|
|
|
|
// Draw cursor highlights
|
|
|
|
dc.SetPen(wxPen(high));
|
|
|
|
dc.DrawLine(curX,y1-2,curX-4,y1+2);
|
|
|
|
dc.DrawLine(curX-3,y1+2,curX-3,y2+5);
|
|
|
|
|
|
|
|
// Draw cursor shades
|
|
|
|
dc.SetPen(wxPen(shad));
|
|
|
|
dc.DrawLine(curX+1,y1-1,curX+4,y1+2);
|
|
|
|
dc.DrawLine(curX+3,y1+2,curX+3,y2+5);
|
|
|
|
dc.DrawLine(curX-3,y2+4,curX+3,y2+4);
|
|
|
|
|
|
|
|
// Draw cursor outline
|
|
|
|
dc.SetPen(wxPen(bord));
|
|
|
|
dc.DrawLine(curX,y1-3,curX-4,y1+1);
|
|
|
|
dc.DrawLine(curX,y1-3,curX+4,y1+1);
|
|
|
|
dc.DrawLine(curX-4,y1+1,curX-4,y2+5);
|
|
|
|
dc.DrawLine(curX+4,y1+1,curX+4,y2+5);
|
|
|
|
dc.DrawLine(curX-3,y2+5,curX+4,y2+5);
|
|
|
|
dc.DrawLine(curX-3,y2,curX+4,y2);
|
|
|
|
|
|
|
|
// Draw selection
|
|
|
|
dc.SetPen(*wxTRANSPARENT_PEN);
|
|
|
|
if (selected) dc.SetBrush(wxBrush(sel));
|
|
|
|
else dc.SetBrush(wxBrush(notSel));
|
|
|
|
dc.DrawRectangle(curX-3,y2+1,7,4);
|
2007-01-21 07:30:19 +01:00
|
|
|
|
|
|
|
// Draw final
|
|
|
|
destdc.Blit(0,0,w,h,&dc,0,0);
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
/// @brief Update image
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
void VideoSlider::UpdateImage () {
|
2007-01-21 07:30:19 +01:00
|
|
|
//wxClientDC dc(this);
|
|
|
|
//DrawImage(dc);
|
|
|
|
Refresh(false);
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
/// @brief Focus change
|
|
|
|
/// @param event
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
void VideoSlider::OnFocus(wxFocusEvent &event) {
|
|
|
|
Refresh(false);
|
|
|
|
}
|
2009-07-29 07:43:02 +02:00
|
|
|
|
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
|
|
|
|