From 588817acc6aa3717668a2660b9bd891c329ca45b Mon Sep 17 00:00:00 2001 From: zetaPRIME Date: Mon, 6 Mar 2017 20:32:36 -0500 Subject: [PATCH] InputHandler backend for onscreen keyboards, app:/ asset loading --- .../source/starlight/ThemeManager.cpp | 15 ++++ libstarlight/source/starlight/dialog/OSK.cpp | 15 ++-- libstarlight/source/starlight/dialog/OSK.h | 9 +-- .../starlight/dialog/osk/InputHandler.cpp | 53 ++++++++++++++ .../starlight/dialog/osk/InputHandler.h | 72 +++++++++++++++++++ libstarlight/todo.txt | 10 +-- testbed/source/Core.cpp | 3 +- 7 files changed, 160 insertions(+), 17 deletions(-) create mode 100644 libstarlight/source/starlight/dialog/osk/InputHandler.cpp create mode 100644 libstarlight/source/starlight/dialog/osk/InputHandler.h diff --git a/libstarlight/source/starlight/ThemeManager.cpp b/libstarlight/source/starlight/ThemeManager.cpp index 560dbef..7bd17fa 100644 --- a/libstarlight/source/starlight/ThemeManager.cpp +++ b/libstarlight/source/starlight/ThemeManager.cpp @@ -13,6 +13,8 @@ #include "starlight/ConfigManager.h" +#include "starlight/Application.h" + #include "starlight/gfx/DrawableImage.h" #include "starlight/gfx/DrawableNinePatch.h" #include "starlight/gfx/DrawableTest.h" @@ -263,6 +265,19 @@ string ThemeManager::ResolveAssetPath(const string& id) { if (id.compare(0, pfxLocal.length(), pfxLocal) == 0) { // app-local asset // check if present in theme/app/[appname]/, else check in romfs + for (auto thm : themeData) { + Path bp = thm.basePath.Combine("app").Combine(Application::AppName()); + Path p = bp.Combine(id+".json"); + if (p.IsFile()) return p; + p = bp.Combine(id+".png"); + if (p.IsFile()) return p; + } + // TBD - directly in romfs, or in an assets folder? + Path bp = Path("romfs:"); + Path p = bp.Combine(id+".json"); + if (p.IsFile()) return p; + p = bp.Combine(id+".png"); + if (p.IsFile()) return p; } else { // theme asset; check in each theme from selected to most-fallback diff --git a/libstarlight/source/starlight/dialog/OSK.cpp b/libstarlight/source/starlight/dialog/OSK.cpp index 1e01cc2..cb5415f 100644 --- a/libstarlight/source/starlight/dialog/OSK.cpp +++ b/libstarlight/source/starlight/dialog/OSK.cpp @@ -23,10 +23,9 @@ using starlight::ui::Form; using starlight::dialog::OSK; -OSK::OSK(std::string* textptr, std::function onModify) : Form(true) { +OSK::OSK(osk::InputHandler* handler) : Form(true), handler(handler) { priority = 1000; // probably don't want all that much displaying above the keyboard - eOnModify = onModify; - pText = textptr; + handler->parent = this; auto cover = std::make_shared(touchScreen->rect.Expand(4), "decorations/dialog.modal-cover"); cover->blockTouch = true; @@ -38,7 +37,7 @@ OSK::OSK(std::string* textptr, std::function onModify) : Form(true) { touchScreen->Add(setContainer); auto actSym = [this](Button& key){ - this->OnSymKey(key.label); + this->handler->InputSymbol(key.label); }; Vector2 bs(24, 32); @@ -80,19 +79,21 @@ OSK::OSK(std::string* textptr, std::function onModify) : Form(true) { auto key = std::make_shared