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

View file

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

View file

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

View file

@ -56,34 +56,18 @@ class FrameMain;
// Video box class
class VideoBox : public wxPanel {
private:
wxButton *standard;
wxButton *drag;
wxButton *rotatez;
wxButton *rotatexy;
wxButton *scale;
wxButton *clip;
wxButton *vectorClip;
ToggleBitmap *realtime;
void OnVideoPlay(wxCommandEvent &event);
void OnVideoPlayLine(wxCommandEvent &event);
void OnVideoStop(wxCommandEvent &event);
void OnVideoToggleScroll(wxCommandEvent &event);
void OnVideoTrackerMenu(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 OnModeChange(wxCommandEvent &event);
void OnToggleRealtime(wxCommandEvent &event);
public:
wxToolBar *visualToolBar;
wxSizer *visualSubToolBar;
ToggleBitmap *AutoScroll;
wxBoxSizer *VideoSizer;
wxBoxSizer *videoSliderSizer;
@ -93,7 +77,6 @@ public:
VideoDisplay *videoDisplay;
VideoSlider *videoSlider;
FrameMain *frame;
wxSizer *visualSubToolBar;
VideoBox (wxWindow *parent);
@ -117,22 +100,6 @@ enum {
Video_Mode_Clip,
Video_Mode_Vector_Clip,
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

View file

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