mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-06-19 06:27:02 -04:00
ad53af5c78
* WIP touch controls * Action icons * Updates * Don't mutate freeCamera config; allow switching between touch and controller cam * Wow * Fix build & add Skip button * Fix build & add settings * RCSS cleanup * Dpad and fishing, might redo * Add menu mouse controls * More pointer & fix icons * Optimizations & introduce layout system * Update aurora * Implement touch controls layout editor * Cleanup & fixes * Allow disabling mouse/touch in menus * More fixes
65 lines
1.8 KiB
C++
65 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include "component.hpp"
|
|
#include "ui.hpp"
|
|
|
|
namespace dusk::ui {
|
|
|
|
class Document {
|
|
public:
|
|
explicit Document(const Rml::String& source, bool passive = false);
|
|
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::Element* element, const Rml::String& 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 listen(
|
|
const Rml::String& 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; }
|
|
|
|
bool handle_nav_event(Rml::Event& event);
|
|
|
|
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;
|
|
bool mPassive = false;
|
|
};
|
|
|
|
} // namespace dusk::ui
|