Very early reform to visual typesetting, in order to implement the more advanced tools.

Originally committed to SVN as r1322.
This commit is contained in:
Rodrigo Braz Monteiro 2007-06-30 21:56:15 +00:00
parent 3a7fa50f9d
commit af9af29419
5 changed files with 189 additions and 54 deletions

View File

@ -210,6 +210,7 @@ aegisub_SOURCES = \
video_context.cpp \
video_display.cpp \
video_display_visual.cpp \
video_dragable_feature.cpp \
video_frame.cpp \
video_provider.cpp \
video_provider_dummy.cpp \

View File

@ -169,18 +169,18 @@ void VideoDisplayVisual::DrawOverlay() {
// Get scale
if (isCur && mode == 4) {
scalX = curScaleX;
scalY = curScaleY;
scalX = curFloat1;
scalY = curFloat2;
}
else GetLineScale(diag,scalX,scalY);
// Get angle
GetLineRotation(diag,rx,ry,rz);
if (isCur) {
if (mode == 2) rz = curAngle;
if (mode == 2) rz = curFloat1;
else if (mode == 3) {
rx = curAngle;
ry = curAngle2;
rx = curFloat1;
ry = curFloat2;
}
}
@ -859,23 +859,23 @@ void VideoDisplayVisual::OnMouseEvent (wxMouseEvent &event) {
// Rotate Z
if (mode == 2) {
startAngle = atan2(double(lineOrgY-y*sh/h),double(x*sw/w-lineOrgX)) * 180.0 / 3.1415926535897932;
startFloat1 = atan2(double(lineOrgY-y*sh/h),double(x*sw/w-lineOrgX)) * 180.0 / 3.1415926535897932;
GetLineRotation(curSelection,rx,ry,rz);
origAngle = rz;
curAngle = rz;
origFloat1 = rz;
curFloat1 = rz;
curSelection->StripTag(_T("\\frz"));
curSelection->StripTag(_T("\\fr"));
}
// Rotate XY
if (mode == 3) {
startAngle = (lineOrgY-y*sh/h)*2.0;
startAngle2 = (x*sw/w-lineOrgX)*2.0;
startFloat1 = (lineOrgY-y*sh/h)*2.0;
startFloat2 = (x*sw/w-lineOrgX)*2.0;
GetLineRotation(curSelection,rx,ry,rz);
origAngle = rx;
origAngle2 = ry;
curAngle = rx;
curAngle2 = ry;
origFloat1 = rx;
origFloat2 = ry;
curFloat1 = rx;
curFloat2 = ry;
curSelection->StripTag(_T("\\frx"));
curSelection->StripTag(_T("\\fry"));
}
@ -887,10 +887,10 @@ void VideoDisplayVisual::OnMouseEvent (wxMouseEvent &event) {
startX = x;
startY = y;
GetLineScale(curSelection,scalX,scalY);
origScaleX = scalX;
origScaleY = scalY;
curScaleX = scalX;
curScaleY = scalY;
origFloat1 = scalX;
origFloat2 = scalY;
curFloat1 = scalX;
curFloat2 = scalY;
curSelection->StripTag(_T("\\fscx"));
curSelection->StripTag(_T("\\fscy"));
}
@ -930,20 +930,20 @@ void VideoDisplayVisual::OnMouseEvent (wxMouseEvent &event) {
else if (hold == 2) {
// Find angle
float screenAngle = atan2(double(lineOrgY-y*sh/h),double(x*sw/w-lineOrgX)) * 180.0 / 3.1415926535897932;
curAngle = screenAngle - startAngle + origAngle;
while (curAngle < 0.0f) curAngle += 360.0f;
while (curAngle >= 360.0f) curAngle -= 360.0f;
curFloat1 = screenAngle - startFloat1 + origFloat1;
while (curFloat1 < 0.0f) curFloat1 += 360.0f;
while (curFloat1 >= 360.0f) curFloat1 -= 360.0f;
// Snap
if (event.ShiftDown()) {
curAngle = (float)((int)((curAngle+15.0f)/30.0f))*30.0f;
if (curAngle == 360.0f) curAngle = 0.0f;
curFloat1 = (float)((int)((curFloat1+15.0f)/30.0f))*30.0f;
if (curFloat1 == 360.0f) curFloat1 = 0.0f;
}
// Update
if (realTime) {
AssLimitToVisibleFilter::SetFrame(frame_n);
wxString param = PrettyFloat(wxString::Format(_T("(%0.3f)"),curAngle));
wxString param = PrettyFloat(wxString::Format(_T("(%0.3f)"),curFloat1));
grid->editBox->SetOverride(_T("\\frz"),param,0,false);
grid->editBox->CommitText(true);
grid->CommitChanges(false,true);
@ -954,29 +954,29 @@ void VideoDisplayVisual::OnMouseEvent (wxMouseEvent &event) {
else if (hold == 3) {
// Find screen angles
float screenAngle = (lineOrgY-y*sh/h)*2.0;
float screenAngle2 = (x*sw/w-lineOrgX)*2.0;
float screenFloat2 = (x*sw/w-lineOrgX)*2.0;
// Calculate
curAngle = screenAngle - startAngle + origAngle;
curAngle2 = screenAngle2 - startAngle2 + origAngle2;
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;
curFloat1 = screenAngle - startFloat1 + origFloat1;
curFloat2 = screenFloat2 - startFloat2 + origFloat2;
while (curFloat1 < 0.0) curFloat1 += 360.0;
while (curFloat1 >= 360.0) curFloat1 -= 360.0;
while (curFloat2 < 0.0) curFloat2 += 360.0;
while (curFloat2 >= 360.0) curFloat2 -= 360.0;
// 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;
curFloat1 = (float)((int)((curFloat1+15.0f)/30.0f))*30.0f;
curFloat2 = (float)((int)((curFloat2+15.0f)/30.0f))*30.0f;
if (curFloat1 == 360.0f) curFloat1 = 0.0f;
if (curFloat2 == 360.0f) curFloat1 = 0.0f;
}
// Update
if (realTime) {
AssLimitToVisibleFilter::SetFrame(frame_n);
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);
grid->editBox->SetOverride(_T("\\frx"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curFloat1)),0,false);
grid->editBox->SetOverride(_T("\\fry"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curFloat2)),0,false);
grid->editBox->CommitText(true);
grid->CommitChanges(false,true);
}
@ -985,22 +985,22 @@ void VideoDisplayVisual::OnMouseEvent (wxMouseEvent &event) {
// 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;
curFloat1 = (float(x - startX)/0.8f) + origFloat1;
curFloat2 = (float(startY - y)/0.8f) + origFloat2;
if (curFloat1 < 0.0f) curFloat1 = 0.0f;
if (curFloat2 < 0.0f) curFloat2 = 0.0f;
// Snap
if (event.ShiftDown()) {
curScaleX = (float)((int)((curScaleX+12.5f)/25.0f))*25.0f;
curScaleY = (float)((int)((curScaleY+12.5f)/25.0f))*25.0f;
curFloat1 = (float)((int)((curFloat1+12.5f)/25.0f))*25.0f;
curFloat2 = (float)((int)((curFloat2+12.5f)/25.0f))*25.0f;
}
// Update
if (realTime) {
AssLimitToVisibleFilter::SetFrame(frame_n);
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);
grid->editBox->SetOverride(_T("\\fscx"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curFloat1)),0,false);
grid->editBox->SetOverride(_T("\\fscy"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curFloat2)),0,false);
grid->editBox->CommitText(true);
grid->CommitChanges(false,true);
}
@ -1046,19 +1046,19 @@ void VideoDisplayVisual::OnMouseEvent (wxMouseEvent &event) {
// Finished rotating Z
else if (hold == 2) {
grid->editBox->SetOverride(_T("\\frz"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curAngle)),0,false);
grid->editBox->SetOverride(_T("\\frz"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curFloat1)),0,false);
}
// Finished rotating XY
else if (hold == 3) {
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);
grid->editBox->SetOverride(_T("\\frx"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curFloat1)),0,false);
grid->editBox->SetOverride(_T("\\fry"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curFloat2)),0,false);
}
// Finished scaling
else if (hold == 4) {
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);
grid->editBox->SetOverride(_T("\\fscx"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curFloat1)),0,false);
grid->editBox->SetOverride(_T("\\fscy"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curFloat2)),0,false);
}
// Finished clipping
@ -1114,7 +1114,7 @@ void VideoDisplayVisual::OnMouseEvent (wxMouseEvent &event) {
/////////////
// Key event
void VideoDisplayVisual::OnKeyEvent(wxKeyEvent &event) {
// FIXME: should these beconfigurable?
// FIXME: should these be configurable?
// Think of the frenchmen and other people not using qwerty layout
if (event.GetKeyCode() == 'A') SetMode(0);
if (event.GetKeyCode() == 'S') SetMode(1);

View File

@ -40,6 +40,8 @@
///////////
// Headers
#include "gl_wrap.h"
#include "video_dragable_feature.h"
#include <vector>
//////////////
@ -60,9 +62,8 @@ private:
int startX,startY;
int curX,curY,curX2,curY2;
int origX,origY;
float curAngle,startAngle,origAngle;
float curAngle2,startAngle2,origAngle2;
float curScaleX,curScaleY,origScaleX,origScaleY;
float curFloat1,startFloat1,origFloat1;
float curFloat2,startFloat2,origFloat2;
int lineOrgX,lineOrgY;
int mode;
@ -73,6 +74,8 @@ private:
AssDialogue *curSelection;
VideoDisplay *parent;
std::vector<VideoDragAbleFeature> drags;
void GetLinePosition(AssDialogue *diag,int &x,int &y);
void GetLinePosition(AssDialogue *diag,int &x,int &y,int &orgx,int &orgy);
void GetLineRotation(AssDialogue *diag,float &rx,float &ry,float &rz);

View File

@ -0,0 +1,62 @@
// 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
//
///////////
// Headers
#include "video_dragable_feature.h"
///////////////
// Constructor
VideoDragAbleFeature::VideoDragAbleFeature() {
type = DRAG_NONE;
x = -1;
y = -1;
line = NULL;
}
/////////////////////
// Is mouse over it?
bool VideoDragAbleFeature::IsMouseOver(int x,int y) {
return false;
}
////////////////
// Draw feature
void VideoDragAbleFeature::Draw(bool highlighted) {
}

View File

@ -0,0 +1,69 @@
// 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
///////////
// Headers
#include "ass_dialogue.h"
////////////////
// Feature type
enum DragAbleFeatureType {
DRAG_NONE,
DRAG_BIG_SQUARE,
DRAG_BIG_CIRCLE,
DRAG_SMALL_SQUARE,
DRAG_SMALL_CIRCLE
};
/////////////////////
// Drag-able feature
class VideoDragAbleFeature {
public:
DragAbleFeatureType type;
int x,y;
int index;
AssDialogue *line;
bool IsMouseOver(int x,int y);
void Draw(bool highlighted);
VideoDragAbleFeature();
};