12 #ifndef hifi_OffscreenQmlElement_h
13 #define hifi_OffscreenQmlElement_h
17 #include <PathUtils.h>
21 #define HIFI_QML_DECL \
23 static const QString NAME; \
24 static const QUrl QML; \
25 static bool registered; \
27 static void registerType(); \
28 static void show(std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {}); \
30 static void toggle(std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {}); \
31 static void load(std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {}); \
34 #define HIFI_QML_DECL_LAMBDA \
36 static const QString NAME; \
37 static const QUrl QML; \
39 static void registerType(); \
42 static void toggle(); \
46 #define HIFI_QML_DEF(x) \
47 const QUrl x::QML = PathUtils::qmlUrl(#x ".qml"); \
48 const QString x::NAME = #x; \
49 bool x::registered = false; \
51 void x::registerType() { \
52 qmlRegisterType<x>("Hifi", 1, 0, NAME.toLocal8Bit().constData()); \
55 void x::show(std::function<void(QQmlContext*, QObject*)> f) { \
56 auto offscreenUI = DependencyManager::get<OffscreenUi>(); \
61 offscreenUI->show(QML, NAME, f); \
66 if (auto offscreenUI = DependencyManager::get<OffscreenUi>()) { \
67 offscreenUI->hide(NAME); \
71 void x::toggle(std::function<void(QQmlContext*, QObject*)> f) { \
72 if (auto offscreenUI = DependencyManager::get<OffscreenUi>()) { \
73 offscreenUI->toggle(QML, NAME, f); \
76 void x::load(std::function<void(QQmlContext*, QObject*)> f) { \
77 if (auto offscreenUI = DependencyManager::get<OffscreenUi>()) { \
78 offscreenUI->load(QML, f); \
82 #define HIFI_QML_DEF_LAMBDA(x, f) \
83 const QUrl x::QML = QUrl(#x ".qml"); \
84 const QString x::NAME = #x; \
86 void x::registerType() { \
87 qmlRegisterType<x>("Hifi", 1, 0, NAME.toLocal8Bit().constData()); \
90 if (auto offscreenUI = DependencyManager::get<OffscreenUi>()) { \
91 offscreenUI->show(QML, NAME, f); \
95 if (auto offscreenUI = DependencyManager::get<OffscreenUi>()) { \
96 offscreenUI->hide(NAME); \
101 if (auto offscreenUI = DependencyManager::get<OffscreenUi>()) { \
102 offscreenUI->toggle(QML, NAME, f); \
106 if (auto offscreenUI = DependencyManager::get<OffscreenUi>()) { \
107 offscreenUI->load(QML, f); \