mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-05 00:09:32 -04:00
Rename FRAME_MARGIN to FRAME_MARGIN_PX to avoid clash with winapi constant
And move to constexpr
This commit is contained in:
parent
56297a13ea
commit
8e1209a576
@ -26,14 +26,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
|
||||||
#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 )
|
QgsGradientStopEditor::QgsGradientStopEditor( QWidget *parent, QgsGradientColorRamp *ramp )
|
||||||
: QWidget( parent )
|
: QWidget( parent )
|
||||||
{
|
{
|
||||||
@ -106,7 +98,7 @@ void QgsGradientStopEditor::paintEvent( QPaintEvent *event )
|
|||||||
painter.setBrush( checkBrush );
|
painter.setBrush( checkBrush );
|
||||||
painter.setPen( Qt::NoPen );
|
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 );
|
painter.drawRect( box );
|
||||||
|
|
||||||
@ -395,7 +387,7 @@ void QgsGradientStopEditor::keyPressEvent( QKeyEvent *e )
|
|||||||
if ( selectedStopIsMovable() )
|
if ( selectedStopIsMovable() )
|
||||||
{
|
{
|
||||||
// calculate offset corresponding to 1 px
|
// 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 )
|
if ( e->modifiers() & Qt::ShiftModifier )
|
||||||
offsetDiff *= 10.0;
|
offsetDiff *= 10.0;
|
||||||
@ -447,8 +439,8 @@ void QgsGradientStopEditor::drawStopMarker( QPainter &painter, QPoint topMiddle,
|
|||||||
|
|
||||||
double QgsGradientStopEditor::pointToRelativePosition( int x ) const
|
double QgsGradientStopEditor::pointToRelativePosition( int x ) const
|
||||||
{
|
{
|
||||||
int left = rect().x() + MARGIN_X + FRAME_MARGIN;
|
int left = rect().x() + MARGIN_X + FRAME_MARGIN_PX;
|
||||||
int right = left + rect().width() - 2 * MARGIN_X - 2 * FRAME_MARGIN;
|
int right = left + rect().width() - 2 * MARGIN_X - 2 * FRAME_MARGIN_PX;
|
||||||
|
|
||||||
if ( x <= left )
|
if ( x <= left )
|
||||||
return 0;
|
return 0;
|
||||||
@ -460,8 +452,8 @@ double QgsGradientStopEditor::pointToRelativePosition( int x ) const
|
|||||||
|
|
||||||
int QgsGradientStopEditor::relativePositionToPoint( double position ) const
|
int QgsGradientStopEditor::relativePositionToPoint( double position ) const
|
||||||
{
|
{
|
||||||
int left = rect().x() + MARGIN_X + FRAME_MARGIN;
|
int left = rect().x() + MARGIN_X + FRAME_MARGIN_PX;
|
||||||
int right = left + rect().width() - 2 * MARGIN_X - 2 * FRAME_MARGIN;
|
int right = left + rect().width() - 2 * MARGIN_X - 2 * FRAME_MARGIN_PX;
|
||||||
|
|
||||||
if ( position <= 0 )
|
if ( position <= 0 )
|
||||||
return left;
|
return left;
|
||||||
|
@ -200,6 +200,14 @@ class GUI_EXPORT QgsGradientStopEditor : public QWidget
|
|||||||
|
|
||||||
//! Polygon for stop triangle marker inner
|
//! Polygon for stop triangle marker inner
|
||||||
QPolygonF sInnerTriangle;
|
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
|
#endif // QGSGRADIENTSTOPEDITOR_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user