1 #ifndef _ofxInteract_h_
2 #define _ofxInteract_h_
3 
4 #include "ofxCore.h"
5 
6 /*
7 Software License :
8 
9 Copyright (c) 2007-2015, The Open Effects Association Ltd. All rights reserved.
10 
11 Redistribution and use in source and binary forms, with or without
12 modification, are permitted provided that the following conditions are met:
13 
14     * Redistributions of source code must retain the above copyright notice,
15       this list of conditions and the following disclaimer.
16     * Redistributions in binary form must reproduce the above copyright notice,
17       this list of conditions and the following disclaimer in the documentation
18       and/or other materials provided with the distribution.
19     * Neither the name The Open Effects Association Ltd, nor the names of its
20       contributors may be used to endorse or promote products derived from this
21       software without specific prior written permission.
22 
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
27 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
30 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34 
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 /** @file ofxInteract.h
41 Contains the API for ofx plugin defined GUIs and interaction.
42 */
43 
44 #define kOfxInteractSuite "OfxInteractSuite"
45 
46 
47 /** @brief Blind declaration of an OFX interactive gui
48 */
49 typedef struct OfxInteract *OfxInteractHandle;
50 
51 /**
52    \addtogroup PropertiesAll
53 */
54 /*@{*/
55 /**
56    \defgroup PropertiesInteract Interact Property Definitions
57 
58 These are the list of properties used by the Interact API documented in \ref CustomInteractionPage.
59 */
60 /*@{*/
61 /** @brief The set of parameters on which a value change will trigger a redraw for an interact.
62 
63    - Type - string X N
64    - Property Set - interact instance property (read/write)
65    - Default - no values set
66    - Valid Values - the name of any parameter associated with this interact.
67 
68 If the interact is representing the state of some set of OFX parameters, then is will
69 need to be redrawn if any of those parameters' values change. This multi-dimensional property
70 links such parameters to the interact.
71 
72 The interact can be slaved to multiple parameters (setting index 0, then index 1 etc...)
73  */
74 #define kOfxInteractPropSlaveToParam "OfxInteractPropSlaveToParam"
75 
76 /** @brief The size of a real screen pixel under the interact's canonical projection.
77 
78    - Type - double X 2
79    - Property Set - interact instance and actions (read only)
80 
81  */
82 #define kOfxInteractPropPixelScale "OfxInteractPropPixelScale"
83 
84 
85 
86 /** @brief The background colour of the application behind an interact instance
87 
88     - Type - double X 3
89     - Property Set - read only on the interact instance and in argument to the ::kOfxInteractActionDraw action
90     - Valid Values - from 0 to 1
91 
92 The components are in the order red, green then blue.
93 
94  */
95 #define kOfxInteractPropBackgroundColour "OfxInteractPropBackgroundColour"
96 
97 /** @brief The suggested colour to draw a widget in an interact, typically for overlays.
98 
99     - Type - double X 3 if set, else double X 0
100     - Property Set - read only on the interact instance
101     - Default - 1.0
102     - Valid Values - greater than or equal to 0.0
103 
104 Some applications allow the user to specify colours of any overlay via a colour picker, this
105 property represents the value of that colour. Plugins are at liberty to use this or not when
106 they draw an overlay.
107 
108 If a host does not support such a colour, it should return kOfxStatReplyDefault
109 */
110 #define kOfxInteractPropSuggestedColour "OfxInteractPropSuggestedColour"
111 
112 /** @brief The position of the pen in an interact.
113 
114    - Type - double X 2
115    - Property Set - read only in argument to the ::kOfxInteractActionPenMotion, ::kOfxInteractActionPenDown and ::kOfxInteractActionPenUp actions
116 
117 This value passes the postion of the pen into an interact. This is in the interact's canonical coordinates.
118  */
119 #define kOfxInteractPropPenPosition "OfxInteractPropPenPosition"
120 
121 /** @brief The position of the pen in an interact in viewport coordinates.
122 
123    - Type - int X 2
124    - Property Set - read only in argument to the ::kOfxInteractActionPenMotion, ::kOfxInteractActionPenDown and ::kOfxInteractActionPenUp actions
125 
126 This value passes the postion of the pen into an interact. This is in the interact's openGL viewport coordinates, with 0,0 being at the bottom left.
127  */
128 #define kOfxInteractPropPenViewportPosition "OfxInteractPropPenViewportPosition"
129 
130 /** @brief The pressure of the pen in an interact.
131 
132    - Type - double X 1
133    - Property Set - read only in argument to the ::kOfxInteractActionPenMotion, ::kOfxInteractActionPenDown and ::kOfxInteractActionPenUp actions
134    - Valid Values - from 0 (no pressure) to 1 (maximum pressure)
135 
136 This is used to indicate the status of the 'pen' in an interact. If a pen has only two states (eg: a mouse button), these should map to 0.0 and 1.0.
137  */
138 #define kOfxInteractPropPenPressure "OfxInteractPropPenPressure"
139 
140 /** @brief Indicates whether the dits per component in the interact's openGL frame buffer
141 
142    - Type - int X 1
143    - Property Set - interact instance and descriptor (read only)
144 
145  */
146 #define kOfxInteractPropBitDepth "OfxInteractPropBitDepth"
147 
148 /** @brief Indicates whether the interact's frame buffer has an alpha component or not
149 
150    - Type - int X 1
151    - Property Set - interact instance and descriptor (read only)
152    - Valid Values - This must be one of
153        - 0 indicates no alpha component
154        - 1 indicates an alpha component
155  */
156 #define kOfxInteractPropHasAlpha "OfxInteractPropHasAlpha"
157 
158 /*@}*/
159 /*@}*/
160 
161 /**
162    \addtogroup ActionsAll
163 */
164 /*@{*/
165 /**
166    \defgroup InteractActions Interact Actions
167 
168 These are the list of actions passed to an interact's entry point function. For more details on how to deal with actions, see \ref InteractActions.
169 */
170 /*@{*/
171 
172 /** @brief
173 
174  This action is the first action passed to an interact. It is
175  where an interact defines how it behaves and the resources it needs to
176  function.
177  If not trapped, the default action is for the host to carry on as normal
178  Note that the handle passed in acts as a descriptor for, rather than an
179  instance of the interact.
180 
181  @param  handle handle to the interact descriptor, cast to an \ref OfxInteractHandle
182  @param  inArgs is redundant and is set to NULL
183  @param  outArgs is redundant and is set to NULL
184 
185 
186  \pre
187      - The plugin has been loaded and the effect described.
188 
189  @returns
190      -  \ref kOfxStatOK the action was trapped and all was well
191      -  \ref kOfxStatErrMemory in which case describe may be called again after a memory purge
192      -  \ref kOfxStatFailed something was wrong, the host should ignore the interact
193      -  \ref kOfxStatErrFatal
194  */
195 #define kOfxActionDescribeInteract kOfxActionDescribe
196 
197 
198 /** @brief
199 
200  This action is the first action passed to an interact instance after its creation.
201  It is there to allow a plugin to create any per-instance data structures it may need.
202 
203  @param  handle handle to the interact instance, cast to an \ref OfxInteractHandle
204  @param  inArgs is redundant and is set to NULL
205  @param  outArgs is redundant and is set to NULL
206 
207 
208  \pre
209      - \ref kOfxActionDescribe has been called on this interact
210 
211  \post
212      -  the instance pointer will be valid until the \ref kOfxActionDestroyInstance
213      action is passed to the plug-in with the same instance handle
214 
215  @returns
216      -  \ref kOfxStatOK the action was trapped and all was well
217      -  \ref kOfxStatReplyDefault the action was ignored, but all was well anyway
218      -  \ref kOfxStatErrFatal
219      -  \ref kOfxStatErrMemory in which case this may be called again after a memory purge
220      -  \ref kOfxStatFailed in which case the host should ignore this interact
221  */
222 #define kOfxActionCreateInstanceInteract kOfxActionCreateInstance
223 
224 /**@brief
225 
226  This action is the last passed to an interact's instance before its
227  destruction. It is there to allow a plugin to destroy any per-instance
228  data structures it may have created.
229 
230  @param handle handle to the interact instance, cast to an \ref OfxInteractHandle
231  @param inArgs is redundant and is set to NULL
232  @param outArgs is redundant and is set to NULL
233 
234  \pre
235      - \ref kOfxActionCreateInstance
236      has been called on the handle,
237      - the instance has not had any of its members destroyed yet
238 
239  \post
240      -  the instance pointer is no longer valid and any operation on it will be undefined
241 
242  @returns
243      To some extent, what is returned is moot, a bit like throwing an
244      exception in a C++ destructor, so the host should continue destruction
245      of the instance regardless
246      - \ref kOfxStatOK the action was trapped and all was well
247      - \ref kOfxStatReplyDefault the action was ignored as the effect had nothing to do
248      - \ref kOfxStatErrFatal
249      - \ref kOfxStatFailed something went wrong, but no error code appropriate.
250  */
251 #define kOfxActionDestroyInstanceInteract kOfxActionDestroyInstance
252 
253 /** @brief
254 
255  This action is issued to an interact whenever the host needs the plugin
256  to redraw the given interact. The interact should issue any openGL calls
257  it needs at this point.
258 
259  Note that the interact may (in the case of custom parameter GUIS) or may
260  not (in the case of image effect overlays) be required to swap buffers,
261  that is up to the kind of interact.
262 
263  @param  handle handle to an interact instance, cast to an \ref OfxInteractHandle
264  @param  inArgs has the following properties on an image effect plugin
265      - \ref kOfxPropEffectInstance a handle to the effect for which the interact has been,
266      - \ref kOfxInteractPropPixelScale the scale factor to convert cannonical pixels to screen pixels
267      - \ref kOfxInteractPropBackgroundColour the background colour of the application behind the current view
268      - \ref kOfxPropTime the effect time at which changed occured
269      - \ref kOfxImageEffectPropRenderScale the render scale applied to any image fetched
270 
271  @param  outArgs is redundant and is set to NULL
272 
273 \pre
274      - \ref kOfxActionCreateInstance has been called on the instance handle
275      - the openGL context for this interact has been set
276      -  the projection matrix will correspond to the interact's cannonical view
277 
278  @returns
279      - \ref kOfxStatOK the action was trapped and all was well
280      - \ref kOfxStatReplyDefault the action was ignored
281      - \ref kOfxStatErrFatal
282      - \ref kOfxStatFailed something went wrong, the host should ignore this interact in future
283  */
284 #define kOfxInteractActionDraw "OfxInteractActionDraw"
285 
286 /** @brief
287 
288  This action is issued whenever the pen moves an the interact's has
289  focus. It should be issued whether the pen is currently up or down.
290  No openGL calls should be issued by the plug-in during this action.
291 
292 
293  @param  handle handle to an interact instance, cast to an \ref OfxInteractHandle
294  @param  inArgs has the following properties on an image effect plugin
295      - \ref kOfxPropEffectInstance a handle to the effect for which the interact has been,
296      - \ref kOfxInteractPropPixelScale the scale factor to convert cannonical pixels to screen pixels
297      - \ref kOfxInteractPropBackgroundColour the background colour of the application behind the current view
298      - \ref kOfxPropTime the effect time at which changed occured
299      - \ref kOfxImageEffectPropRenderScale the render scale applied to any image fetched
300      - \ref kOfxInteractPropPenPosition postion of the pen in,
301      - \ref kOfxInteractPropPenViewportPosition position of the pen in,
302      - \ref kOfxInteractPropPenPressure the pressure of the pen,
303 
304  @param  outArgs is redundant and is set to NULL
305 
306 \pre
307      - \ref  kOfxActionCreateInstance
308      has been called on the instance handle
309      - the current instance handle has had
310      \ref kOfxInteractActionGainFocus called on it
311 
312 \post
313      -  if the instance returns \ref kOfxStatOK the host should not
314      pass the pen motion to any other interactive object it may own that
315      shares the same view.
316 
317  @returns
318      -  \ref kOfxStatOK the action was trapped and the host should not pass the event to other objects it may own
319      -  \ref kOfxStatReplyDefault the action was not trapped and the host can deal with it if it wants
320  */
321 #define kOfxInteractActionPenMotion "OfxInteractActionPenMotion"
322 
323 /**@brief
324 
325  This action is issued when a pen transitions for the 'up' to the 'down'
326  state.
327  No openGL calls should be issued by the plug-in during this action.
328 
329 
330  @param  handle handle to an interact instance, cast to an \ref OfxInteractHandle
331  @param  inArgs has the following properties on an image effect plugin,
332      - \ref kOfxPropEffectInstance a handle to the effect for which the interact has been,
333      - \ref kOfxInteractPropPixelScale the scale factor to convert cannonical pixels to screen pixels
334      - \ref kOfxInteractPropBackgroundColour the background colour of the application behind the current view
335      - \ref kOfxPropTime the effect time at which changed occured
336      - \ref kOfxImageEffectPropRenderScale the render scale applied to any image fetched
337      - \ref kOfxInteractPropPenPosition position of the pen in
338      - \ref kOfxInteractPropPenViewportPosition position of the pen in
339      - \ref kOfxInteractPropPenPressure the pressure of the pen
340 
341  @param  outArgs is redundant and is set to NULL
342 
343  \pre
344      -  \ref kOfxActionCreateInstance
345      has been called on the instance handle,
346      -  the current instance handle has had
347      \ref kOfxInteractActionGainFocus
348      called on it
349 
350 \post
351      -  if the instance returns \ref kOfxStatOK, the host should not
352      pass the pen motion to any other interactive object it may own that
353      shares the same view.
354 
355  @returns
356      -  \ref kOfxStatOK, the action was trapped and the host should not pass the event to other objects it may own
357      -  \ref kOfxStatReplyDefault , the action was not trapped and the host can deal with it if it wants
358  */
359 #define kOfxInteractActionPenDown   "OfxInteractActionPenDown"
360 
361 /**@brief
362 
363  This action is issued when a pen transitions for the 'down' to the 'up'
364  state.
365  No openGL calls should be issued by the plug-in during this action.
366 
367  @param  handle handle to an interact instance, cast to an \ref OfxInteractHandle
368  @param  inArgs has the following properties on an image effect plugin,
369  - \ref kOfxPropEffectInstance a handle to the effect for which the interact has been,
370  - \ref kOfxInteractPropPixelScale the scale factor to convert cannonical pixels to screen pixels
371  - \ref kOfxInteractPropBackgroundColour the background colour of the application behind the current view
372  - \ref kOfxPropTime the effect time at which changed occured
373  - \ref kOfxImageEffectPropRenderScale the render scale applied to any image fetched
374  - \ref kOfxInteractPropPenPosition position of the pen in
375  - \ref kOfxInteractPropPenViewportPosition position of the pen in
376  - \ref kOfxInteractPropPenPressure the pressure of the pen
377 
378  @param  outArgs is redundant and is set to NULL
379 
380  \pre
381      -  \ref kOfxActionCreateInstance
382      has been called on the instance handle,
383      -  the current instance handle has had
384      \ref kOfxInteractActionGainFocus called on it
385 
386  \post
387      -  if the instance returns \ref kOfxStatOK, the host should not
388      pass the pen motion to any other interactive object it may own that
389      shares the same view.
390 
391  @returns
392      -  \ref kOfxStatOK, the action was trapped and the host should not pass the event to other objects it may own
393      -  \ref kOfxStatReplyDefault , the action was not trapped and the host can deal with it if it wants
394  */
395 #define kOfxInteractActionPenUp     "OfxInteractActionPenUp"
396 
397 /**@brief
398 
399  This action is issued when a key on the keyboard is depressed.
400  No openGL calls should be issued by the plug-in during this action.
401 
402  @param handle handle to an interact instance, cast to an \ref OfxInteractHandle
403  @param inArgs has the following properties on an image effect plugin
404      -  \ref kOfxPropEffectInstance a handle to the effect for which the interact has been,
405      - \ref kOfxPropKeySym single integer value representing the key that was manipulated,
406      this may not have a UTF8 representation (eg: a return key)
407      -  \ref kOfxPropKeyString UTF8 string representing a character key that was pressed, some
408      keys have no UTF8 encoding, in which case this is ""
409      -  \ref kOfxPropTime the effect time at which changed occured
410      - \ref kOfxImageEffectPropRenderScale the render scale applied to any image fetched
411 
412  @param  outArgs is redundant and is set to NULL
413 
414 \pre
415      - \ref kOfxActionCreateInstance
416      has been called on the instance handle,
417      -  the current instance handle has had
418      \ref kOfxInteractActionGainFocus called on it
419 
420  \post
421      -  if the instance returns \ref kOfxStatOK, the host should not
422      pass the pen motion to any other interactive object it may own that
423      shares the same focus.
424 
425  @returns
426      - \ref kOfxStatOK , the action was trapped and the host should not pass the event to other objects it may own
427      - \ref kOfxStatReplyDefault , the action was not trapped and the host can deal with it if it wants
428  */
429 #define kOfxInteractActionKeyDown   "OfxInteractActionKeyDown"
430 
431 /**@brief
432  This action is issued when a key on the keyboard is released.
433  No openGL calls should be issued by the plug-in during this action.
434 
435  @param handle handle to an interact instance, cast to an \ref OfxInteractHandle
436  @param inArgs has the following properties on an image effect plugin
437      -  \ref kOfxPropEffectInstance a handle to the effect for which the interact has been,
438      - \ref kOfxPropKeySym single integer value representing the key that was manipulated,
439      this may not have a UTF8 representation (eg: a return key)
440      -  \ref kOfxPropKeyString UTF8 string representing a character key that was pressed, some
441      keys have no UTF8 encoding, in which case this is ""
442      -  \ref kOfxPropTime the effect time at which changed occured
443      - \ref kOfxImageEffectPropRenderScale the render scale applied to any image fetched
444 
445  @param  outArgs is redundant and is set to NULL
446 
447  \pre
448      - \ref kOfxActionCreateInstance
449      has been called on the instance handle,
450      -  the current instance handle has had
451      \ref kOfxInteractActionGainFocus called on it
452 
453  \post
454      -  if the instance returns \ref kOfxStatOK, the host should not
455      pass the pen motion to any other interactive object it may own that
456      shares the same focus.
457 
458  @returns
459      - \ref kOfxStatOK , the action was trapped and the host should not pass the event to other objects it may own
460      - \ref kOfxStatReplyDefault , the action was not trapped and the host can deal with it if it wants
461  */
462 #define kOfxInteractActionKeyUp     "OfxInteractActionKeyUp"
463 
464 /**@brief
465  This action is issued when a key on the keyboard is repeated.
466  No openGL calls should be issued by the plug-in during this action.
467 
468  @param handle handle to an interact instance, cast to an \ref OfxInteractHandle
469  @param inArgs has the following properties on an image effect plugin
470      -  \ref kOfxPropEffectInstance a handle to the effect for which the interact has been,
471      - \ref kOfxPropKeySym single integer value representing the key that was manipulated,
472      this may not have a UTF8 representation (eg: a return key)
473      -  \ref kOfxPropKeyString UTF8 string representing a character key that was pressed, some
474      keys have no UTF8 encoding, in which case this is ""
475      -  \ref kOfxPropTime the effect time at which changed occured
476      - \ref kOfxImageEffectPropRenderScale the render scale applied to any image fetched
477 
478  @param  outArgs is redundant and is set to NULL
479 
480  \pre
481      - \ref kOfxActionCreateInstance
482      has been called on the instance handle,
483      -  the current instance handle has had
484      \ref kOfxInteractActionGainFocus called on it
485 
486  \post
487      -  if the instance returns \ref kOfxStatOK, the host should not
488      pass the pen motion to any other interactive object it may own that
489      shares the same focus.
490 
491  @returns
492      - \ref kOfxStatOK , the action was trapped and the host should not pass the event to other objects it may own
493      - \ref kOfxStatReplyDefault , the action was not trapped and the host can deal with it if it wants
494  */
495 #define kOfxInteractActionKeyRepeat     "OfxInteractActionKeyRepeat"
496 
497 /**@brief
498  This action is issued when an interact gains input focus.
499  No openGL calls should be issued by the plug-in during this action.
500 
501  @param handle handle to an interact instance, cast to an \ref OfxInteractHandle
502  @param inArgs has the following properties on an image effect plugin
503      - \ref kOfxPropEffectInstance a handle to the effect for which the interact is being used on,
504      - \ref kOfxInteractPropPixelScale the scale factor to convert cannonical pixels to screen pixels,
505      - \ref kOfxInteractPropBackgroundColour the background colour of the application behind the current view
506      - \ref kOfxPropTime the effect time at which changed occured
507      - \ref kOfxImageEffectPropRenderScale the render scale applied to any image fetched
508 
509  @param  outArgs is redundant and is set to NULL
510 
511  \pre
512      - \ref kOfxActionCreateInstance
513  has been called on the instance handle,
514 
515 
516  @returns
517      - \ref kOfxStatOK  the action was trapped
518      - \ref kOfxStatReplyDefault  the action was not trapped
519  */
520 #define kOfxInteractActionGainFocus "OfxInteractActionGainFocus"
521 
522 /**@brief
523  This action is issued when an interact loses input focus.
524  No openGL calls should be issued by the plug-in during this action.
525 
526  @param handle handle to an interact instance, cast to an \ref OfxInteractHandle
527  @param inArgs has the following properties on an image effect plugin
528      - \ref kOfxPropEffectInstance a handle to the effect for which the interact is being used on,
529      - \ref kOfxInteractPropPixelScale the scale factor to convert cannonical pixels to screen pixels,
530      - \ref kOfxInteractPropBackgroundColour the background colour of the application behind the current view
531      - \ref kOfxPropTime the effect time at which changed occured
532      - \ref kOfxImageEffectPropRenderScale the render scale applied to any image fetched
533 
534  @param  outArgs is redundant and is set to NULL
535 
536  \pre
537      - \ref kOfxActionCreateInstance
538      has been called on the instance handle,
539 
540 
541  @returns
542      - \ref kOfxStatOK  the action was trapped
543      - \ref kOfxStatReplyDefault  the action was not trapped
544  */
545 #define kOfxInteractActionLoseFocus "OfxInteractActionLoseFocus"
546 
547 /*@}*/
548 /*@}*/
549 
550 /** @brief OFX suite that allows an effect to interact with an openGL window so as to provide custom interfaces.
551 
552 */
553 typedef struct OfxInteractSuiteV1 {
554   /** @brief Requests an openGL buffer swap on the interact instance */
555   OfxStatus (*interactSwapBuffers)(OfxInteractHandle interactInstance);
556 
557   /** @brief Requests a redraw of the interact instance */
558   OfxStatus (*interactRedraw)(OfxInteractHandle interactInstance);
559 
560   /** @brief Gets the property set handle for this interact handle */
561   OfxStatus (*interactGetPropertySet)(OfxInteractHandle interactInstance,
562 				      OfxPropertySetHandle *property);
563 } OfxInteractSuiteV1;
564 
565 #ifdef __cplusplus
566 }
567 #endif
568 
569 #endif
570