2011-11-06 18:18:20 +01:00
|
|
|
// Copyright (c) 2011, Thomas Goyne <plorkyeran@aegisub.org>
|
2007-07-05 06:32:46 +02:00
|
|
|
//
|
2011-11-06 18:18:20 +01:00
|
|
|
// 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.
|
2007-07-05 06:32:46 +02:00
|
|
|
//
|
2011-11-06 18:18:20 +01:00
|
|
|
// 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.
|
2007-07-05 06:32:46 +02:00
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// Aegisub Project http://www.aegisub.org/
|
|
|
|
|
2022-07-12 14:14:44 +02:00
|
|
|
#pragma once
|
|
|
|
|
2010-05-20 10:55:46 +02:00
|
|
|
#include "visual_feature.h"
|
2007-07-05 06:32:46 +02:00
|
|
|
#include "visual_tool.h"
|
|
|
|
#include "spline.h"
|
2022-07-12 15:59:18 +02:00
|
|
|
#include "command/command.h"
|
2007-07-05 06:32:46 +02:00
|
|
|
|
2010-05-16 08:39:11 +02:00
|
|
|
class wxToolBar;
|
2007-07-05 06:32:46 +02:00
|
|
|
|
2022-07-12 00:58:14 +02:00
|
|
|
/// Button IDs
|
|
|
|
enum VisualToolVectorClipMode {
|
|
|
|
VCLIP_DRAG = 0, // Assumed to be at the start
|
|
|
|
VCLIP_LINE,
|
|
|
|
VCLIP_BICUBIC,
|
|
|
|
VCLIP_CONVERT,
|
|
|
|
VCLIP_INSERT,
|
|
|
|
VCLIP_REMOVE,
|
|
|
|
VCLIP_FREEHAND,
|
|
|
|
VCLIP_FREEHAND_SMOOTH,
|
|
|
|
VCLIP_LAST // Leave this at the end and don't use it
|
|
|
|
};
|
|
|
|
|
2010-05-20 10:55:52 +02:00
|
|
|
/// @class VisualToolVectorClipDraggableFeature
|
|
|
|
/// @brief VisualDraggableFeature with information about a feature's location
|
|
|
|
/// in the spline
|
2014-03-13 02:39:07 +01:00
|
|
|
struct VisualToolVectorClipDraggableFeature final : public VisualDraggableFeature {
|
2010-05-20 10:55:52 +02:00
|
|
|
/// Which curve in the spline this feature is a point on
|
2014-06-03 19:07:19 +02:00
|
|
|
size_t idx = 0;
|
2010-05-20 10:55:52 +02:00
|
|
|
/// 0-3; indicates which part of the curve this point is
|
2014-04-25 19:01:07 +02:00
|
|
|
int point = 0;
|
2010-05-20 10:55:52 +02:00
|
|
|
};
|
|
|
|
|
2014-03-13 02:39:07 +01:00
|
|
|
class VisualToolVectorClip final : public VisualTool<VisualToolVectorClipDraggableFeature> {
|
2010-06-08 08:09:19 +02:00
|
|
|
Spline spline; /// The current spline
|
2013-12-12 01:29:48 +01:00
|
|
|
wxToolBar *toolBar = nullptr; /// The subtoolbar
|
2023-01-14 13:56:21 +01:00
|
|
|
int mode = VCLIP_DRAG; /// 0-7
|
2013-12-12 01:29:48 +01:00
|
|
|
bool inverse = false; /// is iclip?
|
2007-07-07 07:51:18 +02:00
|
|
|
|
2013-09-19 00:52:48 +02:00
|
|
|
std::set<Feature *> box_added;
|
|
|
|
|
2010-06-30 08:29:14 +02:00
|
|
|
void Save();
|
2013-09-19 01:18:38 +02:00
|
|
|
void Commit(wxString message="") override;
|
2010-06-30 08:29:14 +02:00
|
|
|
|
2022-07-12 15:59:18 +02:00
|
|
|
void AddTool(std::string command_name, VisualToolVectorClipMode mode);
|
|
|
|
|
2014-06-03 19:07:19 +02:00
|
|
|
void MakeFeature(size_t idx);
|
2010-06-30 08:29:14 +02:00
|
|
|
void MakeFeatures();
|
2010-06-18 09:14:23 +02:00
|
|
|
|
2013-11-21 18:13:36 +01:00
|
|
|
bool InitializeHold() override;
|
|
|
|
void UpdateHold() override;
|
2007-07-05 06:32:46 +02:00
|
|
|
|
2013-11-21 18:13:36 +01:00
|
|
|
void UpdateDrag(Feature *feature) override;
|
|
|
|
bool InitializeDrag(Feature *feature) override;
|
2007-07-05 06:32:46 +02:00
|
|
|
|
2013-11-21 18:13:36 +01:00
|
|
|
void DoRefresh() override;
|
|
|
|
void Draw() override;
|
2014-06-03 19:07:19 +02:00
|
|
|
|
2007-07-05 06:32:46 +02:00
|
|
|
public:
|
2011-11-06 18:18:20 +01:00
|
|
|
VisualToolVectorClip(VideoDisplay *parent, agi::Context *context);
|
2013-11-21 18:13:36 +01:00
|
|
|
void SetToolbar(wxToolBar *tb) override;
|
2022-07-12 14:14:44 +02:00
|
|
|
|
2023-01-14 13:56:21 +01:00
|
|
|
void SetSubTool(int subtool) override;
|
|
|
|
int GetSubTool() override;
|
2007-07-05 06:32:46 +02:00
|
|
|
};
|