[escher] Add a class MessageTableCellWithChevronAndBuffer

This commit is contained in:
Émilie Feral
2019-08-29 15:18:30 +02:00
parent 2827594616
commit 6013e6a937
4 changed files with 42 additions and 0 deletions

View File

@@ -35,6 +35,7 @@ escher_src += $(addprefix escher/src/,\
message_table_cell.cpp \
message_table_cell_with_buffer.cpp \
message_table_cell_with_chevron.cpp \
message_table_cell_with_chevron_and_buffer.cpp \
message_table_cell_with_chevron_and_message.cpp \
message_table_cell_with_chevron_and_expression.cpp \
message_table_cell_with_editable_text.cpp \

View File

@@ -39,6 +39,7 @@
#include <escher/message_table_cell.h>
#include <escher/message_table_cell_with_buffer.h>
#include <escher/message_table_cell_with_chevron.h>
#include <escher/message_table_cell_with_chevron_and_buffer.h>
#include <escher/message_table_cell_with_chevron_and_message.h>
#include <escher/message_table_cell_with_chevron_and_expression.h>
#include <escher/message_table_cell_with_editable_text.h>

View File

@@ -0,0 +1,17 @@
#ifndef ESCHER_MESSAGE_TABLE_CELL_WITH_CHEVRON_AND_BUFFER_H
#define ESCHER_MESSAGE_TABLE_CELL_WITH_CHEVRON_AND_BUFFER_H
#include <escher/message_table_cell_with_chevron.h>
#include <escher/buffer_text_view.h>
class MessageTableCellWithChevronAndBuffer : public MessageTableCellWithChevron {
public:
MessageTableCellWithChevronAndBuffer(const KDFont * labelFont = KDFont::SmallFont, const KDFont * subAccessoryFont = KDFont::SmallFont);
View * subAccessoryView() const override;
void setHighlighted(bool highlight) override;
void setAccessoryText(const char * textBody);
private:
BufferTextView m_subAccessoryView;
};
#endif

View File

@@ -0,0 +1,23 @@
#include <escher/message_table_cell_with_chevron_and_buffer.h>
#include <escher/palette.h>
MessageTableCellWithChevronAndBuffer::MessageTableCellWithChevronAndBuffer(const KDFont * labelFont, const KDFont * subAccessoryFont) :
MessageTableCellWithChevron((I18n::Message)0, labelFont),
m_subAccessoryView(subAccessoryFont, 1.0f, 0.5f, Palette::GreyDark)
{
}
View * MessageTableCellWithChevronAndBuffer::subAccessoryView() const {
return (View *)&m_subAccessoryView;
}
void MessageTableCellWithChevronAndBuffer::setHighlighted(bool highlight) {
MessageTableCellWithChevron::setHighlighted(highlight);
KDColor backgroundColor = isHighlighted()? Palette::Select : KDColorWhite;
m_subAccessoryView.setBackgroundColor(backgroundColor);
}
void MessageTableCellWithChevronAndBuffer::setAccessoryText(const char * textBody) {
m_subAccessoryView.setText(textBody);
layoutSubviews();
}