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