summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-05-21 08:33:19 +0200
committerStanislaw Halik <sthalik@misaki.pl>2017-05-21 08:33:19 +0200
commitf3a0f680f83e782aaa7d5bcdfb5dd080fe1e2a10 (patch)
tree302ac6719e1edce6ea1b179ec2c180a4bbcf2d17
parent12119e9fa2566624ed63305448cab9cf21017250 (diff)
spline: minor cleanup
-rw-r--r--spline/spline-widget.cpp43
-rw-r--r--spline/spline-widget.hpp5
2 files changed, 23 insertions, 25 deletions
diff --git a/spline/spline-widget.cpp b/spline/spline-widget.cpp
index c71626f0..0378da09 100644
--- a/spline/spline-widget.cpp
+++ b/spline/spline-widget.cpp
@@ -182,26 +182,25 @@ void spline_widget::drawFunction()
}
}
- const QColor color = progn
- (
- if (!isEnabled() && !_preview_only)
- {
- QColor color(spline_color);
- const int avg = int(float(color.red() + color.green() + color.blue())/3);
- return QColor(int(float(color.red() + avg) * .5f),
- int(float(color.green() + avg) * .5f),
- int(float(color.blue() + avg) * .5f),
- 96);
- }
- else
- {
- QColor color(spline_color);
- color.setAlphaF(color.alphaF() * .9);
- return color;
- }
- );
-
- painter.setPen(QPen(color, 1.75, Qt::SolidLine, Qt::FlatCap));
+ const QColor color_ = progn(
+ if (!isEnabled() && !_preview_only)
+ {
+ QColor color(spline_color);
+ const int avg = int(float(color.red() + color.green() + color.blue())/3);
+ return QColor(int(float(color.red() + avg)*.5f),
+ int(float(color.green() + avg)*.5f),
+ int(float(color.blue() + avg)*.5f),
+ 96);
+ }
+ else
+ {
+ QColor color(spline_color);
+ color.setAlphaF(color.alphaF()*.9);
+ return color;
+ }
+ );
+
+ painter.setPen(QPen(color_, 1.75, Qt::SolidLine, Qt::FlatCap));
//#define DEBUG_SPLINE
#ifndef DEBUG_SPLINE
@@ -329,7 +328,7 @@ void spline_widget::mousePressEvent(QMouseEvent *e)
if (point_within_pixel(points[i], e->pos()))
{
bTouchingPoint = true;
- moving_control_point_idx = int(i);
+ moving_control_point_idx = i;
break;
}
}
@@ -487,7 +486,7 @@ void spline_widget::reload_spline()
int spline_widget::get_closeness_limit()
{
- return std::fmax(snap_x, 1);
+ return iround(std::fmax(snap_x, 1));
}
void spline_widget::show_tooltip(const QPoint& pos, const QPointF& value_)
diff --git a/spline/spline-widget.hpp b/spline/spline-widget.hpp
index 062db493..711bdb2a 100644
--- a/spline/spline-widget.hpp
+++ b/spline/spline-widget.hpp
@@ -40,7 +40,6 @@ public:
spline_widget(QWidget *parent = 0);
~spline_widget();
- spline* config();
void setConfig(spline* spl);
QColor colorBezier() const;
@@ -52,8 +51,8 @@ public:
double x_step() { return _x_step; }
double y_step() { return _y_step; }
- void set_x_step(double val) { _x_step = val; }
- void set_y_step(double val) { _y_step = val; }
+ void set_x_step(double val) { _x_step = std::fmax(1., val); }
+ void set_y_step(double val) { _y_step = std::fmax(1., val); }
void set_snap(double x, double y) { snap_x = x; snap_y = y; }
void get_snap(double& x, double& y) const { x = snap_x; y = snap_y; }