Merge changes Id08242b9,I1631136c

* changes:
  [apps/home] Improve app cell rendering 2
  [apps/probability] Clean (add a page index in snapshot)
This commit is contained in:
Émilie Feral
2017-05-23 15:25:30 +02:00
committed by Gerrit
4 changed files with 14 additions and 11 deletions

View File

@@ -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) {

View File

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

View File

@@ -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

View File

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