Re-implemented visual typesetting clip, and added a stub for drag.

Originally committed to SVN as r1329.
This commit is contained in:
Rodrigo Braz Monteiro 2007-07-01 03:36:17 +00:00
parent 4dd3a031c6
commit c498c3a0b7
7 changed files with 350 additions and 4 deletions

View File

@ -215,7 +215,9 @@ aegisub_SOURCES = \
video_slider.cpp \
visual_feature.cpp \
visual_tool.cpp \
visual_tool_clip.cpp \
visual_tool_cross.cpp \
visual_tool_drag.cpp \
visual_tool_rotatexy.cpp \
visual_tool_rotatez.cpp \
visual_tool_scale.cpp \

View File

@ -72,6 +72,8 @@
#include "visual_tool_rotatez.h"
#include "visual_tool_rotatexy.h"
#include "visual_tool_scale.h"
#include "visual_tool_clip.h"
#include "visual_tool_drag.h"
///////
@ -648,11 +650,11 @@ void VideoDisplay::SetVisualMode(int mode) {
delete visual;
switch (mode) {
case 0: visual = new VisualToolCross(this); break;
//case 1: visual = new VisualToolDrag(this); break;
case 1: visual = new VisualToolDrag(this); break;
case 2: visual = new VisualToolRotateZ(this); break;
case 3: visual = new VisualToolRotateXY(this); break;
case 4: visual = new VisualToolScale(this); break;
//case 5: visual = new VisualToolClip(this); break;
case 5: visual = new VisualToolClip(this); break;
default: visual = NULL;
}

View File

@ -0,0 +1,128 @@
// 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 "visual_tool_clip.h"
#include "subs_grid.h"
#include "subs_edit_box.h"
#include "ass_file.h"
#include "ass_dialogue.h"
#include "utils.h"
///////////////
// Constructor
VisualToolClip::VisualToolClip(VideoDisplay *_parent)
: VisualTool(_parent)
{
_parent->ShowCursor(false);
}
//////////
// Update
void VisualToolClip::Update() {
// Render parent
GetParent()->Render();
}
////////
// Draw
void VisualToolClip::Draw() {
// Get position
int dx1 = curX1;
int dy1 = curY1;
int dx2 = curX2;
int dy2 = curY2;
// Draw rectangle
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);
// Draw circles
SetLineColour(colour[0]);
SetFillColour(colour[1],0.5);
DrawCircle(dx1,dy1,4);
DrawCircle(dx2,dy1,4);
DrawCircle(dx2,dy2,4);
DrawCircle(dx1,dy2,4);
}
/////////////////
// Start holding
void VisualToolClip::InitializeHold() {
startX = mouseX;
startY = mouseY;
curDiag->StripTag(_T("\\clip"));
}
///////////////
// Update hold
void VisualToolClip::UpdateHold() {
// Coordinates
curX1 = startX * sw / w;
curY1 = startY * sh / h;
curX2 = mouseX * sw / w;
curY2 = mouseY * sh / h;
if (curX1 > curX2) IntSwap(curX1,curX2);
if (curY1 > curY2) IntSwap(curY1,curY2);
}
///////////////
// Commit hold
void VisualToolClip::CommitHold() {
VideoContext::Get()->grid->editBox->SetOverride(_T("\\clip"),wxString::Format(_T("(%i,%i,%i,%i)"),curX1,curY1,curX2,curY2),0,false);
}

View File

@ -0,0 +1,61 @@
// 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 "visual_tool.h"
///////////////////
// Clip tool class
class VisualToolClip : public VisualTool {
private:
int startX,startY,curX1,curY1,curX2,curY2;
bool CanHold() { return true; }
void InitializeHold();
void UpdateHold();
void CommitHold();
public:
VisualToolClip(VideoDisplay *parent);
void Update();
void Draw();
};

View File

@ -0,0 +1,94 @@
// 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 "visual_tool_drag.h"
#include "subs_grid.h"
#include "subs_edit_box.h"
#include "ass_file.h"
#include "ass_dialogue.h"
#include "utils.h"
///////////////
// Constructor
VisualToolDrag::VisualToolDrag(VideoDisplay *_parent)
: VisualTool(_parent)
{
_parent->ShowCursor(false);
}
//////////
// Update
void VisualToolDrag::Update() {
// Render parent
GetParent()->Render();
}
////////
// Draw
void VisualToolDrag::Draw() {
// Get line to draw
AssDialogue *line = GetActiveDialogueLine();
if (!line) return;
}
/////////////////
// Start holding
void VisualToolDrag::InitializeHold() {
}
///////////////
// Update hold
void VisualToolDrag::UpdateHold() {
}
///////////////
// Commit hold
void VisualToolDrag::CommitHold() {
}

View File

@ -0,0 +1,59 @@
// 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 "visual_tool.h"
///////////////////
// Drag tool class
class VisualToolDrag : public VisualTool {
private:
bool CanHold() { return true; }
void InitializeHold();
void UpdateHold();
void CommitHold();
public:
VisualToolDrag(VideoDisplay *parent);
void Update();
void Draw();
};

View File

@ -42,8 +42,8 @@
#include "visual_tool.h"
/////////////////////////
// Z Rotation tool class
////////////////////
// Scale tool class
class VisualToolScale : public VisualTool {
private:
float curScaleX,startScaleX,origScaleX;