2007-01-08 22:11:06 +01:00
|
|
|
// Copyright (c) 2007, Rodrigo Braz Monteiro
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer in the documentation
|
|
|
|
// and/or other materials provided with the distribution.
|
|
|
|
// * Neither the name of the Aegisub Group nor the names of its contributors
|
|
|
|
// may be used to endorse or promote products derived from this software
|
|
|
|
// without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
// POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
//
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// AEGISUB
|
|
|
|
//
|
|
|
|
// Website: http://aegisub.cellosoft.com
|
|
|
|
// Contact: mailto:zeratul@cellosoft.com
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
2007-01-21 07:30:19 +01:00
|
|
|
///////////
|
|
|
|
// Headers
|
2007-07-01 09:09:37 +02:00
|
|
|
#include <vector>
|
2007-07-01 02:19:55 +02:00
|
|
|
#include "video_display.h"
|
2007-01-21 07:30:19 +01:00
|
|
|
#include "gl_wrap.h"
|
2007-07-01 09:09:37 +02:00
|
|
|
#include "visual_feature.h"
|
2007-01-21 07:30:19 +01:00
|
|
|
|
|
|
|
|
2007-01-08 22:11:06 +01:00
|
|
|
//////////////
|
|
|
|
// Prototypes
|
|
|
|
class VideoDisplay;
|
|
|
|
class AssDialogue;
|
2007-07-04 06:24:47 +02:00
|
|
|
class VisualTool;
|
|
|
|
|
|
|
|
|
2007-07-07 07:51:18 +02:00
|
|
|
/////////////////////////
|
|
|
|
// Visual sub tool range
|
|
|
|
#define VISUAL_SUB_TOOL_START 1300
|
|
|
|
#define VISUAL_SUB_TOOL_END (VISUAL_SUB_TOOL_START+100)
|
|
|
|
|
|
|
|
|
2007-07-04 06:24:47 +02:00
|
|
|
////////////////////
|
|
|
|
// Event sink class
|
|
|
|
class VisualToolEvent : public wxEvtHandler {
|
|
|
|
private:
|
|
|
|
VisualTool *tool;
|
|
|
|
|
|
|
|
public:
|
|
|
|
void OnButton(wxCommandEvent &event);
|
|
|
|
|
|
|
|
VisualToolEvent(VisualTool *tool);
|
|
|
|
};
|
2007-01-08 22:11:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
////////////////////////
|
|
|
|
// Visual handler class
|
2007-07-01 02:19:55 +02:00
|
|
|
class VisualTool : public OpenGLWrapper {
|
2007-07-04 06:24:47 +02:00
|
|
|
friend class VisualToolEvent;
|
|
|
|
|
2007-01-08 22:11:06 +01:00
|
|
|
private:
|
2007-07-01 02:19:55 +02:00
|
|
|
VideoDisplay *parent;
|
2007-07-04 06:24:47 +02:00
|
|
|
VisualToolEvent eventSink;
|
2007-07-01 02:19:55 +02:00
|
|
|
|
|
|
|
protected:
|
2007-01-09 07:25:25 +01:00
|
|
|
wxColour colour[4];
|
|
|
|
|
2007-07-01 04:23:57 +02:00
|
|
|
bool holding;
|
|
|
|
AssDialogue *curDiag;
|
|
|
|
|
2007-07-01 09:09:37 +02:00
|
|
|
bool dragging;
|
|
|
|
int curFeature;
|
|
|
|
std::vector<VisualDraggableFeature> features;
|
|
|
|
int dragStartX,dragStartY,dragOrigX,dragOrigY;
|
|
|
|
bool dragListOK;
|
|
|
|
|
2007-07-01 02:19:55 +02:00
|
|
|
int w,h,sw,sh,mx,my;
|
|
|
|
int frame_n;
|
2007-01-08 22:11:06 +01:00
|
|
|
|
2007-07-01 02:19:55 +02:00
|
|
|
bool leftClick;
|
|
|
|
bool leftDClick;
|
2007-07-01 04:23:57 +02:00
|
|
|
bool shiftDown;
|
|
|
|
bool ctrlDown;
|
|
|
|
bool altDown;
|
2007-06-30 23:56:15 +02:00
|
|
|
|
2007-01-08 22:11:06 +01:00
|
|
|
void GetLinePosition(AssDialogue *diag,int &x,int &y);
|
2007-01-09 07:25:25 +01:00
|
|
|
void GetLinePosition(AssDialogue *diag,int &x,int &y,int &orgx,int &orgy);
|
2007-07-04 02:36:04 +02:00
|
|
|
void GetLineMove(AssDialogue *diag,bool &hasMove,int &x1,int &y1,int &x2,int &y2,int &t1,int &t2);
|
2007-01-09 07:25:25 +01:00
|
|
|
void GetLineRotation(AssDialogue *diag,float &rx,float &ry,float &rz);
|
2007-01-10 22:01:47 +01:00
|
|
|
void GetLineScale(AssDialogue *diag,float &scalX,float &scalY);
|
2007-01-10 22:53:00 +01:00
|
|
|
void GetLineClip(AssDialogue *diag,int &x1,int &y1,int &x2,int &y2);
|
2007-07-05 06:32:46 +02:00
|
|
|
wxString GetLineVectorClip(AssDialogue *diag,int &scale);
|
2007-07-01 02:19:55 +02:00
|
|
|
void FillPositionData();
|
2007-07-01 05:57:34 +02:00
|
|
|
void SetOverride(wxString tag,wxString value);
|
2007-01-10 22:01:47 +01:00
|
|
|
|
2007-07-01 02:19:55 +02:00
|
|
|
VideoDisplay *GetParent() { return parent; }
|
2007-07-01 09:09:37 +02:00
|
|
|
AssDialogue *GetActiveDialogueLine();
|
|
|
|
int GetHighlightedFeature();
|
|
|
|
void DrawAllFeatures();
|
2007-07-07 09:27:28 +02:00
|
|
|
void Commit(bool full=false);
|
2007-01-08 22:11:06 +01:00
|
|
|
|
2007-07-04 06:24:47 +02:00
|
|
|
void ConnectButton(wxButton *button);
|
|
|
|
virtual void OnButton(wxCommandEvent &event) {}
|
|
|
|
|
2007-07-01 04:23:57 +02:00
|
|
|
virtual bool CanHold() { return false; }
|
2007-07-07 07:51:18 +02:00
|
|
|
virtual bool HoldEnabled() { return true; }
|
2007-07-01 04:23:57 +02:00
|
|
|
virtual void InitializeHold() {}
|
|
|
|
virtual void UpdateHold() {}
|
|
|
|
virtual void CommitHold() {}
|
|
|
|
|
2007-07-01 09:09:37 +02:00
|
|
|
virtual bool CanDrag() { return false; }
|
2007-07-07 07:51:18 +02:00
|
|
|
virtual bool DragEnabled() { return true; }
|
2007-07-01 09:09:37 +02:00
|
|
|
virtual void PopulateFeatureList() { wxLogMessage(_T("wtf?")); }
|
|
|
|
virtual void InitializeDrag(VisualDraggableFeature &feature) {}
|
|
|
|
virtual void UpdateDrag(VisualDraggableFeature &feature) {}
|
|
|
|
virtual void CommitDrag(VisualDraggableFeature &feature) {}
|
2007-07-07 07:51:18 +02:00
|
|
|
virtual void ClickedFeature(VisualDraggableFeature &feature) {}
|
2007-07-01 09:09:37 +02:00
|
|
|
|
2007-07-04 06:24:47 +02:00
|
|
|
virtual void DoRefresh() {}
|
|
|
|
|
2007-01-08 22:11:06 +01:00
|
|
|
public:
|
2007-07-01 02:19:55 +02:00
|
|
|
int mouseX,mouseY;
|
|
|
|
|
|
|
|
void OnMouseEvent(wxMouseEvent &event);
|
2007-07-07 07:51:18 +02:00
|
|
|
virtual void OnSubTool(wxCommandEvent &event) {}
|
2007-07-01 02:19:55 +02:00
|
|
|
virtual void Update()=0;
|
|
|
|
virtual void Draw()=0;
|
2007-07-01 09:09:37 +02:00
|
|
|
void Refresh();
|
2007-01-11 07:15:56 +01:00
|
|
|
|
2007-07-01 02:19:55 +02:00
|
|
|
VisualTool(VideoDisplay *parent);
|
|
|
|
virtual ~VisualTool();
|
2007-01-08 22:11:06 +01:00
|
|
|
};
|
2007-07-04 06:24:47 +02:00
|
|
|
|