[apps/shared] Class Hideable

This commit is contained in:
Léa Saviot
2018-05-28 11:43:29 +02:00
parent 8ad6fd3c8c
commit 452957caf6
3 changed files with 29 additions and 9 deletions

22
apps/shared/hideable.h Normal file
View File

@@ -0,0 +1,22 @@
#ifndef APPS_SHARED_HIDEABLE_H
#define APPS_SHARED_HIDEABLE_H
#include <escher/palette.h>
namespace Shared {
class Hideable {
public:
Hideable() :
m_hide(false)
{}
static KDColor hideColor() { return Palette::WallScreenDark; }
bool hidden() const { return m_hide; }
virtual void setHide(bool hide) { m_hide = hide; }
private:
bool m_hide;
};
}
#endif

View File

@@ -3,15 +3,15 @@
namespace Shared {
KDColor HideableEvenOddEditableTextCell::backgroundColor() const {
if (m_hide) {
if (hidden()) {
return hideColor();
}
return EvenOddEditableTextCell::backgroundColor();
}
void HideableEvenOddEditableTextCell::setHide(bool hide) {
if (m_hide != hide) {
m_hide = hide;
if (hidden() != hide) {
Hideable::setHide(hide);
editableTextCell()->textField()->setBackgroundColor(backgroundColor());
reloadCell();
}

View File

@@ -3,20 +3,18 @@
#include <escher/even_odd_editable_text_cell.h>
#include <escher/palette.h>
#include "hideable.h"
namespace Shared {
class HideableEvenOddEditableTextCell : public EvenOddEditableTextCell {
class HideableEvenOddEditableTextCell : public EvenOddEditableTextCell, public Hideable {
public:
HideableEvenOddEditableTextCell(Responder * parentResponder = nullptr, TextFieldDelegate * delegate = nullptr, char * draftTextBuffer = nullptr) :
EvenOddEditableTextCell(parentResponder, delegate, draftTextBuffer),
m_hide(false)
Hideable()
{}
KDColor backgroundColor() const override;
static KDColor hideColor() { return Palette::WallScreenDark; }
void setHide(bool hide);
private:
bool m_hide;
void setHide(bool hide) override;
};
}