Blame view

Modif/epsilon-master/escher/src/bank_view_controller.cpp 1.06 KB
6663b6c9   adorian   projet complet av...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  #include <escher/bank_view_controller.h>
  #include <escher/app.h>
  
  BankViewController::BankViewController(Responder * parentViewController) :
    ViewController(parentViewController),
    m_activeIndex(0)
  {
  }
  
  void BankViewController::setActiveIndex(int i) {
    assert(i >= 0 && i < numberOfChildren());
    if (i == m_activeIndex) {
      return;
    }
    ViewController * upcomingVC = childAtIndex(i);
    upcomingVC->viewWillAppear();
    app()->setFirstResponder(upcomingVC);
    childAtIndex(m_activeIndex)->viewDidDisappear();
    m_activeIndex = i;
    m_view.setSubview(upcomingVC->view());
  }
  
  void BankViewController::didEnterResponderChain(Responder * previousResponder) {
    app()->setFirstResponder(activeViewController());
  }
  
  void BankViewController::viewWillAppear() {
    m_view.setSubview(activeViewController()->view());
    activeViewController()->viewWillAppear();
  }
  
  void BankViewController::viewDidDisappear() {
    activeViewController()->viewDidDisappear();
  }
  
  void BankViewController::ContentView::setSubview(View * view) {
    m_subview = view;
    layoutSubviews();
    markRectAsDirty(bounds());
  }