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 grid.cpp
|
|
|
|
/// @brief grid/ 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
|
|
|
|
|
|
|
#include "command.h"
|
|
|
|
|
2011-01-18 06:13:26 +01:00
|
|
|
#include "../ass_dialogue.h"
|
|
|
|
#include "../ass_file.h"
|
2011-01-05 19:40:37 +01:00
|
|
|
#include "../include/aegisub/context.h"
|
|
|
|
#include "../subs_grid.h"
|
|
|
|
#include "../main.h"
|
|
|
|
#include "../frame_main.h"
|
2011-01-18 06:13:26 +01:00
|
|
|
#include "../utils.h"
|
|
|
|
|
2011-07-15 06:05:01 +02:00
|
|
|
namespace {
|
|
|
|
using cmd::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
|
|
|
/// @defgroup cmd-grid Subtitle grid commands.
|
|
|
|
/// @{
|
|
|
|
|
|
|
|
/// Move to the next subtitle line.
|
2011-01-16 08:15:32 +01:00
|
|
|
struct grid_line_next : 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("grid/line/next")
|
|
|
|
STR_MENU("Next Line")
|
|
|
|
STR_DISP("Next Line")
|
|
|
|
STR_HELP("Move to the next subtitle line.")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
2011-01-16 08:16:54 +01:00
|
|
|
c->subsGrid->NextLine();
|
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
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Move to the previous line.
|
2011-01-16 08:15:32 +01:00
|
|
|
struct grid_line_prev : 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("grid/line/prev")
|
|
|
|
STR_MENU("Previous Line")
|
|
|
|
STR_DISP("Previous Line")
|
|
|
|
STR_HELP("Move to the previous line.")
|
|
|
|
|
|
|
|
void operator()(agi::Context *c) {
|
2011-01-16 08:16:54 +01:00
|
|
|
c->subsGrid->PrevLine();
|
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
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Cycle through tag hiding modes.
|
2011-01-16 08:15:32 +01:00
|
|
|
struct grid_tag_cycle_hiding : 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("grid/tag/cycle_hiding")
|
|
|
|
STR_MENU("Cycle Tag Hiding")
|
|
|
|
STR_DISP("Cycle Tag Hiding")
|
|
|
|
STR_HELP("Cycle through tag hiding modes.")
|
|
|
|
|
2011-12-22 22:09:31 +01:00
|
|
|
void operator()(agi::Context *) {
|
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 tagMode = OPT_GET("Subtitle/Grid/Hide Overrides")->GetInt();
|
|
|
|
|
|
|
|
// Cycle to next
|
|
|
|
tagMode = (tagMode+1)%3;
|
|
|
|
|
|
|
|
// Show on status bar
|
2012-01-08 02:05:13 +01:00
|
|
|
wxString message;
|
|
|
|
if (tagMode == 0) message = _("ASS Override Tag mode set to show full tags.");
|
|
|
|
if (tagMode == 1) message = _("ASS Override Tag mode set to simplify tags.");
|
|
|
|
if (tagMode == 2) message = _("ASS Override Tag mode set to hide tags.");
|
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
|
|
|
wxGetApp().frame->StatusTimeout(message,10000);
|
|
|
|
|
|
|
|
// Set option
|
|
|
|
OPT_SET("Subtitle/Grid/Hide Overrides")->SetInt(tagMode);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Hide override tags in the subtitle grid.
|
2011-01-16 08:15:32 +01:00
|
|
|
struct grid_tags_hide : 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("grid/tags/hide")
|
2011-11-18 06:00:20 +01:00
|
|
|
STR_MENU("&Hide Tags")
|
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("Hide Tags")
|
|
|
|
STR_HELP("Hide override tags in the subtitle grid.")
|
2011-07-15 06:05:56 +02:00
|
|
|
CMD_TYPE(COMMAND_RADIO)
|
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-12-22 22:09:31 +01:00
|
|
|
bool IsActive(const agi::Context *) {
|
2011-07-15 06:06:03 +02:00
|
|
|
return OPT_GET("Subtitle/Grid/Hide Overrides")->GetInt() == 2;
|
|
|
|
}
|
|
|
|
|
2011-12-22 22:09:31 +01:00
|
|
|
void operator()(agi::Context *) {
|
2011-01-16 08:15:24 +01:00
|
|
|
OPT_SET("Subtitle/Grid/Hide Overrides")->SetInt(2);
|
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
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Show full override tags in the subtitle grid.
|
2011-01-16 08:15:32 +01:00
|
|
|
struct grid_tags_show : 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("grid/tags/show")
|
2011-11-18 06:00:20 +01:00
|
|
|
STR_MENU("Sh&ow Tags")
|
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("Show Tags")
|
|
|
|
STR_HELP("Show full override tags in the subtitle grid.")
|
2011-07-15 06:05:56 +02:00
|
|
|
CMD_TYPE(COMMAND_RADIO)
|
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-12-22 22:09:31 +01:00
|
|
|
bool IsActive(const agi::Context *) {
|
2011-07-15 06:06:03 +02:00
|
|
|
return OPT_GET("Subtitle/Grid/Hide Overrides")->GetInt() == 0;
|
|
|
|
}
|
|
|
|
|
2011-12-22 22:09:31 +01:00
|
|
|
void operator()(agi::Context *) {
|
2011-01-16 08:15:24 +01:00
|
|
|
OPT_SET("Subtitle/Grid/Hide Overrides")->SetInt(0);
|
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
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Replace override tags in the subtitle grid with a simplified placeholder.
|
2011-01-16 08:15:32 +01:00
|
|
|
struct grid_tags_simplify : 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("grid/tags/simplify")
|
2011-11-18 06:00:20 +01:00
|
|
|
STR_MENU("S&implify Tags")
|
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("Simplify Tags")
|
|
|
|
STR_HELP("Replace override tags in the subtitle grid with a simplified placeholder.")
|
2011-07-15 06:05:56 +02:00
|
|
|
CMD_TYPE(COMMAND_RADIO)
|
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-12-22 22:09:31 +01:00
|
|
|
bool IsActive(const agi::Context *) {
|
2011-07-15 06:06:03 +02:00
|
|
|
return OPT_GET("Subtitle/Grid/Hide Overrides")->GetInt() == 1;
|
|
|
|
}
|
|
|
|
|
2011-12-22 22:09:31 +01:00
|
|
|
void operator()(agi::Context *) {
|
2011-01-16 08:15:24 +01:00
|
|
|
OPT_SET("Subtitle/Grid/Hide Overrides")->SetInt(1);
|
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 06:13:26 +01:00
|
|
|
template<class T, class U>
|
|
|
|
static bool move_one(T begin, T end, U value) {
|
|
|
|
T it = find(begin, end, value);
|
|
|
|
assert(it != end);
|
|
|
|
|
|
|
|
T prev = it;
|
|
|
|
++prev;
|
|
|
|
prev = find_if(prev, end, cast<U>());
|
|
|
|
|
|
|
|
if (prev != end) {
|
|
|
|
using std::swap;
|
|
|
|
swap(*it, *prev);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Swap the active line with the dialogue line above it
|
|
|
|
struct grid_swap_up : public Command {
|
|
|
|
CMD_NAME("grid/swap/up")
|
|
|
|
STR_MENU("Move line up")
|
|
|
|
STR_DISP("Move line up")
|
|
|
|
STR_HELP("Move the selected line up one row")
|
2011-07-15 06:05:56 +02:00
|
|
|
CMD_TYPE(COMMAND_VALIDATE)
|
2011-01-18 06:13:26 +01:00
|
|
|
|
2011-11-07 07:18:34 +01:00
|
|
|
bool Validate(const agi::Context *c) {
|
2011-07-15 06:05:22 +02:00
|
|
|
return c->selectionController->GetActiveLine() != 0;
|
|
|
|
}
|
|
|
|
|
2011-01-18 06:13:26 +01:00
|
|
|
void operator()(agi::Context *c) {
|
|
|
|
if (AssDialogue *line = c->selectionController->GetActiveLine()) {
|
|
|
|
if (move_one(c->ass->Line.rbegin(), c->ass->Line.rend(), line))
|
2011-09-15 07:16:32 +02:00
|
|
|
c->ass->Commit(_("swap lines"), AssFile::COMMIT_ORDER);
|
2011-01-18 06:13:26 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Swap the active line with the dialogue line below it
|
|
|
|
struct grid_swap_down : public Command {
|
|
|
|
CMD_NAME("grid/swap/down")
|
2011-07-15 06:05:56 +02:00
|
|
|
STR_MENU("Move line down")
|
|
|
|
STR_DISP("Move line down")
|
|
|
|
STR_HELP("Move the selected line down one row")
|
|
|
|
CMD_TYPE(COMMAND_VALIDATE)
|
2011-01-18 06:13:26 +01:00
|
|
|
|
2011-11-07 07:18:34 +01:00
|
|
|
bool Validate(const agi::Context *c) {
|
2011-07-15 06:05:22 +02:00
|
|
|
return c->selectionController->GetActiveLine() != 0;
|
|
|
|
}
|
|
|
|
|
2011-11-07 07:18:34 +01:00
|
|
|
void operator()(agi::Context *c) {
|
|
|
|
if (AssDialogue *line = c->selectionController->GetActiveLine()) {
|
|
|
|
if (move_one(c->ass->Line.begin(), c->ass->Line.end(), line))
|
|
|
|
c->ass->Commit(_("swap lines"), AssFile::COMMIT_ORDER);
|
|
|
|
}
|
2011-01-18 06:13:26 +01:00
|
|
|
}
|
|
|
|
};
|
2011-07-15 06:05:01 +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
|
|
|
/// @}
|
|
|
|
|
2011-07-15 06:05:01 +02:00
|
|
|
namespace cmd {
|
|
|
|
void init_grid() {
|
|
|
|
reg(new grid_line_next);
|
|
|
|
reg(new grid_line_prev);
|
|
|
|
reg(new grid_swap_down);
|
|
|
|
reg(new grid_swap_up);
|
|
|
|
reg(new grid_tag_cycle_hiding);
|
|
|
|
reg(new grid_tags_hide);
|
|
|
|
reg(new grid_tags_show);
|
|
|
|
reg(new grid_tags_simplify);
|
|
|
|
}
|
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
|
|
|
}
|