1.9.9.2
Gameface
View.h
1 /*
2 This file is part of Cohtml, Gameface and Prysm - modern user interface technologies.
3 
4 Copyright (c) 2012-2018 Coherent Labs AD and/or its licensors. All
5 rights reserved in all media.
6 
7 The coded instructions, statements, computer programs, and/or related
8 material (collectively the "Data") in these files contain confidential
9 and unpublished information proprietary Coherent Labs and/or its
10 licensors, which is protected by United States of America federal
11 copyright law and by international treaties.
12 
13 This software or source code is supplied under the terms of a license
14 agreement and nondisclosure agreement with Coherent Labs AD and may
15 not be copied, disclosed, or exploited except in accordance with the
16 terms of that agreement. The Data may not be disclosed or distributed to
17 third parties, in whole or in part, without the prior written consent of
18 Coherent Labs AD.
19 
20 COHERENT LABS MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS
21 SOURCE CODE FOR ANY PURPOSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
22 HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
23 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE
25 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER, ITS AFFILIATES,
26 PARENT COMPANIES, LICENSORS, SUPPLIERS, OR CONTRIBUTORS BE LIABLE FOR
27 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 ANY WAY OUT OF THE USE OR PERFORMANCE OF THIS SOFTWARE OR SOURCE CODE,
33 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35 #pragma once
36 
37 #include <cohtml/Declarations.h>
38 #include <cohtml/ResourceHandler.h>
39 #include <cohtml/CursorTypes.h>
40 #include <cohtml/Binding/Binding.h>
41 #include <cohtml/Socket.h>
42 
43 #if !defined(COHTML_TRIGGER_EVENT_SCOPE)
44 #define COHTML_TRIGGER_EVENT_SCOPE(CompileTimeArgsCount, RuntimeEventName)
45 #endif
46 
47 namespace cohtml
48 {
49 class Binder;
50 class IViewListener;
51 struct TouchEventData;
52 struct MouseEventData;
53 struct KeyEventData;
54 struct GestureEventData;
55 class IEventHandler;
56 class INodeProxy;
58 typedef void* BoundEventHandle;
59 
60 template <typename T>
61 void CoherentCreateModelBindPointer(Binder* binder, T* model)
62 {
63  binder->BeginType();
64  CoherentBind(binder, model);
65  binder->EndType(model);
66 }
67 
68 #if defined(IW_SDK)
69 template <typename T>
70 void CoherentGenericBind(Binder* b, const void* arg)
71 {
72  CoherentBindInternal(b, *(const T*)arg);
73 }
74 typedef void(*CoherentGenericBindFuncPtr)(Binder*, const void*);
75 #endif
76 }
77 
78 namespace renoir
79 {
80 class ISubLayerCompositor;
81 class ICustomEffectRenderer;
82 }
83 
84 #if defined(IW_SDK)
85 extern "C"
86 {
87 void HummingbirdTriggerEventOnOSThread(void* binder, const char* name, int numArgs,
88  void* functions, const void** args);
89 }
90 #endif
91 
92 namespace cohtml
93 {
94 
96 {
99 };
100 
101 typedef void (*OnRenderingTasksAvailableFunc)(void* userData, unsigned viewId, unsigned frameId, RenderingTasksAvailableType type);
102 typedef double (*OnMonotonicallyIncreasingTimeRequestFunc)(void* userdata, unsigned viewId);
103 
106 {
109 
111  unsigned Width;
112 
114  unsigned Height;
115 
119 
123 
125  void* UserData;
126 
135 
141 
145 
149 
154 
156  unsigned DoubleClickTime;
157 
161 
164 
169 
172 
174  const void* DeveloperOptions;
175 
177  : Listener(nullptr)
178  , Width(1280u)
179  , Height(720u)
180  , OnRenderingTasksAvailable(nullptr)
182  , UserData(nullptr)
188  , DoubleClickTime(200)
189  , TextInputHandler(nullptr)
190  , StartPanThreshold(8)
193  , DeveloperOptions(nullptr)
194  {}
195 };
196 
197 
198 namespace InputEventPhase
199 {
202  {
204  NONE = 0,
205 
208 
211 
214  };
215 }
216 
218 namespace EventAction
219 {
221  enum Actions
222  {
225 
229  };
230 };
231 
232 
233 namespace TextInputControlType
234 {
237  {
240 
243  };
244 };
245 
246 namespace TextInput
247 {
250  {
257  };
258 
260  struct Range
261  {
263  unsigned Start;
265  unsigned End;
266  };
267 
269  struct Selection
270  {
275  };
276 
277  struct Rectangle
278  {
280  float X;
282  float Y;
284  float Width;
286  float Height;
287  };
288 };
289 
292 {
294  unsigned Width;
295 
297  unsigned Height;
298 
300  unsigned AvailableWidth;
301 
303  unsigned AvailableHeight;
304 
306  unsigned ColorDepth;
307 
309  unsigned PixelDepth;
310 
312  : Width(0)
313  , Height(0)
314  , AvailableWidth(0)
315  , AvailableHeight(0)
316  , ColorDepth(0)
317  , PixelDepth(0)
318  {}
319 };
320 
321 // Reflects the status based on which cohtml should handle a concrete resource request
323 {
326 };
327 
329 class COHTML_API IViewListener
330 {
331 public:
332  IViewListener();
333  virtual ~IViewListener();
334 
339  virtual bool OnNavigateTo(const char* url)
340  {
341  UNUSED_PARAM(url);
342  return true;
343  }
344 
351  {
352  UNUSED_PARAM(url);
353  return InterceptRequestStatus::Allow;
354  }
355 
359  virtual void OnScriptContextCreated()
360  {}
361 
364  virtual void OnDOMBuilt()
365  {}
366 
370  virtual void OnLoadFailed(const char* url, const char* error)
371  {
372  UNUSED_PARAM(url);
373  UNUSED_PARAM(error);
374  }
375 
379  virtual void OnFinishLoad(const char* url)
380  {
381  UNUSED_PARAM(url);
382  }
383 
385  virtual void OnReadyForBindings()
386  {}
387 
391  virtual void OnBindingsReleased()
392  {}
393 
397  {
398  cohtml::ScreenInfo info;
399  info.AvailableWidth = 1920u;
400  info.AvailableHeight = 1080u;
401  info.ColorDepth = 24;
402  info.PixelDepth = 24;
403  info.Width = 1920u;
404  info.Height = 1080u;
405  return info;
406  }
407 
414  const TouchEventData* event,
415  void* userData,
416  const InputEventPhase::PhaseType phase)
417  {
418  UNUSED_PARAM(node);
419  UNUSED_PARAM(event);
420  UNUSED_PARAM(userData);
421  UNUSED_PARAM(phase);
423  }
424 
431  const MouseEventData* event,
432  void* userData,
433  const InputEventPhase::PhaseType phase)
434  {
435  UNUSED_PARAM(node);
436  UNUSED_PARAM(event);
437  UNUSED_PARAM(userData);
438  UNUSED_PARAM(phase);
440  }
441 
448  const KeyEventData* event,
449  void* userData,
450  const InputEventPhase::PhaseType phase)
451  {
452  UNUSED_PARAM(node);
453  UNUSED_PARAM(event);
454  UNUSED_PARAM(userData);
455  UNUSED_PARAM(phase);
457  }
458 
464  virtual void OnAudioStreamCreated(int id, int bitDepth, int channels,
465  float samplingRate)
466  {
467  UNUSED_PARAM(id);
468  UNUSED_PARAM(bitDepth);
469  UNUSED_PARAM(channels);
470  UNUSED_PARAM(samplingRate);
471  }
472 
475  virtual void OnAudioStreamClosed(int id)
476  {
477  UNUSED_PARAM(id);
478  }
479 
482  virtual void OnAudioStreamPlay(int id)
483  {
484  UNUSED_PARAM(id);
485  }
486 
489  virtual void OnAudioStreamPause(int id)
490  {
491  UNUSED_PARAM(id);
492  }
493 
500  virtual void OnAudioDataReceived(int id, int samples, float** pcm,
501  int channels)
502  {
503  UNUSED_PARAM(id);
504  UNUSED_PARAM(samples);
505  UNUSED_PARAM(pcm);
506  UNUSED_PARAM(channels);
507  }
508 
511  virtual void OnAudioStreamEnded(int id)
512  {
513  UNUSED_PARAM(id);
514  }
515 
519  virtual void OnAudioStreamVolumeChanged(int id, float volume)
520  {
521  UNUSED_PARAM(id);
522  UNUSED_PARAM(volume);
523  }
524 
529  {
530  UNUSED_PARAM(type);
531  }
532 
540  virtual void OnCaretRectChanged(int x,
541  int y,
542  unsigned width,
543  unsigned height)
544  {
545  UNUSED_PARAM(x);
546  UNUSED_PARAM(y);
547  UNUSED_PARAM(width);
548  UNUSED_PARAM(height);
549  }
550 
554  {}
555 
562  virtual void OnCursorChanged(CursorTypes::Cursors cursor, const char* url, const float* xHotspot, const float* yHotspot)
563  {
564  UNUSED_PARAM(cursor);
565  UNUSED_PARAM(url);
566  UNUSED_PARAM(xHotspot);
567  UNUSED_PARAM(yHotspot);
568  }
569 
574  virtual void OnClipboardTextSet(const char* text, unsigned lengthBytes)
575  {
576  UNUSED_PARAM(text);
577  UNUSED_PARAM(lengthBytes);
578  }
579 
583  {
587  virtual void Set(const char* text, unsigned lengthBytes) = 0;
588 
589  virtual ~IClipboardData() {}
590  };
591 
597  virtual void OnClipboardTextGet(IClipboardData* setDataObject)
598  {
599  UNUSED_PARAM(setDataObject);
600  }
601 
613  virtual IClientSideSocket* OnCreateWebSocket(ISocketListener * listener, const char* url, const char**protocols, unsigned protocolsCount)
614  {
615  UNUSED_PARAM(listener);
616  UNUSED_PARAM(url);
617  UNUSED_PARAM(protocols);
618  UNUSED_PARAM(protocolsCount);
619  return nullptr;
620  }
621 };
622 
624 struct DebugDump
625 {
627  {
628  DF_None = 0,
631  };
632 
633  const char* Dump;
634  virtual void Release() = 0;
635  virtual ~DebugDump();
636 };
637 
642 {
644  const char* Data;
645 
647  unsigned long long Size;
648 
650  virtual void Release() = 0;
651  virtual ~FrameCapture();
652 };
653 
658 {
660  virtual const char* Next() = 0;
661 
663  virtual void ResetIterator() = 0;
664 
666  virtual void Release() = 0;
667  virtual ~ImagesList();
668 };
669 
672 namespace ImagesListExtract
673 {
675  enum Options
676  {
678  Images = 0,
680  Hidden = 1 << 0,
683  Styles = 1 << 1
684  };
685 }
686 
690 typedef void(*FrameCaptureCallback)(void* userData, FrameCapture* capture);
691 
693 {
696  ICACHE_Shadows = 1 << 0,
699  ICACHE_Paths = 1 << 1,
702  ICACHE_Textures = 1 << 2,
706 };
707 
711 class View
712 {
713 public:
714  virtual ~View();
715 
717  virtual void Destroy() = 0;
718 
722  virtual void LoadURL(const char* url) = 0;
723 
725  virtual void Reload() = 0;
726 
730  virtual void UnloadDocument() = 0;
731 
734  virtual void ClearNavigationHistory() = 0;
735 
740  virtual unsigned Advance(TimePoint timeMilliseconds) = 0;
741 
743  virtual unsigned GetId() const = 0;
744 
746  virtual TaskFamilyId GetTaskFamilyId() const = 0;
747 
753  virtual void Resize(unsigned width, unsigned height) = 0;
754 
756  virtual unsigned GetWidth() const = 0;
757 
759  virtual unsigned GetHeight() const = 0;
760 
762  virtual void OnListenerLost() = 0;
763 
767  virtual void EnableRendering(bool value) = 0;
768 
772  virtual void ContinuousRepaint(bool enable) = 0;
773 
776  virtual void ShowPaintRectangles(bool show) = 0;
777 
780  virtual void ShowElementAABBs(bool show) = 0;
781 
792  virtual void EmitRenderingMetadata(bool emit) = 0;
793 
795  virtual DebugDump* DebugDumpDOMTree(unsigned flags) = 0;
796 
799 
805  virtual void TouchEvent(const cohtml::TouchEventData* events, unsigned count, bool* handled, void* userData) = 0;
806 
811  virtual void GestureEvent(const cohtml::GestureEventData& event, bool* handled, void* userData) = 0;
812 
817  virtual void MouseEvent(const cohtml::MouseEventData& event, bool* handled, void* userData) = 0;
818 
823  virtual void KeyEvent(const cohtml::KeyEventData& event, bool* handled, void* userData) = 0;
824 
830  virtual bool IMESetComposition(const char* composition,
831  unsigned targetStart,
832  unsigned targetEnd) = 0;
833 
837  virtual bool IMEConfirmComposition(const char* composition) = 0;
838 
841  virtual bool IMECancelComposition() = 0;
842 
844  virtual float GetStartPanThreshold() const = 0;
845 
848  virtual void SetStartPanThreshold(float value) = 0;
849 
852  virtual void SetUserAgent(const char* userAgent) = 0;
853 
861  virtual ImagesList* GetUsedImagesList(ImagesListExtract::Options options) const = 0;
862 
871  virtual void BeginCaptureDebugFrame(void* userData, FrameCaptureCallback callback) = 0;
872 
874  virtual void EndCaptureDebugFrame() = 0;
875 
885  virtual void CaptureSingleDebugFrame(void* userData, FrameCaptureCallback callback) = 0;
886 
893  virtual void GetCacheCountStats(InternalCaches cache, unsigned& filled, unsigned& capacity) = 0;
894 
901  virtual void GetCacheBytesStats(InternalCaches cache, unsigned& filled, unsigned& capacity) = 0;
902 
908  virtual void QueueSetCacheCountSize(InternalCaches cache, unsigned capacity) = 0;
909 
915  virtual void QueueSetCacheBytesSize(InternalCaches cache, unsigned capacity) = 0;
916 
920  virtual void QueueClearCaches(unsigned caches) = 0;
921 
927  virtual BoundEventHandle RegisterForEvent(const char* name,
928  IEventHandler* handler) = 0;
929 
934  virtual void UnregisterFromEvent(BoundEventHandle handle) = 0;
935 
941  virtual BoundEventHandle BindCall(const char* name, IEventHandler* handler)
942  = 0;
943 
948  virtual void UnbindCall(BoundEventHandle handle) = 0;
949 
954  virtual void UnbindObject(const void* object) = 0;
955 
959  template <typename T>
960  void ExposeAsGlobal(const char* name, T* object)
961  {
962  Binder* binder = GetBinder();
963  binder->BeginExposeObject();
964  CoherentBindInternal(binder, object);
965  binder->SetAsGlobal(name, object);
966  }
967 
970  template <typename T>
971  void DestroyExposedObject(T* object)
972  {
974  };
975 
979  virtual bool IsReadyForBindings() const = 0;
980 
985  virtual void ExecuteScript(const char* script) = 0;
986 
992  virtual void AddInitialScript(const char* script) = 0;
993 
995  virtual void ResetInitialScripts() = 0;
996 
1011  virtual void SetCustomSceneCompositor(renoir::ISubLayerCompositor* compositor, void* viewMetadata) = 0;
1012 
1028  virtual void SetSceneCustomEffectRenderer(renoir::ICustomEffectRenderer* renderer, void* customEffectRendererMetadata) = 0;
1029 
1031  virtual Binder* GetBinder() = 0;
1032 
1036 
1038 
1042  template <typename T>
1043  void CreateModel(const char* name, T* model)
1044  {
1045  typedef void(*CoherentInternalBindFunc)(cohtml::Binder*, T*);
1046  CoherentInternalBindFunc bindFuncPtr = &CoherentCreateModelBindPointer<T>;
1047  CoherentInternalBindGenericFunc bindGenericPtr = reinterpret_cast<CoherentInternalBindGenericFunc>(bindFuncPtr);
1048  RegisterModel(name, model, bindGenericPtr);
1049  }
1050 
1054  template<typename T>
1055  void UpdateWholeModel(T* model)
1056  {
1058  }
1059 
1062  virtual void SynchronizeModels() = 0;
1063 
1069  template<typename T>
1070  void RegisterModel(const char* name, T* model, CoherentInternalBindGenericFunc func)
1071  {
1073  }
1074 
1078  template<typename T>
1079  void UnregisterModel(T* model)
1080  {
1082  }
1083 
1084  public:
1085 
1089 
1093 
1098 
1101 
1105  virtual void DestroyExposedInstanceOfType(void* object, cohtml::TypeInfo* typeInfo) = 0;
1106 
1111  virtual void UpdateWholeModelOfType(void* model, cohtml::TypeInfo* typeInfo) = 0;
1112 
1117  virtual void UnregisterModelOfType(void* model, cohtml::TypeInfo* typeInfo) = 0;
1118 
1124  virtual void RegisterModelOfType(const char* name, void* model, cohtml::TypeInfo* typeInfo, CoherentInternalBindGenericFunc func) = 0;
1125 
1126  public:
1127 
1129 
1130 
1134 
1135 #if !defined(IW_SDK)
1136  virtual void TriggerEvent(const char* name) = 0;
1139 
1142  template <typename T1>
1143  void TriggerEvent(const char* name, const T1& argument1)
1144  {
1145  COHTML_TRIGGER_EVENT_SCOPE(TriggerEvent_1_Param, name);
1146  Binder* binder = GetBinder();
1147 
1148  if (binder)
1149  {
1150  binder->BeginEvent(name, 1);
1151 
1152  CoherentBindInternal(binder, argument1);
1153 
1154  binder->EndEvent();
1155  }
1156  }
1157 
1160  template <typename T1, typename T2>
1161  void TriggerEvent(const char* name,
1162  const T1& argument1,
1163  const T2& argument2)
1164  {
1165  COHTML_TRIGGER_EVENT_SCOPE(TriggerEvent_2_Param, name);
1166  Binder* binder = GetBinder();
1167 
1168  if (binder)
1169  {
1170 
1171  binder->BeginEvent(name, 2);
1172 
1173  CoherentBindInternal(binder, argument1);
1174  CoherentBindInternal(binder, argument2);
1175 
1176  binder->EndEvent();
1177  }
1178  }
1179 
1182  template <typename T1, typename T2, typename T3>
1183  void TriggerEvent(const char* name,
1184  const T1& argument1,
1185  const T2& argument2,
1186  const T3& argument3)
1187  {
1188  COHTML_TRIGGER_EVENT_SCOPE(TriggerEvent_3_Param, name);
1189  Binder* binder = GetBinder();
1190 
1191  if (binder)
1192  {
1193  binder->BeginEvent(name, 3);
1194 
1195  CoherentBindInternal(binder, argument1);
1196  CoherentBindInternal(binder, argument2);
1197  CoherentBindInternal(binder, argument3);
1198 
1199  binder->EndEvent();
1200  }
1201  }
1202 
1205  template <typename T1, typename T2, typename T3, typename T4>
1206  void TriggerEvent(const char* name,
1207  const T1& argument1,
1208  const T2& argument2,
1209  const T3& argument3,
1210  const T4& argument4)
1211  {
1212  COHTML_TRIGGER_EVENT_SCOPE(TriggerEvent_4_Param, name);
1213  Binder* binder = GetBinder();
1214 
1215  if (binder)
1216  {
1217  binder->BeginEvent(name, 4);
1218 
1219  CoherentBindInternal(binder, argument1);
1220  CoherentBindInternal(binder, argument2);
1221  CoherentBindInternal(binder, argument3);
1222  CoherentBindInternal(binder, argument4);
1223 
1224  binder->EndEvent();
1225  }
1226  }
1227 
1230  template <typename T1, typename T2, typename T3, typename T4, typename T5>
1231  void TriggerEvent(const char* name,
1232  const T1& argument1,
1233  const T2& argument2,
1234  const T3& argument3,
1235  const T4& argument4,
1236  const T5& argument5)
1237  {
1238  COHTML_TRIGGER_EVENT_SCOPE(TriggerEvent_5_Param, name);
1239  Binder* binder = GetBinder();
1240 
1241  if (binder)
1242  {
1243  binder->BeginEvent(name, 5);
1244 
1245  CoherentBindInternal(binder, argument1);
1246  CoherentBindInternal(binder, argument2);
1247  CoherentBindInternal(binder, argument3);
1248  CoherentBindInternal(binder, argument4);
1249  CoherentBindInternal(binder, argument5);
1250 
1251  binder->EndEvent();
1252  }
1253  }
1255 
1256 #else
1257  inline void TriggerEventOnOSThread(const char* name)
1260  {
1261  COHTML_TRIGGER_EVENT_SCOPE(TriggerEvent_0_Param, name);
1262  Binder* binder = GetBinder();
1263 
1264  if (binder)
1265  {
1266  HummingbirdTriggerEventOnOSThread(binder, name, 0, NULL, NULL);
1267  }
1268  }
1269 
1272  template <typename T1>
1273  void TriggerEvent(const char* name, const T1& argument1)
1274  {
1275  COHTML_TRIGGER_EVENT_SCOPE(TriggerEvent_1_Param, name);
1276  Binder* binder = GetBinder();
1277 
1278  if (binder)
1279  {
1280  CoherentGenericBindFuncPtr functions[] = {
1281  &CoherentGenericBind<T1>
1282  };
1283  const void* args[] = {
1284  &argument1
1285  };
1286  HummingbirdTriggerEventOnOSThread(binder, name, 1, functions, args);
1287  }
1288  }
1289 
1292  template <typename T1, typename T2>
1293  void TriggerEvent(const char* name,
1294  const T1& argument1,
1295  const T2& argument2)
1296  {
1297  COHTML_TRIGGER_EVENT_SCOPE(TriggerEvent_2_Param, name);
1298  Binder* binder = GetBinder();
1299 
1300  if (binder)
1301  {
1302  CoherentGenericBindFuncPtr functions[] = {
1303  &CoherentGenericBind<T1>,
1304  &CoherentGenericBind<T2>
1305  };
1306  const void* args[] = {
1307  &argument1,
1308  &argument2
1309  };
1310  HummingbirdTriggerEventOnOSThread(binder, name, 2, functions, args);
1311  }
1312  }
1313 
1316  template <typename T1, typename T2, typename T3>
1317  void TriggerEvent(const char* name,
1318  const T1& argument1,
1319  const T2& argument2,
1320  const T3& argument3)
1321  {
1322  COHTML_TRIGGER_EVENT_SCOPE(TriggerEvent_3_Param, name);
1323  Binder* binder = GetBinder();
1324 
1325  if (binder)
1326  {
1327  CoherentGenericBindFuncPtr functions[] = {
1328  &CoherentGenericBind<T1>,
1329  &CoherentGenericBind<T2>,
1330  &CoherentGenericBind<T3>,
1331  };
1332  const void* args[] = {
1333  &argument1,
1334  &argument2,
1335  &argument3
1336  };
1337  HummingbirdTriggerEventOnOSThread(binder, name, 3, functions, args);
1338  }
1339  }
1340 
1343  template <typename T1, typename T2, typename T3, typename T4>
1344  void TriggerEvent(const char* name,
1345  const T1& argument1,
1346  const T2& argument2,
1347  const T3& argument3,
1348  const T4& argument4)
1349  {
1350  COHTML_TRIGGER_EVENT_SCOPE(TriggerEvent_4_Param, name);
1351  Binder* binder = GetBinder();
1352 
1353  if (binder)
1354  {
1355  CoherentGenericBindFuncPtr functions[] = {
1356  &CoherentGenericBind<T1>,
1357  &CoherentGenericBind<T2>,
1358  &CoherentGenericBind<T3>,
1359  &CoherentGenericBind<T4>
1360  };
1361  const void* args[] = {
1362  &argument1,
1363  &argument2,
1364  &argument3,
1365  &argument4
1366  };
1367  HummingbirdTriggerEventOnOSThread(binder, name, 4, functions, args);
1368  }
1369  }
1370 
1373  template <typename T1, typename T2, typename T3, typename T4, typename T5>
1374  void TriggerEventOnUIThread(const char* name,
1375  const T1& argument1,
1376  const T2& argument2,
1377  const T3& argument3,
1378  const T4& argument4,
1379  const T5& argument5)
1380  {
1381  COHTML_TRIGGER_EVENT_SCOPE(TriggerEvent_5_Param, name);
1382  Binder* binder = GetBinder();
1383 
1384  if (binder)
1385  {
1386  CoherentGenericBindFuncPtr functions[] = {
1387  &CoherentGenericBind<T1>,
1388  &CoherentGenericBind<T2>,
1389  &CoherentGenericBind<T3>,
1390  &CoherentGenericBind<T4>,
1391  &CoherentGenericBind<T5>,
1392  };
1393  const void* args[] = {
1394  &argument1,
1395  &argument2,
1396  &argument3,
1397  &argument4,
1398  &argument5
1399  };
1400  HummingbirdTriggerEventOnOSThread(binder, name, 5, functions, args);
1401  }
1402  }
1404 #endif
1405 };
1406 
1407 }
virtual void BeginEvent(const char *eventName, int arguments)=0
No event is being processed at this time.
Definition: View.h:204
The event is being propagated through the target&#39;s ancestor objects.
Definition: View.h:207
Debugging class holding debug frame captured data and size. Passed to FrameCaptureCallback on View::B...
Definition: View.h:641
virtual unsigned GetHeight() const =0
Gets the View height.
void TriggerEvent(const char *name, const T1 &argument1, const T2 &argument2)
Triggers a UI event.
Definition: View.h:1161
Denotes a text range.
Definition: View.h:260
virtual void CaptureSingleDebugFrame(void *userData, FrameCaptureCallback callback)=0
Will serialize next rendered frame to a memory blob which will be passed in the callback. The saved frames can be inspected for debug purposes.
Options
Configures the images to include in the list.
Definition: View.h:675
void TriggerEvent(const char *name, const T1 &argument1)
Triggers a UI event.
Definition: View.h:1143
virtual void OnDOMBuilt()
Called when the page&#39;s DOM is fully constructed, but the referenced resources may not finish loading...
Definition: View.h:364
virtual void TriggerEvent(const char *name)=0
Triggers a UI event.
virtual void UnregisterModelOfType(void *model, cohtml::TypeInfo *typeInfo)=0
Unregisters a model.
Direction
Enum containing the possible text selection directions.
Definition: View.h:249
virtual void BeginType()
Direction SelectionDirection
The direction of the selection, which shows on which end does the caret go.
Definition: View.h:274
virtual void ResetInitialScripts()=0
Resets the list of initial scripts executed on every page load.
virtual DebugDump * DebugDumpStackingContextTree()=0
Debugging helper. Collects data about stacking context subtrees of the DOM tree.
virtual void SetAsGlobal(const char *name, void *object)=0
Holds the information about a text selection.
Definition: View.h:269
virtual bool IMESetComposition(const char *composition, unsigned targetStart, unsigned targetEnd)=0
Updates the internal state of the IME composition in the View.
float X
Leftmost coordinate in pixels.
Definition: View.h:280
virtual void OnListenerLost()=0
Informs the View that its listener has been lost.
OnMonotonicallyIncreasingTimeRequestFunc OnMonotonicallyIncreasingTimeRequest
Called during the advance of the views when accurate current time is needed The client should return ...
Definition: View.h:122
virtual void OnBindingsReleased()
Called when the JavaScript bindings are released Use this call to release any resources hold by the J...
Definition: View.h:391
virtual void SetSceneCustomEffectRenderer(renoir::ICustomEffectRenderer *renderer, void *customEffectRendererMetadata)=0
Set a custom effect renderer for the View. Callbacks of the interface will be invoked for elements th...
virtual void Reload()=0
Reloads the current page in the view.
virtual void UnloadDocument()=0
Unloads the HTML document. This will remove the entire DOM tree, so nothing will rendered but the vie...
unsigned AvailableHeight
Height of the user&#39;s screen, in pixels, minus interface features like the Windows Taskbar...
Definition: View.h:303
bool InterceptResourceRequests
Allows you to intercept resource requests for this view in order to restrict resource access of the v...
Definition: View.h:140
EnableIf<!IsChar< ArrayType >::Value||IsSame< ArrayType, unsigned char >::Value >::Type CoherentBindInternal(Binder *binder, ArrayType(&array)[ArraySize])
Definition: Array.h:83
Definition: View.h:325
void DestroyExposedObject(T *object)
Remove exposed object from JavaScript.
Definition: View.h:971
All handling will be interrupted along with event bubbling. Eventual event listeners on the Node will...
Definition: View.h:228
virtual void Resize(unsigned width, unsigned height)=0
Resizes the View contents.
virtual ~DebugDump()
unsigned MinimumVertexBufferSize
Controls the mininum count of vertices allocated when creating vertex buffers. If equal to 0 then def...
Definition: View.h:144
void UpdateWholeModel(T *model)
Marks a model as dirty. Properties will be synchronized using the View::SynchronizeModels call...
Definition: View.h:1055
bool ExecuteCommandProcessingWithLayout
Tells the view to process all collected front-end commands right after the layout execution on the sa...
Definition: View.h:171
The input type for text.
Definition: View.h:239
unsigned long long Size
Size in bytes of the data pointed by Data.
Definition: View.h:647
RenderingTasksAvailableType
Definition: View.h:95
double TimePoint
Definition: Declarations.h:39
virtual ~ImagesList()
virtual void OnClipboardTextSet(const char *text, unsigned lengthBytes)
Called when the user has initaiated an operation of putting data in the Clipboard (copy or cut)...
Definition: View.h:574
InterceptRequestStatus
Definition: View.h:322
virtual ScreenInfo OnScreenInfoRequested()
Called when JavaScript requested screen metrics Returns current screen metrics.
Definition: View.h:396
This flag will also include images on elements that are currently hidden (display: none) ...
Definition: View.h:680
virtual void ResetIterator()=0
Will reset the internal iterator used by Next() to the beginning of the list.
void(* OnRenderingTasksAvailableFunc)(void *userData, unsigned viewId, unsigned frameId, RenderingTasksAvailableType type)
Definition: View.h:101
Notifies of changes to input elements.
Definition: TextInputHandler.h:41
unsigned AvailableWidth
Width of the user&#39;s screen, in pixels, minus interface features like the Windows Taskbar.
Definition: View.h:300
virtual void OnFinishLoad(const char *url)
Called when a page, including the resources it refers to, is completely loaded and initialized...
Definition: View.h:379
Contains almost all Coherent namespaces, classes and functions.
Definition: CursorTypes.h:37
InternalCaches
Definition: View.h:692
Debugging class used for dumping the whole structure of the page DOM.
Definition: View.h:624
virtual unsigned Advance(TimePoint timeMilliseconds)=0
Advances the internal timer of the View and runs all animations. If changes have happened in the page...
virtual void UnregisterFromEvent(BoundEventHandle handle)=0
Remove a registered C++ handler.
void(* FrameCaptureCallback)(void *userData, FrameCapture *capture)
Function signature of callback used in View::BeginCaptureDebugFrame and View::CaptureSingleDebugFrame...
Definition: View.h:690
virtual void EndType(void *)
virtual void LoadURL(const char *url)=0
Loads a page in the View.
virtual BoundEventHandle BindCall(const char *name, IEventHandler *handler)=0
Expose C++ handler to be called from UI.
virtual unsigned GetId() const =0
Returns the unique ID of the View.
virtual void QueueSetCacheCountSize(InternalCaches cache, unsigned capacity)=0
Queue task to set the maximum number of objects in internal cache.
Definition: View.h:324
virtual IClientSideSocket * OnCreateWebSocket(ISocketListener *listener, const char *url, const char **protocols, unsigned protocolsCount)
Called when the view tries to establish a web socket connection. When JS tries to create a new web so...
Definition: View.h:613
void TriggerEvent(const char *name, const T1 &argument1, const T2 &argument2, const T3 &argument3, const T4 &argument4, const T5 &argument5)
Triggers a UI event.
Definition: View.h:1231
virtual TaskFamilyId GetTaskFamilyId() const =0
Returns the Task Family Id that can be used to schedule Layout work in an auxiliary thread...
Access the cache for client textures (such as image elements) This cache has both size in number of c...
Definition: View.h:702
unsigned VertexIndexBufferRingSize
Controls the size of each ring buffer (the VB ring buffer and the IB ring buffer). Every call to BeginFrame rotates the ring buffer and takes the next available buffer that the GPU should not be using. The acceptable range is between 1 and 8.
Definition: View.h:153
A touch event.
Definition: InputEvents.h:63
ControlType
Enum containing the text input types.
Definition: View.h:236
ViewSettings()
Definition: View.h:176
virtual void OnAudioStreamVolumeChanged(int id, float volume)
Called when an audio stream volume has changed.
Definition: View.h:519
Other non-input types.
Definition: View.h:242
unsigned End
The end position of the range.
Definition: View.h:265
int TaskFamilyId
Definition: Declarations.h:40
float StartPanThreshold
Controls the minumum lenght of pans to be performed.
Definition: View.h:163
void CoherentCreateModelBindPointer(Binder *binder, T *model)
Definition: View.h:61
virtual void Destroy()=0
Destroys the View. Should be called before the destruction of the System and Library.
virtual void KeyEvent(const cohtml::KeyEventData &event, bool *handled, void *userData)=0
Sends a keyboard input event to the View.
virtual bool IMECancelComposition()=0
Cancels the current IME composition.
The View will continue with the normal handling of the event.
Definition: View.h:224
virtual EventAction::Actions OnNodeTouched(const INodeProxy *node, const TouchEventData *event, void *userData, const InputEventPhase::PhaseType phase)
Called before an event is passed to a DOM node for evaluation. The user is able to interrupt the hand...
Definition: View.h:413
virtual void GestureEvent(const cohtml::GestureEventData &event, bool *handled, void *userData)=0
Sends a gesture input event to the View.
bool ExecuteLayoutOnDedicatedThread
Tells if the application will spawn a dedicated layout thread or the Layout will happen in the View::...
Definition: View.h:168
virtual void AddInitialScript(const char *script)=0
Schedules execution of JavaScript code on every page load. Can be called at any time. The scripts will be executed on the next page load in the same order they were added.
virtual void OnTextInputTypeChanged(TextInputControlType::ControlType type)
Called when the current text input control changes (i.e. the user click an edit-box). Use this method to decide when to allow for IME input.
Definition: View.h:528
void RegisterModel(const char *name, T *model, CoherentInternalBindGenericFunc func)
Registers a model with a given name.
Definition: View.h:1070
OnRenderingTasksAvailableFunc OnRenderingTasksAvailable
Called when the View is completely advanced and laid-out.
Definition: View.h:118
virtual ~View()
virtual void OnReadyForBindings()
Called when the view is ready to accept JavaScript bindings.
Definition: View.h:385
ITextInputHandler * TextInputHandler
Notifies of changes to an input elements Can be set to nullptr if the user is not interested in recei...
Definition: View.h:160
virtual void BeginCaptureDebugFrame(void *userData, FrameCaptureCallback callback)=0
Will begin serializing every rendered frame to a memory blob which will be passed in the callback...
void ExposeAsGlobal(const char *name, T *object)
Expose object as global variable.
Definition: View.h:960
virtual void TouchEvent(const cohtml::TouchEventData *events, unsigned count, bool *handled, void *userData)=0
Sends a touch input event to the View.
virtual Binder * GetBinder()=0
Returns a pointer to the internal binder.
virtual const char * Next()=0
Returns the next image in the list. Will return nullptr when the end is reached.
virtual bool IsReadyForBindings() const =0
Checks whether the cohtml.js bindings are initialized and ready to use.
unsigned MinimumIndexBufferSize
Controls the mininum count of indices allocated when creating index buffers. If equal to 0 then defau...
Definition: View.h:148
virtual EventAction::Actions OnNodeMouseEvent(const INodeProxy *node, const MouseEventData *event, void *userData, const InputEventPhase::PhaseType phase)
Called before an event is passed to a DOM node for evaluation. The user is able to interrupt the hand...
Definition: View.h:430
virtual void SetCustomSceneCompositor(renoir::ISubLayerCompositor *compositor, void *viewMetadata)=0
Set a custom scene compositor whose callbacks will be invoked when the Renoir library processes the f...
virtual DebugDump * DebugDumpDOMTree(unsigned flags)=0
Debugging helper. Collects a comprehensive DOM structure dump.
virtual void OnAudioStreamEnded(int id)
Called when an audio stream ends and will no longer receive data.
Definition: View.h:511
void * UserData
Passed to the OnRenderingTasksAvailable and OnMonotonicallyIncreasingTimeRequest callbacks.
Definition: View.h:125
virtual BoundEventHandle RegisterForEvent(const char *name, IEventHandler *handler)=0
Expose C++ handler to be called when a specific event occurs.
virtual void OnAudioStreamClosed(int id)
Called when an audio stream is destroyed.
Definition: View.h:475
virtual void OnAudioStreamPause(int id)
Called by the UI when a playing media element pauses.
Definition: View.h:489
IViewListener * Listener
The ViewListener is notified of events happening in the View.
Definition: View.h:108
Range SelectionRange
The start and end positions of the selection.
Definition: View.h:272
Access the cache for complex shapes This cache has only size in number of contained objects...
Definition: View.h:699
void UnregisterModel(T *model)
Unregisters a model.
Definition: View.h:1079
The ISocketListener represents cohtml::View side of the web sockets.
Definition: Socket.h:92
virtual unsigned GetWidth() const =0
Gets the View width.
virtual void RegisterModelOfType(const char *name, void *model, cohtml::TypeInfo *typeInfo, CoherentInternalBindGenericFunc func)=0
Registers a model with a given name.
virtual void ExecuteScript(const char *script)=0
Execute arbitrary JavaScript code. This should be called only with a valid script context created...
virtual void QueueClearCaches(unsigned caches)=0
Queue a task to clear an internal caches list.
A keyboard event.
Definition: InputEvents.h:166
virtual void OnAudioStreamCreated(int id, int bitDepth, int channels, float samplingRate)
Called by the UI when a media element initializes an audio stream.
Definition: View.h:464
virtual void UnbindCall(BoundEventHandle handle)=0
Remove a bound C++ handler.
Definition: EventHandler.h:127
virtual void EndCaptureDebugFrame()=0
Ends serializing rendered frames.
unsigned Start
The start position of the range.
Definition: View.h:263
unsigned Width
The Width of the View.
Definition: View.h:111
The View represents a UI page with its DOM, styles and JavaScript context. Think of the View as a who...
Definition: View.h:711
Cursors
Definition: CursorTypes.h:41
virtual void OnCursorChanged(CursorTypes::Cursors cursor, const char *url, const float *xHotspot, const float *yHotspot)
Called when the cursor under the pointer changes. The user should modify the visible cursor from the ...
Definition: View.h:562
void TriggerEvent(const char *name, const T1 &argument1, const T2 &argument2, const T3 &argument3)
Triggers a UI event.
Definition: View.h:1183
float Height
Height in pixels.
Definition: View.h:286
A gesture event.
Definition: InputEvents.h:228
Definition: Property.h:765
virtual EventAction::Actions OnNodeKeyEvent(const INodeProxy *node, const KeyEventData *event, void *userData, const InputEventPhase::PhaseType phase)
Called before an event is passed to a DOM node for evaluation. The user is able to interrupt the hand...
Definition: View.h:447
ScreenInfo()
Definition: View.h:311
unsigned Width
Full width in pixels.
Definition: View.h:294
virtual void QueueSetCacheBytesSize(InternalCaches cache, unsigned capacity)=0
Queue task to set the maximum bytes allowed for internal cache.
virtual void ShowElementAABBs(bool show)=0
Debugging flag. This will cause the View to draw the bounding-boxes of all elements.
Provides binding between C++ and the UI.
Definition: Binder.h:138
virtual void SynchronizeModels()=0
Applies the changes accumulated by View::UpdateWholeModel and View::UpdateModelProperty to the corres...
virtual InterceptRequestStatus OnResourceRequestIntercepted(const char *url)
Only used when View::InterceptResourceRequests is explicitly set to true. Called before sending a req...
Definition: View.h:350
virtual ~IClipboardData()
Definition: View.h:589
virtual void SetUserAgent(const char *userAgent)=0
Sets the User Agent string.
virtual void MouseEvent(const cohtml::MouseEventData &event, bool *handled, void *userData)=0
Sends a mouse input event to the View.
float Y
Topmost coordinate in pixels.
Definition: View.h:282
virtual void GetCacheBytesStats(InternalCaches cache, unsigned &filled, unsigned &capacity)=0
Get info about the bytes statistic of a particular internal cache.
virtual void Release()=0
Frees the underlying data.
virtual void OnAudioStreamPlay(int id)
Called by the UI when a media element starts playing an audio stream.
Definition: View.h:482
The event is propagating back up through the target&#39;s ancestors in reverse order. ...
Definition: View.h:213
virtual void UpdateWholeModelOfType(void *model, cohtml::TypeInfo *typeInfo)=0
Marks a model as dirty. Properties will be synchronized using the View::SynchronizeModels call...
virtual void OnAudioDataReceived(int id, int samples, float **pcm, int channels)
Called by the UI when there is decoded PCM data available for playing.
Definition: View.h:500
virtual void EnableRendering(bool value)=0
Enables or disables the recording of rendering commands for the view. Enabled by default.
Access the cache for temporary internal textures The size of the texture is only in bytes...
Definition: View.h:705
This flag is always on - the images of Visible elements will be selected.
Definition: View.h:678
unsigned DoubleClickTime
The double-click time is the maximum number of milliseconds that may occur between the first and seco...
Definition: View.h:156
virtual bool OnNavigateTo(const char *url)
Called when a navigation is about to occur. The user is able to interrupt the navigation or let it co...
Definition: View.h:339
const void * DeveloperOptions
Reserved property for internal usage. Do not use it.
Definition: View.h:174
virtual void OnClipboardTextGet(IClipboardData *setDataObject)
Called when the user has initiated an operation that recovers data from the clipboard (paste)...
Definition: View.h:597
virtual ImagesList * GetUsedImagesList(ImagesListExtract::Options options) const =0
Return a list of images currently in use by the View The list can be used to decide which images to p...
const char * Data
Pointer to the binary capture data.
Definition: View.h:644
Definition: View.h:277
virtual void OnScriptContextCreated()
Called immediately after the script context has been created for the page. This happens before starti...
Definition: View.h:359
The class should be used by the implementer to set the data recovered from the clipboard. Use this class only in the context of a ViewListener::OnClipboardTextGet call.
Definition: View.h:582
void CreateModel(const char *name, T *model)
Creates a model for binding.
Definition: View.h:1043
void TriggerEvent(const char *name, const T1 &argument1, const T2 &argument2, const T3 &argument3, const T4 &argument4)
Triggers a UI event.
Definition: View.h:1206
void(* CoherentInternalBindGenericFunc)(cohtml::Binder *, void *)
Definition: View.h:1037
Definition: InputEvents.h:108
float Width
Width in pixels.
Definition: View.h:284
Backward direction, the caret should be at the begining of the selection.
Definition: View.h:256
Definition: View.h:628
virtual void EndEvent()=0
Represents a DOM element in the View - i.e. a DIV, the BODY etc.
Definition: NodeProxy.h:43
virtual void SetStartPanThreshold(float value)=0
Sets the minumum lenght of pans to be performed.
virtual void DestroyExposedInstanceOfType(void *object, cohtml::TypeInfo *typeInfo)=0
In order to identify different models internally we use a combination between a pointer to the object...
void * BoundEventHandle
Definition: View.h:57
virtual void GetCacheCountStats(InternalCaches cache, unsigned &filled, unsigned &capacity)=0
Get info about the number of objects statistic of a particular internal cache.
Definition: SystemRenderer.h:37
virtual void ClearNavigationHistory()=0
Clears the navigation history accessed from JavaScript History object Use that method after View::Loa...
virtual void OnIMEShouldCancelComposition()
Called when the user must reset the IME composition due to an event in the View itself (i...
Definition: View.h:553
const char * Dump
Definition: View.h:633
Interface that allows to listen for various events in the View.
Definition: View.h:329
virtual void OnLoadFailed(const char *url, const char *error)
Called when a navigation change request failed.
Definition: View.h:370
The event has arrived at the event&#39;s target, event&#39;s node is the one that is being hit by the input...
Definition: View.h:210
virtual void ShowPaintRectangles(bool show)=0
Debugging flag. This will cause the View show which parts of the texture are re-drawn each frame...
virtual bool IMEConfirmComposition(const char *composition)=0
Confirms the current IME composition.
Forward direction, the caret should be at the end of the selection.
Definition: View.h:254
The IClientSideSocket represents platform/client specific part of the web sockets.
Definition: Socket.h:42
DumpFlags
Definition: View.h:626
virtual float GetStartPanThreshold() const =0
Returns the minumum lenght of pans to be performed.
bool EnableComplexCSSSelectorsStyling
Tells if to enable complex CSS selectors when doing style matching. By complex in this context we mea...
Definition: View.h:134
This flag will also include all images mentioned in CSS styles, even though they might not be current...
Definition: View.h:683
Holds the information about current screen.
Definition: View.h:291
Actions
Possible actions when deciding on input handling.
Definition: View.h:221
unsigned Height
Full height in pixels.
Definition: View.h:297
unsigned Height
The Height of the View.
Definition: View.h:114
Access the cache for shadow textures (e.g. box-shadow, text-shadow) This cache has only size in numbe...
Definition: View.h:696
The default selection direction.
Definition: View.h:252
PhaseType
Holds information for input event PhaseType.
Definition: View.h:201
unsigned PixelDepth
Pixel depth in bits.
Definition: View.h:309
A list of images. Used for getting all images that are currently loaded by this View. The list can be used to build a collection of resources that must be pre-loaded via native code or JavaScript to avoid dynamic loading when the page is shown.
Definition: View.h:657
Settings used when initializing a View.
Definition: View.h:105
double(* OnMonotonicallyIncreasingTimeRequestFunc)(void *userdata, unsigned viewId)
Definition: View.h:102
virtual void EmitRenderingMetadata(bool emit)=0
Debugging flag. Enabling this will request the library to attach and emit metadata for every renderin...
virtual void Release()=0
Frees the underlying data.
virtual void BeginExposeObject()=0
virtual void ContinuousRepaint(bool enable)=0
Debugging flag. This will cause the View to re-draw itself each frame.
unsigned ColorDepth
Color depth in bits.
Definition: View.h:306
virtual void UnbindObject(const void *object)=0
Remove all handlers bound to a specific object.
virtual void OnCaretRectChanged(int x, int y, unsigned width, unsigned height)
Called when the caret changes during IME composition. You can use this method to correctly position a...
Definition: View.h:540
virtual void Release()=0