Kill the redundant VisualToolEvent nonsense and make the drag tool just use OnSubTool like the vector clip mode.

Originally committed to SVN as r4316.
This commit is contained in:
Thomas Goyne 2010-05-20 08:55:23 +00:00
parent 2ec4a97dbb
commit 34a7d21a42
4 changed files with 13 additions and 82 deletions

View File

@ -71,7 +71,6 @@ const wxColour VisualTool::colour[4] = {wxColour(106,32,19), wxColour(255,169,40
/// @param parent /// @param parent
VisualTool::VisualTool(VideoDisplay *parent, VideoState const& video) VisualTool::VisualTool(VideoDisplay *parent, VideoState const& video)
: parent(parent) : parent(parent)
, eventSink(this)
, holding(false) , holding(false)
, curDiag(NULL) , curDiag(NULL)
, dragging(false) , dragging(false)
@ -692,21 +691,3 @@ void VisualTool::SetOverride(wxString tag,wxString value) {
VideoContext::Get()->grid->editBox->SetOverride(tag,value,0,false); VideoContext::Get()->grid->editBox->SetOverride(tag,value,0,false);
//parent->SetFocus(); //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);
}

View File

@ -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 /// DOCME
/// @class VisualTool /// @class VisualTool
/// @brief DOCME /// @brief DOCME
/// ///
/// DOCME /// DOCME
class VisualTool : public OpenGLWrapper { class VisualTool : public OpenGLWrapper {
friend class VisualToolEvent;
private:
/// DOCME
VisualToolEvent eventSink;
int GetHighlightedFeature(); int GetHighlightedFeature();
protected: protected:
/// DOCME /// DOCME
@ -173,15 +148,6 @@ protected:
void DrawAllFeatures(); void DrawAllFeatures();
void Commit(bool full=false); void Commit(bool full=false);
void ConnectButton(wxButton *button);
/// @brief DOCME
/// @param event
/// @return
///
virtual void OnButton(wxCommandEvent &event) {}
/// @brief DOCME /// @brief DOCME
/// @return /// @return
/// ///

View File

@ -34,9 +34,6 @@
/// @ingroup visual_ts /// @ingroup visual_ts
/// ///
///////////
// Headers
#include "config.h" #include "config.h"
#include "ass_dialogue.h" #include "ass_dialogue.h"
@ -50,12 +47,7 @@
#include "video_display.h" #include "video_display.h"
#include "visual_tool_drag.h" #include "visual_tool_drag.h"
///////
// IDs
enum { enum {
/// DOCME
BUTTON_TOGGLE_MOVE = VISUAL_SUB_TOOL_START BUTTON_TOGGLE_MOVE = VISUAL_SUB_TOOL_START
}; };
@ -67,11 +59,10 @@ enum {
/// ///
VisualToolDrag::VisualToolDrag(VideoDisplay *parent, VideoState const& video, wxToolBar * toolBar) VisualToolDrag::VisualToolDrag(VideoDisplay *parent, VideoState const& video, wxToolBar * toolBar)
: VisualTool(parent, video) : VisualTool(parent, video)
, toolBar(toolBar)
, toggleMoveOnMove(true)
{ {
toggleMove = new wxBitmapButton(toolBar,BUTTON_TOGGLE_MOVE,GETIMAGE(visual_move_conv_move_24),wxDefaultPosition); toolBar->AddTool(BUTTON_TOGGLE_MOVE, _("Toggle between \\move and \\pos"), GETIMAGE(visual_move_conv_move_24));
ConnectButton(toggleMove);
toolBar->AddControl(toggleMove);
toggleMoveOnMove = true;
toolBar->Realize(); toolBar->Realize();
toolBar->Show(true); toolBar->Show(true);
} }
@ -96,8 +87,12 @@ void VisualToolDrag::UpdateToggleButtons() {
if (toMove == toggleMoveOnMove) return; if (toMove == toggleMoveOnMove) return;
// Change bitmap // Change bitmap
if (toMove) toggleMove->SetBitmapLabel(GETIMAGE(visual_move_conv_move_24)); if (toMove) {
else toggleMove->SetBitmapLabel(GETIMAGE(visual_move_conv_pos_24)); 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; toggleMoveOnMove = toMove;
} }
@ -106,8 +101,7 @@ void VisualToolDrag::UpdateToggleButtons() {
/// @brief Toggle button pressed /// @brief Toggle button pressed
/// @param event /// @param event
/// @return /// @return
/// void VisualToolDrag::OnSubTool(wxCommandEvent &event) {
void VisualToolDrag::OnButton(wxCommandEvent &event) {
// Get line // Get line
AssDialogue *line = GetActiveDialogueLine(); AssDialogue *line = GetActiveDialogueLine();
if (!line) return; if (!line) return;
@ -125,10 +119,7 @@ void VisualToolDrag::OnButton(wxCommandEvent &event) {
// Replace tag // Replace tag
if (hasMove) SetOverride(L"\\pos",wxString::Format(L"(%i,%i)",x1,y1)); 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())); 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; Commit(true);
grid->editBox->CommitText();
grid->ass->FlagAsModified(_("visual typesetting"));
grid->CommitChanges(false,true);
// Update display // Update display
Refresh(); Refresh();

View File

@ -34,11 +34,6 @@
/// @ingroup visual_ts /// @ingroup visual_ts
/// ///
///////////
// Headers
#ifndef AGI_PRE #ifndef AGI_PRE
#include <wx/bmpbuttn.h> #include <wx/bmpbuttn.h>
#include <wx/toolbar.h> #include <wx/toolbar.h>
@ -54,14 +49,12 @@
/// DOCME /// DOCME
class VisualToolDrag : public VisualTool { class VisualToolDrag : public VisualTool {
private: private:
/// DOCME /// DOCME
wxBitmapButton *toggleMove; wxToolBar *toolBar;
/// DOCME /// DOCME
bool toggleMoveOnMove; bool toggleMoveOnMove;
/// @brief DOCME /// @brief DOCME
/// ///
bool CanDrag() { return true; } bool CanDrag() { return true; }
@ -69,7 +62,6 @@ private:
void UpdateDrag(VisualDraggableFeature &feature); void UpdateDrag(VisualDraggableFeature &feature);
void CommitDrag(VisualDraggableFeature &feature); void CommitDrag(VisualDraggableFeature &feature);
void OnButton(wxCommandEvent &event);
void UpdateToggleButtons(); void UpdateToggleButtons();
void DoRefresh(); void DoRefresh();
@ -77,4 +69,5 @@ public:
VisualToolDrag(VideoDisplay *parent, VideoState const& video, wxToolBar *toolbar); VisualToolDrag(VideoDisplay *parent, VideoState const& video, wxToolBar *toolbar);
void Draw(); void Draw();
void OnSubTool(wxCommandEvent &event);
}; };