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_drag.cpp
|
|
|
|
/// @brief Position all visible subtitles by dragging 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"
|
|
|
|
|
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 "libresrc/libresrc.h"
|
|
|
|
#include "subs_edit_box.h"
|
|
|
|
#include "subs_grid.h"
|
2007-07-01 05:36:17 +02:00
|
|
|
#include "utils.h"
|
2007-07-01 09:09:37 +02:00
|
|
|
#include "vfr.h"
|
2009-09-10 03:41:34 +02:00
|
|
|
#include "video_context.h"
|
|
|
|
#include "video_display.h"
|
2009-09-10 15:06:40 +02:00
|
|
|
#include "visual_tool_drag.h"
|
2007-07-01 05:36:17 +02:00
|
|
|
|
2007-07-04 06:24:47 +02:00
|
|
|
enum {
|
2007-07-07 07:51:18 +02:00
|
|
|
BUTTON_TOGGLE_MOVE = VISUAL_SUB_TOOL_START
|
2007-07-04 06:24:47 +02:00
|
|
|
};
|
2010-05-23 10:53:27 +02:00
|
|
|
static const DraggableFeatureType DRAG_ORIGIN = DRAG_BIG_TRIANGLE;
|
|
|
|
static const DraggableFeatureType DRAG_START = DRAG_BIG_SQUARE;
|
|
|
|
static const DraggableFeatureType DRAG_END = DRAG_BIG_CIRCLE;
|
2007-07-04 06:24:47 +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
|
|
|
|
/// @param toolBar
|
2010-05-16 08:39:11 +02:00
|
|
|
VisualToolDrag::VisualToolDrag(VideoDisplay *parent, VideoState const& video, wxToolBar * toolBar)
|
2010-05-20 10:55:58 +02:00
|
|
|
: VisualTool<VisualToolDragDraggableFeature>(parent, video)
|
2010-05-20 10:55:23 +02:00
|
|
|
, toolBar(toolBar)
|
2010-05-23 10:53:27 +02:00
|
|
|
, primary(NULL)
|
2010-05-20 10:55:23 +02:00
|
|
|
, toggleMoveOnMove(true)
|
2007-07-01 05:36:17 +02:00
|
|
|
{
|
2010-05-20 10:55:23 +02:00
|
|
|
toolBar->AddTool(BUTTON_TOGGLE_MOVE, _("Toggle between \\move and \\pos"), GETIMAGE(visual_move_conv_move_24));
|
2007-07-07 05:21:52 +02:00
|
|
|
toolBar->Realize();
|
|
|
|
toolBar->Show(true);
|
2007-07-04 06:24:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void VisualToolDrag::UpdateToggleButtons() {
|
|
|
|
// Check which bitmap to use
|
|
|
|
bool toMove = true;
|
|
|
|
AssDialogue *line = GetActiveDialogueLine();
|
|
|
|
if (line) {
|
|
|
|
int x1,y1,x2,y2,t1,t2;
|
|
|
|
bool hasMove;
|
|
|
|
GetLineMove(line,hasMove,x1,y1,x2,y2,t1,t2);
|
|
|
|
toMove = !hasMove;
|
|
|
|
}
|
|
|
|
|
|
|
|
// No change needed
|
|
|
|
if (toMove == toggleMoveOnMove) return;
|
|
|
|
|
|
|
|
// Change bitmap
|
2010-05-20 10:55:23 +02:00
|
|
|
if (toMove) {
|
|
|
|
toolBar->SetToolNormalBitmap(BUTTON_TOGGLE_MOVE, GETIMAGE(visual_move_conv_move_24));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
toolBar->SetToolNormalBitmap(BUTTON_TOGGLE_MOVE, GETIMAGE(visual_move_conv_pos_24));
|
|
|
|
}
|
2007-07-04 06:24:47 +02:00
|
|
|
toggleMoveOnMove = toMove;
|
|
|
|
}
|
|
|
|
|
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 Toggle button pressed
|
|
|
|
/// @param event
|
2010-05-20 10:55:23 +02:00
|
|
|
void VisualToolDrag::OnSubTool(wxCommandEvent &event) {
|
2007-07-04 06:24:47 +02:00
|
|
|
// Get line
|
|
|
|
AssDialogue *line = GetActiveDialogueLine();
|
|
|
|
if (!line) return;
|
|
|
|
|
|
|
|
// Toggle \move <-> \pos
|
|
|
|
if (event.GetId() == BUTTON_TOGGLE_MOVE) {
|
|
|
|
// Get coordinates
|
|
|
|
int x1,y1,x2,y2,t1,t2;
|
|
|
|
bool hasMove;
|
|
|
|
GetLinePosition(line,x1,y1);
|
|
|
|
GetLineMove(line,hasMove,x1,y1,x2,y2,t1,t2);
|
2010-05-16 08:39:11 +02:00
|
|
|
parent->ToScriptCoords(&x1, &y1);
|
|
|
|
parent->ToScriptCoords(&x2, &y2);
|
2007-07-04 06:24:47 +02:00
|
|
|
|
|
|
|
// Replace tag
|
2010-05-20 10:55:29 +02:00
|
|
|
if (hasMove) SetOverride(line, L"\\pos",wxString::Format(L"(%i,%i)",x1,y1));
|
|
|
|
else SetOverride(line, L"\\move",wxString::Format(L"(%i,%i,%i,%i,%i,%i)",x1,y1,x1,y1,0,line->End.GetMS() - line->Start.GetMS()));
|
2010-05-20 10:55:23 +02:00
|
|
|
Commit(true);
|
2007-07-04 06:24:47 +02:00
|
|
|
|
|
|
|
// Update display
|
|
|
|
Refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VisualToolDrag::DoRefresh() {
|
|
|
|
UpdateToggleButtons();
|
2007-07-01 05:36:17 +02:00
|
|
|
}
|
|
|
|
|
2010-05-26 09:17:39 +02:00
|
|
|
void VisualToolDrag::OnSelectionChange(bool clear, int row, bool selected) {
|
|
|
|
if (!externalChange) return;
|
|
|
|
externalChange = false;
|
|
|
|
if (clear) {
|
|
|
|
ClearSelection(false);
|
|
|
|
}
|
|
|
|
if (selected) {
|
|
|
|
for (size_t i = 0; i < features.size(); i++) {
|
|
|
|
if (features[i].lineN == row && features[i].type == DRAG_START) {
|
|
|
|
AddSelection(i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (size_t i = 0; i < features.size(); i++) {
|
|
|
|
if (features[i].lineN == row) {
|
|
|
|
RemoveSelection(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
externalChange = true;
|
|
|
|
}
|
|
|
|
|
2007-07-01 05:36:17 +02:00
|
|
|
void VisualToolDrag::Draw() {
|
2007-07-01 09:09:37 +02:00
|
|
|
DrawAllFeatures();
|
2007-07-04 02:36:04 +02:00
|
|
|
|
|
|
|
// Draw arrows
|
2010-05-26 09:17:39 +02:00
|
|
|
for (feature_iterator cur = features.begin(); cur != features.end(); ++cur) {
|
2010-05-23 10:53:27 +02:00
|
|
|
if (cur->type == DRAG_START) continue;
|
2010-05-20 10:55:58 +02:00
|
|
|
VisualDraggableFeature *p2 = &*cur;
|
2010-05-26 09:17:39 +02:00
|
|
|
VisualDraggableFeature *p1 = &features[cur->parent];
|
2010-05-20 10:55:52 +02:00
|
|
|
|
|
|
|
// Has arrow?
|
2010-05-23 10:53:27 +02:00
|
|
|
bool hasArrow = p2->type == DRAG_END;
|
2010-05-20 10:55:52 +02:00
|
|
|
int arrowLen = hasArrow ? 10 : 0;
|
|
|
|
|
|
|
|
// See if the distance between them is enough
|
|
|
|
int dx = p2->x - p1->x;
|
|
|
|
int dy = p2->y - p1->y;
|
|
|
|
int dist = (int)sqrt(double(dx*dx + dy*dy));
|
|
|
|
if (dist < 20+arrowLen) continue;
|
|
|
|
|
|
|
|
// Get end points
|
|
|
|
int x1 = p1->x + dx*10/dist;
|
|
|
|
int x2 = p2->x - dx*(10+arrowLen)/dist;
|
|
|
|
int y1 = p1->y + dy*10/dist;
|
|
|
|
int y2 = p2->y - dy*(10+arrowLen)/dist;
|
|
|
|
|
|
|
|
// Draw arrow
|
|
|
|
if (hasArrow) {
|
|
|
|
// Calculate angle
|
|
|
|
double angle = atan2(double(y2-y1),double(x2-x1))+1.570796;
|
|
|
|
int sx = int(cos(angle)*4);
|
|
|
|
int sy = int(-sin(angle)*4);
|
|
|
|
|
|
|
|
// Arrow line
|
|
|
|
SetLineColour(colour[3],0.8f,2);
|
|
|
|
DrawLine(x1,y1,x2,y2);
|
|
|
|
|
|
|
|
// Arrow head
|
|
|
|
DrawLine(x2+sx,y2-sy,x2-sx,y2+sy);
|
|
|
|
DrawLine(x2+sx,y2-sy,x2+dx*10/dist,y2+dy*10/dist);
|
|
|
|
DrawLine(x2-sx,y2+sy,x2+dx*10/dist,y2+dy*10/dist);
|
|
|
|
}
|
2007-07-04 22:25:24 +02:00
|
|
|
|
2010-05-20 10:55:52 +02:00
|
|
|
// Draw dashed line
|
|
|
|
else {
|
|
|
|
SetLineColour(colour[3],0.5f,2);
|
|
|
|
DrawDashedLine(x1,y1,x2,y2,6);
|
2007-07-04 02:36:04 +02:00
|
|
|
}
|
|
|
|
}
|
2007-07-01 05:36:17 +02:00
|
|
|
}
|
|
|
|
|
2007-07-01 09:09:37 +02:00
|
|
|
void VisualToolDrag::PopulateFeatureList() {
|
2010-05-26 09:17:39 +02:00
|
|
|
ClearSelection(false);
|
|
|
|
primary = -1;
|
|
|
|
GenerateFeatures();
|
|
|
|
}
|
|
|
|
void VisualToolDrag::GenerateFeatures() {
|
2007-07-01 09:09:37 +02:00
|
|
|
features.clear();
|
|
|
|
|
|
|
|
// Get video data
|
2010-05-26 09:17:39 +02:00
|
|
|
BaseGrid* grid = VideoContext::Get()->grid;
|
|
|
|
int numRows = grid->GetRows();
|
2007-07-01 09:09:37 +02:00
|
|
|
|
|
|
|
for (int i=numRows;--i>=0;) {
|
2010-05-26 09:17:39 +02:00
|
|
|
AssDialogue *diag = grid->GetDialogue(i);
|
|
|
|
if (!diag || !BaseGrid::IsDisplayed(diag)) continue;
|
|
|
|
|
|
|
|
// Get position
|
|
|
|
int x1,x2,y1,y2;
|
|
|
|
int t1=0;
|
|
|
|
int t2=diag->End.GetMS()-diag->Start.GetMS();
|
|
|
|
int torgx,torgy;
|
|
|
|
bool hasMove;
|
|
|
|
GetLinePosition(diag,x1,y1,torgx,torgy);
|
|
|
|
GetLineMove(diag,hasMove,x1,y1,x2,y2,t1,t2);
|
|
|
|
|
|
|
|
// Create \pos feature
|
|
|
|
VisualToolDragDraggableFeature feat;
|
|
|
|
feat.x = x1;
|
|
|
|
feat.y = y1;
|
|
|
|
feat.layer = 0;
|
|
|
|
feat.type = DRAG_START;
|
|
|
|
feat.time = t1;
|
|
|
|
feat.line = diag;
|
|
|
|
feat.lineN = i;
|
|
|
|
features.push_back(feat);
|
|
|
|
feat.parent = features.size() - 1;
|
|
|
|
if (grid->IsInSelection(i)) {
|
|
|
|
AddSelection(features.size() - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create move destination feature
|
|
|
|
if (hasMove) {
|
|
|
|
feat.x = x2;
|
|
|
|
feat.y = y2;
|
|
|
|
feat.layer = 1;
|
|
|
|
feat.type = DRAG_END;
|
|
|
|
feat.time = t2;
|
|
|
|
feat.line = diag;
|
|
|
|
feat.lineN = i;
|
|
|
|
features.push_back(feat);
|
|
|
|
features[feat.parent].parent = features.size() - 1;
|
|
|
|
}
|
|
|
|
// Create org feature
|
|
|
|
if (torgx != x1 || torgy != y1) {
|
|
|
|
feat.x = torgx;
|
|
|
|
feat.y = torgy;
|
|
|
|
feat.layer = -1;
|
|
|
|
feat.type = DRAG_ORIGIN;
|
|
|
|
feat.time = 0;
|
|
|
|
feat.line = diag;
|
|
|
|
feat.lineN = i;
|
|
|
|
features.push_back(feat);
|
2007-07-01 09:09:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-05-26 09:17:39 +02:00
|
|
|
|
2010-05-23 10:53:27 +02:00
|
|
|
bool VisualToolDrag::InitializeDrag(VisualToolDragDraggableFeature *feature) {
|
2010-05-26 09:17:39 +02:00
|
|
|
primary = feature - &features[0];
|
2010-05-23 10:53:27 +02:00
|
|
|
return true;
|
|
|
|
}
|
2007-07-01 09:09:37 +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 VisualToolDrag::UpdateDrag(VisualToolDragDraggableFeature* feature) {
|
2010-05-20 10:55:52 +02:00
|
|
|
// Update "time" to reflect the time of the frame in which the feature is being dragged
|
2007-07-04 02:36:04 +02:00
|
|
|
int time = VFR_Output.GetTimeAtFrame(frame_n,true,true);
|
2010-05-20 10:55:58 +02:00
|
|
|
feature->time = MID(0,time - feature->line->Start.GetMS(),feature->line->End.GetMS()-feature->line->Start.GetMS());
|
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 drag
|
|
|
|
/// @param feature
|
2010-05-20 10:55:58 +02:00
|
|
|
void VisualToolDrag::CommitDrag(VisualToolDragDraggableFeature* feature) {
|
2010-05-23 10:53:27 +02:00
|
|
|
if (feature->type == DRAG_ORIGIN) {
|
2010-05-20 10:55:58 +02:00
|
|
|
int x = feature->x;
|
|
|
|
int y = feature->y;
|
2010-05-16 08:39:11 +02:00
|
|
|
parent->ToScriptCoords(&x, &y);
|
2010-05-20 10:55:58 +02:00
|
|
|
SetOverride(feature->line, L"\\org",wxString::Format(L"(%i,%i)",x,y));
|
2010-05-20 10:55:52 +02:00
|
|
|
return;
|
2007-07-04 09:26:24 +02:00
|
|
|
}
|
|
|
|
|
2010-05-26 09:17:39 +02:00
|
|
|
VisualToolDragDraggableFeature *p = feature->parent > -1 ? &features[feature->parent] : NULL;
|
2010-05-23 10:53:27 +02:00
|
|
|
if (feature->type == DRAG_END) {
|
2010-05-20 10:55:52 +02:00
|
|
|
std::swap(feature, p);
|
2007-07-04 02:36:04 +02:00
|
|
|
}
|
|
|
|
|
2010-05-20 10:55:52 +02:00
|
|
|
int x1 = feature->x;
|
|
|
|
int y1 = feature->y;
|
|
|
|
parent->ToScriptCoords(&x1, &y1);
|
|
|
|
|
|
|
|
// Position
|
|
|
|
if (!p) {
|
2010-05-20 10:55:58 +02:00
|
|
|
SetOverride(feature->line, L"\\pos", wxString::Format(L"(%i,%i)", x1, y1));
|
2010-05-20 10:55:52 +02:00
|
|
|
}
|
2007-07-04 02:36:04 +02:00
|
|
|
// Move
|
|
|
|
else {
|
2010-05-20 10:55:52 +02:00
|
|
|
int x2 = p->x;
|
|
|
|
int y2 = p->y;
|
2010-05-16 08:39:11 +02:00
|
|
|
parent->ToScriptCoords(&x2, &y2);
|
|
|
|
|
2007-07-04 02:36:04 +02:00
|
|
|
// Set override
|
2010-05-20 10:55:52 +02:00
|
|
|
SetOverride(feature->line, L"\\move", wxString::Format(L"(%i,%i,%i,%i,%i,%i)", x1, y1, x2, y2, feature->time, p->time));
|
2007-07-04 02:36:04 +02:00
|
|
|
}
|
2007-07-01 05:36:17 +02:00
|
|
|
}
|
2010-05-23 10:53:27 +02:00
|
|
|
void VisualToolDrag::Update() {
|
|
|
|
if (!leftDClick) return;
|
|
|
|
|
|
|
|
int dx, dy;
|
|
|
|
int vx = video.x;
|
|
|
|
int vy = video.y;
|
|
|
|
parent->ToScriptCoords(&vx, &vy);
|
2010-05-26 09:17:39 +02:00
|
|
|
if (primary > -1) {
|
|
|
|
dx = features[primary].x;
|
|
|
|
dy = features[primary].y;
|
2010-05-23 10:53:27 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
AssDialogue* line = GetActiveDialogueLine();
|
|
|
|
if (!line) return;
|
|
|
|
GetLinePosition(line, dx, dy);
|
|
|
|
}
|
|
|
|
parent->ToScriptCoords(&dx, &dy);
|
|
|
|
dx -= vx;
|
|
|
|
dy -= vy;
|
|
|
|
|
|
|
|
SubtitlesGrid *grid = VideoContext::Get()->grid;
|
|
|
|
wxArrayInt sel = grid->GetSelection();
|
|
|
|
for (wxArrayInt::const_iterator cur = sel.begin(); cur != sel.end(); ++cur) {
|
|
|
|
AssDialogue* line = grid->GetDialogue(*cur);
|
|
|
|
if (!line) continue;
|
2010-05-26 09:17:28 +02:00
|
|
|
int x1 = 0, y1 = 0, x2 = 0, y2 = 0, t1 = INT_MIN, t2 = INT_MIN, orgx, orgy;
|
2010-05-23 10:53:27 +02:00
|
|
|
bool isMove;
|
2010-05-26 09:17:28 +02:00
|
|
|
|
|
|
|
GetLinePosition(line, x1, y1, orgx, orgy);
|
2010-05-23 10:53:27 +02:00
|
|
|
GetLineMove(line, isMove, x1, y1, x2, y2, t1, t2);
|
2010-05-26 09:17:28 +02:00
|
|
|
parent->ToScriptCoords(&x1, &y1);
|
|
|
|
parent->ToScriptCoords(&x2, &y2);
|
|
|
|
parent->ToScriptCoords(&orgx, &orgy);
|
|
|
|
|
2010-05-23 10:53:27 +02:00
|
|
|
if (isMove) {
|
|
|
|
if (t1 > INT_MIN && t2 > INT_MIN)
|
|
|
|
SetOverride(line, L"\\move", wxString::Format(L"(%i,%i,%i,%i,%i,%i)", x1 - dx, y1 - dy, x2 - dx, y2 - dy, t1, t2));
|
|
|
|
else
|
|
|
|
SetOverride(line, L"\\move", wxString::Format(L"(%i,%i,%i,%i)", x1, y1, x2, y2));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
SetOverride(line, L"\\pos", wxString::Format(L"(%i,%i)", x1 - dx, y1 - dy));
|
|
|
|
}
|
2010-05-26 09:17:28 +02:00
|
|
|
if (orgx != x1 || orgy != y1) {
|
|
|
|
SetOverride(line, L"\\org", wxString::Format(L"(%i,%i)", orgx - dx, orgy - dy));
|
|
|
|
}
|
2010-05-23 10:53:27 +02:00
|
|
|
}
|
|
|
|
|
2010-05-26 09:17:39 +02:00
|
|
|
Commit(false, _("positioning"));
|
2010-05-23 10:53:27 +02:00
|
|
|
|
2010-05-26 09:17:39 +02:00
|
|
|
GenerateFeatures();
|
2010-05-23 10:53:27 +02:00
|
|
|
}
|