1.4.0.3
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/Binder.h>
41 
42 #if !defined(COHTML_TRIGGER_EVENT_SCOPE)
43 #define COHTML_TRIGGER_EVENT_SCOPE(CompileTimeArgsCount, RuntimeEventName)
44 #endif
45 
46 namespace cohtml
47 {
48 class Binder;
49 class IViewListener;
50 struct TouchEventData;
51 struct MouseEventData;
52 struct KeyEventData;
53 struct GestureEventData;
54 class IEventHandler;
55 class INodeProxy;
57 typedef void* BoundEventHandle;
58 
59 template <typename T>
60 void CoherentCreateModelBindPointer(Binder* binder, T* model)
61 {
62  binder->BeginType();
63  CoherentBind(binder, model);
64  binder->EndType(model);
65 }
66 
67 #if defined(IW_SDK)
68 template <typename T>
69 void CoherentGenericBind(Binder* b, const void* arg)
70 {
71  CoherentBindInternal(b, *(const T*)arg);
72 }
73 typedef void(*CoherentGenericBindFuncPtr)(Binder*, const void*);
74 #endif
75 }
76 
77 #if defined(IW_SDK)
78 extern "C"
79 {
80 void HummingbirdTriggerEventOnOSThread(void* binder, const char* name, int numArgs,
81  void* functions, const void** args);
82 }
83 #endif
84 
85 namespace cohtml
86 {
87 
89 {
92 };
93 
94 typedef void (*OnRenderingTasksAvailableFunc)(void* userData, unsigned viewId, unsigned frameId, RenderingTasksAvailableType type);
95 typedef double (*OnMonotonicallyIncreasingTimeRequestFunc)(void* userdata, unsigned viewId);
96 
99 {
102 
104  unsigned Width;
105 
107  unsigned Height;
108 
112 
116 
118  void* UserData;
119 
128 
134 
141 
145 
147  : Listener(nullptr)
148  , Width(1280u)
149  , Height(720u)
150  , OnRenderingTasksAvailable(nullptr)
152  , UserData(nullptr)
157  , TextInputHandler(nullptr)
158  {}
159 };
160 
161 
162 namespace InputEventPhase
163 {
166  {
168  NONE = 0,
169 
172 
175 
178  };
179 }
180 
182 namespace EventAction
183 {
185  enum Actions
186  {
189 
193  };
194 };
195 
196 
197 namespace TextInputControlType
198 {
201  {
204 
207  };
208 };
209 
210 namespace TextInput
211 {
214  {
221  };
222 
224  struct Range
225  {
227  unsigned Start;
229  unsigned End;
230  };
231 
233  struct Selection
234  {
239  };
240 };
241 
244 {
246  unsigned Width;
247 
249  unsigned Height;
250 
252  unsigned AvailableWidth;
253 
255  unsigned AvailableHeight;
256 
258  unsigned ColorDepth;
259 
261  unsigned PixelDepth;
262 
264  : Width(0)
265  , Height(0)
266  , AvailableWidth(0)
267  , AvailableHeight(0)
268  , ColorDepth(0)
269  , PixelDepth(0)
270  {}
271 };
272 
273 // Reflects the status based on which cohtml should handle a concrete resource request
275 {
278 };
279 
281 class COHTML_API IViewListener
282 {
283 public:
284  virtual ~IViewListener();
285 
290  virtual bool OnNavigateTo(const char* url)
291  {
292  UNUSED_PARAM(url);
293  return true;
294  }
295 
302  {
303  UNUSED_PARAM(url);
304  return InterceptRequestStatus::Allow;
305  }
306 
310  virtual void OnScriptContextCreated()
311  {}
312 
315  virtual void OnDOMBuilt()
316  {}
317 
321  virtual void OnLoadFailed(const char* url, const char* error)
322  {
323  UNUSED_PARAM(url);
324  UNUSED_PARAM(error);
325  }
326 
330  virtual void OnFinishLoad(const char* url)
331  {
332  UNUSED_PARAM(url);
333  }
334 
336  virtual void OnReadyForBindings()
337  {}
338 
342  virtual void OnBindingsReleased()
343  {}
344 
348  {
349  cohtml::ScreenInfo info;
350  info.AvailableWidth = 1920u;
351  info.AvailableHeight = 1080u;
352  info.ColorDepth = 24;
353  info.PixelDepth = 24;
354  info.Width = 1920u;
355  info.Height = 1080u;
356  return info;
357  }
358 
363  const TouchEventData* event,
364  void* userData,
365  const InputEventPhase::PhaseType phase)
366  {
367  UNUSED_PARAM(node);
368  UNUSED_PARAM(event);
369  UNUSED_PARAM(userData);
370  UNUSED_PARAM(phase);
372  }
373 
378  const MouseEventData* event,
379  void* userData,
380  const InputEventPhase::PhaseType phase)
381  {
382  UNUSED_PARAM(node);
383  UNUSED_PARAM(event);
384  UNUSED_PARAM(userData);
385  UNUSED_PARAM(phase);
387  }
388 
393  const KeyEventData* event,
394  void* userData,
395  const InputEventPhase::PhaseType phase)
396  {
397  UNUSED_PARAM(node);
398  UNUSED_PARAM(event);
399  UNUSED_PARAM(userData);
400  UNUSED_PARAM(phase);
402  }
403 
409  virtual void OnAudioStreamCreated(int id, int bitDepth, int channels,
410  float samplingRate)
411  {
412  UNUSED_PARAM(id);
413  UNUSED_PARAM(bitDepth);
414  UNUSED_PARAM(channels);
415  UNUSED_PARAM(samplingRate);
416  }
417 
420  virtual void OnAudioStreamClosed(int id)
421  {
422  UNUSED_PARAM(id);
423  }
424 
427  virtual void OnAudioStreamPlay(int id)
428  {
429  UNUSED_PARAM(id);
430  }
431 
434  virtual void OnAudioStreamPause(int id)
435  {
436  UNUSED_PARAM(id);
437  }
438 
445  virtual void OnAudioDataReceived(int id, int samples, float** pcm,
446  int channels)
447  {
448  UNUSED_PARAM(id);
449  UNUSED_PARAM(samples);
450  UNUSED_PARAM(pcm);
451  UNUSED_PARAM(channels);
452  }
453 
456  virtual void OnAudioStreamEnded(int id)
457  {
458  UNUSED_PARAM(id);
459  }
460 
464  virtual void OnAudioStreamVolumeChanged(int id, float volume)
465  {
466  UNUSED_PARAM(id);
467  UNUSED_PARAM(volume);
468  }
469 
474  {
475  UNUSED_PARAM(type);
476  }
477 
485  virtual void OnCaretRectChanged(int x,
486  int y,
487  unsigned width,
488  unsigned height)
489  {
490  UNUSED_PARAM(x);
491  UNUSED_PARAM(y);
492  UNUSED_PARAM(width);
493  UNUSED_PARAM(height);
494  }
495 
499  {}
500 
507  virtual void OnCursorChanged(CursorTypes::Cursors cursor, const char* url, const float* xHotspot, const float* yHotspot)
508  {
509  UNUSED_PARAM(cursor);
510  UNUSED_PARAM(url);
511  UNUSED_PARAM(xHotspot);
512  UNUSED_PARAM(yHotspot);
513  }
514 
519  virtual void OnClipboardTextSet(const char* text, unsigned lengthBytes)
520  {
521  UNUSED_PARAM(text);
522  UNUSED_PARAM(lengthBytes);
523  }
524 
528  {
532  virtual void Set(const char* text, unsigned lengthBytes) = 0;
533 
534  virtual ~IClipboardData() {}
535  };
536 
542  virtual void OnClipboardTextGet(IClipboardData* setDataObject)
543  {
544  UNUSED_PARAM(setDataObject);
545  }
546 };
547 
549 struct DebugDump
550 {
552  {
553  DF_None = 0,
556  };
557 
558  const char* Dump;
559  virtual void Release() = 0;
560  virtual ~DebugDump();
561 };
562 
567 {
569  const char* Data;
570 
572  unsigned long long Size;
573 
575  virtual void Release() = 0;
576  virtual ~FrameCapture();
577 };
578 
583 {
585  virtual const char* Next() = 0;
586 
588  virtual void ResetIterator() = 0;
589 
591  virtual void Release() = 0;
592  virtual ~ImagesList();
593 };
594 
597 namespace ImagesListExtract
598 {
600  enum Options
601  {
603  Images = 0,
605  Hidden = 1 << 0,
608  Styles = 1 << 1
609  };
610 }
611 
615 typedef void(*FrameCaptureCallback)(void* userData, FrameCapture* capture);
616 
618 {
621  ICACHE_Shadows = 1 << 0,
624  ICACHE_Paths = 1 << 1,
627  ICACHE_Textures = 1 << 2,
631 };
632 
636 class View
637 {
638 public:
639  virtual ~View();
640 
642  virtual void Destroy() = 0;
643 
646  virtual void LoadURL(const char* url) = 0;
647 
649  virtual void Reload() = 0;
650 
654  virtual void UnloadDocument() = 0;
655 
660  virtual unsigned Advance(TimePoint timeMilliseconds) = 0;
661 
663  virtual unsigned GetId() const = 0;
664 
666  virtual TaskFamilyId GetTaskFamilyId() const = 0;
667 
673  virtual void Resize(unsigned width, unsigned height) = 0;
674 
676  virtual unsigned GetWidth() const = 0;
677 
679  virtual unsigned GetHeight() const = 0;
680 
684  virtual void EnableRendering(bool value) = 0;
685 
689  virtual void ContinuousRepaint(bool enable) = 0;
690 
693  virtual void ShowPaintRectangles(bool show) = 0;
694 
697  virtual void ShowElementAABBs(bool show) = 0;
698 
709  virtual void EmitRenderingMetadata(bool emit) = 0;
710 
712  virtual DebugDump* DebugDumpDOMTree(unsigned flags) = 0;
713 
719  virtual void TouchEvent(const cohtml::TouchEventData* events, unsigned count, bool* handled, void* userData) = 0;
720 
725  virtual void GestureEvent(const cohtml::GestureEventData& event, bool* handled, void* userData) = 0;
726 
731  virtual void MouseEvent(const cohtml::MouseEventData& event, bool* handled, void* userData) = 0;
732 
737  virtual void KeyEvent(const cohtml::KeyEventData& event, bool* handled, void* userData) = 0;
738 
744  virtual bool IMESetComposition(const char* composition,
745  unsigned targetStart,
746  unsigned targetEnd) = 0;
747 
751  virtual bool IMEConfirmComposition(const char* composition) = 0;
752 
755  virtual bool IMECancelComposition() = 0;
756 
759  virtual void SetUserAgent(const char* userAgent) = 0;
760 
768  virtual ImagesList* GetUsedImagesList(ImagesListExtract::Options options) const = 0;
769 
778  virtual void BeginCaptureDebugFrame(void* userData, FrameCaptureCallback callback) = 0;
779 
781  virtual void EndCaptureDebugFrame() = 0;
782 
792  virtual void CaptureSingleDebugFrame(void* userData, FrameCaptureCallback callback) = 0;
793 
800  virtual void GetCacheCountStats(InternalCaches cache, unsigned& filled, unsigned& capacity) = 0;
801 
808  virtual void GetCacheBytesStats(InternalCaches cache, unsigned& filled, unsigned& capacity) = 0;
809 
815  virtual void QueueSetCacheCountSize(InternalCaches cache, unsigned capacity) = 0;
816 
822  virtual void QueueSetCacheBytesSize(InternalCaches cache, unsigned capacity) = 0;
823 
827  virtual void QueueClearCaches(unsigned caches) = 0;
828 
834  virtual BoundEventHandle RegisterForEvent(const char* name,
835  IEventHandler* handler) = 0;
836 
841  virtual void UnregisterFromEvent(BoundEventHandle handle) = 0;
842 
848  virtual BoundEventHandle BindCall(const char* name, IEventHandler* handler)
849  = 0;
850 
855  virtual void UnbindCall(BoundEventHandle handle) = 0;
856 
861  virtual void UnbindObject(const void* object) = 0;
862 
866  template <typename T>
867  void ExposeAsGlobal(const char* name, T* object)
868  {
869  Binder* binder = GetBinder();
870  binder->BeginExposeObject();
871  CoherentBindInternal(binder, object);
872  binder->SetAsGlobal(name, object);
873  }
874 
877  virtual void DestroyExposedObject(void* object) = 0;
878 
882  virtual bool IsReadyForBindings() const = 0;
883 
888  virtual void ExecuteScript(const char* script) = 0;
889 
895  virtual void AddInitialScript(const char* script) = 0;
896 
898  virtual void ResetInitialScripts() = 0;
899 
901  virtual Binder* GetBinder() = 0;
902 
906 
908 
912  template <typename T>
913  void CreateModel(const char* name, T* model)
914  {
915  typedef void(*CoherentInternalBindFunc)(cohtml::Binder*, T*);
916  CoherentInternalBindFunc bindFuncPtr = &CoherentCreateModelBindPointer<T>;
917  CoherentInternalBindGenericFunc bindGenericPtr = reinterpret_cast<CoherentInternalBindGenericFunc>(bindFuncPtr);
918  RegisterModel(name, model, bindGenericPtr);
919  }
920 
924  virtual void UpdateWholeModel(void* model) = 0;
925 
928  virtual void SynchronizeModels() = 0;
929 
935  virtual void RegisterModel(const char* name, void* model, CoherentInternalBindGenericFunc func) = 0;
936 
940  virtual void UnregisterModel(void* model) = 0;
941 
943 
944 
948 
949 #if !defined(IW_SDK)
950  virtual void TriggerEvent(const char* name) = 0;
953 
956  template <typename T1>
957  void TriggerEvent(const char* name, const T1& argument1)
958  {
959  COHTML_TRIGGER_EVENT_SCOPE(TriggerEvent_1_Param, name);
960  Binder* binder = GetBinder();
961 
962  if (binder)
963  {
964  binder->BeginEvent(name, 1);
965 
966  CoherentBindInternal(binder, argument1);
967 
968  binder->EndEvent();
969  }
970  }
971 
974  template <typename T1, typename T2>
975  void TriggerEvent(const char* name,
976  const T1& argument1,
977  const T2& argument2)
978  {
979  COHTML_TRIGGER_EVENT_SCOPE(TriggerEvent_2_Param, name);
980  Binder* binder = GetBinder();
981 
982  if (binder)
983  {
984 
985  binder->BeginEvent(name, 2);
986 
987  CoherentBindInternal(binder, argument1);
988  CoherentBindInternal(binder, argument2);
989 
990  binder->EndEvent();
991  }
992  }
993 
996  template <typename T1, typename T2, typename T3>
997  void TriggerEvent(const char* name,
998  const T1& argument1,
999  const T2& argument2,
1000  const T3& argument3)
1001  {
1002  COHTML_TRIGGER_EVENT_SCOPE(TriggerEvent_3_Param, name);
1003  Binder* binder = GetBinder();
1004 
1005  if (binder)
1006  {
1007  binder->BeginEvent(name, 3);
1008 
1009  CoherentBindInternal(binder, argument1);
1010  CoherentBindInternal(binder, argument2);
1011  CoherentBindInternal(binder, argument3);
1012 
1013  binder->EndEvent();
1014  }
1015  }
1016 
1019  template <typename T1, typename T2, typename T3, typename T4>
1020  void TriggerEvent(const char* name,
1021  const T1& argument1,
1022  const T2& argument2,
1023  const T3& argument3,
1024  const T4& argument4)
1025  {
1026  COHTML_TRIGGER_EVENT_SCOPE(TriggerEvent_4_Param, name);
1027  Binder* binder = GetBinder();
1028 
1029  if (binder)
1030  {
1031  binder->BeginEvent(name, 4);
1032 
1033  CoherentBindInternal(binder, argument1);
1034  CoherentBindInternal(binder, argument2);
1035  CoherentBindInternal(binder, argument3);
1036  CoherentBindInternal(binder, argument4);
1037 
1038  binder->EndEvent();
1039  }
1040  }
1041 
1044  template <typename T1, typename T2, typename T3, typename T4, typename T5>
1045  void TriggerEvent(const char* name,
1046  const T1& argument1,
1047  const T2& argument2,
1048  const T3& argument3,
1049  const T4& argument4,
1050  const T5& argument5)
1051  {
1052  COHTML_TRIGGER_EVENT_SCOPE(TriggerEvent_5_Param, name);
1053  Binder* binder = GetBinder();
1054 
1055  if (binder)
1056  {
1057  binder->BeginEvent(name, 5);
1058 
1059  CoherentBindInternal(binder, argument1);
1060  CoherentBindInternal(binder, argument2);
1061  CoherentBindInternal(binder, argument3);
1062  CoherentBindInternal(binder, argument4);
1063  CoherentBindInternal(binder, argument5);
1064 
1065  binder->EndEvent();
1066  }
1067  }
1069 
1070 #else
1071  inline void TriggerEventOnOSThread(const char* name)
1074  {
1075  COHTML_TRIGGER_EVENT_SCOPE(TriggerEvent_0_Param, name);
1076  Binder* binder = GetBinder();
1077 
1078  if (binder)
1079  {
1080  HummingbirdTriggerEventOnOSThread(binder, name, 0, NULL, NULL);
1081  }
1082  }
1083 
1086  template <typename T1>
1087  void TriggerEvent(const char* name, const T1& argument1)
1088  {
1089  COHTML_TRIGGER_EVENT_SCOPE(TriggerEvent_1_Param, name);
1090  Binder* binder = GetBinder();
1091 
1092  if (binder)
1093  {
1094  CoherentGenericBindFuncPtr functions[] = {
1095  &CoherentGenericBind<T1>
1096  };
1097  const void* args[] = {
1098  &argument1
1099  };
1100  HummingbirdTriggerEventOnOSThread(binder, name, 1, functions, args);
1101  }
1102  }
1103 
1106  template <typename T1, typename T2>
1107  void TriggerEvent(const char* name,
1108  const T1& argument1,
1109  const T2& argument2)
1110  {
1111  COHTML_TRIGGER_EVENT_SCOPE(TriggerEvent_2_Param, name);
1112  Binder* binder = GetBinder();
1113 
1114  if (binder)
1115  {
1116  CoherentGenericBindFuncPtr functions[] = {
1117  &CoherentGenericBind<T1>,
1118  &CoherentGenericBind<T2>
1119  };
1120  const void* args[] = {
1121  &argument1,
1122  &argument2
1123  };
1124  HummingbirdTriggerEventOnOSThread(binder, name, 2, functions, args);
1125  }
1126  }
1127 
1130  template <typename T1, typename T2, typename T3>
1131  void TriggerEvent(const char* name,
1132  const T1& argument1,
1133  const T2& argument2,
1134  const T3& argument3)
1135  {
1136  COHTML_TRIGGER_EVENT_SCOPE(TriggerEvent_3_Param, name);
1137  Binder* binder = GetBinder();
1138 
1139  if (binder)
1140  {
1141  CoherentGenericBindFuncPtr functions[] = {
1142  &CoherentGenericBind<T1>,
1143  &CoherentGenericBind<T2>,
1144  &CoherentGenericBind<T3>,
1145  };
1146  const void* args[] = {
1147  &argument1,
1148  &argument2,
1149  &argument3
1150  };
1151  HummingbirdTriggerEventOnOSThread(binder, name, 3, functions, args);
1152  }
1153  }
1154 
1157  template <typename T1, typename T2, typename T3, typename T4>
1158  void TriggerEvent(const char* name,
1159  const T1& argument1,
1160  const T2& argument2,
1161  const T3& argument3,
1162  const T4& argument4)
1163  {
1164  COHTML_TRIGGER_EVENT_SCOPE(TriggerEvent_4_Param, name);
1165  Binder* binder = GetBinder();
1166 
1167  if (binder)
1168  {
1169  CoherentGenericBindFuncPtr functions[] = {
1170  &CoherentGenericBind<T1>,
1171  &CoherentGenericBind<T2>,
1172  &CoherentGenericBind<T3>,
1173  &CoherentGenericBind<T4>
1174  };
1175  const void* args[] = {
1176  &argument1,
1177  &argument2,
1178  &argument3,
1179  &argument4
1180  };
1181  HummingbirdTriggerEventOnOSThread(binder, name, 4, functions, args);
1182  }
1183  }
1184 
1187  template <typename T1, typename T2, typename T3, typename T4, typename T5>
1188  void TriggerEventOnUIThread(const char* name,
1189  const T1& argument1,
1190  const T2& argument2,
1191  const T3& argument3,
1192  const T4& argument4,
1193  const T5& argument5)
1194  {
1195  COHTML_TRIGGER_EVENT_SCOPE(TriggerEvent_5_Param, name);
1196  Binder* binder = GetBinder();
1197 
1198  if (binder)
1199  {
1200  CoherentGenericBindFuncPtr functions[] = {
1201  &CoherentGenericBind<T1>,
1202  &CoherentGenericBind<T2>,
1203  &CoherentGenericBind<T3>,
1204  &CoherentGenericBind<T4>,
1205  &CoherentGenericBind<T5>,
1206  };
1207  const void* args[] = {
1208  &argument1,
1209  &argument2,
1210  &argument3,
1211  &argument4,
1212  &argument5
1213  };
1214  HummingbirdTriggerEventOnOSThread(binder, name, 5, functions, args);
1215  }
1216  }
1218 #endif
1219 };
1220 
1221 }
virtual void BeginEvent(const char *eventName, int arguments)=0
No event is being processed at this time.
Definition: View.h:168
The event is being propagated through the target&#39;s ancestor objects.
Definition: View.h:171
Debugging class holding debug frame captured data and size. Passed to FrameCaptureCallback on View::B...
Definition: View.h:566
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:975
Denotes a text range.
Definition: View.h:224
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:600
void TriggerEvent(const char *name, const T1 &argument1)
Triggers a UI event.
Definition: View.h:957
virtual void OnDOMBuilt()
Called when the page&#39;s DOM is fully constructed, but the referenced resources may not finish loading...
Definition: View.h:315
virtual void TriggerEvent(const char *name)=0
Triggers a UI event.
Direction
Enum containing the possible text selection directions.
Definition: View.h:213
virtual void BeginType()
Direction SelectionDirection
The direction of the selection, which shows on which end does the caret go.
Definition: View.h:238
virtual void ResetInitialScripts()=0
Resets the list of initial scripts executed on every page load.
virtual void SetAsGlobal(const char *name, void *object)=0
Holds the information about a text selection.
Definition: View.h:233
virtual bool IMESetComposition(const char *composition, unsigned targetStart, unsigned targetEnd)=0
Updates the internal state of the IME composition in the View.
OnMonotonicallyIncreasingTimeRequestFunc OnMonotonicallyIncreasingTimeRequest
Called during the advance of the views when accurate current time is needed The client should return ...
Definition: View.h:115
virtual void OnBindingsReleased()
Called when the JavaScript bindings are released Use this call to release any resources hold by the J...
Definition: View.h:342
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:255
bool InterceptResourceRequests
Allows you to intercept resource requests for this view in order to restrict resource access of the v...
Definition: View.h:133
Definition: View.h:277
All handling will be interrupted along with event bubbling. Eventual event listeners on the Node will...
Definition: View.h:192
virtual void Resize(unsigned width, unsigned height)=0
Resizes the View contents.
virtual ~DebugDump()
unsigned MinimumVertexBufferSize
This controls the mininum count of vertices allocated when creating vertex buffers. If equal to 0 then default count will be used which is 32768.
Definition: View.h:137
The input type for text.
Definition: View.h:203
unsigned long long Size
Size in bytes of the data pointed by Data.
Definition: View.h:572
RenderingTasksAvailableType
Definition: View.h:88
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:519
InterceptRequestStatus
Definition: View.h:274
virtual ScreenInfo OnScreenInfoRequested()
Called when JavaScript requested screen metrics Returns current screen metrics.
Definition: View.h:347
This flag will also include images on elements that are currently hidden (display: none) ...
Definition: View.h:605
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:94
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:252
void CoherentBindInternal(Binder *binder, ArrayType(&array)[ArraySize])
Definition: Array.h:80
virtual void OnFinishLoad(const char *url)
Called when a page, including the resources it refers to, is completely loaded and initialized...
Definition: View.h:330
Contains almost all Coherent namespaces, classes and functions.
Definition: CursorTypes.h:37
InternalCaches
Definition: View.h:617
Debugging class used for dumping the whole structure of the page DOM.
Definition: View.h:549
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:615
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:276
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:1045
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:627
A touch event.
Definition: InputEvents.h:63
ControlType
Enum containing the text input types.
Definition: View.h:200
ViewSettings()
Definition: View.h:146
virtual void OnAudioStreamVolumeChanged(int id, float volume)
Called when an audio stream volume has changed.
Definition: View.h:464
Other non-input types.
Definition: View.h:206
unsigned End
The end position of the range.
Definition: View.h:229
int TaskFamilyId
Definition: Declarations.h:40
void CoherentCreateModelBindPointer(Binder *binder, T *model)
Definition: View.h:60
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:188
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:362
virtual void GestureEvent(const cohtml::GestureEventData &event, bool *handled, void *userData)=0
Sends a gesture input event to the View.
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:473
OnRenderingTasksAvailableFunc OnRenderingTasksAvailable
Called when the View is completely advanced and laid-out.
Definition: View.h:111
virtual ~View()
virtual void OnReadyForBindings()
Called when the view is ready to accept JavaScript bindings.
Definition: View.h:336
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:144
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:867
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
This controls the mininum count of indices allocated when creating index buffers. If equal to 0 then ...
Definition: View.h:140
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:377
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:456
void * UserData
Passed to the OnRenderingTasksAvailable and OnMonotonicallyIncreasingTimeRequest callbacks.
Definition: View.h:118
virtual BoundEventHandle RegisterForEvent(const char *name, IEventHandler *handler)=0
Expose C++ handler to be called when a specific event occurs.
virtual void UpdateWholeModel(void *model)=0
Marks a model as dirty. Properties will be synchronized using the View::SynchronizeModels call...
virtual void OnAudioStreamClosed(int id)
Called when an audio stream is destroyed.
Definition: View.h:420
virtual void OnAudioStreamPause(int id)
Called by the UI when a playing media element pauses.
Definition: View.h:434
IViewListener * Listener
The ViewListener is notified of events happening in the View.
Definition: View.h:101
Range SelectionRange
The start and end positions of the selection.
Definition: View.h:236
Access the cache for complex shapes This cache has only size in number of contained objects...
Definition: View.h:624
virtual unsigned GetWidth() const =0
Gets the View width.
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:409
virtual void UnbindCall(BoundEventHandle handle)=0
Remove a bound C++ handler.
Definition: EventHandler.h:125
virtual void EndCaptureDebugFrame()=0
Ends serializing rendered frames.
unsigned Start
The start position of the range.
Definition: View.h:227
unsigned Width
The Width of the View.
Definition: View.h:104
The View represents a UI page with its DOM, styles and JavaScript context. Think of the View as a who...
Definition: View.h:636
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:507
void TriggerEvent(const char *name, const T1 &argument1, const T2 &argument2, const T3 &argument3)
Triggers a UI event.
Definition: View.h:997
A gesture event.
Definition: InputEvents.h:228
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:392
ScreenInfo()
Definition: View.h:263
unsigned Width
Full width in pixels.
Definition: View.h:246
virtual void UnregisterModel(void *model)=0
Unregisters a model.
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:301
virtual ~IClipboardData()
Definition: View.h:534
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.
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:427
The event is propagating back up through the target&#39;s ancestors in reverse order. ...
Definition: View.h:177
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:445
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:630
This flag is always on - the images of Visible elements will be selected.
Definition: View.h:603
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:290
virtual void OnClipboardTextGet(IClipboardData *setDataObject)
Called when the user has initiated an operation that recovers data from the clipboard (paste)...
Definition: View.h:542
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:569
virtual void OnScriptContextCreated()
Called immediately after the script context has been created for the page. This happens before starti...
Definition: View.h:310
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:527
void CreateModel(const char *name, T *model)
Creates a model for binding.
Definition: View.h:913
void TriggerEvent(const char *name, const T1 &argument1, const T2 &argument2, const T3 &argument3, const T4 &argument4)
Triggers a UI event.
Definition: View.h:1020
void(* CoherentInternalBindGenericFunc)(cohtml::Binder *, void *)
Definition: View.h:907
Definition: InputEvents.h:108
Backward direction, the caret should be at the begining of the selection.
Definition: View.h:220
Definition: View.h:553
virtual void EndEvent()=0
virtual void RegisterModel(const char *name, void *model, CoherentInternalBindGenericFunc func)=0
Registers a model with a given name.
Represents a DOM element in the View - i.e. a DIV, the BODY etc.
Definition: NodeProxy.h:43
void * BoundEventHandle
Definition: View.h:56
virtual void GetCacheCountStats(InternalCaches cache, unsigned &filled, unsigned &capacity)=0
Get info about the number of objects statistic of a particular internal cache.
virtual void OnIMEShouldCancelComposition()
Called when the user must reset the IME composition due to an event in the View itself (i...
Definition: View.h:498
virtual void DestroyExposedObject(void *object)=0
Remove exposed object from JavaScript.
const char * Dump
Definition: View.h:558
Interface that allows to listen for various events in the View.
Definition: View.h:281
virtual void OnLoadFailed(const char *url, const char *error)
Called when a navigation change request failed.
Definition: View.h:321
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:174
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:218
DumpFlags
Definition: View.h:551
bool EnableComplexCSSSelectorsStyling
Tells if to enable complex CSS selectors when doing style matching. By complex in this context we mea...
Definition: View.h:127
This flag will also include all images mentioned in CSS styles, even though they might not be current...
Definition: View.h:608
Holds the information about current screen.
Definition: View.h:243
Actions
Possible actions when deciding on input handling.
Definition: View.h:185
unsigned Height
Full height in pixels.
Definition: View.h:249
unsigned Height
The Height of the View.
Definition: View.h:107
Access the cache for shadow textures (e.g. box-shadow, text-shadow) This cache has only size in numbe...
Definition: View.h:621
The default selection direction.
Definition: View.h:216
PhaseType
Holds information for input event PhaseType.
Definition: View.h:165
unsigned PixelDepth
Pixel depth in bits.
Definition: View.h:261
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:582
Settings used when initializing a View.
Definition: View.h:98
double(* OnMonotonicallyIncreasingTimeRequestFunc)(void *userdata, unsigned viewId)
Definition: View.h:95
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:258
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:485
virtual void Release()=0