MCPcopy Create free account
hub / github.com/LibreSprite/LibreSprite / getHandleAtPoint

Method getHandleAtPoint

src/app/ui/editor/transform_handles.cpp:55–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53};
54
55HandleType TransformHandles::getHandleAtPoint(Editor* editor, const gfx::Point& pt, const Transformation& transform)
56{
57 SkinTheme* theme = static_cast<SkinTheme*>(CurrentTheme::get());
58 she::Surface* gfx = theme->parts.transformationHandle()->bitmap(0);
59 fixmath::fixed angle = fixmath::ftofix(128.0 * transform.angle() / PI);
60
61 Transformation::Corners corners;
62 transform.transformBox(corners);
63
64 std::vector<gfx::Point> screenPoints(corners.size());
65 for (size_t c=0; c<corners.size(); ++c)
66 screenPoints[c] = editor->editorToScreen(
67 gfx::Point((int)corners[c].x, (int)corners[c].y));
68
69 int handle_rs[2] = { gfx->width()*2, gfx->width()*3 };
70 for (int i=0; i<2; ++i) {
71 int handle_r = handle_rs[i];
72 for (size_t c=0; c<HANDLES; ++c) {
73 if (inHandle(pt,
74 (screenPoints[handles_info[c].i1].x+screenPoints[handles_info[c].i2].x)/2,
75 (screenPoints[handles_info[c].i1].y+screenPoints[handles_info[c].i2].y)/2,
76 handle_r, handle_r,
77 angle + handles_info[c].angle)) {
78 return handles_info[c].handle[i];
79 }
80 }
81 }
82
83 // Check if the cursor is in the pivot
84 if (visiblePivot(angle) && getPivotHandleBounds(editor, transform, corners).contains(pt))
85 return PivotHandle;
86
87 return NoHandle;
88}
89
90void TransformHandles::drawHandles(Editor* editor, const Transformation& transform)
91{

Callers 3

onMouseDownMethod · 0.80
onMouseDownMethod · 0.80
onSetCursorMethod · 0.80

Calls 10

ftofixFunction · 0.85
PointClass · 0.85
transformBoxMethod · 0.80
editorToScreenMethod · 0.80
getFunction · 0.50
bitmapMethod · 0.45
angleMethod · 0.45
sizeMethod · 0.45
widthMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected