mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[code] Created DoubleBufferTextView for functions/variables toolbox.
Change-Id: I8fb8d12463de44f244230eca36d4b0404343f57d
This commit is contained in:
@@ -8,6 +8,7 @@ app_objs += $(addprefix apps/code/,\
|
||||
console_edit_cell.o\
|
||||
console_line_cell.o\
|
||||
console_store.o\
|
||||
double_buffer_text_cell.o\
|
||||
editor_controller.o\
|
||||
helpers.o\
|
||||
menu_controller.o\
|
||||
|
||||
53
apps/code/double_buffer_text_cell.cpp
Normal file
53
apps/code/double_buffer_text_cell.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
#include "double_buffer_text_cell.h"
|
||||
#include <escher/palette.h>
|
||||
#include <assert.h>
|
||||
|
||||
DoubleBufferTextCell::DoubleBufferTextCell(KDText::FontSize size, float horizontalAlignment, float verticalAlignment) :
|
||||
TableCell(TableCell::Layout::Vertical),
|
||||
m_firstBufferTextView(size, horizontalAlignment, verticalAlignment),
|
||||
m_secondBufferTextView(size, horizontalAlignment, verticalAlignment)
|
||||
{
|
||||
}
|
||||
|
||||
const char * DoubleBufferTextCell::firstText() {
|
||||
return m_firstBufferTextView.text();
|
||||
}
|
||||
|
||||
const char * DoubleBufferTextCell::secondText() {
|
||||
return m_secondBufferTextView.text();
|
||||
}
|
||||
|
||||
void DoubleBufferTextCell::setFirstText(const char * textContent) {
|
||||
m_firstBufferTextView.setText(textContent);
|
||||
}
|
||||
|
||||
void DoubleBufferTextCell::setSecondText(const char * textContent) {
|
||||
m_secondBufferTextView.setText(textContent);
|
||||
}
|
||||
|
||||
void DoubleBufferTextCell::setFirstTextColor(KDColor textColor) {
|
||||
m_firstBufferTextView.setTextColor(textColor);
|
||||
}
|
||||
|
||||
void DoubleBufferTextCell::setSecondTextColor(KDColor textColor) {
|
||||
m_secondBufferTextView.setTextColor(textColor);
|
||||
}
|
||||
|
||||
void DoubleBufferTextCell::setHighlighted(bool highlight) {
|
||||
HighlightCell::setHighlighted(highlight);
|
||||
KDColor background = isHighlighted() ? Palette::Select : KDColorWhite;
|
||||
m_firstBufferTextView.setBackgroundColor(background);
|
||||
m_secondBufferTextView.setBackgroundColor(background);
|
||||
}
|
||||
|
||||
View * DoubleBufferTextCell::subviewAtIndex(int index) {
|
||||
assert(index >= 0 && index <= 1);
|
||||
if (index == 0) {
|
||||
return &m_firstBufferTextView;
|
||||
}
|
||||
return &m_secondBufferTextView;
|
||||
}
|
||||
|
||||
void DoubleBufferTextCell::layoutSubviews() {
|
||||
TableCell::layoutSubviews();
|
||||
}
|
||||
33
apps/code/double_buffer_text_cell.h
Normal file
33
apps/code/double_buffer_text_cell.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef CODE_DOUBLE_BUFFER_TEXT_CELL_H
|
||||
#define CODE_DOUBLE_BUFFER_TEXT_CELL_H
|
||||
|
||||
#include <escher/table_cell.h>
|
||||
#include <escher/buffer_text_view.h>
|
||||
|
||||
class DoubleBufferTextCell : public TableCell {
|
||||
public:
|
||||
DoubleBufferTextCell(KDText::FontSize size = KDText::FontSize::Small, float horizontalAlignment = 0.0f, float verticalAlignment = 0.5f);
|
||||
const char * firstText();
|
||||
const char * secondText();
|
||||
void setFirstText(const char * textContent);
|
||||
void setSecondText(const char * textContent);
|
||||
void setFirstTextColor(KDColor textColor);
|
||||
void setSecondTextColor(KDColor textColor);
|
||||
|
||||
/* TableCell */
|
||||
View * labelView() const override { return const_cast<View *>(static_cast<const View *>(&m_firstBufferTextView)); }
|
||||
View * accessoryView() const override { return const_cast<View *>(static_cast<const View *>(&m_secondBufferTextView)); }
|
||||
|
||||
/* HighlightCell */
|
||||
void setHighlighted(bool highlight) override;
|
||||
|
||||
/* View */
|
||||
int numberOfSubviews() const override { return 2; }
|
||||
View * subviewAtIndex(int index) override;
|
||||
void layoutSubviews() override;
|
||||
protected:
|
||||
BufferTextView m_firstBufferTextView;
|
||||
BufferTextView m_secondBufferTextView;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user