diff --git a/src/gui/qgsgradientstopeditor.cpp b/src/gui/qgsgradientstopeditor.cpp index 122c48d47be..5dee0a82926 100644 --- a/src/gui/qgsgradientstopeditor.cpp +++ b/src/gui/qgsgradientstopeditor.cpp @@ -26,14 +26,6 @@ #endif #include -#define MARKER_WIDTH 11 -#define MARKER_HEIGHT 14 -#define MARKER_GAP 1.5 -#define MARGIN_BOTTOM ( MARKER_HEIGHT + 2 ) -#define MARGIN_X ( MARKER_WIDTH / 2 ) -#define FRAME_MARGIN 2 -#define CLICK_THRESHOLD ( MARKER_WIDTH / 2 + 3 ) - QgsGradientStopEditor::QgsGradientStopEditor( QWidget *parent, QgsGradientColorRamp *ramp ) : QWidget( parent ) { @@ -106,7 +98,7 @@ void QgsGradientStopEditor::paintEvent( QPaintEvent *event ) painter.setBrush( checkBrush ); painter.setPen( Qt::NoPen ); - QRect box( frameRect.x() + FRAME_MARGIN, frameRect.y() + FRAME_MARGIN, frameRect.width() - 2 * FRAME_MARGIN, frameRect.height() - 2 * FRAME_MARGIN ); + QRect box( frameRect.x() + FRAME_MARGIN_PX, frameRect.y() + FRAME_MARGIN_PX, frameRect.width() - 2 * FRAME_MARGIN_PX, frameRect.height() - 2 * FRAME_MARGIN_PX ); painter.drawRect( box ); @@ -395,7 +387,7 @@ void QgsGradientStopEditor::keyPressEvent( QKeyEvent *e ) if ( selectedStopIsMovable() ) { // calculate offset corresponding to 1 px - double offsetDiff = pointToRelativePosition( rect().x() + MARGIN_X + FRAME_MARGIN + 2 ) - pointToRelativePosition( rect().x() + MARGIN_X + FRAME_MARGIN + 1 ); + double offsetDiff = pointToRelativePosition( rect().x() + MARGIN_X + FRAME_MARGIN_PX + 2 ) - pointToRelativePosition( rect().x() + MARGIN_X + FRAME_MARGIN_PX + 1 ); if ( e->modifiers() & Qt::ShiftModifier ) offsetDiff *= 10.0; @@ -447,8 +439,8 @@ void QgsGradientStopEditor::drawStopMarker( QPainter &painter, QPoint topMiddle, double QgsGradientStopEditor::pointToRelativePosition( int x ) const { - int left = rect().x() + MARGIN_X + FRAME_MARGIN; - int right = left + rect().width() - 2 * MARGIN_X - 2 * FRAME_MARGIN; + int left = rect().x() + MARGIN_X + FRAME_MARGIN_PX; + int right = left + rect().width() - 2 * MARGIN_X - 2 * FRAME_MARGIN_PX; if ( x <= left ) return 0; @@ -460,8 +452,8 @@ double QgsGradientStopEditor::pointToRelativePosition( int x ) const int QgsGradientStopEditor::relativePositionToPoint( double position ) const { - int left = rect().x() + MARGIN_X + FRAME_MARGIN; - int right = left + rect().width() - 2 * MARGIN_X - 2 * FRAME_MARGIN; + int left = rect().x() + MARGIN_X + FRAME_MARGIN_PX; + int right = left + rect().width() - 2 * MARGIN_X - 2 * FRAME_MARGIN_PX; if ( position <= 0 ) return left; diff --git a/src/gui/qgsgradientstopeditor.h b/src/gui/qgsgradientstopeditor.h index 83e79c0014c..6f091acedfa 100644 --- a/src/gui/qgsgradientstopeditor.h +++ b/src/gui/qgsgradientstopeditor.h @@ -200,6 +200,14 @@ class GUI_EXPORT QgsGradientStopEditor : public QWidget //! Polygon for stop triangle marker inner QPolygonF sInnerTriangle; + + static constexpr int FRAME_MARGIN_PX = 2; + static constexpr int MARKER_WIDTH = 11; + static constexpr int MARKER_HEIGHT = 14; + static constexpr double MARKER_GAP = 1.5; + static constexpr int MARGIN_BOTTOM = MARKER_HEIGHT + 2; + static constexpr int MARGIN_X = MARKER_WIDTH / 2; + static constexpr int CLICK_THRESHOLD = MARKER_WIDTH / 2 + 3; }; #endif // QGSGRADIENTSTOPEDITOR_H