2007-01-08 22:11:06 +01:00
|
|
|
// Copyright (c) 2005-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
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
//////////////
|
|
|
|
// Headers
|
2007-01-21 07:30:19 +01:00
|
|
|
#include <wx/glcanvas.h>
|
|
|
|
#include <GL/glu.h>
|
2007-01-08 22:11:06 +01:00
|
|
|
#include <wx/wxprec.h>
|
|
|
|
#include "video_display_visual.h"
|
|
|
|
#include "video_display.h"
|
|
|
|
#include "video_provider.h"
|
|
|
|
#include "vfr.h"
|
|
|
|
#include "ass_file.h"
|
|
|
|
#include "ass_time.h"
|
|
|
|
#include "ass_dialogue.h"
|
2007-01-09 02:52:30 +01:00
|
|
|
#include "ass_override.h"
|
2007-01-08 22:11:06 +01:00
|
|
|
#include "ass_style.h"
|
|
|
|
#include "subs_grid.h"
|
|
|
|
#include "options.h"
|
|
|
|
#include "subs_edit_box.h"
|
2007-01-09 02:52:30 +01:00
|
|
|
#include "export_visible_lines.h"
|
2007-01-10 05:33:03 +01:00
|
|
|
#include "utils.h"
|
2007-04-13 05:52:25 +02:00
|
|
|
#include "gl_text.h"
|
2007-01-08 22:11:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
///////////////
|
|
|
|
// Constructor
|
|
|
|
VideoDisplayVisual::VideoDisplayVisual(VideoDisplay *par) {
|
|
|
|
parent = par;
|
2007-01-09 02:52:30 +01:00
|
|
|
curSelection = NULL;
|
2007-01-08 22:11:06 +01:00
|
|
|
holding = false;
|
2007-01-09 02:52:30 +01:00
|
|
|
mode = -1;
|
|
|
|
SetMode(0);
|
2007-01-09 07:25:25 +01:00
|
|
|
colour[0] = wxColour(27,60,114);
|
2007-06-29 01:11:10 +02:00
|
|
|
//colour[1] = wxColour(175,219,254);
|
|
|
|
colour[1] = wxColour(166,247,177);
|
2007-01-09 07:25:25 +01:00
|
|
|
colour[2] = wxColour(255,255,255);
|
|
|
|
colour[3] = wxColour(187,0,0);
|
2007-01-08 22:11:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////
|
|
|
|
// Destructor
|
|
|
|
VideoDisplayVisual::~VideoDisplayVisual() {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-01-09 02:52:30 +01:00
|
|
|
////////////
|
|
|
|
// Set mode
|
|
|
|
void VideoDisplayVisual::SetMode(int _mode) {
|
|
|
|
// Set mode
|
|
|
|
mode = _mode;
|
|
|
|
|
2007-04-18 06:51:17 +02:00
|
|
|
// Display cursor or not
|
|
|
|
parent->ShowCursor(mode != 0);
|
2007-06-29 00:27:33 +02:00
|
|
|
|
|
|
|
// Refresh parent
|
|
|
|
parent->Render();
|
2007-01-09 02:52:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-01-08 22:11:06 +01:00
|
|
|
////////////////
|
|
|
|
// Draw overlay
|
|
|
|
void VideoDisplayVisual::DrawOverlay() {
|
|
|
|
// Variables
|
2007-01-21 07:30:19 +01:00
|
|
|
int frame_n = VideoContext::Get()->GetFrameN();
|
|
|
|
int w,h;
|
|
|
|
parent->GetClientSize(&w,&h);
|
|
|
|
int sw,sh;
|
|
|
|
VideoContext::Get()->GetScriptSize(sw,sh);
|
2007-01-10 22:01:47 +01:00
|
|
|
int x = mouseX;
|
|
|
|
int y = mouseY;
|
2007-01-21 07:30:19 +01:00
|
|
|
int mx = mouseX * sw / w;
|
|
|
|
int my = mouseY * sh / h;
|
2007-01-08 22:11:06 +01:00
|
|
|
|
2007-01-11 18:14:25 +01:00
|
|
|
// Draw lines
|
2007-01-09 07:25:25 +01:00
|
|
|
if (mode != 0) {
|
2007-01-21 07:30:19 +01:00
|
|
|
int numRows = VideoContext::Get()->grid->GetRows();
|
2007-01-09 02:52:30 +01:00
|
|
|
AssDialogue *diag;
|
2007-01-11 18:14:25 +01:00
|
|
|
AssDialogue *diagHigh = NULL;
|
|
|
|
|
|
|
|
// Find where the highlight is
|
|
|
|
if (mode == 1) {
|
|
|
|
int dx,dy;
|
|
|
|
for (int i=0;i<numRows;i++) {
|
2007-01-21 07:30:19 +01:00
|
|
|
diag = VideoContext::Get()->grid->GetDialogue(i);
|
2007-01-11 18:14:25 +01:00
|
|
|
if (diag) {
|
|
|
|
if (VFR_Output.GetFrameAtTime(diag->Start.GetMS(),true) <= frame_n && VFR_Output.GetFrameAtTime(diag->End.GetMS(),false) >= frame_n) {
|
|
|
|
GetLinePosition(diag,dx,dy);
|
2007-01-12 06:57:45 +01:00
|
|
|
dx = dx * w / sw;
|
|
|
|
dy = dy * h / sh;
|
2007-01-11 18:14:25 +01:00
|
|
|
if (x >= dx-8 && x <= dx+8 && y >= dy-8 && y <= dy+8) {
|
|
|
|
diagHigh = diag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-01-09 02:52:30 +01:00
|
|
|
|
|
|
|
// For each line
|
|
|
|
for (int i=0;i<numRows;i++) {
|
2007-01-21 07:30:19 +01:00
|
|
|
diag = VideoContext::Get()->grid->GetDialogue(i);
|
2007-01-09 02:52:30 +01:00
|
|
|
if (diag) {
|
|
|
|
// Draw?
|
2007-01-24 04:54:32 +01:00
|
|
|
//bool draw = false;
|
2007-01-09 07:25:25 +01:00
|
|
|
bool high = false;
|
|
|
|
bool isCur = diag == curSelection;
|
2007-01-11 18:14:25 +01:00
|
|
|
bool timeVisible = VFR_Output.GetFrameAtTime(diag->Start.GetMS(),true) <= frame_n && VFR_Output.GetFrameAtTime(diag->End.GetMS(),false) >= frame_n;
|
|
|
|
bool show = timeVisible;
|
|
|
|
if (mode != 1) {
|
2007-01-21 07:30:19 +01:00
|
|
|
show = diag == VideoContext::Get()->grid->GetDialogue(VideoContext::Get()->grid->editBox->linen) && timeVisible;
|
2007-01-11 18:14:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Variables
|
2007-01-09 02:52:30 +01:00
|
|
|
int dx = -1;
|
|
|
|
int dy = -1;
|
2007-01-09 07:25:25 +01:00
|
|
|
int orgx = -1;
|
|
|
|
int orgy = -1;
|
|
|
|
float rx = 0.0f;
|
|
|
|
float ry = 0.0f;
|
|
|
|
float rz = 0.0f;
|
2007-01-10 22:01:47 +01:00
|
|
|
float scalX = 100.0f;
|
|
|
|
float scalY = 100.0f;
|
2007-01-09 07:25:25 +01:00
|
|
|
int deltax = 0;
|
|
|
|
int deltay = 0;
|
2007-01-09 02:52:30 +01:00
|
|
|
|
|
|
|
// Line visible?
|
2007-01-11 18:14:25 +01:00
|
|
|
if (show) {
|
2007-01-09 02:52:30 +01:00
|
|
|
// Get position
|
2007-01-09 07:25:25 +01:00
|
|
|
if (isCur && mode == 1) {
|
2007-01-10 22:01:47 +01:00
|
|
|
dx = curX;
|
|
|
|
dy = curY;
|
2007-01-09 07:25:25 +01:00
|
|
|
high = true;
|
|
|
|
}
|
|
|
|
else GetLinePosition(diag,dx,dy,orgx,orgy);
|
|
|
|
|
2007-01-21 07:30:19 +01:00
|
|
|
// Get scale
|
|
|
|
if (isCur && mode == 4) {
|
|
|
|
scalX = curScaleX;
|
|
|
|
scalY = curScaleY;
|
|
|
|
}
|
|
|
|
else GetLineScale(diag,scalX,scalY);
|
|
|
|
|
2007-01-27 07:15:25 +01:00
|
|
|
// Get angle
|
|
|
|
GetLineRotation(diag,rx,ry,rz);
|
|
|
|
if (isCur) {
|
|
|
|
if (mode == 2) rz = curAngle;
|
|
|
|
else if (mode == 3) {
|
|
|
|
rx = curAngle;
|
|
|
|
ry = curAngle2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-09 07:25:25 +01:00
|
|
|
// Mouse over?
|
2007-01-11 18:14:25 +01:00
|
|
|
if (diag == diagHigh) {
|
2007-01-09 07:25:25 +01:00
|
|
|
high = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Highlight
|
|
|
|
int brushCol = 1;
|
|
|
|
if (high) brushCol = 2;
|
2007-01-21 07:30:19 +01:00
|
|
|
SetLineColour(colour[0]);
|
|
|
|
SetFillColour(colour[brushCol],0.3f);
|
2007-01-09 07:25:25 +01:00
|
|
|
|
|
|
|
// Set drawing coordinates
|
2007-01-10 05:33:03 +01:00
|
|
|
int radius = (int) sqrt(double((dx-orgx)*(dx-orgx)+(dy-orgy)*(dy-orgy)));
|
2007-01-09 02:52:30 +01:00
|
|
|
|
2007-01-09 07:25:25 +01:00
|
|
|
// Drag
|
|
|
|
if (mode == 1) {
|
2007-01-21 07:30:19 +01:00
|
|
|
SetFillColour(colour[brushCol],0.5f);
|
|
|
|
DrawRectangle(dx-8,dy-8,dx+8,dy+8);
|
|
|
|
SetLineColour(colour[2]);
|
|
|
|
SetModeLine();
|
|
|
|
DrawLine(dx,dy-16,dx,dy+16);
|
|
|
|
DrawLine(dx-16,dy,dx+16,dy);
|
2007-01-09 07:25:25 +01:00
|
|
|
}
|
2007-01-09 02:52:30 +01:00
|
|
|
|
2007-01-10 22:01:47 +01:00
|
|
|
// Rotation
|
|
|
|
if (mode == 2 || mode == 3) {
|
|
|
|
// Pivot coordinates
|
2007-01-09 07:25:25 +01:00
|
|
|
int odx = dx;
|
|
|
|
int ody = dy;
|
|
|
|
dx = orgx;
|
|
|
|
dy = orgy;
|
|
|
|
|
|
|
|
// Draw pivot
|
2007-01-21 07:30:19 +01:00
|
|
|
DrawCircle(dx,dy,7);
|
|
|
|
DrawLine(dx,dy-16,dx,dy+16);
|
|
|
|
DrawLine(dx-16,dy,dx+16,dy);
|
2007-01-10 22:01:47 +01:00
|
|
|
|
|
|
|
// Rotate Z
|
|
|
|
if (mode == 2) {
|
2007-01-21 07:30:19 +01:00
|
|
|
// Transform
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
glPushMatrix();
|
|
|
|
glLoadIdentity();
|
|
|
|
glTranslatef(dx,dy,-1.0f);
|
|
|
|
float matrix[16] = { 2500, 0, 0, 0, 0, 2500, 0, 0, 0, 0, 1, 1, 0, 0, 2500, 2500 };
|
|
|
|
glMultMatrixf(matrix);
|
|
|
|
glScalef(1.0f,1.0f,8.0f);
|
|
|
|
glRotatef(ry,0.0f,-1.0f,0.0f);
|
|
|
|
glRotatef(rx,-1.0f,0.0f,0.0f);
|
|
|
|
glScalef(scalX/100.0f,scalY/100.0f,1.0f);
|
|
|
|
|
2007-01-10 22:01:47 +01:00
|
|
|
// Calculate radii
|
2007-01-21 07:30:19 +01:00
|
|
|
int oRadius = radius;
|
2007-01-10 22:01:47 +01:00
|
|
|
if (radius < 50) radius = 50;
|
|
|
|
|
|
|
|
// Draw the circle
|
2007-01-21 07:30:19 +01:00
|
|
|
SetLineColour(colour[0]);
|
|
|
|
SetFillColour(colour[1],0.3f);
|
|
|
|
DrawRing(0,0,radius+4,radius-4);
|
|
|
|
|
|
|
|
// Draw markers around circle
|
|
|
|
int markers = 6;
|
|
|
|
float markStart = -90.0f / markers;
|
|
|
|
float markEnd = markStart+(180.0f/markers);
|
|
|
|
for (int i=0;i<markers;i++) {
|
|
|
|
float angle = i*(360.0f/markers);
|
|
|
|
DrawRing(0,0,radius+30,radius+12,radius/radius,angle+markStart,angle+markEnd);
|
|
|
|
}
|
2007-01-10 22:01:47 +01:00
|
|
|
|
|
|
|
// Get deltas
|
2007-01-21 07:30:19 +01:00
|
|
|
deltax = int(cos(rz*3.1415926536/180.0)*radius);
|
|
|
|
deltay = int(-sin(rz*3.1415926536/180.0)*radius);
|
2007-01-10 22:01:47 +01:00
|
|
|
|
|
|
|
// Draw the baseline
|
2007-01-21 07:30:19 +01:00
|
|
|
SetLineColour(colour[3],1.0f,2);
|
|
|
|
DrawLine(deltax,deltay,-deltax,-deltay);
|
2007-01-10 22:01:47 +01:00
|
|
|
|
|
|
|
// Draw the connection line
|
|
|
|
if (orgx != odx && orgy != ody) {
|
2007-01-21 07:30:19 +01:00
|
|
|
//double angle = atan2(double(dy*sh/h-ody*sh/h),double(odx*sw/w-dx*sw/w)) + rz*3.1415926536/180.0;
|
|
|
|
double angle = atan2(double(dy-ody),double(odx-dx)) + rz*3.1415926536/180.0;
|
|
|
|
int fx = int(cos(angle)*oRadius);
|
|
|
|
int fy = -int(sin(angle)*oRadius);
|
|
|
|
DrawLine(0,0,fx,fy);
|
2007-04-04 22:42:44 +02:00
|
|
|
int mdx = int(cos(rz*3.1415926536/180.0)*20);
|
|
|
|
int mdy = int(-sin(rz*3.1415926536/180.0)*20);
|
2007-01-21 07:30:19 +01:00
|
|
|
DrawLine(-mdx,-mdy,mdx,mdy);
|
2007-01-10 22:01:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Draw the rotation line
|
2007-01-21 07:30:19 +01:00
|
|
|
SetLineColour(colour[0],1.0f,1);
|
|
|
|
SetFillColour(colour[brushCol],0.3f);
|
|
|
|
DrawCircle(deltax,deltay,4);
|
|
|
|
|
|
|
|
// Restore
|
|
|
|
glPopMatrix();
|
|
|
|
|
|
|
|
// Draw line to mouse
|
2007-06-29 00:27:33 +02:00
|
|
|
if (x != -1) {
|
|
|
|
SetLineColour(colour[0]);
|
|
|
|
DrawLine(dx,dy,mx,my);
|
|
|
|
}
|
2007-01-10 22:01:47 +01:00
|
|
|
}
|
2007-01-10 05:33:03 +01:00
|
|
|
|
2007-01-10 22:01:47 +01:00
|
|
|
// Rotate XY
|
|
|
|
if (mode == 3) {
|
2007-01-21 07:30:19 +01:00
|
|
|
// Transform grid
|
2007-01-22 20:20:46 +01:00
|
|
|
glMatrixMode(GL_MODELVIEW);
|
2007-01-21 07:30:19 +01:00
|
|
|
glPushMatrix();
|
|
|
|
glLoadIdentity();
|
|
|
|
glTranslatef(dx,dy,0.0f);
|
|
|
|
float matrix[16] = { 2500, 0, 0, 0, 0, 2500, 0, 0, 0, 0, 1, 1, 0, 0, 2500, 2500 };
|
|
|
|
glMultMatrixf(matrix);
|
|
|
|
glScalef(1.0f,1.0f,8.0f);
|
2007-01-22 19:57:34 +01:00
|
|
|
if (ry != 0.0f) glRotatef(ry,0.0f,-1.0f,0.0f);
|
|
|
|
if (rx != 0.0f) glRotatef(rx,-1.0f,0.0f,0.0f);
|
|
|
|
if (rz != 0.0f) glRotatef(rz,0.0f,0.0f,-1.0f);
|
2007-01-21 07:30:19 +01:00
|
|
|
|
|
|
|
// Draw grid
|
|
|
|
glShadeModel(GL_SMOOTH);
|
|
|
|
SetLineColour(colour[0],0.5f,1);
|
|
|
|
SetModeLine();
|
|
|
|
float r = colour[0].Red()/255.0f;
|
|
|
|
float g = colour[0].Green()/255.0f;
|
|
|
|
float b = colour[0].Blue()/255.0f;
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
for (int i=0;i<11;i++) {
|
|
|
|
float a = 1.0f - abs(i-5)*0.18f;
|
|
|
|
int pos = 20*(i-5);
|
|
|
|
glColor4f(r,g,b,0.0f);
|
|
|
|
glVertex2i(pos,120);
|
|
|
|
glColor4f(r,g,b,a);
|
|
|
|
glVertex2i(pos,0);
|
|
|
|
glVertex2i(pos,0);
|
|
|
|
glColor4f(r,g,b,0.0f);
|
|
|
|
glVertex2i(pos,-120);
|
|
|
|
glVertex2i(120,pos);
|
|
|
|
glColor4f(r,g,b,a);
|
|
|
|
glVertex2i(0,pos);
|
|
|
|
glVertex2i(0,pos);
|
|
|
|
glColor4f(r,g,b,0.0f);
|
|
|
|
glVertex2i(-120,pos);
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
// Draw vectors
|
|
|
|
SetLineColour(colour[3],1.0f,2);
|
|
|
|
SetModeLine();
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
glVertex3f(0.0f,0.0f,0.0f);
|
|
|
|
glVertex3f(50.0f,0.0f,0.0f);
|
|
|
|
glVertex3f(0.0f,0.0f,0.0f);
|
|
|
|
glVertex3f(0.0f,-50.0f,0.0f);
|
|
|
|
glVertex3f(0.0f,0.0f,0.0f);
|
|
|
|
glVertex3f(0.0f,0.0f,-50.0f);
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
// Draw arrow tops
|
|
|
|
glBegin(GL_TRIANGLE_FAN);
|
|
|
|
glVertex3f(60.0f,0.0f,0.0f);
|
|
|
|
glVertex3f(50.0f,-3.0f,-3.0f);
|
|
|
|
glVertex3f(50.0f,3.0f,-3.0f);
|
|
|
|
glVertex3f(50.0f,3.0f,3.0f);
|
|
|
|
glVertex3f(50.0f,-3.0f,3.0f);
|
|
|
|
glVertex3f(50.0f,-3.0f,-3.0f);
|
|
|
|
glEnd();
|
|
|
|
glBegin(GL_TRIANGLE_FAN);
|
|
|
|
glVertex3f(0.0f,-60.0f,0.0f);
|
|
|
|
glVertex3f(-3.0f,-50.0f,-3.0f);
|
|
|
|
glVertex3f(3.0f,-50.0f,-3.0f);
|
|
|
|
glVertex3f(3.0f,-50.0f,3.0f);
|
|
|
|
glVertex3f(-3.0f,-50.0f,3.0f);
|
|
|
|
glVertex3f(-3.0f,-50.0f,-3.0f);
|
|
|
|
glEnd();
|
|
|
|
glBegin(GL_TRIANGLE_FAN);
|
|
|
|
glVertex3f(0.0f,0.0f,-60.0f);
|
|
|
|
glVertex3f(-3.0f,-3.0f,-50.0f);
|
|
|
|
glVertex3f(3.0f,-3.0f,-50.0f);
|
|
|
|
glVertex3f(3.0f,3.0f,-50.0f);
|
|
|
|
glVertex3f(-3.0f,3.0f,-50.0f);
|
|
|
|
glVertex3f(-3.0f,-3.0f,-50.0f);
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
// Restore gl's state
|
|
|
|
glPopMatrix();
|
|
|
|
glShadeModel(GL_FLAT);
|
2007-01-10 22:01:47 +01:00
|
|
|
}
|
|
|
|
}
|
2007-01-09 07:25:25 +01:00
|
|
|
|
2007-01-10 22:01:47 +01:00
|
|
|
// Scale
|
|
|
|
if (mode == 4) {
|
2007-01-27 07:15:25 +01:00
|
|
|
// Set dx/dy
|
2007-01-10 22:01:47 +01:00
|
|
|
int len = 160;
|
2007-01-21 07:30:19 +01:00
|
|
|
dx = MID(len/2+10,dx,sw-len/2-30);
|
|
|
|
dy = MID(len/2+10,dy,sh-len/2-30);
|
2007-01-27 07:15:25 +01:00
|
|
|
|
|
|
|
// Transform grid
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
glPushMatrix();
|
|
|
|
glLoadIdentity();
|
|
|
|
glTranslatef(dx,dy,0.0f);
|
|
|
|
float matrix[16] = { 2500, 0, 0, 0, 0, 2500, 0, 0, 0, 0, 1, 1, 0, 0, 2500, 2500 };
|
|
|
|
glMultMatrixf(matrix);
|
|
|
|
glScalef(1.0f,1.0f,8.0f);
|
|
|
|
if (ry != 0.0f) glRotatef(ry,0.0f,-1.0f,0.0f);
|
|
|
|
if (rx != 0.0f) glRotatef(rx,-1.0f,0.0f,0.0f);
|
|
|
|
if (rz != 0.0f) glRotatef(rz,0.0f,0.0f,-1.0f);
|
|
|
|
|
|
|
|
// Scale parameters
|
|
|
|
int lenx = int(1.6 * scalX);
|
|
|
|
int leny = int(1.6 * scalY);
|
|
|
|
int drawX = len/2 + 10;
|
|
|
|
int drawY = len/2 + 10;
|
2007-01-09 07:25:25 +01:00
|
|
|
|
2007-01-10 22:01:47 +01:00
|
|
|
// Draw length markers
|
2007-01-21 07:30:19 +01:00
|
|
|
SetLineColour(colour[3],1.0f,2);
|
2007-01-27 07:15:25 +01:00
|
|
|
DrawLine(-lenx/2,drawY+10,lenx/2,drawY+10);
|
|
|
|
DrawLine(drawX+10,-leny/2,drawX+10,leny/2);
|
2007-01-21 07:30:19 +01:00
|
|
|
SetLineColour(colour[0],1.0f,1);
|
|
|
|
SetFillColour(colour[brushCol],0.3f);
|
2007-01-27 07:15:25 +01:00
|
|
|
DrawCircle(lenx/2,drawY+10,4);
|
|
|
|
DrawCircle(drawX+10,-leny/2,4);
|
2007-01-10 22:01:47 +01:00
|
|
|
|
|
|
|
// Draw horizontal scale
|
2007-01-21 07:30:19 +01:00
|
|
|
SetLineColour(colour[0],1.0f,1);
|
2007-01-27 07:15:25 +01:00
|
|
|
DrawRectangle(-len/2,drawY,len/2+1,drawY+5);
|
2007-01-21 07:30:19 +01:00
|
|
|
SetLineColour(colour[0],1.0f,2);
|
2007-01-27 07:15:25 +01:00
|
|
|
DrawLine(-len/2+1,drawY+5,-len/2+1,drawY+15);
|
|
|
|
DrawLine(len/2,drawY+5,len/2,drawY+15);
|
2007-01-10 22:01:47 +01:00
|
|
|
|
|
|
|
// Draw vertical scale
|
2007-01-21 07:30:19 +01:00
|
|
|
SetLineColour(colour[0],1.0f,1);
|
2007-01-27 07:15:25 +01:00
|
|
|
DrawRectangle(drawX,-len/2,drawX+5,len/2+1);
|
2007-01-21 07:30:19 +01:00
|
|
|
SetLineColour(colour[0],1.0f,2);
|
2007-01-27 07:15:25 +01:00
|
|
|
DrawLine(drawX+5,-len/2+1,drawX+15,-len/2+1);
|
|
|
|
DrawLine(drawX+5,len/2,drawX+15,len/2);
|
|
|
|
|
|
|
|
// Restore gl's state
|
|
|
|
glPopMatrix();
|
2007-01-09 07:25:25 +01:00
|
|
|
}
|
2007-01-10 22:53:00 +01:00
|
|
|
|
|
|
|
// Clip
|
|
|
|
if (mode == 5) {
|
|
|
|
int dx1,dx2,dy1,dy2;
|
|
|
|
|
|
|
|
// Get position
|
|
|
|
if (isCur) {
|
2007-01-21 07:30:19 +01:00
|
|
|
dx1 = startX * sw / w;
|
|
|
|
dy1 = startY * sh / h;
|
|
|
|
dx2 = mx;
|
|
|
|
dy2 = my;
|
2007-01-11 18:14:25 +01:00
|
|
|
}
|
2007-01-21 07:30:19 +01:00
|
|
|
else GetLineClip(diag,dx1,dy1,dx2,dy2);
|
|
|
|
|
|
|
|
// Swap
|
|
|
|
if (dx1 > dx2) IntSwap(dx1,dx2);
|
|
|
|
if (dy1 > dy2) IntSwap(dy1,dy2);
|
2007-01-10 22:53:00 +01:00
|
|
|
|
|
|
|
// Draw rectangle
|
2007-01-21 07:30:19 +01:00
|
|
|
SetLineColour(colour[3]);
|
|
|
|
SetFillColour(colour[3],0.0f);
|
|
|
|
DrawRectangle(dx1,dy1,dx2,dy2);
|
|
|
|
|
|
|
|
// Draw outside area
|
|
|
|
SetLineColour(colour[3],0.0f);
|
|
|
|
SetFillColour(colour[3],0.3f);
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
DrawRectangle(0,0,sw,dy1);
|
|
|
|
DrawRectangle(0,dy2,sw,sh);
|
|
|
|
DrawRectangle(0,dy1,dx1,dy2);
|
|
|
|
DrawRectangle(dx2,dy1,sw,dy2);
|
|
|
|
glDisable(GL_BLEND);
|
2007-01-10 22:53:00 +01:00
|
|
|
|
|
|
|
// Draw circles
|
2007-01-21 07:30:19 +01:00
|
|
|
SetLineColour(colour[0]);
|
|
|
|
SetFillColour(colour[1],0.5);
|
|
|
|
DrawCircle(dx1,dy1,4);
|
|
|
|
DrawCircle(dx2,dy1,4);
|
|
|
|
DrawCircle(dx2,dy2,4);
|
|
|
|
DrawCircle(dx1,dy2,4);
|
2007-01-10 22:53:00 +01:00
|
|
|
}
|
2007-01-09 02:52:30 +01:00
|
|
|
}
|
2007-01-08 22:11:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Current position info
|
2007-01-09 02:52:30 +01:00
|
|
|
if (mode == 0 && x >= 0 && x < w && y >= 0 && y < h) {
|
2007-01-08 22:11:06 +01:00
|
|
|
// Draw cross
|
2007-06-29 00:18:19 +02:00
|
|
|
glDisable(GL_LINE_SMOOTH);
|
2007-01-21 07:30:19 +01:00
|
|
|
glEnable(GL_COLOR_LOGIC_OP);
|
|
|
|
glLogicOp(GL_INVERT);
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
glColor3f(1.0f,1.0f,1.0f);
|
|
|
|
glVertex2f(0,my);
|
|
|
|
glVertex2f(sw,my);
|
|
|
|
glVertex2f(mx,0);
|
|
|
|
glVertex2f(mx,sh);
|
|
|
|
glEnd();
|
|
|
|
glDisable(GL_COLOR_LOGIC_OP);
|
|
|
|
|
2007-04-16 00:44:52 +02:00
|
|
|
// Switch display
|
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
glPushMatrix();
|
|
|
|
glLoadIdentity();
|
|
|
|
glOrtho(0.0f,w,h,0.0f,-1000.0f,1000.0f);
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
|
2007-04-13 05:52:25 +02:00
|
|
|
// Setup text
|
2007-04-13 16:38:27 +02:00
|
|
|
int tw,th;
|
|
|
|
OpenGLText::SetFont(_T("Verdana"),12,true);
|
|
|
|
OpenGLText::SetColour(wxColour(255,255,255));
|
|
|
|
OpenGLText::GetExtent(mouseText,tw,th);
|
|
|
|
|
|
|
|
// Calculate draw position
|
|
|
|
bool left = x > w/2;
|
|
|
|
bool bottom = y < h/2;
|
|
|
|
|
|
|
|
// Text draw coords
|
|
|
|
int dx = x,dy = y;
|
|
|
|
if (left) dx -= tw + 4;
|
|
|
|
else dx += 4;
|
|
|
|
if (bottom) dy += 3;
|
|
|
|
else dy -= th + 3;
|
|
|
|
|
|
|
|
// Draw text
|
|
|
|
OpenGLText::Print(mouseText,dx,dy);
|
2007-04-16 00:44:52 +02:00
|
|
|
|
|
|
|
// Restore matrix
|
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
glPopMatrix();
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
2007-01-08 22:11:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////
|
|
|
|
// Get position of line
|
|
|
|
void VideoDisplayVisual::GetLinePosition(AssDialogue *diag,int &x, int &y) {
|
2007-01-09 07:25:25 +01:00
|
|
|
int orgx=0,orgy=0;
|
|
|
|
GetLinePosition(diag,x,y,orgx,orgy);
|
|
|
|
}
|
|
|
|
void VideoDisplayVisual::GetLinePosition(AssDialogue *diag,int &x, int &y, int &orgx, int &orgy) {
|
2007-01-09 02:52:30 +01:00
|
|
|
// No dialogue
|
|
|
|
if (!diag) {
|
|
|
|
x = -1;
|
|
|
|
y = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-01-08 22:11:06 +01:00
|
|
|
// Default values
|
|
|
|
int margin[4];
|
|
|
|
for (int i=0;i<4;i++) margin[i] = diag->Margin[i];
|
|
|
|
int align = 2;
|
|
|
|
|
|
|
|
// Get style
|
2007-01-21 07:30:19 +01:00
|
|
|
AssStyle *style = VideoContext::Get()->grid->ass->GetStyle(diag->Style);
|
2007-01-08 22:11:06 +01:00
|
|
|
if (style) {
|
|
|
|
align = style->alignment;
|
|
|
|
for (int i=0;i<4;i++) {
|
|
|
|
if (margin[i] == 0) margin[i] = style->Margin[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Script size
|
|
|
|
int sw,sh;
|
2007-01-21 07:30:19 +01:00
|
|
|
VideoContext::Get()->GetScriptSize(sw,sh);
|
2007-01-08 22:11:06 +01:00
|
|
|
|
|
|
|
// Process margins
|
|
|
|
margin[3] = margin[2];
|
|
|
|
margin[1] = sw - margin[1];
|
|
|
|
margin[3] = sh - margin[3];
|
|
|
|
|
2007-01-09 02:52:30 +01:00
|
|
|
// Position
|
2007-01-09 07:25:25 +01:00
|
|
|
bool posSet = false;
|
|
|
|
bool orgSet = false;
|
2007-01-09 02:52:30 +01:00
|
|
|
int posx = -1;
|
|
|
|
int posy = -1;
|
|
|
|
|
2007-01-08 22:11:06 +01:00
|
|
|
// Overrides processing
|
2007-01-09 02:52:30 +01:00
|
|
|
diag->ParseASSTags();
|
|
|
|
AssDialogueBlockOverride *override;
|
|
|
|
AssOverrideTag *tag;
|
|
|
|
size_t blockn = diag->Blocks.size();
|
|
|
|
for (size_t i=0;i<blockn;i++) {
|
|
|
|
override = AssDialogueBlock::GetAsOverride(diag->Blocks.at(i));
|
|
|
|
if (override) {
|
|
|
|
for (size_t j=0;j<override->Tags.size();j++) {
|
|
|
|
tag = override->Tags.at(j);
|
2007-01-09 07:25:25 +01:00
|
|
|
|
|
|
|
// Position
|
2007-01-09 02:52:30 +01:00
|
|
|
if ((tag->Name == _T("\\pos") || tag->Name == _("\\move")) && tag->Params.size() >= 2) {
|
2007-01-09 07:25:25 +01:00
|
|
|
if (!posSet) {
|
|
|
|
posx = tag->Params[0]->AsInt();
|
|
|
|
posy = tag->Params[1]->AsInt();
|
|
|
|
posSet = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Alignment
|
|
|
|
else if ((tag->Name == _T("\\an") || tag->Name == _T("\\a")) && tag->Params.size() >= 1) {
|
|
|
|
align = tag->Params[0]->AsInt();
|
|
|
|
if (tag->Name == _T("\\a")) {
|
|
|
|
switch(align) {
|
|
|
|
case 1: align = 1; break;
|
|
|
|
case 2: align = 2; break;
|
|
|
|
case 3: align = 3; break;
|
|
|
|
case 5: align = 7; break;
|
|
|
|
case 6: align = 8; break;
|
|
|
|
case 7: align = 9; break;
|
|
|
|
case 9: align = 4; break;
|
|
|
|
case 10: align = 5; break;
|
|
|
|
case 11: align = 6; break;
|
|
|
|
default: align = 2; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Origin
|
|
|
|
else if (!orgSet && tag->Name == _T("\\org") && tag->Params.size() >= 2) {
|
|
|
|
orgx = tag->Params[0]->AsInt();
|
|
|
|
orgy = tag->Params[1]->AsInt();
|
|
|
|
orgSet = true;
|
2007-01-09 02:52:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
diag->ClearBlocks();
|
|
|
|
|
|
|
|
// Got position
|
2007-01-09 07:25:25 +01:00
|
|
|
if (posSet) {
|
2007-01-09 02:52:30 +01:00
|
|
|
x = posx;
|
|
|
|
y = posy;
|
2007-01-09 07:25:25 +01:00
|
|
|
if (!orgSet) {
|
|
|
|
orgx = x;
|
|
|
|
orgy = y;
|
|
|
|
}
|
2007-01-09 02:52:30 +01:00
|
|
|
return;
|
|
|
|
}
|
2007-01-08 22:11:06 +01:00
|
|
|
|
|
|
|
// Alignment type
|
|
|
|
int hor = (align - 1) % 3;
|
|
|
|
int vert = (align - 1) / 3;
|
|
|
|
|
|
|
|
// Calculate positions
|
|
|
|
if (hor == 0) x = margin[0];
|
|
|
|
else if (hor == 1) x = (margin[0] + margin[1])/2;
|
|
|
|
else if (hor == 2) x = margin[1];
|
|
|
|
if (vert == 0) y = margin[3];
|
|
|
|
else if (vert == 1) y = (margin[2] + margin[3])/2;
|
|
|
|
else if (vert == 2) y = margin[2];
|
2007-01-09 07:25:25 +01:00
|
|
|
|
|
|
|
// No origin?
|
|
|
|
if (!orgSet) {
|
|
|
|
orgx = x;
|
|
|
|
orgy = y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////
|
|
|
|
// Get line's rotation
|
|
|
|
void VideoDisplayVisual::GetLineRotation(AssDialogue *diag,float &rx,float &ry,float &rz) {
|
|
|
|
// Default values
|
|
|
|
rx = ry = rz = 0.0f;
|
|
|
|
|
|
|
|
// Prepare overrides
|
|
|
|
diag->ParseASSTags();
|
|
|
|
AssDialogueBlockOverride *override;
|
|
|
|
AssOverrideTag *tag;
|
|
|
|
size_t blockn = diag->Blocks.size();
|
|
|
|
if (blockn == 0) {
|
|
|
|
diag->ClearBlocks();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Process override
|
|
|
|
override = AssDialogueBlock::GetAsOverride(diag->Blocks.at(0));
|
|
|
|
if (override) {
|
|
|
|
for (size_t j=0;j<override->Tags.size();j++) {
|
|
|
|
tag = override->Tags.at(j);
|
|
|
|
if (tag->Name == _T("\\frx") && tag->Params.size() == 1) {
|
|
|
|
rx = tag->Params[0]->AsFloat();
|
|
|
|
}
|
|
|
|
if (tag->Name == _T("\\fry") && tag->Params.size() == 1) {
|
|
|
|
ry = tag->Params[0]->AsFloat();
|
|
|
|
}
|
|
|
|
if ((tag->Name == _T("\\frz") || tag->Name == _T("\fr")) && tag->Params.size() == 1) {
|
|
|
|
rz = tag->Params[0]->AsFloat();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
diag->ClearBlocks();
|
2007-01-08 22:11:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-01-10 22:01:47 +01:00
|
|
|
////////////////////
|
|
|
|
// Get line's scale
|
|
|
|
void VideoDisplayVisual::GetLineScale(AssDialogue *diag,float &scalX,float &scalY) {
|
|
|
|
// Default values
|
|
|
|
scalX = scalY = 100.0f;
|
|
|
|
|
|
|
|
// Prepare overrides
|
|
|
|
diag->ParseASSTags();
|
|
|
|
AssDialogueBlockOverride *override;
|
|
|
|
AssOverrideTag *tag;
|
|
|
|
size_t blockn = diag->Blocks.size();
|
|
|
|
if (blockn == 0) {
|
|
|
|
diag->ClearBlocks();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Process override
|
|
|
|
override = AssDialogueBlock::GetAsOverride(diag->Blocks.at(0));
|
|
|
|
if (override) {
|
|
|
|
for (size_t j=0;j<override->Tags.size();j++) {
|
|
|
|
tag = override->Tags.at(j);
|
|
|
|
if (tag->Name == _T("\\fscx") && tag->Params.size() == 1) {
|
|
|
|
scalX = tag->Params[0]->AsFloat();
|
|
|
|
}
|
|
|
|
if (tag->Name == _T("\\fscy") && tag->Params.size() == 1) {
|
|
|
|
scalY = tag->Params[0]->AsFloat();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
diag->ClearBlocks();
|
|
|
|
}
|
|
|
|
|
2007-01-09 07:25:25 +01:00
|
|
|
|
2007-01-10 22:53:00 +01:00
|
|
|
///////////////////
|
|
|
|
// Get line's clip
|
|
|
|
void VideoDisplayVisual::GetLineClip(AssDialogue *diag,int &x1,int &y1,int &x2,int &y2) {
|
|
|
|
// Default values
|
|
|
|
x1 = y1 = 0;
|
2007-01-12 06:57:45 +01:00
|
|
|
int sw,sh;
|
2007-01-21 07:30:19 +01:00
|
|
|
VideoContext::Get()->GetScriptSize(sw,sh);
|
2007-01-12 06:57:45 +01:00
|
|
|
x2 = sw-1;
|
|
|
|
y2 = sh-1;
|
2007-01-10 22:53:00 +01:00
|
|
|
|
|
|
|
// Prepare overrides
|
|
|
|
diag->ParseASSTags();
|
|
|
|
AssDialogueBlockOverride *override;
|
|
|
|
AssOverrideTag *tag;
|
|
|
|
size_t blockn = diag->Blocks.size();
|
|
|
|
if (blockn == 0) {
|
|
|
|
diag->ClearBlocks();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Process override
|
|
|
|
override = AssDialogueBlock::GetAsOverride(diag->Blocks.at(0));
|
|
|
|
if (override) {
|
|
|
|
for (size_t j=0;j<override->Tags.size();j++) {
|
|
|
|
tag = override->Tags.at(j);
|
|
|
|
if (tag->Name == _T("\\clip") && tag->Params.size() == 4) {
|
|
|
|
x1 = tag->Params[0]->AsInt();
|
|
|
|
y1 = tag->Params[1]->AsInt();
|
|
|
|
x2 = tag->Params[2]->AsInt();
|
|
|
|
y2 = tag->Params[3]->AsInt();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
diag->ClearBlocks();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-01-08 22:11:06 +01:00
|
|
|
///////////////
|
|
|
|
// Mouse event
|
|
|
|
void VideoDisplayVisual::OnMouseEvent (wxMouseEvent &event) {
|
|
|
|
// Coords
|
|
|
|
int x = event.GetX();
|
|
|
|
int y = event.GetY();
|
2007-01-23 07:32:16 +01:00
|
|
|
parent->ConvertMouseCoords(x,y);
|
2007-01-21 07:30:19 +01:00
|
|
|
int w,h;
|
|
|
|
parent->GetClientSize(&w,&h);
|
2007-01-10 05:33:03 +01:00
|
|
|
int orgx = -1;
|
|
|
|
int orgy = -1;
|
2007-01-09 02:52:30 +01:00
|
|
|
int sw,sh;
|
2007-01-21 07:30:19 +01:00
|
|
|
VideoContext::Get()->GetScriptSize(sw,sh);
|
|
|
|
int frame_n = VideoContext::Get()->GetFrameN();
|
|
|
|
SubtitlesGrid *grid = VideoContext::Get()->grid;
|
2007-01-09 02:52:30 +01:00
|
|
|
bool hasOverlay = false;
|
|
|
|
bool realTime = Options.AsBool(_T("Video Visual Realtime"));
|
2007-01-30 21:49:22 +01:00
|
|
|
|
2007-01-08 22:11:06 +01:00
|
|
|
// Text of current coords
|
|
|
|
int vx = (sw * x + w/2) / w;
|
|
|
|
int vy = (sh * y + h/2) / h;
|
|
|
|
if (!event.ShiftDown()) mouseText = wxString::Format(_T("%i,%i"),vx,vy);
|
|
|
|
else mouseText = wxString::Format(_T("%i,%i"),vx - sw,vy - sh);
|
|
|
|
|
|
|
|
// Start dragging
|
2007-01-09 07:25:25 +01:00
|
|
|
if (mode != 0 && event.LeftIsDown() && !holding) {
|
2007-01-10 22:01:47 +01:00
|
|
|
float rx,ry,rz,scalX,scalY;
|
2007-01-09 02:52:30 +01:00
|
|
|
AssDialogue *gotDiag = NULL;
|
|
|
|
|
2007-01-10 05:33:03 +01:00
|
|
|
// Drag
|
|
|
|
if (mode == 1) {
|
|
|
|
// For each line
|
2007-01-21 07:30:19 +01:00
|
|
|
int numRows = VideoContext::Get()->grid->GetRows();
|
2007-01-24 04:54:32 +01:00
|
|
|
//int startMs = VFR_Output.GetTimeAtFrame(frame_n,true);
|
|
|
|
//int endMs = VFR_Output.GetTimeAtFrame(frame_n,false);
|
2007-01-10 05:33:03 +01:00
|
|
|
AssDialogue *diag;
|
2007-01-11 18:14:25 +01:00
|
|
|
|
|
|
|
// Don't uninvert this loop or selection will break
|
|
|
|
for (int i=numRows;--i>=0;) {
|
2007-01-21 07:30:19 +01:00
|
|
|
diag = VideoContext::Get()->grid->GetDialogue(i);
|
2007-01-10 05:33:03 +01:00
|
|
|
if (diag) {
|
|
|
|
// Line visible?
|
2007-01-13 07:17:14 +01:00
|
|
|
int f1 = VFR_Output.GetFrameAtTime(diag->Start.GetMS(),true);
|
|
|
|
int f2 = VFR_Output.GetFrameAtTime(diag->End.GetMS(),false);
|
|
|
|
if (f1 <= frame_n && f2 >= frame_n) {
|
2007-01-10 05:33:03 +01:00
|
|
|
// Get position
|
|
|
|
int lineX,lineY;
|
|
|
|
int torgx,torgy;
|
|
|
|
GetLinePosition(diag,lineX,lineY,torgx,torgy);
|
|
|
|
lineX = lineX * w / sw;
|
|
|
|
lineY = lineY * h / sh;
|
|
|
|
orgx = orgx * w / sw;
|
|
|
|
orgy = orgy * h / sh;
|
|
|
|
|
|
|
|
// Mouse over?
|
|
|
|
if (x >= lineX-8 && x <= lineX+8 && y >= lineY-8 && y <= lineY+8) {
|
2007-01-21 07:30:19 +01:00
|
|
|
VideoContext::Get()->grid->editBox->SetToLine(i,true);
|
2007-01-10 05:33:03 +01:00
|
|
|
gotDiag = diag;
|
2007-01-10 22:01:47 +01:00
|
|
|
origX = lineX;
|
|
|
|
origY = lineY;
|
2007-01-10 05:33:03 +01:00
|
|
|
orgx = torgx;
|
|
|
|
orgy = torgy;
|
|
|
|
break;
|
|
|
|
}
|
2007-01-09 02:52:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-10 22:01:47 +01:00
|
|
|
// Pick active line
|
2007-01-10 05:33:03 +01:00
|
|
|
else {
|
2007-01-10 22:01:47 +01:00
|
|
|
// Get active
|
2007-01-21 07:30:19 +01:00
|
|
|
gotDiag = VideoContext::Get()->grid->GetDialogue(VideoContext::Get()->grid->editBox->linen);
|
2007-01-10 05:33:03 +01:00
|
|
|
|
2007-01-10 22:01:47 +01:00
|
|
|
// Check if it's within range
|
|
|
|
if (gotDiag) {
|
|
|
|
int f1 = VFR_Output.GetFrameAtTime(gotDiag->Start.GetMS(),true);
|
|
|
|
int f2 = VFR_Output.GetFrameAtTime(gotDiag->End.GetMS(),false);
|
|
|
|
|
|
|
|
// Invisible
|
|
|
|
if (f1 > frame_n || f2 < frame_n) {
|
|
|
|
gotDiag = NULL;
|
|
|
|
}
|
2007-01-10 05:33:03 +01:00
|
|
|
|
2007-01-10 22:01:47 +01:00
|
|
|
// OK
|
|
|
|
else {
|
|
|
|
GetLinePosition(gotDiag,origX,origY,orgx,orgy);
|
|
|
|
}
|
2007-01-10 05:33:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-09 02:52:30 +01:00
|
|
|
// Got a line?
|
|
|
|
if (gotDiag) {
|
|
|
|
// Set dialogue
|
|
|
|
curSelection = gotDiag;
|
2007-01-10 22:01:47 +01:00
|
|
|
lineOrgX = orgx;
|
|
|
|
lineOrgY = orgy;
|
2007-01-09 07:25:25 +01:00
|
|
|
|
|
|
|
// Set coordinates
|
|
|
|
if (mode == 1) {
|
2007-01-10 22:01:47 +01:00
|
|
|
startX = x;
|
|
|
|
startY = y;
|
2007-01-13 23:33:02 +01:00
|
|
|
curSelection->StripTag(_T("\\pos"));
|
|
|
|
curSelection->StripTag(_T("\\move"));
|
2007-01-09 07:25:25 +01:00
|
|
|
}
|
2007-01-09 02:52:30 +01:00
|
|
|
|
2007-01-10 05:33:03 +01:00
|
|
|
// Rotate Z
|
|
|
|
if (mode == 2) {
|
|
|
|
startAngle = atan2(double(lineOrgY-y*sh/h),double(x*sw/w-lineOrgX)) * 180.0 / 3.1415926535897932;
|
|
|
|
GetLineRotation(curSelection,rx,ry,rz);
|
|
|
|
origAngle = rz;
|
2007-01-10 22:01:47 +01:00
|
|
|
curAngle = rz;
|
2007-01-13 23:33:02 +01:00
|
|
|
curSelection->StripTag(_T("\\frz"));
|
|
|
|
curSelection->StripTag(_T("\\fr"));
|
2007-01-10 22:01:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Rotate XY
|
|
|
|
if (mode == 3) {
|
|
|
|
startAngle = (lineOrgY-y*sh/h)*2.0;
|
|
|
|
startAngle2 = (x*sw/w-lineOrgX)*2.0;
|
|
|
|
GetLineRotation(curSelection,rx,ry,rz);
|
|
|
|
origAngle = rx;
|
|
|
|
origAngle2 = ry;
|
|
|
|
curAngle = rx;
|
|
|
|
curAngle2 = ry;
|
2007-01-13 23:33:02 +01:00
|
|
|
curSelection->StripTag(_T("\\frx"));
|
|
|
|
curSelection->StripTag(_T("\\fry"));
|
2007-01-10 22:01:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Scale
|
|
|
|
if (mode == 4) {
|
|
|
|
//startScaleX = x;
|
|
|
|
//startScaleY = y;
|
|
|
|
startX = x;
|
|
|
|
startY = y;
|
|
|
|
GetLineScale(curSelection,scalX,scalY);
|
|
|
|
origScaleX = scalX;
|
|
|
|
origScaleY = scalY;
|
|
|
|
curScaleX = scalX;
|
|
|
|
curScaleY = scalY;
|
2007-01-13 23:33:02 +01:00
|
|
|
curSelection->StripTag(_T("\\fscx"));
|
|
|
|
curSelection->StripTag(_T("\\fscy"));
|
2007-01-10 05:33:03 +01:00
|
|
|
}
|
|
|
|
|
2007-01-10 22:53:00 +01:00
|
|
|
// Clip
|
|
|
|
if (mode == 5) {
|
|
|
|
startX = x;
|
|
|
|
startY = y;
|
2007-01-13 23:33:02 +01:00
|
|
|
curSelection->StripTag(_T("\\clip"));
|
2007-01-10 22:53:00 +01:00
|
|
|
}
|
|
|
|
|
2007-01-13 23:33:02 +01:00
|
|
|
// Commit changes to edit box
|
|
|
|
grid->editBox->TextEdit->SetTextTo(curSelection->Text);
|
|
|
|
grid->editBox->CommitText(true);
|
|
|
|
|
2007-01-09 02:52:30 +01:00
|
|
|
// Hold it
|
|
|
|
holding = true;
|
2007-01-09 07:25:25 +01:00
|
|
|
hold = mode;
|
2007-01-09 02:52:30 +01:00
|
|
|
parent->CaptureMouse();
|
|
|
|
hasOverlay = true;
|
|
|
|
}
|
2007-01-08 22:11:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Drag
|
|
|
|
if (hold == 1) {
|
2007-01-10 22:01:47 +01:00
|
|
|
curX = (x - startX + origX) * sw / w;
|
|
|
|
curY = (y - startY + origY) * sh / h;
|
2007-01-09 02:52:30 +01:00
|
|
|
if (realTime) {
|
|
|
|
AssLimitToVisibleFilter::SetFrame(frame_n);
|
2007-01-23 05:42:08 +01:00
|
|
|
grid->editBox->SetOverride(_T("\\pos"),wxString::Format(_T("(%i,%i)"),curX,curY),0,false);
|
2007-01-09 02:52:30 +01:00
|
|
|
grid->editBox->CommitText(true);
|
|
|
|
grid->CommitChanges(false,true);
|
|
|
|
}
|
2007-01-08 22:11:06 +01:00
|
|
|
}
|
|
|
|
|
2007-01-10 22:01:47 +01:00
|
|
|
// Rotate Z
|
|
|
|
else if (hold == 2) {
|
2007-01-15 06:38:32 +01:00
|
|
|
// Find angle
|
2007-01-10 05:33:03 +01:00
|
|
|
float screenAngle = atan2(double(lineOrgY-y*sh/h),double(x*sw/w-lineOrgX)) * 180.0 / 3.1415926535897932;
|
2007-01-15 06:38:32 +01:00
|
|
|
curAngle = screenAngle - startAngle + origAngle;
|
|
|
|
while (curAngle < 0.0f) curAngle += 360.0f;
|
|
|
|
while (curAngle >= 360.0f) curAngle -= 360.0f;
|
|
|
|
|
|
|
|
// Snap
|
|
|
|
if (event.ShiftDown()) {
|
|
|
|
curAngle = (float)((int)((curAngle+15.0f)/30.0f))*30.0f;
|
|
|
|
if (curAngle == 360.0f) curAngle = 0.0f;
|
|
|
|
}
|
2007-01-10 05:33:03 +01:00
|
|
|
|
|
|
|
// Update
|
|
|
|
if (realTime) {
|
|
|
|
AssLimitToVisibleFilter::SetFrame(frame_n);
|
2007-01-15 06:38:32 +01:00
|
|
|
wxString param = PrettyFloat(wxString::Format(_T("(%0.3f)"),curAngle));
|
2007-01-23 05:42:08 +01:00
|
|
|
grid->editBox->SetOverride(_T("\\frz"),param,0,false);
|
2007-01-10 05:33:03 +01:00
|
|
|
grid->editBox->CommitText(true);
|
|
|
|
grid->CommitChanges(false,true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-10 22:01:47 +01:00
|
|
|
// Rotate XY
|
|
|
|
else if (hold == 3) {
|
|
|
|
// Find screen angles
|
|
|
|
float screenAngle = (lineOrgY-y*sh/h)*2.0;
|
|
|
|
float screenAngle2 = (x*sw/w-lineOrgX)*2.0;
|
|
|
|
|
|
|
|
// Calculate
|
|
|
|
curAngle = screenAngle - startAngle + origAngle;
|
|
|
|
curAngle2 = screenAngle2 - startAngle2 + origAngle2;
|
2007-01-11 18:14:25 +01:00
|
|
|
while (curAngle < 0.0) curAngle += 360.0;
|
|
|
|
while (curAngle >= 360.0) curAngle -= 360.0;
|
|
|
|
while (curAngle2 < 0.0) curAngle2 += 360.0;
|
|
|
|
while (curAngle2 >= 360.0) curAngle2 -= 360.0;
|
2007-01-10 22:01:47 +01:00
|
|
|
|
2007-01-15 06:38:32 +01:00
|
|
|
// Oh Snap
|
|
|
|
if (event.ShiftDown()) {
|
|
|
|
curAngle = (float)((int)((curAngle+15.0f)/30.0f))*30.0f;
|
|
|
|
curAngle2 = (float)((int)((curAngle2+15.0f)/30.0f))*30.0f;
|
|
|
|
if (curAngle == 360.0f) curAngle = 0.0f;
|
|
|
|
if (curAngle2 == 360.0f) curAngle = 0.0f;
|
|
|
|
}
|
|
|
|
|
2007-01-10 22:01:47 +01:00
|
|
|
// Update
|
|
|
|
if (realTime) {
|
|
|
|
AssLimitToVisibleFilter::SetFrame(frame_n);
|
2007-01-23 05:42:08 +01:00
|
|
|
grid->editBox->SetOverride(_T("\\frx"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curAngle)),0,false);
|
|
|
|
grid->editBox->SetOverride(_T("\\fry"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curAngle2)),0,false);
|
2007-01-10 22:01:47 +01:00
|
|
|
grid->editBox->CommitText(true);
|
|
|
|
grid->CommitChanges(false,true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Scale
|
|
|
|
else if (hold == 4) {
|
|
|
|
// Calculate
|
|
|
|
curScaleX = (float(x - startX)/0.8f) + origScaleX;
|
|
|
|
curScaleY = (float(startY - y)/0.8f) + origScaleY;
|
|
|
|
if (curScaleX < 0.0f) curScaleX = 0.0f;
|
|
|
|
if (curScaleY < 0.0f) curScaleY = 0.0f;
|
|
|
|
|
2007-01-15 06:38:32 +01:00
|
|
|
// Snap
|
|
|
|
if (event.ShiftDown()) {
|
|
|
|
curScaleX = (float)((int)((curScaleX+12.5f)/25.0f))*25.0f;
|
|
|
|
curScaleY = (float)((int)((curScaleY+12.5f)/25.0f))*25.0f;
|
|
|
|
}
|
|
|
|
|
2007-01-10 22:01:47 +01:00
|
|
|
// Update
|
|
|
|
if (realTime) {
|
|
|
|
AssLimitToVisibleFilter::SetFrame(frame_n);
|
2007-01-23 05:42:08 +01:00
|
|
|
grid->editBox->SetOverride(_T("\\fscx"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curScaleX)),0,false);
|
|
|
|
grid->editBox->SetOverride(_T("\\fscy"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curScaleY)),0,false);
|
2007-01-10 22:01:47 +01:00
|
|
|
grid->editBox->CommitText(true);
|
|
|
|
grid->CommitChanges(false,true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-10 22:53:00 +01:00
|
|
|
// Clip
|
|
|
|
else if (hold == 5) {
|
|
|
|
// Coordinates
|
|
|
|
curX = startX * sw / w;
|
|
|
|
curY = startY * sh / h;
|
|
|
|
curX2 = x * sw / w;
|
|
|
|
curY2 = y * sh / h;
|
|
|
|
int temp;
|
|
|
|
if (curX > curX2) {
|
|
|
|
temp = curX;
|
|
|
|
curX = curX2;
|
|
|
|
curX2 = temp;
|
|
|
|
}
|
|
|
|
if (curY > curY2) {
|
|
|
|
temp = curY;
|
|
|
|
curY = curY2;
|
|
|
|
curY2 = temp;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update
|
|
|
|
if (realTime) {
|
|
|
|
AssLimitToVisibleFilter::SetFrame(frame_n);
|
2007-01-23 05:42:08 +01:00
|
|
|
grid->editBox->SetOverride(_T("\\clip"),wxString::Format(_T("(%i,%i,%i,%i)"),curX,curY,curX2,curY2),0,false);
|
2007-01-10 22:53:00 +01:00
|
|
|
grid->editBox->CommitText(true);
|
|
|
|
grid->CommitChanges(false,true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-08 22:11:06 +01:00
|
|
|
// End dragging
|
|
|
|
if (holding && !event.LeftIsDown()) {
|
2007-01-09 02:52:30 +01:00
|
|
|
// Disable limiting
|
|
|
|
if (realTime) AssLimitToVisibleFilter::SetFrame(-1);
|
|
|
|
|
2007-01-08 22:11:06 +01:00
|
|
|
// Finished dragging subtitles
|
|
|
|
if (hold == 1) {
|
2007-01-23 05:42:08 +01:00
|
|
|
grid->editBox->SetOverride(_T("\\pos"),wxString::Format(_T("(%i,%i)"),curX,curY),0,false);
|
2007-01-10 05:33:03 +01:00
|
|
|
}
|
|
|
|
|
2007-01-10 22:01:47 +01:00
|
|
|
// Finished rotating Z
|
|
|
|
else if (hold == 2) {
|
2007-01-23 05:42:08 +01:00
|
|
|
grid->editBox->SetOverride(_T("\\frz"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curAngle)),0,false);
|
2007-01-08 22:11:06 +01:00
|
|
|
}
|
|
|
|
|
2007-01-10 22:01:47 +01:00
|
|
|
// Finished rotating XY
|
|
|
|
else if (hold == 3) {
|
2007-01-23 05:42:08 +01:00
|
|
|
grid->editBox->SetOverride(_T("\\frx"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curAngle)),0,false);
|
|
|
|
grid->editBox->SetOverride(_T("\\fry"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curAngle2)),0,false);
|
2007-01-10 22:01:47 +01:00
|
|
|
}
|
|
|
|
|
2007-01-10 22:53:00 +01:00
|
|
|
// Finished scaling
|
|
|
|
else if (hold == 4) {
|
2007-01-23 05:42:08 +01:00
|
|
|
grid->editBox->SetOverride(_T("\\fscx"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curScaleX)),0,false);
|
|
|
|
grid->editBox->SetOverride(_T("\\fscy"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curScaleY)),0,false);
|
2007-01-10 22:53:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Finished clipping
|
|
|
|
else if (hold == 5) {
|
2007-01-23 05:42:08 +01:00
|
|
|
grid->editBox->SetOverride(_T("\\clip"),wxString::Format(_T("(%i,%i,%i,%i)"),curX,curY,curX2,curY2),0,false);
|
2007-01-10 22:53:00 +01:00
|
|
|
}
|
|
|
|
|
2007-01-10 22:01:47 +01:00
|
|
|
// Commit
|
|
|
|
grid->editBox->CommitText();
|
2007-01-26 01:47:42 +01:00
|
|
|
grid->ass->FlagAsModified(_("visual typesetting"));
|
2007-01-10 22:01:47 +01:00
|
|
|
grid->CommitChanges(false,true);
|
|
|
|
|
2007-01-08 22:11:06 +01:00
|
|
|
// Set flags
|
|
|
|
hold = 0;
|
2007-01-09 02:52:30 +01:00
|
|
|
holding = false;
|
|
|
|
hasOverlay = true;
|
2007-01-10 05:33:03 +01:00
|
|
|
|
|
|
|
// Clean up
|
|
|
|
curSelection = NULL;
|
2007-01-08 22:11:06 +01:00
|
|
|
parent->ReleaseMouse();
|
2007-01-09 02:52:30 +01:00
|
|
|
parent->SetFocus();
|
2007-01-08 22:11:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Double click
|
2007-01-09 02:52:30 +01:00
|
|
|
if (mode == 0 && event.LeftDClick()) {
|
2007-01-23 05:42:08 +01:00
|
|
|
grid->editBox->SetOverride(_T("\\pos"),wxString::Format(_T("(%i,%i)"),vx,vy),0,false);
|
2007-01-08 22:11:06 +01:00
|
|
|
grid->editBox->CommitText();
|
2007-01-26 01:47:42 +01:00
|
|
|
grid->ass->FlagAsModified(_("positioning"));
|
2007-01-08 22:11:06 +01:00
|
|
|
grid->CommitChanges(false,true);
|
2007-01-09 02:52:30 +01:00
|
|
|
parent->SetFocus();
|
2007-01-08 22:11:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Hover
|
2007-01-10 22:01:47 +01:00
|
|
|
if (x != mouseX || y != mouseY) {
|
2007-01-08 22:11:06 +01:00
|
|
|
// Set coords
|
2007-01-10 22:01:47 +01:00
|
|
|
mouseX = x;
|
|
|
|
mouseY = y;
|
2007-01-08 22:11:06 +01:00
|
|
|
hasOverlay = true;
|
|
|
|
}
|
2007-05-28 20:45:57 +02:00
|
|
|
if (event.Leaving()) {
|
|
|
|
mouseX = -1;
|
|
|
|
mouseY = -1;
|
|
|
|
}
|
2007-01-08 22:11:06 +01:00
|
|
|
|
|
|
|
// Has something to draw
|
|
|
|
if (hasOverlay) {
|
2007-01-21 07:30:19 +01:00
|
|
|
//DrawOverlay();
|
|
|
|
parent->Render();
|
2007-01-08 22:11:06 +01:00
|
|
|
}
|
|
|
|
}
|
2007-01-09 02:52:30 +01:00
|
|
|
|
|
|
|
|
|
|
|
/////////////
|
|
|
|
// Key event
|
|
|
|
void VideoDisplayVisual::OnKeyEvent(wxKeyEvent &event) {
|
2007-05-28 20:45:57 +02:00
|
|
|
// FIXME: should these beconfigurable?
|
|
|
|
// Think of the frenchmen and other people not using qwerty layout
|
2007-01-09 02:52:30 +01:00
|
|
|
if (event.GetKeyCode() == 'A') SetMode(0);
|
|
|
|
if (event.GetKeyCode() == 'S') SetMode(1);
|
2007-01-09 07:25:25 +01:00
|
|
|
if (event.GetKeyCode() == 'D') SetMode(2);
|
2007-01-10 22:01:47 +01:00
|
|
|
if (event.GetKeyCode() == 'F') SetMode(3);
|
|
|
|
if (event.GetKeyCode() == 'G') SetMode(4);
|
2007-01-10 22:53:00 +01:00
|
|
|
if (event.GetKeyCode() == 'H') SetMode(5);
|
2007-01-09 02:52:30 +01:00
|
|
|
}
|