Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
// Copyright (c) 2005-2010, Niels Martin Hansen
|
|
|
|
// Copyright (c) 2005-2010, Rodrigo Braz Monteiro
|
|
|
|
// Copyright (c) 2010, Amar Takhar
|
|
|
|
// 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 Project http://www.aegisub.org/
|
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
|
|
|
|
/// @file time.cpp
|
|
|
|
/// @brief time/ commands.
|
|
|
|
/// @ingroup command
|
|
|
|
///
|
|
|
|
|
2011-01-05 19:40:37 +01:00
|
|
|
#include "../config.h"
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
|
|
|
|
#ifndef AGI_PRE
|
2011-01-08 13:10:40 +01:00
|
|
|
#include <algorithm>
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "command.h"
|
|
|
|
|
2011-01-18 00:53:59 +01:00
|
|
|
#include "../ass_dialogue.h"
|
|
|
|
#include "../ass_file.h"
|
|
|
|
#include "../audio_controller.h"
|
|
|
|
#include "../audio_timing.h"
|
|
|
|
#include "../dialog_shift_times.h"
|
2011-01-05 19:40:37 +01:00
|
|
|
#include "../include/aegisub/context.h"
|
2011-07-15 06:04:07 +02:00
|
|
|
#include "../main.h"
|
2011-07-15 06:04:13 +02:00
|
|
|
#include "../selection_controller.h"
|
2011-01-05 19:40:37 +01:00
|
|
|
#include "../subs_grid.h"
|
|
|
|
#include "../video_context.h"
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
|
2011-07-15 06:05:01 +02:00
|
|
|
namespace {
|
|
|
|
using cmd::Command;
|
2011-07-15 06:05:22 +02:00
|
|
|
|
|
|
|
struct validate_video_loaded : public Command {
|
2011-07-15 06:05:56 +02:00
|
|
|
CMD_TYPE(COMMAND_VALIDATE)
|
2011-07-15 06:05:22 +02:00
|
|
|
bool Validate(const agi::Context *c) {
|
|
|
|
return c->videoController->IsLoaded();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct validate_adjoinable : public Command {
|
2011-07-15 06:05:56 +02:00
|
|
|
CMD_TYPE(COMMAND_VALIDATE)
|
2011-07-15 06:05:22 +02:00
|
|
|
bool Validate(const agi::Context *c) {
|
|
|
|
SelectionController<AssDialogue>::Selection sel = c->selectionController->GetSelectedSet();
|
|
|
|
if (sel.size() < 2) return false;
|
|
|
|
|
2011-10-17 19:52:22 +02:00
|
|
|
size_t found = 0;
|
2011-07-15 06:05:22 +02:00
|
|
|
for (entryIter it = c->ass->Line.begin(); it != c->ass->Line.end(); ++it) {
|
|
|
|
AssDialogue *diag = dynamic_cast<AssDialogue*>(*it);
|
|
|
|
if (!diag) continue;
|
2011-10-17 19:52:22 +02:00
|
|
|
|
2011-07-15 06:05:22 +02:00
|
|
|
if (sel.count(diag)) {
|
2011-10-17 19:52:22 +02:00
|
|
|
++found;
|
|
|
|
if (found == sel.size())
|
|
|
|
return true;
|
2011-07-15 06:05:22 +02:00
|
|
|
}
|
2011-10-17 19:52:22 +02:00
|
|
|
else if (found)
|
2011-07-15 06:05:22 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
/// @defgroup cmd-time Time manipulation commands.
|
|
|
|
/// @{
|
|
|
|
|
|
|
|
/// Changes times of subs so end times begin on next's start time.
|
2011-07-15 06:05:22 +02:00
|
|
|
struct time_continuous_end : public validate_adjoinable {
|
2011-01-16 08:17:46 +01:00
|
|
|
CMD_NAME("time/continuous/end")
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
STR_MENU("Change &End")
|
|
|
|
STR_DISP("Change End")
|
|
|
|
STR_HELP("Changes times of subs so end times begin on next's start time.")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
2011-01-16 08:16:54 +01:00
|
|
|
wxArrayInt sels = c->subsGrid->GetSelection();
|
|
|
|
c->subsGrid->AdjoinLines(sels.front(), sels.back(), false);
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Changes times of subs so start times begin on previous's end time.
|
2011-07-15 06:05:22 +02:00
|
|
|
struct time_continuous_start : public validate_adjoinable {
|
2011-01-16 08:17:46 +01:00
|
|
|
CMD_NAME("time/continuous/start")
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
STR_MENU("Change &Start")
|
|
|
|
STR_DISP("Change Start")
|
|
|
|
STR_HELP("Changes times of subs so start times begin on previous's end time.")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
2011-01-16 08:16:54 +01:00
|
|
|
wxArrayInt sels = c->subsGrid->GetSelection();
|
|
|
|
c->subsGrid->AdjoinLines(sels.front(), sels.back(), true);
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Shift selection so first selected line starts at current frame.
|
2011-07-15 06:05:22 +02:00
|
|
|
struct time_frame_current : public validate_video_loaded {
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
CMD_NAME("time/frame/current")
|
2011-11-18 06:00:20 +01:00
|
|
|
STR_MENU("Shift to &Current Frame")
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
STR_DISP("Shift to Current Frame")
|
|
|
|
STR_HELP("Shift selection so first selected line starts at current frame.")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
2011-01-16 08:16:54 +01:00
|
|
|
if (!c->videoController->IsLoaded()) return;
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
|
2011-10-13 01:08:11 +02:00
|
|
|
std::set<AssDialogue*> sel = c->selectionController->GetSelectedSet();
|
|
|
|
AssDialogue *active_line = c->selectionController->GetActiveLine();
|
|
|
|
|
|
|
|
if (sel.empty() || !active_line) return;
|
|
|
|
|
|
|
|
int shift_by = c->videoController->TimeAtFrame(c->videoController->GetFrameN(), agi::vfr::START) - active_line->Start.GetMS();
|
|
|
|
|
|
|
|
for (std::set<AssDialogue*>::iterator it = sel.begin(); it != sel.end(); ++it) {
|
|
|
|
(*it)->Start.SetMS((*it)->Start.GetMS() + shift_by);
|
|
|
|
(*it)->End.SetMS((*it)->End.GetMS() + shift_by);
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
}
|
|
|
|
|
2011-09-15 07:16:32 +02:00
|
|
|
c->ass->Commit(_("shift to frame"), AssFile::COMMIT_DIAG_TIME);
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Shift subtitles by time or frames.
|
2011-01-16 08:15:32 +01:00
|
|
|
struct time_shift : public Command {
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
CMD_NAME("time/shift")
|
2011-10-01 20:35:12 +02:00
|
|
|
STR_MENU("S&hift Times...")
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
STR_DISP("Shift Times")
|
|
|
|
STR_HELP("Shift subtitles by time or frames.")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
2011-01-16 08:16:54 +01:00
|
|
|
c->videoController->Stop();
|
2011-09-15 07:17:14 +02:00
|
|
|
(new DialogShiftTimes(c))->Show();
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-10-17 19:52:31 +02:00
|
|
|
static void snap_subs_video(agi::Context *c, bool set_start) {
|
2011-09-15 07:17:22 +02:00
|
|
|
std::set<AssDialogue*> sel = c->selectionController->GetSelectedSet();
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
|
2011-09-15 07:17:22 +02:00
|
|
|
if (!c->videoController->IsLoaded() || sel.empty()) return;
|
|
|
|
|
2011-10-17 19:52:31 +02:00
|
|
|
int start = c->videoController->TimeAtFrame(c->videoController->GetFrameN(), agi::vfr::START);
|
|
|
|
int end = c->videoController->TimeAtFrame(c->videoController->GetFrameN(), agi::vfr::END);
|
2011-09-15 07:17:22 +02:00
|
|
|
|
|
|
|
for (std::set<AssDialogue*>::iterator it = sel.begin(); it != sel.end(); ++it) {
|
2011-10-17 19:52:31 +02:00
|
|
|
if (set_start || (*it)->Start.GetMS() > start)
|
|
|
|
(*it)->Start.SetMS(start);
|
|
|
|
if (!set_start || (*it)->End.GetMS() < end)
|
|
|
|
(*it)->End.SetMS(end);
|
2011-09-15 07:17:22 +02:00
|
|
|
}
|
|
|
|
|
2011-10-17 19:52:31 +02:00
|
|
|
c->ass->Commit(_("timing"), AssFile::COMMIT_DIAG_TIME);
|
2011-09-15 07:17:22 +02:00
|
|
|
}
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
|
|
|
|
/// Set end of selected subtitles to current video frame.
|
2011-07-15 06:05:22 +02:00
|
|
|
struct time_snap_end_video : public validate_video_loaded {
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
CMD_NAME("time/snap/end_video")
|
2011-11-18 06:00:20 +01:00
|
|
|
STR_MENU("Snap &End to Video")
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
STR_DISP("Snap End to Video")
|
|
|
|
STR_HELP("Set end of selected subtitles to current video frame.")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
2011-09-15 07:17:22 +02:00
|
|
|
snap_subs_video(c, false);
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Set start and end of subtitles to the keyframes around current video frame.
|
2011-07-15 06:05:22 +02:00
|
|
|
struct time_snap_scene : public validate_video_loaded {
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
CMD_NAME("time/snap/scene")
|
2011-11-18 06:00:20 +01:00
|
|
|
STR_MENU("Snap to S&cene")
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
STR_DISP("Snap to Scene")
|
|
|
|
STR_HELP("Set start and end of subtitles to the keyframes around current video frame.")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
2011-01-16 08:16:54 +01:00
|
|
|
VideoContext *con = c->videoController;
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
if (!con->IsLoaded() || !con->KeyFramesLoaded()) return;
|
|
|
|
|
|
|
|
// Get frames
|
2011-01-16 08:16:54 +01:00
|
|
|
wxArrayInt sel = c->subsGrid->GetSelection();
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
int curFrame = con->GetFrameN();
|
|
|
|
int prev = 0;
|
|
|
|
int next = 0;
|
|
|
|
|
|
|
|
const std::vector<int> &keyframes = con->GetKeyFrames();
|
|
|
|
if (curFrame < keyframes.front()) {
|
|
|
|
next = keyframes.front();
|
|
|
|
}
|
|
|
|
else if (curFrame >= keyframes.back()) {
|
|
|
|
prev = keyframes.back();
|
|
|
|
next = con->GetLength();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
std::vector<int>::const_iterator kf = std::lower_bound(keyframes.begin(), keyframes.end(), curFrame);
|
|
|
|
if (*kf == curFrame) {
|
|
|
|
prev = *kf;
|
|
|
|
next = *(kf + 1);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
prev = *(kf - 1);
|
|
|
|
next = *kf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get times
|
|
|
|
int start_ms = con->TimeAtFrame(prev,agi::vfr::START);
|
|
|
|
int end_ms = con->TimeAtFrame(next-1,agi::vfr::END);
|
|
|
|
AssDialogue *cur;
|
|
|
|
|
|
|
|
// Update rows
|
|
|
|
for (size_t i=0;i<sel.Count();i++) {
|
2011-01-16 08:16:54 +01:00
|
|
|
cur = c->subsGrid->GetDialogue(sel[i]);
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
cur->Start.SetMS(start_ms);
|
|
|
|
cur->End.SetMS(end_ms);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Commit
|
2011-09-15 07:16:32 +02:00
|
|
|
c->ass->Commit(_("snap to scene"), AssFile::COMMIT_DIAG_TIME);
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-01-18 00:53:59 +01:00
|
|
|
struct time_add_lead_in : public Command {
|
|
|
|
CMD_NAME("time/lead/in")
|
|
|
|
STR_MENU("Add lead in")
|
|
|
|
STR_DISP("Add lead in")
|
|
|
|
STR_HELP("Add lead in")
|
|
|
|
void operator()(agi::Context *c) {
|
2011-07-15 06:04:07 +02:00
|
|
|
if (AssDialogue *line = c->selectionController->GetActiveLine()) {
|
|
|
|
line->Start.SetMS(line->Start.GetMS() - OPT_GET("Audio/Lead/IN")->GetInt());
|
2011-09-15 07:16:32 +02:00
|
|
|
c->ass->Commit(_("add lead in"), AssFile::COMMIT_DIAG_TIME);
|
2011-07-15 06:04:07 +02:00
|
|
|
}
|
2011-01-18 00:53:59 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct time_add_lead_out : public Command {
|
|
|
|
CMD_NAME("time/lead/out")
|
|
|
|
STR_MENU("Add lead out")
|
|
|
|
STR_DISP("Add lead out")
|
|
|
|
STR_HELP("Add lead out")
|
|
|
|
void operator()(agi::Context *c) {
|
2011-07-15 06:04:07 +02:00
|
|
|
if (AssDialogue *line = c->selectionController->GetActiveLine()) {
|
|
|
|
line->End.SetMS(line->End.GetMS() + OPT_GET("Audio/Lead/OUT")->GetInt());
|
2011-09-15 07:16:32 +02:00
|
|
|
c->ass->Commit(_("add lead out"), AssFile::COMMIT_DIAG_TIME);
|
2011-07-15 06:04:07 +02:00
|
|
|
}
|
2011-01-18 00:53:59 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
|
|
|
|
/// Set start of selected subtitles to current video frame.
|
2011-07-15 06:05:22 +02:00
|
|
|
struct time_snap_start_video : public validate_video_loaded {
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
CMD_NAME("time/snap/start_video")
|
2011-11-18 06:00:20 +01:00
|
|
|
STR_MENU("Snap &Start to Video")
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
STR_DISP("Snap Start to Video")
|
|
|
|
STR_HELP("Set start of selected subtitles to current video frame.")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
2011-09-15 07:17:22 +02:00
|
|
|
snap_subs_video(c, true);
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Sort all subtitles by their end times.
|
2011-01-16 08:15:32 +01:00
|
|
|
struct time_sort_end : public Command {
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
CMD_NAME("time/sort/end")
|
|
|
|
STR_MENU("&End Time")
|
|
|
|
STR_DISP("End Time")
|
|
|
|
STR_HELP("Sort all subtitles by their end times.")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
|
|
|
c->ass->Sort(AssFile::CompEnd);
|
2011-09-15 07:16:32 +02:00
|
|
|
c->ass->Commit(_("sort"), AssFile::COMMIT_ORDER);
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Sort all subtitles by their start times.
|
2011-01-16 08:15:32 +01:00
|
|
|
struct time_sort_start : public Command {
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
CMD_NAME("time/sort/start")
|
|
|
|
STR_MENU("&Start Time")
|
|
|
|
STR_DISP("Start Time")
|
|
|
|
STR_HELP("Sort all subtitles by their start times.")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
|
|
|
c->ass->Sort();
|
2011-09-15 07:16:32 +02:00
|
|
|
c->ass->Commit(_("sort"), AssFile::COMMIT_ORDER);
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Sort all subtitles by their style names.
|
2011-01-16 08:15:32 +01:00
|
|
|
struct time_sort_style : public Command {
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
CMD_NAME("time/sort/style")
|
|
|
|
STR_MENU("St&yle Name")
|
|
|
|
STR_DISP("Style Name")
|
|
|
|
STR_HELP("Sort all subtitles by their style names.")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
|
|
|
c->ass->Sort(AssFile::CompStyle);
|
2011-09-15 07:16:32 +02:00
|
|
|
c->ass->Commit(_("sort"), AssFile::COMMIT_ORDER);
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-01-18 00:53:59 +01:00
|
|
|
/// Switch to the next timeable thing (line or syllable)
|
|
|
|
struct time_next : public Command {
|
|
|
|
CMD_NAME("time/next")
|
|
|
|
STR_MENU("Next line")
|
|
|
|
STR_DISP("Next line")
|
2011-01-18 00:54:05 +01:00
|
|
|
STR_HELP("Next line or syllable")
|
2011-01-18 00:53:59 +01:00
|
|
|
void operator()(agi::Context *c) {
|
|
|
|
c->audioController->Stop();
|
|
|
|
if (c->audioController->GetTimingController())
|
|
|
|
c->audioController->GetTimingController()->Next();
|
|
|
|
c->audioController->PlayPrimaryRange();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Switch to the previous timeable thing (line or syllable)
|
|
|
|
struct time_prev : public Command {
|
|
|
|
CMD_NAME("time/prev")
|
|
|
|
STR_MENU("Previous line")
|
|
|
|
STR_DISP("Previous line")
|
2011-01-18 00:54:05 +01:00
|
|
|
STR_HELP("Previous line or syllable")
|
2011-01-18 00:53:59 +01:00
|
|
|
void operator()(agi::Context *c) {
|
|
|
|
c->audioController->Stop();
|
|
|
|
if (c->audioController->GetTimingController())
|
|
|
|
c->audioController->GetTimingController()->Prev();
|
|
|
|
c->audioController->PlayPrimaryRange();
|
|
|
|
}
|
|
|
|
};
|
2011-07-15 06:05:01 +02:00
|
|
|
}
|
2011-01-18 00:53:59 +01:00
|
|
|
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
/// @}
|
|
|
|
|
2011-07-15 06:05:01 +02:00
|
|
|
namespace cmd {
|
|
|
|
void init_time() {
|
|
|
|
reg(new time_add_lead_in);
|
|
|
|
reg(new time_add_lead_out);
|
|
|
|
reg(new time_continuous_end);
|
|
|
|
reg(new time_continuous_start);
|
|
|
|
reg(new time_frame_current);
|
|
|
|
reg(new time_next);
|
|
|
|
reg(new time_prev);
|
|
|
|
reg(new time_shift);
|
|
|
|
reg(new time_snap_end_video);
|
|
|
|
reg(new time_snap_scene);
|
|
|
|
reg(new time_snap_start_video);
|
|
|
|
reg(new time_sort_end);
|
|
|
|
reg(new time_sort_start);
|
|
|
|
reg(new time_sort_style);
|
|
|
|
}
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
}
|