Committed early working \frz visual typesetting
Originally committed to SVN as r756.
This commit is contained in:
parent
283bb7f48d
commit
5b93f561db
4 changed files with 133 additions and 37 deletions
|
@ -910,6 +910,7 @@ void SubsEditBox::SetOverride (wxString tagname,wxString preValue,int forcePos)
|
||||||
// Current tag name
|
// Current tag name
|
||||||
wxString alttagname = tagname;
|
wxString alttagname = tagname;
|
||||||
if (tagname == _T("\\1c")) tagname = _T("\\c");
|
if (tagname == _T("\\1c")) tagname = _T("\\c");
|
||||||
|
if (tagname == _T("\\fr")) tagname = _T("\\frz");
|
||||||
|
|
||||||
// Get block at start
|
// Get block at start
|
||||||
size_t blockn = BlockAtPos(selstart);
|
size_t blockn = BlockAtPos(selstart);
|
||||||
|
@ -927,10 +928,12 @@ void SubsEditBox::SetOverride (wxString tagname,wxString preValue,int forcePos)
|
||||||
// Default value
|
// Default value
|
||||||
wxColour startcolor;
|
wxColour startcolor;
|
||||||
wxFont startfont;
|
wxFont startfont;
|
||||||
|
float startangle;
|
||||||
bool isColor = false;
|
bool isColor = false;
|
||||||
bool isFont = false;
|
bool isFont = false;
|
||||||
bool isPos = false;
|
bool isPos = false;
|
||||||
bool isFlag = false;
|
bool isFlag = false;
|
||||||
|
bool isAngle = false;
|
||||||
bool state = false;
|
bool state = false;
|
||||||
AssStyle *style = grid->ass->GetStyle(grid->GetDialogue(linen)->Style);
|
AssStyle *style = grid->ass->GetStyle(grid->GetDialogue(linen)->Style);
|
||||||
AssStyle defStyle;
|
AssStyle defStyle;
|
||||||
|
@ -978,12 +981,16 @@ void SubsEditBox::SetOverride (wxString tagname,wxString preValue,int forcePos)
|
||||||
else if (tagname == _T("\\pos")) {
|
else if (tagname == _T("\\pos")) {
|
||||||
isPos = true;
|
isPos = true;
|
||||||
}
|
}
|
||||||
|
else if (tagname == _T("\\frz")) {
|
||||||
|
startangle = style->angle;
|
||||||
|
isAngle = true;
|
||||||
|
}
|
||||||
bool hasEnd = isFlag;
|
bool hasEnd = isFlag;
|
||||||
|
|
||||||
// Find current value of style
|
// Find current value of style
|
||||||
AssDialogueBlockOverride *override;
|
AssDialogueBlockOverride *override;
|
||||||
AssOverrideTag *tag;
|
AssOverrideTag *tag;
|
||||||
if (isFont || isColor || isFlag) {
|
if (isFont || isColor || isFlag || isAngle) {
|
||||||
for (size_t i=0;i<=blockn;i++) {
|
for (size_t i=0;i<=blockn;i++) {
|
||||||
override = AssDialogueBlock::GetAsOverride(line->Blocks.at(i));
|
override = AssDialogueBlock::GetAsOverride(line->Blocks.at(i));
|
||||||
if (override) {
|
if (override) {
|
||||||
|
@ -999,6 +1006,7 @@ void SubsEditBox::SetOverride (wxString tagname,wxString preValue,int forcePos)
|
||||||
if (tag->Name == _T("\\i")) startfont.SetStyle(tag->Params.at(0)->AsBool() ? wxFONTSTYLE_ITALIC : wxFONTSTYLE_NORMAL);
|
if (tag->Name == _T("\\i")) startfont.SetStyle(tag->Params.at(0)->AsBool() ? wxFONTSTYLE_ITALIC : wxFONTSTYLE_NORMAL);
|
||||||
if (tag->Name == _T("\\u")) startfont.SetUnderlined(tag->Params.at(0)->AsBool());
|
if (tag->Name == _T("\\u")) startfont.SetUnderlined(tag->Params.at(0)->AsBool());
|
||||||
}
|
}
|
||||||
|
if (isAngle) startangle = tag->Params.at(0)->AsFloat();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1064,6 +1072,11 @@ void SubsEditBox::SetOverride (wxString tagname,wxString preValue,int forcePos)
|
||||||
insert = tagname + preValue;
|
insert = tagname + preValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Angle
|
||||||
|
if (isAngle) {
|
||||||
|
insert = tagname + preValue;
|
||||||
|
}
|
||||||
|
|
||||||
// Get current block as plain or override
|
// Get current block as plain or override
|
||||||
AssDialogueBlockPlain *plain = AssDialogueBlock::GetAsPlain(block);
|
AssDialogueBlockPlain *plain = AssDialogueBlock::GetAsPlain(block);
|
||||||
override = AssDialogueBlock::GetAsOverride(block);
|
override = AssDialogueBlock::GetAsOverride(block);
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "subs_edit_box.h"
|
#include "subs_edit_box.h"
|
||||||
#include "export_visible_lines.h"
|
#include "export_visible_lines.h"
|
||||||
|
#include "utils.h"
|
||||||
#if USE_FEXTRACKER == 1
|
#if USE_FEXTRACKER == 1
|
||||||
#include "../FexTrackerSource/FexTracker.h"
|
#include "../FexTrackerSource/FexTracker.h"
|
||||||
#include "../FexTrackerSource/FexTrackingFeature.h"
|
#include "../FexTrackerSource/FexTrackingFeature.h"
|
||||||
|
@ -186,8 +187,11 @@ void VideoDisplayVisual::DrawOverlay() {
|
||||||
dc.SetPen(wxPen(colour[0],1));
|
dc.SetPen(wxPen(colour[0],1));
|
||||||
|
|
||||||
// Set drawing coordinates
|
// Set drawing coordinates
|
||||||
|
int radius = (int) sqrt(double((dx-orgx)*(dx-orgx)+(dy-orgy)*(dy-orgy)));
|
||||||
dx = dx * w / sw;
|
dx = dx * w / sw;
|
||||||
dy = dy * h / sh;
|
dy = dy * h / sh;
|
||||||
|
orgx = orgx * w / sw;
|
||||||
|
orgy = orgy * h / sh;
|
||||||
|
|
||||||
// Drag
|
// Drag
|
||||||
if (mode == 1) {
|
if (mode == 1) {
|
||||||
|
@ -199,13 +203,22 @@ void VideoDisplayVisual::DrawOverlay() {
|
||||||
// Rotate Z
|
// Rotate Z
|
||||||
if (mode == 2) {
|
if (mode == 2) {
|
||||||
// Calculate radius
|
// Calculate radius
|
||||||
int radius = (int) sqrt(double((dx-orgx)*(dx-orgx)+(dy-orgy)*(dy-orgy)));
|
float arDistort = float(w) * float(sh) / float(h) / float(sw);
|
||||||
|
int oRadiusX = radius * w / sw;
|
||||||
|
int oRadiusY = radius * h / sh;
|
||||||
if (radius < 50) radius = 50;
|
if (radius < 50) radius = 50;
|
||||||
|
int radiusX = radius * w / sw;
|
||||||
|
int radiusY = radius * h / sh;
|
||||||
|
|
||||||
|
// Get angle
|
||||||
|
if (isCur && mode == 2) {
|
||||||
|
rz = curAngle;
|
||||||
|
}
|
||||||
|
else GetLineRotation(diag,rx,ry,rz);
|
||||||
|
|
||||||
// Get deltas
|
// Get deltas
|
||||||
GetLineRotation(diag,rx,ry,rz);
|
deltax = int(cos(rz*3.1415926536/180.0)*radiusX);
|
||||||
deltax = int(cos(rz*3.1415926536/180.0)*radius);
|
deltay = int(-sin(rz*3.1415926536/180.0)*radiusY);
|
||||||
deltay = int(-sin(rz*3.1415926536/180.0)*radius);
|
|
||||||
int odx = dx;
|
int odx = dx;
|
||||||
int ody = dy;
|
int ody = dy;
|
||||||
dx = orgx;
|
dx = orgx;
|
||||||
|
@ -218,9 +231,11 @@ void VideoDisplayVisual::DrawOverlay() {
|
||||||
|
|
||||||
// Draw the circle
|
// Draw the circle
|
||||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||||
dc.DrawCircle(dx,dy,radius+2);
|
dc.DrawEllipse(dx-radiusX-2,dy-radiusY-2,2*radiusX+4,2*radiusY+4);
|
||||||
dc.DrawCircle(dx,dy,radius-2);
|
dc.DrawEllipse(dx-radiusX+2,dy-radiusY+2,2*radiusX-4,2*radiusY-4);
|
||||||
dc.SetBrush(wxBrush(colour[brushCol]));
|
|
||||||
|
// Draw line to mouse
|
||||||
|
dc.DrawLine(dx,dy,mouse_x,mouse_y);
|
||||||
|
|
||||||
// Draw the baseline
|
// Draw the baseline
|
||||||
dc.SetPen(wxPen(colour[3],2));
|
dc.SetPen(wxPen(colour[3],2));
|
||||||
|
@ -228,18 +243,19 @@ void VideoDisplayVisual::DrawOverlay() {
|
||||||
|
|
||||||
// Draw the connection line
|
// Draw the connection line
|
||||||
if (orgx != odx && orgy != ody) {
|
if (orgx != odx && orgy != ody) {
|
||||||
double angle = atan2(double(dy-ody),double(odx-dx)) + rz*3.1415926536/180.0;
|
double angle = atan2(double(dy*sh/h-ody*sh/h),double(odx*sw/w-dx*sw/w)) + rz*3.1415926536/180.0;
|
||||||
int fx = dx+int(cos(angle)*radius);
|
int fx = dx+int(cos(angle)*oRadiusX);
|
||||||
int fy = dy-int(sin(angle)*radius);
|
int fy = dy-int(sin(angle)*oRadiusY);
|
||||||
dc.DrawLine(dx,dy,fx,fy);
|
dc.DrawLine(dx,dy,fx,fy);
|
||||||
//dc.SetPen(wxPen(colour[0],1));
|
//dc.SetPen(wxPen(colour[0],1));
|
||||||
int mdx = cos(rz*3.1415926536/180.0)*10;
|
int mdx = cos(rz*3.1415926536/180.0)*20;
|
||||||
int mdy = -sin(rz*3.1415926536/180.0)*10;
|
int mdy = -sin(rz*3.1415926536/180.0)*20;
|
||||||
dc.DrawLine(fx-mdx,fy-mdy,fx+mdx,fy+mdy);
|
dc.DrawLine(fx-mdx,fy-mdy,fx+mdx,fy+mdy);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw the rotation line
|
// Draw the rotation line
|
||||||
dc.SetPen(wxPen(colour[0],1));
|
dc.SetPen(wxPen(colour[0],1));
|
||||||
|
dc.SetBrush(wxBrush(colour[brushCol]));
|
||||||
dc.DrawCircle(dx+deltax,dy+deltay,4);
|
dc.DrawCircle(dx+deltax,dy+deltay,4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -548,6 +564,8 @@ void VideoDisplayVisual::OnMouseEvent (wxMouseEvent &event) {
|
||||||
int y = event.GetY();
|
int y = event.GetY();
|
||||||
int w = parent->w;
|
int w = parent->w;
|
||||||
int h = parent->h;
|
int h = parent->h;
|
||||||
|
int orgx = -1;
|
||||||
|
int orgy = -1;
|
||||||
int sw,sh;
|
int sw,sh;
|
||||||
parent->GetScriptSize(sw,sh);
|
parent->GetScriptSize(sw,sh);
|
||||||
int frame_n = parent->frame_n;
|
int frame_n = parent->frame_n;
|
||||||
|
@ -610,35 +628,63 @@ void VideoDisplayVisual::OnMouseEvent (wxMouseEvent &event) {
|
||||||
|
|
||||||
// Start dragging
|
// Start dragging
|
||||||
if (mode != 0 && event.LeftIsDown() && !holding) {
|
if (mode != 0 && event.LeftIsDown() && !holding) {
|
||||||
// For each line
|
float rx,ry,rz;
|
||||||
int numRows = parent->grid->GetRows();
|
|
||||||
int startMs = VFR_Output.GetTimeAtFrame(frame_n,true);
|
|
||||||
int endMs = VFR_Output.GetTimeAtFrame(frame_n,false);
|
|
||||||
AssDialogue *diag;
|
|
||||||
AssDialogue *gotDiag = NULL;
|
AssDialogue *gotDiag = NULL;
|
||||||
for (int i=0;i<numRows;i++) {
|
|
||||||
diag = parent->grid->GetDialogue(i);
|
|
||||||
if (diag) {
|
|
||||||
// Line visible?
|
|
||||||
if (diag->Start.GetMS() <= startMs && diag->End.GetMS() >= endMs) {
|
|
||||||
// Get position
|
|
||||||
int lineX,lineY;
|
|
||||||
GetLinePosition(diag,lineX,lineY);
|
|
||||||
lineX = lineX * w / sw;
|
|
||||||
lineY = lineY * h / sh;
|
|
||||||
|
|
||||||
// Mouse over?
|
// Drag
|
||||||
if (x >= lineX-8 && x <= lineX+8 && y >= lineY-8 && y <= lineY+8) {
|
if (mode == 1) {
|
||||||
parent->grid->editBox->SetToLine(i,true);
|
// For each line
|
||||||
gotDiag = diag;
|
int numRows = parent->grid->GetRows();
|
||||||
orig_x = lineX;
|
int startMs = VFR_Output.GetTimeAtFrame(frame_n,true);
|
||||||
orig_y = lineY;
|
int endMs = VFR_Output.GetTimeAtFrame(frame_n,false);
|
||||||
break;
|
AssDialogue *diag;
|
||||||
|
for (int i=0;i<numRows;i++) {
|
||||||
|
diag = parent->grid->GetDialogue(i);
|
||||||
|
if (diag) {
|
||||||
|
// Line visible?
|
||||||
|
if (diag->Start.GetMS() <= startMs && diag->End.GetMS() >= endMs) {
|
||||||
|
// 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) {
|
||||||
|
parent->grid->editBox->SetToLine(i,true);
|
||||||
|
gotDiag = diag;
|
||||||
|
orig_x = lineX;
|
||||||
|
orig_y = lineY;
|
||||||
|
orgx = torgx;
|
||||||
|
orgy = torgy;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Rotate
|
||||||
|
else {
|
||||||
|
// Check if it's within range
|
||||||
|
gotDiag = parent->grid->GetDialogue(parent->grid->editBox->linen);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// OK
|
||||||
|
else {
|
||||||
|
GetLinePosition(gotDiag,orig_x,orig_y,orgx,orgy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Got a line?
|
// Got a line?
|
||||||
if (gotDiag) {
|
if (gotDiag) {
|
||||||
// Set dialogue
|
// Set dialogue
|
||||||
|
@ -650,6 +696,15 @@ void VideoDisplayVisual::OnMouseEvent (wxMouseEvent &event) {
|
||||||
start_y = y;
|
start_y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Rotate Z
|
||||||
|
if (mode == 2) {
|
||||||
|
lineOrgX = orgx;
|
||||||
|
lineOrgY = orgy;
|
||||||
|
startAngle = atan2(double(lineOrgY-y*sh/h),double(x*sw/w-lineOrgX)) * 180.0 / 3.1415926535897932;
|
||||||
|
GetLineRotation(curSelection,rx,ry,rz);
|
||||||
|
origAngle = rz;
|
||||||
|
}
|
||||||
|
|
||||||
// Hold it
|
// Hold it
|
||||||
holding = true;
|
holding = true;
|
||||||
hold = mode;
|
hold = mode;
|
||||||
|
@ -670,6 +725,22 @@ void VideoDisplayVisual::OnMouseEvent (wxMouseEvent &event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Rotate
|
||||||
|
if (hold == 2) {
|
||||||
|
// Find screen angle
|
||||||
|
float screenAngle = atan2(double(lineOrgY-y*sh/h),double(x*sw/w-lineOrgX)) * 180.0 / 3.1415926535897932;
|
||||||
|
|
||||||
|
// Update
|
||||||
|
curAngle = screenAngle - startAngle + origAngle;
|
||||||
|
if (curAngle < 0.0) curAngle += 360.0;
|
||||||
|
if (realTime) {
|
||||||
|
AssLimitToVisibleFilter::SetFrame(frame_n);
|
||||||
|
grid->editBox->SetOverride(_T("\\frz"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curAngle)),0);
|
||||||
|
grid->editBox->CommitText(true);
|
||||||
|
grid->CommitChanges(false,true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// End dragging
|
// End dragging
|
||||||
if (holding && !event.LeftIsDown()) {
|
if (holding && !event.LeftIsDown()) {
|
||||||
// Disable limiting
|
// Disable limiting
|
||||||
|
@ -681,13 +752,23 @@ void VideoDisplayVisual::OnMouseEvent (wxMouseEvent &event) {
|
||||||
grid->editBox->CommitText();
|
grid->editBox->CommitText();
|
||||||
grid->ass->FlagAsModified();
|
grid->ass->FlagAsModified();
|
||||||
grid->CommitChanges(false,true);
|
grid->CommitChanges(false,true);
|
||||||
curSelection = NULL;
|
}
|
||||||
|
|
||||||
|
// Finished rotating subtitles
|
||||||
|
if (hold == 2) {
|
||||||
|
grid->editBox->SetOverride(_T("\\frz"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curAngle)),0);
|
||||||
|
grid->editBox->CommitText();
|
||||||
|
grid->ass->FlagAsModified();
|
||||||
|
grid->CommitChanges(false,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set flags
|
// Set flags
|
||||||
hold = 0;
|
hold = 0;
|
||||||
holding = false;
|
holding = false;
|
||||||
hasOverlay = true;
|
hasOverlay = true;
|
||||||
|
|
||||||
|
// Clean up
|
||||||
|
curSelection = NULL;
|
||||||
parent->ReleaseMouse();
|
parent->ReleaseMouse();
|
||||||
parent->SetFocus();
|
parent->SetFocus();
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,10 +55,12 @@ private:
|
||||||
int start_x,start_y;
|
int start_x,start_y;
|
||||||
int cur_x,cur_y;
|
int cur_x,cur_y;
|
||||||
int orig_x,orig_y;
|
int orig_x,orig_y;
|
||||||
|
float curAngle,startAngle,origAngle;
|
||||||
|
int lineOrgX,lineOrgY;
|
||||||
|
|
||||||
int mode;
|
int mode;
|
||||||
bool holding;
|
|
||||||
int hold;
|
int hold;
|
||||||
|
bool holding;
|
||||||
|
|
||||||
wxBitmap *backbuffer;
|
wxBitmap *backbuffer;
|
||||||
wxString mouseText;
|
wxString mouseText;
|
||||||
|
|
Binary file not shown.
Loading…
Reference in a new issue