Replaced visual typesetting controls with an actual toolbar.

Originally committed to SVN as r1383.
This commit is contained in:
Rodrigo Braz Monteiro 2007-07-06 05:47:03 +00:00
parent 9043bdecf8
commit 70367a1c35
5 changed files with 31 additions and 126 deletions

View file

@ -37,14 +37,14 @@
/////////// ///////////
// Headers // Headers
#include "toggle_bitmap.h" #include "toggle_bitmap.h"
//#include <wx/event.h> #include <wx/wxprec.h>
#include <wx/tglbtn.h> #include <wx/tglbtn.h>
/////////////// ///////////////
// Constructor // Constructor
ToggleBitmap::ToggleBitmap(wxWindow *parent,wxWindowID id,const wxBitmap &image,const wxSize &size) ToggleBitmap::ToggleBitmap(wxWindow *parent,wxWindowID id,const wxBitmap &image,const wxSize &size)
: wxWindow (parent,id,wxDefaultPosition,wxDefaultSize,wxSUNKEN_BORDER) : wxControl (parent,id,wxDefaultPosition,wxDefaultSize,wxSUNKEN_BORDER)
{ {
// Set variables // Set variables
img = image; img = image;
@ -57,6 +57,8 @@ ToggleBitmap::ToggleBitmap(wxWindow *parent,wxWindowID id,const wxBitmap &image,
if (size.GetHeight() != -1) h = size.GetHeight(); if (size.GetHeight() != -1) h = size.GetHeight();
else h = img.GetHeight(); else h = img.GetHeight();
SetClientSize(w,h); SetClientSize(w,h);
GetSize(&w,&h);
SetSizeHints(w,h,w,h);
} }
@ -108,7 +110,7 @@ void ToggleBitmap::DrawImage(wxDC &dc) {
/////////////// ///////////////
// Event table // Event table
BEGIN_EVENT_TABLE(ToggleBitmap,wxWindow) BEGIN_EVENT_TABLE(ToggleBitmap,wxControl)
EVT_MOUSE_EVENTS(ToggleBitmap::OnMouseEvent) EVT_MOUSE_EVENTS(ToggleBitmap::OnMouseEvent)
EVT_PAINT(ToggleBitmap::OnPaint) EVT_PAINT(ToggleBitmap::OnPaint)
END_EVENT_TABLE() END_EVENT_TABLE()

View file

@ -45,7 +45,7 @@
///////// /////////
// Class // Class
class ToggleBitmap : public wxWindow { class ToggleBitmap : public wxControl {
private: private:
wxBitmap img; wxBitmap img;
bool state; bool state;

View file

@ -106,39 +106,22 @@ VideoBox::VideoBox(wxWindow *parent)
videoSlider->Display = videoDisplay; videoSlider->Display = videoDisplay;
// Typesetting buttons // Typesetting buttons
standard = new wxBitmapButton(videoPage,Video_Mode_Standard,wxBITMAP(visual_standard)); visualToolBar = new wxToolBar(videoPage,-1,wxDefaultPosition,wxDefaultSize,wxTB_VERTICAL | wxTB_FLAT);
standard->SetToolTip(_("Standard mode, double click sets position.")); visualToolBar->AddTool(Video_Mode_Standard,_("Standard"),wxBITMAP(visual_standard),_("Standard mode, double click sets position."),wxITEM_RADIO);
drag = new wxBitmapButton(videoPage,Video_Mode_Drag,wxBITMAP(visual_move)); visualToolBar->AddTool(Video_Mode_Drag,_("Drag"),wxBITMAP(visual_move),_("Drag subtitles."),wxITEM_RADIO);
drag->SetToolTip(_("Drag subtitles.")); visualToolBar->AddTool(Video_Mode_Rotate_Z,_("Rotate Z"),wxBITMAP(visual_rotatez),_("Rotate subtitles on their Z axis."),wxITEM_RADIO);
rotatez = new wxBitmapButton(videoPage,Video_Mode_Rotate_Z,wxBITMAP(visual_rotatez)); visualToolBar->AddTool(Video_Mode_Rotate_XY,_("Rotate XY"),wxBITMAP(visual_rotatexy),_("Rotate subtitles on their X and Y axes."),wxITEM_RADIO);
rotatez->SetToolTip(_("Rotate subtitles on their Z axis.")); visualToolBar->AddTool(Video_Mode_Scale,_("Scale"),wxBITMAP(visual_scale),_("Scale subtitles on X and Y axes."),wxITEM_RADIO);
rotatexy = new wxBitmapButton(videoPage,Video_Mode_Rotate_XY,wxBITMAP(visual_rotatexy)); visualToolBar->AddTool(Video_Mode_Clip,_("Clip"),wxBITMAP(visual_clip),_("Clip subtitles to a rectangle."),wxITEM_RADIO);
rotatexy->SetToolTip(_("Rotate subtitles on their X and Y axes.")); visualToolBar->AddTool(Video_Mode_Vector_Clip,_("Vector Clip"),wxBITMAP(visual_vector_clip),_("Clip subtitles to a vectorial area."),wxITEM_RADIO);
scale = new wxBitmapButton(videoPage,Video_Mode_Scale,wxBITMAP(visual_scale)); visualToolBar->AddSeparator();
scale->SetToolTip(_("Scale subtitles on X and Y axes.")); visualToolBar->AddTool(Video_Mode_Realtime,_("Realtime"),wxBITMAP(visual_realtime),_("Toggle realtime display of changes."),wxITEM_CHECK);
clip = new wxBitmapButton(videoPage,Video_Mode_Clip,wxBITMAP(visual_clip)); visualToolBar->ToggleTool(Video_Mode_Realtime,Options.AsBool(_T("Video Visual Realtime")));
clip->SetToolTip(_("Clip subtitles to a rectangle.")); visualToolBar->Realize();
vectorClip = new wxBitmapButton(videoPage,Video_Mode_Vector_Clip,wxBITMAP(visual_vector_clip));
vectorClip->SetToolTip(_("Clip subtitles to a vectorial area."));
realtime = new ToggleBitmap(videoPage,Video_Mode_Realtime,wxBITMAP(visual_realtime),wxSize(20,20));
realtime->SetToolTip(_("Toggle realtime display of changes."));
bool isRealtime = Options.AsBool(_T("Video Visual Realtime"));
realtime->SetValue(isRealtime);
wxSizer *typeSizer = new wxBoxSizer(wxVERTICAL);
typeSizer->Add(standard,0,wxEXPAND,0);
typeSizer->Add(drag,0,wxEXPAND,0);
typeSizer->Add(rotatez,0,wxEXPAND,0);
typeSizer->Add(rotatexy,0,wxEXPAND,0);
typeSizer->Add(scale,0,wxEXPAND,0);
typeSizer->Add(clip,0,wxEXPAND,0);
typeSizer->Add(vectorClip,0,wxEXPAND | wxBOTTOM,5);
typeSizer->Add(new wxStaticLine(videoPage),0,wxEXPAND | wxBOTTOM,5);
typeSizer->Add(realtime,0,wxEXPAND,0);
typeSizer->AddStretchSpacer(1);
// Top sizer // Top sizer
wxFlexGridSizer *topSizer = new wxFlexGridSizer(2,2,0,0); wxFlexGridSizer *topSizer = new wxFlexGridSizer(2,2,0,0);
topSizer->Add(typeSizer,0,wxEXPAND,0); topSizer->Add(visualToolBar,0,wxEXPAND,0);
topSizer->Add(videoDisplay,1,wxEXPAND,0); topSizer->Add(videoDisplay,1,wxEXPAND,0);
topSizer->AddSpacer(0); topSizer->AddSpacer(0);
topSizer->Add(visualSubToolBar,1,wxEXPAND,0); topSizer->Add(visualSubToolBar,1,wxEXPAND,0);
@ -173,14 +156,8 @@ BEGIN_EVENT_TABLE(VideoBox, wxPanel)
EVT_BUTTON(Video_Stop, VideoBox::OnVideoStop) EVT_BUTTON(Video_Stop, VideoBox::OnVideoStop)
EVT_TOGGLEBUTTON(Video_Auto_Scroll, VideoBox::OnVideoToggleScroll) EVT_TOGGLEBUTTON(Video_Auto_Scroll, VideoBox::OnVideoToggleScroll)
EVT_BUTTON(Video_Mode_Standard, VideoBox::OnModeStandard) EVT_TOOL_RANGE(Video_Mode_Standard, Video_Mode_Vector_Clip, VideoBox::OnModeChange)
EVT_BUTTON(Video_Mode_Drag, VideoBox::OnModeDrag) EVT_TOOL(Video_Mode_Realtime, VideoBox::OnToggleRealtime)
EVT_BUTTON(Video_Mode_Rotate_Z, VideoBox::OnModeRotateZ)
EVT_BUTTON(Video_Mode_Rotate_XY, VideoBox::OnModeRotateXY)
EVT_BUTTON(Video_Mode_Scale, VideoBox::OnModeScale)
EVT_BUTTON(Video_Mode_Clip, VideoBox::OnModeClip)
EVT_BUTTON(Video_Mode_Vector_Clip, VideoBox::OnModeVectorClip)
EVT_TOGGLEBUTTON(Video_Mode_Realtime, VideoBox::OnToggleRealtime)
END_EVENT_TABLE() END_EVENT_TABLE()
@ -217,59 +194,17 @@ void VideoBox::OnVideoToggleScroll(wxCommandEvent &event) {
} }
///////////////// ////////////////
// Standard mode // Mode changed
void VideoBox::OnModeStandard(wxCommandEvent &event) { void VideoBox::OnModeChange(wxCommandEvent &event) {
videoDisplay->SetVisualMode(0); videoDisplay->SetVisualMode(event.GetId() - Video_Mode_Standard);
}
/////////////
// Drag mode
void VideoBox::OnModeDrag(wxCommandEvent &event) {
videoDisplay->SetVisualMode(1);
}
/////////////////
// Rotate Z mode
void VideoBox::OnModeRotateZ(wxCommandEvent &event) {
videoDisplay->SetVisualMode(2);
}
//////////////////
// Rotate XY mode
void VideoBox::OnModeRotateXY(wxCommandEvent &event) {
videoDisplay->SetVisualMode(3);
}
//////////////
// Scale mode
void VideoBox::OnModeScale(wxCommandEvent &event) {
videoDisplay->SetVisualMode(4);
}
/////////////
// Clip mode
void VideoBox::OnModeClip(wxCommandEvent &event) {
videoDisplay->SetVisualMode(5);
}
////////////////////
// Vector clip mode
void VideoBox::OnModeVectorClip(wxCommandEvent &event) {
videoDisplay->SetVisualMode(6);
} }
/////////////////// ///////////////////
// Realtime toggle // Realtime toggle
void VideoBox::OnToggleRealtime(wxCommandEvent &event) { void VideoBox::OnToggleRealtime(wxCommandEvent &event) {
Options.SetBool(_T("Video Visual Realtime"),realtime->GetValue()); Options.SetBool(_T("Video Visual Realtime"),event.IsChecked());
Options.Save(); Options.Save();
} }

View file

@ -56,34 +56,18 @@ class FrameMain;
// Video box class // Video box class
class VideoBox : public wxPanel { class VideoBox : public wxPanel {
private: private:
wxButton *standard;
wxButton *drag;
wxButton *rotatez;
wxButton *rotatexy;
wxButton *scale;
wxButton *clip;
wxButton *vectorClip;
ToggleBitmap *realtime;
void OnVideoPlay(wxCommandEvent &event); void OnVideoPlay(wxCommandEvent &event);
void OnVideoPlayLine(wxCommandEvent &event); void OnVideoPlayLine(wxCommandEvent &event);
void OnVideoStop(wxCommandEvent &event); void OnVideoStop(wxCommandEvent &event);
void OnVideoToggleScroll(wxCommandEvent &event); void OnVideoToggleScroll(wxCommandEvent &event);
void OnVideoTrackerMenu(wxCommandEvent &event); void OnModeChange(wxCommandEvent &event);
void OnVideoTrackerMenu2(wxCommandEvent &event);
void OnTrackerOption(wxCommandEvent &event);
void OnModeStandard(wxCommandEvent &event);
void OnModeDrag(wxCommandEvent &event);
void OnModeRotateZ(wxCommandEvent &event);
void OnModeRotateXY(wxCommandEvent &event);
void OnModeScale(wxCommandEvent &event);
void OnModeClip(wxCommandEvent &event);
void OnModeVectorClip(wxCommandEvent &event);
void OnToggleRealtime(wxCommandEvent &event); void OnToggleRealtime(wxCommandEvent &event);
public: public:
wxToolBar *visualToolBar;
wxSizer *visualSubToolBar;
ToggleBitmap *AutoScroll; ToggleBitmap *AutoScroll;
wxBoxSizer *VideoSizer; wxBoxSizer *VideoSizer;
wxBoxSizer *videoSliderSizer; wxBoxSizer *videoSliderSizer;
@ -93,7 +77,6 @@ public:
VideoDisplay *videoDisplay; VideoDisplay *videoDisplay;
VideoSlider *videoSlider; VideoSlider *videoSlider;
FrameMain *frame; FrameMain *frame;
wxSizer *visualSubToolBar;
VideoBox (wxWindow *parent); VideoBox (wxWindow *parent);
@ -117,22 +100,6 @@ enum {
Video_Mode_Clip, Video_Mode_Clip,
Video_Mode_Vector_Clip, Video_Mode_Vector_Clip,
Video_Mode_Realtime, Video_Mode_Realtime,
Video_Tracker_Menu,
Video_Tracker_Menu2,
Video_Tracker_START = 1000,
Video_Track_Points,
Video_Track_Point_Add,
Video_Track_Point_Del,
Video_Track_Movement,
Video_Track_Movement_MoveAll,
Video_Track_Movement_MoveOne,
Video_Track_Movement_MoveBefore,
Video_Track_Movement_MoveAfter,
Video_Track_Split_Line,
Video_Track_Link_File,
Video_Track_Movement_Empty,
Video_Tracker_END
}; };
#endif #endif

View file

@ -656,6 +656,7 @@ void VideoDisplay::SetVisualMode(int mode) {
if (box) { if (box) {
toolBar = box->visualSubToolBar; toolBar = box->visualSubToolBar;
toolBar->Clear(true); toolBar->Clear(true);
if (!box->visualToolBar->GetToolState(mode + Video_Mode_Standard)) box->visualToolBar->ToggleTool(mode + Video_Mode_Standard,true);
} }
// Replace mode // Replace mode