Convert the video box buttons over to commands

Originally committed to SVN as r5252.
This commit is contained in:
Thomas Goyne 2011-01-20 05:58:01 +00:00
parent b286339ce0
commit 71daddeeb2
6 changed files with 144 additions and 167 deletions

View File

@ -134,6 +134,17 @@ struct help_irc : public Command {
}
};
/// Open the manual page for Visual Typesetting.
struct help_video : public Command {
CMD_NAME("help/video")
STR_MENU("&Visual Typesetting..")
STR_DISP("Visual Typesetting")
STR_HELP("Open the manual page for Visual Typesetting.")
void operator()(agi::Context *c) {
HelpButton::OpenPage("Visual Typesetting");
}
};
/// Visit Aegisub's official website.
struct help_website : public Command {
@ -151,12 +162,13 @@ struct help_website : public Command {
/// Init help/ commands.
void init_help(CommandManager *cm) {
cm->reg(new help_bugs());
cm->reg(new help_contents());
cm->reg(new help_files());
cm->reg(new help_forums());
cm->reg(new help_irc());
cm->reg(new help_website());
cm->reg(new help_bugs);
cm->reg(new help_contents);
cm->reg(new help_files);
cm->reg(new help_forums);
cm->reg(new help_irc);
cm->reg(new help_video);
cm->reg(new help_website);
}
} // namespace cmd

View File

@ -134,6 +134,7 @@ INSERT_ICON("help/contents", contents_button)
INSERT_ICON("help/files", contents_button)
INSERT_ICON("help/forums", forums_button)
INSERT_ICON("help/irc", irc_button)
INSERT_ICON("help/video", visual_help)
INSERT_ICON("help/website", website_button)
INSERT_ICON("keyframe/close", close_keyframes_menu)
INSERT_ICON("keyframe/open", open_keyframes_menu)
@ -190,6 +191,10 @@ INSERT_ICON("video/jump/end", video_to_subend)
INSERT_ICON("video/jump/start", video_to_substart)
INSERT_ICON("video/open", open_video_menu)
INSERT_ICON("video/open/dummy", use_dummy_video_menu)
INSERT_ICON("video/opt/autoscroll", toggle_video_autoscroll)
INSERT_ICON("video/play", button_play)
INSERT_ICON("video/play/line", button_playline)
INSERT_ICON("video/stop", button_pause)
INSERT_ICON("video/zoom/in", zoom_in_button)
INSERT_ICON("video/zoom/out", zoom_out_button)

View File

@ -254,20 +254,6 @@ struct video_frame_next : public Command {
}
};
/// Play video.
struct video_frame_play : public Command {
CMD_NAME("video/frame/play")
STR_MENU("Play")
STR_DISP("Play")
STR_HELP("Play video.")
void operator()(agi::Context *c) {
c->videoController->Play();
}
};
/// Seek to the previous frame.
struct video_frame_prev : public Command {
CMD_NAME("video/frame/prev")
@ -347,7 +333,7 @@ struct video_open : public Command {
/// Opens a video clip with solid colour.
struct video_open_dummy : public Command {
CMD_NAME("video/open/dummy")
STR_MENU("Use Dummy Video..")
STR_MENU("Use Dummy Video...")
STR_DISP("Use Dummy Video")
STR_HELP("Opens a video clip with solid colour.")
@ -359,6 +345,41 @@ struct video_open_dummy : public Command {
}
};
/// Toggle autoscrolling video when the active line changes
struct video_opt_autoscroll : public Command {
CMD_NAME("video/opt/autoscroll")
STR_MENU("Toggle autoscroll of video")
STR_DISP("Toggle autoscroll of video")
STR_HELP("Toggle autoscroll of video")
void operator()(agi::Context *c) {
OPT_SET("Video/Subtitle Sync")->SetBool(!OPT_GET("Video/Subtitle Sync")->GetBool());
}
};
/// Play video.
struct video_play : public Command {
CMD_NAME("video/play")
STR_MENU("Play")
STR_DISP("Play")
STR_HELP("Play video starting on this position")
void operator()(agi::Context *c) {
c->videoController->Play();
}
};
/// Play video for the active line.
struct video_play_line : public Command {
CMD_NAME("video/play/line")
STR_MENU("Play line")
STR_DISP("Play line")
STR_HELP("Play current line")
void operator()(agi::Context *c) {
c->videoController->PlayLine();
}
};
/// Show a mask over the video.
struct video_show_overscan : public Command {
@ -390,7 +411,18 @@ public:
}
};
/// Stop video playback
class video_stop: public Command {
public:
CMD_NAME("video/stop")
STR_MENU("Stop video")
STR_DISP("Stop video")
STR_HELP("Stop video playback")
void operator()(agi::Context *c) {
c->videoController->Stop();
}
};
/// Set zoom to 200%.
class video_zoom_200: public Command {
@ -451,29 +483,32 @@ struct video_zoom_out : public Command {
/// Init video/ commands.
void init_video(CommandManager *cm) {
cm->reg(new video_aspect_cinematic());
cm->reg(new video_aspect_custom());
cm->reg(new video_aspect_default());
cm->reg(new video_aspect_full());
cm->reg(new video_aspect_wide());
cm->reg(new video_close());
cm->reg(new video_detach());
cm->reg(new video_details());
cm->reg(new video_focus_seek());
cm->reg(new video_frame_next());
cm->reg(new video_frame_play());
cm->reg(new video_frame_prev());
cm->reg(new video_jump());
cm->reg(new video_jump_end());
cm->reg(new video_jump_start());
cm->reg(new video_open());
cm->reg(new video_open_dummy());
cm->reg(new video_show_overscan());
cm->reg(new video_zoom_100());
cm->reg(new video_zoom_200());
cm->reg(new video_zoom_50());
cm->reg(new video_zoom_in());
cm->reg(new video_zoom_out());
cm->reg(new video_aspect_cinematic);
cm->reg(new video_aspect_custom);
cm->reg(new video_aspect_default);
cm->reg(new video_aspect_full);
cm->reg(new video_aspect_wide);
cm->reg(new video_close);
cm->reg(new video_detach);
cm->reg(new video_details);
cm->reg(new video_focus_seek);
cm->reg(new video_frame_next);
cm->reg(new video_frame_prev);
cm->reg(new video_jump);
cm->reg(new video_jump_end);
cm->reg(new video_jump_start);
cm->reg(new video_open);
cm->reg(new video_open_dummy);
cm->reg(new video_opt_autoscroll);
cm->reg(new video_play);
cm->reg(new video_play_line);
cm->reg(new video_show_overscan);
cm->reg(new video_stop);
cm->reg(new video_zoom_100);
cm->reg(new video_zoom_200);
cm->reg(new video_zoom_50);
cm->reg(new video_zoom_in);
cm->reg(new video_zoom_out);
}
} // namespace cmd

View File

@ -282,7 +282,7 @@
"enable" : true
}
],
"video/frame/play" : [
"video/play" : [
{
"modifiers" : [ "Ctrl" ],
"key" : "P",
@ -622,7 +622,7 @@
"enable" : true
}
],
"video play" : [
"video/play" : [
{
"modifiers" : [],
"key" : "Home",
@ -754,7 +754,7 @@
"enable" : true
}
],
"video play" : [
"video/play" : [
{
"modifiers" : [],
"key" : "Home",

View File

@ -45,7 +45,7 @@
#include "include/aegisub/context.h"
#include "frame_main.h"
#include "command/command.h"
#include "help_button.h"
#include "libresrc/libresrc.h"
#include "main.h"
@ -53,51 +53,56 @@
#include "subs_edit_box.h"
#include "subs_grid.h"
#include "toggle_bitmap.h"
#include "tooltip_manager.h"
#include "utils.h"
#include "video_box.h"
#include "video_context.h"
#include "video_display.h"
#include "video_slider.h"
static void add_button(wxWindow *parent, wxSizer *sizer, const char *command) {
cmd::Command *c = cmd::get(command);
wxBitmapButton *btn = new wxBitmapButton(parent, cmd::id(command), *c->Icon(24));
ToolTipManager::Bind(btn, c->StrHelp(), "Video", command);
sizer->Add(btn, 0, wxTOP | wxLEFT | wxBOTTOM | wxALIGN_CENTER, 2);;
}
static void add_option(wxWindow *parent, wxSizer *sizer, const char *command, const char *option) {
cmd::Command *c = cmd::get(command);
ToggleBitmap *btn = new ToggleBitmap(parent, cmd::id(command), *c->Icon(24));
ToolTipManager::Bind(btn, c->StrHelp(), "Video", command);
btn->SetValue(OPT_GET(option)->GetBool());
sizer->Add(btn, 0, wxTOP | wxLEFT | wxBOTTOM | wxALIGN_CENTER, 2);
}
/// @brief Constructor
/// @param parent
/// @param isDetached
///
VideoBox::VideoBox(wxWindow *parent, bool isDetached, wxComboBox *zoomBox, agi::Context *context)
: wxPanel (parent,-1)
, context(context)
{
// Parent
videoPage = this;
// Visual controls sub-toolbar
visualSubToolBar = new wxToolBar(videoPage,-1,wxDefaultPosition,wxDefaultSize,wxTB_HORIZONTAL | wxTB_BOTTOM | wxTB_FLAT);
visualSubToolBar = new wxToolBar(this,-1,wxDefaultPosition,wxDefaultSize,wxTB_HORIZONTAL | wxTB_BOTTOM | wxTB_FLAT);
// Buttons
wxBitmapButton *VideoPlayButton = new wxBitmapButton(videoPage,Video_Play,GETIMAGE(button_play_24),wxDefaultPosition,wxSize(25,-1));
VideoPlayButton->SetToolTip(_("Play video starting on this position"));
wxBitmapButton *VideoPlayLineButton = new wxBitmapButton(videoPage,Video_Play_Line,GETIMAGE(button_playline_24),wxDefaultPosition,wxSize(25,-1));
VideoPlayLineButton->SetToolTip(_("Play current line"));
wxBitmapButton *VideoStopButton = new wxBitmapButton(videoPage,Video_Stop,GETIMAGE(button_pause_24),wxDefaultPosition,wxSize(25,-1));
VideoStopButton->SetToolTip(_("Stop video playback"));
AutoScroll = new ToggleBitmap(videoPage,Video_Auto_Scroll,GETIMAGE(toggle_video_autoscroll_24),wxSize(30,-1));
AutoScroll->SetToolTip(_("Toggle autoscroll of video"));
AutoScroll->SetValue(OPT_GET("Video/Subtitle Sync")->GetBool());
wxSizer *videoBottomSizer = new wxBoxSizer(wxHORIZONTAL);
add_button(this, videoBottomSizer, "video/play");
add_button(this, videoBottomSizer, "video/play/line");
add_button(this, videoBottomSizer, "video/stop");
add_option(this, videoBottomSizer, "video/opt/autoscroll", "Video/Subtitle Sync");
// Seek
videoSlider = new VideoSlider(videoPage,-1);
videoSlider = new VideoSlider(this,-1);
videoSlider->SetToolTip(_("Seek video."));
// Position
VideoPosition = new wxTextCtrl(videoPage,-1,_T(""),wxDefaultPosition,wxSize(110,20),wxTE_READONLY);
VideoPosition = new wxTextCtrl(this,-1,"",wxDefaultPosition,wxSize(110,20),wxTE_READONLY);
VideoPosition->SetToolTip(_("Current frame time and number."));
// Times of sub relative to video
VideoSubsPos = new wxTextCtrl(videoPage,-1,_T(""),wxDefaultPosition,wxSize(110,20),wxTE_READONLY);
VideoSubsPos = new wxTextCtrl(this,-1,"",wxDefaultPosition,wxSize(110,20),wxTE_READONLY);
VideoSubsPos->SetToolTip(_("Time of this frame relative to start and end of current subs."));
// Typesetting buttons
visualToolBar = new wxToolBar(videoPage,-1,wxDefaultPosition,wxDefaultSize,wxTB_VERTICAL|wxTB_FLAT|wxTB_NODIVIDER);
visualToolBar = new wxToolBar(this,-1,wxDefaultPosition,wxDefaultSize,wxTB_VERTICAL|wxTB_FLAT|wxTB_NODIVIDER);
visualToolBar->AddTool(Video_Mode_Standard,_("Standard"),GETIMAGE(visual_standard_24),_("Standard mode, double click sets position."),wxITEM_RADIO);
visualToolBar->AddTool(Video_Mode_Drag,_("Drag"),GETIMAGE(visual_move_24),_("Drag subtitles."),wxITEM_RADIO);
visualToolBar->AddTool(Video_Mode_Rotate_Z,_("Rotate Z"),GETIMAGE(visual_rotatez_24),_("Rotate subtitles on their Z axis."),wxITEM_RADIO);
@ -106,14 +111,14 @@ VideoBox::VideoBox(wxWindow *parent, bool isDetached, wxComboBox *zoomBox, agi::
visualToolBar->AddTool(Video_Mode_Clip,_("Clip"),GETIMAGE(visual_clip_24),_("Clip subtitles to a rectangle."),wxITEM_RADIO);
visualToolBar->AddTool(Video_Mode_Vector_Clip,_("Vector Clip"),GETIMAGE(visual_vector_clip_24),_("Clip subtitles to a vectorial area."),wxITEM_RADIO);
visualToolBar->AddSeparator();
visualToolBar->AddTool(Video_Mode_Help,_("Help"),GETIMAGE(visual_help_24),_("Open the manual page for Visual Typesetting."));
visualToolBar->AddTool(cmd::id("help/video"),_("Help"),*cmd::get("help/video")->Icon(24),_("Open the manual page for Visual Typesetting."));
visualToolBar->Realize();
// Avoid ugly themed background on Vista and possibly also Win7
visualToolBar->SetBackgroundStyle(wxBG_STYLE_COLOUR);
visualToolBar->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
// Display
videoDisplay = new VideoDisplay(this,VideoPosition,VideoSubsPos,zoomBox,videoPage,context);
videoDisplay = new VideoDisplay(this,VideoPosition,VideoSubsPos,zoomBox,this,context);
// Set display
videoSlider->Display = videoDisplay;
@ -128,17 +133,11 @@ VideoBox::VideoBox(wxWindow *parent, bool isDetached, wxComboBox *zoomBox, agi::
topTopSizer->Add(videoDisplay,1,highSizerFlags,0);
topSizer->Add(topTopSizer,1,wxEXPAND,0);
topSizer->Add(visualSubToolBar,0,wxEXPAND | wxBOTTOM,4);
topSizer->Add(new wxStaticLine(videoPage),0,wxEXPAND,0);
topSizer->Add(new wxStaticLine(this),0,wxEXPAND,0);
// Sizers
videoSliderSizer = new wxBoxSizer(wxHORIZONTAL);
videoSliderSizer->Add(videoSlider,1,wxEXPAND|wxLEFT,0);
wxSizer *videoBottomSizer = new wxBoxSizer(wxHORIZONTAL);
//videoBottomSizer->Add(zoomSlider,1,wxEXPAND,0);
videoBottomSizer->Add(VideoPlayButton,0,wxTOP|wxLEFT|wxBOTTOM|wxALIGN_CENTER,2);
videoBottomSizer->Add(VideoPlayLineButton,0,wxTOP|wxBOTTOM|wxALIGN_CENTER,2);
videoBottomSizer->Add(VideoStopButton,0,wxTOP|wxBOTTOM|wxALIGN_CENTER,2);
videoBottomSizer->Add(AutoScroll,0,wxTOP|wxBOTTOM|wxALIGN_CENTER|wxEXPAND,2);
videoBottomSizer->Add(VideoPosition,1,wxLEFT|wxALIGN_CENTER,5);
videoBottomSizer->Add(VideoSubsPos,1,wxALIGN_CENTER,0);
@ -151,74 +150,20 @@ VideoBox::VideoBox(wxWindow *parent, bool isDetached, wxComboBox *zoomBox, agi::
if (!isDetached)
VideoSizer->AddStretchSpacer(1);
SetSizer(VideoSizer);
Bind(wxEVT_COMMAND_BUTTON_CLICKED, &VideoBox::OnButton, this);
Bind(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, &VideoBox::OnButton, this);
}
///////////////
// Event table
BEGIN_EVENT_TABLE(VideoBox, wxPanel)
EVT_BUTTON(Video_Play, VideoBox::OnVideoPlay)
EVT_BUTTON(Video_Play_Line, VideoBox::OnVideoPlayLine)
EVT_BUTTON(Video_Stop, VideoBox::OnVideoStop)
EVT_TOGGLEBUTTON(Video_Auto_Scroll, VideoBox::OnVideoToggleScroll)
EVT_TOOL(Video_Mode_Help, VideoBox::OnHelp)
END_EVENT_TABLE()
/// @brief Play video
/// @param event
///
void VideoBox::OnVideoPlay(wxCommandEvent &event) {
VideoContext *ctx = VideoContext::Get();
void VideoBox::OnButton(wxCommandEvent &evt) {
if (evt.GetId() >= Video_Mode_Standard) {
evt.Skip();
return;
}
#ifdef __APPLE__
ctx->EnableAudioSync(wxGetMouseState().CmdDown() == false);
context->videoController->EnableAudioSync(!wxGetMouseState().CmdDown());
#else
ctx->EnableAudioSync(wxGetMouseState().ControlDown() == false);
context->videoController->EnableAudioSync(!wxGetMouseState().ControlDown());
#endif
ctx->Play();
cmd::call(context, evt.GetId());
}
/// @brief Play video line
/// @param event
///
void VideoBox::OnVideoPlayLine(wxCommandEvent &event) {
VideoContext *ctx = VideoContext::Get();
#ifdef __APPLE__
ctx->EnableAudioSync(wxGetMouseState().CmdDown() == false);
#else
ctx->EnableAudioSync(wxGetMouseState().ControlDown() == false);
#endif
ctx->PlayLine();
}
/// @brief Stop video
/// @param event
///
void VideoBox::OnVideoStop(wxCommandEvent &event) {
VideoContext::Get()->Stop();
}
/// @brief Toggle autoscroll
/// @param event
///
void VideoBox::OnVideoToggleScroll(wxCommandEvent &event) {
OPT_SET("Video/Subtitle Sync")->SetBool(AutoScroll->GetValue());
}
/// @brief Help
/// @param event
///
void VideoBox::OnHelp(wxCommandEvent &event) {
HelpButton::OpenPage(_T("Visual Typesetting"));
}

View File

@ -45,10 +45,9 @@
#endif
namespace agi { struct Context; }
class ToggleBitmap;
class VideoDisplay;
class VideoSlider;
class ToggleBitmap;
class FrameMain;
class wxComboBox;
/// DOCME
@ -57,14 +56,9 @@ class wxComboBox;
///
/// DOCME
class VideoBox : public wxPanel {
private:
void OnVideoPlay(wxCommandEvent &event);
void OnVideoPlayLine(wxCommandEvent &event);
void OnVideoStop(wxCommandEvent &event);
void OnVideoToggleScroll(wxCommandEvent &event);
void OnHelp(wxCommandEvent &event);
agi::Context *context;
void OnButton(wxCommandEvent &evt);
public:
/// DOCME
@ -73,18 +67,12 @@ public:
/// DOCME
wxToolBar *visualSubToolBar;
/// DOCME
ToggleBitmap *AutoScroll;
/// DOCME
wxBoxSizer *VideoSizer;
/// DOCME
wxBoxSizer *videoSliderSizer;
/// DOCME
wxWindow *videoPage;
/// DOCME
wxTextCtrl *VideoPosition;
@ -98,23 +86,15 @@ public:
VideoSlider *videoSlider;
VideoBox(wxWindow *parent, bool isDetached, wxComboBox *zoomBox, agi::Context *context);
DECLARE_EVENT_TABLE()
};
// IDs
enum {
Video_Play = 500,
Video_Play_Line,
Video_Stop,
Video_Auto_Scroll,
Video_Mode_Standard,
Video_Mode_Standard = 5000,
Video_Mode_Drag,
Video_Mode_Rotate_Z,
Video_Mode_Rotate_XY,
Video_Mode_Scale,
Video_Mode_Clip,
Video_Mode_Vector_Clip,
Video_Mode_Help
};