/* * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ using System.ComponentModel; using Tizen.NUI; using Tizen.NUI.XamlBinding; namespace Tizen.NUI.Xaml.Forms.BaseComponents { internal class InternalCustomeView : Tizen.NUI.BaseComponents.CustomView { public InternalCustomeView(string typeName, CustomViewBehaviour behaviour) : base(typeName, behaviour) { } /// /// Requests a relayout, which means performing a size negotiation on this view, its parent, and children (and potentially whole scene).
/// This method can also be called from a derived class every time it needs a different size.
/// At the end of event processing, the relayout process starts and all controls which requested relayout will have their sizes (re)negotiated.
/// 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.
///
/// 6 public new void RelayoutRequest() { base.RelayoutRequest(); } /// /// Provides the view implementation of GetHeightForWidth. /// /// The width to use. /// The height based on the width. /// 6 public new float GetHeightForWidthBase(float width) { return base.GetHeightForWidthBase(width); } /// /// Provides the view implementation of GetWidthForHeight. /// /// The height to use. /// The width based on the height. /// 6 public new float GetWidthForHeightBase(float height) { return base.GetWidthForHeightBase(height); } /// /// Calculates the size for a child using the base view object. /// /// The child view to calculate the size for. /// The dimension to calculate the size, for example, the width or the height. /// Return the calculated size for the given dimension. If more than one dimension is requested, just return the first one found. /// 6 public float CalculateChildSizeBase(View child, DimensionType dimension) { return base.CalculateChildSizeBase(child.ViewInstance, dimension); } /// /// Determines if this view is dependent on it's children for relayout from the base class. /// /// The dimension(s) to check for. /// Return if the view is dependent on it's children. /// 6 public new bool RelayoutDependentOnChildrenBase(DimensionType dimension) { return base.RelayoutDependentOnChildrenBase(dimension); } /// /// Determines if this view is dependent on it's children for relayout from the base class. /// /// Return if the view is dependent on it's children. /// 6 public new bool RelayoutDependentOnChildrenBase() { return base.RelayoutDependentOnChildrenBase(); } /// /// Registers a visual by property index, linking a view to visual when required.
/// In the case of the visual being a view or control deeming visual not required, then the visual should be an empty handle.
/// No parenting is done during registration, this should be done by a derived class.
///
/// The property index of the visual used to reference visual. /// The visual to register. /// 6 public new void RegisterVisual(int index, VisualBase visual) { base.RegisterVisual(index, visual); } /// /// Registers a visual by the property index, linking a view to visual when required.
/// In the case of the visual being a view or control deeming visual not required, then the visual should be an empty handle.
/// If enabled is false, then the visual is not set on the stage until enabled by the derived class.
///
/// The property index of the visual used to reference visual. /// The visual to register. /// False if derived class wants to control when the visual is set on the stage. /// 6 public new void RegisterVisual(int index, VisualBase visual, bool enabled) { base.RegisterVisual(index, visual, enabled); } /// /// Erases the entry matching the given index from the list of registered visuals. /// /// The property index of the visual used to reference visual. /// 6 public new void UnregisterVisual(int index) { base.UnregisterVisual(index); } /// /// Retrieves the visual associated with the given property index.
/// For managing the object lifecycle, do not store the returned visual as a member which increments its reference count.
///
/// The property index of the visual used to reference visual. /// The registered visual if exists, otherwise an empty handle. /// 6 public new VisualBase GetVisual(int index) { return base.GetVisual(index); } /// /// Sets the given visual to be displayed or not when parent staged.
/// For managing the object lifecycle, do not store the returned visual as a member which increments its reference count.
///
/// The property index of the visual, used to reference visual. /// Flag set to enabled or disabled. /// 6 public new void EnableVisual(int index, bool enable) { base.EnableVisual(index, enable); } /// /// Queries if the given visual is to be displayed when parent staged.
/// For managing the object lifecycle, do not store the returned visual as a member which increments its reference count.
///
/// The property index of the visual. /// Whether visual is enabled or not. /// 6 public new bool IsVisualEnabled(int index) { return base.IsVisualEnabled(index); } /// /// Creates a transition effect on the control. /// /// The transition data describing the effect to create. /// A handle to an animation defined with the given effect, or an empty handle if no properties match. /// 6 public new Animation CreateTransition(TransitionData transitionData) { return base.CreateTransition(transitionData); } /// /// Emits the KeyInputFocusGained signal if true, else, emits the KeyInputFocusLost signal.
/// Should be called last by the control after it acts on the input focus change.
///
/// True if gained, false if lost. /// 6 public new void EmitFocusSignal(bool focusGained) { base.EmitFocusSignal(focusGained); } } /// /// CustomView provides some common functionality required by all views. /// /// 6 [EditorBrowsable(EditorBrowsableState.Never)] public class CustomView : View { private InternalCustomeView _customView; internal InternalCustomeView customView { get { if (null == _customView) { _customView = handleInstance as InternalCustomeView; } return _customView; } } /// /// Creates a new instance of a Xaml CustomView. /// /// 6 [EditorBrowsable(EditorBrowsableState.Never)] public CustomView(string typeName, CustomViewBehaviour behaviour) : this(new Tizen.NUI.BaseComponents.CustomView(typeName, behaviour)) { } internal CustomView(Tizen.NUI.BaseComponents.CustomView nuiInstance) : base(nuiInstance) { SetNUIInstance(nuiInstance); } /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty FocusNavigationSupportProperty = BindableProperty.Create("FocusNavigationSupport", typeof(bool), typeof(CustomView), false, propertyChanged: (bindable, oldValue, newValue) => { var customView = ((CustomView)bindable).customView; customView.FocusNavigationSupport = (bool)newValue; }, defaultValueCreator:(bindable) => { var customView = ((CustomView)bindable).customView; return customView.FocusNavigationSupport; }); /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty FocusGroupProperty = BindableProperty.Create("FocusGroup", typeof(bool), typeof(CustomView), false, propertyChanged: (bindable, oldValue, newValue) => { var customView = ((CustomView)bindable).customView; customView.FocusGroup = (bool)newValue; }, defaultValueCreator:(bindable) => { var customView = ((CustomView)bindable).customView; return customView.FocusGroup; }); /// /// Sets the background with a property map. /// /// The background property map. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] public void SetBackground(PropertyMap map) { customView.SetBackground(map); } /// /// Allows deriving classes to enable any of the gesture detectors that are available.
/// Gesture detection can be enabled one at a time or in a bitwise format.
///
/// The gesture type(s) to enable. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] public void EnableGestureDetection(Gesture.GestureType type) { customView.EnableGestureDetection(type); } /// /// Sets whether this control supports two dimensional keyboard navigation /// (i.e., whether it knows how to handle the keyboard focus movement between its child views).
/// The control doesn't support it by default.
///
/// 6 [EditorBrowsable(EditorBrowsableState.Never)] public bool FocusNavigationSupport { get { return (bool)GetValue(FocusNavigationSupportProperty); } set { SetValue(FocusNavigationSupportProperty, value); } } /// /// Sets or gets whether this control is a focus group for keyboard navigation. /// /// True if this control is set as a focus group for keyboard navigation. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] public bool FocusGroup { get { return (bool)GetValue(FocusGroupProperty); } set { SetValue(FocusGroupProperty, value); } } /// /// This method is called after the control has been initialized.
/// Derived classes should do any second phase initialization by overriding this method.
///
/// 6 [EditorBrowsable(EditorBrowsableState.Never)] public virtual void OnInitialize() { } /// /// Called after the view has been connected to the stage.
/// When a view is connected, it will be directly or indirectly parented to the root view.
/// The root view is provided automatically by Tizen.NUI.Stage, and is always considered to be connected.
/// When the parent of a set of views is connected to the stage, then all of the children will receive this callback.
///
/// The depth in the hierarchy for the view. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] public virtual void OnStageConnection(int depth) { } /// /// Called after the view has been disconnected from the stage.
/// If a view is disconnected, it either has no parent, or is parented to a disconnected view.
/// When the parent of a set of views is disconnected to the stage, then all of the children will receive this callback, starting with the leaf views.
///
/// 6 [EditorBrowsable(EditorBrowsableState.Never)] public virtual void OnStageDisconnection() { } /// /// Called after a child has been added to the owning view. /// /// The child which has been added. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] public virtual void OnChildAdd(View view) { } /// /// Called after the owning view has attempted to remove a child( regardless of whether it succeeded or not ). /// /// The child being removed. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] public virtual void OnChildRemove(View view) { } /// /// Called when the owning view property is set. /// /// The property index that was set. /// The value to set. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] public virtual void OnPropertySet(int index, PropertyValue propertyValue) { } /// /// Called when the owning view's size is set, for example, using View.SetSize(). /// /// The target size. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] public virtual void OnSizeSet(Vector3 targetSize) { } /// /// Called when the owning view's size is animated, for example, using Animation::AnimateTo( Property ( view, View::Property::SIZE ), ... ). /// /// The object which is animating the owning view. /// The target size. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] public virtual void OnSizeAnimation(Animation animation, Vector3 targetSize) { } /// /// Called after a touch event is received by the owning view.
/// CustomViewBehaviour.REQUIRES_TOUCH_EVENTS must be enabled during construction. See CustomView(ViewWrapperImpl.CustomViewBehaviour behaviour).
///
/// The touch event. /// True if the event should be consumed. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] public virtual bool OnTouch(Touch touch) { return false; // Do not consume } /// /// Called after a hover event is received by the owning view.
/// CustomViewBehaviour.REQUIRES_HOVER_EVENTS must be enabled during construction. See CustomView(ViewWrapperImpl.CustomViewBehaviour behaviour).
///
/// The hover event. /// True if the hover event should be consumed. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] public virtual bool OnHover(Hover hover) { return false; // Do not consume } /// /// Called after a key event is received by the view that has had its focus set. /// /// The key event. /// True if the key event should be consumed. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] public virtual bool OnKey(Key key) { return false; // Do not consume } /// /// Called after a wheel event is received by the owning view.
/// CustomViewBehaviour.REQUIRES_WHEEL_EVENTS must be enabled during construction. See CustomView(ViewWrapperImpl.CustomViewBehaviour behaviour).
///
/// The wheel event. /// True if the wheel event should be consumed. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] public virtual bool OnWheel(Wheel wheel) { return false; // Do not consume } /// /// Called after the size negotiation has been finished for this control.
/// The control is expected to assign this given size to itself or its children.
/// Should be overridden by derived classes if they need to layout views differently after certain operations like add or remove views, resize, or after changing specific properties.
/// As this function is called from inside the size negotiation algorithm, you cannot call RequestRelayout (the call would just be ignored).
///
/// The allocated size. /// The control should add views to this container that it is not able to allocate a size for. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] public virtual void OnRelayout(Vector2 size, RelayoutContainer container) { } /// /// Notification for deriving classes. /// /// The policy being set. /// The policy is being set for. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] public virtual void OnSetResizePolicy(ResizePolicyType policy, DimensionType dimension) { } /// /// Returns the natural size of the view. /// /// The view's natural size /// 6 [EditorBrowsable(EditorBrowsableState.Never)] public virtual Size2D GetNaturalSize() { return new Size2D(0, 0); } /// /// Calculates the size for a child. /// /// The child view to calculate the size for. /// The dimension to calculate the size, for example, the width or the height. /// Return the calculated size for the given dimension. If more than one dimension is requested, just return the first one found. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] public virtual float CalculateChildSize(View child, DimensionType dimension) { return customView.CalculateChildSize(child.view, dimension); } /// /// This method is called during size negotiation when a height is required for a given width.
/// Derived classes should override this if they wish to customize the height returned.
///
/// Width to use /// The height based on the width /// 6 [EditorBrowsable(EditorBrowsableState.Never)] public new virtual float GetHeightForWidth(float width) { return customView.GetHeightForWidth(width); } /// /// This method is called during size negotiation when a width is required for a given height.
/// Derived classes should override this if they wish to customize the width returned.
///
/// Height to use /// The width based on the width /// 6 [EditorBrowsable(EditorBrowsableState.Never)] public new virtual float GetWidthForHeight(float height) { return customView.GetWidthForHeight(height); } /// /// Determines if this view is dependent on it's children for relayout. /// /// The dimension(s) to check for. /// Return if the view is dependent on it's children. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] public virtual bool RelayoutDependentOnChildren(DimensionType dimension) { return customView.RelayoutDependentOnChildren(dimension); } /// /// Determines if this view is dependent on it's children for relayout from the base class. /// /// Return true if the view is dependent on it's children. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] public virtual bool RelayoutDependentOnChildren() { return customView.RelayoutDependentOnChildren(); } /// /// The virtual method to notify deriving classes that relayout dependencies have been /// met and the size for this object is about to be calculated for the given dimension. /// /// The dimension that is about to be calculated. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] public virtual void OnCalculateRelayoutSize(DimensionType dimension) { } /// /// The virtual method to notify deriving classes that the size for a dimension has just been negotiated. /// /// The new size for the given dimension. /// The dimension that was just negotiated. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] public virtual void OnLayoutNegotiated(float size, DimensionType dimension) { } /// /// This method should be overridden by deriving classes requiring notifications when the style changes. /// /// The StyleManager object. /// Information denoting what has changed. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] public virtual void OnStyleChange(StyleManager styleManager, StyleChangeType change) { } /// /// Called when the control gain key input focus. Should be overridden by derived classes if they need to customize what happens when the focus is gained. /// /// 6 [EditorBrowsable(EditorBrowsableState.Never)] public virtual void OnFocusGained() { } /// /// Called when the control loses key input focus. Should be overridden by derived classes if they need to customize what happens when the focus is lost. /// /// 6 [EditorBrowsable(EditorBrowsableState.Never)] public virtual void OnFocusLost() { } /// /// Gets the next keyboard focusable view in this control towards the given direction.
/// A control needs to override this function in order to support two dimensional keyboard navigation.
///
/// The current focused view. /// The direction to move the focus towards. /// Whether the focus movement should be looped within the control. /// The next keyboard focusable view in this control or an empty handle if no view can be focused. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] public virtual View GetNextFocusableView(View currentFocusedView, Tizen.NUI.BaseComponents.View.FocusDirection direction, bool loopEnabled) { return new View(); } /// /// Informs this control that its chosen focusable view will be focused.
/// This allows the application to preform any actions it wishes before the focus is actually moved to the chosen view.
///
/// The commited focused view. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] public virtual void OnFocusChangeCommitted(View commitedFocusableView) { } /// /// This method is called when the control has enter pressed on it.
/// Derived classes should override this to perform custom actions.
///
/// True if this control supported this action. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] public virtual bool OnKeyboardEnter() { return false; } /// /// Called whenever a pan gesture is detected on this control.
/// This should be overridden by deriving classes when pan detection is enabled.
/// There is no default behavior with panning.
/// Pan detection should be enabled via EnableGestureDetection().
///
/// The pan gesture. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] public virtual void OnPan(PanGesture pan) { } /// /// Called whenever a tap gesture is detected on this control.
/// This should be overridden by deriving classes when tap detection is enabled.
/// There is no default behavior with a tap.
/// Tap detection should be enabled via EnableGestureDetection().
///
/// The tap gesture. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] public virtual void OnTap(TapGesture tap) { } /// /// Requests a relayout, which means performing a size negotiation on this view, its parent, and children (and potentially whole scene).
/// This method can also be called from a derived class every time it needs a different size.
/// At the end of event processing, the relayout process starts and all controls which requested relayout will have their sizes (re)negotiated.
/// 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.
///
/// 6 [EditorBrowsable(EditorBrowsableState.Never)] protected void RelayoutRequest() { customView.RelayoutRequest(); } /// /// Provides the view implementation of GetHeightForWidth. /// /// The width to use. /// The height based on the width. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] protected float GetHeightForWidthBase(float width) { return customView.GetHeightForWidthBase(width); } /// /// Provides the view implementation of GetWidthForHeight. /// /// The height to use. /// The width based on the height. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] protected float GetWidthForHeightBase(float height) { return customView.GetWidthForHeightBase(height); } /// /// Calculates the size for a child using the base view object. /// /// The child view to calculate the size for. /// The dimension to calculate the size, for example, the width or the height. /// Return the calculated size for the given dimension. If more than one dimension is requested, just return the first one found. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] protected float CalculateChildSizeBase(View child, DimensionType dimension) { return customView.CalculateChildSizeBase(child, dimension); } /// /// Determines if this view is dependent on it's children for relayout from the base class. /// /// The dimension(s) to check for. /// Return if the view is dependent on it's children. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] protected bool RelayoutDependentOnChildrenBase(DimensionType dimension) { return customView.RelayoutDependentOnChildrenBase(dimension); } /// /// Determines if this view is dependent on it's children for relayout from the base class. /// /// Return if the view is dependent on it's children. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] protected bool RelayoutDependentOnChildrenBase() { return customView.RelayoutDependentOnChildrenBase(); } /// /// Registers a visual by property index, linking a view to visual when required.
/// In the case of the visual being a view or control deeming visual not required, then the visual should be an empty handle.
/// No parenting is done during registration, this should be done by a derived class.
///
/// The property index of the visual used to reference visual. /// The visual to register. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] protected void RegisterVisual(int index, VisualBase visual) { customView.RegisterVisual(index, visual); } /// /// Registers a visual by the property index, linking a view to visual when required.
/// In the case of the visual being a view or control deeming visual not required, then the visual should be an empty handle.
/// If enabled is false, then the visual is not set on the stage until enabled by the derived class.
///
/// The property index of the visual used to reference visual. /// The visual to register. /// False if derived class wants to control when the visual is set on the stage. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] protected void RegisterVisual(int index, VisualBase visual, bool enabled) { customView.RegisterVisual(index, visual, enabled); } /// /// Erases the entry matching the given index from the list of registered visuals. /// /// The property index of the visual used to reference visual. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] protected void UnregisterVisual(int index) { customView.UnregisterVisual(index); } /// /// Retrieves the visual associated with the given property index.
/// For managing the object lifecycle, do not store the returned visual as a member which increments its reference count.
///
/// The property index of the visual used to reference visual. /// The registered visual if exists, otherwise an empty handle. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] protected VisualBase GetVisual(int index) { return customView.GetVisual(index); } /// /// Sets the given visual to be displayed or not when parent staged.
/// For managing the object lifecycle, do not store the returned visual as a member which increments its reference count.
///
/// The property index of the visual, used to reference visual. /// Flag set to enabled or disabled. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] protected void EnableVisual(int index, bool enable) { customView.EnableVisual(index, enable); } /// /// Queries if the given visual is to be displayed when parent staged.
/// For managing the object lifecycle, do not store the returned visual as a member which increments its reference count.
///
/// The property index of the visual. /// Whether visual is enabled or not. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] protected bool IsVisualEnabled(int index) { return customView.IsVisualEnabled(index); } /// /// Creates a transition effect on the control. /// /// The transition data describing the effect to create. /// A handle to an animation defined with the given effect, or an empty handle if no properties match. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] protected Animation CreateTransition(TransitionData transitionData) { return customView.CreateTransition(transitionData); } /// /// Emits the KeyInputFocusGained signal if true, else, emits the KeyInputFocusLost signal.
/// Should be called last by the control after it acts on the input focus change.
///
/// True if gained, false if lost. /// 6 [EditorBrowsable(EditorBrowsableState.Never)] protected void EmitFocusSignal(bool focusGained) { customView.EmitFocusSignal(focusGained); } } }