[escher] in menu list cell, change name contentView->accessoryView

Change-Id: Ide0ce134f83b6b491b66bc6df9900a1928888a8a
This commit is contained in:
Émilie Feral
2016-11-10 11:25:59 +01:00
parent af6a1c7046
commit 3ccc240d05
11 changed files with 37 additions and 37 deletions

View File

@@ -29,7 +29,7 @@ void ParameterController::didBecomeFirstResponder() {
void ParameterController::willDisplayCellForIndex(TableViewCell * cell, int index) {
if (cell == &m_enableCell) {
SwitchView * switchView = (SwitchView *)m_enableCell.contentView();
SwitchView * switchView = (SwitchView *)m_enableCell.accessoryView();
switchView->setState(m_function->isActive());
}
}

View File

@@ -83,7 +83,7 @@ KDCoordinate FunctionParameterController::cellHeight() {
void FunctionParameterController::willDisplayCellForIndex(TableViewCell * cell, int index) {
if (cell == &m_displayDerivativeColumn) {
SwitchView * switchView = (SwitchView *)m_displayDerivativeColumn.contentView();
SwitchView * switchView = (SwitchView *)m_displayDerivativeColumn.accessoryView();
switchView->setState(m_function->displayDerivative());
}
}

View File

@@ -44,15 +44,15 @@ void ValuesParameterController::willDisplayCellForIndex(TableViewCell * cell, in
switch (index) {
case 0:
Float(m_interval->start()).convertFloatToText(buffer, Constant::FloatBufferSizeInScientificMode, Constant::NumberOfDigitsInMantissaInScientificMode);
myCell->setText(buffer);
myCell->setAccessoryText(buffer);
break;
case 1:
Float(m_interval->end()).convertFloatToText(buffer, Constant::FloatBufferSizeInScientificMode, Constant::NumberOfDigitsInMantissaInScientificMode);
myCell->setText(buffer);
myCell->setAccessoryText(buffer);
break;
case 2:
Float(m_interval->step()).convertFloatToText(buffer, Constant::FloatBufferSizeInScientificMode, Constant::NumberOfDigitsInMantissaInScientificMode);
myCell->setText(buffer);
myCell->setAccessoryText(buffer);
break;
default:
assert(false);
@@ -100,7 +100,7 @@ void ValuesParameterController::editInterval(bool overwrite, char initialDigit)
initialTextContent[1] = 0;
} else {
TextMenuListCell * textMenuListCell = (TextMenuListCell *)reusableCell(activeCell());
strlcpy(initialTextContent, textMenuListCell->textContent(), sizeof(initialTextContent));
strlcpy(initialTextContent, textMenuListCell->accessoryText(), sizeof(initialTextContent));
}
App * myApp = (App *)app();
InputViewController * inputController = myApp->inputViewController();

View File

@@ -7,10 +7,10 @@
class ChevronMenuListCell : public MenuListCell {
public:
ChevronMenuListCell(char * label = nullptr);
View * contentView() const override;
View * accessoryView() const override;
void reloadCell() override;
private:
ChevronView m_contentView;
ChevronView m_accessoryView;
};
#endif

View File

@@ -10,7 +10,7 @@
class MenuListCell : public TableViewCell {
public:
MenuListCell(char * label = nullptr);
virtual View * contentView() const;
virtual View * accessoryView() const;
void setText(const char * text);
void drawRect(KDContext * ctx, KDRect rect) const override;
void reloadCell() override;

View File

@@ -7,9 +7,9 @@
class SwitchMenuListCell : public MenuListCell {
public:
SwitchMenuListCell(char * label);
View * contentView() const override;
View * accessoryView() const override;
private:
SwitchView m_contentView;
SwitchView m_accessoryView;
};
#endif

View File

@@ -8,12 +8,12 @@ class TextMenuListCell : public MenuListCell {
public:
TextMenuListCell(char * label);
void reloadCell() override;
View * contentView() const override;
View * accessoryView() const override;
void setHighlighted(bool highlight);
void setText(const char * textBody);
const char * textContent();
void setAccessoryText(const char * textBody);
const char * accessoryText();
private:
BufferTextView m_contentView;
BufferTextView m_accessoryView;
};
#endif

View File

@@ -2,15 +2,15 @@
ChevronMenuListCell::ChevronMenuListCell(char * label) :
MenuListCell(label),
m_contentView(ChevronView())
m_accessoryView(ChevronView())
{
}
View * ChevronMenuListCell::contentView() const {
return (View *)&m_contentView;
View * ChevronMenuListCell::accessoryView() const {
return (View *)&m_accessoryView;
}
void ChevronMenuListCell::reloadCell() {
MenuListCell::reloadCell();
m_contentView.setHighlighted(isHighlighted());
m_accessoryView.setHighlighted(isHighlighted());
}

View File

@@ -10,7 +10,7 @@ MenuListCell::MenuListCell(char * label) :
}
int MenuListCell::numberOfSubviews() const {
if (contentView() == nullptr) {
if (accessoryView() == nullptr) {
return 1;
}
return 2;
@@ -21,7 +21,7 @@ View * MenuListCell::subviewAtIndex(int index) {
return &m_pointerTextView;
}
assert(numberOfSubviews() == 2 && index == 1);
return contentView();
return accessoryView();
}
void MenuListCell::layoutSubviews() {
@@ -29,9 +29,9 @@ void MenuListCell::layoutSubviews() {
KDCoordinate height = bounds().height();
KDSize labelSize = m_pointerTextView.minimalSizeForOptimalDisplay();
m_pointerTextView.setFrame(KDRect(k_separatorThickness, k_separatorThickness, labelSize.width(), height - 2*k_separatorThickness));
View * content = contentView();
if (content) {
content->setFrame(KDRect(k_separatorThickness + labelSize.width(), k_separatorThickness, width - labelSize.width()-2*k_separatorThickness, height-2*k_separatorThickness));
View * accessory = accessoryView();
if (accessory) {
accessory->setFrame(KDRect(k_separatorThickness + labelSize.width(), k_separatorThickness, width - labelSize.width()-2*k_separatorThickness, height-2*k_separatorThickness));
}
}
@@ -46,7 +46,7 @@ void MenuListCell::setText(const char * text) {
layoutSubviews();
}
View * MenuListCell::contentView() const {
View * MenuListCell::accessoryView() const {
return nullptr;
}

View File

@@ -2,10 +2,10 @@
SwitchMenuListCell::SwitchMenuListCell(char * label) :
MenuListCell(label),
m_contentView(SwitchView())
m_accessoryView(SwitchView())
{
}
View * SwitchMenuListCell::contentView() const {
return (View *)&m_contentView;
View * SwitchMenuListCell::accessoryView() const {
return (View *)&m_accessoryView;
}

View File

@@ -2,30 +2,30 @@
TextMenuListCell::TextMenuListCell(char * label) :
MenuListCell(label),
m_contentView(BufferTextView(1.0f, 0.5f))
m_accessoryView(BufferTextView(1.0f, 0.5f))
{
}
void TextMenuListCell::setText(const char * textBody) {
m_contentView.setText(textBody);
void TextMenuListCell::setAccessoryText(const char * textBody) {
m_accessoryView.setText(textBody);
}
const char * TextMenuListCell::textContent() {
return m_contentView.text();
const char * TextMenuListCell::accessoryText() {
return m_accessoryView.text();
}
View * TextMenuListCell::contentView() const {
return (View *)&m_contentView;
View * TextMenuListCell::accessoryView() const {
return (View *)&m_accessoryView;
}
void TextMenuListCell::reloadCell() {
MenuListCell::reloadCell();
KDColor backgroundColor = isHighlighted()? Palette::FocusCellBackgroundColor : Palette::CellBackgroundColor;
m_contentView.setBackgroundColor(backgroundColor);
m_accessoryView.setBackgroundColor(backgroundColor);
}
void TextMenuListCell::setHighlighted(bool highlight) {
MenuListCell::setHighlighted(highlight);
KDColor backgroundColor = highlight? Palette::FocusCellBackgroundColor : Palette::CellBackgroundColor;
m_contentView.setBackgroundColor(backgroundColor);
m_accessoryView.setBackgroundColor(backgroundColor);
}