From ce88f3417910ff63c6c5c84df72af8bc8e68d709 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Wed, 18 Jan 2017 16:00:22 +0100 Subject: [PATCH] [escher] In text view, fix bug: color all background in background color Change-Id: I45bab2759cde8d6af51b927750ba16610afc36cd --- apps/graph/function_title_cell.cpp | 15 ++++++++------- apps/graph/function_title_cell.h | 3 +-- apps/graph/list/list_controller.cpp | 3 ++- apps/graph/values/values_controller.cpp | 3 ++- .../escher/alternate_empty_view_controller.h | 1 - escher/src/alternate_empty_view_controller.cpp | 6 ------ escher/src/stack_view.cpp | 2 +- escher/src/text_view.cpp | 1 + 8 files changed, 15 insertions(+), 19 deletions(-) diff --git a/apps/graph/function_title_cell.cpp b/apps/graph/function_title_cell.cpp index 0b7cc6695..08116dcff 100644 --- a/apps/graph/function_title_cell.cpp +++ b/apps/graph/function_title_cell.cpp @@ -3,9 +3,10 @@ namespace Graph { -FunctionTitleCell::FunctionTitleCell() : +FunctionTitleCell::FunctionTitleCell(Orientation orientation) : EvenOddCell(), - m_bufferTextView(0.5f, 0.5f) + m_bufferTextView(0.5f, 0.5f), + m_orientation(orientation) { } @@ -23,10 +24,6 @@ void FunctionTitleCell::setColor(KDColor color) { m_bufferTextView.setTextColor(color); } -void FunctionTitleCell::setOrientation(Orientation orientation) { - m_orientation = orientation; -} - int FunctionTitleCell::numberOfSubviews() const { return 1; } @@ -37,7 +34,11 @@ View * FunctionTitleCell::subviewAtIndex(int index) { } void FunctionTitleCell::layoutSubviews() { - m_bufferTextView.setFrame(bounds()); + KDRect textFrame(0, k_colorIndicatorThickness, bounds().width(), bounds().height() - k_colorIndicatorThickness); + if (m_orientation == Orientation::VerticalIndicator){ + textFrame = KDRect(k_colorIndicatorThickness, 0, bounds().width() - k_colorIndicatorThickness, bounds().height()); + } + m_bufferTextView.setFrame(textFrame); } void FunctionTitleCell::drawRect(KDContext * ctx, KDRect rect) const { diff --git a/apps/graph/function_title_cell.h b/apps/graph/function_title_cell.h index b9e751c92..05cf15d5d 100644 --- a/apps/graph/function_title_cell.h +++ b/apps/graph/function_title_cell.h @@ -10,9 +10,8 @@ public: HorizontalIndicator, VerticalIndicator }; - FunctionTitleCell(); + FunctionTitleCell(Orientation orientation); void setColor(KDColor color); - void setOrientation(Orientation orientation); void setText(const char * textContent); void drawRect(KDContext * ctx, KDRect rect) const override; void reloadCell() override; diff --git a/apps/graph/list/list_controller.cpp b/apps/graph/list/list_controller.cpp index ea15b1446..8bba76947 100644 --- a/apps/graph/list/list_controller.cpp +++ b/apps/graph/list/list_controller.cpp @@ -7,6 +7,8 @@ namespace Graph { ListController::ListController(Responder * parentResponder, FunctionStore * functionStore, HeaderViewController * header) : ViewController(parentResponder), HeaderViewDelegate(header), + m_functionTitleCells{FunctionTitleCell(FunctionTitleCell::Orientation::VerticalIndicator), FunctionTitleCell(FunctionTitleCell::Orientation::VerticalIndicator), FunctionTitleCell(FunctionTitleCell::Orientation::VerticalIndicator), + FunctionTitleCell(FunctionTitleCell::Orientation::VerticalIndicator), FunctionTitleCell(FunctionTitleCell::Orientation::VerticalIndicator), FunctionTitleCell(FunctionTitleCell::Orientation::VerticalIndicator)}, m_selectableTableView(SelectableTableView(this, this)), m_functionStore(functionStore), m_parameterController(ParameterController(this, functionStore)) @@ -233,7 +235,6 @@ void ListController::willDisplayCellAtLocation(TableViewCell * cell, int i, int myFunctionCell->setText(bufferName); KDColor functionNameColor = function->isActive() ? function->color() : Palette::DesactiveTextColor; myFunctionCell->setColor(functionNameColor); - myFunctionCell->setOrientation(FunctionTitleCell::Orientation::VerticalIndicator); } else { FunctionExpressionView * myCell = (FunctionExpressionView *)cell; myCell->setFunction(m_functionStore->functionAtIndex(j)); diff --git a/apps/graph/values/values_controller.cpp b/apps/graph/values/values_controller.cpp index af1431a36..903c27ce0 100644 --- a/apps/graph/values/values_controller.cpp +++ b/apps/graph/values/values_controller.cpp @@ -9,6 +9,8 @@ namespace Graph { ValuesController::ValuesController(Responder * parentResponder, FunctionStore * functionStore, HeaderViewController * header) : EditableCellTableViewController(parentResponder, k_topMargin, k_rightMargin, k_bottomMargin, k_leftMargin), HeaderViewDelegate(header), + m_functionTitleCells{FunctionTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator), FunctionTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator), FunctionTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator), + FunctionTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator), FunctionTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator)}, m_abscissaCells{EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer),EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer)}, m_functionStore(functionStore), @@ -140,7 +142,6 @@ void ValuesController::willDisplayCellAtLocation(TableViewCell * cell, int i, in } myFunctionCell->setText(name); myFunctionCell->setColor(function->color()); - myFunctionCell->setOrientation(FunctionTitleCell::Orientation::HorizontalIndicator); return; } // The cell is not a title cell diff --git a/escher/include/escher/alternate_empty_view_controller.h b/escher/include/escher/alternate_empty_view_controller.h index 08af6a7a9..4bd054e6e 100644 --- a/escher/include/escher/alternate_empty_view_controller.h +++ b/escher/include/escher/alternate_empty_view_controller.h @@ -16,7 +16,6 @@ private: class ContentView : public View { public: ContentView(ViewController * mainViewController, AlternateEmptyViewDelegate * delegate); - void drawRect(KDContext * ctx, KDRect rect) const override; ViewController * mainViewController() const; AlternateEmptyViewDelegate * alternateEmptyViewDelegate() const; void layoutSubviews() override; diff --git a/escher/src/alternate_empty_view_controller.cpp b/escher/src/alternate_empty_view_controller.cpp index 6e288bdb6..9406406bf 100644 --- a/escher/src/alternate_empty_view_controller.cpp +++ b/escher/src/alternate_empty_view_controller.cpp @@ -12,12 +12,6 @@ AlternateEmptyViewController::ContentView::ContentView(ViewController * mainView { } -void AlternateEmptyViewController::ContentView::drawRect(KDContext * ctx, KDRect rect) const { - if (m_delegate->isEmpty()) { - ctx->fillRect(bounds(), Palette::BackgroundColor); - } -} - int AlternateEmptyViewController::ContentView::numberOfSubviews() const { return 1; } diff --git a/escher/src/stack_view.cpp b/escher/src/stack_view.cpp index 94904e933..deb4d9595 100644 --- a/escher/src/stack_view.cpp +++ b/escher/src/stack_view.cpp @@ -32,7 +32,7 @@ View * StackView::subviewAtIndex(int index) { } void StackView::layoutSubviews() { - m_textView.setFrame(bounds()); + m_textView.setFrame(KDRect(0, 1, bounds().width(), bounds().height()-2)); } void StackView::setName(const char * name) { diff --git a/escher/src/text_view.cpp b/escher/src/text_view.cpp index 524ece4a4..47914fb3b 100644 --- a/escher/src/text_view.cpp +++ b/escher/src/text_view.cpp @@ -37,6 +37,7 @@ void TextView::drawRect(KDContext * ctx, KDRect rect) const { KDSize textSize = KDText::stringSize(text()); KDPoint origin(m_horizontalAlignment*(m_frame.width() - textSize.width()), m_verticalAlignment*(m_frame.height() - textSize.height())); + ctx->fillRect(bounds(), m_backgroundColor); ctx->drawString(text(), origin, m_textColor, m_backgroundColor); }