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