forked from mia/Aegisub
Template VisualTool on the type of draggable features to use
Originally committed to SVN as r4320.
This commit is contained in:
parent
2ef8302a6d
commit
a282393b47
12 changed files with 75 additions and 52 deletions
|
@ -81,7 +81,6 @@ class SubtitlesProvider;
|
|||
/// DOCME
|
||||
class VideoContext : public wxEvtHandler {
|
||||
friend class AudioProvider;
|
||||
friend class VisualTool;
|
||||
|
||||
private:
|
||||
/// DOCME
|
||||
|
|
|
@ -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<VideoOutGL> videoOut;
|
||||
|
||||
/// The active visual typesetting tool
|
||||
std::auto_ptr<VisualTool> tool;
|
||||
std::auto_ptr<IVisualTool> tool;
|
||||
/// The current tool's ID
|
||||
int activeMode;
|
||||
/// The toolbar used by individual typesetting tools
|
||||
|
|
|
@ -34,6 +34,8 @@
|
|||
/// @ingroup visual_ts
|
||||
///
|
||||
|
||||
#pragma once
|
||||
|
||||
class OpenGLWrapper;
|
||||
class AssDialogue;
|
||||
|
||||
|
|
|
@ -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<class FeatureType>
|
||||
VisualTool<FeatureType>::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<class FeatureType>
|
||||
VisualTool<FeatureType>::~VisualTool() {
|
||||
}
|
||||
|
||||
/// @brief Mouse event
|
||||
/// @param event
|
||||
void VisualTool::OnMouseEvent (wxMouseEvent &event) {
|
||||
template<class FeatureType>
|
||||
void VisualTool<FeatureType>::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<class FeatureType>
|
||||
void VisualTool<FeatureType>::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<class FeatureType>
|
||||
AssDialogue* VisualTool<FeatureType>::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<class FeatureType>
|
||||
int VisualTool<FeatureType>::GetHighlightedFeature() {
|
||||
int highestLayerFound = INT_MIN;
|
||||
int bestMatch = -1;
|
||||
for (size_t i=0;i<features.size();i++) {
|
||||
|
@ -242,7 +249,8 @@ int VisualTool::GetHighlightedFeature() {
|
|||
}
|
||||
|
||||
/// @brief Draw all features
|
||||
void VisualTool::DrawAllFeatures() {
|
||||
template<class FeatureType>
|
||||
void VisualTool<FeatureType>::DrawAllFeatures() {
|
||||
if (!dragListOK) {
|
||||
PopulateFeatureList();
|
||||
dragListOK = true;
|
||||
|
@ -259,7 +267,8 @@ void VisualTool::DrawAllFeatures() {
|
|||
}
|
||||
|
||||
/// @brief Refresh
|
||||
void VisualTool::Refresh() {
|
||||
template<class FeatureType>
|
||||
void VisualTool<FeatureType>::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<class FeatureType>
|
||||
void VisualTool<FeatureType>::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<class FeatureType>
|
||||
void VisualTool<FeatureType>::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<class FeatureType>
|
||||
void VisualTool<FeatureType>::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<class FeatureType>
|
||||
void VisualTool<FeatureType>::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<class FeatureType>
|
||||
void VisualTool<FeatureType>::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<class FeatureType>
|
||||
void VisualTool<FeatureType>::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<class FeatureType>
|
||||
wxString VisualTool<FeatureType>::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<class FeatureType>
|
||||
void VisualTool<FeatureType>::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<VisualDraggableFeature>;
|
||||
|
|
|
@ -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 FeatureType>
|
||||
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<VisualDraggableFeature> features;
|
||||
std::vector<FeatureType> 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
|
||||
///
|
||||
|
|
|
@ -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<VisualDraggableFeature> {
|
||||
private:
|
||||
|
||||
/// DOCME
|
||||
|
|
|
@ -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<VisualDraggableFeature> {
|
||||
public:
|
||||
VisualToolCross(VideoDisplay *parent, VideoState const& video, wxToolBar *);
|
||||
~VisualToolCross();
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include <wx/toolbar.h>
|
||||
#endif
|
||||
|
||||
#include "visual_feature.h"
|
||||
#include "visual_tool.h"
|
||||
|
||||
|
||||
|
@ -47,7 +48,7 @@
|
|||
/// @brief DOCME
|
||||
///
|
||||
/// DOCME
|
||||
class VisualToolDrag : public VisualTool {
|
||||
class VisualToolDrag : public VisualTool<VisualDraggableFeature> {
|
||||
private:
|
||||
/// DOCME
|
||||
wxToolBar *toolBar;
|
||||
|
|
|
@ -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<VisualDraggableFeature> {
|
||||
private:
|
||||
|
||||
/// DOCME
|
||||
|
|
|
@ -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<VisualDraggableFeature> {
|
||||
private:
|
||||
|
||||
/// DOCME
|
||||
|
|
|
@ -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<VisualDraggableFeature> {
|
||||
private:
|
||||
|
||||
/// DOCME
|
||||
|
|
|
@ -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<VisualDraggableFeature> {
|
||||
private:
|
||||
|
||||
/// DOCME
|
||||
|
|
Loading…
Reference in a new issue