mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-06-17 22:12:43 -04:00
8280ac00a0
Co-authored-by: MelonSpeedruns <melonspeedruns@stratobox.net>
58 lines
1.4 KiB
C++
58 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include "component.hpp"
|
|
#include "ui.hpp"
|
|
|
|
namespace dusk::ui {
|
|
|
|
class Document {
|
|
public:
|
|
Document(const Rml::String& source);
|
|
virtual ~Document();
|
|
|
|
Document(const Document&) = delete;
|
|
Document& operator=(const Document&) = delete;
|
|
|
|
virtual void show();
|
|
virtual void hide(bool close);
|
|
virtual void update();
|
|
virtual bool focus();
|
|
virtual bool visible() const;
|
|
|
|
void listen(Rml::Element* element, Rml::EventId event, ScopedEventListener::Callback callback,
|
|
bool capture = false);
|
|
void listen(Rml::EventId event, ScopedEventListener::Callback callback, bool capture = false) {
|
|
listen(mDocument, event, std::move(callback), capture);
|
|
}
|
|
void toggle() {
|
|
if (visible()) {
|
|
hide(false);
|
|
} else {
|
|
show();
|
|
}
|
|
}
|
|
void push(std::unique_ptr<Document> document) {
|
|
push_document(std::move(document));
|
|
hide(false);
|
|
}
|
|
void pop() {
|
|
hide(true);
|
|
show_top_document();
|
|
}
|
|
|
|
bool pending_close() const { return mPendingClose; }
|
|
bool closed() const { return mClosed; }
|
|
|
|
void toggle_cursor_if_gyro(bool);
|
|
|
|
protected:
|
|
virtual bool handle_nav_command(Rml::Event& event, NavCommand cmd);
|
|
|
|
Rml::ElementDocument* mDocument;
|
|
std::vector<std::unique_ptr<ScopedEventListener> > mListeners;
|
|
bool mPendingClose = false;
|
|
bool mClosed = false;
|
|
};
|
|
|
|
} // namespace dusk::ui
|