summaryrefslogtreecommitdiff
path: root/plugingui
diff options
context:
space:
mode:
Diffstat (limited to 'plugingui')
-rw-r--r--plugingui/button.cc31
-rw-r--r--plugingui/button.h15
-rw-r--r--plugingui/button_base.cc21
-rw-r--r--plugingui/button_base.h4
-rw-r--r--plugingui/diskstreamingframecontent.cc5
-rw-r--r--plugingui/resources/pushbutton.pngbin1396 -> 1577 bytes
6 files changed, 56 insertions, 20 deletions
diff --git a/plugingui/button.cc b/plugingui/button.cc
index 0da79a0..4cd3ef3 100644
--- a/plugingui/button.cc
+++ b/plugingui/button.cc
@@ -59,24 +59,31 @@ void Button::repaintEvent(RepaintEvent* repaintEvent)
return;
}
- switch(draw_state)
- {
- case State::Up:
- box_up.setSize(w - padLeft, h - padTop);
- p.drawImage(padLeft, padTop, box_up);
- break;
+ if (enabled) {
+ switch(draw_state)
+ {
+ case State::Up:
+ box_up.setSize(w - padLeft, h - padTop);
+ p.drawImage(padLeft, padTop, box_up);
+ break;
+
+ case State::Down:
+ box_down.setSize(w - padLeft, h - padTop);
+ p.drawImage(padLeft, padTop, box_down);
+ break;
+ }
+ }
+ else {
+ box_grey.setSize(w - padLeft, h - padTop);
+ p.drawImage(padLeft, padTop, box_grey);
- case State::Down:
- box_down.setSize(w - padLeft, h - padTop);
- p.drawImage(padLeft, padTop, box_down);
- break;
+ p.setColour(Colour(0.3));
}
- p.setColour(Colour(0.1));
auto x = (w / 2) - (3 * text.length()) + (draw_state == State::Up ? 0 : 1) +
(padLeft / 2);
auto y = (h / 2) + 5 + 1 + (draw_state == State::Up ? 0 : 1) + (padTop / 2);
- p.drawText(x, y, font, text, true);
+ p.drawText(x, y, font, text, enabled);
}
} // GUI::
diff --git a/plugingui/button.h b/plugingui/button.h
index fde0459..f6bb83c 100644
--- a/plugingui/button.h
+++ b/plugingui/button.h
@@ -45,13 +45,18 @@ protected:
private:
TexturedBox box_up{getImageCache(), ":pushbutton.png",
0, 0, // atlas offset (x, y)
- 11, 1, 11, // dx1, dx2, dx3
- 10, 72, 12}; // dy1, dy2, dy3
+ 7, 1, 7, // dx1, dx2, dx3
+ 6, 12, 9}; // dy1, dy2, dy3
TexturedBox box_down{getImageCache(), ":pushbutton.png",
- 23, 0, // atlas offset (x, y)
- 11, 1, 11, // dx1, dx2, dx3
- 10, 72, 12}; // dy1, dy2, dy3
+ 15, 0, // atlas offset (x, y)
+ 7, 1, 7, // dx1, dx2, dx3
+ 6, 12, 9}; // dy1, dy2, dy3
+
+ TexturedBox box_grey{getImageCache(), ":pushbutton.png",
+ 30, 0, // atlas offset (x, y)
+ 7, 1, 7, // dx1, dx2, dx3
+ 6, 12, 9}; // dy1, dy2, dy3
Font font{":fontemboss.png"};
};
diff --git a/plugingui/button_base.cc b/plugingui/button_base.cc
index 1030bbc..bf441f5 100644
--- a/plugingui/button_base.cc
+++ b/plugingui/button_base.cc
@@ -42,7 +42,7 @@ ButtonBase::~ButtonBase()
void ButtonBase::buttonEvent(ButtonEvent* buttonEvent)
{
// Ignore everything except left clicks.
- if(buttonEvent->button != MouseButton::left)
+ if(!enabled || buttonEvent->button != MouseButton::left)
{
return;
}
@@ -74,8 +74,23 @@ void ButtonBase::setText(const std::string& text)
redraw();
}
+void ButtonBase::setEnabled(bool enabled)
+{
+ this->enabled = enabled;
+ redraw();
+}
+
+bool ButtonBase::isEnabled() const
+{
+ return enabled;
+}
+
void ButtonBase::mouseLeaveEvent()
{
+ if (!enabled) {
+ return;
+ }
+
in_button = false;
if(button_state == State::Down)
{
@@ -86,6 +101,10 @@ void ButtonBase::mouseLeaveEvent()
void ButtonBase::mouseEnterEvent()
{
+ if (!enabled) {
+ return;
+ }
+
in_button = true;
if(button_state == State::Down)
{
diff --git a/plugingui/button_base.h b/plugingui/button_base.h
index a21a084..c872d9b 100644
--- a/plugingui/button_base.h
+++ b/plugingui/button_base.h
@@ -47,6 +47,9 @@ public:
void setText(const std::string& text);
+ void setEnabled(bool enabled);
+ bool isEnabled() const;
+
Notifier<> clickNotifier;
protected:
@@ -58,6 +61,7 @@ protected:
virtual void mouseLeaveEvent() override;
virtual void mouseEnterEvent() override;
+ bool enabled{true};
bool in_button{false};
enum class State {
diff --git a/plugingui/diskstreamingframecontent.cc b/plugingui/diskstreamingframecontent.cc
index 35ab8d8..bb93bc9 100644
--- a/plugingui/diskstreamingframecontent.cc
+++ b/plugingui/diskstreamingframecontent.cc
@@ -45,6 +45,7 @@ DiskstreamingframeContent::DiskstreamingframeContent(Widget* parent,
label_text.setAlignment(TextAlignment::center);
button.setText("Apply");
+ button.setEnabled(false);
label_size.setText("0 MB");
label_size.setAlignment(TextAlignment::center);
@@ -96,7 +97,7 @@ void DiskstreamingframeContent::limitSettingsValueChanged(std::size_t value)
label_size.setText("Unlimited");
}
- // TODO: un-grayout "Apply" button
+ button.setEnabled(true);
}
void DiskstreamingframeContent::limitValueChanged(float value)
@@ -112,7 +113,7 @@ void DiskstreamingframeContent::reloadClicked()
{
settings.reload_counter++;
- // TODO: grayout "Apply" button
+ button.setEnabled(false);
}
diff --git a/plugingui/resources/pushbutton.png b/plugingui/resources/pushbutton.png
index 4145e9a..d2debb6 100644
--- a/plugingui/resources/pushbutton.png
+++ b/plugingui/resources/pushbutton.png
Binary files differ