Skip to content

Commit

Permalink
Merge branch 'vector_clip_actions' into feature
Browse files Browse the repository at this point in the history
  • Loading branch information
arch1t3cht committed May 18, 2023
2 parents 4365b16 + c8f8e8a commit 5e51c59
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/libresrc/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@
"Grid": false,
"Org Mode": 0
},
"Shape Handle Size": 3,
"Autohide": false
},
"Align to Video" : {
Expand Down
1 change: 1 addition & 0 deletions src/libresrc/osx/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@
"Grid": false,
"Org Mode": 0
},
"Shape Handle Size": 3,
"Autohide": false
},
"Align to Video" : {
Expand Down
7 changes: 5 additions & 2 deletions src/preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void General_DefaultStyles(wxTreebook *book, Preferences *parent) {
instructions->Wrap(400);
staticbox->Add(instructions, 0, wxALL, 5);
staticbox->AddSpacer(16);

auto general = new wxFlexGridSizer(2, 5, 5);
general->AddGrowableCol(0, 1);
staticbox->Add(general, 1, wxEXPAND, 5);
Expand Down Expand Up @@ -232,6 +232,9 @@ void Interface(wxTreebook *book, Preferences *parent) {
auto tl_assistant = p->PageSizer(_("Translation Assistant"));
p->OptionAdd(tl_assistant, _("Skip over whitespace"), "Tool/Translation Assistant/Skip Whitespace");

auto visual_tools = p->PageSizer(_("Visual Tools"));
p->OptionAdd(visual_tools, _("Shape handle size"), "Tool/Visual/Shape Handle Size");

auto color_picker = p->PageSizer(_("Colour Picker"));
p->OptionAdd(color_picker, _("Restrict Screen Picker to Window"), "Tool/Colour Picker/Restrict to Window");

Expand Down Expand Up @@ -459,7 +462,7 @@ void Advanced_Video(wxTreebook *book, Preferences *parent) {

wxArrayString sp_choice = to_wx(SubtitlesProviderFactory::GetClasses());
p->OptionChoice(expert, _("Subtitles provider"), sp_choice, "Subtitle/Provider");


#ifdef WITH_AVISYNTH
auto avisynth = p->PageSizer("Avisynth");
Expand Down
13 changes: 9 additions & 4 deletions src/visual_feature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@
///

#include "gl_wrap.h"
#include "options.h"
#include "visual_feature.h"

VisualDraggableFeature::VisualDraggableFeature()
: size(OPT_GET("Tool/Visual/Shape Handle Size")->GetInt())
{}

bool VisualDraggableFeature::IsMouseOver(Vector2D mouse_pos) const {
if (!pos) return false;

Expand All @@ -54,10 +59,10 @@ bool VisualDraggableFeature::IsMouseOver(Vector2D mouse_pos) const {
}

case DRAG_SMALL_SQUARE:
return fabs(delta.X()) < 3 && fabs(delta.Y()) < 3;
return fabs(delta.X()) < size && fabs(delta.Y()) < size;

case DRAG_SMALL_CIRCLE:
return delta.SquareLen() < 9;
return delta.SquareLen() < 3 * size;

default:
return false;
Expand Down Expand Up @@ -88,11 +93,11 @@ void VisualDraggableFeature::Draw(OpenGLWrapper const& gl) const {
break;

case DRAG_SMALL_SQUARE:
gl.DrawRectangle(pos - 3, pos + 3);
gl.DrawRectangle(pos - size, pos + size);
break;

case DRAG_SMALL_CIRCLE:
gl.DrawCircle(pos, 3);
gl.DrawCircle(pos, size);
break;
default:
break;
Expand Down
3 changes: 3 additions & 0 deletions src/visual_feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,13 @@ class VisualDraggableFeature : public boost::intrusive::make_list_base_hook<boos

public:
DraggableFeatureType type = DRAG_NONE; ///< Shape of feature
int size = 0;
Vector2D pos; ///< Position of this feature
int layer = 0; ///< Layer; Higher = above
AssDialogue* line = nullptr; ///< The dialogue line this feature is for; may be nullptr

VisualDraggableFeature();

/// @brief Is the given point over this feature?
/// @param mouse_pos Position of the mouse
bool IsMouseOver(Vector2D mouse_pos) const;
Expand Down
5 changes: 3 additions & 2 deletions src/visual_tool_vector_clip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ int BUTTON_ID_BASE = 1300;
VisualToolVectorClip::VisualToolVectorClip(VideoDisplay *parent, agi::Context *context)
: VisualTool<VisualToolVectorClipDraggableFeature>(parent, context)
, spline(this)
, featureSize(OPT_GET("Tool/Visual/Shape Handle Size")->GetInt())
{
}

Expand Down Expand Up @@ -154,11 +155,11 @@ void VisualToolVectorClip::Draw() {

if (feature.type == DRAG_SMALL_SQUARE) {
gl.SetLineColour(line_color, .5f, 1);
gl.DrawRectangle(feature.pos - 3, feature.pos + 3);
gl.DrawRectangle(feature.pos - featureSize, feature.pos + featureSize);
}
else {
gl.SetLineColour(feature_color, .5f, 1);
gl.DrawCircle(feature.pos, 2.f);
gl.DrawCircle(feature.pos, featureSize * 2.f / 3.f);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/visual_tool_vector_clip.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class VisualToolVectorClip final : public VisualTool<VisualToolVectorClipDraggab
wxToolBar *toolBar = nullptr; /// The subtoolbar
int mode = VCLIP_DRAG; /// 0-7
bool inverse = false; /// is iclip?
int featureSize = 0;

std::set<Feature *> box_added;

Expand Down

0 comments on commit 5e51c59

Please sign in to comment.