diff options
-rw-r--r-- | plugingui/powerbutton.cc | 32 | ||||
-rw-r--r-- | plugingui/powerbutton.h | 6 | ||||
-rw-r--r-- | plugingui/resources/bypass_button.png | bin | 1615 -> 2146 bytes |
3 files changed, 32 insertions, 6 deletions
diff --git a/plugingui/powerbutton.cc b/plugingui/powerbutton.cc index a91524f..36edc35 100644 --- a/plugingui/powerbutton.cc +++ b/plugingui/powerbutton.cc @@ -35,31 +35,51 @@ PowerButton::PowerButton(Widget* parent) : Toggle(parent) { } +void PowerButton::setEnabled(bool enabled) +{ + this->enabled = enabled; +} + void PowerButton::repaintEvent(RepaintEvent* repaintEvent) { Painter p(*this); - if(state) + // disabled + if(!enabled) { if(clicked) { - p.drawImage(0, 0, on_clicked); + p.drawImage(0, 0, disabled_clicked); } else { - p.drawImage(0, 0, on); + p.drawImage(0, 0, disabled); } + return; } - else + + // enabled and on + if(state) { if(clicked) { - p.drawImage(0, 0, off_clicked); + p.drawImage(0, 0, on_clicked); } else { - p.drawImage(0, 0, off); + p.drawImage(0, 0, on); } + return; + } + + // enabled and off + if(clicked) + { + p.drawImage(0, 0, off_clicked); + } + else + { + p.drawImage(0, 0, off); } } diff --git a/plugingui/powerbutton.h b/plugingui/powerbutton.h index 53f8d88..14dbeca 100644 --- a/plugingui/powerbutton.h +++ b/plugingui/powerbutton.h @@ -38,15 +38,21 @@ public: PowerButton(Widget* parent); virtual ~PowerButton() = default; + void setEnabled(bool enabled); + protected: // From Widget: virtual void repaintEvent(RepaintEvent* repaintEvent) override; + bool enabled = true; + private: Texture on{getImageCache(), ":resources/bypass_button.png", 32, 0, 16, 16}; Texture on_clicked{getImageCache(), ":resources/bypass_button.png", 48, 0, 16, 16}; Texture off{getImageCache(), ":resources/bypass_button.png", 0, 0, 16, 16}; Texture off_clicked{getImageCache(), ":resources/bypass_button.png", 16, 0, 16, 16}; + Texture disabled{getImageCache(), ":resources/bypass_button.png", 64, 0, 16, 16}; + Texture disabled_clicked{getImageCache(), ":resources/bypass_button.png", 80, 0, 16, 16}; }; } // GUI:: diff --git a/plugingui/resources/bypass_button.png b/plugingui/resources/bypass_button.png Binary files differindex f5399fb..e084d39 100644 --- a/plugingui/resources/bypass_button.png +++ b/plugingui/resources/bypass_button.png |