mirror of
https://github.com/zetaPRIME/libstarlight.git
synced 2025-06-26 13:42:46 +00:00
Backdrop, fix crash-on-exit(!)
This commit is contained in:
parent
fd44ee0f90
commit
c969d48e6b
@ -82,8 +82,15 @@ void Application::_init() {
|
|||||||
void Application::_end() {
|
void Application::_end() {
|
||||||
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
|
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();
|
ThemeManager::End();
|
||||||
RenderCore::Close();
|
RenderCore::Close();
|
||||||
ConfigManager::End();
|
ConfigManager::End();
|
||||||
|
17
libstarlight/source/starlight/dialog/Backdrop.cpp
Normal file
17
libstarlight/source/starlight/dialog/Backdrop.cpp
Normal 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);
|
||||||
|
}
|
21
libstarlight/source/starlight/dialog/Backdrop.h
Normal file
21
libstarlight/source/starlight/dialog/Backdrop.h
Normal 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 { };
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -121,6 +121,7 @@ OSK::OSK(osk::InputHandler* handler) : Form(true), handler(handler) {
|
|||||||
void OSK::Update(bool focused) {
|
void OSK::Update(bool focused) {
|
||||||
if (handler->done) {
|
if (handler->done) {
|
||||||
Close();
|
Close();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (focused) {
|
if (focused) {
|
||||||
if (InputManager::Pressed(Keys::B)) handler->Done();
|
if (InputManager::Pressed(Keys::B)) handler->Done();
|
||||||
|
@ -25,7 +25,7 @@ namespace starlight {
|
|||||||
std::unique_ptr<osk::InputHandler> handler;
|
std::unique_ptr<osk::InputHandler> handler;
|
||||||
|
|
||||||
OSK(osk::InputHandler* handler);
|
OSK(osk::InputHandler* handler);
|
||||||
~OSK() override { };
|
//~OSK() override { };
|
||||||
|
|
||||||
void Update(bool focused) override;
|
void Update(bool focused) override;
|
||||||
|
|
||||||
|
@ -62,6 +62,7 @@ void Form::Open(bool showImmediately) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Form::Close() {
|
void Form::Close() {
|
||||||
|
volatile auto keepalive = shared_from_this(); // don't allow delete until Close() goes out of scope
|
||||||
auto app = Application::Current();
|
auto app = Application::Current();
|
||||||
if (app == nullptr) return;
|
if (app == nullptr) return;
|
||||||
app->forms.remove(shared_from_this());
|
app->forms.remove(shared_from_this());
|
||||||
|
@ -66,7 +66,7 @@ namespace starlight {
|
|||||||
|
|
||||||
Form() { }
|
Form() { }
|
||||||
Form(bool useDefaults);
|
Form(bool useDefaults);
|
||||||
virtual ~Form() { }
|
virtual ~Form() = default;
|
||||||
|
|
||||||
void Open(bool showImmediately = true);
|
void Open(bool showImmediately = true);
|
||||||
void Close();
|
void Close();
|
||||||
|
@ -19,7 +19,7 @@ namespace starlight {
|
|||||||
bool needsRedraw = true;
|
bool needsRedraw = true;
|
||||||
|
|
||||||
UICanvas(VRect rect);
|
UICanvas(VRect rect);
|
||||||
~UICanvas() { }
|
//~UICanvas() { }
|
||||||
|
|
||||||
void MarkForRedraw() override;
|
void MarkForRedraw() override;
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ using starlight::ui::UIElement;
|
|||||||
using starlight::ui::UIContainer;
|
using starlight::ui::UIContainer;
|
||||||
|
|
||||||
UIContainer::UIContainer() { }
|
UIContainer::UIContainer() { }
|
||||||
UIContainer::~UIContainer() { }
|
|
||||||
|
|
||||||
void UIContainer::Dive(std::function<bool(UIElement*)> check, std::function<bool(UIElement*)> func, bool consumable, bool frontFirst) {
|
void UIContainer::Dive(std::function<bool(UIElement*)> check, std::function<bool(UIElement*)> func, bool consumable, bool frontFirst) {
|
||||||
bool finished = false;
|
bool finished = false;
|
||||||
|
@ -29,7 +29,7 @@ namespace starlight {
|
|||||||
|
|
||||||
UIContainer();
|
UIContainer();
|
||||||
UIContainer(VRect rect) { this->rect = rect; }
|
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*)> 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);
|
void Dive(std::function<bool(UIElement*)> func, bool consumable = true, bool frontFirst = true);
|
||||||
|
@ -6,7 +6,7 @@ using starlight::ui::UIElement;
|
|||||||
using starlight::ui::UIContainer;
|
using starlight::ui::UIContainer;
|
||||||
|
|
||||||
UIElement::UIElement() { }
|
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) {
|
void UIElement::_Dive(std::function<bool(UIElement*)>& check, std::function<bool(UIElement*)>& func, bool consumable, bool frontFirst, bool& finished) {
|
||||||
if (!check(this)) return;
|
if (!check(this)) return;
|
||||||
|
@ -32,7 +32,7 @@ namespace starlight {
|
|||||||
inline VRect& Resize(float w, float h) { return Resize(Vector2(w, h)); }
|
inline VRect& Resize(float w, float h) { return Resize(Vector2(w, h)); }
|
||||||
|
|
||||||
UIElement();
|
UIElement();
|
||||||
virtual ~UIElement();
|
virtual ~UIElement() = default;
|
||||||
|
|
||||||
virtual void Update() { }
|
virtual void Update() { }
|
||||||
virtual void PreDraw() { }
|
virtual void PreDraw() { }
|
||||||
|
@ -3,16 +3,13 @@
|
|||||||
|
|
||||||
roadmap to first release, in no particular order {
|
roadmap to first release, in no particular order {
|
||||||
finish implementing OSK! {
|
finish implementing OSK! {
|
||||||
- fix cursor-down
|
|
||||||
polish! {
|
polish! {
|
||||||
- background
|
|
||||||
actual cursor image?
|
actual cursor image?
|
||||||
}
|
}
|
||||||
InputManager::OpenKeyboard
|
InputManager::OpenKeyboard
|
||||||
}
|
}
|
||||||
fix [ offset (-1 it)
|
|
||||||
|
|
||||||
add generic backdrop assets (and form)
|
- whee, fixed softlock/crash on exit, hopefully permanently!
|
||||||
|
|
||||||
add license!! (MIT?)
|
add license!! (MIT?)
|
||||||
ADD README.MD PLS
|
ADD README.MD PLS
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "starlight/ui/TextBox.h"
|
#include "starlight/ui/TextBox.h"
|
||||||
#include "starlight/ui/Label.h"
|
#include "starlight/ui/Label.h"
|
||||||
|
|
||||||
|
#include "starlight/dialog/Backdrop.h"
|
||||||
#include "starlight/dialog/MessageBox.h"
|
#include "starlight/dialog/MessageBox.h"
|
||||||
#include "starlight/dialog/OSK.h"
|
#include "starlight/dialog/OSK.h"
|
||||||
|
|
||||||
@ -81,6 +82,8 @@ void Core::Init() {
|
|||||||
tb->multiLine = true;
|
tb->multiLine = true;
|
||||||
form->touchScreen->Add(tb);
|
form->touchScreen->Add(tb);
|
||||||
|
|
||||||
|
sl::dialog::Backdrop::New()->Open();
|
||||||
|
|
||||||
/*label->SetFont("default.16");
|
/*label->SetFont("default.16");
|
||||||
btn.SetText("I was pressed!");
|
btn.SetText("I was pressed!");
|
||||||
btn.eOnTap = [label](auto& btn){
|
btn.eOnTap = [label](auto& btn){
|
||||||
|
BIN
themes/default/decorations/generic backdrop.png
Normal file
BIN
themes/default/decorations/generic backdrop.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.1 KiB |
BIN
themes/default/decorations/generic backdrop.xcf
Normal file
BIN
themes/default/decorations/generic backdrop.xcf
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user