37 #include <cohtml/Declarations.h> 38 #include <cohtml/ResourceHandler.h> 39 #include <cohtml/Binding/Binder.h> 41 #if !defined(COHTML_TRIGGER_EVENT_SCOPE) 42 #define COHTML_TRIGGER_EVENT_SCOPE(CompileTimeArgsCount, RuntimeEventName) 49 struct TouchEventData;
50 struct MouseEventData;
52 struct GestureEventData;
55 typedef void* BoundEventHandle;
58 void CoherentCreateModelBindPointer(Binder* binder, T* model)
61 CoherentBind(binder, model);
62 binder->EndType(model);
67 void CoherentGenericBind(Binder* b,
const void* arg)
69 CoherentBindInternal(b, *(
const T*)arg);
71 typedef void(*CoherentGenericBindFuncPtr)(Binder*,
const void*);
78 void HummingbirdTriggerEventOnOSThread(
void* binder,
const char* name,
int numArgs,
79 void* functions,
const void** args);
86 enum RenderingTasksAvailableType
88 RTA_ViewReadyForRendering,
89 RTA_RenderingSubSystemTask
92 typedef void (*OnRenderingTasksAvailableFunc)(
void* userData,
unsigned viewId,
unsigned frameId, RenderingTasksAvailableType type);
93 typedef double (*OnMonotonicallyIncreasingTimeRequestFunc)(
void* userdata,
unsigned viewId);
131 , OnRenderingTasksAvailable(nullptr)
132 , OnMonotonicallyIncreasingTimeRequest(nullptr)
134 , EnableComplexCSSSelectorsStyling(false)
139 namespace InputEventPhase
158 namespace EventAction
173 namespace TextInputControlType
227 virtual bool OnNavigateTo(
const char* url) = 0;
232 virtual void OnScriptContextCreated() = 0;
236 virtual void OnDOMBuilt() = 0;
241 virtual void OnLoadFailed(
const char* url,
const char* error) = 0;
246 virtual void OnFinishLoad(
const char* url) = 0;
249 virtual void OnReadyForBindings() = 0;
254 virtual void OnBindingsReleased() = 0;
258 virtual ScreenInfo OnScreenInfoRequested() = 0;
272 const MouseEventData* event,
293 UNUSED_PARAM(bitDepth);
294 UNUSED_PARAM(channels);
295 UNUSED_PARAM(samplingRate);
329 UNUSED_PARAM(samples);
331 UNUSED_PARAM(channels);
347 UNUSED_PARAM(volume);
362 virtual void OnCaretRectChanged(
int x,
365 unsigned height) = 0;
371 virtual void OnIMEShouldCancelComposition() = 0;
380 DF_IncludeStyles = 1 << 1,
381 DF_IncludeLayout = 1 << 2,
385 virtual void Release() = 0;
400 virtual void Release() = 0;
417 virtual void Destroy() = 0;
421 virtual void LoadURL(
const char* url) = 0;
424 virtual void Reload() = 0;
429 virtual void UnloadDocument() = 0;
435 virtual unsigned Advance(TimePoint timeMilliseconds) = 0;
438 virtual unsigned GetId()
const = 0;
441 virtual TaskFamilyId GetTaskFamilyId()
const = 0;
448 virtual void Resize(
unsigned width,
unsigned height) = 0;
451 virtual unsigned GetWidth()
const = 0;
454 virtual unsigned GetHeight()
const = 0;
459 virtual void ContinuousRepaint(
bool enable) = 0;
463 virtual void ShowPaintRectangles(
bool show) = 0;
467 virtual void ShowElementAABBs(
bool show) = 0;
470 virtual DebugDump* DebugDumpDOMTree(
unsigned flags) = 0;
477 virtual void TouchEvent(
const cohtml::TouchEventData* events,
unsigned count,
bool* handled,
void* userData) = 0;
489 virtual void MouseEvent(
const cohtml::MouseEventData& event,
bool* handled,
void* userData) = 0;
503 virtual bool IMESetComposition(
const char* composition,
504 unsigned targetStart,
505 unsigned targetEnd) = 0;
511 virtual bool IMEConfirmComposition(
const char* composition) = 0;
516 virtual bool IMECancelComposition() = 0;
520 virtual void SetUserAgent(
const char* userAgent) = 0;
533 virtual void EndCaptureDebugFrame() = 0;
551 virtual BoundEventHandle RegisterForEvent(
const char* name,
552 IEventHandler* handler) = 0;
558 virtual void UnregisterFromEvent(BoundEventHandle handle) = 0;
565 virtual BoundEventHandle BindCall(
const char* name, IEventHandler* handler)
572 virtual void UnbindCall(BoundEventHandle handle) = 0;
578 virtual void UnbindObject(
const void*
object) = 0;
583 template <
typename T>
586 Binder* binder = GetBinder();
587 binder->BeginExposeObject();
588 CoherentBindInternal(binder,
object);
589 binder->SetAsGlobal(name,
object);
594 virtual void DestroyExposedObject(
void*
object) = 0;
599 virtual bool IsReadyForBindings()
const = 0;
605 virtual void ExecuteScript(
const char* script) = 0;
612 virtual void AddInitialScript(
const char* script) = 0;
615 virtual void ResetInitialScripts() = 0;
617 virtual Binder* GetBinder() = 0;
623 typedef void(*CoherentInternalBindGenericFunc)(
cohtml::Binder*,
void*);
628 template <
typename T>
631 typedef void(*CoherentInternalBindFunc)(cohtml::Binder*, T*);
632 CoherentInternalBindFunc bindFuncPtr = &CoherentCreateModelBindPointer<T>;
633 CoherentInternalBindGenericFunc bindGenericPtr =
reinterpret_cast<CoherentInternalBindGenericFunc
>(bindFuncPtr);
634 RegisterModel(name, model, bindGenericPtr);
640 virtual void UpdateWholeModel(
void* model) = 0;
644 virtual void SynchronizeModels() = 0;
651 virtual void RegisterModel(
const char* name,
void* model, CoherentInternalBindGenericFunc func) = 0;
655 virtual void UnregisterModel(
void* model) = 0;
665 virtual void TriggerEvent(
const char* name) = 0;
671 template <
typename T1>
674 COHTML_TRIGGER_EVENT_SCOPE(TriggerEvent_1_Param, name);
675 Binder* binder = GetBinder();
679 binder->BeginEvent(name, 1);
681 CoherentBindInternal(binder, argument1);
689 template <
typename T1,
typename T2>
694 COHTML_TRIGGER_EVENT_SCOPE(TriggerEvent_2_Param, name);
695 Binder* binder = GetBinder();
700 binder->BeginEvent(name, 2);
702 CoherentBindInternal(binder, argument1);
703 CoherentBindInternal(binder, argument2);
711 template <
typename T1,
typename T2,
typename T3>
717 COHTML_TRIGGER_EVENT_SCOPE(TriggerEvent_3_Param, name);
718 Binder* binder = GetBinder();
722 binder->BeginEvent(name, 3);
724 CoherentBindInternal(binder, argument1);
725 CoherentBindInternal(binder, argument2);
726 CoherentBindInternal(binder, argument3);
734 template <
typename T1,
typename T2,
typename T3,
typename T4>
741 COHTML_TRIGGER_EVENT_SCOPE(TriggerEvent_4_Param, name);
742 Binder* binder = GetBinder();
746 binder->BeginEvent(name, 4);
748 CoherentBindInternal(binder, argument1);
749 CoherentBindInternal(binder, argument2);
750 CoherentBindInternal(binder, argument3);
751 CoherentBindInternal(binder, argument4);
759 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
767 COHTML_TRIGGER_EVENT_SCOPE(TriggerEvent_5_Param, name);
768 Binder* binder = GetBinder();
772 binder->BeginEvent(name, 5);
774 CoherentBindInternal(binder, argument1);
775 CoherentBindInternal(binder, argument2);
776 CoherentBindInternal(binder, argument3);
777 CoherentBindInternal(binder, argument4);
778 CoherentBindInternal(binder, argument5);
786 inline void TriggerEventOnOSThread(
const char* name)
790 COHTML_TRIGGER_EVENT_SCOPE(TriggerEvent_0_Param, name);
791 Binder* binder = GetBinder();
795 HummingbirdTriggerEventOnOSThread(binder, name, 0, NULL, NULL);
801 template <
typename T1>
802 void TriggerEvent(
const char* name,
const T1& argument1)
804 COHTML_TRIGGER_EVENT_SCOPE(TriggerEvent_1_Param, name);
805 Binder* binder = GetBinder();
809 CoherentGenericBindFuncPtr functions[] = {
810 &CoherentGenericBind<T1>
812 const void* args[] = {
815 HummingbirdTriggerEventOnOSThread(binder, name, 1, functions, args);
821 template <
typename T1,
typename T2>
822 void TriggerEvent(
const char* name,
826 COHTML_TRIGGER_EVENT_SCOPE(TriggerEvent_2_Param, name);
827 Binder* binder = GetBinder();
831 CoherentGenericBindFuncPtr functions[] = {
832 &CoherentGenericBind<T1>,
833 &CoherentGenericBind<T2>
835 const void* args[] = {
839 HummingbirdTriggerEventOnOSThread(binder, name, 2, functions, args);
845 template <
typename T1,
typename T2,
typename T3>
846 void TriggerEvent(
const char* name,
851 COHTML_TRIGGER_EVENT_SCOPE(TriggerEvent_3_Param, name);
852 Binder* binder = GetBinder();
856 CoherentGenericBindFuncPtr functions[] = {
857 &CoherentGenericBind<T1>,
858 &CoherentGenericBind<T2>,
859 &CoherentGenericBind<T3>,
861 const void* args[] = {
866 HummingbirdTriggerEventOnOSThread(binder, name, 3, functions, args);
872 template <
typename T1,
typename T2,
typename T3,
typename T4>
873 void TriggerEvent(
const char* name,
879 COHTML_TRIGGER_EVENT_SCOPE(TriggerEvent_4_Param, name);
880 Binder* binder = GetBinder();
884 CoherentGenericBindFuncPtr functions[] = {
885 &CoherentGenericBind<T1>,
886 &CoherentGenericBind<T2>,
887 &CoherentGenericBind<T3>,
888 &CoherentGenericBind<T4>
890 const void* args[] = {
896 HummingbirdTriggerEventOnOSThread(binder, name, 4, functions, args);
902 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
903 void TriggerEventOnUIThread(
const char* name,
910 COHTML_TRIGGER_EVENT_SCOPE(TriggerEvent_5_Param, name);
911 Binder* binder = GetBinder();
915 CoherentGenericBindFuncPtr functions[] = {
916 &CoherentGenericBind<T1>,
917 &CoherentGenericBind<T2>,
918 &CoherentGenericBind<T3>,
919 &CoherentGenericBind<T4>,
920 &CoherentGenericBind<T5>,
922 const void* args[] = {
929 HummingbirdTriggerEventOnOSThread(binder, name, 5, functions, args);
Debugging class holding debug frame captured data and size. Passed to FrameCaptureCallback on View::B...
Definition: View.h:391
void TriggerEvent(const char *name, const T1 &argument1, const T2 &argument2)
Triggers a UI event.
Definition: View.h:690
void TriggerEvent(const char *name, const T1 &argument1)
Triggers a UI event.
Definition: View.h:672
OnMonotonicallyIncreasingTimeRequestFunc OnMonotonicallyIncreasingTimeRequest
Called during the advance of the views when accurate current time is needed The client should return ...
Definition: View.h:113
unsigned AvailableHeight
Height of the user's screen, in pixels, minus interface features like the Windows Taskbar...
Definition: View.h:198
All handling will be interrupted along with event bubbling. Eventual event listeners on the Node will...
Definition: View.h:168
The input type for text.
Definition: View.h:178
unsigned long long Size
Size in bytes of the data pointed by Data.
Definition: View.h:397
unsigned AvailableWidth
Width of the user's screen, in pixels, minus interface features like the Windows Taskbar.
Definition: View.h:195
Contains almost all Coherent namespaces, classes and functions.
Definition: DataStorage.h:38
Debugging class used for dumping the whole structure of the page DOM.
Definition: View.h:375
void(* FrameCaptureCallback)(void *userData, FrameCapture *capture)
Function signature of callback used in View::BeginCaptureDebugFrame and View::CaptureSingleDebugFrame...
Definition: View.h:406
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:760
A touch event.
Definition: InputEvents.h:63
ControlType
Definition: View.h:175
virtual void OnAudioStreamVolumeChanged(int id, float volume)
Called when an audio stream volume has changed.
Definition: View.h:344
Other non-input types.
Definition: View.h:181
The View will continue with the normal handling of the event.
Definition: View.h:164
OnRenderingTasksAvailableFunc OnRenderingTasksAvailable
Called when the View is completely advanced and laid-out.
Definition: View.h:109
void ExposeAsGlobal(const char *name, T *object)
Expose object as global variable.
Definition: View.h:584
virtual void OnAudioStreamEnded(int id)
Called when an audio stream ends and will no longer receive data.
Definition: View.h:336
void * UserData
Passed to the OnRenderingTasksAvailable and OnMonotonicallyIncreasingTimeRequest callbacks.
Definition: View.h:116
virtual void OnAudioStreamClosed(int id)
Called when an audio stream is destroyed.
Definition: View.h:300
virtual void OnAudioStreamPause(int id)
Called by the UI when a playing media element pauses.
Definition: View.h:314
IViewListener * Listener
The ViewListener is notified of events happening in the View.
Definition: View.h:99
A keyboard event.
Definition: InputEvents.h:159
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:289
unsigned Width
The Width of the View.
Definition: View.h:102
The View represents a UI page with its DOM, styles and JavaScript context. Think of the View as a who...
Definition: View.h:411
void TriggerEvent(const char *name, const T1 &argument1, const T2 &argument2, const T3 &argument3)
Triggers a UI event.
Definition: View.h:712
A gesture event.
Definition: InputEvents.h:209
unsigned Width
Full width in pixels.
Definition: View.h:189
Provides binding between C++ and the UI.
Definition: Binder.h:138
virtual void OnAudioStreamPlay(int id)
Called by the UI when a media element starts playing an audio stream.
Definition: View.h:307
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:325
const char * Data
Pointer to the binary capture data.
Definition: View.h:394
void CreateModel(const char *name, T *model)
Creates a model for binding.
Definition: View.h:629
void TriggerEvent(const char *name, const T1 &argument1, const T2 &argument2, const T3 &argument3, const T4 &argument4)
Triggers a UI event.
Definition: View.h:735
Represents a DOM element in the View - i.e. a DIV, the BODY etc.
Definition: NodeProxy.h:43
Interface that allows to listen for various events in the View.
Definition: View.h:217
bool EnableComplexCSSSelectorsStyling
Tells if to enable complex CSS selectors when doing style matching. By complex in this context we mea...
Definition: View.h:125
Holds the information about current screen.
Definition: View.h:186
Actions
Possible actions when deciding on input handling.
Definition: View.h:161
unsigned Height
Full height in pixels.
Definition: View.h:192
unsigned Height
The Height of the View.
Definition: View.h:105
unsigned PixelDepth
Pixel depth in bits.
Definition: View.h:204
Settings used when initializing a View.
Definition: View.h:96
unsigned ColorDepth
Color depth in bits.
Definition: View.h:201