summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugin/drumgizmo_plugin.h2
-rw-r--r--plugingui/checkbox.cc13
-rw-r--r--plugingui/maintab.cc27
-rw-r--r--plugingui/maintab.h4
-rw-r--r--plugingui/powerwidget.cc120
-rw-r--r--plugingui/powerwidget.h18
-rw-r--r--plugingui/testmain.cc4
7 files changed, 77 insertions, 111 deletions
diff --git a/plugin/drumgizmo_plugin.h b/plugin/drumgizmo_plugin.h
index b422430..1f91fbc 100644
--- a/plugin/drumgizmo_plugin.h
+++ b/plugin/drumgizmo_plugin.h
@@ -213,5 +213,5 @@ private:
bool inline_image_first_draw{true};
static constexpr std::size_t width{750};
- static constexpr std::size_t height{613};
+ static constexpr std::size_t height{713};
};
diff --git a/plugingui/checkbox.cc b/plugingui/checkbox.cc
index 1893f59..f3601bd 100644
--- a/plugingui/checkbox.cc
+++ b/plugingui/checkbox.cc
@@ -32,19 +32,18 @@ namespace GUI
{
CheckBox::CheckBox(Widget* parent)
- : Toggle(parent)
- , bg_on(getImageCache(), ":resources/switch_back_on.png")
- , bg_off(getImageCache(), ":resources/switch_back_off.png")
- , knob(getImageCache(), ":resources/switch_front.png")
+ : Toggle(parent)
+ , bg_on(getImageCache(), ":resources/switch_back_on.png")
+ , bg_off(getImageCache(), ":resources/switch_back_off.png")
+ , knob(getImageCache(), ":resources/switch_front.png")
{
}
void CheckBox::repaintEvent(RepaintEvent* repaintEvent)
{
Painter p(*this);
-
- p.drawImage(
- 0, (knob.height() - bg_on.height()) / 2, state ? bg_on : bg_off);
+ p.clear();
+ p.drawImage(0, (knob.height() - bg_on.height()) / 2, state ? bg_on : bg_off);
if(clicked)
{
diff --git a/plugingui/maintab.cc b/plugingui/maintab.cc
index e09d530..d425583 100644
--- a/plugingui/maintab.cc
+++ b/plugingui/maintab.cc
@@ -81,6 +81,10 @@ The pink areas indicate the spread of the position and velocity of the\n\
next note in line. The wider the area the more the note can move in time\n\
and velocity.";
+constexpr char power_tip[] =
+R"lit(Some explanatory text about how the power curvatures work and how they
+can be controlled.)lit";
+
} // end anonymous namespace
namespace GUI
@@ -100,6 +104,7 @@ MainTab::MainTab(Widget* parent,
, timingframe_content{this, settings, settings_notifier}
, sampleselectionframe_content{this, settings, settings_notifier}
, visualizerframe_content{this, settings, settings_notifier}
+ , powerframe_content{this, settings, settings_notifier}
, settings(settings)
, settings_notifier(settings_notifier)
{
@@ -111,16 +116,18 @@ MainTab::MainTab(Widget* parent,
add("Resampling", resampling_frame, resamplingframe_content, 10, 0);
add("Disk Streaming", diskstreaming_frame, diskstreamingframe_content, 9, 0);
- add("Velocity Humanizer", humanizer_frame, humanizerframe_content, 10, 1);
+ add("Velocity Humanizer", humanizer_frame, humanizerframe_content, 8, 1);
humanizer_frame.setHelpText(humanizer_tip);
- add("Timing Humanizer", timing_frame, timingframe_content, 10, 1);
+ add("Timing Humanizer", timing_frame, timingframe_content, 8, 1);
timing_frame.setHelpText(timing_tip);
add("Sample Selection", sampleselection_frame,
- sampleselectionframe_content, 10, 1);
+ sampleselectionframe_content, 8, 1);
sampleselection_frame.setHelpText(sampleselection_tip);
- add("Visualizer", visualizer_frame, visualizerframe_content, 10, 1);
+ add("Visualizer", visualizer_frame, visualizerframe_content, 8, 1);
visualizer_frame.setHelpText(visualizer_tip);
- add("Bleed Control", bleedcontrol_frame, bleedcontrolframe_content, 9, 1);
+ add("Velocity Curve", power_frame, powerframe_content, 9, 1);
+ power_frame.setHelpText(power_tip);
+ add("Bleed Control", bleedcontrol_frame, bleedcontrolframe_content, 8, 1);
humanizer_frame.setOnSwitch(settings.enable_velocity_modifier);
bleedcontrol_frame.setOnSwitch(settings.enable_bleed_control);
@@ -146,6 +153,11 @@ MainTab::MainTab(Widget* parent,
this, &MainTab::timingOnChange);
CONNECT(&bleedcontrol_frame, onEnabledChanged,
&bleedcontrolframe_content, &BleedcontrolframeContent::setEnabled);
+
+ CONNECT(&settings_notifier, enable_powermap,
+ &power_frame, &FrameWidget::setOnSwitch);
+ CONNECT(&power_frame, onSwitchChangeNotifier,
+ this, &MainTab::powerOnChange);
}
void MainTab::resize(std::size_t width, std::size_t height)
@@ -178,6 +190,11 @@ void MainTab::timingOnChange(bool on)
settings.enable_latency_modifier.store(on);
}
+void MainTab::powerOnChange(bool on)
+{
+ settings.enable_powermap.store(on);
+}
+
void MainTab::add(std::string const& title, FrameWidget& frame, Widget& content,
std::size_t height, int column)
{
diff --git a/plugingui/maintab.h b/plugingui/maintab.h
index ea46f11..a19b183 100644
--- a/plugingui/maintab.h
+++ b/plugingui/maintab.h
@@ -38,6 +38,7 @@
#include "timingframecontent.h"
#include "sampleselectionframecontent.h"
#include "visualizerframecontent.h"
+#include "powerwidget.h"
struct Settings;
class SettingsNotifier;
@@ -63,6 +64,7 @@ private:
void bleedcontrolOnChange(bool on);
void resamplingOnChange(bool on);
void timingOnChange(bool on);
+ void powerOnChange(bool on);
Image logo{":resources/logo.png"};
@@ -77,6 +79,7 @@ private:
FrameWidget timing_frame{this, true, true};
FrameWidget sampleselection_frame{this, false, true};
FrameWidget visualizer_frame{this, false, true};
+ FrameWidget power_frame{this, true, true};
DrumkitframeContent drumkitframe_content;
StatusframeContent statusframe_content;
@@ -87,6 +90,7 @@ private:
TimingframeContent timingframe_content;
SampleselectionframeContent sampleselectionframe_content;
VisualizerframeContent visualizerframe_content;
+ PowerWidget powerframe_content;
void add(std::string const& title, FrameWidget& frame, Widget& content,
std::size_t height, int column);
diff --git a/plugingui/powerwidget.cc b/plugingui/powerwidget.cc
index 60c056d..560a5d3 100644
--- a/plugingui/powerwidget.cc
+++ b/plugingui/powerwidget.cc
@@ -31,7 +31,6 @@
#include <notifier.h>
#include <settings.h>
#include <colour.h>
-
#include <powermap.h>
#include <hugin.hpp>
@@ -46,67 +45,15 @@ PowerWidget::PowerWidget(GUI::Widget* parent,
{
canvas.move(7, 7);
- CONNECT(&checkbox_enable, stateChangedNotifier, this, &PowerWidget::chk_enable);
- CONNECT(&knob0_x, valueChangedNotifier, this, &PowerWidget::k0_x);
- CONNECT(&knob0_y, valueChangedNotifier, this, &PowerWidget::k0_y);
- CONNECT(&knob1_x, valueChangedNotifier, this, &PowerWidget::k1_x);
- CONNECT(&knob1_y, valueChangedNotifier, this, &PowerWidget::k1_y);
- CONNECT(&knob2_x, valueChangedNotifier, this, &PowerWidget::k2_x);
- CONNECT(&knob2_y, valueChangedNotifier, this, &PowerWidget::k2_y);
- CONNECT(&checkbox_shelf, stateChangedNotifier, this, &PowerWidget::chk_shelf);
-
- checkbox_enable.resize(100, 42);
- knob0_x.resize(42, 42);
- knob0_y.resize(42, 42);
- knob1_x.resize(42, 42);
- knob1_y.resize(42, 42);
- knob2_x.resize(42, 42);
- knob2_y.resize(42, 42);
- checkbox_shelf.resize(100, 42);
-
- CONNECT(&settings_notifier, enable_powermap, &checkbox_enable, &GUI::CheckBox::setChecked);
- CONNECT(&settings_notifier, fixed0_x, &knob0_x, &GUI::Knob::setValue);
- CONNECT(&settings_notifier, fixed0_y, &knob0_y, &GUI::Knob::setValue);
- CONNECT(&settings_notifier, fixed1_x, &knob1_x, &GUI::Knob::setValue);
- CONNECT(&settings_notifier, fixed1_y, &knob1_y, &GUI::Knob::setValue);
- CONNECT(&settings_notifier, fixed2_x, &knob2_x, &GUI::Knob::setValue);
- CONNECT(&settings_notifier, fixed2_y, &knob2_y, &GUI::Knob::setValue);
- CONNECT(&settings_notifier, shelf, &checkbox_shelf, &GUI::CheckBox::setChecked);
-}
-
-void PowerWidget::chk_enable(bool v)
-{
- settings.enable_powermap.store(v);
-}
-
-void PowerWidget::k0_x(float v)
-{
- settings.fixed0_x.store(v);
-}
-
-void PowerWidget::k0_y(float v)
-{
- settings.fixed0_y.store(v);
-}
-
-void PowerWidget::k1_x(float v)
-{
- settings.fixed1_x.store(v);
-}
-
-void PowerWidget::k1_y(float v)
-{
- settings.fixed1_y.store(v);
-}
+ CONNECT(&shelf_checkbox, stateChangedNotifier, this, &PowerWidget::chk_shelf);
-void PowerWidget::k2_x(float v)
-{
- settings.fixed2_x.store(v);
-}
+ shelf_label.setText("Shelf");
+ shelf_label.setAlignment(GUI::TextAlignment::center);
+ shelf_label.resize(59, 16);
+ shelf_checkbox.resize(59, 40);
-void PowerWidget::k2_y(float v)
-{
- settings.fixed2_y.store(v);
+ CONNECT(&settings_notifier, shelf, &shelf_checkbox,
+ &GUI::CheckBox::setChecked);
}
void PowerWidget::chk_shelf(bool v)
@@ -117,7 +64,7 @@ void PowerWidget::chk_shelf(bool v)
void PowerWidget::repaintEvent(GUI::RepaintEvent *repaintEvent)
{
GUI::Painter p(*this);
- box.setSize(width(), height() / 2);
+ box.setSize(width() - 59, height());
p.drawImage(0, 0, box);
}
@@ -129,16 +76,10 @@ void PowerWidget::resize(std::size_t width, std::size_t height)
canvas.resize(1, 1);
return;
}
- canvas.resize(width - 14, height / 2 - 14);
-
- checkbox_enable.move(220, height / 2 + 14);
- knob0_x.move(0, height / 2 + 14);
- knob0_y.move(0, height / 2 + 14 + 60);
- knob1_x.move(80, height / 2 + 14);
- knob1_y.move(80, height / 2 + 14 + 60);
- knob2_x.move(160, height / 2 + 14);
- knob2_y.move(160, height / 2 + 14 + 60);
- checkbox_shelf.move(220, height / 2 + 14 + 60);
+ canvas.resize(width - 14 - 59, height - 14);
+
+ shelf_label.move(width - 59 + 5, 0);
+ shelf_checkbox.move(width - 59 + 5, 16);
}
PowerWidget::Canvas::Canvas(GUI::Widget* parent,
@@ -181,19 +122,19 @@ void PowerWidget::Canvas::repaintEvent(GUI::RepaintEvent *repaintEvent)
// draw the fixed nodes of the spline
float rad = radius * width();
- p.setColour(GUI::Colour{0.0f, 0.7f, 0.5f, 1.0f});
+ p.setColour(GUI::Colour{0.0f, 1.0f, 0.0f, 0.7f});
p.drawFilledCircle(settings.fixed0_x.load() * width(),
height() - settings.fixed0_y.load() * height(), rad);
p.drawCircle(power_map.getFixed0().in * width(),
height() - power_map.getFixed0().out * height(), rad + 2);
- p.setColour(GUI::Colour{0.5f, 0.7f, 0.0f, 1.0f});
+ p.setColour(GUI::Colour{1.0f, 1.0f, 0.0f, 0.7f});
p.drawFilledCircle(settings.fixed1_x.load() * width(),
height() - settings.fixed1_y.load() * height(), rad);
p.drawCircle(power_map.getFixed1().in * width(),
height() - power_map.getFixed1().out * height(), rad + 2);
- p.setColour(GUI::Colour{0.5f, 0.0f, 0.7f, 1.0f});
+ p.setColour(GUI::Colour{1.0f, 0.0f, 0.0f, 0.7f});
p.drawFilledCircle(settings.fixed2_x.load() * width(),
height() - settings.fixed2_y.load() * height(), rad);
p.drawCircle(power_map.getFixed2().in * width(),
@@ -201,13 +142,20 @@ void PowerWidget::Canvas::repaintEvent(GUI::RepaintEvent *repaintEvent)
if(enabled)
{
+ // draw 1:1 line in grey in the background to indicate where 1:1 is
+ p.setColour(GUI::Colour(0.5));
+ p.drawLine(0, height(), width(), 0);
+ }
+
+ if(enabled)
+ {
// enabled green
p.setColour(GUI::Colour(0.0f, 1.0f, 0.0f, 1.0f));
}
else
{
// disabled grey
- p.setColour(GUI::Colour(0.5f, 0.5f, 0.5f, 1.0f));
+ p.setColour(GUI::Colour(0.5f));
}
// Draw very short line segments across the region
@@ -226,6 +174,13 @@ void PowerWidget::Canvas::repaintEvent(GUI::RepaintEvent *repaintEvent)
int y = power_map.map((float)x / width()) * height();
p.drawLine(old.first, old.second, x, height() - y);
old = { x, height() - y };
+
+ if(!enabled)
+ {
+ // draw 1:1 line in green
+ p.setColour(GUI::Colour(0.0f, 1.0f, 0.0f, 1.0f));
+ p.drawLine(0, height(), width(), 0);
+ }
}
void PowerWidget::Canvas::buttonEvent(GUI::ButtonEvent* buttonEvent)
@@ -233,26 +188,29 @@ void PowerWidget::Canvas::buttonEvent(GUI::ButtonEvent* buttonEvent)
float x0 = (float)buttonEvent->x / width();
float y0 = (float)(height() - buttonEvent->y) / height();
+ float radius_x = radius * 2;
+ float radius_y = radius * width() / height() * 2;
+
switch(buttonEvent->direction)
{
case GUI::Direction::up:
in_point = -1;
break;
case GUI::Direction::down:
- if(std::abs(x0 - settings.fixed0_x.load()) < radius * 1.5 &&
- std::abs(y0 - settings.fixed0_y.load()) < radius * 1.5)
+ if(std::abs(x0 - settings.fixed0_x.load()) < radius_x &&
+ std::abs(y0 - settings.fixed0_y.load()) < radius_y)
{
in_point = 0;
}
- if(std::abs(x0 - settings.fixed1_x.load()) < radius * 1.5 &&
- std::abs(y0 - settings.fixed1_y.load()) < radius * 1.5)
+ if(std::abs(x0 - settings.fixed1_x.load()) < radius_x &&
+ std::abs(y0 - settings.fixed1_y.load()) < radius_y)
{
in_point = 1;
}
- if(std::abs(x0 - settings.fixed2_x.load()) < radius * 1.5 &&
- std::abs(y0 - settings.fixed2_y.load()) < radius * 1.5)
+ if(std::abs(x0 - settings.fixed2_x.load()) < radius_x &&
+ std::abs(y0 - settings.fixed2_y.load()) < radius_y)
{
in_point = 2;
}
diff --git a/plugingui/powerwidget.h b/plugingui/powerwidget.h
index 125d1d9..316c631 100644
--- a/plugingui/powerwidget.h
+++ b/plugingui/powerwidget.h
@@ -31,6 +31,7 @@
#include <texture.h>
#include <knob.h>
#include <checkbox.h>
+#include <label.h>
#include <powermap.h>
struct Settings;
@@ -83,24 +84,11 @@ private:
const float radius = 0.015;
};
- void chk_enable(bool v);
- void k0_x(float v);
- void k0_y(float v);
- void k1_x(float v);
- void k1_y(float v);
- void k2_x(float v);
- void k2_y(float v);
void chk_shelf(bool v);
Canvas canvas;
- GUI::CheckBox checkbox_enable{this};
- GUI::Knob knob0_x{this};
- GUI::Knob knob0_y{this};
- GUI::Knob knob1_x{this};
- GUI::Knob knob1_y{this};
- GUI::Knob knob2_x{this};
- GUI::Knob knob2_y{this};
- GUI::CheckBox checkbox_shelf{this};
+ GUI::Label shelf_label{this};
+ GUI::CheckBox shelf_checkbox{this};
Settings& settings;
};
diff --git a/plugingui/testmain.cc b/plugingui/testmain.cc
index b122756..91effc4 100644
--- a/plugingui/testmain.cc
+++ b/plugingui/testmain.cc
@@ -57,9 +57,9 @@ int main()
// TODO: automatically use drumgizmo_plugin.h size here
#ifndef UI_PUGL
- parent.resize(750, 613);
+ parent.resize(750, 713);
#else
- main_window.resize(750, 613);
+ main_window.resize(750, 713);
#endif
while(true)