mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-19 05:40:38 +01:00
[apps/sequence/list] Create a class sequence cell
Change-Id: I2443133224c7b961ee805026d3a96fe4408e5115
This commit is contained in:
@@ -2,6 +2,7 @@ app_objs += $(addprefix apps/sequence/,\
|
||||
app.o\
|
||||
list/list_controller.o\
|
||||
list/type_parameter_controller.o\
|
||||
list/sequence_cell.o\
|
||||
list/sequence_expression_cell.o\
|
||||
list/sequence_title_cell.o\
|
||||
values/values_controller.o\
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
32
apps/sequence/list/sequence_cell.h
Normal file
32
apps/sequence/list/sequence_cell.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef SEQUENCE_SEQUENCE_CELL_H
|
||||
#define SEQUENCE_SEQUENCE_CELL_H
|
||||
|
||||
#include "../sequence.h"
|
||||
#include <escher.h>
|
||||
|
||||
namespace Sequence {
|
||||
|
||||
class SequenceCell : public EvenOddCell {
|
||||
public:
|
||||
SequenceCell();
|
||||
virtual void setSequence(Sequence * sequence);
|
||||
int numberOfSubCells();
|
||||
int selectedSubCell();
|
||||
void selectSubCell(int index);
|
||||
void setHighlighted(bool highlight) override;
|
||||
void setEven(bool even) override;
|
||||
int numberOfSubviews() const override;
|
||||
View * subviewAtIndex(int index) override;
|
||||
void layoutSubviews() override;
|
||||
protected:
|
||||
constexpr static KDCoordinate k_separatorThickness = 1;
|
||||
int m_numberOfSubCells;
|
||||
int m_selectedSubCell;
|
||||
Sequence * m_sequence;
|
||||
private:
|
||||
virtual EvenOddCell * viewAtIndex(int index) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user