AppView 0.8.2
app_view.hpp
Go to the documentation of this file.
1// Copyright 2008-2024 by Rightware. All rights reserved.
2
3#ifndef APP_VIEW_HPP
4#define APP_VIEW_HPP
5
6#include <kanzi/core.ui/message/message_arguments.hpp>
7#include <kanzi/core/metadata/metaclass.hpp>
8
9#include <app_view_controller.hpp>
10
11namespace kanzi
12{
13
14// Forward declarations.
15class Matrix4x4;
16class Node2D;
17class Vector2;
18struct TouchPoint;
19
20namespace plugin
21{
22
23namespace appview
24{
25
26class ForwardingManipulator;
27using ForwardingManipulatorSharedPtr = shared_ptr<ForwardingManipulator>;
28
29class APP_VIEW_PLUGIN_API AppViewConcept
30{
31public:
34 static PropertyType<string> AppNameProperty;
35 static PropertyType<string> VirtualDisplayNameProperty;
36 static PropertyType<int> VirtualDisplayWidthProperty;
37 static PropertyType<int> VirtualDisplayHeightProperty;
38 static PropertyType<int> VirtualDisplayDensityProperty;
39 static PropertyType<bool> CanExitAppProperty;
40 static PropertyType<ResourceSharedPtr> OverrideMaterialProperty;
42
45 static PropertyType<string> MessageArgumentAppNameProperty;
46 static PropertyType<bool> MessageArgumentCanExitAppProperty;
51
54 class StartAppMessageArguments : public MessageArguments
55 {
56 public:
58 StartAppMessageArguments, MessageArguments, "Kanzi.AppView.AppViewConcept.StartAppMessageArguments")
59 KZ_METACLASS_PROPERTY_TYPE(MessageArgumentAppNameProperty)
60 KZ_METACLASS_PROPERTY_TYPE(MessageArgumentCanExitAppProperty)
61 KZ_METACLASS_END()
62
63 static PropertyTypeEditorInfoSharedPtr makeEditorInfo()
64 {
65 return KZ_DECLARE_EDITOR_METADATA(
66 metadata.legacyName = "AppView.AppViewConcept.StartAppMessageArguments";);
67 }
68 };
69
70 class FinishAppMessageArguments : public MessageArguments
71 {
72 public:
73 KZ_MESSAGE_ARGUMENTS_METACLASS_BEGIN(
74 FinishAppMessageArguments, MessageArguments, "Kanzi.AppView.AppViewConcept.FinishAppMessageArguments")
75 KZ_METACLASS_END()
76 };
77
78 class NavigateBackMessageArguments : public MessageArguments
79 {
80 public:
82 NavigateBackMessageArguments, MessageArguments, "Kanzi.AppView.AppViewConcept.NavigateBackMessageArguments")
83 KZ_METACLASS_END()
84
85 static PropertyTypeEditorInfoSharedPtr makeEditorInfo()
86 {
87 return KZ_DECLARE_EDITOR_METADATA(
88 metadata.legacyName = "AppView.AppViewConcept.NavigateBackMessageArguments";);
89 }
90 };
91
92 class UpdateVirtualDisplayMessageArguments : public MessageArguments
93 {
94 public:
96 UpdateVirtualDisplayMessageArguments, MessageArguments, "Kanzi.AppView.AppViewConcept.UpdateVirtualDisplayMessageArguments")
97 KZ_METACLASS_PROPERTY_TYPE(MessageArgumentVirtualDisplayWidthProperty)
98 KZ_METACLASS_PROPERTY_TYPE(MessageArgumentVirtualDisplayHeightProperty)
99 KZ_METACLASS_PROPERTY_TYPE(MessageArgumentVirtualDisplayDensityProperty)
100 KZ_METACLASS_END()
101
102 static PropertyTypeEditorInfoSharedPtr makeEditorInfo()
103 {
104 return KZ_DECLARE_EDITOR_METADATA(
105 metadata.legacyName = "AppView.AppViewConcept.UpdateVirtualDisplayMessageArguments";);
106 }
107 };
109
112 static MessageType<StartAppMessageArguments> StartAppMessage;
113 static MessageType<FinishAppMessageArguments> FinishAppMessage;
114 static MessageType<NavigateBackMessageArguments> NavigateBackMessage;
115 static MessageType<UpdateVirtualDisplayMessageArguments> UpdateVirtualDisplayMessage;
116 static MessageType<MessageArguments> PauseAppMessage;
117 static MessageType<MessageArguments> ResumeAppMessage;
119
120 KZ_MIXIN_METACLASS_BEGIN(AppViewConcept, "Kanzi.AppView.AppViewConcept")
121 KZ_METACLASS_PROPERTY_TYPE(AppNameProperty)
122 KZ_METACLASS_PROPERTY_TYPE(VirtualDisplayNameProperty)
123 KZ_METACLASS_PROPERTY_TYPE(VirtualDisplayWidthProperty)
124 KZ_METACLASS_PROPERTY_TYPE(VirtualDisplayHeightProperty)
125 KZ_METACLASS_PROPERTY_TYPE(VirtualDisplayDensityProperty)
126 KZ_METACLASS_PROPERTY_TYPE(CanExitAppProperty)
127 KZ_METACLASS_PROPERTY_TYPE(OverrideMaterialProperty)
128
129 KZ_METACLASS_MESSAGE_TYPE(StartAppMessage)
130 KZ_METACLASS_MESSAGE_TYPE(FinishAppMessage)
131 KZ_METACLASS_MESSAGE_TYPE(NavigateBackMessage)
132 KZ_METACLASS_MESSAGE_TYPE(UpdateVirtualDisplayMessage)
133 KZ_METACLASS_MESSAGE_TYPE(PauseAppMessage)
134 KZ_METACLASS_MESSAGE_TYPE(ResumeAppMessage)
135 KZ_METACLASS_END()
136
137 static PropertyTypeEditorInfoSharedPtr makeEditorInfo();
138};
139
140template <typename TBaseClass, typename TDerivedClass>
141class APP_VIEW_PLUGIN_API AppViewConceptImpl : public TBaseClass, public AppViewConcept
142{
143public:
144 KZ_TEMPLATE_METACLASS_BEGIN(AppViewConceptImpl, TBaseClass)
145 KZ_METACLASS_MIXIN(AppViewConcept)
146 KZ_METACLASS_END()
147
148 static PropertyTypeEditorInfoSharedPtr makeEditorInfo();
149
150protected:
151 explicit AppViewConceptImpl(Domain* domain, string_view name);
152
153 void initialize();
154
155 void onAttached() override;
156 void onDetached() override;
157
159 void onFrameAvailable();
160
161 TextureSharedPtr getAppViewTexture();
162 MaterialSharedPtr getAppViewMaterial();
163
164 virtual void setupMaterialOverride() = 0;
165 virtual bool calculateHitUV(
166 const TouchPoint& touchPoint,
167 Vector2& outHitUV) = 0;
169 virtual void onAppViewTextureChanged() = 0;
170
172 void onNodePropertyChanged(AbstractPropertyType propertyType, PropertyNotificationReason reason) override;
173
174 void handleStartAppMessage(const StartAppMessageArguments& messageArguments);
175 void handleFinishAppMessage(FinishAppMessageArguments& messageArguments);
176 void handleNavigateBackMessage(const NavigateBackMessageArguments& messageArguments);
177 void handleUpdateVirtualDisplayMessage(const UpdateVirtualDisplayMessageArguments& messageArguments);
178
179private:
180 AppViewControllerSharedPtr m_appViewController;
181 ForwardingManipulatorSharedPtr m_forwardingManipulator;
182
183 TDerivedClass* getThisObject()
184 {
185 return static_cast<TDerivedClass*>(this);
186 }
187
188 const TDerivedClass* getThisObject() const
189 {
190 return static_cast<const TDerivedClass*>(this);
191 }
192
193 void setupInputHandling();
194 void setupController();
195 void resetController();
196 void setupMaterial();
197 void startApp(const string& appName, bool canExitApp);
198 void finishApp();
199
200 Vector2 getVirtualDisplaySize() const;
201
203 Matrix4x4 m_stMatrix;
204 int m_textureId = 0;
205};
206
207}
208
209}
210
211}
212
213#endif
Definition app_view.hpp:12
shared_ptr< ForwardingManipulator > ForwardingManipulatorSharedPtr
Definition app_view.hpp:27
Definition app_view.hpp:30
static PropertyType< int > MessageArgumentVirtualDisplayDensityProperty
Definition app_view.hpp:49
static PropertyType< bool > CanExitAppProperty
Definition app_view.hpp:39
static PropertyType< int > VirtualDisplayDensityProperty
Definition app_view.hpp:38
static PropertyType< string > AppNameProperty
Definition app_view.hpp:34
static PropertyType< bool > MessageArgumentCanExitAppProperty
Definition app_view.hpp:46
static MessageType< MessageArguments > ResumeAppMessage
Definition app_view.hpp:117
static MessageType< FinishAppMessageArguments > FinishAppMessage
Definition app_view.hpp:113
static PropertyType< int > MessageArgumentVirtualDisplayHeightProperty
Definition app_view.hpp:48
static MessageType< MessageArguments > PauseAppMessage
Definition app_view.hpp:116
static PropertyType< string > MessageArgumentAppNameProperty
Definition app_view.hpp:45
static PropertyType< ResourceSharedPtr > OverrideMaterialProperty
Definition app_view.hpp:40
static PropertyType< int > VirtualDisplayWidthProperty
Definition app_view.hpp:36
static PropertyType< int > MessageArgumentVirtualDisplayWidthProperty
Definition app_view.hpp:47
static MessageType< NavigateBackMessageArguments > NavigateBackMessage
Definition app_view.hpp:114
static PropertyType< int > VirtualDisplayHeightProperty
Definition app_view.hpp:37
static MessageType< StartAppMessageArguments > StartAppMessage
Definition app_view.hpp:112
static PropertyType< string > VirtualDisplayNameProperty
Definition app_view.hpp:35
static MessageType< UpdateVirtualDisplayMessageArguments > UpdateVirtualDisplayMessage
Definition app_view.hpp:115
KZ_MESSAGE_ARGUMENTS_METACLASS_BEGIN(StartAppMessageArguments, MessageArguments, "Kanzi.AppView.AppViewConcept.StartAppMessageArguments") static PropertyTypeEditorInfoSharedPtr makeEditorInfo()
Definition app_view.hpp:57
KZ_MESSAGE_ARGUMENTS_METACLASS_BEGIN(NavigateBackMessageArguments, MessageArguments, "Kanzi.AppView.AppViewConcept.NavigateBackMessageArguments") static PropertyTypeEditorInfoSharedPtr makeEditorInfo()
Definition app_view.hpp:81
KZ_MESSAGE_ARGUMENTS_METACLASS_BEGIN(UpdateVirtualDisplayMessageArguments, MessageArguments, "Kanzi.AppView.AppViewConcept.UpdateVirtualDisplayMessageArguments") static PropertyTypeEditorInfoSharedPtr makeEditorInfo()
Definition app_view.hpp:95