2 * Copyright(c) 2022 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 using System.ComponentModel;
20 using global::System.Diagnostics;
23 namespace Tizen.NUI.BaseComponents
26 /// View is the base class for all views.
28 /// <since_tizen> 3 </since_tizen>
29 public partial class View
31 internal string styleName;
33 internal virtual LayoutItem CreateDefaultLayout()
35 return new AbsoluteLayout();
38 internal class ThemeData
41 private enum States : byte
44 ControlStatePropagation = 1 << 0,
45 ThemeChangeSensitive = 1 << 1,
46 ThemeApplied = 1 << 2, // It is true when the view has valid style name or the platform theme has a component style for this view type.
47 // That indicates the view can have different styles by theme.
48 // Hence if the current state has ThemeApplied and ThemeChangeSensitive, the view will change its style by theme changing.
49 ListeningThemeChangeEvent = 1 << 3,
52 private States states = ThemeManager.ApplicationThemeChangeSensitive ? States.ThemeChangeSensitive : States.None;
53 public ViewStyle viewStyle;
54 public ControlState controlStates = ControlState.Normal;
55 public ViewSelectorData selectorData;
57 public bool ControlStatePropagation
59 get => ((states & States.ControlStatePropagation) != 0);
60 set => SetOption(States.ControlStatePropagation, value);
63 public bool ThemeChangeSensitive
65 get => ((states & States.ThemeChangeSensitive) != 0);
66 set => SetOption(States.ThemeChangeSensitive, value);
69 public bool ThemeApplied
71 get => ((states & States.ThemeApplied) != 0);
72 set => SetOption(States.ThemeApplied, value);
75 public bool ListeningThemeChangeEvent
77 get => ((states & States.ListeningThemeChangeEvent) != 0);
78 set => SetOption(States.ListeningThemeChangeEvent, value);
81 private void SetOption(States option, bool value)
83 if (value) states |= option;
84 else states &= ~option;
89 /// The color mode of View.
90 /// This specifies whether the View uses its own color, or inherits its parent color.
91 /// The default is ColorMode.UseOwnMultiplyParentColor.
93 internal ColorMode ColorMode
101 return GetColorMode();
105 internal LayoutLength SuggestedMinimumWidth
109 float result = Interop.Actor.GetSuggestedMinimumWidth(SwigCPtr);
110 if (NDalicPINVOKE.SWIGPendingException.Pending)
111 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
112 return new LayoutLength(result);
116 internal LayoutLength SuggestedMinimumHeight
120 float result = Interop.Actor.GetSuggestedMinimumHeight(SwigCPtr);
121 if (NDalicPINVOKE.SWIGPendingException.Pending)
122 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
123 return new LayoutLength(result);
127 internal float WorldPositionX
131 #if NUI_PROPERTY_CHANGE_3
132 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.WorldPositionX);
134 float returnValue = 0.0f;
135 PropertyValue wordPositionX = GetProperty(View.Property.WorldPositionX);
136 wordPositionX?.Get(out returnValue);
137 wordPositionX?.Dispose();
143 internal float WorldPositionY
147 #if NUI_PROPERTY_CHANGE_3
148 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.WorldPositionY);
150 float returnValue = 0.0f;
151 PropertyValue wordPositionY = GetProperty(View.Property.WorldPositionY);
152 wordPositionY?.Get(out returnValue);
153 wordPositionY?.Dispose();
159 internal float WorldPositionZ
163 #if NUI_PROPERTY_CHANGE_3
164 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.WorldPositionZ);
166 float returnValue = 0.0f;
167 PropertyValue wordPositionZ = GetProperty(View.Property.WorldPositionZ);
168 wordPositionZ?.Get(out returnValue);
169 wordPositionZ?.Dispose();
175 internal bool FocusState
179 return IsKeyboardFocusable();
183 SetKeyboardFocusable(value);
187 internal void SetLayout(LayoutItem layout)
191 this.layout = layout;
192 this.layout?.AttachToOwner(this);
193 this.layout?.RequestLayout();
196 internal void AttachTransitionsToChildren(LayoutTransition transition)
198 // Iterate children, adding the transition unless a transition
199 // for the same condition and property has already been
201 foreach (View view in Children)
203 LayoutTransitionsHelper.AddTransitionForCondition(view.LayoutTransitions, transition.Condition, transition, false);
207 internal float ParentOriginX
211 #if NUI_PROPERTY_CHANGE_3
212 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.ParentOriginX);
214 float returnValue = 0.0f;
215 PropertyValue parentOriginX = GetProperty(View.Property.ParentOriginX);
216 parentOriginX?.Get(out returnValue);
217 parentOriginX?.Dispose();
223 #if NUI_PROPERTY_CHANGE_3
224 Object.InternalSetPropertyFloat(SwigCPtr, View.Property.WorldPositionX, value);
226 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
227 SetProperty(View.Property.ParentOriginX, setValue);
230 NotifyPropertyChanged();
234 internal float ParentOriginY
238 #if NUI_PROPERTY_CHANGE_3
239 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.ParentOriginY);
241 float returnValue = 0.0f;
242 PropertyValue parentOriginY = GetProperty(View.Property.ParentOriginY);
243 parentOriginY?.Get(out returnValue);
244 parentOriginY?.Dispose();
250 #if NUI_PROPERTY_CHANGE_3
251 Object.InternalSetPropertyFloat(SwigCPtr, View.Property.ParentOriginY, value);
254 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
255 SetProperty(View.Property.ParentOriginY, setValue);
258 NotifyPropertyChanged();
262 internal float ParentOriginZ
266 #if NUI_PROPERTY_CHANGE_3
267 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.ParentOriginZ);
269 float returnValue = 0.0f;
270 PropertyValue parentOriginZ = GetProperty(View.Property.ParentOriginZ);
271 parentOriginZ?.Get(out returnValue);
272 parentOriginZ?.Dispose();
278 #if NUI_PROPERTY_CHANGE_3
279 Object.InternalSetPropertyFloat(SwigCPtr, View.Property.ParentOriginZ, value);
281 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
282 SetProperty(View.Property.ParentOriginZ, setValue);
285 NotifyPropertyChanged();
289 internal float PivotPointX
293 #if NUI_PROPERTY_CHANGE_3
294 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.AnchorPointX);
296 float returnValue = 0.0f;
297 PropertyValue anchorPointX = GetProperty(View.Property.AnchorPointX);
298 anchorPointX?.Get(out returnValue);
299 anchorPointX?.Dispose();
305 #if NUI_PROPERTY_CHANGE_3
306 Object.InternalSetPropertyFloat(SwigCPtr, View.Property.AnchorPointX, value);
308 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
309 SetProperty(View.Property.AnchorPointX, setValue);
315 internal float PivotPointY
319 #if NUI_PROPERTY_CHANGE_3
320 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.AnchorPointY);
323 float returnValue = 0.0f;
324 PropertyValue anchorPointY = GetProperty(View.Property.AnchorPointY);
325 anchorPointY?.Get(out returnValue);
326 anchorPointY?.Dispose();
332 #if NUI_PROPERTY_CHANGE_3
333 Object.InternalSetPropertyFloat(SwigCPtr, View.Property.AnchorPointY, value);
335 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
336 SetProperty(View.Property.AnchorPointY, setValue);
342 internal float PivotPointZ
346 #if NUI_PROPERTY_CHANGE_3
347 return Object.InternalGetPropertyFloat(SwigCPtr, View.Property.AnchorPointZ);
349 float returnValue = 0.0f;
350 PropertyValue anchorPointZ = GetProperty(View.Property.AnchorPointZ);
351 anchorPointZ?.Get(out returnValue);
352 anchorPointZ?.Dispose();
358 #if NUI_PROPERTY_CHANGE_3
359 Object.InternalSetPropertyFloat(SwigCPtr, View.Property.AnchorPointZ, value);
361 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
362 SetProperty(View.Property.AnchorPointZ, setValue);
368 internal Matrix WorldMatrix
372 Matrix returnValue = new Matrix();
373 PropertyValue wordMatrix = GetProperty(View.Property.WorldMatrix);
374 wordMatrix?.Get(returnValue);
375 wordMatrix?.Dispose();
381 /// The number of layouts including view's layout and children's layouts.
382 /// This can be used to set/unset Process callback to calculate Layout.
384 internal int LayoutCount
393 if (layoutCount == value) return;
395 if (value < 0) throw new global::System.ArgumentOutOfRangeException(nameof(LayoutCount), "LayoutCount(" + LayoutCount + ") should not be less than zero");
397 int diff = value - layoutCount;
400 if (InternalParent != null)
402 var parentView = InternalParent as View;
403 if (parentView != null)
405 parentView.LayoutCount += diff;
409 var parentLayer = InternalParent as Layer;
410 if (parentLayer != null)
412 parentLayer.LayoutCount += diff;
420 /// Indicates that this View should listen Touch event to handle its ControlState.
422 private bool enableControlState = false;
424 private int LeftFocusableViewId
428 #if NUI_PROPERTY_CHANGE_3
429 return Object.InternalGetPropertyInt(SwigCPtr, View.Property.LeftFocusableViewId);
432 PropertyValue leftFocusableViewId = GetProperty(View.Property.LeftFocusableViewId);
433 leftFocusableViewId?.Get(out returnValue);
434 leftFocusableViewId?.Dispose();
440 #if NUI_PROPERTY_CHANGE_3
441 Object.InternalSetPropertyInt(SwigCPtr, View.Property.LeftFocusableViewId, value);
443 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
444 SetProperty(View.Property.LeftFocusableViewId, setValue);
450 private int RightFocusableViewId
454 #if NUI_PROPERTY_CHANGE_3
455 return Object.InternalGetPropertyInt(SwigCPtr, View.Property.RightFocusableViewId);
458 PropertyValue rightFocusableViewId = GetProperty(View.Property.RightFocusableViewId);
459 rightFocusableViewId?.Get(out returnValue);
460 rightFocusableViewId?.Dispose();
466 #if NUI_PROPERTY_CHANGE_3
467 Object.InternalSetPropertyInt(SwigCPtr, View.Property.RightFocusableViewId, value);
469 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
470 SetProperty(View.Property.RightFocusableViewId, setValue);
476 private int UpFocusableViewId
480 #if NUI_PROPERTY_CHANGE_3
481 return Object.InternalGetPropertyInt(SwigCPtr, View.Property.UpFocusableViewId);
484 PropertyValue upFocusableViewId = GetProperty(View.Property.UpFocusableViewId);
485 upFocusableViewId?.Get(out returnValue);
486 upFocusableViewId?.Dispose();
492 #if NUI_PROPERTY_CHANGE_3
493 Object.InternalSetPropertyInt(SwigCPtr, View.Property.UpFocusableViewId, value);
495 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
496 SetProperty(View.Property.UpFocusableViewId, setValue);
502 private int DownFocusableViewId
506 #if NUI_PROPERTY_CHANGE_3
507 return Object.InternalGetPropertyInt(SwigCPtr, View.Property.DownFocusableViewId);
510 PropertyValue downFocusableViewId = GetProperty(View.Property.DownFocusableViewId);
511 downFocusableViewId?.Get(out returnValue);
512 downFocusableViewId?.Dispose();
518 #if NUI_PROPERTY_CHANGE_3
519 Object.InternalSetPropertyInt(SwigCPtr, View.Property.DownFocusableViewId, value);
521 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
522 SetProperty(View.Property.DownFocusableViewId, setValue);
528 private int ClockwiseFocusableViewId
532 #if NUI_PROPERTY_CHANGE_3
533 return Object.InternalGetPropertyInt(SwigCPtr, View.Property.ClockwiseFocusableViewId);
535 int returnValue = -1;
536 PropertyValue clockwiseFocusableViewId = GetProperty(View.Property.ClockwiseFocusableViewId);
537 clockwiseFocusableViewId?.Get(out returnValue);
538 clockwiseFocusableViewId?.Dispose();
544 #if NUI_PROPERTY_CHANGE_3
545 Object.InternalSetPropertyInt(SwigCPtr, View.Property.ClockwiseFocusableViewId, value);
547 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
548 SetProperty(View.Property.ClockwiseFocusableViewId, setValue);
554 private int CounterClockwiseFocusableViewId
558 #if NUI_PROPERTY_CHANGE_3
559 return Object.InternalGetPropertyInt(SwigCPtr, View.Property.CounterClockwiseFocusableViewId);
561 int returnValue = -1;
562 PropertyValue counterClockwiseFocusableViewId = GetProperty(View.Property.CounterClockwiseFocusableViewId);
563 counterClockwiseFocusableViewId?.Get(out returnValue);
564 counterClockwiseFocusableViewId?.Dispose();
570 #if NUI_PROPERTY_CHANGE_3
571 Object.InternalSetPropertyInt(SwigCPtr, View.Property.CounterClockwiseFocusableViewId, value);
573 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
574 SetProperty(View.Property.CounterClockwiseFocusableViewId, setValue);
580 internal string GetName()
582 string ret = Interop.Actor.GetName(SwigCPtr);
583 if (NDalicPINVOKE.SWIGPendingException.Pending)
584 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
588 internal void SetName(string name)
590 Interop.Actor.SetName(SwigCPtr, name);
591 if (NDalicPINVOKE.SWIGPendingException.Pending)
592 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
595 internal uint GetId()
597 uint ret = Interop.Actor.GetId(SwigCPtr);
598 if (NDalicPINVOKE.SWIGPendingException.Pending)
599 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
603 internal bool IsRoot()
605 bool ret = Interop.ActorInternal.IsRoot(SwigCPtr);
606 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
610 internal bool OnWindow()
612 bool ret = Interop.Actor.OnStage(SwigCPtr);
613 if (NDalicPINVOKE.SWIGPendingException.Pending)
614 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
618 internal View FindChildById(uint id)
620 //to fix memory leak issue, match the handle count with native side.
621 IntPtr cPtr = Interop.Actor.FindChildById(SwigCPtr, id);
622 View ret = this.GetInstanceSafely<View>(cPtr);
623 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
627 internal override View FindCurrentChildById(uint id)
629 return FindChildById(id);
632 internal void SetParentOrigin(Position origin)
634 Interop.ActorInternal.SetParentOrigin(SwigCPtr, Position.getCPtr(origin));
635 if (NDalicPINVOKE.SWIGPendingException.Pending)
636 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
639 internal Position GetCurrentParentOrigin()
641 #if NUI_PROPERTY_CHANGE_3
642 if(internalCurrentParentOrigin == null)
644 internalCurrentParentOrigin = new Position(0, 0, 0);
647 Interop.ActorInternal.RetrieveCurrentPropertyVector3(SwigCPtr, View.Property.ParentOrigin, internalCurrentParentOrigin.SwigCPtr);
649 if (NDalicPINVOKE.SWIGPendingException.Pending)
651 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
653 return internalCurrentParentOrigin;
655 Position ret = new Position(Interop.ActorInternal.GetCurrentParentOrigin(SwigCPtr), true);
657 if (NDalicPINVOKE.SWIGPendingException.Pending)
658 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
663 internal void SetAnchorPoint(Position anchorPoint)
665 Interop.Actor.SetAnchorPoint(SwigCPtr, Position.getCPtr(anchorPoint));
666 if (NDalicPINVOKE.SWIGPendingException.Pending)
667 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
670 internal Position GetCurrentAnchorPoint()
672 #if NUI_PROPERTY_CHANGE_3
673 if(internalCurrentAnchorPoint == null)
675 internalCurrentAnchorPoint = new Position(0, 0, 0);
678 Interop.ActorInternal.RetrieveCurrentPropertyVector3(SwigCPtr, View.Property.AnchorPoint, internalCurrentAnchorPoint.SwigCPtr);
680 if (NDalicPINVOKE.SWIGPendingException.Pending)
682 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
684 return internalCurrentAnchorPoint;
686 Position ret = new Position(Interop.ActorInternal.GetCurrentAnchorPoint(SwigCPtr), true);
687 if (NDalicPINVOKE.SWIGPendingException.Pending)
688 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
693 internal void SetSize(float width, float height)
695 Interop.ActorInternal.SetSize(SwigCPtr, width, height);
696 if (NDalicPINVOKE.SWIGPendingException.Pending)
697 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
700 internal void SetSize(float width, float height, float depth)
702 Interop.ActorInternal.SetSize(SwigCPtr, width, height, depth);
703 if (NDalicPINVOKE.SWIGPendingException.Pending)
704 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
707 internal void SetSize(Vector2 size)
709 Interop.ActorInternal.SetSizeVector2(SwigCPtr, Vector2.getCPtr(size));
710 if (NDalicPINVOKE.SWIGPendingException.Pending)
711 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
714 internal void SetSize(Vector3 size)
716 Interop.ActorInternal.SetSizeVector3(SwigCPtr, Vector3.getCPtr(size));
717 if (NDalicPINVOKE.SWIGPendingException.Pending)
718 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
721 internal Vector3 GetTargetSize()
723 #if NUI_PROPERTY_CHANGE_3
724 if(internalTargetSize == null)
726 internalTargetSize = new Vector3(0, 0, 0);
729 Interop.ActorInternal.RetrieveTargetSize(SwigCPtr, internalTargetSize.SwigCPtr);
731 if (NDalicPINVOKE.SWIGPendingException.Pending)
733 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
735 return internalTargetSize;
737 Vector3 ret = new Vector3(Interop.ActorInternal.GetTargetSize(SwigCPtr), true);
738 if (NDalicPINVOKE.SWIGPendingException.Pending)
739 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
744 internal Size2D GetCurrentSize()
746 #if NUI_PROPERTY_CHANGE_3
747 if(internalCurrentSize == null)
749 internalCurrentSize = new Size2D(0, 0);
752 Interop.ActorInternal.RetrieveCurrentPropertyVector2ActualVector3(SwigCPtr, Property.SIZE, internalCurrentSize.SwigCPtr);
754 if (NDalicPINVOKE.SWIGPendingException.Pending)
756 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
758 return internalCurrentSize;
760 Size ret = new Size(Interop.Actor.GetCurrentSize(SwigCPtr), true);
761 if (NDalicPINVOKE.SWIGPendingException.Pending)
762 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
763 Size2D size = new Size2D((int)ret.Width, (int)ret.Height);
769 internal Size2D GetCurrentSizeFloat()
771 Size ret = new Size(Interop.Actor.GetCurrentSize(SwigCPtr), true);
772 if (NDalicPINVOKE.SWIGPendingException.Pending)
773 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
778 /// GetNaturalSize() function behaviour can be changed for each subclass of View.
779 /// So we make GetNaturalSize() function virtual, and make subclass can define it's owned logic
781 internal virtual Vector3 GetNaturalSize()
783 Vector3 ret = new Vector3(Interop.Actor.GetNaturalSize(SwigCPtr), true);
784 if (NDalicPINVOKE.SWIGPendingException.Pending)
785 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
789 internal void SetX(float x)
791 Interop.ActorInternal.SetX(SwigCPtr, x);
792 if (NDalicPINVOKE.SWIGPendingException.Pending)
793 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
796 internal void SetY(float y)
798 Interop.ActorInternal.SetY(SwigCPtr, y);
799 if (NDalicPINVOKE.SWIGPendingException.Pending)
800 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
803 internal void SetZ(float z)
805 Interop.ActorInternal.SetZ(SwigCPtr, z);
806 if (NDalicPINVOKE.SWIGPendingException.Pending)
807 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
810 internal void TranslateBy(Vector3 distance)
812 Interop.ActorInternal.TranslateBy(SwigCPtr, Vector3.getCPtr(distance));
813 if (NDalicPINVOKE.SWIGPendingException.Pending)
814 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
817 internal Position GetCurrentPosition()
819 #if NUI_PROPERTY_CHANGE_3
820 if(internalCurrentPosition == null)
822 internalCurrentPosition = new Position(0, 0, 0);
825 Interop.ActorInternal.RetrieveCurrentPropertyVector3(SwigCPtr, Property.POSITION, internalCurrentPosition.SwigCPtr);
827 if (NDalicPINVOKE.SWIGPendingException.Pending)
829 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
831 return internalCurrentPosition;
834 Position ret = new Position(Interop.Actor.GetCurrentPosition(SwigCPtr), true);
835 if (NDalicPINVOKE.SWIGPendingException.Pending)
836 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
840 internal Vector3 GetCurrentWorldPosition()
842 #if NUI_PROPERTY_CHANGE_3
843 if(internalCurrentWorldPosition == null)
845 internalCurrentWorldPosition = new Vector3(0, 0, 0);
848 Interop.ActorInternal.RetrieveCurrentPropertyVector3(SwigCPtr, View.Property.WorldPosition, internalCurrentWorldPosition.SwigCPtr);
850 if (NDalicPINVOKE.SWIGPendingException.Pending)
852 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
854 return internalCurrentWorldPosition;
856 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentWorldPosition(SwigCPtr), true);
857 if (NDalicPINVOKE.SWIGPendingException.Pending)
858 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
863 internal Vector2 GetCurrentScreenPosition()
865 #if NUI_VISUAL_PROPERTY_CHANGE_1
866 if(internalCurrentScreenPosition == null)
868 internalCurrentScreenPosition = new Vector2(0, 0);
871 Object.InternalRetrievingPropertyVector2(SwigCPtr, View.Property.ScreenPosition, internalCurrentScreenPosition.SwigCPtr);
873 if (NDalicPINVOKE.SWIGPendingException.Pending)
875 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
877 return internalCurrentScreenPosition;
879 Vector2 temp = new Vector2(0.0f, 0.0f);
880 var pValue = GetProperty(View.Property.ScreenPosition);
887 internal Vector4 GetCurrentScreenPositionSize()
889 Vector4 ret = new Vector4(Interop.Actor.CalculateScreenExtents(SwigCPtr), true);
890 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
894 internal void SetInheritPosition(bool inherit)
896 Interop.ActorInternal.SetInheritPosition(SwigCPtr, inherit);
897 if (NDalicPINVOKE.SWIGPendingException.Pending)
898 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
901 internal bool IsPositionInherited()
903 bool ret = Interop.ActorInternal.IsPositionInherited(SwigCPtr);
904 if (NDalicPINVOKE.SWIGPendingException.Pending)
905 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
909 internal void SetOrientation(Degree angle, Vector3 axis)
911 Interop.ActorInternal.SetOrientationDegree(SwigCPtr, Degree.getCPtr(angle), Vector3.getCPtr(axis));
912 if (NDalicPINVOKE.SWIGPendingException.Pending)
913 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
916 internal void SetOrientation(Radian angle, Vector3 axis)
918 Interop.ActorInternal.SetOrientationRadian(SwigCPtr, Radian.getCPtr(angle), Vector3.getCPtr(axis));
919 if (NDalicPINVOKE.SWIGPendingException.Pending)
920 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
923 internal void SetOrientation(Rotation orientation)
925 Interop.ActorInternal.SetOrientationQuaternion(SwigCPtr, Rotation.getCPtr(orientation));
926 if (NDalicPINVOKE.SWIGPendingException.Pending)
927 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
930 internal Rotation GetCurrentOrientation()
932 Rotation ret = new Rotation(Interop.ActorInternal.GetCurrentOrientation(SwigCPtr), true);
933 if (NDalicPINVOKE.SWIGPendingException.Pending)
934 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
938 internal void SetInheritOrientation(bool inherit)
940 Interop.ActorInternal.SetInheritOrientation(SwigCPtr, inherit);
941 if (NDalicPINVOKE.SWIGPendingException.Pending)
942 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
945 internal bool IsOrientationInherited()
947 bool ret = Interop.ActorInternal.IsOrientationInherited(SwigCPtr);
948 if (NDalicPINVOKE.SWIGPendingException.Pending)
949 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
953 internal Rotation GetCurrentWorldOrientation()
955 Rotation ret = new Rotation(Interop.ActorInternal.GetCurrentWorldOrientation(SwigCPtr), true);
956 if (NDalicPINVOKE.SWIGPendingException.Pending)
957 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
961 internal void SetScale(float scale)
963 Interop.ActorInternal.SetScale(SwigCPtr, scale);
964 if (NDalicPINVOKE.SWIGPendingException.Pending)
965 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
968 internal void SetScale(float scaleX, float scaleY, float scaleZ)
970 Interop.ActorInternal.SetScale(SwigCPtr, scaleX, scaleY, scaleZ);
971 if (NDalicPINVOKE.SWIGPendingException.Pending)
972 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
975 internal void SetScale(Vector3 scale)
977 Interop.ActorInternal.SetScale(SwigCPtr, Vector3.getCPtr(scale));
978 if (NDalicPINVOKE.SWIGPendingException.Pending)
979 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
982 internal Vector3 GetCurrentScale()
984 #if NUI_PROPERTY_CHANGE_3
985 if(internalCurrentScale == null)
987 internalCurrentScale = new Vector3(0, 0, 0);
990 Interop.ActorInternal.RetrieveCurrentPropertyVector3(SwigCPtr, View.Property.SCALE, internalCurrentScale.SwigCPtr);
992 if (NDalicPINVOKE.SWIGPendingException.Pending)
994 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
996 return internalCurrentScale;
999 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentScale(SwigCPtr), true);
1000 if (NDalicPINVOKE.SWIGPendingException.Pending)
1001 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1006 internal Vector3 GetCurrentWorldScale()
1008 #if NUI_PROPERTY_CHANGE_3
1009 if(internalCurrentWorldScale == null)
1011 internalCurrentWorldScale = new Vector3(0, 0, 0);
1014 Interop.ActorInternal.RetrieveCurrentPropertyVector3(SwigCPtr, View.Property.WorldScale, internalCurrentWorldScale.SwigCPtr);
1016 if (NDalicPINVOKE.SWIGPendingException.Pending)
1018 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1020 return internalCurrentWorldScale;
1023 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentWorldScale(SwigCPtr), true);
1024 if (NDalicPINVOKE.SWIGPendingException.Pending)
1025 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1030 internal void SetInheritScale(bool inherit)
1032 Interop.ActorInternal.SetInheritScale(SwigCPtr, inherit);
1033 if (NDalicPINVOKE.SWIGPendingException.Pending)
1034 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1037 internal bool IsScaleInherited()
1039 bool ret = Interop.ActorInternal.IsScaleInherited(SwigCPtr);
1040 if (NDalicPINVOKE.SWIGPendingException.Pending)
1041 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1045 internal Matrix GetCurrentWorldMatrix()
1047 Matrix ret = new Matrix(Interop.ActorInternal.GetCurrentWorldMatrix(SwigCPtr), true);
1048 if (NDalicPINVOKE.SWIGPendingException.Pending)
1049 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1053 internal void SetVisible(bool visible)
1055 Interop.Actor.SetVisible(SwigCPtr, visible);
1056 if (NDalicPINVOKE.SWIGPendingException.Pending)
1057 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1061 /// Retrieve the View's current Visibility.
1064 /// The <see cref="Visibility"/> property is set in the main thread, so it is not updated in real time when the value is changed in the render thread.
1065 /// However, this method can get the current actual value updated in real time.
1067 internal bool IsVisible()
1069 bool ret = Interop.ActorInternal.IsVisible(SwigCPtr);
1070 if (NDalicPINVOKE.SWIGPendingException.Pending)
1071 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1075 internal void SetOpacity(float opacity)
1077 Interop.ActorInternal.SetOpacity(SwigCPtr, opacity);
1078 if (NDalicPINVOKE.SWIGPendingException.Pending)
1079 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1082 internal float GetCurrentOpacity()
1084 float ret = Interop.ActorInternal.GetCurrentOpacity(SwigCPtr);
1085 if (NDalicPINVOKE.SWIGPendingException.Pending)
1086 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1090 internal Vector4 GetCurrentColor()
1092 #if NUI_PROPERTY_CHANGE_3
1093 if(internalCurrentColor == null)
1095 internalCurrentColor = new Vector4(0, 0, 0, 0);
1098 Interop.ActorInternal.RetrieveCurrentPropertyVector4(SwigCPtr, Interop.ActorProperty.ColorGet(), internalCurrentColor.SwigCPtr);
1100 if (NDalicPINVOKE.SWIGPendingException.Pending)
1102 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1104 return internalCurrentColor;
1107 Vector4 ret = new Vector4(Interop.ActorInternal.GetCurrentColor(SwigCPtr), true);
1108 if (NDalicPINVOKE.SWIGPendingException.Pending)
1109 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1113 internal ColorMode GetColorMode()
1115 ColorMode ret = (ColorMode)Interop.ActorInternal.GetColorMode(SwigCPtr);
1116 if (NDalicPINVOKE.SWIGPendingException.Pending)
1117 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1121 internal Vector4 GetCurrentWorldColor()
1123 #if NUI_PROPERTY_CHANGE_3
1124 if(internalCurrentWorldColor == null)
1126 internalCurrentWorldColor = new Vector4(0, 0, 0, 0);
1129 Interop.ActorInternal.RetrieveCurrentPropertyVector4(SwigCPtr, Property.WorldColor, internalCurrentWorldColor.SwigCPtr);
1131 if (NDalicPINVOKE.SWIGPendingException.Pending)
1133 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1135 return internalCurrentWorldColor;
1138 Vector4 ret = new Vector4(Interop.ActorInternal.GetCurrentWorldColor(SwigCPtr), true);
1139 if (NDalicPINVOKE.SWIGPendingException.Pending)
1140 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1145 internal void SetDrawMode(DrawModeType drawMode)
1147 Interop.ActorInternal.SetDrawMode(SwigCPtr, (int)drawMode);
1148 if (NDalicPINVOKE.SWIGPendingException.Pending)
1149 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1152 internal DrawModeType GetDrawMode()
1154 DrawModeType ret = (DrawModeType)Interop.ActorInternal.GetDrawMode(SwigCPtr);
1155 if (NDalicPINVOKE.SWIGPendingException.Pending)
1156 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1160 internal void SetKeyboardFocusable(bool focusable)
1162 Interop.ActorInternal.SetKeyboardFocusable(SwigCPtr, focusable);
1163 if (NDalicPINVOKE.SWIGPendingException.Pending)
1164 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1167 internal bool IsKeyboardFocusable()
1169 bool ret = Interop.ActorInternal.IsKeyboardFocusable(SwigCPtr);
1170 if (NDalicPINVOKE.SWIGPendingException.Pending)
1171 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1175 internal void SetKeyboardFocusableChildren(bool focusable)
1177 Interop.ActorInternal.SetKeyboardFocusableChildren(SwigCPtr, focusable);
1178 if (NDalicPINVOKE.SWIGPendingException.Pending)
1179 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1182 internal bool AreChildrenKeyBoardFocusable()
1184 bool ret = Interop.ActorInternal.AreChildrenKeyBoardFocusable(SwigCPtr);
1185 if (NDalicPINVOKE.SWIGPendingException.Pending)
1186 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1190 internal void SetFocusableInTouch(bool enabled)
1192 Interop.ActorInternal.SetFocusableInTouch(SwigCPtr, enabled);
1193 if (NDalicPINVOKE.SWIGPendingException.Pending)
1194 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1197 internal bool IsFocusableInTouch()
1199 bool ret = Interop.ActorInternal.IsFocusableInTouch(SwigCPtr);
1200 if (NDalicPINVOKE.SWIGPendingException.Pending)
1201 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1205 internal void SetResizePolicy(ResizePolicyType policy, DimensionType dimension)
1207 Interop.Actor.SetResizePolicy(SwigCPtr, (int)policy, (int)dimension);
1208 if (NDalicPINVOKE.SWIGPendingException.Pending)
1209 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1212 internal ResizePolicyType GetResizePolicy(DimensionType dimension)
1214 ResizePolicyType ret = (ResizePolicyType)Interop.Actor.GetResizePolicy(SwigCPtr, (int)dimension);
1215 if (NDalicPINVOKE.SWIGPendingException.Pending)
1216 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1220 internal Vector3 GetSizeModeFactor()
1222 #if NUI_PROPERTY_CHANGE_1
1223 if (internalSizeModeFactor == null)
1225 internalSizeModeFactor = new Vector3(OnSizeModeFactorChanged, 0, 0, 0);
1227 Object.InternalRetrievingPropertyVector3(SwigCPtr, View.Property.SizeModeFactor, internalSizeModeFactor.SwigCPtr);
1228 return internalSizeModeFactor;
1231 Vector3 ret = new Vector3(Interop.Actor.GetSizeModeFactor(SwigCPtr), true);
1232 if (NDalicPINVOKE.SWIGPendingException.Pending)
1233 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1238 internal void SetMinimumSize(Vector2 size)
1240 Interop.ActorInternal.SetMinimumSize(SwigCPtr, Vector2.getCPtr(size));
1241 if (NDalicPINVOKE.SWIGPendingException.Pending)
1242 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1245 internal Vector2 GetMinimumSize()
1247 #if NUI_PROPERTY_CHANGE_1
1248 if (internalMinimumSize == null)
1250 internalMinimumSize = new Size2D(OnMinimumSizeChanged, 0, 0);
1252 Object.InternalRetrievingPropertyVector2(SwigCPtr, View.Property.MinimumSize, internalMinimumSize.SwigCPtr);
1253 return internalMinimumSize;
1255 Vector2 ret = new Vector2(Interop.ActorInternal.GetMinimumSize(SwigCPtr), true);
1256 if (NDalicPINVOKE.SWIGPendingException.Pending)
1257 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1262 internal void SetMaximumSize(Vector2 size)
1264 Interop.ActorInternal.SetMaximumSize(SwigCPtr, Vector2.getCPtr(size));
1265 if (NDalicPINVOKE.SWIGPendingException.Pending)
1266 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1269 internal Vector2 GetMaximumSize()
1271 #if NUI_PROPERTY_CHANGE_1
1272 if (internalMaximumSize == null)
1274 internalMaximumSize = new Size2D(OnMaximumSizeChanged, 0, 0);
1276 Object.InternalRetrievingPropertyVector2(SwigCPtr, View.Property.MaximumSize, internalMaximumSize.SwigCPtr);
1277 return internalMaximumSize;
1280 Vector2 ret = new Vector2(Interop.ActorInternal.GetMaximumSize(SwigCPtr), true);
1281 if (NDalicPINVOKE.SWIGPendingException.Pending)
1282 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1287 internal int GetHierarchyDepth()
1289 int ret = Interop.Actor.GetHierarchyDepth(SwigCPtr);
1290 if (NDalicPINVOKE.SWIGPendingException.Pending)
1291 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1295 internal uint GetRendererCount()
1297 uint ret = Interop.Actor.GetRendererCount(SwigCPtr);
1298 if (NDalicPINVOKE.SWIGPendingException.Pending)
1299 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1303 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(View obj)
1305 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
1308 internal bool IsTopLevelView()
1310 if (GetParent() is Layer)
1318 /// Check whether Current view don't has BackgroundVisual or not.
1319 /// Some API (like Animation, Borderline) required non-empty backgrounds.
1321 internal bool IsBackgroundEmpty()
1323 #if NUI_VISUAL_PROPERTY_CHANGE_1
1324 int visualType = (int)Visual.Type.Invalid;
1325 Interop.View.InternalRetrievingVisualPropertyInt(this.SwigCPtr, Property.BACKGROUND, Visual.Property.Type, out visualType);
1326 return visualType == (int)Visual.Type.Invalid;
1328 PropertyMap background = Background;
1329 return (background == null || background.Empty());
1333 internal void SetKeyInputFocus()
1335 Interop.ViewInternal.SetKeyInputFocus(SwigCPtr);
1336 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1339 internal void ClearKeyInputFocus()
1341 Interop.ViewInternal.ClearKeyInputFocus(SwigCPtr);
1342 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1345 internal PinchGestureDetector GetPinchGestureDetector()
1347 PinchGestureDetector ret = new PinchGestureDetector(Interop.ViewInternal.GetPinchGestureDetector(SwigCPtr), true);
1348 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1352 internal PanGestureDetector GetPanGestureDetector()
1354 PanGestureDetector ret = new PanGestureDetector(Interop.ViewInternal.GetPanGestureDetector(SwigCPtr), true);
1355 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1359 internal TapGestureDetector GetTapGestureDetector()
1361 TapGestureDetector ret = new TapGestureDetector(Interop.ViewInternal.GetTapGestureDetector(SwigCPtr), true);
1362 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1366 internal LongPressGestureDetector GetLongPressGestureDetector()
1368 LongPressGestureDetector ret = new LongPressGestureDetector(Interop.ViewInternal.GetLongPressGestureDetector(SwigCPtr), true);
1369 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1373 internal IntPtr GetPtrfromView()
1375 return (IntPtr)SwigCPtr;
1378 internal void RemoveChild(View child)
1380 // If the view had focus, it clears focus.
1381 if (child == FocusManager.Instance.GetCurrentFocusView())
1383 FocusManager.Instance.ClearFocus();
1385 // Do actual child removal
1386 Interop.Actor.Remove(SwigCPtr, View.getCPtr(child));
1387 if (NDalicPINVOKE.SWIGPendingException.Pending)
1388 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1390 Children.Remove(child);
1391 child.InternalParent = null;
1392 LayoutCount -= child.LayoutCount;
1394 OnChildRemoved(child);
1395 if (ChildRemoved != null)
1397 ChildRemovedEventArgs e = new ChildRemovedEventArgs
1401 ChildRemoved(this, e);
1406 /// Removes the layout from this View.
1408 internal void ResetLayout()
1415 internal ResourceLoadingStatusType GetBackgroundResourceStatus()
1417 return (ResourceLoadingStatusType)Interop.View.GetVisualResourceStatus(this.SwigCPtr, Property.BACKGROUND);
1420 /// TODO open as a protected level
1421 internal virtual void ApplyCornerRadius()
1423 if (backgroundExtraData == null) return;
1425 #if NUI_VISUAL_PROPERTY_CHANGE_1
1426 // Update corner radius properties to background and shadow by ActionUpdateProperty
1427 if (backgroundExtraData.CornerRadius != null)
1429 Interop.View.InternalUpdateVisualPropertyVector4(this.SwigCPtr, View.Property.BACKGROUND, Visual.Property.CornerRadius, Vector4.getCPtr(backgroundExtraData.CornerRadius));
1430 Interop.View.InternalUpdateVisualPropertyVector4(this.SwigCPtr, View.Property.SHADOW, Visual.Property.CornerRadius, Vector4.getCPtr(backgroundExtraData.CornerRadius));
1432 Interop.View.InternalUpdateVisualPropertyInt(this.SwigCPtr, View.Property.BACKGROUND, Visual.Property.CornerRadiusPolicy, (int)backgroundExtraData.CornerRadiusPolicy);
1433 Interop.View.InternalUpdateVisualPropertyInt(this.SwigCPtr, View.Property.SHADOW, Visual.Property.CornerRadiusPolicy, (int)backgroundExtraData.CornerRadiusPolicy);
1435 var cornerRadiusValue = backgroundExtraData.CornerRadius == null ? new PropertyValue() : new PropertyValue(backgroundExtraData.CornerRadius);
1436 var cornerRadiusPolicyValue = new PropertyValue((int)backgroundExtraData.CornerRadiusPolicy);
1438 // Make current propertyMap
1439 PropertyMap currentPropertyMap = new PropertyMap();
1440 currentPropertyMap[Visual.Property.CornerRadius] = cornerRadiusValue;
1441 currentPropertyMap[Visual.Property.CornerRadiusPolicy] = cornerRadiusPolicyValue;
1442 var temp = new PropertyValue(currentPropertyMap);
1444 // Update corner radius properties to background and shadow by ActionUpdateProperty
1445 DoAction(View.Property.BACKGROUND, ActionUpdateProperty, temp);
1446 DoAction(View.Property.SHADOW, ActionUpdateProperty, temp);
1449 currentPropertyMap.Dispose();
1450 cornerRadiusValue.Dispose();
1451 cornerRadiusPolicyValue.Dispose();
1455 /// TODO open as a protected level
1456 internal virtual void ApplyBorderline()
1458 if (backgroundExtraData == null) return;
1460 #if NUI_VISUAL_PROPERTY_CHANGE_1
1461 // ActionUpdateProperty works well only if BACKGROUND visual setup before.
1462 // If view don't have BACKGROUND visual, we set transparent background color in default.
1463 if (IsBackgroundEmpty())
1465 // BACKGROUND visual doesn't exist.
1466 SetBackgroundColor(Color.Transparent);
1467 // SetBackgroundColor function apply borderline internally.
1468 // So we can just return now.
1472 // Update borderline properties to background by ActionUpdateProperty
1473 Interop.View.InternalUpdateVisualPropertyFloat(this.SwigCPtr, View.Property.BACKGROUND, Visual.Property.BorderlineWidth, backgroundExtraData.BorderlineWidth);
1474 Interop.View.InternalUpdateVisualPropertyVector4(this.SwigCPtr, View.Property.BACKGROUND, Visual.Property.BorderlineColor, Vector4.getCPtr(backgroundExtraData.BorderlineColor ?? Color.Black));
1475 Interop.View.InternalUpdateVisualPropertyFloat(this.SwigCPtr, View.Property.BACKGROUND, Visual.Property.BorderlineOffset, backgroundExtraData.BorderlineOffset);
1477 // ActionUpdateProperty works well only if BACKGROUND visual setup before.
1478 // If view don't have BACKGROUND visual, we set transparent background color in default.
1479 using (PropertyMap backgroundPropertyMap = new PropertyMap())
1481 using (PropertyValue propertyValue = Object.GetProperty(SwigCPtr, Property.BACKGROUND))
1483 propertyValue?.Get(backgroundPropertyMap);
1484 if (backgroundPropertyMap.Empty())
1486 // BACKGROUND visual doesn't exist.
1487 SetBackgroundColor(Color.Transparent);
1488 // SetBackgroundColor function apply borderline internally.
1489 // So we can just return now.
1495 var borderlineWidthValue = new PropertyValue(backgroundExtraData.BorderlineWidth);
1496 var borderlineColorValue = backgroundExtraData.BorderlineColor == null ? new PropertyValue(Color.Black) : new PropertyValue(backgroundExtraData.BorderlineColor);
1497 var borderlineOffsetValue = new PropertyValue(backgroundExtraData.BorderlineOffset);
1499 // Make current propertyMap
1500 PropertyMap currentPropertyMap = new PropertyMap();
1501 currentPropertyMap[Visual.Property.BorderlineWidth] = borderlineWidthValue;
1502 currentPropertyMap[Visual.Property.BorderlineColor] = borderlineColorValue;
1503 currentPropertyMap[Visual.Property.BorderlineOffset] = borderlineOffsetValue;
1504 var temp = new PropertyValue(currentPropertyMap);
1506 // Update borderline properties to background by ActionUpdateProperty
1507 DoAction(View.Property.BACKGROUND, ActionUpdateProperty, temp);
1510 currentPropertyMap.Dispose();
1511 borderlineWidthValue.Dispose();
1512 borderlineColorValue.Dispose();
1513 borderlineOffsetValue.Dispose();
1518 /// Get selector value from the triggerable selector or related property.
1520 internal Selector<T> GetSelector<T>(TriggerableSelector<T> triggerableSelector, NUI.Binding.BindableProperty relatedProperty)
1522 var selector = triggerableSelector?.Get();
1523 if (selector != null)
1528 var value = (T)GetValue(relatedProperty);
1529 return value == null ? null : new Selector<T>(value);
1532 internal void SetThemeApplied()
1534 if (themeData == null) themeData = new ThemeData();
1535 themeData.ThemeApplied = true;
1537 if (ThemeChangeSensitive && !themeData.ListeningThemeChangeEvent)
1539 themeData.ListeningThemeChangeEvent = true;
1540 ThemeManager.ThemeChangedInternal.Add(OnThemeChanged);
1545 /// you can override it to clean-up your own resources.
1547 /// <param name="type">DisposeTypes</param>
1548 /// <since_tizen> 3 </since_tizen>
1549 protected override void Dispose(DisposeTypes type)
1556 disposeDebugging(type);
1558 //_mergedStyle = null;
1560 internalMaximumSize?.Dispose();
1561 internalMaximumSize = null;
1562 internalMinimumSize?.Dispose();
1563 internalMinimumSize = null;
1564 internalMargin?.Dispose();
1565 internalMargin = null;
1566 internalPadding?.Dispose();
1567 internalPadding = null;
1568 internalSizeModeFactor?.Dispose();
1569 internalSizeModeFactor = null;
1570 internalCellIndex?.Dispose();
1571 internalCellIndex = null;
1572 internalBackgroundColor?.Dispose();
1573 internalBackgroundColor = null;
1574 internalColor?.Dispose();
1575 internalColor = null;
1576 internalPivotPoint?.Dispose();
1577 internalPivotPoint = null;
1578 internalPosition?.Dispose();
1579 internalPosition = null;
1580 internalPosition2D?.Dispose();
1581 internalPosition2D = null;
1582 internalScale?.Dispose();
1583 internalScale = null;
1584 internalSize?.Dispose();
1585 internalSize = null;
1586 internalSize2D?.Dispose();
1587 internalSize2D = null;
1589 panGestureDetector?.Dispose();
1590 panGestureDetector = null;
1591 longGestureDetector?.Dispose();
1592 longGestureDetector = null;
1593 pinchGestureDetector?.Dispose();
1594 pinchGestureDetector = null;
1595 tapGestureDetector?.Dispose();
1596 tapGestureDetector = null;
1597 rotationGestureDetector?.Dispose();
1598 rotationGestureDetector = null;
1600 #if NUI_PROPERTY_CHANGE_3
1601 internalCurrentParentOrigin?.Dispose();
1602 internalCurrentParentOrigin = null;
1603 internalCurrentAnchorPoint?.Dispose();
1604 internalCurrentAnchorPoint = null;
1605 internalTargetSize?.Dispose();
1606 internalTargetSize = null;
1607 internalCurrentSize?.Dispose();
1608 internalCurrentSize = null;
1609 internalNaturalSize?.Dispose();
1610 internalNaturalSize = null;
1611 internalCurrentPosition?.Dispose();
1612 internalCurrentPosition = null;
1613 internalCurrentWorldPosition?.Dispose();
1614 internalCurrentWorldPosition = null;
1615 internalCurrentScale?.Dispose();
1616 internalCurrentScale = null;
1617 internalCurrentWorldScale?.Dispose();
1618 internalCurrentWorldScale = null;
1619 internalCurrentColor?.Dispose();
1620 internalCurrentColor = null;
1621 internalCurrentWorldColor?.Dispose();
1622 internalCurrentWorldColor = null;
1623 internalSizeModeFactor?.Dispose();
1624 internalSizeModeFactor = null;
1626 #if NUI_VISUAL_PROPERTY_CHANGE_1
1627 internalCurrentScreenPosition?.Dispose();
1628 internalCurrentScreenPosition = null;
1631 if (type == DisposeTypes.Explicit)
1634 //Release your own managed resources here.
1635 //You should release all of your own disposable objects here.
1636 if (themeData != null)
1638 themeData.selectorData?.Reset(this);
1639 if (themeData.ListeningThemeChangeEvent)
1641 ThemeManager.ThemeChangedInternal.Remove(OnThemeChanged);
1644 if (widthConstraint != null)
1646 widthConstraint.Remove();
1647 widthConstraint.Dispose();
1649 if (heightConstraint != null)
1651 heightConstraint.Remove();
1652 heightConstraint.Dispose();
1656 //Release your own unmanaged resources here.
1657 //You should not access any managed member here except static instance.
1658 //because the execution order of Finalizes is non-deterministic.
1660 DisConnectFromSignals();
1662 foreach (View view in Children)
1664 view.InternalParent = null;
1669 NUILog.Debug($"[Dispose] View.Dispose({type}) END");
1670 NUILog.Debug($"=============================");
1675 /// This will not be public opened.
1676 [EditorBrowsable(EditorBrowsableState.Never)]
1677 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1679 Interop.View.DeleteView(swigCPtr);
1683 /// The touch event handler for ControlState.
1684 /// Please change ControlState value by touch state if needed.
1686 /// <exception cref="ArgumentNullException"> Thrown when touch is null. </exception>
1687 [EditorBrowsable(EditorBrowsableState.Never)]
1688 protected virtual bool HandleControlStateOnTouch(Touch touch)
1692 throw new global::System.ArgumentNullException(nameof(touch));
1695 switch (touch.GetState(0))
1697 case PointStateType.Down:
1698 ControlState += ControlState.Pressed;
1700 case PointStateType.Interrupted:
1701 case PointStateType.Up:
1702 if (ControlState.Contains(ControlState.Pressed))
1704 ControlState -= ControlState.Pressed;
1714 /// Internal callback of enabled property changes.
1715 /// Inherited view can override this method to implements enabled property changes.
1717 [EditorBrowsable(EditorBrowsableState.Never)]
1718 protected virtual void OnEnabled(bool enabled)
1722 if (State == View.States.Disabled)
1724 State = View.States.Normal;
1726 if (enableControlState)
1728 ControlState -= ControlState.Disabled;
1733 State = View.States.Disabled;
1734 if (enableControlState)
1736 ControlState += ControlState.Disabled;
1742 private void DisConnectFromSignals()
1744 if (HasBody() == false)
1746 NUILog.Debug($"[Dispose] DisConnectFromSignals() No native body! No need to Disconnect Signals!");
1749 NUILog.Debug($"[Dispose] DisConnectFromSignals START");
1750 NUILog.Debug($"[Dispose] View.DisConnectFromSignals() type:{GetType()} copyNativeHandle:{GetBaseHandleCPtrHandleRef.Handle.ToString("X8")}");
1751 NUILog.Debug($"[Dispose] ID:{Interop.Actor.GetId(GetBaseHandleCPtrHandleRef)} Name:{Interop.Actor.GetName(GetBaseHandleCPtrHandleRef)}");
1753 if (onRelayoutEventCallback != null)
1755 NUILog.Debug($"[Dispose] onRelayoutEventCallback");
1757 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnRelayoutSignal(GetBaseHandleCPtrHandleRef), false);
1758 signal?.Disconnect(onRelayoutEventCallback);
1759 onRelayoutEventCallback = null;
1762 if (offWindowEventCallback != null)
1764 NUILog.Debug($"[Dispose] offWindowEventCallback");
1766 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOffSceneSignal(GetBaseHandleCPtrHandleRef), false);
1767 signal?.Disconnect(offWindowEventCallback);
1768 offWindowEventCallback = null;
1771 if (onWindowEventCallback != null)
1773 NUILog.Debug($"[Dispose] onWindowEventCallback");
1775 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(GetBaseHandleCPtrHandleRef), false);
1776 signal?.Disconnect(onWindowEventCallback);
1777 onWindowEventCallback = null;
1780 if (wheelEventCallback != null)
1782 NUILog.Debug($"[Dispose] wheelEventCallback");
1784 using WheelSignal signal = new WheelSignal(Interop.ActorSignal.ActorWheelEventSignal(GetBaseHandleCPtrHandleRef), false);
1785 signal?.Disconnect(wheelEventCallback);
1786 wheelEventCallback = null;
1789 if (hoverEventCallback != null)
1791 NUILog.Debug($"[Dispose] hoverEventCallback");
1793 using HoverSignal signal = new HoverSignal(Interop.ActorSignal.ActorHoveredSignal(GetBaseHandleCPtrHandleRef), false);
1794 signal?.Disconnect(hoverEventCallback);
1795 hoverEventCallback = null;
1798 if (hitTestResultDataCallback != null)
1800 NUILog.Debug($"[Dispose] hitTestResultDataCallback");
1802 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorHitTestResultSignal(GetBaseHandleCPtrHandleRef), false);
1803 signal?.Disconnect(hitTestResultDataCallback);
1804 hitTestResultDataCallback = null;
1808 if (interceptTouchDataCallback != null)
1810 NUILog.Debug($"[Dispose] interceptTouchDataCallback");
1812 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorInterceptTouchSignal(GetBaseHandleCPtrHandleRef), false);
1813 signal?.Disconnect(interceptTouchDataCallback);
1814 interceptTouchDataCallback = null;
1817 if (touchDataCallback != null)
1819 NUILog.Debug($"[Dispose] touchDataCallback");
1821 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorTouchSignal(GetBaseHandleCPtrHandleRef), false);
1822 signal?.Disconnect(touchDataCallback);
1823 touchDataCallback = null;
1826 if (ResourcesLoadedCallback != null)
1828 NUILog.Debug($"[Dispose] ResourcesLoadedCallback");
1830 using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(GetBaseHandleCPtrHandleRef), false);
1831 signal?.Disconnect(ResourcesLoadedCallback);
1832 ResourcesLoadedCallback = null;
1835 if (keyCallback != null)
1837 NUILog.Debug($"[Dispose] keyCallback");
1839 using ControlKeySignal signal = new ControlKeySignal(Interop.ViewSignal.KeyEventSignal(GetBaseHandleCPtrHandleRef), false);
1840 signal?.Disconnect(keyCallback);
1844 if (keyInputFocusLostCallback != null)
1846 NUILog.Debug($"[Dispose] keyInputFocusLostCallback");
1848 using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusLostSignal(GetBaseHandleCPtrHandleRef), false);
1849 signal?.Disconnect(keyInputFocusLostCallback);
1850 keyInputFocusLostCallback = null;
1851 keyInputFocusLostEventHandler = null;
1854 if (keyInputFocusGainedCallback != null)
1856 NUILog.Debug($"[Dispose] keyInputFocusGainedCallback");
1858 using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusGainedSignal(GetBaseHandleCPtrHandleRef), false);
1859 signal?.Disconnect(keyInputFocusGainedCallback);
1860 keyInputFocusGainedCallback = null;
1861 keyInputFocusGainedEventHandler = null;
1864 if (backgroundResourceLoadedCallback != null)
1866 NUILog.Debug($"[Dispose] backgroundResourceLoadedCallback");
1868 using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(GetBaseHandleCPtrHandleRef), false);
1869 signal?.Disconnect(backgroundResourceLoadedCallback);
1870 backgroundResourceLoadedCallback = null;
1873 if (onWindowSendEventCallback != null)
1875 NUILog.Debug($"[Dispose] onWindowSendEventCallback");
1877 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(GetBaseHandleCPtrHandleRef), false);
1878 signal?.Disconnect(onWindowSendEventCallback);
1879 onWindowSendEventCallback = null;
1881 NUILog.Debug($"[Dispose] DisConnectFromSignals END");
1885 /// Apply initial style to the view.
1887 [EditorBrowsable(EditorBrowsableState.Never)]
1888 protected virtual void InitializeStyle(ViewStyle style = null)
1890 var initialStyle = ThemeManager.GetInitialStyleWithoutClone(GetType());
1893 ApplyStyle(initialStyle);
1897 var refinedStyle = style;
1898 if (style.IncludeDefaultStyle)
1900 refinedStyle = initialStyle?.Merge(style);
1902 ApplyStyle(refinedStyle);
1905 // Listen theme change event if needs.
1906 if (ThemeManager.PlatformThemeEnabled && initialStyle != null)
1912 private View ConvertIdToView(uint id)
1914 View view = GetParent()?.FindCurrentChildById(id);
1916 //If we can't find the parent's children, find in the top layer.
1919 Container parent = GetParent();
1920 while ((parent is View) && (parent != null))
1922 parent = parent.GetParent();
1923 if (parent is Layer)
1925 view = parent.FindCurrentChildById(id);
1934 private void OnScaleChanged(float x, float y, float z)
1936 Scale = new Vector3(x, y, z);
1939 private void OnBackgroundColorChanged(float r, float g, float b, float a)
1941 BackgroundColor = new Color(r, g, b, a);
1944 private void OnPaddingChanged(ushort start, ushort end, ushort top, ushort bottom)
1946 Padding = new Extents(start, end, top, bottom);
1949 private void OnMarginChanged(ushort start, ushort end, ushort top, ushort bottom)
1951 Margin = new Extents(start, end, top, bottom);
1954 private void OnAnchorPointChanged(float x, float y, float z)
1956 AnchorPoint = new Position(x, y, z);
1959 private void OnCellIndexChanged(float x, float y)
1961 CellIndex = new Vector2(x, y);
1964 private void OnFlexMarginChanged(float x, float y, float z, float w)
1966 FlexMargin = new Vector4(x, y, z, w);
1969 private void OnPaddingEXChanged(ushort start, ushort end, ushort top, ushort bottom)
1971 PaddingEX = new Extents(start, end, top, bottom);
1974 private void OnSizeModeFactorChanged(float x, float y, float z)
1976 SizeModeFactor = new Vector3(x, y, z);
1979 private bool EmptyOnTouch(object target, TouchEventArgs args)
1984 [EditorBrowsable(EditorBrowsableState.Never)]
1985 protected virtual bool CheckResourceReady()
1990 private ViewSelectorData EnsureSelectorData()
1992 if (themeData == null) themeData = new ThemeData();
1994 return themeData.selectorData ?? (themeData.selectorData = new ViewSelectorData());
1997 [Conditional("NUI_DISPOSE_DEBUG_ON")]
1998 private void disposeDebugging(DisposeTypes type)
2000 DebugFileLogging.Instance.WriteLog($"View.Dispose({type}) START");
2001 DebugFileLogging.Instance.WriteLog($"type:{GetType()} copyNativeHandle:{GetBaseHandleCPtrHandleRef.Handle.ToString("X8")}");
2004 DebugFileLogging.Instance.WriteLog($"ID:{Interop.Actor.GetId(GetBaseHandleCPtrHandleRef)} Name:{Interop.Actor.GetName(GetBaseHandleCPtrHandleRef)}");
2008 DebugFileLogging.Instance.WriteLog($"has no native body!");