2007-07-01 05:36:17 +02:00
|
|
|
// 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.
|
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// Aegisub Project http://www.aegisub.org/
|
2007-07-01 05:36:17 +02:00
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// $Id$
|
|
|
|
|
|
|
|
/// @file visual_tool_clip.cpp
|
|
|
|
/// @brief Rectangular clipping visual typesetting tool
|
|
|
|
/// @ingroup visual_ts
|
2007-07-01 05:36:17 +02:00
|
|
|
|
2009-01-04 07:31:48 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
2010-06-22 02:03:03 +02:00
|
|
|
#ifndef AGI_PRE
|
|
|
|
#include <utility>
|
|
|
|
#endif
|
|
|
|
|
2007-07-01 05:36:17 +02:00
|
|
|
#include "ass_dialogue.h"
|
2009-09-10 15:06:40 +02:00
|
|
|
#include "ass_file.h"
|
|
|
|
#include "subs_edit_box.h"
|
|
|
|
#include "subs_grid.h"
|
2007-07-01 05:36:17 +02:00
|
|
|
#include "utils.h"
|
2009-09-10 03:41:34 +02:00
|
|
|
#include "video_display.h"
|
2009-09-10 15:06:40 +02:00
|
|
|
#include "visual_tool_clip.h"
|
2007-07-01 05:36:17 +02:00
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Constructor
|
|
|
|
/// @param _parent
|
2010-05-16 08:39:11 +02:00
|
|
|
VisualToolClip::VisualToolClip(VideoDisplay *parent, VideoState const& video, wxToolBar *)
|
2010-05-20 10:55:58 +02:00
|
|
|
: VisualTool<ClipCorner>(parent, video)
|
2010-05-16 08:39:11 +02:00
|
|
|
, curX1(0)
|
|
|
|
, curY1(0)
|
|
|
|
, curX2(video.w)
|
|
|
|
, curY2(video.h)
|
|
|
|
, inverse(false)
|
2007-07-01 05:36:17 +02:00
|
|
|
{
|
2007-07-04 07:22:35 +02:00
|
|
|
AssDialogue *line = GetActiveDialogueLine();
|
2008-09-10 18:13:54 +02:00
|
|
|
if (line) GetLineClip(line,curX1,curY1,curX2,curY2,inverse);
|
2007-07-01 05:36:17 +02:00
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Draw
|
2007-07-01 05:36:17 +02:00
|
|
|
void VisualToolClip::Draw() {
|
2007-07-01 05:57:34 +02:00
|
|
|
AssDialogue *line = GetActiveDialogueLine();
|
|
|
|
if (!line) return;
|
|
|
|
|
2007-07-01 05:36:17 +02:00
|
|
|
int dx1 = curX1;
|
|
|
|
int dy1 = curY1;
|
|
|
|
int dx2 = curX2;
|
|
|
|
int dy2 = curY2;
|
|
|
|
|
|
|
|
// Draw rectangle
|
2007-07-05 06:56:56 +02:00
|
|
|
SetLineColour(colour[3],1.0f,2);
|
2007-07-01 05:36:17 +02:00
|
|
|
SetFillColour(colour[3],0.0f);
|
|
|
|
DrawRectangle(dx1,dy1,dx2,dy2);
|
|
|
|
|
|
|
|
// Draw outside area
|
|
|
|
SetLineColour(colour[3],0.0f);
|
2007-07-05 06:32:46 +02:00
|
|
|
SetFillColour(wxColour(0,0,0),0.5f);
|
2008-09-10 18:13:54 +02:00
|
|
|
if (inverse) {
|
|
|
|
DrawRectangle(dx1,dy1,dx2,dy2);
|
|
|
|
}
|
|
|
|
else {
|
2010-05-16 08:39:11 +02:00
|
|
|
DrawRectangle(0,0,video.w,dy1);
|
|
|
|
DrawRectangle(0,dy2,video.w,video.h);
|
2008-09-10 18:13:54 +02:00
|
|
|
DrawRectangle(0,dy1,dx1,dy2);
|
2010-05-16 08:39:11 +02:00
|
|
|
DrawRectangle(dx2,dy1,video.w,dy2);
|
2008-09-10 18:13:54 +02:00
|
|
|
}
|
2007-07-01 05:36:17 +02:00
|
|
|
|
|
|
|
// Draw circles
|
|
|
|
SetLineColour(colour[0]);
|
|
|
|
SetFillColour(colour[1],0.5);
|
2010-05-20 10:55:35 +02:00
|
|
|
DrawAllFeatures();
|
2007-07-01 05:36:17 +02:00
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Start holding
|
2010-05-20 10:55:35 +02:00
|
|
|
bool VisualToolClip::InitializeHold() {
|
2010-05-16 08:39:11 +02:00
|
|
|
startX = video.x;
|
|
|
|
startY = video.y;
|
|
|
|
curDiag->StripTag(L"\\clip");
|
|
|
|
curDiag->StripTag(L"\\iclip");
|
2010-05-20 10:55:35 +02:00
|
|
|
return true;
|
2007-07-01 05:36:17 +02:00
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Update hold
|
2007-07-01 05:36:17 +02:00
|
|
|
void VisualToolClip::UpdateHold() {
|
|
|
|
// Coordinates
|
2010-05-16 08:39:11 +02:00
|
|
|
curX1 = startX;
|
|
|
|
curY1 = startY;
|
|
|
|
curX2 = video.x;
|
|
|
|
curY2 = video.y;
|
2007-07-01 05:57:34 +02:00
|
|
|
|
|
|
|
// Make sure 1 is smaller than 2
|
2010-06-22 02:03:03 +02:00
|
|
|
if (curX1 > curX2) std::swap(curX1,curX2);
|
|
|
|
if (curY1 > curY2) std::swap(curY1,curY2);
|
2007-07-01 05:57:34 +02:00
|
|
|
|
|
|
|
// Limit to video area
|
2010-05-16 08:39:11 +02:00
|
|
|
curX1 = MID(0,curX1,video.w);
|
|
|
|
curX2 = MID(0,curX2,video.w);
|
|
|
|
curY1 = MID(0,curY1,video.h);
|
|
|
|
curY2 = MID(0,curY2,video.h);
|
2007-07-04 07:22:35 +02:00
|
|
|
|
|
|
|
// Features
|
2010-05-20 10:55:35 +02:00
|
|
|
PopulateFeatureList();
|
2007-07-01 05:36:17 +02:00
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Commit hold
|
2007-07-01 05:36:17 +02:00
|
|
|
void VisualToolClip::CommitHold() {
|
2010-05-20 10:55:18 +02:00
|
|
|
int x1 = curX1;
|
|
|
|
int x2 = curX2;
|
|
|
|
int y1 = curY1;
|
|
|
|
int y2 = curY2;
|
|
|
|
parent->ToScriptCoords(&x1, &y1);
|
|
|
|
parent->ToScriptCoords(&x2, &y2);
|
|
|
|
SetOverride(GetActiveDialogueLine(), inverse ? L"\\iclip" : L"\\clip",wxString::Format(L"(%i,%i,%i,%i)",x1,y1,x2,y2));
|
2007-07-01 05:36:17 +02:00
|
|
|
}
|
2007-07-04 07:22:35 +02:00
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Populate feature list
|
2007-07-04 07:22:35 +02:00
|
|
|
void VisualToolClip::PopulateFeatureList() {
|
|
|
|
// Clear
|
2007-07-04 08:50:03 +02:00
|
|
|
if (features.size() != 4) {
|
2010-05-26 09:17:39 +02:00
|
|
|
ClearSelection(false);
|
2007-07-04 08:50:03 +02:00
|
|
|
features.clear();
|
|
|
|
features.resize(4);
|
|
|
|
}
|
2007-07-04 07:22:35 +02:00
|
|
|
|
|
|
|
// Top-left
|
2007-07-04 08:50:03 +02:00
|
|
|
int i = 0;
|
2010-05-26 09:17:39 +02:00
|
|
|
features[i].x = curX1;
|
|
|
|
features[i].y = curY1;
|
|
|
|
features[i].horiz = &features[1];
|
|
|
|
features[i].vert = &features[2];
|
|
|
|
features[i].type = DRAG_SMALL_CIRCLE;
|
2007-07-04 08:50:03 +02:00
|
|
|
i++;
|
2007-07-04 07:22:35 +02:00
|
|
|
|
|
|
|
// Top-right
|
2010-05-26 09:17:39 +02:00
|
|
|
features[i].x = curX2;
|
|
|
|
features[i].y = curY1;
|
|
|
|
features[i].horiz = &features[0];
|
|
|
|
features[i].vert = &features[3];
|
|
|
|
features[i].type = DRAG_SMALL_CIRCLE;
|
2007-07-04 08:50:03 +02:00
|
|
|
i++;
|
2007-07-04 07:22:35 +02:00
|
|
|
|
|
|
|
// Bottom-left
|
2010-05-26 09:17:39 +02:00
|
|
|
features[i].x = curX1;
|
|
|
|
features[i].y = curY2;
|
|
|
|
features[i].horiz = &features[3];
|
|
|
|
features[i].vert = &features[0];
|
|
|
|
features[i].type = DRAG_SMALL_CIRCLE;
|
2007-07-04 08:50:03 +02:00
|
|
|
i++;
|
2007-07-04 07:22:35 +02:00
|
|
|
|
|
|
|
// Bottom-right
|
2010-05-26 09:17:39 +02:00
|
|
|
features[i].x = curX2;
|
|
|
|
features[i].y = curY2;
|
|
|
|
features[i].horiz = &features[2];
|
|
|
|
features[i].vert = &features[1];
|
|
|
|
features[i].type = DRAG_SMALL_CIRCLE;
|
2007-07-04 08:50:03 +02:00
|
|
|
i++;
|
2007-07-04 07:22:35 +02:00
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Initialize
|
|
|
|
/// @param feature
|
2010-05-20 10:55:58 +02:00
|
|
|
bool VisualToolClip::InitializeDrag(ClipCorner*) {
|
2007-07-04 07:22:35 +02:00
|
|
|
curDiag = GetActiveDialogueLine();
|
2010-05-16 08:39:11 +02:00
|
|
|
curDiag->StripTag(L"\\clip");
|
|
|
|
curDiag->StripTag(L"\\iclip");
|
2010-05-20 10:55:35 +02:00
|
|
|
return true;
|
2007-07-04 07:22:35 +02:00
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Update drag
|
|
|
|
/// @param feature
|
2010-05-20 10:55:58 +02:00
|
|
|
void VisualToolClip::UpdateDrag(ClipCorner* feature) {
|
2007-07-04 07:22:35 +02:00
|
|
|
// Update brothers
|
2010-05-20 10:55:58 +02:00
|
|
|
feature->horiz->y = feature->y;
|
|
|
|
feature->vert->x = feature->x;
|
2007-07-04 07:22:35 +02:00
|
|
|
|
|
|
|
// Get "cur" from features
|
2010-05-26 09:17:39 +02:00
|
|
|
curX1 = features[0].x;
|
|
|
|
curX2 = features[3].x;
|
|
|
|
curY1 = features[0].y;
|
|
|
|
curY2 = features[3].y;
|
2007-07-04 07:22:35 +02:00
|
|
|
|
|
|
|
// Make sure p1 < p2
|
2010-06-22 02:03:03 +02:00
|
|
|
if (curX1 > curX2) std::swap(curX1,curX2);
|
|
|
|
if (curY1 > curY2) std::swap(curY1,curY2);
|
2007-07-04 07:22:35 +02:00
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Done dragging
|
|
|
|
/// @param feature
|
2010-05-20 10:55:58 +02:00
|
|
|
void VisualToolClip::CommitDrag(ClipCorner*) {
|
2007-07-04 07:22:35 +02:00
|
|
|
CommitHold();
|
|
|
|
}
|
2010-06-27 09:53:08 +02:00
|
|
|
|
|
|
|
void VisualToolClip::DoRefresh() {
|
|
|
|
AssDialogue* line = GetActiveDialogueLine();
|
|
|
|
if (line)
|
|
|
|
GetLineClip(line,curX1,curY1,curX2,curY2,inverse);
|
|
|
|
}
|