diff --git a/escher/include/escher/stack_view.h b/escher/include/escher/stack_view.h index fa4201107..9059c3bf4 100644 --- a/escher/include/escher/stack_view.h +++ b/escher/include/escher/stack_view.h @@ -2,6 +2,7 @@ #define ESCHER_STACK_VIEW_H #include +#include class StackView : public View { public: @@ -14,7 +15,10 @@ protected: void logAttributes(std::ostream &os) const override; #endif private: - const char * m_name; + int numberOfSubviews() const override; + View * subviewAtIndex(int index) override; + void layoutSubviews() override; + PointerTextView m_textView; }; #endif diff --git a/escher/src/stack_view.cpp b/escher/src/stack_view.cpp index f9d963d61..0b56a6c3b 100644 --- a/escher/src/stack_view.cpp +++ b/escher/src/stack_view.cpp @@ -1,22 +1,38 @@ #include +#include extern "C" { #include } StackView::StackView() : View(), - m_name(nullptr) + m_textView(PointerTextView(nullptr, 0.5f, 0.5f, Palette::k_desactiveTextColor)) { } +int StackView::numberOfSubviews() const { + return 1; +} + +View * StackView::subviewAtIndex(int index) { + assert(index == 0); + return &m_textView; +} + +void StackView::layoutSubviews() { + m_textView.setFrame(bounds()); +} + void StackView::setName(const char * name) { - m_name = name; - markRectAsDirty(bounds()); + m_textView.setText(name); } void StackView::drawRect(KDContext * ctx, KDRect rect) const { - ctx->fillRect(rect, KDColor(0xFFCD50)); - ctx->drawString(m_name, KDPointZero); + KDCoordinate height = bounds().height(); + KDCoordinate width = bounds().width(); + ctx->fillRect(KDRect(0, 0, width, 1), Palette::LineColor); + ctx->fillRect(KDRect(0, 1, width, height-2), KDColorWhite); + ctx->fillRect(KDRect(0, height-1, width, 1), Palette::LineColor); } #if ESCHER_VIEW_LOGGING diff --git a/escher/src/stack_view_controller.cpp b/escher/src/stack_view_controller.cpp index 819c61c7d..37adfabea 100644 --- a/escher/src/stack_view_controller.cpp +++ b/escher/src/stack_view_controller.cpp @@ -33,10 +33,11 @@ void StackViewController::ControllerView::layoutSubviews() { KDCoordinate width = m_frame.width(); int indexFirstHeader = m_displayFirstStackHeader ? 0 : 1; for (int i=indexFirstHeader; i 1); + KDRect contentViewFrame = KDRect( 0, (m_numberOfStacks-indexFirstHeader)*stackHeight + separatorHeight, width, m_frame.height() - (m_numberOfStacks-indexFirstHeader)*stackHeight); m_contentView->setFrame(contentViewFrame); }