aboutsummaryrefslogtreecommitdiffstats
path: root/support/magicleap/Servo2D/code
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2019-01-22 13:44:06 -0500
committerJosh Matthews <josh@joshmatthews.net>2019-03-04 12:43:49 -0500
commit5b7be2548a837fcf327935ba615b189f9e3b830d (patch)
treeb179c7004ff2b7d346cfee5184cbad503e2da450 /support/magicleap/Servo2D/code
parent887333ae827f24fbac4e4b4f63adc80fa59e7df9 (diff)
downloadservo-5b7be2548a837fcf327935ba615b189f9e3b830d.tar.gz
servo-5b7be2548a837fcf327935ba615b189f9e3b830d.zip
Build MagicLeap port using libsimpleservo.
Diffstat (limited to 'support/magicleap/Servo2D/code')
-rw-r--r--support/magicleap/Servo2D/code/inc/Servo2D.h7
-rw-r--r--support/magicleap/Servo2D/code/src/Servo2D.cpp23
2 files changed, 22 insertions, 8 deletions
diff --git a/support/magicleap/Servo2D/code/inc/Servo2D.h b/support/magicleap/Servo2D/code/inc/Servo2D.h
index 88ccbf6cc76..e127332b52d 100644
--- a/support/magicleap/Servo2D/code/inc/Servo2D.h
+++ b/support/magicleap/Servo2D/code/inc/Servo2D.h
@@ -59,7 +59,12 @@ public:
/**
* Update the browser history UI
*/
- void updateHistory(bool canGoBack, const char* url, bool canGoForward);
+ void updateHistory(bool canGoBack, bool canGoForward);
+
+ /**
+ * Update the browser url bar.
+ */
+ void updateUrl(const char* url);
/**
* Make the keyboard visible
diff --git a/support/magicleap/Servo2D/code/src/Servo2D.cpp b/support/magicleap/Servo2D/code/src/Servo2D.cpp
index c0abce98ec2..6056ebcada2 100644
--- a/support/magicleap/Servo2D/code/src/Servo2D.cpp
+++ b/support/magicleap/Servo2D/code/src/Servo2D.cpp
@@ -48,9 +48,15 @@ void logger(MLLogLevel lvl, char* msg) {
}
// A function which updates the history ui, suitable for passing into Servo
-typedef void (*MLHistoryUpdate)(Servo2D* app, bool canGoBack, char* url, bool canGoForward);
-void history(Servo2D* app, bool canGoBack, char* url, bool canGoForward) {
- app->updateHistory(canGoBack, url, canGoForward);
+typedef void (*MLHistoryUpdate)(Servo2D* app, bool canGoBack, bool canGoForward);
+void history(Servo2D* app, bool canGoBack, bool canGoForward) {
+ app->updateHistory(canGoBack, canGoForward);
+}
+
+// A function which updates the url ui, suitable for passing into Servo
+typedef void (*MLURLUpdate)(Servo2D* app, char* url);
+void url(Servo2D* app, char* url) {
+ app->updateUrl(url);
}
// A function to show or hide the keyboard
@@ -61,7 +67,7 @@ void keyboard(Servo2D* app, bool visible) {
// The functions Servo provides for hooking up to the ML.
extern "C" ServoInstance* init_servo(EGLContext, EGLSurface, EGLDisplay,
- Servo2D*, MLLogger, MLHistoryUpdate, MLKeyboard,
+ Servo2D*, MLLogger, MLHistoryUpdate, MLURLUpdate, MLKeyboard,
const char* url, int width, int height, float hidpi);
extern "C" void heartbeat_servo(ServoInstance*);
extern "C" void keyboard_servo(ServoInstance*, char32_t code, lumin::ui::KeyType keyType);
@@ -165,7 +171,7 @@ int Servo2D::init() {
EGLDisplay dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
// Hook into servo
- servo_ = init_servo(ctx, surf, dpy, this, logger, history, keyboard, HOME_PAGE, VIEWPORT_W, VIEWPORT_H, HIDPI);
+ servo_ = init_servo(ctx, surf, dpy, this, logger, history, url, keyboard, HOME_PAGE, VIEWPORT_W, VIEWPORT_H, HIDPI);
if (!servo_) {
ML_LOG(Error, "Servo2D Failed to init servo instance");
abort();
@@ -401,8 +407,11 @@ bool Servo2D::keyboardEventListener(const lumin::ui::KeyboardEvent::EventData& e
return true;
}
-void Servo2D::updateHistory(bool canGoBack, const char* url, bool canGoForward) {
+void Servo2D::updateUrl(const char* url) {
+ url_bar_->setText(url);
+}
+
+void Servo2D::updateHistory(bool canGoBack, bool canGoForward) {
back_button_->setEnabled(canGoBack);
fwd_button_->setEnabled(canGoForward);
- url_bar_->setText(url);
}