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