From 587406bccd2bb1c8844355196532b387b8b6964a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Thu, 10 Aug 2017 10:56:07 +0200 Subject: [PATCH] [escher] In modal view controller, draw the regular view only if the modal view does not cover all of it Change-Id: I0eedcb881fa30ffad83cd371e59908810b4e179f --- escher/src/modal_view_controller.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/escher/src/modal_view_controller.cpp b/escher/src/modal_view_controller.cpp index 9f6eacb5a..ef397ed9c 100644 --- a/escher/src/modal_view_controller.cpp +++ b/escher/src/modal_view_controller.cpp @@ -23,15 +23,16 @@ void ModalViewController::ContentView::setMainView(View * regularView) { } int ModalViewController::ContentView::numberOfSubviews() const { - if (m_isDisplayingModal) { - return 2; - } - return 1; + bool shouldDrawTheRegularViewBehind = m_topMargin != 0 || m_leftMargin != 0 || m_bottomMargin != 0 || m_rightMargin != 0; + return 1 + (m_isDisplayingModal && shouldDrawTheRegularViewBehind); } View * ModalViewController::ContentView::subviewAtIndex(int index) { switch (index) { case 0: + if (m_isDisplayingModal && numberOfSubviews() == 1) { + return m_currentModalView; + } return m_regularView; case 1: if (numberOfSubviews() == 2) { @@ -59,8 +60,8 @@ KDRect ModalViewController::ContentView::frame() { void ModalViewController::ContentView::layoutSubviews() { assert(m_regularView != nullptr); m_regularView->setFrame(bounds()); - if (numberOfSubviews() == 2) { - assert(m_currentModalView != nullptr); + if (m_isDisplayingModal) { + assert(m_currentModalView != nullptr); m_currentModalView->setFrame(frame()); } }