From 92e61f885f343e0384d01134b42280dd2f119add Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Wed, 4 Jul 2007 04:24:47 +0000 Subject: [PATCH] Completed \move support and fixed a bug related to dragging. Originally committed to SVN as r1348. --- aegisub/bitmaps/visual_clip.bmp | Bin 1318 -> 1318 bytes aegisub/bitmaps/visual_move.bmp | Bin 1318 -> 1318 bytes aegisub/bitmaps/visual_move_conv_move.bmp | Bin 0 -> 1558 bytes aegisub/bitmaps/visual_move_conv_pos.bmp | Bin 0 -> 1558 bytes aegisub/changelog.txt | 2 +- aegisub/res.rc | 2 + aegisub/video_box.cpp | 10 ++- aegisub/video_box.h | 1 + aegisub/video_display.cpp | 34 +++++++--- aegisub/visual_tool.cpp | 26 +++++++- aegisub/visual_tool.h | 23 +++++++ aegisub/visual_tool_drag.cpp | 75 +++++++++++++++++++++- aegisub/visual_tool_drag.h | 9 ++- 13 files changed, 164 insertions(+), 18 deletions(-) create mode 100644 aegisub/bitmaps/visual_move_conv_move.bmp create mode 100644 aegisub/bitmaps/visual_move_conv_pos.bmp diff --git a/aegisub/bitmaps/visual_clip.bmp b/aegisub/bitmaps/visual_clip.bmp index 27542ada9c7ea056ba616fd1fd2bec41a6c825a1..84013308073b2fc5b304cfdc0ab7e46c24bab815 100644 GIT binary patch delta 232 zcmZ3+wTx?nJ4-zyTf=o2NT$lz=Q`6kOd}80Lo8*s{k^<>Y)N42?!r709FbkKr+Yxq7-T# jSQAji1a=o>1Arnh17S`=a{$Ctux)S^4<<~uXAuVg6Lm(7 delta 178 zcmZ3+wTx?n56fg3R<6lntOE7y?CcX@0LTV`2@f7T0AmOjKOd$SN|UNz3akNU2-HHb M82e;?R&kIM0q!wGc>n+a diff --git a/aegisub/bitmaps/visual_move_conv_move.bmp b/aegisub/bitmaps/visual_move_conv_move.bmp new file mode 100644 index 0000000000000000000000000000000000000000..d2c24deb23abcfd87ed74182330de91cebb3a2d6 GIT binary patch literal 1558 zcma*lJ(AQw42EHC6~&N|ZAdBP1jH(G?x3US2y+Al6z5RP83=TQ%?XCrEgOpQu!TL3 zzaFdo)9wEJ<@v3w?b92PkF-AEJ)Y#q$yP;^`qqF`!^9aI4EeM z&>|*K&@e|JQD_ktC=C4ZK%&t5bConW0*OM4(3Dgd9Dzikc}ao7;0PoNEy7P)VQ>Tz zg%%TDQxx0o2qX$ULsKOUjzFT&Gi+1R;0PoNJyYUJ8XSQ{p=Y{6NrNMhDD+HaDrs;8 z5`~^=E+q|)K%&s=6Id&0a0C*CmSFrLif!bMZBGi;0PoNJ1qR_KkLrH@pkSO#lwK6yyjthFSL=-7Kc2s)>im+w-~X7(%l$~U0{6e$_B%bAzdt>h;@QsE Kuk%Nl`~L#5LDWD1 literal 0 HcmV?d00001 diff --git a/aegisub/bitmaps/visual_move_conv_pos.bmp b/aegisub/bitmaps/visual_move_conv_pos.bmp new file mode 100644 index 0000000000000000000000000000000000000000..cf5026a56feb439ebb16aeb6e8c9d7e2423c8410 GIT binary patch literal 1558 zcmc)IJ&qJH5QgEeCB%@C5uyq?0da|(JJeC?C>0>~8WnQ}f;z(H1jF0*Xcx4zBBZ;Y z{@ix|*lvIM`r)nC_W6zUiPA^B$DwztevTD)PAPFHa|dUN>TdPV*5i-wk~so2SfMeJ z3kC`vNE8|)g+{9=03l2qX%P*;5imIs%D8WA=2Vk&Zy3(3m}yWuzmJC^TkI za~tUhBnpjLzre>xM<7vXjFR!E4ClxL=U!-x(gcGekSH`}|28+$5l9povwvwA=?EkW zjoH7Ok7POmi9%!cQYa%GfkdG(dzrM6jzFT&n6-p*jC2GNg~q5Ef6L$qBnsy~duf@G zjzFT&n7!=WNJk)1Xv|)cVWcCFC^Tj-*EG@*NE8~gmvR~D2qX%P*~`3*bOaKm$6r@{ z>Z=NoYyZ`_I literal 0 HcmV?d00001 diff --git a/aegisub/changelog.txt b/aegisub/changelog.txt index 32f35dec4..9ebde8d1d 100644 --- a/aegisub/changelog.txt +++ b/aegisub/changelog.txt @@ -31,7 +31,7 @@ Please visit http://aegisub.net to download latest version o Framegrabs from the video now also includes framenumber in the filename. (jfs) o Added a toggleable overscan mask to show which areas might get cropped by televisions. (AMZ) - Visual Typesetting functionality implemented, which should make typesetting much easier and faster. It supports: (AMZ) - o Dragging; + o Dragging, including support for \move; o Rotation on Z axis; o Rotation on X/Y axes; o Scaling on X/Y axes; diff --git a/aegisub/res.rc b/aegisub/res.rc index 951dce187..5e4d4b5de 100644 --- a/aegisub/res.rc +++ b/aegisub/res.rc @@ -131,6 +131,8 @@ toggle_video_autoscroll BITMAP "bitmaps/toggle_video_autoscroll.bmp" visual_standard BITMAP "bitmaps/visual_standard.bmp" visual_move BITMAP "bitmaps/visual_move.bmp" +visual_move_conv_move BITMAP "bitmaps/visual_move_conv_move.bmp" +visual_move_conv_pos BITMAP "bitmaps/visual_move_conv_pos.bmp" visual_rotatez BITMAP "bitmaps/visual_rotatez.bmp" visual_rotatexy BITMAP "bitmaps/visual_rotatexy.bmp" visual_scale BITMAP "bitmaps/visual_scale.bmp" diff --git a/aegisub/video_box.cpp b/aegisub/video_box.cpp index d52972aee..62af4b88f 100644 --- a/aegisub/video_box.cpp +++ b/aegisub/video_box.cpp @@ -67,6 +67,9 @@ VideoBox::VideoBox(wxWindow *parent) videoPage = this; frame = AegisubApp::Get()->frame; + // Visual controls sub-toolbar + visualSubToolBar = new wxBoxSizer(wxHORIZONTAL); + // Buttons wxBitmapButton *VideoPlayButton = new wxBitmapButton(videoPage,Video_Play,wxBITMAP(button_play),wxDefaultPosition,wxSize(25,-1)); VideoPlayButton->SetToolTip(_("Play video starting on this position")); @@ -130,9 +133,13 @@ VideoBox::VideoBox(wxWindow *parent) typeSizer->AddStretchSpacer(1); // Top sizer - wxSizer *topSizer = new wxBoxSizer(wxHORIZONTAL); + wxFlexGridSizer *topSizer = new wxFlexGridSizer(2,2,0,0); topSizer->Add(typeSizer,0,wxEXPAND,0); topSizer->Add(videoDisplay,1,wxEXPAND,0); + topSizer->AddSpacer(0); + topSizer->Add(visualSubToolBar,1,wxEXPAND,0); + topSizer->AddGrowableCol(1); + topSizer->AddGrowableRow(0); // Sizers videoSliderSizer = new wxBoxSizer(wxHORIZONTAL); @@ -147,6 +154,7 @@ VideoBox::VideoBox(wxWindow *parent) videoBottomSizer->Add(VideoSubsPos,1,wxALIGN_CENTER,0); VideoSizer = new wxBoxSizer(wxVERTICAL); VideoSizer->Add(topSizer,1,wxEXPAND,0); + VideoSizer->Add(new wxStaticLine(videoPage),0,wxEXPAND,0); VideoSizer->Add(videoSliderSizer,0,wxEXPAND,0); VideoSizer->Add(videoBottomSizer,0,wxEXPAND,0); SetSizer(VideoSizer); diff --git a/aegisub/video_box.h b/aegisub/video_box.h index 33460d57e..6faa37389 100644 --- a/aegisub/video_box.h +++ b/aegisub/video_box.h @@ -91,6 +91,7 @@ public: VideoDisplay *videoDisplay; VideoSlider *videoSlider; FrameMain *frame; + wxSizer *visualSubToolBar; VideoBox (wxWindow *parent); diff --git a/aegisub/video_display.cpp b/aegisub/video_display.cpp index 9b35b68c4..2401d75a4 100644 --- a/aegisub/video_display.cpp +++ b/aegisub/video_display.cpp @@ -114,6 +114,7 @@ VideoDisplay::VideoDisplay(wxWindow* parent, wxWindowID id, const wxPoint& pos, : wxGLCanvas (parent, id, attribList, pos, size, style, name) { // Set options + box = NULL; locked = false; ControlSlider = NULL; PositionDisplay = NULL; @@ -646,16 +647,29 @@ void VideoDisplay::ConvertMouseCoords(int &x,int &y) { // Set mode void VideoDisplay::SetVisualMode(int mode) { // Set visual - visualMode = mode; - delete visual; - switch (mode) { - case 0: visual = new VisualToolCross(this); break; - case 1: visual = new VisualToolDrag(this); break; - case 2: visual = new VisualToolRotateZ(this); break; - case 3: visual = new VisualToolRotateXY(this); break; - case 4: visual = new VisualToolScale(this); break; - case 5: visual = new VisualToolClip(this); break; - default: visual = NULL; + if (visualMode != mode) { + // Get toolbar + wxSizer *toolBar = NULL; + if (box) { + toolBar = box->visualSubToolBar; + toolBar->Clear(true); + } + + // Replace mode + visualMode = mode; + delete visual; + switch (mode) { + case 0: visual = new VisualToolCross(this); break; + case 1: visual = new VisualToolDrag(this,toolBar,box); break; + case 2: visual = new VisualToolRotateZ(this); break; + case 3: visual = new VisualToolRotateXY(this); break; + case 4: visual = new VisualToolScale(this); break; + case 5: visual = new VisualToolClip(this); break; + default: visual = NULL; + } + + // Update size to reflect toolbar changes + UpdateSize(); } // Render diff --git a/aegisub/visual_tool.cpp b/aegisub/visual_tool.cpp index 15b4b2f9f..cbe64e2a3 100644 --- a/aegisub/visual_tool.cpp +++ b/aegisub/visual_tool.cpp @@ -57,7 +57,7 @@ /////////////// // Constructor -VisualTool::VisualTool(VideoDisplay *par) { +VisualTool::VisualTool(VideoDisplay *par) : eventSink(this) { parent = par; colour[0] = wxColour(27,60,114); colour[1] = wxColour(166,247,177); @@ -169,8 +169,9 @@ void VisualTool::OnMouseEvent (wxMouseEvent &event) { // Commit CommitDrag(features[curFeature]); + grid->editBox->CommitText(); grid->ass->FlagAsModified(_("visual typesetting")); - grid->CommitChanges(false,true); + grid->CommitChanges(false); // Clean up dragging = false; @@ -222,7 +223,7 @@ void VisualTool::OnMouseEvent (wxMouseEvent &event) { CommitHold(); grid->editBox->CommitText(); grid->ass->FlagAsModified(_("visual typesetting")); - grid->CommitChanges(false,true); + grid->CommitChanges(false); // Clean up holding = false; @@ -293,6 +294,7 @@ void VisualTool::DrawAllFeatures() { void VisualTool::Refresh() { frame_n = VideoContext::Get()->GetFrameN(); dragListOK = false; + DoRefresh(); } @@ -568,3 +570,21 @@ void VisualTool::GetLineClip(AssDialogue *diag,int &x1,int &y1,int &x2,int &y2) void VisualTool::SetOverride(wxString tag,wxString value) { VideoContext::Get()->grid->editBox->SetOverride(tag,value,0,false); } + + +////////////////// +// Connect button +void VisualTool::ConnectButton(wxButton *button) { + button->Connect(wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(VisualToolEvent::OnButton),NULL,&eventSink); +} + + +////////////// +// Event sink +VisualToolEvent::VisualToolEvent(VisualTool *_tool) { + tool = _tool; +} +void VisualToolEvent::OnButton(wxCommandEvent &event) { + tool->OnButton(event); +} + diff --git a/aegisub/visual_tool.h b/aegisub/visual_tool.h index ebe6a3cfb..5c0478289 100644 --- a/aegisub/visual_tool.h +++ b/aegisub/visual_tool.h @@ -49,13 +49,30 @@ // Prototypes class VideoDisplay; class AssDialogue; +class VisualTool; + + +//////////////////// +// Event sink class +class VisualToolEvent : public wxEvtHandler { +private: + VisualTool *tool; + +public: + void OnButton(wxCommandEvent &event); + + VisualToolEvent(VisualTool *tool); +}; //////////////////////// // Visual handler class class VisualTool : public OpenGLWrapper { + friend class VisualToolEvent; + private: VideoDisplay *parent; + VisualToolEvent eventSink; protected: wxColour colour[4]; @@ -92,6 +109,9 @@ protected: int GetHighlightedFeature(); void DrawAllFeatures(); + void ConnectButton(wxButton *button); + virtual void OnButton(wxCommandEvent &event) {} + virtual bool CanHold() { return false; } virtual void InitializeHold() {} virtual void UpdateHold() {} @@ -103,6 +123,8 @@ protected: virtual void UpdateDrag(VisualDraggableFeature &feature) {} virtual void CommitDrag(VisualDraggableFeature &feature) {} + virtual void DoRefresh() {} + public: int mouseX,mouseY; @@ -114,3 +136,4 @@ public: VisualTool(VideoDisplay *parent); virtual ~VisualTool(); }; + diff --git a/aegisub/visual_tool_drag.cpp b/aegisub/visual_tool_drag.cpp index 095c98e0d..4996b245e 100644 --- a/aegisub/visual_tool_drag.cpp +++ b/aegisub/visual_tool_drag.cpp @@ -48,19 +48,90 @@ #include "vfr.h" +/////// +// IDs +enum { + BUTTON_TOGGLE_MOVE = 1300 +}; + + /////////////// // Constructor -VisualToolDrag::VisualToolDrag(VideoDisplay *_parent) +VisualToolDrag::VisualToolDrag(VideoDisplay *_parent,wxSizer *toolbar,wxWindow *toolWindow) : VisualTool(_parent) { _parent->ShowCursor(false); + toggleMove = new wxBitmapButton(toolWindow,BUTTON_TOGGLE_MOVE,wxBITMAP(visual_move_conv_move),wxDefaultPosition); + ConnectButton(toggleMove); + toolbar->Add(toggleMove,0,wxEXPAND); + toolbar->AddStretchSpacer(1); + toggleMoveOnMove = true; + UpdateToggleButtons(); +} + + +///////////////////////// +// Update toggle buttons +void VisualToolDrag::UpdateToggleButtons() { + // Check which bitmap to use + bool toMove = true; + AssDialogue *line = GetActiveDialogueLine(); + if (line) { + int x1,y1,x2,y2,t1,t2; + bool hasMove; + GetLineMove(line,hasMove,x1,y1,x2,y2,t1,t2); + toMove = !hasMove; + } + + // No change needed + if (toMove == toggleMoveOnMove) return; + + // Change bitmap + if (toMove) toggleMove->SetBitmapLabel(wxBITMAP(visual_move_conv_move)); + else toggleMove->SetBitmapLabel(wxBITMAP(visual_move_conv_pos)); + toggleMoveOnMove = toMove; +} + + +///////////////////////// +// Toggle button pressed +void VisualToolDrag::OnButton(wxCommandEvent &event) { + // Get line + AssDialogue *line = GetActiveDialogueLine(); + if (!line) return; + + // Toggle \move <-> \pos + if (event.GetId() == BUTTON_TOGGLE_MOVE) { + // Get coordinates + int x1,y1,x2,y2,t1,t2; + bool hasMove; + GetLinePosition(line,x1,y1); + GetLineMove(line,hasMove,x1,y1,x2,y2,t1,t2); + + // Replace tag + if (hasMove) SetOverride(_T("\\pos"),wxString::Format(_T("(%i,%i)"),x1,y1)); + else SetOverride(_T("\\move"),wxString::Format(_T("(%i,%i,%i,%i,%i,%i)"),x1,y1,x1,y1,0,line->End.GetMS() - line->Start.GetMS())); + SubtitlesGrid *grid = VideoContext::Get()->grid; + grid->editBox->CommitText(); + grid->ass->FlagAsModified(_("visual typesetting")); + grid->CommitChanges(false,true); + + // Update display + Refresh(); + } +} + + +/////////// +// Refresh +void VisualToolDrag::DoRefresh() { + UpdateToggleButtons(); } ////////// // Update void VisualToolDrag::Update() { - // Render parent GetParent()->Render(); } diff --git a/aegisub/visual_tool_drag.h b/aegisub/visual_tool_drag.h index bcf4fe527..398568df6 100644 --- a/aegisub/visual_tool_drag.h +++ b/aegisub/visual_tool_drag.h @@ -46,14 +46,21 @@ // Drag tool class class VisualToolDrag : public VisualTool { private: + wxBitmapButton *toggleMove; + bool toggleMoveOnMove; + bool CanDrag() { return true; } void PopulateFeatureList(); void InitializeDrag(VisualDraggableFeature &feature); void UpdateDrag(VisualDraggableFeature &feature); void CommitDrag(VisualDraggableFeature &feature); + void OnButton(wxCommandEvent &event); + void UpdateToggleButtons(); + void DoRefresh(); + public: - VisualToolDrag(VideoDisplay *parent); + VisualToolDrag(VideoDisplay *parent,wxSizer *toolbar,wxWindow *toolWindow); void Update(); void Draw();