[escher] In modal view controller, draw the regular view only if the

modal view does not cover all of it

Change-Id: I0eedcb881fa30ffad83cd371e59908810b4e179f
This commit is contained in:
Émilie Feral
2017-08-10 10:56:07 +02:00
parent 7f6ee28f4e
commit 587406bccd

View File

@@ -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());
}
}