diff --git a/aegisub/src/video_context.h b/aegisub/src/video_context.h index 54fbd8e91..c64f3e02e 100644 --- a/aegisub/src/video_context.h +++ b/aegisub/src/video_context.h @@ -81,7 +81,6 @@ class SubtitlesProvider; /// DOCME class VideoContext : public wxEvtHandler { friend class AudioProvider; - friend class VisualTool; private: /// DOCME diff --git a/aegisub/src/video_display.h b/aegisub/src/video_display.h index 26b35283b..e6c2a451f 100644 --- a/aegisub/src/video_display.h +++ b/aegisub/src/video_display.h @@ -46,7 +46,7 @@ class VideoSlider; class VideoBox; class VideoOutGL; -class VisualTool; +class IVisualTool; struct VideoState { int x; @@ -132,7 +132,7 @@ class VideoDisplay: public wxGLCanvas { std::auto_ptr videoOut; /// The active visual typesetting tool - std::auto_ptr tool; + std::auto_ptr tool; /// The current tool's ID int activeMode; /// The toolbar used by individual typesetting tools diff --git a/aegisub/src/visual_feature.h b/aegisub/src/visual_feature.h index fade30fe4..659a650a0 100644 --- a/aegisub/src/visual_feature.h +++ b/aegisub/src/visual_feature.h @@ -34,6 +34,8 @@ /// @ingroup visual_ts /// +#pragma once + class OpenGLWrapper; class AssDialogue; diff --git a/aegisub/src/visual_tool.cpp b/aegisub/src/visual_tool.cpp index f04015288..c0de38151 100644 --- a/aegisub/src/visual_tool.cpp +++ b/aegisub/src/visual_tool.cpp @@ -59,13 +59,15 @@ #include "video_context.h" #include "video_display.h" #include "video_provider_manager.h" +#include "visual_feature.h" #include "visual_tool.h" -const wxColour VisualTool::colour[4] = {wxColour(106,32,19), wxColour(255,169,40), wxColour(255,253,185), wxColour(187,0,0)}; +const wxColour IVisualTool::colour[4] = {wxColour(106,32,19), wxColour(255,169,40), wxColour(255,253,185), wxColour(187,0,0)}; /// @brief Constructor /// @param parent -VisualTool::VisualTool(VideoDisplay *parent, VideoState const& video) +template +VisualTool::VisualTool(VideoDisplay *parent, VideoState const& video) : parent(parent) , holding(false) , curDiag(NULL) @@ -83,12 +85,14 @@ VisualTool::VisualTool(VideoDisplay *parent, VideoState const& video) } /// @brief Destructor -VisualTool::~VisualTool() { +template +VisualTool::~VisualTool() { } /// @brief Mouse event /// @param event -void VisualTool::OnMouseEvent (wxMouseEvent &event) { +template +void VisualTool::OnMouseEvent (wxMouseEvent &event) { bool realTime = Options.AsBool(L"Video Visual Realtime"); if (event.Leaving()) { @@ -203,7 +207,8 @@ void VisualTool::OnMouseEvent (wxMouseEvent &event) { /// @brief Commit /// @param full -void VisualTool::Commit(bool full) { +template +void VisualTool::Commit(bool full) { SubtitlesGrid *grid = VideoContext::Get()->grid; if (full) grid->ass->FlagAsModified(_("visual typesetting")); grid->CommitChanges(false,!full); @@ -212,7 +217,8 @@ void VisualTool::Commit(bool full) { /// @brief Get active dialogue line /// @return -AssDialogue* VisualTool::GetActiveDialogueLine() { +template +AssDialogue* VisualTool::GetActiveDialogueLine() { SubtitlesGrid *grid = VideoContext::Get()->grid; AssDialogue *diag = grid->GetDialogue(grid->editBox->linen); @@ -229,7 +235,8 @@ AssDialogue* VisualTool::GetActiveDialogueLine() { /// @brief Get feature under mouse /// @return -int VisualTool::GetHighlightedFeature() { +template +int VisualTool::GetHighlightedFeature() { int highestLayerFound = INT_MIN; int bestMatch = -1; for (size_t i=0;i +void VisualTool::DrawAllFeatures() { if (!dragListOK) { PopulateFeatureList(); dragListOK = true; @@ -259,7 +267,8 @@ void VisualTool::DrawAllFeatures() { } /// @brief Refresh -void VisualTool::Refresh() { +template +void VisualTool::Refresh() { frame_n = VideoContext::Get()->GetFrameN(); if (!dragging) dragListOK = false; DoRefresh(); @@ -269,7 +278,8 @@ void VisualTool::Refresh() { /// @param diag /// @param x /// @param y -void VisualTool::GetLinePosition(AssDialogue *diag,int &x, int &y) { +template +void VisualTool::GetLinePosition(AssDialogue *diag,int &x, int &y) { int orgx=0,orgy=0; GetLinePosition(diag,x,y,orgx,orgy); } @@ -280,7 +290,8 @@ void VisualTool::GetLinePosition(AssDialogue *diag,int &x, int &y) { /// @param y /// @param orgx /// @param orgy -void VisualTool::GetLinePosition(AssDialogue *diag,int &x, int &y, int &orgx, int &orgy) { +template +void VisualTool::GetLinePosition(AssDialogue *diag,int &x, int &y, int &orgx, int &orgy) { if (!diag) { x = INT_MIN; y = INT_MIN; @@ -399,7 +410,8 @@ void VisualTool::GetLinePosition(AssDialogue *diag,int &x, int &y, int &orgx, in /// @param y2 /// @param t1 /// @param t2 -void VisualTool::GetLineMove(AssDialogue *diag,bool &hasMove,int &x1,int &y1,int &x2,int &y2,int &t1,int &t2) { +template +void VisualTool::GetLineMove(AssDialogue *diag,bool &hasMove,int &x1,int &y1,int &x2,int &y2,int &t1,int &t2) { // Parse tags hasMove = false; diag->ParseASSTags(); @@ -443,7 +455,8 @@ void VisualTool::GetLineMove(AssDialogue *diag,bool &hasMove,int &x1,int &y1,int /// @param rx /// @param ry /// @param rz -void VisualTool::GetLineRotation(AssDialogue *diag,float &rx,float &ry,float &rz) { +template +void VisualTool::GetLineRotation(AssDialogue *diag,float &rx,float &ry,float &rz) { // Default values rx = ry = rz = 0.0f; @@ -483,7 +496,8 @@ void VisualTool::GetLineRotation(AssDialogue *diag,float &rx,float &ry,float &rz /// @param diag /// @param scalX /// @param scalY -void VisualTool::GetLineScale(AssDialogue *diag,float &scalX,float &scalY) { +template +void VisualTool::GetLineScale(AssDialogue *diag,float &scalX,float &scalY) { // Default values scalX = scalY = 100.0f; @@ -520,7 +534,8 @@ void VisualTool::GetLineScale(AssDialogue *diag,float &scalX,float &scalY) { /// @param x2 /// @param y2 /// @param inverse -void VisualTool::GetLineClip(AssDialogue *diag,int &x1,int &y1,int &x2,int &y2,bool &inverse) { +template +void VisualTool::GetLineClip(AssDialogue *diag,int &x1,int &y1,int &x2,int &y2,bool &inverse) { // Default values x1 = y1 = 0; int sw,sh; @@ -570,7 +585,8 @@ void VisualTool::GetLineClip(AssDialogue *diag,int &x1,int &y1,int &x2,int &y2,b /// @param diag /// @param scale /// @param inverse -wxString VisualTool::GetLineVectorClip(AssDialogue *diag,int &scale,bool &inverse) { +template +wxString VisualTool::GetLineVectorClip(AssDialogue *diag,int &scale,bool &inverse) { // Prepare overrides wxString result; scale = 1; @@ -615,7 +631,8 @@ wxString VisualTool::GetLineVectorClip(AssDialogue *diag,int &scale,bool &invers /// @brief Set override /// @param tag /// @param value -void VisualTool::SetOverride(AssDialogue* line, wxString tag, wxString value) { +template +void VisualTool::SetOverride(AssDialogue* line, wxString tag, wxString value) { if (!line) return; wxString removeTag; @@ -658,3 +675,5 @@ void VisualTool::SetOverride(AssDialogue* line, wxString tag, wxString value) { parent->SetFocus(); } + +template class VisualTool; diff --git a/aegisub/src/visual_tool.h b/aegisub/src/visual_tool.h index 63c3f4828..5738ec3aa 100644 --- a/aegisub/src/visual_tool.h +++ b/aegisub/src/visual_tool.h @@ -45,26 +45,36 @@ #endif #include "gl_wrap.h" -#include "visual_feature.h" -////////////// -// Prototypes class VideoDisplay; class AssDialogue; -class VisualTool; struct VideoState; -/// DOCME +/// First window id for visualsubtoolbar items #define VISUAL_SUB_TOOL_START 1300 -/// DOCME +/// Last window id for visualsubtoolbar items #define VISUAL_SUB_TOOL_END (VISUAL_SUB_TOOL_START+100) +class IVisualTool : public OpenGLWrapper { +protected: + /// DOCME + static const wxColour colour[4]; +public: + virtual void OnMouseEvent(wxMouseEvent &event)=0; + virtual void OnSubTool(wxCommandEvent &)=0; + virtual void Update()=0; + virtual void Draw()=0; + virtual void Refresh()=0; + virtual ~IVisualTool() { }; +}; + /// DOCME /// @class VisualTool /// @brief DOCME /// DOCME -class VisualTool : public OpenGLWrapper { +template +class VisualTool : public IVisualTool { private: /// DOCME @@ -79,9 +89,6 @@ protected: /// DOCME VideoDisplay *parent; - /// DOCME - static const wxColour colour[4]; - /// DOCME bool holding; @@ -95,7 +102,7 @@ protected: int curFeature; /// DOCME - std::vector features; + std::vector features; /// DOCME bool dragListOK; @@ -153,17 +160,17 @@ protected: /// @brief DOCME /// @param feature /// - virtual bool InitializeDrag(VisualDraggableFeature &feature) { return true; } + virtual bool InitializeDrag(FeatureType &feature) { return true; } /// @brief DOCME /// @param feature /// - virtual void UpdateDrag(VisualDraggableFeature &feature) {} + virtual void UpdateDrag(FeatureType &feature) {} /// @brief DOCME /// @param feature /// - virtual void CommitDrag(VisualDraggableFeature &feature) {} + virtual void CommitDrag(FeatureType &feature) {} /// @brief DOCME /// diff --git a/aegisub/src/visual_tool_clip.h b/aegisub/src/visual_tool_clip.h index 4631ffcea..53eb324bc 100644 --- a/aegisub/src/visual_tool_clip.h +++ b/aegisub/src/visual_tool_clip.h @@ -34,20 +34,15 @@ /// @ingroup visual_ts /// - - - -/////////// -// Headers +#include "visual_feature.h" #include "visual_tool.h" - /// DOCME /// @class VisualToolClip /// @brief DOCME /// /// DOCME -class VisualToolClip : public VisualTool { +class VisualToolClip : public VisualTool { private: /// DOCME diff --git a/aegisub/src/visual_tool_cross.h b/aegisub/src/visual_tool_cross.h index 2578a8d8d..f67b25fde 100644 --- a/aegisub/src/visual_tool_cross.h +++ b/aegisub/src/visual_tool_cross.h @@ -34,11 +34,7 @@ /// @ingroup visual_ts /// - - - -/////////// -// Headers +#include "visual_feature.h" #include "visual_tool.h" @@ -47,7 +43,7 @@ /// @brief DOCME /// /// DOCME -class VisualToolCross : public VisualTool { +class VisualToolCross : public VisualTool { public: VisualToolCross(VideoDisplay *parent, VideoState const& video, wxToolBar *); ~VisualToolCross(); diff --git a/aegisub/src/visual_tool_drag.h b/aegisub/src/visual_tool_drag.h index e8fe72a07..8ecf90976 100644 --- a/aegisub/src/visual_tool_drag.h +++ b/aegisub/src/visual_tool_drag.h @@ -39,6 +39,7 @@ #include #endif +#include "visual_feature.h" #include "visual_tool.h" @@ -47,7 +48,7 @@ /// @brief DOCME /// /// DOCME -class VisualToolDrag : public VisualTool { +class VisualToolDrag : public VisualTool { private: /// DOCME wxToolBar *toolBar; diff --git a/aegisub/src/visual_tool_rotatexy.h b/aegisub/src/visual_tool_rotatexy.h index ce56de478..f389dbfb2 100644 --- a/aegisub/src/visual_tool_rotatexy.h +++ b/aegisub/src/visual_tool_rotatexy.h @@ -34,12 +34,13 @@ /// @ingroup visual_ts /// +#include "visual_feature.h" #include "visual_tool.h" /// DOCME /// @class VisualToolRotateXY /// @brief DOCME -class VisualToolRotateXY : public VisualTool { +class VisualToolRotateXY : public VisualTool { private: /// DOCME diff --git a/aegisub/src/visual_tool_rotatez.h b/aegisub/src/visual_tool_rotatez.h index d23483dfa..0b13ff6d3 100644 --- a/aegisub/src/visual_tool_rotatez.h +++ b/aegisub/src/visual_tool_rotatez.h @@ -34,6 +34,7 @@ /// @ingroup visual_ts /// +#include "visual_feature.h" #include "visual_tool.h" @@ -42,7 +43,7 @@ /// @brief DOCME /// /// DOCME -class VisualToolRotateZ : public VisualTool { +class VisualToolRotateZ : public VisualTool { private: /// DOCME diff --git a/aegisub/src/visual_tool_scale.h b/aegisub/src/visual_tool_scale.h index cccb51672..167348e04 100644 --- a/aegisub/src/visual_tool_scale.h +++ b/aegisub/src/visual_tool_scale.h @@ -34,12 +34,13 @@ /// @ingroup visual_ts /// +#include "visual_feature.h" #include "visual_tool.h" /// DOCME /// @class VisualToolScale /// @brief DOCME -class VisualToolScale : public VisualTool { +class VisualToolScale : public VisualTool { private: /// DOCME diff --git a/aegisub/src/visual_tool_vector_clip.h b/aegisub/src/visual_tool_vector_clip.h index 71dadfbc5..1736ef4dd 100644 --- a/aegisub/src/visual_tool_vector_clip.h +++ b/aegisub/src/visual_tool_vector_clip.h @@ -34,6 +34,7 @@ /// @ingroup visual_ts /// +#include "visual_feature.h" #include "visual_tool.h" #include "spline.h" @@ -42,7 +43,7 @@ class wxToolBar; /// DOCME /// @class VisualToolVectorClip /// @brief DOCME -class VisualToolVectorClip : public VisualTool { +class VisualToolVectorClip : public VisualTool { private: /// DOCME