Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: arrow tool glitches #2395

Merged
merged 1 commit into from
Feb 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/tools/arrow/arrowtool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ QPainterPath getArrowHead(QPoint p1, QPoint p2, const int thickness)
// Create the vector for the position of the base of the arrowhead
QLineF temp(QPoint(0, 0), p2 - p1);
int val = ArrowHeight + thickness * 4;
if (base.length() < val) {
if (base.length() < (val - thickness * 2)) {
val = static_cast<int>(base.length() + thickness * 2);
}
temp.setLength(base.length() + thickness * 2 - val);
Expand Down Expand Up @@ -45,10 +45,13 @@ QLine getShorterLine(QPoint p1, QPoint p2, const int thickness)
{
QLineF l(p1, p2);
int val = ArrowHeight + thickness * 4;
if (l.length() < val) {
val = static_cast<int>(l.length() + thickness * 2);
}
l.setLength(l.length() + thickness * 2 - val);
if (l.length() < (val - thickness * 2)) {
// here should be 0, but then we lose "angle", so this is hack, but
// looks not very bad
val = thickness / 4;
l.setLength(val);
} else
l.setLength(l.length() + thickness * 2 - val);
return l.toLine();
}

Expand Down