summaryrefslogtreecommitdiff
path: root/plugingui
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2019-07-07 15:16:00 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2020-03-07 20:39:02 +0100
commitc43acb32f36c6658e9b98f46c07de68a81a88e33 (patch)
tree2f483979cce95a4db7b093b1929745d758b9c911 /plugingui
parentd9d7188ad7b22e8991a9ef685840ac0e88566b39 (diff)
Experimental rotating knob graphics.rotating_knobs
Diffstat (limited to 'plugingui')
-rw-r--r--plugingui/humanizerframecontent.cc6
-rw-r--r--plugingui/knob.cc9
-rw-r--r--plugingui/painter.cc62
-rw-r--r--plugingui/painter.h1
-rw-r--r--plugingui/resources/knob.pngbin3597 -> 9287 bytes
-rw-r--r--plugingui/sampleselectionframecontent.cc6
-rw-r--r--plugingui/timingframecontent.cc6
7 files changed, 77 insertions, 13 deletions
diff --git a/plugingui/humanizerframecontent.cc b/plugingui/humanizerframecontent.cc
index 475f16d..0f02cf8 100644
--- a/plugingui/humanizerframecontent.cc
+++ b/plugingui/humanizerframecontent.cc
@@ -43,21 +43,21 @@ HumanizerframeContent::HumanizerframeContent(Widget* parent,
layout.setResizeChildren(false);
attack.resize(80, 80);
- attack_knob.resize(30, 30);
+ attack_knob.resize(31, 31);
attack_knob.showValue(false);
attack_knob.setDefaultValue(Settings::velocity_modifier_weight_default);
attack.setControl(&attack_knob);
layout.addItem(&attack);
falloff.resize(80, 80);
- falloff_knob.resize(30, 30);
+ falloff_knob.resize(31, 31);
falloff_knob.showValue(false);
falloff_knob.setDefaultValue(Settings::velocity_modifier_falloff_default);
falloff.setControl(&falloff_knob);
layout.addItem(&falloff);
stddev.resize(80, 80);
- stddev_knob.resize(30, 30);
+ stddev_knob.resize(31, 31);
stddev_knob.showValue(false);
stddev_knob.setDefaultValue(Settings::velocity_stddev_default/stddev_factor);
stddev.setControl(&stddev_knob);
diff --git a/plugingui/knob.cc b/plugingui/knob.cc
index 3d09d51..bb719a6 100644
--- a/plugingui/knob.cc
+++ b/plugingui/knob.cc
@@ -185,7 +185,11 @@ void Knob::repaintEvent(RepaintEvent* repaintEvent)
Painter p(*this);
p.clear();
- p.drawImageStretched(0, 0, img_knob, diameter, diameter);
+ // Make it start from 20% and stop at 80%
+ double padval = current_value * 0.8 + 0.1;
+
+ //p.drawImageStretched(0, 0, img_knob, diameter, diameter);
+ p.drawRotatedImage(0, 0, padval * 2.0 * M_PI, img_knob);
float range = maximum - minimum;
@@ -208,9 +212,6 @@ void Knob::repaintEvent(RepaintEvent* repaintEvent)
center_y + font.textHeight(buf) / 2 + 1, font, buf);
}
- // Make it start from 20% and stop at 80%
- double padval = current_value * 0.8 + 0.1;
-
double from_x = sin((-1 * padval + 1) * 2 * M_PI) * radius * 0.6;
double from_y = cos((-1 * padval + 1) * 2 * M_PI) * radius * 0.6;
diff --git a/plugingui/painter.cc b/plugingui/painter.cc
index d3f28ff..a844ca5 100644
--- a/plugingui/painter.cc
+++ b/plugingui/painter.cc
@@ -490,6 +490,68 @@ void Painter::drawImage(int x0, int y0, const Drawable& image)
}
#endif
+void Painter::drawRotatedImage(int x0, int y0, float a, const Drawable& image)
+{
+ int fw = image.width();
+ int fh = image.height();
+
+ // Make sure we don't try to draw outside the pixbuf.
+ if(fw > (int)(pixbuf.width - x0))
+ {
+ fw = (int)(pixbuf.width - x0);
+ }
+
+ if(fh > (int)(pixbuf.height - y0))
+ {
+ fh = (int)(pixbuf.height - y0);
+ }
+
+ if((fw < 1) || (fh < 1))
+ {
+ return;
+ }
+
+ const auto cos_a = std::cos(a);
+ const auto sin_a = std::sin(a);
+ for(int y = -1 * std::min(0, y0) - (int)image.height() / 2;
+ y < fh - (int)image.height() / 2; ++y)
+ {
+ //auto y0_ = y - image.height() / 2;
+ for(int x = -1 * std::min(0, x0) - (int)image.width() / 2;
+ x < fw - (int)image.width() / 2; ++x)
+ {
+ //auto x0_ = x - image.width() / 2;
+
+ auto x_rotated = x * cos_a + y * sin_a + image.width() / 2;
+ auto y_rotated = y * cos_a - x * sin_a + image.height() / 2;
+
+ if(x_rotated < 0 ||
+ y_rotated < 0 ||
+ x_rotated >= (int)image.width() ||
+ y_rotated >= (int)image.height())
+ {
+ continue;
+ }
+
+ auto& c = image.getPixel(x_rotated, y_rotated);
+
+ if(x0 + x + (int)image.width() / 2 < 0 ||
+ y0 + y + (int)image.height() / 2< 0 ||
+ x0 + x >= (int)pixbuf.width ||
+ y0 + y >= (int)pixbuf.height)
+ {
+ continue;
+ }
+
+ if (!has_restriction || c == restriction_colour)
+ {
+ pixbuf.addPixel(x0 + x + image.width() / 2,
+ y0 + y + image.height() / 2, c);
+ }
+ }
+ }
+}
+
void Painter::drawRestrictedImage(int x0, int y0, Colour const& colour, const Drawable& image)
{
has_restriction = true;
diff --git a/plugingui/painter.h b/plugingui/painter.h
index 2630b0c..4415ad8 100644
--- a/plugingui/painter.h
+++ b/plugingui/painter.h
@@ -56,6 +56,7 @@ public:
void drawCircle(int x, int y, double r);
void drawFilledCircle(int x, int y, int r);
void drawImage(int x, int y, const Drawable& image);
+ void drawRotatedImage(int x0, int y0, float a, const Drawable& image);
void drawRestrictedImage(int x0, int y0, Colour const& colour, const Drawable& image);
void drawImageStretched(int x, int y, const Drawable& image,
int width, int height);
diff --git a/plugingui/resources/knob.png b/plugingui/resources/knob.png
index 792db2a..ceba6fa 100644
--- a/plugingui/resources/knob.png
+++ b/plugingui/resources/knob.png
Binary files differ
diff --git a/plugingui/sampleselectionframecontent.cc b/plugingui/sampleselectionframecontent.cc
index f0aa5e7..e79a662 100644
--- a/plugingui/sampleselectionframecontent.cc
+++ b/plugingui/sampleselectionframecontent.cc
@@ -43,21 +43,21 @@ SampleselectionframeContent::SampleselectionframeContent(Widget* parent,
layout.setResizeChildren(false);
f_close.resize(80, 80);
- f_close_knob.resize(30, 30);
+ f_close_knob.resize(31, 31);
f_close_knob.showValue(false);
f_close_knob.setDefaultValue(Settings::sample_selection_f_close_default);
f_close.setControl(&f_close_knob);
layout.addItem(&f_close);
f_diverse.resize(80, 80);
- f_diverse_knob.resize(30, 30);
+ f_diverse_knob.resize(31, 31);
f_diverse_knob.showValue(false);
f_diverse_knob.setDefaultValue(Settings::sample_selection_f_diverse_default);
f_diverse.setControl(&f_diverse_knob);
layout.addItem(&f_diverse);
f_random.resize(80, 80);
- f_random_knob.resize(30, 30);
+ f_random_knob.resize(31, 31);
f_random_knob.showValue(false);
f_random_knob.setDefaultValue(Settings::sample_selection_f_random_default);
f_random.setControl(&f_random_knob);
diff --git a/plugingui/timingframecontent.cc b/plugingui/timingframecontent.cc
index ceaf5be..a6a651a 100644
--- a/plugingui/timingframecontent.cc
+++ b/plugingui/timingframecontent.cc
@@ -44,21 +44,21 @@ TimingframeContent::TimingframeContent(Widget* parent,
layout.setResizeChildren(false);
tightness.resize(80, 80);
- tightness_knob.resize(30, 30);
+ tightness_knob.resize(31, 31);
tightness_knob.showValue(false);
tightness_knob.setDefaultValue(tightnessSettingsToKnob(Settings::latency_stddev_default));
tightness.setControl(&tightness_knob);
layout.addItem(&tightness);
regain.resize(80, 80);
- regain_knob.resize(30, 30);
+ regain_knob.resize(31, 31);
regain_knob.showValue(false);
regain_knob.setDefaultValue(Settings::latency_regain_default);
regain.setControl(&regain_knob);
layout.addItem(&regain);
laidback.resize(80, 80);
- laidback_knob.resize(30, 30);
+ laidback_knob.resize(31, 31);
laidback_knob.showValue(false);
laidback_knob.setDefaultValue(Settings::latency_laid_back_ms_default);
laidback_knob.setRange(-100.0f, 100.0f); // +/- 100 ms range