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
41
42
43
44
45
46
47
48
49
|
#include "simple_interactive_curve_view_controller.h"
#include <cmath>
#include <assert.h>
using namespace Poincare;
namespace Shared {
SimpleInteractiveCurveViewController::SimpleInteractiveCurveViewController(Responder * parentResponder,InteractiveCurveViewRange * interactiveRange, CurveView * curveView, CurveViewCursor * cursor) :
ViewController(parentResponder),
m_cursor(cursor)
{
}
View * SimpleInteractiveCurveViewController::view() {
return curveView();
}
bool SimpleInteractiveCurveViewController::handleEvent(Ion::Events::Event event) {
if (event == Ion::Events::Plus || event == Ion::Events::Minus) {
return handleZoom(event);
}
if (event == Ion::Events::Left || event == Ion::Events::Right) {
return handleLeftRightEvent(event);
}
if (event == Ion::Events::EXE || event == Ion::Events::OK) {
return handleEnter();
}
return false;
}
bool SimpleInteractiveCurveViewController::handleZoom(Ion::Events::Event event) {
float ratio = event == Ion::Events::Plus ? 2.0f/3.0f : 3.0f/2.0f;
interactiveCurveViewRange()->zoom(ratio, m_cursor->x(), m_cursor->y());
curveView()->reload();
return true;
}
bool SimpleInteractiveCurveViewController::handleLeftRightEvent(Ion::Events::Event event) {
int direction = event == Ion::Events::Left ? -1 : 1;
if (moveCursorHorizontally(direction)) {
reloadBannerView();
curveView()->reload();
return true;
}
return false;
}
}
|