#pragma once #include "typedefs.hpp" #include #include #include #include "io/fwd.hpp" namespace gui { class GUI; class UINode; } struct UiDocScript { bool onopen : 1; bool onprogress : 1; bool onclose : 1; bool ondestroy : 1; }; using UINodesMap = std::unordered_map>; class UiDocument { std::string id; UiDocScript script; UINodesMap map; std::shared_ptr root; scriptenv env; public: UiDocument( std::string id, UiDocScript script, const std::shared_ptr &root, scriptenv env ); ~UiDocument(); void rebuildIndices(); void pushIndices(const std::shared_ptr& node); const std::string& getId() const; const UINodesMap& getMap() const; std::shared_ptr getRoot() const; std::shared_ptr get(const std::string& id) const; const UiDocScript& getScript() const; scriptenv getEnvironment() const; static std::unique_ptr read( gui::GUI&, const scriptenv& parent_env, const std::string& name, const io::path& file, const std::string& fileName, scriptenv&& env = nullptr ); };