From 34a7d21a428d5fca754ae210ce214ca8ad74d67c Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Thu, 20 May 2010 08:55:23 +0000 Subject: [PATCH] Kill the redundant VisualToolEvent nonsense and make the drag tool just use OnSubTool like the vector clip mode. Originally committed to SVN as r4316. --- aegisub/src/visual_tool.cpp | 19 ------------------ aegisub/src/visual_tool.h | 34 -------------------------------- aegisub/src/visual_tool_drag.cpp | 31 +++++++++++------------------ aegisub/src/visual_tool_drag.h | 11 ++--------- 4 files changed, 13 insertions(+), 82 deletions(-) diff --git a/aegisub/src/visual_tool.cpp b/aegisub/src/visual_tool.cpp index f4bfdb354..e20e22108 100644 --- a/aegisub/src/visual_tool.cpp +++ b/aegisub/src/visual_tool.cpp @@ -71,7 +71,6 @@ const wxColour VisualTool::colour[4] = {wxColour(106,32,19), wxColour(255,169,40 /// @param parent VisualTool::VisualTool(VideoDisplay *parent, VideoState const& video) : parent(parent) -, eventSink(this) , holding(false) , curDiag(NULL) , dragging(false) @@ -692,21 +691,3 @@ void VisualTool::SetOverride(wxString tag,wxString value) { VideoContext::Get()->grid->editBox->SetOverride(tag,value,0,false); //parent->SetFocus(); } - -/// @brief Connect button -/// @param button -void VisualTool::ConnectButton(wxButton *button) { - button->Connect(wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(VisualToolEvent::OnButton),NULL,&eventSink); -} - -/// @brief Event sink -/// @param _tool -VisualToolEvent::VisualToolEvent(VisualTool *_tool) { - tool = _tool; -} - -/// @brief DOCME -/// @param event -void VisualToolEvent::OnButton(wxCommandEvent &event) { - tool->OnButton(event); -} diff --git a/aegisub/src/visual_tool.h b/aegisub/src/visual_tool.h index 63bc712b3..7d9e4a14a 100644 --- a/aegisub/src/visual_tool.h +++ b/aegisub/src/visual_tool.h @@ -69,37 +69,12 @@ struct VideoState; -/// DOCME -/// @class VisualToolEvent -/// @brief DOCME -/// -/// DOCME -class VisualToolEvent : public wxEvtHandler { -private: - - /// DOCME - VisualTool *tool; - -public: - void OnButton(wxCommandEvent &event); - - VisualToolEvent(VisualTool *tool); -}; - - - /// DOCME /// @class VisualTool /// @brief DOCME /// /// DOCME class VisualTool : public OpenGLWrapper { - friend class VisualToolEvent; - -private: - /// DOCME - VisualToolEvent eventSink; - int GetHighlightedFeature(); protected: /// DOCME @@ -173,15 +148,6 @@ protected: void DrawAllFeatures(); void Commit(bool full=false); - void ConnectButton(wxButton *button); - - /// @brief DOCME - /// @param event - /// @return - /// - virtual void OnButton(wxCommandEvent &event) {} - - /// @brief DOCME /// @return /// diff --git a/aegisub/src/visual_tool_drag.cpp b/aegisub/src/visual_tool_drag.cpp index e77081143..c63e81f4a 100644 --- a/aegisub/src/visual_tool_drag.cpp +++ b/aegisub/src/visual_tool_drag.cpp @@ -34,9 +34,6 @@ /// @ingroup visual_ts /// - -/////////// -// Headers #include "config.h" #include "ass_dialogue.h" @@ -50,12 +47,7 @@ #include "video_display.h" #include "visual_tool_drag.h" - -/////// -// IDs enum { - - /// DOCME BUTTON_TOGGLE_MOVE = VISUAL_SUB_TOOL_START }; @@ -67,11 +59,10 @@ enum { /// VisualToolDrag::VisualToolDrag(VideoDisplay *parent, VideoState const& video, wxToolBar * toolBar) : VisualTool(parent, video) +, toolBar(toolBar) +, toggleMoveOnMove(true) { - toggleMove = new wxBitmapButton(toolBar,BUTTON_TOGGLE_MOVE,GETIMAGE(visual_move_conv_move_24),wxDefaultPosition); - ConnectButton(toggleMove); - toolBar->AddControl(toggleMove); - toggleMoveOnMove = true; + toolBar->AddTool(BUTTON_TOGGLE_MOVE, _("Toggle between \\move and \\pos"), GETIMAGE(visual_move_conv_move_24)); toolBar->Realize(); toolBar->Show(true); } @@ -96,8 +87,12 @@ void VisualToolDrag::UpdateToggleButtons() { if (toMove == toggleMoveOnMove) return; // Change bitmap - if (toMove) toggleMove->SetBitmapLabel(GETIMAGE(visual_move_conv_move_24)); - else toggleMove->SetBitmapLabel(GETIMAGE(visual_move_conv_pos_24)); + if (toMove) { + toolBar->SetToolNormalBitmap(BUTTON_TOGGLE_MOVE, GETIMAGE(visual_move_conv_move_24)); + } + else { + toolBar->SetToolNormalBitmap(BUTTON_TOGGLE_MOVE, GETIMAGE(visual_move_conv_pos_24)); + } toggleMoveOnMove = toMove; } @@ -106,8 +101,7 @@ void VisualToolDrag::UpdateToggleButtons() { /// @brief Toggle button pressed /// @param event /// @return -/// -void VisualToolDrag::OnButton(wxCommandEvent &event) { +void VisualToolDrag::OnSubTool(wxCommandEvent &event) { // Get line AssDialogue *line = GetActiveDialogueLine(); if (!line) return; @@ -125,10 +119,7 @@ void VisualToolDrag::OnButton(wxCommandEvent &event) { // Replace tag if (hasMove) SetOverride(L"\\pos",wxString::Format(L"(%i,%i)",x1,y1)); else SetOverride(L"\\move",wxString::Format(L"(%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); + Commit(true); // Update display Refresh(); diff --git a/aegisub/src/visual_tool_drag.h b/aegisub/src/visual_tool_drag.h index d8be85ee8..e8fe72a07 100644 --- a/aegisub/src/visual_tool_drag.h +++ b/aegisub/src/visual_tool_drag.h @@ -34,11 +34,6 @@ /// @ingroup visual_ts /// - - - -/////////// -// Headers #ifndef AGI_PRE #include #include @@ -54,14 +49,12 @@ /// DOCME class VisualToolDrag : public VisualTool { private: - /// DOCME - wxBitmapButton *toggleMove; + wxToolBar *toolBar; /// DOCME bool toggleMoveOnMove; - /// @brief DOCME /// bool CanDrag() { return true; } @@ -69,7 +62,6 @@ private: void UpdateDrag(VisualDraggableFeature &feature); void CommitDrag(VisualDraggableFeature &feature); - void OnButton(wxCommandEvent &event); void UpdateToggleButtons(); void DoRefresh(); @@ -77,4 +69,5 @@ public: VisualToolDrag(VideoDisplay *parent, VideoState const& video, wxToolBar *toolbar); void Draw(); + void OnSubTool(wxCommandEvent &event); };