From 8665978b2e373fa0c645eb3210b0e1bcb089442a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Mon, 22 May 2017 15:40:35 +0200 Subject: [PATCH 1/2] =?UTF-8?q?[apps/probability]=C2=A0Clean=20(add=20a=20?= =?UTF-8?q?page=20index=20in=20snapshot)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I1631136cf4912225b88d26cd3cd9d36fa91db5f0 --- apps/probability/app.cpp | 6 +++--- escher/include/escher/stack_view_controller.h | 2 +- escher/src/stack_view_controller.cpp | 15 +++++++++------ 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/apps/probability/app.cpp b/apps/probability/app.cpp index fbb8096a4..9a34dbbd0 100644 --- a/apps/probability/app.cpp +++ b/apps/probability/app.cpp @@ -75,11 +75,11 @@ App::App(Container * container, Snapshot * snapshot) : { switch (snapshot->activePage()) { case Snapshot::Page::Parameters: - m_stackViewController.pushModel(&m_parametersController, KDColorWhite, Palette::PurpleBright, Palette::PurpleBright); + m_stackViewController.push(&m_parametersController, KDColorWhite, Palette::PurpleBright, Palette::PurpleBright); break; case Snapshot::Page::Calculations: - m_stackViewController.pushModel(&m_parametersController, KDColorWhite, Palette::PurpleBright, Palette::PurpleBright); - m_stackViewController.pushModel(&m_calculationController, KDColorWhite, Palette::SubTab, Palette::SubTab); + m_stackViewController.push(&m_parametersController, KDColorWhite, Palette::PurpleBright, Palette::PurpleBright); + m_stackViewController.push(&m_calculationController, KDColorWhite, Palette::SubTab, Palette::SubTab); default: break; } diff --git a/escher/include/escher/stack_view_controller.h b/escher/include/escher/stack_view_controller.h index b2275ce17..8c9ce7e05 100644 --- a/escher/include/escher/stack_view_controller.h +++ b/escher/include/escher/stack_view_controller.h @@ -14,7 +14,6 @@ public: /* Push creates a new StackView and adds it */ void push(ViewController * vc, KDColor textColor = Palette::SubTab, KDColor backgroundColor = KDColorWhite, KDColor separatorColor = Palette::GreyBright); - void pushModel(ViewController * vc, KDColor textColor = Palette::SubTab, KDColor backgroundColor = KDColorWhite, KDColor separatorColor = Palette::GreyBright); void pop(); int depth(); @@ -69,6 +68,7 @@ private: static constexpr uint8_t k_maxNumberOfChildren = 4; Frame m_childrenFrame[k_maxNumberOfChildren]; uint8_t m_numberOfChildren; + bool m_isVisible; }; #endif diff --git a/escher/src/stack_view_controller.cpp b/escher/src/stack_view_controller.cpp index 1077bae92..0ac5e91ba 100644 --- a/escher/src/stack_view_controller.cpp +++ b/escher/src/stack_view_controller.cpp @@ -69,7 +69,8 @@ StackViewController::StackViewController(Responder * parentResponder, ViewContro bool displayFirstStackHeader, KDColor textColor, KDColor backgroundColor, KDColor separatorColor) : ViewController(parentResponder), m_view(ControllerView(displayFirstStackHeader)), - m_numberOfChildren(0) + m_numberOfChildren(0), + m_isVisible(false) { pushModel(Frame(rootViewController, textColor, backgroundColor, separatorColor)); rootViewController->setParentResponder(this); @@ -82,19 +83,19 @@ const char * StackViewController::title() { void StackViewController::push(ViewController * vc, KDColor textColor, KDColor backgroundColor, KDColor separatorColor) { Frame frame = Frame(vc, textColor, backgroundColor, separatorColor); - /* Load stack view */ - m_view.pushStack(frame); /* Add the frame to the model */ pushModel(frame); + if (!m_isVisible) { + return; + } + /* Load stack view */ + m_view.pushStack(frame); setupActiveViewController(); if (m_numberOfChildren > 1) { m_childrenFrame[m_numberOfChildren-2].viewController()->viewDidDisappear(); } } -void StackViewController::pushModel(ViewController * vc, KDColor textColor, KDColor backgroundColor, KDColor separatorColor) { - pushModel(Frame(vc, textColor, backgroundColor, separatorColor)); -} void StackViewController::pop() { m_view.popStack(); assert(m_numberOfChildren > 0); @@ -150,6 +151,7 @@ void StackViewController::viewWillAppear() { m_view.setContentView(vc->view()); vc->viewWillAppear(); } + m_isVisible = true; } void StackViewController::viewDidDisappear() { @@ -160,4 +162,5 @@ void StackViewController::viewDidDisappear() { for (int i = 0; i < m_numberOfChildren; i++) { m_view.popStack(); } + m_isVisible = false; } From d8b6399aa8ea94b0c7c69b51d113b1a864162ab7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Mon, 22 May 2017 15:50:54 +0200 Subject: [PATCH 2/2] [apps/home] Improve app cell rendering 2 Change-Id: Id08242b9731ddc22632602e4671f124752e319f9 --- apps/home/app_cell.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/home/app_cell.cpp b/apps/home/app_cell.cpp index 145ddcfb6..1b5f24280 100644 --- a/apps/home/app_cell.cpp +++ b/apps/home/app_cell.cpp @@ -28,7 +28,7 @@ View * AppCell::subviewAtIndex(int index) { void AppCell::layoutSubviews() { m_iconView.setFrame(KDRect((bounds().width()-k_iconWidth)/2, k_iconMargin, k_iconWidth,k_iconHeight)); KDSize nameSize = m_nameView.minimalSizeForOptimalDisplay(); - m_nameView.setFrame(KDRect(k_nameWidthMargin, bounds().height()-nameSize.height() - 2*k_nameHeightMargin, bounds().width()-2*k_nameWidthMargin, nameSize.height()+2*k_nameHeightMargin)); + m_nameView.setFrame(KDRect((bounds().width()-nameSize.width())/2-k_nameWidthMargin, bounds().height()-nameSize.height() - 2*k_nameHeightMargin, nameSize.width()+2*k_nameWidthMargin, nameSize.height()+2*k_nameHeightMargin)); } void AppCell::setAppDescriptor(::App::Descriptor * descriptor) {