2011-11-06 18:18:20 +01:00
|
|
|
// Copyright (c) 2011, Thomas Goyne <plorkyeran@aegisub.org>
|
|
|
|
//
|
|
|
|
// Permission to use, copy, modify, and distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
|
|
// copyright notice and this permission notice appear in all copies.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
//
|
|
|
|
// Aegisub Project http://www.aegisub.org/
|
|
|
|
|
|
|
|
#include "command.h"
|
|
|
|
|
|
|
|
#include "../include/aegisub/context.h"
|
2013-12-25 22:36:37 +01:00
|
|
|
#include "../libresrc/libresrc.h"
|
2014-05-22 01:23:28 +02:00
|
|
|
#include "../project.h"
|
2011-11-06 18:18:20 +01:00
|
|
|
#include "../video_display.h"
|
|
|
|
#include "../visual_tool_clip.h"
|
|
|
|
#include "../visual_tool_cross.h"
|
|
|
|
#include "../visual_tool_drag.h"
|
|
|
|
#include "../visual_tool_rotatexy.h"
|
|
|
|
#include "../visual_tool_rotatez.h"
|
|
|
|
#include "../visual_tool_scale.h"
|
|
|
|
#include "../visual_tool_vector_clip.h"
|
|
|
|
|
2014-04-23 22:53:24 +02:00
|
|
|
#include <libaegisub/make_unique.h>
|
2013-06-08 06:19:40 +02:00
|
|
|
|
2011-11-06 18:18:20 +01:00
|
|
|
namespace {
|
|
|
|
using cmd::Command;
|
|
|
|
|
2012-01-13 21:18:40 +01:00
|
|
|
template<class T>
|
2014-03-13 04:32:57 +01:00
|
|
|
struct visual_tool_command : public Command {
|
2012-01-13 21:18:40 +01:00
|
|
|
CMD_TYPE(COMMAND_VALIDATE | COMMAND_RADIO)
|
|
|
|
|
2013-11-21 18:13:36 +01:00
|
|
|
bool Validate(const agi::Context *c) override {
|
2014-05-22 01:23:28 +02:00
|
|
|
return !!c->project->VideoProvider();
|
2012-01-13 21:18:40 +01:00
|
|
|
}
|
|
|
|
|
2013-11-21 18:13:36 +01:00
|
|
|
bool IsActive(const agi::Context *c) override {
|
2012-01-13 21:18:40 +01:00
|
|
|
return c->videoDisplay->ToolIsType(typeid(T));
|
|
|
|
}
|
|
|
|
|
2013-11-21 18:13:36 +01:00
|
|
|
void operator()(agi::Context *c) override {
|
2014-04-23 22:53:24 +02:00
|
|
|
c->videoDisplay->SetTool(agi::make_unique<T>(c->videoDisplay, c));
|
2011-11-06 18:18:20 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-03-13 02:39:07 +01:00
|
|
|
struct visual_mode_cross final : public visual_tool_command<VisualToolCross> {
|
2011-11-06 18:18:20 +01:00
|
|
|
CMD_NAME("video/tool/cross")
|
2013-12-25 22:36:37 +01:00
|
|
|
CMD_ICON(visual_standard)
|
2011-11-06 18:18:20 +01:00
|
|
|
STR_MENU("Standard")
|
|
|
|
STR_DISP("Standard")
|
2012-02-01 19:47:26 +01:00
|
|
|
STR_HELP("Standard mode, double click sets position")
|
2011-11-06 18:18:20 +01:00
|
|
|
};
|
|
|
|
|
2014-03-13 02:39:07 +01:00
|
|
|
struct visual_mode_drag final : public visual_tool_command<VisualToolDrag> {
|
2011-11-06 18:18:20 +01:00
|
|
|
CMD_NAME("video/tool/drag")
|
2013-12-25 22:36:37 +01:00
|
|
|
CMD_ICON(visual_move)
|
2011-11-06 18:18:20 +01:00
|
|
|
STR_MENU("Drag")
|
|
|
|
STR_DISP("Drag")
|
2012-02-01 19:47:26 +01:00
|
|
|
STR_HELP("Drag subtitles")
|
2011-11-06 18:18:20 +01:00
|
|
|
};
|
|
|
|
|
2014-03-13 02:39:07 +01:00
|
|
|
struct visual_mode_rotate_z final : public visual_tool_command<VisualToolRotateZ> {
|
2011-11-06 18:18:20 +01:00
|
|
|
CMD_NAME("video/tool/rotate/z")
|
2013-12-25 22:36:37 +01:00
|
|
|
CMD_ICON(visual_rotatez)
|
2011-11-06 18:18:20 +01:00
|
|
|
STR_MENU("Rotate Z")
|
|
|
|
STR_DISP("Rotate Z")
|
2012-02-01 19:47:26 +01:00
|
|
|
STR_HELP("Rotate subtitles on their Z axis")
|
2011-11-06 18:18:20 +01:00
|
|
|
};
|
|
|
|
|
2014-03-13 02:39:07 +01:00
|
|
|
struct visual_mode_rotate_xy final : public visual_tool_command<VisualToolRotateXY> {
|
2011-11-06 18:18:20 +01:00
|
|
|
CMD_NAME("video/tool/rotate/xy")
|
2013-12-25 22:36:37 +01:00
|
|
|
CMD_ICON(visual_rotatexy)
|
2011-11-06 18:18:20 +01:00
|
|
|
STR_MENU("Rotate XY")
|
|
|
|
STR_DISP("Rotate XY")
|
2012-02-01 19:47:26 +01:00
|
|
|
STR_HELP("Rotate subtitles on their X and Y axes")
|
2011-11-06 18:18:20 +01:00
|
|
|
};
|
|
|
|
|
2014-03-13 02:39:07 +01:00
|
|
|
struct visual_mode_scale final : public visual_tool_command<VisualToolScale> {
|
2011-11-06 18:18:20 +01:00
|
|
|
CMD_NAME("video/tool/scale")
|
2013-12-25 22:36:37 +01:00
|
|
|
CMD_ICON(visual_scale)
|
2011-11-06 18:18:20 +01:00
|
|
|
STR_MENU("Scale")
|
|
|
|
STR_DISP("Scale")
|
2012-02-01 19:47:26 +01:00
|
|
|
STR_HELP("Scale subtitles on X and Y axes")
|
2011-11-06 18:18:20 +01:00
|
|
|
};
|
|
|
|
|
2014-03-13 02:39:07 +01:00
|
|
|
struct visual_mode_clip final : public visual_tool_command<VisualToolClip> {
|
2011-11-06 18:18:20 +01:00
|
|
|
CMD_NAME("video/tool/clip")
|
2013-12-25 22:36:37 +01:00
|
|
|
CMD_ICON(visual_clip)
|
2011-11-06 18:18:20 +01:00
|
|
|
STR_MENU("Clip")
|
|
|
|
STR_DISP("Clip")
|
2012-02-01 19:47:26 +01:00
|
|
|
STR_HELP("Clip subtitles to a rectangle")
|
2011-11-06 18:18:20 +01:00
|
|
|
};
|
|
|
|
|
2014-03-13 02:39:07 +01:00
|
|
|
struct visual_mode_vector_clip final : public visual_tool_command<VisualToolVectorClip> {
|
2011-11-06 18:18:20 +01:00
|
|
|
CMD_NAME("video/tool/vector_clip")
|
2013-12-25 22:36:37 +01:00
|
|
|
CMD_ICON(visual_vector_clip)
|
2011-11-06 18:18:20 +01:00
|
|
|
STR_MENU("Vector Clip")
|
|
|
|
STR_DISP("Vector Clip")
|
2012-02-01 19:47:26 +01:00
|
|
|
STR_HELP("Clip subtitles to a vectorial area")
|
2011-11-06 18:18:20 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace cmd {
|
|
|
|
void init_visual_tools() {
|
2014-04-23 22:53:24 +02:00
|
|
|
reg(agi::make_unique<visual_mode_cross>());
|
|
|
|
reg(agi::make_unique<visual_mode_drag>());
|
|
|
|
reg(agi::make_unique<visual_mode_rotate_z>());
|
|
|
|
reg(agi::make_unique<visual_mode_rotate_xy>());
|
|
|
|
reg(agi::make_unique<visual_mode_scale>());
|
|
|
|
reg(agi::make_unique<visual_mode_clip>());
|
|
|
|
reg(agi::make_unique<visual_mode_vector_clip>());
|
2011-11-06 18:18:20 +01:00
|
|
|
}
|
|
|
|
}
|