mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[apps/sequence] Create a class sequence title cell
Change-Id: I2a891e6a47ec742cedfa6780ee1a50eb3df24085
This commit is contained in:
@@ -4,6 +4,7 @@ app_objs += $(addprefix apps/sequence/,\
|
||||
values/values_controller.o\
|
||||
sequence.o\
|
||||
sequence_store.o\
|
||||
sequence_title_cell.o\
|
||||
)
|
||||
|
||||
app_images += apps/sequence/sequence_icon.png
|
||||
|
||||
91
apps/sequence/sequence_title_cell.cpp
Normal file
91
apps/sequence/sequence_title_cell.cpp
Normal file
@@ -0,0 +1,91 @@
|
||||
#include "sequence_title_cell.h"
|
||||
|
||||
using namespace Shared;
|
||||
|
||||
namespace Sequence {
|
||||
|
||||
SequenceTitleCell::SequenceTitleCell(Responder * parentResponder) :
|
||||
FunctionTitleCell(FunctionTitleCell::Orientation::VerticalIndicator),
|
||||
Responder(parentResponder),
|
||||
m_numberOfSubCells(1),
|
||||
m_selectedSubCell(0),
|
||||
m_firstInitialConditionView(KDText::FontSize::Large, 0.5f, 0.5f),
|
||||
m_secondInitialConditionView(KDText::FontSize::Large, 0.5f, 0.5f)
|
||||
{
|
||||
}
|
||||
|
||||
int SequenceTitleCell::selectedSubCell() {
|
||||
return m_selectedSubCell;
|
||||
}
|
||||
|
||||
void SequenceTitleCell::selectSubCell(int selectedSubCell) {
|
||||
m_selectedSubCell = selectedSubCell;
|
||||
m_bufferTextView.setHighlighted(selectedSubCell == 0);
|
||||
m_firstInitialConditionView.setHighlighted(selectedSubCell == 1);
|
||||
m_secondInitialConditionView.setHighlighted(selectedSubCell == 2);
|
||||
reloadCell();
|
||||
}
|
||||
|
||||
void SequenceTitleCell::setHighlighted(bool highlight) {
|
||||
m_bufferTextView.setHighlighted(false);
|
||||
m_firstInitialConditionView.setHighlighted(false);
|
||||
m_secondInitialConditionView.setHighlighted(false);
|
||||
TableViewCell::setHighlighted(highlight);
|
||||
if (isHighlighted()) {
|
||||
if (m_selectedSubCell == 0) {
|
||||
m_bufferTextView.setHighlighted(true);
|
||||
}
|
||||
if (m_selectedSubCell == 1) {
|
||||
m_firstInitialConditionView.setHighlighted(true);
|
||||
}
|
||||
if (m_selectedSubCell == 2) {
|
||||
m_secondInitialConditionView.setHighlighted(true);
|
||||
}
|
||||
}
|
||||
reloadCell();
|
||||
}
|
||||
|
||||
void SequenceTitleCell::setEven(bool even) {
|
||||
m_bufferTextView.setEven(even);
|
||||
m_firstInitialConditionView.setEven(even);
|
||||
m_secondInitialConditionView.setEven(even);
|
||||
reloadCell();
|
||||
}
|
||||
|
||||
int SequenceTitleCell::numberOfSubviews() const {
|
||||
return m_numberOfSubCells;
|
||||
}
|
||||
|
||||
View * SequenceTitleCell::subviewAtIndex(int index) {
|
||||
if (index == 0) {
|
||||
return &m_bufferTextView;
|
||||
}
|
||||
if (index == 1) {
|
||||
return &m_firstInitialConditionView;
|
||||
}
|
||||
return &m_secondInitialConditionView;
|
||||
}
|
||||
|
||||
void SequenceTitleCell::layoutSubviews() {
|
||||
KDCoordinate cellHeight = bounds().height()/m_numberOfSubCells;
|
||||
KDRect expressionFrame(k_colorIndicatorThickness, 0, bounds().width() - k_separatorThickness, cellHeight);
|
||||
m_bufferTextView.setFrame(expressionFrame);
|
||||
expressionFrame = KDRect(k_colorIndicatorThickness, cellHeight, bounds().width() - k_separatorThickness, cellHeight);
|
||||
m_firstInitialConditionView.setFrame(expressionFrame);
|
||||
expressionFrame = KDRect(k_colorIndicatorThickness, 2*cellHeight, bounds().width() - k_separatorThickness, cellHeight);
|
||||
m_secondInitialConditionView.setFrame(expressionFrame);
|
||||
}
|
||||
|
||||
bool SequenceTitleCell::handleEvent(Ion::Events::Event event) {
|
||||
if (m_selectedSubCell < 2 && event == Ion::Events::Down) {
|
||||
selectSubCell(m_selectedSubCell+1);
|
||||
return true;
|
||||
}
|
||||
if (m_selectedSubCell > 0 && event == Ion::Events::Up) {
|
||||
selectSubCell(m_selectedSubCell-1);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
32
apps/sequence/sequence_title_cell.h
Normal file
32
apps/sequence/sequence_title_cell.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef SEQUENCE_SEQUENCE_TITLE_CELL_H
|
||||
#define SEQUENCE_SEQUENCE_TITLE_CELL_H
|
||||
|
||||
#include "../shared/function_title_cell.h"
|
||||
|
||||
namespace Sequence {
|
||||
|
||||
class SequenceTitleCell : public Shared::FunctionTitleCell, public Responder {
|
||||
public:
|
||||
SequenceTitleCell(Responder * parentResponder = nullptr);
|
||||
void setFirstInitialConditionText(const char * textContent);
|
||||
void setSecondInitialConditionText(const char * textContent);
|
||||
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;
|
||||
bool handleEvent(Ion::Events::Event event) override;
|
||||
private:
|
||||
static constexpr KDCoordinate k_emptyRowHeight = 50;
|
||||
constexpr static KDCoordinate k_separatorThickness = 1;
|
||||
int m_numberOfSubCells;
|
||||
int m_selectedSubCell;
|
||||
EvenOddBufferTextCell m_firstInitialConditionView;
|
||||
EvenOddBufferTextCell m_secondInitialConditionView;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -10,9 +10,14 @@ FunctionTitleCell::FunctionTitleCell(Orientation orientation, KDText::FontSize s
|
||||
{
|
||||
}
|
||||
|
||||
void FunctionTitleCell::reloadCell() {
|
||||
EvenOddCell::reloadCell();
|
||||
m_bufferTextView.setBackgroundColor(backgroundColor());
|
||||
void FunctionTitleCell::setHighlighted(bool highlight) {
|
||||
EvenOddCell::setHighlighted(highlight);
|
||||
m_bufferTextView.setHighlighted(highlight);
|
||||
}
|
||||
|
||||
void FunctionTitleCell::setEven(bool even) {
|
||||
EvenOddCell::setEven(even);
|
||||
m_bufferTextView.setEven(even);
|
||||
}
|
||||
|
||||
void FunctionTitleCell::setText(const char * title) {
|
||||
|
||||
@@ -15,14 +15,16 @@ public:
|
||||
void setColor(KDColor color);
|
||||
void setText(const char * textContent);
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
void reloadCell() override;
|
||||
void setEven(bool even) override;
|
||||
void setHighlighted(bool highlight) override;
|
||||
int numberOfSubviews() const override;
|
||||
View * subviewAtIndex(int index) override;
|
||||
void layoutSubviews() override;
|
||||
private:
|
||||
protected:
|
||||
constexpr static KDCoordinate k_colorIndicatorThickness = 2;
|
||||
EvenOddBufferTextCell m_bufferTextView;
|
||||
private:
|
||||
KDColor m_functionColor;
|
||||
BufferTextView m_bufferTextView;
|
||||
Orientation m_orientation;
|
||||
};
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
class EvenOddBufferTextCell : public EvenOddCell {
|
||||
public:
|
||||
EvenOddBufferTextCell(KDText::FontSize size = KDText::FontSize::Small);
|
||||
EvenOddBufferTextCell(KDText::FontSize size = KDText::FontSize::Small, float horizontalAlignment = 1.0f, float verticalAlignment = 0.5f);
|
||||
void reloadCell() override;
|
||||
void setText(const char * textContent);
|
||||
void setTextColor(KDColor textColor);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include <escher/even_odd_buffer_text_cell.h>
|
||||
#include <assert.h>
|
||||
|
||||
EvenOddBufferTextCell::EvenOddBufferTextCell(KDText::FontSize size) :
|
||||
EvenOddBufferTextCell::EvenOddBufferTextCell(KDText::FontSize size, float horizontalAlignment, float verticalAlignment) :
|
||||
EvenOddCell(),
|
||||
m_bufferTextView(BufferTextView(size, 1.0f, 0.5f))
|
||||
m_bufferTextView(BufferTextView(size, horizontalAlignment, verticalAlignment))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user