Backdrop, fix crash-on-exit(!)

This commit is contained in:
zetaPRIME 2017-03-16 22:06:42 -04:00
parent fd44ee0f90
commit c969d48e6b
16 changed files with 58 additions and 12 deletions

View File

@ -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();

View File

@ -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<Image>(VRect(0, 0, 400, 480), imgPath);
topScreen->Add(img);
touchScreen->Add(img);
touchScreen->scrollOffset = Vector2(40, 240);
}

View File

@ -0,0 +1,21 @@
#pragma once
#include "starlight/_global.h"
#include <string>
#include "starlight/ThemeManager.h"
#include "starlight/ui/Form.h"
namespace starlight {
namespace dialog {
class Backdrop : public ui::Form, public ui::FormCreator<Backdrop> {
private:
//
public:
Backdrop(std::string imgPath = "decorations/generic backdrop");
//~Backdrop() override { };
};
}
}

View File

@ -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();

View File

@ -25,7 +25,7 @@ namespace starlight {
std::unique_ptr<osk::InputHandler> handler;
OSK(osk::InputHandler* handler);
~OSK() override { };
//~OSK() override { };
void Update(bool focused) override;

View File

@ -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());

View File

@ -66,7 +66,7 @@ namespace starlight {
Form() { }
Form(bool useDefaults);
virtual ~Form() { }
virtual ~Form() = default;
void Open(bool showImmediately = true);
void Close();

View File

@ -19,7 +19,7 @@ namespace starlight {
bool needsRedraw = true;
UICanvas(VRect rect);
~UICanvas() { }
//~UICanvas() { }
void MarkForRedraw() override;

View File

@ -10,7 +10,6 @@ using starlight::ui::UIElement;
using starlight::ui::UIContainer;
UIContainer::UIContainer() { }
UIContainer::~UIContainer() { }
void UIContainer::Dive(std::function<bool(UIElement*)> check, std::function<bool(UIElement*)> func, bool consumable, bool frontFirst) {
bool finished = false;

View File

@ -29,7 +29,7 @@ namespace starlight {
UIContainer();
UIContainer(VRect rect) { this->rect = rect; }
~UIContainer();
//~UIContainer();
void Dive(std::function<bool(UIElement*)> check, std::function<bool(UIElement*)> func, bool consumable = true, bool frontFirst = true);
void Dive(std::function<bool(UIElement*)> func, bool consumable = true, bool frontFirst = true);

View File

@ -6,7 +6,7 @@ using starlight::ui::UIElement;
using starlight::ui::UIContainer;
UIElement::UIElement() { }
UIElement::~UIElement() { }
//UIElement::~UIElement() { }
void UIElement::_Dive(std::function<bool(UIElement*)>& check, std::function<bool(UIElement*)>& 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();
}
}

View File

@ -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() { }

View File

@ -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

View File

@ -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){

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.