From da0d42ca3b27d4e0b15144f575023d8faa6c6576 Mon Sep 17 00:00:00 2001 From: Ruben Dashyan Date: Thu, 7 Feb 2019 18:19:44 +0100 Subject: [PATCH] [apps/calculation/history_view_cell] Fix background colors Set m_inputView's m_expressionView's background color --- apps/calculation/history_view_cell.cpp | 5 +++-- apps/calculation/scrollable_expression_view.cpp | 4 ++++ apps/calculation/scrollable_expression_view.h | 1 + escher/include/escher/scroll_view.h | 7 ++++++- escher/include/escher/scroll_view_indicator.h | 1 + escher/src/scroll_view.cpp | 6 ++++++ 6 files changed, 21 insertions(+), 3 deletions(-) diff --git a/apps/calculation/history_view_cell.cpp b/apps/calculation/history_view_cell.cpp index 05cc33bfc..d51413654 100644 --- a/apps/calculation/history_view_cell.cpp +++ b/apps/calculation/history_view_cell.cpp @@ -39,17 +39,18 @@ Shared::ScrollableExactApproximateExpressionsView * HistoryViewCell::outputView( void HistoryViewCell::setEven(bool even) { EvenOddCell::setEven(even); m_inputView.setBackgroundColor(backgroundColor()); + m_scrollableOutputView.setBackgroundColor(backgroundColor()); m_scrollableOutputView.evenOddCell()->setEven(even); } void HistoryViewCell::setHighlighted(bool highlight) { assert(m_dataSource); m_highlighted = highlight; - m_inputView.setBackgroundColor(backgroundColor()); + m_inputView.setExpressionBackgroundColor(backgroundColor()); m_scrollableOutputView.evenOddCell()->setHighlighted(false); if (isHighlighted()) { if (m_dataSource->selectedSubviewType() == HistoryViewCellDataSource::SubviewType::Input) { - m_inputView.setBackgroundColor(Palette::Select); + m_inputView.setExpressionBackgroundColor(Palette::Select); } else { m_scrollableOutputView.evenOddCell()->setHighlighted(true); } diff --git a/apps/calculation/scrollable_expression_view.cpp b/apps/calculation/scrollable_expression_view.cpp index 692662014..a07068934 100644 --- a/apps/calculation/scrollable_expression_view.cpp +++ b/apps/calculation/scrollable_expression_view.cpp @@ -19,4 +19,8 @@ void ScrollableExpressionView::setBackgroundColor(KDColor backgroundColor) { ScrollableView::setBackgroundColor(backgroundColor); } +void ScrollableExpressionView::setExpressionBackgroundColor(KDColor backgroundColor) { + m_expressionView.setBackgroundColor(backgroundColor); +} + } diff --git a/apps/calculation/scrollable_expression_view.h b/apps/calculation/scrollable_expression_view.h index 78fc5ff56..15ce343bf 100644 --- a/apps/calculation/scrollable_expression_view.h +++ b/apps/calculation/scrollable_expression_view.h @@ -10,6 +10,7 @@ public: ScrollableExpressionView(Responder * parentResponder); void setLayout(Poincare::Layout layout); void setBackgroundColor(KDColor backgroundColor) override; + void setExpressionBackgroundColor(KDColor backgroundColor); private: ExpressionView m_expressionView; }; diff --git a/escher/include/escher/scroll_view.h b/escher/include/escher/scroll_view.h index 57e7b385e..6fa18ac84 100644 --- a/escher/include/escher/scroll_view.h +++ b/escher/include/escher/scroll_view.h @@ -35,6 +35,7 @@ public: virtual int numberOfIndicators() { return 0; } virtual View * indicatorAtIndex(int index) { assert(false); return nullptr; } virtual void layoutIndicators(KDSize content, KDPoint offset, KDSize frame) {} + virtual void setBackgroundColor(KDColor c) {} }; class BarDecorator : public Decorator { @@ -64,6 +65,7 @@ public: return &m_topArrow + (index-1); } void layoutIndicators(KDSize content, KDPoint offset, KDSize frame) override; + void setBackgroundColor(KDColor c) override; private: ScrollViewArrow m_topArrow; ScrollViewArrow m_rightArrow; @@ -73,7 +75,10 @@ public: Decorator * decorator(); void setDecoratorType(Decorator::Type t) { m_decoratorType = t; } - virtual void setBackgroundColor(KDColor c) { m_backgroundColor = c; } + virtual void setBackgroundColor(KDColor c) { + m_backgroundColor = c; + decorator()->setBackgroundColor(m_backgroundColor); + } KDColor backgroundColor() const { return m_backgroundColor; } void setContentOffset(KDPoint offset, bool forceRelayout = false); diff --git a/escher/include/escher/scroll_view_indicator.h b/escher/include/escher/scroll_view_indicator.h index 6744d6974..b91a64bb4 100644 --- a/escher/include/escher/scroll_view_indicator.h +++ b/escher/include/escher/scroll_view_indicator.h @@ -53,6 +53,7 @@ public: }; ScrollViewArrow(Side side); bool update(bool visible); + void setBackgroundColor(KDColor c) { m_backgroundColor = c; } void drawRect(KDContext * ctx, KDRect rect) const override; private: bool m_visible; diff --git a/escher/src/scroll_view.cpp b/escher/src/scroll_view.cpp index 2539ea0fa..f22f77f07 100644 --- a/escher/src/scroll_view.cpp +++ b/escher/src/scroll_view.cpp @@ -184,6 +184,12 @@ void ScrollView::ArrowDecorator::layoutIndicators(KDSize content, KDPoint offset )); } +void ScrollView::ArrowDecorator::setBackgroundColor(KDColor c) { + for (int i = 0; i < numberOfIndicators(); i++) { + (&m_topArrow + i)->setBackgroundColor(c); + } +} + #if ESCHER_VIEW_LOGGING const char * ScrollView::className() const { return "ScrollView";