Skip to content

Commit

Permalink
Merge pull request #990 from ra3xdh/fix-drawresizehandle-usage
Browse files Browse the repository at this point in the history
Fix unnecessary setPen before draw_resize_handle
  • Loading branch information
zergud authored Oct 12, 2024
2 parents e347b82 + 8ad28c5 commit aae2501
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion qucs/diagrams/tabdiagram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void TabDiagram::paintDiagram(QPainter *painter) {
if (isSelected) {
painter->setPen(QPen(Qt::darkGray,3));
painter->drawRect(-5, -y2-5, x2+10, y2+10);
painter->setPen(QPen(Qt::darkRed,2));

misc::draw_resize_handle(painter, QPoint{0, -y2});
misc::draw_resize_handle(painter, QPoint{0, 0});
misc::draw_resize_handle(painter, QPoint{x2, -y2});
Expand Down
5 changes: 3 additions & 2 deletions qucs/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -846,11 +846,12 @@ void misc::draw_resize_handle(QPainter* painter, const QPointF& center) {
// 1. Find out where on canvas lies the central point and remember these
// coordinates
// 2. Remove all transformations and draw the handle in its natural size
QRectF resize_handle{0, 0, 10, 10}; // nothing special, just a size
static QRectF resize_handle{0, 0, 10, 10}; // nothing special, just a size
resize_handle.moveCenter(painter->transform().map(center));

static QTransform transform{}; // reset transformation
painter->save();
painter->setTransform(QTransform{});
painter->setTransform(transform);
painter->setPen(QPen{Qt::darkRed, 2});
painter->drawRect(resize_handle);
painter->restore();
Expand Down
2 changes: 0 additions & 2 deletions qucs/paintings/ellipse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ void qucs::Ellipse::paint(QPainter *painter) {
painter->setPen(QPen(Qt::white, Pen.width(), Pen.style()));
painter->drawEllipse(cx, cy, x2, y2);

painter->setPen(QPen(Qt::darkRed,2));

misc::draw_resize_handle(painter, QPoint{cx, cy});
misc::draw_resize_handle(painter, QPoint{cx, cy + y2});
misc::draw_resize_handle(painter, QPoint{cx + x2, cy});
Expand Down
2 changes: 0 additions & 2 deletions qucs/paintings/ellipsearc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ void EllipseArc::paint(QPainter *painter) {
painter->setPen(QPen(Qt::white, Pen.width(), Pen.style()));
painter->drawArc(cx, cy, x2, y2, Angle, ArcLen);

painter->setPen(QPen(Qt::darkRed, 2));

misc::draw_resize_handle(painter, QPoint{cx, cy});
misc::draw_resize_handle(painter, QPoint{cx, cy + y2});
misc::draw_resize_handle(painter, QPoint{cx + x2, cy});
Expand Down

0 comments on commit aae2501

Please sign in to comment.