summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Nusser <andre.nusser@googlemail.com>2018-06-08 01:18:02 +0200
committerAndré Nusser <andre.nusser@googlemail.com>2018-06-08 01:19:19 +0200
commit8f3f22bb5d9d6879bb21d0132a3e0d0af4cd5380 (patch)
treeb3aab48cde087b07d0152b5b6945c3eea305a6ad
parentf532587d5c3576dc04d4c6eeee20c5dcdf642244 (diff)
Disable bleed control frame if drumkit doesn't support it.
-rw-r--r--plugingui/bleedcontrolframecontent.cc18
-rw-r--r--plugingui/bleedcontrolframecontent.h4
-rw-r--r--plugingui/frame.cc13
-rw-r--r--plugingui/frame.h6
-rw-r--r--plugingui/label.cc2
-rw-r--r--plugingui/maintab.cc7
-rw-r--r--plugingui/powerbutton.cc2
-rw-r--r--plugingui/slider.cc33
-rw-r--r--plugingui/slider.h4
9 files changed, 80 insertions, 9 deletions
diff --git a/plugingui/bleedcontrolframecontent.cc b/plugingui/bleedcontrolframecontent.cc
index 5d28169..f831210 100644
--- a/plugingui/bleedcontrolframecontent.cc
+++ b/plugingui/bleedcontrolframecontent.cc
@@ -69,6 +69,24 @@ void BleedcontrolframeContent::resize(std::size_t width, std::size_t height)
label_value.resize(slider_width, 15);
}
+void BleedcontrolframeContent::setEnabled(bool enabled)
+{
+ this->enabled = enabled;
+
+ if (enabled) {
+ label_text.resetColour();
+ label_value.resetColour();
+ slider.setEnabled(true);
+ }
+ else {
+ label_text.setColour(0.7);
+ label_value.setColour(0.7);
+ slider.setEnabled(false);
+ }
+
+ redraw();
+}
+
void BleedcontrolframeContent::bleedSettingsValueChanged(float value)
{
slider.setValue(value);
diff --git a/plugingui/bleedcontrolframecontent.h b/plugingui/bleedcontrolframecontent.h
index 09d5642..78733c0 100644
--- a/plugingui/bleedcontrolframecontent.h
+++ b/plugingui/bleedcontrolframecontent.h
@@ -45,10 +45,14 @@ public:
// From Widget
virtual void resize(std::size_t width, std::size_t height) override;
+ void setEnabled(bool enabled);
+
private:
void bleedSettingsValueChanged(float value);
void bleedValueChanged(float value);
+ bool enabled = true;
+
Label label_text{this};
Label label_value{this};
diff --git a/plugingui/frame.cc b/plugingui/frame.cc
index 81cc3c2..d552ff1 100644
--- a/plugingui/frame.cc
+++ b/plugingui/frame.cc
@@ -59,7 +59,7 @@ void FrameWidget::repaintEvent(RepaintEvent* repaintEvent)
auto title_buf = title.c_str();
// draw the dark grey box
- p.setColour(grey_box_colour);
+ p.setColour(enabled ? grey_box_colour : grey_box_colour_disabled);
p.drawFilledRectangle(1, 1, width() - 2, bar_height);
// frame
@@ -76,8 +76,9 @@ void FrameWidget::repaintEvent(RepaintEvent* repaintEvent)
p.drawFilledRectangle(1, bar_height, width() - 2, height() - 2);
// draw the label
- p.setColour(label_colour);
+ p.setColour(enabled ? label_colour : label_colour_disabled);
p.drawText(center_x - label_width, bar_height - 4, font, title_buf);
+ power_button.setEnabled(enabled);
}
void FrameWidget::powerButtonStateChanged(bool new_state)
@@ -104,6 +105,14 @@ void FrameWidget::setOnSwitch(bool on)
power_button.setChecked(is_switched_on);
}
+void FrameWidget::setEnabled(bool enabled)
+{
+ this->enabled = enabled;
+ onEnabledChanged(enabled);
+
+ redraw();
+}
+
void FrameWidget::sizeChanged(int width, int height)
{
if(content)
diff --git a/plugingui/frame.h b/plugingui/frame.h
index eb745f6..e29bd3d 100644
--- a/plugingui/frame.h
+++ b/plugingui/frame.h
@@ -52,8 +52,10 @@ public:
void setContent(Widget* content);
void setOnSwitch(bool on);
+ void setEnabled(bool enabled);
Notifier<bool> onSwitchChangeNotifier; // (bool on)
+ Notifier<bool> onEnabledChanged; // (bool enabled)
protected:
// From Widget:
@@ -62,6 +64,8 @@ protected:
//! Callback for Widget::sizeChangeNotifier
void sizeChanged(int width, int height);
+ bool enabled = true;
+
private:
//
// upper bar
@@ -71,6 +75,7 @@ private:
Font font;
std::string title;
GUI::Colour label_colour{0.1};
+ GUI::Colour label_colour_disabled{0.5};
std::size_t label_width;
// switch
@@ -82,6 +87,7 @@ private:
// grey box
int bar_height;
GUI::Colour grey_box_colour{0.7};
+ GUI::Colour grey_box_colour_disabled{0.7};
GUI::Colour background_colour{0.85, 0.8};
//
diff --git a/plugingui/label.cc b/plugingui/label.cc
index dc5fe23..b5239ec 100644
--- a/plugingui/label.cc
+++ b/plugingui/label.cc
@@ -52,11 +52,13 @@ void Label::setAlignment(TextAlignment alignment)
void Label::setColour(Colour colour)
{
this->colour = std::make_unique<Colour>(colour);
+ redraw();
}
void Label::resetColour()
{
colour.release();
+ redraw();
}
void Label::resizeToText()
diff --git a/plugingui/maintab.cc b/plugingui/maintab.cc
index 84e8a92..170d937 100644
--- a/plugingui/maintab.cc
+++ b/plugingui/maintab.cc
@@ -61,10 +61,15 @@ MainTab::MainTab(Widget* parent,
resampling_frame.setOnSwitch(settings.enable_resampling);
timing_frame.setOnSwitch(settings.enable_latency_modifier);
+ // FIXME:
+ bleedcontrol_frame.setEnabled(false);
+
CONNECT(this, settings_notifier.enable_velocity_modifier,
&humanizer_frame, &FrameWidget::setOnSwitch);
CONNECT(this, settings_notifier.enable_resampling,
&resampling_frame, &FrameWidget::setOnSwitch);
+ CONNECT(this, settings_notifier.has_bleed_control,
+ &bleedcontrol_frame, &FrameWidget::setEnabled);
CONNECT(&humanizer_frame, onSwitchChangeNotifier,
this, &MainTab::humanizerOnChange);
CONNECT(&bleedcontrol_frame, onSwitchChangeNotifier,
@@ -73,6 +78,8 @@ MainTab::MainTab(Widget* parent,
this, &MainTab::resamplingOnChange);
CONNECT(&timing_frame, onSwitchChangeNotifier,
this, &MainTab::timingOnChange);
+ CONNECT(&bleedcontrol_frame, onEnabledChanged,
+ &bleedcontrolframe_content, &BleedcontrolframeContent::setEnabled);
}
void MainTab::resize(std::size_t width, std::size_t height)
diff --git a/plugingui/powerbutton.cc b/plugingui/powerbutton.cc
index 36edc35..5bf2a2c 100644
--- a/plugingui/powerbutton.cc
+++ b/plugingui/powerbutton.cc
@@ -38,6 +38,8 @@ PowerButton::PowerButton(Widget* parent) : Toggle(parent)
void PowerButton::setEnabled(bool enabled)
{
this->enabled = enabled;
+
+ redraw();
}
void PowerButton::repaintEvent(RepaintEvent* repaintEvent)
diff --git a/plugingui/slider.cc b/plugingui/slider.cc
index dd2dc44..bec9405 100644
--- a/plugingui/slider.cc
+++ b/plugingui/slider.cc
@@ -68,24 +68,41 @@ void Slider::setColour(Colour colour)
{
switch (colour) {
case Colour::Green:
- inner_bar = &inner_bar_green;
+ active_inner_bar = &inner_bar_green;
break;
case Colour::Red:
- inner_bar = &inner_bar_red;
+ active_inner_bar = &inner_bar_red;
break;
case Colour::Blue:
- inner_bar = &inner_bar_blue;
+ active_inner_bar = &inner_bar_blue;
break;
case Colour::Yellow:
- inner_bar = &inner_bar_yellow;
+ active_inner_bar = &inner_bar_yellow;
break;
case Colour::Purple:
- inner_bar = &inner_bar_purple;
+ active_inner_bar = &inner_bar_purple;
break;
case Colour::Grey:
- inner_bar = &inner_bar_grey;
+ active_inner_bar = &inner_bar_grey;
break;
}
+
+ if (enabled) { inner_bar = active_inner_bar; }
+}
+
+void Slider::setEnabled(bool enabled)
+{
+ this->enabled = enabled;
+
+ if (enabled) {
+ inner_bar = active_inner_bar;
+ }
+ else {
+ active_inner_bar = inner_bar;
+ inner_bar = &inner_bar_grey;
+ }
+
+ redraw();
}
void Slider::repaintEvent(RepaintEvent* repaintEvent)
@@ -111,7 +128,7 @@ void Slider::repaintEvent(RepaintEvent* repaintEvent)
void Slider::buttonEvent(ButtonEvent* buttonEvent)
{
// Ignore everything except left clicks.
- if(buttonEvent->button != MouseButton::left)
+ if(!enabled || buttonEvent->button != MouseButton::left)
{
return;
}
@@ -151,6 +168,8 @@ void Slider::mouseMoveEvent(MouseMoveEvent* mouseMoveEvent)
void Slider::scrollEvent(ScrollEvent* scrollEvent)
{
+ if (!enabled) { return; }
+
current_value -= scrollEvent->delta/(float)getControlWidth();
if (current_value < 0.)
{
diff --git a/plugingui/slider.h b/plugingui/slider.h
index 4480508..c12144d 100644
--- a/plugingui/slider.h
+++ b/plugingui/slider.h
@@ -56,6 +56,7 @@ public:
enum class Colour { Green, Red, Blue, Yellow, Purple, Grey };
// Changes the colour of the inner bar
void setColour(Colour colour);
+ void setEnabled(bool enabled);
Notifier<> clickNotifier;
Notifier<float> valueChangedNotifier; // (float value)
@@ -66,6 +67,8 @@ protected:
virtual void mouseMoveEvent(MouseMoveEvent* mouseMoveEvent) override;
virtual void scrollEvent(ScrollEvent* scrollEvent) override;
+ bool enabled = true;;
+
private:
enum class State
{
@@ -123,6 +126,7 @@ private:
// This points to the inner_bar_* of the current color.
// It should never be a nullptr!
TexturedBox* inner_bar{&inner_bar_blue};
+ TexturedBox* active_inner_bar = inner_bar;
std::size_t bar_boundary{5};
std::size_t button_offset{7};