mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-20 06:10:31 +01:00
[apps/sequence/list] Create a class sequence cell
Change-Id: I2443133224c7b961ee805026d3a96fe4408e5115
This commit is contained in:
73
apps/sequence/list/sequence_cell.cpp
Normal file
73
apps/sequence/list/sequence_cell.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
#include "sequence_cell.h"
|
||||
|
||||
namespace Sequence {
|
||||
|
||||
SequenceCell::SequenceCell() :
|
||||
EvenOddCell(),
|
||||
m_numberOfSubCells(1),
|
||||
m_selectedSubCell(0),
|
||||
m_sequence(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
int SequenceCell::numberOfSubCells() {
|
||||
return m_numberOfSubCells;
|
||||
}
|
||||
|
||||
int SequenceCell::selectedSubCell() {
|
||||
return m_selectedSubCell;
|
||||
}
|
||||
|
||||
void SequenceCell::selectSubCell(int selectedSubCell) {
|
||||
m_selectedSubCell = selectedSubCell;
|
||||
viewAtIndex(0)->setHighlighted(selectedSubCell == 0);
|
||||
viewAtIndex(1)->setHighlighted(selectedSubCell == 1);
|
||||
viewAtIndex(2)->setHighlighted(selectedSubCell == 2);
|
||||
reloadCell();
|
||||
}
|
||||
|
||||
void SequenceCell::setSequence(Sequence * sequence) {
|
||||
m_sequence = sequence;
|
||||
m_numberOfSubCells = (int)m_sequence->type()+1;
|
||||
layoutSubviews();
|
||||
}
|
||||
|
||||
void SequenceCell::setHighlighted(bool highlight) {
|
||||
TableViewCell::setHighlighted(highlight);
|
||||
viewAtIndex(0)->setHighlighted(false);
|
||||
viewAtIndex(1)->setHighlighted(false);
|
||||
viewAtIndex(2)->setHighlighted(false);
|
||||
TableViewCell::setHighlighted(highlight);
|
||||
if (isHighlighted()) {
|
||||
viewAtIndex(m_selectedSubCell)->setHighlighted(true);
|
||||
}
|
||||
reloadCell();
|
||||
}
|
||||
|
||||
void SequenceCell::setEven(bool even) {
|
||||
EvenOddCell::setEven(even);
|
||||
viewAtIndex(0)->setEven(even);
|
||||
viewAtIndex(1)->setEven(even);
|
||||
viewAtIndex(2)->setEven(even);
|
||||
reloadCell();
|
||||
}
|
||||
|
||||
int SequenceCell::numberOfSubviews() const {
|
||||
return m_numberOfSubCells;
|
||||
}
|
||||
|
||||
View * SequenceCell::subviewAtIndex(int index) {
|
||||
return viewAtIndex(index);
|
||||
}
|
||||
|
||||
void SequenceCell::layoutSubviews() {
|
||||
KDCoordinate cellHeight = (bounds().height()-(m_numberOfSubCells-1)*k_separatorThickness)/m_numberOfSubCells;
|
||||
KDRect expressionFrame(k_separatorThickness, 0, bounds().width() - k_separatorThickness, cellHeight);
|
||||
viewAtIndex(0)->setFrame(expressionFrame);
|
||||
expressionFrame = KDRect(k_separatorThickness, cellHeight+k_separatorThickness, bounds().width() - k_separatorThickness, cellHeight);
|
||||
viewAtIndex(1)->setFrame(expressionFrame);
|
||||
expressionFrame = KDRect(k_separatorThickness, 2*cellHeight+2*k_separatorThickness, bounds().width() - k_separatorThickness, cellHeight);
|
||||
viewAtIndex(2)->setFrame(expressionFrame);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user