/* * Copyright(c) 2019 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; using System.ComponentModel; using System.Collections.Generic; using System.IO; using System.Runtime.InteropServices; using Tizen.NUI.Binding; using Tizen.NUI.Xaml; namespace Tizen.NUI.BaseComponents { /// /// View is the base class for all views. /// /// 3 public partial class View { private MergedStyle mergedStyle = null; private ViewSelectorData selectorData; internal string styleName; internal MergedStyle _mergedStyle { get { if (null == mergedStyle) { mergedStyle = new MergedStyle(GetType(), this); } return mergedStyle; } } /// /// The color mode of View. /// This specifies whether the View uses its own color, or inherits its parent color. /// The default is ColorMode.UseOwnMultiplyParentColor. /// internal ColorMode ColorMode { set { SetColorMode(value); } get { return GetColorMode(); } } internal float WorldPositionX { get { float temp = 0.0f; GetProperty(View.Property.WORLD_POSITION_X).Get(out temp); return temp; } } internal float WorldPositionY { get { float temp = 0.0f; GetProperty(View.Property.WORLD_POSITION_Y).Get(out temp); return temp; } } internal float WorldPositionZ { get { float temp = 0.0f; GetProperty(View.Property.WORLD_POSITION_Z).Get(out temp); return temp; } } internal bool FocusState { get { return IsKeyboardFocusable(); } set { SetKeyboardFocusable(value); } } internal void SetLayout(LayoutItem layout) { Window.Instance.LayoutController.CreateProcessCallback(); _layout = layout; _layout?.AttachToOwner(this); _layout?.RequestLayout(); } /// /// Stores the calculated width value and its ModeType. Width component. /// internal MeasureSpecification MeasureSpecificationWidth { set { _measureSpecificationWidth = value; _layout?.RequestLayout(); } get { return _measureSpecificationWidth; } } /// /// Stores the calculated width value and its ModeType. Height component. /// internal MeasureSpecification MeasureSpecificationHeight { set { _measureSpecificationHeight = value; _layout?.RequestLayout(); } get { return _measureSpecificationHeight; } } internal void AttachTransitionsToChildren(LayoutTransition transition) { // Iterate children, adding the transition unless a transition // for the same condition and property has already been // explicitly added. foreach (View view in Children) { LayoutTransitionsHelper.AddTransitionForCondition(view.LayoutTransitions, transition.Condition, transition, false); } } internal float ParentOriginX { get { float temp = 0.0f; GetProperty(View.Property.PARENT_ORIGIN_X).Get(out temp); return temp; } set { SetProperty(View.Property.PARENT_ORIGIN_X, new Tizen.NUI.PropertyValue(value)); NotifyPropertyChanged(); } } internal float ParentOriginY { get { float temp = 0.0f; GetProperty(View.Property.PARENT_ORIGIN_Y).Get(out temp); return temp; } set { SetProperty(View.Property.PARENT_ORIGIN_Y, new Tizen.NUI.PropertyValue(value)); NotifyPropertyChanged(); } } internal float ParentOriginZ { get { float temp = 0.0f; GetProperty(View.Property.PARENT_ORIGIN_Z).Get(out temp); return temp; } set { SetProperty(View.Property.PARENT_ORIGIN_Z, new Tizen.NUI.PropertyValue(value)); NotifyPropertyChanged(); } } internal float PivotPointX { get { float temp = 0.0f; GetProperty(View.Property.ANCHOR_POINT_X).Get(out temp); return temp; } set { SetProperty(View.Property.ANCHOR_POINT_X, new Tizen.NUI.PropertyValue(value)); } } internal float PivotPointY { get { float temp = 0.0f; GetProperty(View.Property.ANCHOR_POINT_Y).Get(out temp); return temp; } set { SetProperty(View.Property.ANCHOR_POINT_Y, new Tizen.NUI.PropertyValue(value)); } } internal float PivotPointZ { get { float temp = 0.0f; GetProperty(View.Property.ANCHOR_POINT_Z).Get(out temp); return temp; } set { SetProperty(View.Property.ANCHOR_POINT_Z, new Tizen.NUI.PropertyValue(value)); } } internal Matrix WorldMatrix { get { Matrix temp = new Matrix(); GetProperty(View.Property.WORLD_MATRIX).Get(temp); return temp; } } /// /// Indicates that this View should listen Touch event to handle its ControlState. /// private bool enableControlState = false; private int LeftFocusableViewId { get { int temp = 0; GetProperty(View.Property.LEFT_FOCUSABLE_VIEW_ID).Get(out temp); return temp; } set { SetProperty(View.Property.LEFT_FOCUSABLE_VIEW_ID, new Tizen.NUI.PropertyValue(value)); } } private int RightFocusableViewId { get { int temp = 0; GetProperty(View.Property.RIGHT_FOCUSABLE_VIEW_ID).Get(out temp); return temp; } set { SetProperty(View.Property.RIGHT_FOCUSABLE_VIEW_ID, new Tizen.NUI.PropertyValue(value)); } } private int UpFocusableViewId { get { int temp = 0; GetProperty(View.Property.UP_FOCUSABLE_VIEW_ID).Get(out temp); return temp; } set { SetProperty(View.Property.UP_FOCUSABLE_VIEW_ID, new Tizen.NUI.PropertyValue(value)); } } private int DownFocusableViewId { get { int temp = 0; GetProperty(View.Property.DOWN_FOCUSABLE_VIEW_ID).Get(out temp); return temp; } set { SetProperty(View.Property.DOWN_FOCUSABLE_VIEW_ID, new Tizen.NUI.PropertyValue(value)); } } private ViewSelectorData SelectorData { get { if (selectorData == null) { selectorData = new ViewSelectorData(); } return selectorData; } } internal void Raise() { var parentChildren = GetParent()?.Children; if (parentChildren != null) { int currentIndex = parentChildren.IndexOf(this); // If the view is not already the last item in the list. if (currentIndex >= 0 && currentIndex < parentChildren.Count - 1) { View temp = parentChildren[currentIndex + 1]; parentChildren[currentIndex + 1] = this; parentChildren[currentIndex] = temp; Interop.NDalic.Raise(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } } } internal void Lower() { var parentChildren = GetParent()?.Children; if (parentChildren != null) { int currentIndex = parentChildren.IndexOf(this); // If the view is not already the first item in the list. if (currentIndex > 0 && currentIndex < parentChildren.Count) { View temp = parentChildren[currentIndex - 1]; parentChildren[currentIndex - 1] = this; parentChildren[currentIndex] = temp; Interop.NDalic.Lower(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } } } /// /// Raises the view to above the target view. /// /// The sibling order of views within the parent will be updated automatically. /// Views on the level above the target view will still be shown above this view. /// Raising this view above views with the same sibling order as each other will raise this view above them. /// Once a raise or lower API is used that view will then have an exclusive sibling order independent of insertion. /// /// Will be raised above this view. internal void RaiseAbove(View target) { var parentChildren = GetParent()?.Children; if (parentChildren != null) { int currentIndex = parentChildren.IndexOf(this); int targetIndex = parentChildren.IndexOf(target); if (currentIndex < 0 || targetIndex < 0 || currentIndex >= parentChildren.Count || targetIndex >= parentChildren.Count) { NUILog.Error("index should be bigger than 0 and less than children of layer count"); return; } // If the currentIndex is less than the target index and the target has the same parent. if (currentIndex < targetIndex) { parentChildren.Remove(this); parentChildren.Insert(targetIndex, this); Interop.NDalic.RaiseAbove(swigCPtr, View.getCPtr(target)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } } } /// /// Lowers the view to below the target view. /// /// The sibling order of views within the parent will be updated automatically. /// Lowering this view below views with the same sibling order as each other will lower this view above them. /// Once a raise or lower API is used that view will then have an exclusive sibling order independent of insertion. /// /// Will be lowered below this view. internal void LowerBelow(View target) { var parentChildren = GetParent()?.Children; if (parentChildren != null) { int currentIndex = parentChildren.IndexOf(this); int targetIndex = parentChildren.IndexOf(target); if (currentIndex < 0 || targetIndex < 0 || currentIndex >= parentChildren.Count || targetIndex >= parentChildren.Count) { NUILog.Error("index should be bigger than 0 and less than children of layer count"); return; } // If the currentIndex is not already the 0th index and the target has the same parent. if ((currentIndex != 0) && (targetIndex != -1) && (currentIndex > targetIndex)) { parentChildren.Remove(this); parentChildren.Insert(targetIndex, this); Interop.NDalic.LowerBelow(swigCPtr, View.getCPtr(target)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } } } internal string GetName() { string ret = Interop.Actor.Actor_GetName(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal void SetName(string name) { Interop.Actor.Actor_SetName(swigCPtr, name); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal uint GetId() { uint ret = Interop.Actor.Actor_GetId(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal bool IsRoot() { bool ret = Interop.ActorInternal.Actor_IsRoot(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal bool OnWindow() { bool ret = Interop.Actor.Actor_OnStage(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal View FindChildById(uint id) { //to fix memory leak issue, match the handle count with native side. IntPtr cPtr = Interop.Actor.Actor_FindChildById(swigCPtr, id); View ret = this.GetInstanceSafely(cPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal override View FindCurrentChildById(uint id) { return FindChildById(id); } internal void SetParentOrigin(Vector3 origin) { Interop.ActorInternal.Actor_SetParentOrigin(swigCPtr, Vector3.getCPtr(origin)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal Vector3 GetCurrentParentOrigin() { Vector3 ret = new Vector3(Interop.ActorInternal.Actor_GetCurrentParentOrigin(swigCPtr), true); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal void SetAnchorPoint(Vector3 anchorPoint) { Interop.Actor.Actor_SetAnchorPoint(swigCPtr, Vector3.getCPtr(anchorPoint)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal Vector3 GetCurrentAnchorPoint() { Vector3 ret = new Vector3(Interop.ActorInternal.Actor_GetCurrentAnchorPoint(swigCPtr), true); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal void SetSize(float width, float height) { Interop.ActorInternal.Actor_SetSize__SWIG_0(swigCPtr, width, height); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal void SetSize(float width, float height, float depth) { Interop.ActorInternal.Actor_SetSize__SWIG_1(swigCPtr, width, height, depth); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal void SetSize(Vector2 size) { Interop.ActorInternal.Actor_SetSize__SWIG_2(swigCPtr, Vector2.getCPtr(size)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal void SetSize(Vector3 size) { Interop.ActorInternal.Actor_SetSize__SWIG_3(swigCPtr, Vector3.getCPtr(size)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal Vector3 GetTargetSize() { Vector3 ret = new Vector3(Interop.ActorInternal.Actor_GetTargetSize(swigCPtr), true); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal Size2D GetCurrentSize() { Size ret = new Size(Interop.Actor.Actor_GetCurrentSize(swigCPtr), true); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); Size2D size = new Size2D((int)ret.Width, (int)ret.Height); return size; } internal Size2D GetCurrentSizeFloat() { Size ret = new Size(Interop.Actor.Actor_GetCurrentSize(swigCPtr), true); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal Vector3 GetNaturalSize() { Vector3 ret = new Vector3(Interop.Actor.Actor_GetNaturalSize(swigCPtr), true); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal void SetPosition(float x, float y) { Interop.ActorInternal.Actor_SetPosition__SWIG_0(swigCPtr, x, y); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal void SetPosition(float x, float y, float z) { Interop.ActorInternal.Actor_SetPosition__SWIG_1(swigCPtr, x, y, z); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal void SetPosition(Vector3 position) { Interop.ActorInternal.Actor_SetPosition__SWIG_2(swigCPtr, Vector3.getCPtr(position)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal void SetX(float x) { Interop.ActorInternal.Actor_SetX(swigCPtr, x); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal void SetY(float y) { Interop.ActorInternal.Actor_SetY(swigCPtr, y); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal void SetZ(float z) { Interop.ActorInternal.Actor_SetZ(swigCPtr, z); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal void TranslateBy(Vector3 distance) { Interop.ActorInternal.Actor_TranslateBy(swigCPtr, Vector3.getCPtr(distance)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal Position GetCurrentPosition() { Position ret = new Position(Interop.Actor.Actor_GetCurrentPosition(swigCPtr), true); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal Vector3 GetCurrentWorldPosition() { Vector3 ret = new Vector3(Interop.ActorInternal.Actor_GetCurrentWorldPosition(swigCPtr), true); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal void SetInheritPosition(bool inherit) { Interop.ActorInternal.Actor_SetInheritPosition(swigCPtr, inherit); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal bool IsPositionInherited() { bool ret = Interop.ActorInternal.Actor_IsPositionInherited(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal void SetOrientation(Degree angle, Vector3 axis) { Interop.ActorInternal.Actor_SetOrientation__SWIG_0(swigCPtr, Degree.getCPtr(angle), Vector3.getCPtr(axis)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal void SetOrientation(Radian angle, Vector3 axis) { Interop.ActorInternal.Actor_SetOrientation__SWIG_1(swigCPtr, Radian.getCPtr(angle), Vector3.getCPtr(axis)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal void SetOrientation(Rotation orientation) { Interop.ActorInternal.Actor_SetOrientation__SWIG_2(swigCPtr, Rotation.getCPtr(orientation)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal Rotation GetCurrentOrientation() { Rotation ret = new Rotation(Interop.ActorInternal.Actor_GetCurrentOrientation(swigCPtr), true); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal void SetInheritOrientation(bool inherit) { Interop.ActorInternal.Actor_SetInheritOrientation(swigCPtr, inherit); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal bool IsOrientationInherited() { bool ret = Interop.ActorInternal.Actor_IsOrientationInherited(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal Rotation GetCurrentWorldOrientation() { Rotation ret = new Rotation(Interop.ActorInternal.Actor_GetCurrentWorldOrientation(swigCPtr), true); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal void SetScale(float scale) { Interop.ActorInternal.Actor_SetScale__SWIG_0(swigCPtr, scale); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal void SetScale(float scaleX, float scaleY, float scaleZ) { Interop.ActorInternal.Actor_SetScale__SWIG_1(swigCPtr, scaleX, scaleY, scaleZ); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal void SetScale(Vector3 scale) { Interop.ActorInternal.Actor_SetScale__SWIG_2(swigCPtr, Vector3.getCPtr(scale)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal Vector3 GetCurrentScale() { Vector3 ret = new Vector3(Interop.ActorInternal.Actor_GetCurrentScale(swigCPtr), true); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal Vector3 GetCurrentWorldScale() { Vector3 ret = new Vector3(Interop.ActorInternal.Actor_GetCurrentWorldScale(swigCPtr), true); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal void SetInheritScale(bool inherit) { Interop.ActorInternal.Actor_SetInheritScale(swigCPtr, inherit); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal bool IsScaleInherited() { bool ret = Interop.ActorInternal.Actor_IsScaleInherited(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal Matrix GetCurrentWorldMatrix() { Matrix ret = new Matrix(Interop.ActorInternal.Actor_GetCurrentWorldMatrix(swigCPtr), true); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal void SetVisible(bool visible) { Interop.Actor.Actor_SetVisible(swigCPtr, visible); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal bool IsVisible() { bool ret = Interop.ActorInternal.Actor_IsVisible(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal void SetOpacity(float opacity) { Interop.ActorInternal.Actor_SetOpacity(swigCPtr, opacity); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal float GetCurrentOpacity() { float ret = Interop.ActorInternal.Actor_GetCurrentOpacity(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal void SetColor(Vector4 color) { Interop.ActorInternal.Actor_SetColor(swigCPtr, Vector4.getCPtr(color)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal Vector4 GetCurrentColor() { Vector4 ret = new Vector4(Interop.ActorInternal.Actor_GetCurrentColor(swigCPtr), true); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal ColorMode GetColorMode() { ColorMode ret = (ColorMode)Interop.ActorInternal.Actor_GetColorMode(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal Vector4 GetCurrentWorldColor() { Vector4 ret = new Vector4(Interop.ActorInternal.Actor_GetCurrentWorldColor(swigCPtr), true); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal void SetDrawMode(DrawModeType drawMode) { Interop.ActorInternal.Actor_SetDrawMode(swigCPtr, (int)drawMode); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal DrawModeType GetDrawMode() { DrawModeType ret = (DrawModeType)Interop.ActorInternal.Actor_GetDrawMode(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal void SetKeyboardFocusable(bool focusable) { Interop.ActorInternal.Actor_SetKeyboardFocusable(swigCPtr, focusable); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal bool IsKeyboardFocusable() { bool ret = Interop.ActorInternal.Actor_IsKeyboardFocusable(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal void SetKeyboardFocusableChildren(bool focusable) { Interop.ActorInternal.SetKeyboardFocusableChildren(SwigCPtr, focusable); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal bool AreChildrenKeyBoardFocusable() { bool ret = Interop.ActorInternal.AreChildrenKeyBoardFocusable(SwigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal void SetFocusableInTouch(bool enabled) { Interop.ActorInternal.SetFocusableInTouch(SwigCPtr, enabled); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal bool IsFocusableInTouch() { bool ret = Interop.ActorInternal.IsFocusableInTouch(SwigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal void SetResizePolicy(ResizePolicyType policy, DimensionType dimension) { Interop.Actor.Actor_SetResizePolicy(swigCPtr, (int)policy, (int)dimension); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal ResizePolicyType GetResizePolicy(DimensionType dimension) { ResizePolicyType ret = (ResizePolicyType)Interop.Actor.Actor_GetResizePolicy(swigCPtr, (int)dimension); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal Vector3 GetSizeModeFactor() { Vector3 ret = new Vector3(Interop.Actor.Actor_GetSizeModeFactor(swigCPtr), true); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal void SetMinimumSize(Vector2 size) { Interop.ActorInternal.Actor_SetMinimumSize(swigCPtr, Vector2.getCPtr(size)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal Vector2 GetMinimumSize() { Vector2 ret = new Vector2(Interop.ActorInternal.Actor_GetMinimumSize(swigCPtr), true); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal void SetMaximumSize(Vector2 size) { Interop.ActorInternal.Actor_SetMaximumSize(swigCPtr, Vector2.getCPtr(size)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal Vector2 GetMaximumSize() { Vector2 ret = new Vector2(Interop.ActorInternal.Actor_GetMaximumSize(swigCPtr), true); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal int GetHierarchyDepth() { int ret = Interop.Actor.Actor_GetHierarchyDepth(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal uint GetRendererCount() { uint ret = Interop.Actor.Actor_GetRendererCount(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal static global::System.Runtime.InteropServices.HandleRef getCPtr(View obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; } internal bool IsTopLevelView() { if (GetParent() is Layer) { return true; } return false; } internal void SetKeyInputFocus() { Interop.ViewInternal.View_SetKeyInputFocus(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal void ClearKeyInputFocus() { Interop.ViewInternal.View_ClearKeyInputFocus(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal PinchGestureDetector GetPinchGestureDetector() { PinchGestureDetector ret = new PinchGestureDetector(Interop.ViewInternal.View_GetPinchGestureDetector(swigCPtr), true); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal PanGestureDetector GetPanGestureDetector() { PanGestureDetector ret = new PanGestureDetector(Interop.ViewInternal.View_GetPanGestureDetector(swigCPtr), true); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal TapGestureDetector GetTapGestureDetector() { TapGestureDetector ret = new TapGestureDetector(Interop.ViewInternal.View_GetTapGestureDetector(swigCPtr), true); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal LongPressGestureDetector GetLongPressGestureDetector() { LongPressGestureDetector ret = new LongPressGestureDetector(Interop.ViewInternal.View_GetLongPressGestureDetector(swigCPtr), true); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal IntPtr GetPtrfromView() { return (IntPtr)swigCPtr; } internal void RemoveChild(View child) { // Do actual child removal Interop.Actor.Actor_Remove(swigCPtr, View.getCPtr(child)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); Children.Remove(child); child.InternalParent = null; if (ChildRemoved != null) { ChildRemovedEventArgs e = new ChildRemovedEventArgs { Removed = child }; ChildRemoved(this, e); } } /// /// Removes the layout from this View. /// internal void ResetLayout() { _layout = null; } internal ResourceLoadingStatusType GetBackgroundResourceStatus() { return (ResourceLoadingStatusType)Interop.View.View_GetVisualResourceStatus(this.swigCPtr, Property.BACKGROUND); } internal virtual void UpdateCornerRadius(float value) { if (value != 0) { (backgroundExtraData ?? (backgroundExtraData = new BackgroundExtraData())).CornerRadius = value; } Tizen.NUI.PropertyMap backgroundMap = new Tizen.NUI.PropertyMap(); Tizen.NUI.Object.GetProperty(swigCPtr, View.Property.BACKGROUND).Get(backgroundMap); if (!backgroundMap.Empty()) { backgroundMap[Visual.Property.CornerRadius] = new PropertyValue(value); Tizen.NUI.Object.SetProperty(swigCPtr, View.Property.BACKGROUND, new Tizen.NUI.PropertyValue(backgroundMap)); } UpdateShadowCornerRadius(value); } internal void UpdateStyle() { ViewStyle newStyle; if (styleName == null) newStyle = ThemeManager.GetStyle(GetType()); else newStyle = ThemeManager.GetStyle(styleName); if (newStyle != null && (viewStyle == null || viewStyle.GetType() == newStyle.GetType())) ApplyStyle(newStyle); } /// /// you can override it to clean-up your own resources. /// /// DisposeTypes /// 3 protected override void Dispose(DisposeTypes type) { if (disposed) { return; } //_mergedStyle = null; if (type == DisposeTypes.Explicit) { //Called by User //Release your own managed resources here. //You should release all of your own disposable objects here. selectorData?.Reset(this); if (themeChangeSensitive) { ThemeManager.ThemeChangedInternal -= OnThemeChanged; } if (widthConstraint != null) { widthConstraint.Remove(); widthConstraint.Dispose(); } if (heightConstraint != null) { heightConstraint.Remove(); heightConstraint.Dispose(); } } //Release your own unmanaged resources here. //You should not access any managed member here except static instance. //because the execution order of Finalizes is non-deterministic. if (this != null) { DisConnectFromSignals(); } foreach (View view in Children) { view.InternalParent = null; } base.Dispose(type); } /// This will not be public opened. [EditorBrowsable(EditorBrowsableState.Never)] protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr) { Interop.View.delete_View(swigCPtr); } /// /// The touch event handler for ControlState. /// Please change ControlState value by touch state if needed. /// [EditorBrowsable(EditorBrowsableState.Never)] protected virtual bool HandleControlStateOnTouch(Touch touch) { switch (touch.GetState(0)) { case PointStateType.Down: ControlState += ControlState.Pressed; break; case PointStateType.Interrupted: case PointStateType.Up: if (ControlState.Contains(ControlState.Pressed)) { ControlState -= ControlState.Pressed; } break; default: break; } return false; } private void DisConnectFromSignals() { if (HasBody() == false) { NUILog.Debug($"View.DisConnectFromSignals() No native body! No need to Disconnect Signals!"); return; } if (_onRelayoutEventCallback != null) { ViewSignal signal = new ViewSignal(Interop.ActorSignal.Actor_OnRelayoutSignal(GetBaseHandleCPtrHandleRef), false); signal?.Disconnect(_onRelayoutEventCallback); signal?.Dispose(); _onRelayoutEventCallback = null; } if (_offWindowEventCallback != null) { ViewSignal signal = new ViewSignal(Interop.ActorSignal.Actor_OffSceneSignal(GetBaseHandleCPtrHandleRef), false); signal?.Disconnect(_offWindowEventCallback); signal?.Dispose(); _offWindowEventCallback = null; } if (_onWindowEventCallback != null) { ViewSignal signal = new ViewSignal(Interop.ActorSignal.Actor_OnSceneSignal(GetBaseHandleCPtrHandleRef), false); signal?.Disconnect(_onWindowEventCallback); signal?.Dispose(); _onWindowEventCallback = null; } if (_wheelEventCallback != null) { WheelSignal signal = new WheelSignal(Interop.ActorSignal.Actor_WheelEventSignal(GetBaseHandleCPtrHandleRef), false); signal?.Disconnect(_wheelEventCallback); signal?.Dispose(); _wheelEventCallback = null; } if (WindowWheelEventHandler != null) { NUIApplication.GetDefaultWindow().WheelEvent -= OnWindowWheelEvent; } if (_hoverEventCallback != null) { HoverSignal signal = new HoverSignal(Interop.ActorSignal.Actor_HoveredSignal(GetBaseHandleCPtrHandleRef), false); signal?.Disconnect(_hoverEventCallback); signal?.Dispose(); _hoverEventCallback = null; } if (_interceptTouchDataCallback != null) { TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.Actor_InterceptTouchSignal(GetBaseHandleCPtrHandleRef), false); signal?.Disconnect(_interceptTouchDataCallback); signal?.Dispose(); _interceptTouchDataCallback = null; } if (_touchDataCallback != null) { TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.Actor_TouchSignal(GetBaseHandleCPtrHandleRef), false); signal?.Disconnect(_touchDataCallback); signal?.Dispose(); _touchDataCallback = null; } if (_ResourcesLoadedCallback != null) { ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(GetBaseHandleCPtrHandleRef), false); signal?.Disconnect(_ResourcesLoadedCallback); signal?.Dispose(); _ResourcesLoadedCallback = null; } if (_keyCallback != null) { ControlKeySignal signal = new ControlKeySignal(Interop.ViewSignal.View_KeyEventSignal(GetBaseHandleCPtrHandleRef), false); signal?.Disconnect(_keyCallback); signal?.Dispose(); _keyCallback = null; } if (_keyInputFocusLostCallback != null) { KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.View_KeyInputFocusLostSignal(GetBaseHandleCPtrHandleRef), false); signal?.Disconnect(_keyInputFocusLostCallback); signal?.Dispose(); _keyInputFocusLostCallback = null; } if (_keyInputFocusGainedCallback != null) { KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.View_KeyInputFocusGainedSignal(GetBaseHandleCPtrHandleRef), false); signal?.Disconnect(_keyInputFocusGainedCallback); signal?.Dispose(); _keyInputFocusGainedCallback = null; } if (_backgroundResourceLoadedCallback != null) { ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(GetBaseHandleCPtrHandleRef), false); signal?.Disconnect(_backgroundResourceLoadedCallback); signal?.Dispose(); _backgroundResourceLoadedCallback = null; } if (_onWindowSendEventCallback != null) { ViewSignal signal = new ViewSignal(Interop.ActorSignal.Actor_OnSceneSignal(GetBaseHandleCPtrHandleRef), false); signal?.Disconnect(_onWindowSendEventCallback); signal?.Dispose(); _onWindowSendEventCallback = null; } if (_visibilityChangedEventCallback != null) { ViewVisibilityChangedSignal signal = new ViewVisibilityChangedSignal(Interop.NDalic.VisibilityChangedSignal(GetBaseHandleCPtrHandleRef), false); signal?.Disconnect(_visibilityChangedEventCallback); signal?.Dispose(); _visibilityChangedEventCallback = null; } if (_layoutDirectionChangedEventCallback != null) { ViewLayoutDirectionChangedSignal signal = new ViewLayoutDirectionChangedSignal(Interop.Layout.LayoutDirectionChangedSignal(GetBaseHandleCPtrHandleRef), false); signal?.Disconnect(_layoutDirectionChangedEventCallback); signal?.Dispose(); _layoutDirectionChangedEventCallback = null; } } private View ConvertIdToView(uint id) { View view = GetParent()?.FindCurrentChildById(id); //If we can't find the parent's children, find in the top layer. if (!view) { Container parent = GetParent(); while ((parent is View) && (parent != null)) { parent = parent.GetParent(); if (parent is Layer) { view = parent.FindCurrentChildById(id); break; } } } return view; } private void LoadTransitions() { foreach (string str in transitionNames) { string resourceName = str + ".xaml"; Transition trans = null; string resource = Tizen.Applications.Application.Current.DirectoryInfo.Resource; string likelyResourcePath = resource + "animation/" + resourceName; if (File.Exists(likelyResourcePath)) { trans = Xaml.Extensions.LoadObject(likelyResourcePath); } if (trans != null) { transDictionary.Add(trans.Name, trans); } } } private void OnScaleChanged(float x, float y, float z) { Scale = new Vector3(x, y, z); } private void OnBackgroundColorChanged(float r, float g, float b, float a) { BackgroundColor = new Color(r, g, b, a); } private void OnPaddingChanged(ushort start, ushort end, ushort top, ushort bottom) { Padding = new Extents(start, end, top, bottom); } private void OnMarginChanged(ushort start, ushort end, ushort top, ushort bottom) { Margin = new Extents(start, end, top, bottom); } private void OnColorChanged(float r, float g, float b, float a) { Color = new Color(r, g, b, a); } private void OnAnchorPointChanged(float x, float y, float z) { AnchorPoint = new Position(x, y, z); } private void OnCellIndexChanged(float x, float y) { CellIndex = new Vector2(x, y); } private void OnFlexMarginChanged(float x, float y, float z, float w) { FlexMargin = new Vector4(x, y, z, w); } private void OnPaddingEXChanged(ushort start, ushort end, ushort top, ushort bottom) { PaddingEX = new Extents(start, end, top, bottom); } private void OnSizeModeFactorChanged(float x, float y, float z) { SizeModeFactor = new Vector3(x, y, z); } private void UpdateShadowCornerRadius(float value) { // TODO Update corner radius property only whe DALi supports visual property update. PropertyMap map = new PropertyMap(); if (Tizen.NUI.Object.GetProperty(swigCPtr, View.Property.SHADOW).Get(map) && !map.Empty()) { map[Visual.Property.CornerRadius] = new PropertyValue(value); Tizen.NUI.Object.SetProperty(swigCPtr, View.Property.SHADOW, new PropertyValue(map)); } } private bool EmptyOnTouch(object target, TouchEventArgs args) { return false; } } }