diff --git a/aegisub/Makefile.am b/aegisub/Makefile.am index b7e699cef..284e3e456 100644 --- a/aegisub/Makefile.am +++ b/aegisub/Makefile.am @@ -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 \ diff --git a/aegisub/video_display.cpp b/aegisub/video_display.cpp index 01236f76e..9b35b68c4 100644 --- a/aegisub/video_display.cpp +++ b/aegisub/video_display.cpp @@ -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; } diff --git a/aegisub/visual_tool_clip.cpp b/aegisub/visual_tool_clip.cpp new file mode 100644 index 000000000..61e486e07 --- /dev/null +++ b/aegisub/visual_tool_clip.cpp @@ -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); +} diff --git a/aegisub/visual_tool_clip.h b/aegisub/visual_tool_clip.h new file mode 100644 index 000000000..e3570f9e0 --- /dev/null +++ b/aegisub/visual_tool_clip.h @@ -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(); +}; diff --git a/aegisub/visual_tool_drag.cpp b/aegisub/visual_tool_drag.cpp new file mode 100644 index 000000000..631bb8b31 --- /dev/null +++ b/aegisub/visual_tool_drag.cpp @@ -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() { +} diff --git a/aegisub/visual_tool_drag.h b/aegisub/visual_tool_drag.h new file mode 100644 index 000000000..48470fa78 --- /dev/null +++ b/aegisub/visual_tool_drag.h @@ -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(); +}; diff --git a/aegisub/visual_tool_scale.h b/aegisub/visual_tool_scale.h index 6d7ebfca9..7caab6f17 100644 --- a/aegisub/visual_tool_scale.h +++ b/aegisub/visual_tool_scale.h @@ -42,8 +42,8 @@ #include "visual_tool.h" -///////////////////////// -// Z Rotation tool class +//////////////////// +// Scale tool class class VisualToolScale : public VisualTool { private: float curScaleX,startScaleX,origScaleX;