diff --git a/libstarlight/source/starlight/Application.cpp b/libstarlight/source/starlight/Application.cpp index 138ee80..1fe9a50 100644 --- a/libstarlight/source/starlight/Application.cpp +++ b/libstarlight/source/starlight/Application.cpp @@ -82,8 +82,15 @@ void Application::_init() { void Application::_end() { End(); + //for (auto& f : forms) f->Close(); forms.clear(); // not sure why, but not doing this results in a data abort if any forms are active + // force cleanup! let's not softlock, mmkay? + formTouchScreen = nullptr; + formTopScreen = nullptr; + touchScreen.reset(); + topScreen.reset(); + ThemeManager::End(); RenderCore::Close(); ConfigManager::End(); diff --git a/libstarlight/source/starlight/dialog/Backdrop.cpp b/libstarlight/source/starlight/dialog/Backdrop.cpp new file mode 100644 index 0000000..f581043 --- /dev/null +++ b/libstarlight/source/starlight/dialog/Backdrop.cpp @@ -0,0 +1,17 @@ +#include "Backdrop.h" + +#include "starlight/ui/Image.h" + +using starlight::ui::Image; + +using starlight::ui::Form; + +using starlight::dialog::Backdrop; + +Backdrop::Backdrop(std::string imgPath) : Form(true) { + priority = -1000000; // it is, after all, a backdrop + auto img = std::make_shared(VRect(0, 0, 400, 480), imgPath); + topScreen->Add(img); + touchScreen->Add(img); + touchScreen->scrollOffset = Vector2(40, 240); +} diff --git a/libstarlight/source/starlight/dialog/Backdrop.h b/libstarlight/source/starlight/dialog/Backdrop.h new file mode 100644 index 0000000..1d8c98c --- /dev/null +++ b/libstarlight/source/starlight/dialog/Backdrop.h @@ -0,0 +1,21 @@ +#pragma once +#include "starlight/_global.h" + +#include + +#include "starlight/ThemeManager.h" + +#include "starlight/ui/Form.h" + +namespace starlight { + namespace dialog { + class Backdrop : public ui::Form, public ui::FormCreator { + private: + // + + public: + Backdrop(std::string imgPath = "decorations/generic backdrop"); + //~Backdrop() override { }; + }; + } +} diff --git a/libstarlight/source/starlight/dialog/OSK.cpp b/libstarlight/source/starlight/dialog/OSK.cpp index 93918c1..bf1ccdf 100644 --- a/libstarlight/source/starlight/dialog/OSK.cpp +++ b/libstarlight/source/starlight/dialog/OSK.cpp @@ -121,6 +121,7 @@ OSK::OSK(osk::InputHandler* handler) : Form(true), handler(handler) { void OSK::Update(bool focused) { if (handler->done) { Close(); + return; } if (focused) { if (InputManager::Pressed(Keys::B)) handler->Done(); diff --git a/libstarlight/source/starlight/dialog/OSK.h b/libstarlight/source/starlight/dialog/OSK.h index deff676..936429c 100644 --- a/libstarlight/source/starlight/dialog/OSK.h +++ b/libstarlight/source/starlight/dialog/OSK.h @@ -25,7 +25,7 @@ namespace starlight { std::unique_ptr handler; OSK(osk::InputHandler* handler); - ~OSK() override { }; + //~OSK() override { }; void Update(bool focused) override; diff --git a/libstarlight/source/starlight/ui/Form.cpp b/libstarlight/source/starlight/ui/Form.cpp index 2a7db26..a683f37 100644 --- a/libstarlight/source/starlight/ui/Form.cpp +++ b/libstarlight/source/starlight/ui/Form.cpp @@ -62,6 +62,7 @@ void Form::Open(bool showImmediately) { } void Form::Close() { + volatile auto keepalive = shared_from_this(); // don't allow delete until Close() goes out of scope auto app = Application::Current(); if (app == nullptr) return; app->forms.remove(shared_from_this()); diff --git a/libstarlight/source/starlight/ui/Form.h b/libstarlight/source/starlight/ui/Form.h index 97cb6a3..09b09a4 100644 --- a/libstarlight/source/starlight/ui/Form.h +++ b/libstarlight/source/starlight/ui/Form.h @@ -66,7 +66,7 @@ namespace starlight { Form() { } Form(bool useDefaults); - virtual ~Form() { } + virtual ~Form() = default; void Open(bool showImmediately = true); void Close(); diff --git a/libstarlight/source/starlight/ui/UICanvas.h b/libstarlight/source/starlight/ui/UICanvas.h index 95b110e..2aeac8d 100644 --- a/libstarlight/source/starlight/ui/UICanvas.h +++ b/libstarlight/source/starlight/ui/UICanvas.h @@ -19,7 +19,7 @@ namespace starlight { bool needsRedraw = true; UICanvas(VRect rect); - ~UICanvas() { } + //~UICanvas() { } void MarkForRedraw() override; diff --git a/libstarlight/source/starlight/ui/UIContainer.cpp b/libstarlight/source/starlight/ui/UIContainer.cpp index 954b54c..7c399b7 100644 --- a/libstarlight/source/starlight/ui/UIContainer.cpp +++ b/libstarlight/source/starlight/ui/UIContainer.cpp @@ -10,7 +10,6 @@ using starlight::ui::UIElement; using starlight::ui::UIContainer; UIContainer::UIContainer() { } -UIContainer::~UIContainer() { } void UIContainer::Dive(std::function check, std::function func, bool consumable, bool frontFirst) { bool finished = false; diff --git a/libstarlight/source/starlight/ui/UIContainer.h b/libstarlight/source/starlight/ui/UIContainer.h index bd26a4f..8a7d439 100644 --- a/libstarlight/source/starlight/ui/UIContainer.h +++ b/libstarlight/source/starlight/ui/UIContainer.h @@ -29,7 +29,7 @@ namespace starlight { UIContainer(); UIContainer(VRect rect) { this->rect = rect; } - ~UIContainer(); + //~UIContainer(); void Dive(std::function check, std::function func, bool consumable = true, bool frontFirst = true); void Dive(std::function func, bool consumable = true, bool frontFirst = true); diff --git a/libstarlight/source/starlight/ui/UIElement.cpp b/libstarlight/source/starlight/ui/UIElement.cpp index 6cbec72..573541e 100644 --- a/libstarlight/source/starlight/ui/UIElement.cpp +++ b/libstarlight/source/starlight/ui/UIElement.cpp @@ -6,7 +6,7 @@ using starlight::ui::UIElement; using starlight::ui::UIContainer; UIElement::UIElement() { } -UIElement::~UIElement() { } +//UIElement::~UIElement() { } void UIElement::_Dive(std::function& check, std::function& func, bool consumable, bool frontFirst, bool& finished) { if (!check(this)) return; @@ -43,4 +43,4 @@ VRect& UIElement::Resize(Vector2 size) { void UIElement::MarkForRedraw() { if (auto p = parent.lock()) p->MarkForRedraw(); -} \ No newline at end of file +} diff --git a/libstarlight/source/starlight/ui/UIElement.h b/libstarlight/source/starlight/ui/UIElement.h index 2e02c65..6d212a6 100644 --- a/libstarlight/source/starlight/ui/UIElement.h +++ b/libstarlight/source/starlight/ui/UIElement.h @@ -32,7 +32,7 @@ namespace starlight { inline VRect& Resize(float w, float h) { return Resize(Vector2(w, h)); } UIElement(); - virtual ~UIElement(); + virtual ~UIElement() = default; virtual void Update() { } virtual void PreDraw() { } diff --git a/libstarlight/todo.txt b/libstarlight/todo.txt index b668d3d..edf0635 100644 --- a/libstarlight/todo.txt +++ b/libstarlight/todo.txt @@ -3,16 +3,13 @@ roadmap to first release, in no particular order { finish implementing OSK! { - - fix cursor-down polish! { - - background actual cursor image? } InputManager::OpenKeyboard } - fix [ offset (-1 it) - add generic backdrop assets (and form) + - whee, fixed softlock/crash on exit, hopefully permanently! add license!! (MIT?) ADD README.MD PLS diff --git a/testbed/source/Core.cpp b/testbed/source/Core.cpp index 3f906dc..a6aa03e 100644 --- a/testbed/source/Core.cpp +++ b/testbed/source/Core.cpp @@ -18,6 +18,7 @@ #include "starlight/ui/TextBox.h" #include "starlight/ui/Label.h" +#include "starlight/dialog/Backdrop.h" #include "starlight/dialog/MessageBox.h" #include "starlight/dialog/OSK.h" @@ -81,6 +82,8 @@ void Core::Init() { tb->multiLine = true; form->touchScreen->Add(tb); + sl::dialog::Backdrop::New()->Open(); + /*label->SetFont("default.16"); btn.SetText("I was pressed!"); btn.eOnTap = [label](auto& btn){ diff --git a/themes/default/decorations/generic backdrop.png b/themes/default/decorations/generic backdrop.png new file mode 100644 index 0000000..ad9cafe Binary files /dev/null and b/themes/default/decorations/generic backdrop.png differ diff --git a/themes/default/decorations/generic backdrop.xcf b/themes/default/decorations/generic backdrop.xcf new file mode 100644 index 0000000..14ef8d7 Binary files /dev/null and b/themes/default/decorations/generic backdrop.xcf differ