Separate C# classes into Internal and Public
[platform/core/uifw/dali-toolkit.git] / plugins / dali-sharp / sharp / public / CustomView.cs
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 namespace Dali
19 {
20     public class CustomView : ViewWrapper
21     {
22         public CustomView(string typeName, CustomViewBehaviour behaviour) : base(typeName, new ViewWrapperImpl(behaviour))
23         {
24             // Registering CustomView virtual functions to viewWrapperImpl delegates.
25             viewWrapperImpl.OnStageConnection = new ViewWrapperImpl.OnStageConnectionDelegate(OnStageConnection);
26             viewWrapperImpl.OnStageDisconnection = new ViewWrapperImpl.OnStageDisconnectionDelegate(OnStageDisconnection);
27             viewWrapperImpl.OnChildAdd = new ViewWrapperImpl.OnChildAddDelegate(OnChildAdd);
28             viewWrapperImpl.OnChildRemove = new ViewWrapperImpl.OnChildRemoveDelegate(OnChildRemove);
29             viewWrapperImpl.OnPropertySet = new ViewWrapperImpl.OnPropertySetDelegate(OnPropertySet);
30             viewWrapperImpl.OnSizeSet = new ViewWrapperImpl.OnSizeSetDelegate(OnSizeSet);
31             viewWrapperImpl.OnSizeAnimation = new ViewWrapperImpl.OnSizeAnimationDelegate(OnSizeAnimation);
32             viewWrapperImpl.OnTouch = new ViewWrapperImpl.OnTouchDelegate(OnTouch);
33             viewWrapperImpl.OnHover = new ViewWrapperImpl.OnHoverDelegate(OnHover);
34             viewWrapperImpl.OnKey = new ViewWrapperImpl.OnKeyDelegate(OnKey);
35             viewWrapperImpl.OnWheel = new ViewWrapperImpl.OnWheelDelegate(OnWheel);
36             viewWrapperImpl.OnRelayout = new ViewWrapperImpl.OnRelayoutDelegate(OnRelayout);
37             viewWrapperImpl.OnSetResizePolicy = new ViewWrapperImpl.OnSetResizePolicyDelegate(OnSetResizePolicy);
38             viewWrapperImpl.GetNaturalSize = new ViewWrapperImpl.GetNaturalSizeDelegate(GetNaturalSize);
39             viewWrapperImpl.CalculateChildSize = new ViewWrapperImpl.CalculateChildSizeDelegate(CalculateChildSize);
40             viewWrapperImpl.GetHeightForWidth = new ViewWrapperImpl.GetHeightForWidthDelegate(GetHeightForWidth);
41             viewWrapperImpl.GetWidthForHeight = new ViewWrapperImpl.GetWidthForHeightDelegate(GetWidthForHeight);
42             viewWrapperImpl.RelayoutDependentOnChildrenDimension = new ViewWrapperImpl.RelayoutDependentOnChildrenDimensionDelegate(RelayoutDependentOnChildren);
43             viewWrapperImpl.RelayoutDependentOnChildren = new ViewWrapperImpl.RelayoutDependentOnChildrenDelegate(RelayoutDependentOnChildren);
44             viewWrapperImpl.OnCalculateRelayoutSize = new ViewWrapperImpl.OnCalculateRelayoutSizeDelegate(OnCalculateRelayoutSize);
45             viewWrapperImpl.OnLayoutNegotiated = new ViewWrapperImpl.OnLayoutNegotiatedDelegate(OnLayoutNegotiated);
46             viewWrapperImpl.OnControlChildAdd = new ViewWrapperImpl.OnControlChildAddDelegate(OnControlChildAdd);
47             viewWrapperImpl.OnControlChildRemove = new ViewWrapperImpl.OnControlChildRemoveDelegate(OnControlChildRemove);
48             viewWrapperImpl.OnStyleChange = new ViewWrapperImpl.OnStyleChangeDelegate(OnStyleChange);
49             viewWrapperImpl.OnAccessibilityActivated = new ViewWrapperImpl.OnAccessibilityActivatedDelegate(OnAccessibilityActivated);
50             viewWrapperImpl.OnAccessibilityPan = new ViewWrapperImpl.OnAccessibilityPanDelegate(OnAccessibilityPan);
51             viewWrapperImpl.OnAccessibilityTouch = new ViewWrapperImpl.OnAccessibilityTouchDelegate(OnAccessibilityTouch);
52             viewWrapperImpl.OnAccessibilityValueChange = new ViewWrapperImpl.OnAccessibilityValueChangeDelegate(OnAccessibilityValueChange);
53             viewWrapperImpl.OnAccessibilityZoom = new ViewWrapperImpl.OnAccessibilityZoomDelegate(OnAccessibilityZoom);
54             viewWrapperImpl.OnFocusGained = new ViewWrapperImpl.OnFocusGainedDelegate(OnFocusGained);
55             viewWrapperImpl.OnFocusLost = new ViewWrapperImpl.OnFocusLostDelegate(OnFocusLost);
56             viewWrapperImpl.GetNextFocusableActor = new ViewWrapperImpl.GetNextFocusableActorDelegate(GetNextFocusableView);
57             viewWrapperImpl.OnFocusChangeCommitted = new ViewWrapperImpl.OnFocusChangeCommittedDelegate(OnFocusChangeCommitted);
58             viewWrapperImpl.OnFocusEnter = new ViewWrapperImpl.OnFocusEnterDelegate(OnFocusEnter);
59             viewWrapperImpl.OnPinch = new ViewWrapperImpl.OnPinchDelegate(OnPinch);
60             viewWrapperImpl.OnPan = new ViewWrapperImpl.OnPanDelegate(OnPan);
61             viewWrapperImpl.OnTap = new ViewWrapperImpl.OnTapDelegate(OnTap);
62             viewWrapperImpl.OnLongPress = new ViewWrapperImpl.OnLongPressDelegate(OnLongPress);
63
64             // By default, we do not want the position to use the anchor point
65             this.PositionUsesAnchorPoint = false;
66
67             // Make sure CustomView is initialized.
68             OnInitialize();
69
70             // Set the StyleName the name of the View
71             // We have to do this because the StyleManager on Native side can't workout it out
72             // This will also ensure that the style of views/visuals initialized above are applied by the style manager.
73             SetStyleName( this.GetType().Name );
74         }
75
76         /**
77          * @brief Set the background with a property map.
78          *
79          * @param[in] map The background property map.
80          */
81         public void SetBackground(Dali.Property.Map map)
82         {
83             viewWrapperImpl.SetBackground(map);
84         }
85
86         /**
87          * @brief Allows deriving classes to enable any of the gesture detectors that are available.
88          *
89          * Gesture detection can be enabled one at a time or in bitwise format as shown:
90          * @code
91          * EnableGestureDetection(Gesture.Type.Pinch | Gesture.Type.Tap | Gesture.Type.Pan));
92          * @endcode
93          * @param[in]  type  The gesture type(s) to enable.
94          */
95         public void EnableGestureDetection(Gesture.GestureType type)
96         {
97             viewWrapperImpl.EnableGestureDetection(type);
98         }
99
100         /**
101          * @brief Allows deriving classes to disable any of the gesture detectors.
102          *
103          * Like EnableGestureDetection, this can also be called using bitwise or.
104          * @param[in]  type  The gesture type(s) to disable.
105          * @see EnableGetureDetection
106          */
107         public void DisableGestureDetection(Gesture.GestureType type)
108         {
109             viewWrapperImpl.DisableGestureDetection(type);
110         }
111
112         /**
113          * @brief Sets whether this control supports two dimensional
114          * keyboard navigation (i.e. whether it knows how to handle the
115          * keyboard focus movement between its child views).
116          *
117          * The control doesn't support it by default.
118          * @param[in] isSupported Whether this control supports two dimensional keyboard navigation.
119          */
120         public void SetFocusNavigationSupport(bool isSupported)
121         {
122             viewWrapperImpl.SetFocusNavigationSupport(isSupported);
123         }
124
125         /**
126          * @brief Gets whether this control supports two dimensional keyboard navigation.
127          *
128          * @return true if this control supports two dimensional keyboard navigation.
129          */
130         public bool IsFocusNavigationSupported()
131         {
132             return viewWrapperImpl.IsFocusNavigationSupported();
133         }
134
135         /**
136          * @brief Sets whether this control is a focus group for keyboard navigation.
137          *
138          * (i.e. the scope of keyboard focus movement
139          * can be limitied to its child views). The control is not a focus group by default.
140          * @param[in] isFocusGroup Whether this control is set as a focus group for keyboard navigation.
141          */
142         public void SetAsFocusGroup(bool isFocusGroup)
143         {
144             viewWrapperImpl.SetAsFocusGroup(isFocusGroup);
145         }
146
147         /**
148          * @brief Gets whether this control is a focus group for keyboard navigation.
149          *
150          * @return true if this control is set as a focus group for keyboard navigation.
151          */
152         public bool IsFocusGroup()
153         {
154             return viewWrapperImpl.IsFocusGroup();
155         }
156
157         /**
158          * @brief Called by the AccessibilityManager to activate the Control.
159          * @SINCE_1_0.0
160          */
161         public void AccessibilityActivate()
162         {
163             viewWrapperImpl.AccessibilityActivate();
164         }
165
166         /**
167          * @brief Called by the KeyboardFocusManager.
168          */
169         public void FocusEnter()
170         {
171             viewWrapperImpl.FocusEnter();
172         }
173
174         /**
175          * @brief Called by the KeyInputFocusManager to emit key event signals.
176          *
177          * @param[in] key The key event.
178          * @return True if the event was consumed.
179          */
180         internal bool EmitKeyEventSignal(Key key)
181         {
182             return viewWrapperImpl.EmitKeyEventSignal(key);
183         }
184
185         /**
186          * @brief Request a relayout, which means performing a size negotiation on this view, its parent and children (and potentially whole scene).
187          *
188          * This method can also be called from a derived class every time it needs a different size.
189          * At the end of event processing, the relayout process starts and
190          * all controls which requested Relayout will have their sizes (re)negotiated.
191          *
192          * @note RelayoutRequest() can be called multiple times; the size negotiation is still
193          * only performed once, i.e. there is no need to keep track of this in the calling side.
194          */
195         protected void RelayoutRequest()
196         {
197             viewWrapperImpl.RelayoutRequest();
198         }
199
200         /**
201          * @brief Provides the View implementation of GetHeightForWidth.
202          * @param width Width to use.
203          * @return The height based on the width.
204          */
205         protected float GetHeightForWidthBase(float width)
206         {
207             return viewWrapperImpl.GetHeightForWidthBase( width );
208         }
209
210         /**
211          * @brief Provides the View implementation of GetWidthForHeight.
212          * @param height Height to use.
213          * @return The width based on the height.
214          */
215         protected float GetWidthForHeightBase(float height)
216         {
217             return viewWrapperImpl.GetWidthForHeightBase( height );
218         }
219
220         /**
221          * @brief Calculate the size for a child using the base view object.
222          *
223          * @param[in] child The child view to calculate the size for
224          * @param[in] dimension The dimension to calculate the size for. E.g. width or height
225          * @return Return the calculated size for the given dimension. If more than one dimension is requested, just return the first one found.
226          */
227         protected float CalculateChildSizeBase(View child, DimensionType dimension)
228         {
229             return viewWrapperImpl.CalculateChildSizeBase( child, dimension );
230         }
231
232         /**
233          * @brief Determine if this view is dependent on it's children for relayout from the base class.
234          *
235          * @param dimension The dimension(s) to check for
236          * @return Return if the view is dependent on it's children.
237          */
238         protected bool RelayoutDependentOnChildrenBase(DimensionType dimension)
239         {
240             return viewWrapperImpl.RelayoutDependentOnChildrenBase( dimension );
241         }
242
243         /**
244          * @brief Determine if this view is dependent on it's children for relayout from the base class.
245          *
246          * @param dimension The dimension(s) to check for
247          * @return Return if the view is dependent on it's children.
248          */
249         protected bool RelayoutDependentOnChildrenBase()
250         {
251             return viewWrapperImpl.RelayoutDependentOnChildrenBase();
252         }
253
254         /**
255          * @brief Register a visual by Property Index, linking an View to visual when required.
256          * In the case of the visual being an view or control deeming visual not required then visual should be an empty handle.
257          * No parenting is done during registration, this should be done by derived class.
258          *
259          * @param[in] index The Property index of the visual, used to reference visual
260          * @param[in] visual The visual to register
261          * @note Derived class should not call visual.SetOnStage(view). It is the responsibility of the base class to connect/disconnect registered visual to stage.
262          *       Use below API with enabled set to false if derived class wishes to control when visual is staged.
263          */
264         protected void RegisterVisual(int index, VisualBase visual)
265         {
266             viewWrapperImpl.RegisterVisual( index, visual );
267         }
268
269         /**
270          * @brief Register a visual by Property Index, linking an View to visual when required.
271          * In the case of the visual being an view or control deeming visual not required then visual should be an empty handle.
272          * If enabled is false then the visual is not set on stage until enabled by the derived class.
273          * @see EnableVisual
274          *
275          * @param[in] index The Property index of the visual, used to reference visual
276          * @param[in] visual The visual to register
277          * @param[in] enabled false if derived class wants to control when visual is set on stage.
278          *
279          */
280         protected void RegisterVisual(int index, VisualBase visual, bool enabled)
281         {
282             viewWrapperImpl.RegisterVisual( index, visual, enabled );
283         }
284
285         /**
286          * @brief Erase the entry matching the given index from the list of registered visuals
287          * @param[in] index The Property index of the visual, used to reference visual
288          *
289          */
290         protected void UnregisterVisual(int index)
291         {
292             viewWrapperImpl.UnregisterVisual( index );
293         }
294
295         /**
296          * @brief Retrieve the visual associated with the given property index.
297          *
298          * @param[in] index The Property index of the visual.
299          * @return The registered visual if exist, otherwise empty handle.
300          * @note For managing object life-cycle, do not store the returned visual as a member which increments its reference count.
301          */
302         protected VisualBase GetVisual(int index)
303         {
304             return viewWrapperImpl.GetVisual( index );
305         }
306
307         /**
308          * @brief Sets the given visual to be displayed or not when parent staged.
309          *
310          * @param[in] index The Property index of the visual
311          * @param[in] enable flag to set enabled or disabled.
312          */
313         protected void EnableVisual(int index, bool enable)
314         {
315             viewWrapperImpl.EnableVisual( index, enable );
316         }
317
318         /**
319          * @brief Queries if the given visual is to be displayed when parent staged.
320          *
321          * @param[in] index The Property index of the visual
322          * @return bool whether visual is enabled or not
323          */
324         protected bool IsVisualEnabled(int index)
325         {
326             return viewWrapperImpl.IsVisualEnabled( index );
327         }
328
329         /**
330          * @brief Create a transition effect on the control.
331          *
332          * @param[in] transitionData The transition data describing the effect to create
333          * @return A handle to an animation defined with the given effect, or an empty
334          * handle if no properties match.
335          */
336         protected Animation CreateTransition(TransitionData transitionData)
337         {
338             return viewWrapperImpl.CreateTransition( transitionData );
339         }
340
341         /**
342          * @brief Emits KeyInputFocusGained signal if true else emits KeyInputFocusLost signal
343          *
344          * Should be called last by the control after it acts on the Input Focus change.
345          *
346          * @param[in] focusGained True if gained, False if lost
347          */
348         protected void EmitFocusSignal(bool focusGained)
349         {
350             viewWrapperImpl.EmitFocusSignal( focusGained );
351         }
352
353         /**
354          * @brief This method is called after the Control has been initialized.
355          *
356          * Derived classes should do any second phase initialization by overriding this method.
357          */
358         public virtual void OnInitialize()
359         {
360         }
361
362         /**
363          * @brief Called after the view has been connected to the stage.
364          *
365          * When an view is connected, it will be directly or indirectly parented to the root View.
366          * @param[in] depth The depth in the hierarchy for the view
367          *
368          * @note The root View is provided automatically by Dali::Stage, and is always considered to be connected.
369          * When the parent of a set of views is connected to the stage, then all of the children
370          * will received this callback.
371          * For the following view tree, the callback order will be A, B, D, E, C, and finally F.
372          *
373          * @code
374          *
375          *       A (parent)
376          *      / \
377          *     B   C
378          *    / \   \
379          *   D   E   F
380          *
381          * @endcode
382          * @param[in] depth The depth in the hierarchy for the view
383          */
384         public virtual void OnStageConnection(int depth)
385         {
386         }
387
388         /**
389          * @brief Called after the view has been disconnected from Stage.
390          *
391          * If an view is disconnected it either has no parent, or is parented to a disconnected view.
392          *
393          * @note When the parent of a set of views is disconnected to the stage, then all of the children
394          * will received this callback, starting with the leaf views.
395          * For the following view tree, the callback order will be D, E, B, F, C, and finally A.
396          *
397          * @code
398          *
399          *       A (parent)
400          *      / \
401          *     B   C
402          *    / \   \
403          *   D   E   F
404          *
405          * @endcode
406          */
407         public virtual void OnStageDisconnection()
408         {
409         }
410
411         /**
412          * @brief Called after a child has been added to the owning view.
413          *
414          * @param[in] child The child which has been added
415          */
416         public virtual void OnChildAdd(View view)
417         {
418         }
419
420         /**
421          * @brief Called after the owning view has attempted to remove a child( regardless of whether it succeeded or not ).
422          *
423          * @param[in] child The child being removed
424          */
425         public virtual void OnChildRemove(View View)
426         {
427         }
428
429         /**
430          * @brief Called when the owning view property is set.
431          *
432          * @param[in] index The Property index that was set
433          * @param[in] propertyValue The value to set
434          */
435         public virtual void OnPropertySet(int index, Dali.Property.Value propertyValue)
436         {
437         }
438
439         /**
440          * @brief Called when the owning view's size is set e.g. using View::SetSize().
441          *
442          * @param[in] targetSize The target size. Note that this target size may not match the size returned via View.GetTargetSize.
443          */
444         public virtual void OnSizeSet(Vector3 targetSize)
445         {
446         }
447
448         /**
449          * @brief Called when the owning view's size is animated e.g. using Animation::AnimateTo( Property( view, View::Property::SIZE ), ... ).
450          *
451          * @param[in] animation The object which is animating the owning view.
452          * @param[in] targetSize The target size. Note that this target size may not match the size returned via @ref View.GetTargetSize.
453          */
454         public virtual void OnSizeAnimation(Animation animation, Vector3 targetSize)
455         {
456         }
457
458         /**
459          * @DEPRECATED_1_1.37 Connect to TouchSignal() instead.
460          *
461          * @brief Called after a touch-event is received by the owning view.
462          *
463          * @param[in] touch The touch event
464          * @return True if the event should be consumed.
465          * @note CustomViewBehaviour.REQUIRES_TOUCH_EVENTS must be enabled during construction. See CustomView(ViewWrapperImpl.CustomViewBehaviour behaviour).
466          */
467         public virtual bool OnTouch(Touch touch)
468         {
469             return false; // Do not consume
470         }
471
472         /**
473          * @brief Called after a hover-event is received by the owning view.
474          *
475          * @param[in] hover The hover event
476          * @return True if the hover event should be consumed.
477          * @note CustomViewBehaviour.REQUIRES_HOVER_EVENTS must be enabled during construction. See CustomView(ViewWrapperImpl.CustomViewBehaviour behaviour).
478          */
479         public virtual bool OnHover(Hover hover)
480         {
481             return false; // Do not consume
482         }
483
484         /**
485          * @brief Called after a key-event is received by the view that has had its focus set.
486          *
487          * @param[in] key the Key Event
488          * @return True if the event should be consumed.
489          */
490         public virtual bool OnKey(Key key)
491         {
492             return false; // Do not consume
493         }
494
495         /**
496          * @brief Called after a wheel-event is received by the owning view.
497          *
498          * @param[in] wheel The wheel event
499          * @return True if the event should be consumed.
500          * @note CustomViewBehaviour.REQUIRES_WHEEL_EVENTS must be enabled during construction. See CustomView(ViewWrapperImpl.CustomViewBehaviour behaviour).
501          */
502         public virtual bool OnWheel(Wheel wheel)
503         {
504             return false; // Do not consume
505         }
506
507         /**
508          * @brief Called after the size negotiation has been finished for this control.
509          *
510          * The control is expected to assign this given size to itself/its children.
511          *
512          * Should be overridden by derived classes if they need to layout
513          * views differently after certain operations like add or remove
514          * views, resize or after changing specific properties.
515          *
516          * @param[in]      size       The allocated size.
517          * @param[in,out]  container  The control should add views to this container that it is not able
518          *                            to allocate a size for.
519          * @note  As this function is called from inside the size negotiation algorithm, you cannot
520          * call RequestRelayout (the call would just be ignored).
521          */
522         public virtual void OnRelayout(Vector2 size, RelayoutContainer container)
523         {
524         }
525
526         /**
527          * @brief Notification for deriving classes
528          *
529          * @param[in] policy The policy being set
530          * @param[in] dimension The dimension the policy is being set for
531          */
532         public virtual void OnSetResizePolicy(ResizePolicyType policy, DimensionType dimension)
533         {
534         }
535
536         /**
537          * @brief Return the natural size of the view.
538          *
539          * @return The view's natural size
540          */
541         public virtual Vector3 GetNaturalSize()
542         {
543             return new Vector3(0.0f, 0.0f, 0.0f);
544         }
545
546         /**
547          * @brief Calculate the size for a child.
548          *
549          * @param[in] child The child view to calculate the size for
550          * @param[in] dimension The dimension to calculate the size for. E.g. width or height.
551          * @return Return the calculated size for the given dimension.
552          */
553         public virtual float CalculateChildSize(View child, DimensionType dimension)
554         {
555             return viewWrapperImpl.CalculateChildSizeBase( child, dimension );
556         }
557
558         /**
559          * @brief This method is called during size negotiation when a height is required for a given width.
560          *
561          * Derived classes should override this if they wish to customize the height returned.
562          *
563          * @param width Width to use.
564          * @return The height based on the width.
565          */
566         public virtual float GetHeightForWidth(float width)
567         {
568             return viewWrapperImpl.GetHeightForWidthBase( width );
569         }
570
571         /**
572          * @brief This method is called during size negotiation when a width is required for a given height.
573          *
574          * Derived classes should override this if they wish to customize the width returned.
575          *
576          * @param height Height to use.
577          * @return The width based on the width.
578          */
579         public virtual float GetWidthForHeight(float height)
580         {
581             return viewWrapperImpl.GetWidthForHeightBase( height );
582         }
583
584         /**
585          * @brief Determine if this view is dependent on it's children for relayout.
586          *
587          * @param dimension The dimension(s) to check for
588          * @return Return if the view is dependent on it's children.
589          */
590         public virtual bool RelayoutDependentOnChildren(DimensionType dimension)
591         {
592             return viewWrapperImpl.RelayoutDependentOnChildrenBase( dimension );
593         }
594
595         /**
596          * @brief Determine if this view is dependent on it's children for relayout from the base class.
597          *
598          * @return Return if the view is dependent on it's children.
599          */
600         public virtual bool RelayoutDependentOnChildren()
601         {
602             return viewWrapperImpl.RelayoutDependentOnChildrenBase();
603         }
604
605         /**
606          * @brief Virtual method to notify deriving classes that relayout dependencies have been
607          * met and the size for this object is about to be calculated for the given dimension
608          *
609          * @param dimension The dimension that is about to be calculated
610          */
611         public virtual void OnCalculateRelayoutSize(DimensionType dimension)
612         {
613         }
614
615         /**
616          * @brief Virtual method to notify deriving classes that the size for a dimension
617          * has just been negotiated
618          *
619          * @param[in] size The new size for the given dimension
620          * @param[in] dimension The dimension that was just negotiated
621          */
622         public virtual void OnLayoutNegotiated(float size, DimensionType dimension)
623         {
624         }
625
626         /**
627          * @brief This method should be overridden by deriving classes requiring notifications when the style changes.
628          *
629          * @param[in] styleManager  The StyleManager object.
630          * @param[in] change  Information denoting what has changed.
631          */
632         public virtual void OnStyleChange(StyleManager styleManager, StyleChangeType change)
633         {
634         }
635
636         /**
637          * @brief This method is called when the control is accessibility activated.
638          *
639          * Derived classes should override this to perform custom accessibility activation.
640          * @return true if this control can perform accessibility activation.
641          */
642         internal virtual bool OnAccessibilityActivated()
643         {
644             return false;
645         }
646
647         /**
648          * @brief This method should be overridden by deriving classes when they wish to respond the accessibility
649          * pan gesture.
650          *
651          * @param[in] gesture The pan gesture.
652          * @return true if the pan gesture has been consumed by this control
653          */
654         internal virtual bool OnAccessibilityPan(PanGesture gestures)
655         {
656             return false;
657         }
658
659         /**
660          * @brief This method should be overridden by deriving classes when they wish to respond the accessibility
661          * touch event.
662          *
663          * @param[in] touch The touch event.
664          * @return true if the touch event has been consumed by this control
665          */
666         internal virtual bool OnAccessibilityTouch(Touch touch)
667         {
668             return false;
669         }
670
671         /**
672          * @brief This method should be overridden by deriving classes when they wish to respond
673          * the accessibility up and down action (i.e. value change of slider control).
674          *
675          * @param[in] isIncrease Whether the value should be increased or decreased
676          * @return true if the value changed action has been consumed by this control
677          */
678         internal virtual bool OnAccessibilityValueChange(bool isIncrease)
679         {
680             return false;
681         }
682
683         /**
684          * @brief This method should be overridden by deriving classes when they wish to respond
685          * the accessibility zoom action.
686          *
687          * @return true if the zoom action has been consumed by this control
688          */
689         internal virtual bool OnAccessibilityZoom()
690         {
691             return false;
692         }
693
694         /**
695          * @brief This method should be overridden by deriving classes when they wish to respond
696          * the accessibility zoom action.
697          *
698          * @return true if the zoom action has been consumed by this control
699          */
700         public virtual void OnFocusGained()
701         {
702         }
703
704         /**
705          * @brief Called when the control loses key input focus.
706          *
707          * Should be overridden by derived classes if they need to customize what happens when focus is lost.
708          */
709         public virtual void OnFocusLost()
710         {
711         }
712
713         /**
714          * @brief Gets the next keyboard focusable view in this control towards the given direction.
715          *
716          * A control needs to override this function in order to support two dimensional keyboard navigation.
717          * @param[in] currentFocusedView The current focused view.
718          * @param[in] direction The direction to move the focus towards.
719          * @param[in] loopEnabled Whether the focus movement should be looped within the view.
720          * @return the next keyboard focusable view in this control or an empty handle if no view can be focused.
721          */
722         public virtual View GetNextFocusableView(View currentFocusedView, View.Focus.Direction direction, bool loopEnabled)
723         {
724             return new View();
725         }
726
727         /**
728          * @brief Informs this control that its chosen focusable view will be focused.
729          *
730          * This allows the application to preform any actions if wishes
731          * before the focus is actually moved to the chosen view.
732          *
733          * @param[in] commitedFocusableView The commited focusable view.
734          */
735         public virtual void OnFocusChangeCommitted(View commitedFocusableView)
736         {
737         }
738
739         /**
740          * @brief This method is called when the control has enter pressed on it.
741          *
742          * Derived classes should override this to perform custom actions.
743          * @return true if this control supported this action.
744          */
745         public virtual bool OnFocusEnter()
746         {
747             return false;
748         }
749
750         /**
751          * @brief Called whenever a pinch gesture is detected on this control.
752          *
753          * This can be overridden by deriving classes when pinch detection
754          * is enabled.  The default behaviour is to scale the control by the
755          * pinch scale.
756          *
757          * @param[in]  pinch  The pinch gesture.
758          * @note If overridden, then the default behaviour will not occur.
759          * @note Pinch detection should be enabled via EnableGestureDetection().
760          * @see EnableGestureDetection
761          */
762         public virtual void OnPinch(PinchGesture pinch)
763         {
764         }
765
766         /**
767          * @brief Called whenever a pan gesture is detected on this control.
768          *
769          * This should be overridden by deriving classes when pan detection
770          * is enabled.
771          *
772          * @param[in]  pan  The pan gesture.
773          * @note There is no default behaviour with panning.
774          * @note Pan detection should be enabled via EnableGestureDetection().
775          * @see EnableGestureDetection
776          */
777         public virtual void OnPan(PanGesture pan)
778         {
779         }
780
781         /**
782          * @brief Called whenever a tap gesture is detected on this control.
783          *
784          * This should be overridden by deriving classes when tap detection
785          * is enabled.
786          *
787          * @param[in]  tap  The tap gesture.
788          * @note There is no default behaviour with a tap.
789          * @note Tap detection should be enabled via EnableGestureDetection().
790          * @see EnableGestureDetection
791          */
792         public virtual void OnTap(TapGesture tap)
793         {
794         }
795
796         /**
797          * @brief Called whenever a long press gesture is detected on this control.
798          *
799          * This should be overridden by deriving classes when long press
800          * detection is enabled.
801          *
802          * @param[in]  longPress  The long press gesture.
803          * @note There is no default behaviour associated with a long press.
804          * @note Long press detection should be enabled via EnableGestureDetection().
805          * @see EnableGestureDetection
806          */
807         public virtual void OnLongPress(LongPressGesture longPress)
808         {
809         }
810
811         private void OnControlChildAdd(View child)
812         {
813         }
814
815         private void OnControlChildRemove(View child)
816         {
817         }
818     }
819
820     public enum CustomViewBehaviour
821     {
822         VIEW_BEHAVIOUR_DEFAULT = 0,
823         DISABLE_SIZE_NEGOTIATION = 1 << 0,
824         REQUIRES_KEYBOARD_NAVIGATION_SUPPORT = 1 << 5,
825         DISABLE_STYLE_CHANGE_SIGNALS = 1 << 6,
826         LAST_VIEW_BEHAVIOUR_FLAG
827     }
828 }