mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-19 22:00:28 +01:00
[apps] Shared: break InteractiveCurveViewController into 2 classes (to
shared the implementation of Zoom in/out and MoveCursorHorizontally)
This commit is contained in:
committed by
EmilieNumworks
parent
e1b09b639d
commit
323ecc72c5
46
apps/shared/simple_interactive_curve_view_controller.cpp
Normal file
46
apps/shared/simple_interactive_curve_view_controller.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
#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);
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user