[escher] Allow customizing the background color of a button

This commit is contained in:
Romain Goyet
2018-08-24 17:16:58 +02:00
committed by LeaNumworks
parent ebf309654c
commit c52ed0bf6d
2 changed files with 3 additions and 1 deletions

View File

@@ -6,6 +6,7 @@
#include <escher/responder.h>
#include <escher/message_text_view.h>
#include <escher/invocation.h>
#include <escher/palette.h>
class Button : public HighlightCell, public Responder {
public:
@@ -13,6 +14,7 @@ public:
void setMessage(I18n::Message message);
bool handleEvent(Ion::Events::Event event) override;
void setHighlighted(bool highlight) override;
virtual KDColor highlightedBackgroundColor() const { return Palette::Select; }
Responder * responder() override {
return this;
}

View File

@@ -38,7 +38,7 @@ bool Button::handleEvent(Ion::Events::Event event) {
void Button::setHighlighted(bool highlight) {
HighlightCell::setHighlighted(highlight);
KDColor backgroundColor = highlight? Palette::Select : KDColorWhite;
KDColor backgroundColor = highlight? highlightedBackgroundColor() : KDColorWhite;
m_messageTextView.setBackgroundColor(backgroundColor);
markRectAsDirty(bounds());
}