visual tools: Add setting for shape handle size

This commit is contained in:
arch1t3cht 2023-05-18 23:39:00 +02:00
parent 20cc0b8077
commit c8f8e8ac42
7 changed files with 22 additions and 7 deletions

View File

@ -580,6 +580,7 @@
"Grid": false,
"Org Mode": 0
},
"Shape Handle Size": 3,
"Autohide": false
}
},

View File

@ -580,6 +580,7 @@
"Grid": false,
"Org Mode": 0
},
"Shape Handle Size": 3,
"Autohide": false
}
},

View File

@ -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);
@ -228,6 +228,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");
p->SetSizerAndFit(p->sizer);
}

View File

@ -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;
@ -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;
@ -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;

View File

@ -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;

View File

@ -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())
{
}
@ -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);
}
}

View File

@ -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;