2 * Copyright(c) 2021 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.Collections.Generic;
20 using System.ComponentModel;
21 using System.Diagnostics;
22 using System.Runtime.CompilerServices;
23 using Tizen.NUI.Binding;
25 namespace Tizen.NUI.BaseComponents
28 /// View is the base class for all views.
30 /// <since_tizen> 3 </since_tizen>
31 public partial class View
33 private MergedStyle mergedStyle = null;
34 internal string styleName;
36 internal MergedStyle MergedStyle
40 if (null == mergedStyle)
42 mergedStyle = new MergedStyle(GetType(), this);
48 internal virtual LayoutItem CreateDefaultLayout()
50 return new AbsoluteLayout();
53 internal class ThemeData
56 private enum States : byte
59 ControlStatePropagation = 1 << 0,
60 ThemeChangeSensitive = 1 << 1,
61 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.
62 // That indicates the view can have different styles by theme.
63 // Hence if the current state has ThemeApplied and ThemeChangeSensitive, the view will change its style by theme changing.
64 ListeningThemeChangeEvent = 1 << 3,
67 private States states = ThemeManager.ApplicationThemeChangeSensitive ? States.ThemeChangeSensitive : States.None;
68 public ViewStyle viewStyle;
69 public ControlState controlStates = ControlState.Normal;
70 public ViewSelectorData selectorData;
72 public bool ControlStatePropagation
74 get => ((states & States.ControlStatePropagation) != 0);
75 set => SetOption(States.ControlStatePropagation, value);
78 public bool ThemeChangeSensitive
80 get => ((states & States.ThemeChangeSensitive) != 0);
81 set => SetOption(States.ThemeChangeSensitive, value);
84 public bool ThemeApplied
86 get => ((states & States.ThemeApplied) != 0);
87 set => SetOption(States.ThemeApplied, value);
90 public bool ListeningThemeChangeEvent
92 get => ((states & States.ListeningThemeChangeEvent) != 0);
93 set => SetOption(States.ListeningThemeChangeEvent, value);
96 private void SetOption(States option, bool value)
98 if (value) states |= option;
99 else states &= ~option;
104 /// The color mode of View.
105 /// This specifies whether the View uses its own color, or inherits its parent color.
106 /// The default is ColorMode.UseOwnMultiplyParentColor.
108 internal ColorMode ColorMode
116 return GetColorMode();
120 internal LayoutLength SuggestedMinimumWidth
124 float result = Interop.Actor.GetSuggestedMinimumWidth(SwigCPtr);
125 if (NDalicPINVOKE.SWIGPendingException.Pending)
126 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
127 return new LayoutLength(result);
131 internal LayoutLength SuggestedMinimumHeight
135 float result = Interop.Actor.GetSuggestedMinimumHeight(SwigCPtr);
136 if (NDalicPINVOKE.SWIGPendingException.Pending)
137 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
138 return new LayoutLength(result);
142 internal float WorldPositionX
146 float returnValue = 0.0f;
147 PropertyValue wordPositionX = GetProperty(View.Property.WorldPositionX);
148 wordPositionX?.Get(out returnValue);
149 wordPositionX?.Dispose();
154 internal float WorldPositionY
158 float returnValue = 0.0f;
159 PropertyValue wordPositionY = GetProperty(View.Property.WorldPositionY);
160 wordPositionY?.Get(out returnValue);
161 wordPositionY?.Dispose();
166 internal float WorldPositionZ
170 float returnValue = 0.0f;
171 PropertyValue wordPositionZ = GetProperty(View.Property.WorldPositionZ);
172 wordPositionZ?.Get(out returnValue);
173 wordPositionZ?.Dispose();
178 internal bool FocusState
182 return IsKeyboardFocusable();
186 SetKeyboardFocusable(value);
190 internal void SetLayout(LayoutItem layout)
194 this.layout = layout;
195 this.layout?.AttachToOwner(this);
196 this.layout?.RequestLayout();
199 internal void AttachTransitionsToChildren(LayoutTransition transition)
201 // Iterate children, adding the transition unless a transition
202 // for the same condition and property has already been
204 foreach (View view in Children)
206 LayoutTransitionsHelper.AddTransitionForCondition(view.LayoutTransitions, transition.Condition, transition, false);
210 internal float ParentOriginX
214 float returnValue = 0.0f;
215 PropertyValue parentOriginX = GetProperty(View.Property.ParentOriginX);
216 parentOriginX?.Get(out returnValue);
217 parentOriginX?.Dispose();
222 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
223 SetProperty(View.Property.ParentOriginX, setValue);
225 NotifyPropertyChanged();
229 internal float ParentOriginY
233 float returnValue = 0.0f;
234 PropertyValue parentOriginY = GetProperty(View.Property.ParentOriginY);
235 parentOriginY?.Get(out returnValue);
236 parentOriginY?.Dispose();
241 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
242 SetProperty(View.Property.ParentOriginY, setValue);
244 NotifyPropertyChanged();
248 internal float ParentOriginZ
252 float returnValue = 0.0f;
253 PropertyValue parentOriginZ = GetProperty(View.Property.ParentOriginZ);
254 parentOriginZ?.Get(out returnValue);
255 parentOriginZ?.Dispose();
260 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
261 SetProperty(View.Property.ParentOriginZ, setValue);
263 NotifyPropertyChanged();
267 internal float PivotPointX
271 float returnValue = 0.0f;
272 PropertyValue anchorPointX = GetProperty(View.Property.AnchorPointX);
273 anchorPointX?.Get(out returnValue);
274 anchorPointX?.Dispose();
279 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
280 SetProperty(View.Property.AnchorPointX, setValue);
285 internal float PivotPointY
289 float returnValue = 0.0f;
290 PropertyValue anchorPointY = GetProperty(View.Property.AnchorPointY);
291 anchorPointY?.Get(out returnValue);
292 anchorPointY?.Dispose();
297 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
298 SetProperty(View.Property.AnchorPointY, setValue);
303 internal float PivotPointZ
307 float returnValue = 0.0f;
308 PropertyValue anchorPointZ = GetProperty(View.Property.AnchorPointZ);
309 anchorPointZ?.Get(out returnValue);
310 anchorPointZ?.Dispose();
315 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
316 SetProperty(View.Property.AnchorPointZ, setValue);
321 internal Matrix WorldMatrix
325 Matrix returnValue = new Matrix();
326 PropertyValue wordMatrix = GetProperty(View.Property.WorldMatrix);
327 wordMatrix?.Get(returnValue);
328 wordMatrix?.Dispose();
334 /// The number of layouts including view's layout and children's layouts.
335 /// This can be used to set/unset Process callback to calculate Layout.
337 internal int LayoutCount
346 if (layoutCount == value) return;
348 if (value < 0) throw new global::System.ArgumentOutOfRangeException(nameof(LayoutCount), "LayoutCount(" + LayoutCount + ") should not be less than zero");
350 int diff = value - layoutCount;
353 if (InternalParent != null)
355 var parentView = InternalParent as View;
356 if (parentView != null)
358 parentView.LayoutCount += diff;
362 var parentLayer = InternalParent as Layer;
363 if (parentLayer != null)
365 parentLayer.LayoutCount += diff;
373 /// Indicates that this View should listen Touch event to handle its ControlState.
375 private bool enableControlState = false;
377 private int LeftFocusableViewId
382 PropertyValue leftFocusableViewId = GetProperty(View.Property.LeftFocusableViewId);
383 leftFocusableViewId?.Get(out returnValue);
384 leftFocusableViewId?.Dispose();
389 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
390 SetProperty(View.Property.LeftFocusableViewId, setValue);
395 private int RightFocusableViewId
400 PropertyValue rightFocusableViewId = GetProperty(View.Property.RightFocusableViewId);
401 rightFocusableViewId?.Get(out returnValue);
402 rightFocusableViewId?.Dispose();
407 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
408 SetProperty(View.Property.RightFocusableViewId, setValue);
413 private int UpFocusableViewId
418 PropertyValue upFocusableViewId = GetProperty(View.Property.UpFocusableViewId);
419 upFocusableViewId?.Get(out returnValue);
420 upFocusableViewId?.Dispose();
425 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
426 SetProperty(View.Property.UpFocusableViewId, setValue);
431 private int DownFocusableViewId
436 PropertyValue downFocusableViewId = GetProperty(View.Property.DownFocusableViewId);
437 downFocusableViewId?.Get(out returnValue);
438 downFocusableViewId?.Dispose();
443 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
444 SetProperty(View.Property.DownFocusableViewId, setValue);
449 internal string GetName()
451 string ret = Interop.Actor.GetName(SwigCPtr);
452 if (NDalicPINVOKE.SWIGPendingException.Pending)
453 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
457 internal void SetName(string name)
459 Interop.Actor.SetName(SwigCPtr, name);
460 if (NDalicPINVOKE.SWIGPendingException.Pending)
461 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
464 internal uint GetId()
466 uint ret = Interop.Actor.GetId(SwigCPtr);
467 if (NDalicPINVOKE.SWIGPendingException.Pending)
468 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
472 internal bool IsRoot()
474 bool ret = Interop.ActorInternal.IsRoot(SwigCPtr);
475 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
479 internal bool OnWindow()
481 bool ret = Interop.Actor.OnStage(SwigCPtr);
482 if (NDalicPINVOKE.SWIGPendingException.Pending)
483 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
487 internal View FindChildById(uint id)
489 //to fix memory leak issue, match the handle count with native side.
490 IntPtr cPtr = Interop.Actor.FindChildById(SwigCPtr, id);
491 View ret = this.GetInstanceSafely<View>(cPtr);
492 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
496 internal override View FindCurrentChildById(uint id)
498 return FindChildById(id);
501 internal void SetParentOrigin(Vector3 origin)
503 Interop.ActorInternal.SetParentOrigin(SwigCPtr, Vector3.getCPtr(origin));
504 if (NDalicPINVOKE.SWIGPendingException.Pending)
505 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
508 internal Vector3 GetCurrentParentOrigin()
510 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentParentOrigin(SwigCPtr), true);
511 if (NDalicPINVOKE.SWIGPendingException.Pending)
512 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
516 internal void SetAnchorPoint(Vector3 anchorPoint)
518 Interop.Actor.SetAnchorPoint(SwigCPtr, Vector3.getCPtr(anchorPoint));
519 if (NDalicPINVOKE.SWIGPendingException.Pending)
520 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
523 internal Vector3 GetCurrentAnchorPoint()
525 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentAnchorPoint(SwigCPtr), true);
526 if (NDalicPINVOKE.SWIGPendingException.Pending)
527 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
531 internal void SetSize(float width, float height)
533 Interop.ActorInternal.SetSize(SwigCPtr, width, height);
534 if (NDalicPINVOKE.SWIGPendingException.Pending)
535 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
538 internal void SetSize(float width, float height, float depth)
540 Interop.ActorInternal.SetSize(SwigCPtr, width, height, depth);
541 if (NDalicPINVOKE.SWIGPendingException.Pending)
542 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
545 internal void SetSize(Vector2 size)
547 Interop.ActorInternal.SetSizeVector2(SwigCPtr, Vector2.getCPtr(size));
548 if (NDalicPINVOKE.SWIGPendingException.Pending)
549 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
552 internal void SetSize(Vector3 size)
554 Interop.ActorInternal.SetSizeVector3(SwigCPtr, Vector3.getCPtr(size));
555 if (NDalicPINVOKE.SWIGPendingException.Pending)
556 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
559 internal Vector3 GetTargetSize()
561 Vector3 ret = new Vector3(Interop.ActorInternal.GetTargetSize(SwigCPtr), true);
562 if (NDalicPINVOKE.SWIGPendingException.Pending)
563 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
567 internal Size2D GetCurrentSize()
569 Size ret = new Size(Interop.Actor.GetCurrentSize(SwigCPtr), true);
570 if (NDalicPINVOKE.SWIGPendingException.Pending)
571 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
572 Size2D size = new Size2D((int)ret.Width, (int)ret.Height);
577 internal Size2D GetCurrentSizeFloat()
579 Size ret = new Size(Interop.Actor.GetCurrentSize(SwigCPtr), true);
580 if (NDalicPINVOKE.SWIGPendingException.Pending)
581 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
585 internal Vector3 GetNaturalSize()
587 Vector3 ret = new Vector3(Interop.Actor.GetNaturalSize(SwigCPtr), true);
588 if (NDalicPINVOKE.SWIGPendingException.Pending)
589 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
593 internal void SetPosition(float x, float y)
595 Interop.ActorInternal.SetPosition(SwigCPtr, x, y);
596 if (NDalicPINVOKE.SWIGPendingException.Pending)
597 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
600 internal void SetPosition(float x, float y, float z)
602 Interop.ActorInternal.SetPosition(SwigCPtr, x, y, z);
603 if (NDalicPINVOKE.SWIGPendingException.Pending)
604 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
607 internal void SetPosition(Vector3 position)
609 Interop.ActorInternal.SetPosition(SwigCPtr, Vector3.getCPtr(position));
610 if (NDalicPINVOKE.SWIGPendingException.Pending)
611 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
614 internal void SetX(float x)
616 Interop.ActorInternal.SetX(SwigCPtr, x);
617 if (NDalicPINVOKE.SWIGPendingException.Pending)
618 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
621 internal void SetY(float y)
623 Interop.ActorInternal.SetY(SwigCPtr, y);
624 if (NDalicPINVOKE.SWIGPendingException.Pending)
625 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
628 internal void SetZ(float z)
630 Interop.ActorInternal.SetZ(SwigCPtr, z);
631 if (NDalicPINVOKE.SWIGPendingException.Pending)
632 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
635 internal void TranslateBy(Vector3 distance)
637 Interop.ActorInternal.TranslateBy(SwigCPtr, Vector3.getCPtr(distance));
638 if (NDalicPINVOKE.SWIGPendingException.Pending)
639 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
642 internal Position GetCurrentPosition()
644 Position ret = new Position(Interop.Actor.GetCurrentPosition(SwigCPtr), true);
645 if (NDalicPINVOKE.SWIGPendingException.Pending)
646 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
650 internal Vector3 GetCurrentWorldPosition()
652 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentWorldPosition(SwigCPtr), true);
653 if (NDalicPINVOKE.SWIGPendingException.Pending)
654 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
658 internal void SetInheritPosition(bool inherit)
660 Interop.ActorInternal.SetInheritPosition(SwigCPtr, inherit);
661 if (NDalicPINVOKE.SWIGPendingException.Pending)
662 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
665 internal bool IsPositionInherited()
667 bool ret = Interop.ActorInternal.IsPositionInherited(SwigCPtr);
668 if (NDalicPINVOKE.SWIGPendingException.Pending)
669 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
673 internal void SetOrientation(Degree angle, Vector3 axis)
675 Interop.ActorInternal.SetOrientationDegree(SwigCPtr, Degree.getCPtr(angle), Vector3.getCPtr(axis));
676 if (NDalicPINVOKE.SWIGPendingException.Pending)
677 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
680 internal void SetOrientation(Radian angle, Vector3 axis)
682 Interop.ActorInternal.SetOrientationRadian(SwigCPtr, Radian.getCPtr(angle), Vector3.getCPtr(axis));
683 if (NDalicPINVOKE.SWIGPendingException.Pending)
684 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
687 internal void SetOrientation(Rotation orientation)
689 Interop.ActorInternal.SetOrientationQuaternion(SwigCPtr, Rotation.getCPtr(orientation));
690 if (NDalicPINVOKE.SWIGPendingException.Pending)
691 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
694 internal Rotation GetCurrentOrientation()
696 Rotation ret = new Rotation(Interop.ActorInternal.GetCurrentOrientation(SwigCPtr), true);
697 if (NDalicPINVOKE.SWIGPendingException.Pending)
698 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
702 internal void SetInheritOrientation(bool inherit)
704 Interop.ActorInternal.SetInheritOrientation(SwigCPtr, inherit);
705 if (NDalicPINVOKE.SWIGPendingException.Pending)
706 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
709 internal bool IsOrientationInherited()
711 bool ret = Interop.ActorInternal.IsOrientationInherited(SwigCPtr);
712 if (NDalicPINVOKE.SWIGPendingException.Pending)
713 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
717 internal Rotation GetCurrentWorldOrientation()
719 Rotation ret = new Rotation(Interop.ActorInternal.GetCurrentWorldOrientation(SwigCPtr), true);
720 if (NDalicPINVOKE.SWIGPendingException.Pending)
721 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
725 internal void SetScale(float scale)
727 Interop.ActorInternal.SetScale(SwigCPtr, scale);
728 if (NDalicPINVOKE.SWIGPendingException.Pending)
729 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
732 internal void SetScale(float scaleX, float scaleY, float scaleZ)
734 Interop.ActorInternal.SetScale(SwigCPtr, scaleX, scaleY, scaleZ);
735 if (NDalicPINVOKE.SWIGPendingException.Pending)
736 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
739 internal void SetScale(Vector3 scale)
741 Interop.ActorInternal.SetScale(SwigCPtr, Vector3.getCPtr(scale));
742 if (NDalicPINVOKE.SWIGPendingException.Pending)
743 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
746 internal Vector3 GetCurrentScale()
748 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentScale(SwigCPtr), true);
749 if (NDalicPINVOKE.SWIGPendingException.Pending)
750 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
754 internal Vector3 GetCurrentWorldScale()
756 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentWorldScale(SwigCPtr), true);
757 if (NDalicPINVOKE.SWIGPendingException.Pending)
758 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
762 internal void SetInheritScale(bool inherit)
764 Interop.ActorInternal.SetInheritScale(SwigCPtr, inherit);
765 if (NDalicPINVOKE.SWIGPendingException.Pending)
766 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
769 internal bool IsScaleInherited()
771 bool ret = Interop.ActorInternal.IsScaleInherited(SwigCPtr);
772 if (NDalicPINVOKE.SWIGPendingException.Pending)
773 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
777 internal Matrix GetCurrentWorldMatrix()
779 Matrix ret = new Matrix(Interop.ActorInternal.GetCurrentWorldMatrix(SwigCPtr), true);
780 if (NDalicPINVOKE.SWIGPendingException.Pending)
781 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
785 internal void SetVisible(bool visible)
787 Interop.Actor.SetVisible(SwigCPtr, visible);
788 if (NDalicPINVOKE.SWIGPendingException.Pending)
789 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
792 internal bool IsVisible()
794 bool ret = Interop.ActorInternal.IsVisible(SwigCPtr);
795 if (NDalicPINVOKE.SWIGPendingException.Pending)
796 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
800 internal void SetOpacity(float opacity)
802 Interop.ActorInternal.SetOpacity(SwigCPtr, opacity);
803 if (NDalicPINVOKE.SWIGPendingException.Pending)
804 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
807 internal float GetCurrentOpacity()
809 float ret = Interop.ActorInternal.GetCurrentOpacity(SwigCPtr);
810 if (NDalicPINVOKE.SWIGPendingException.Pending)
811 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
815 internal Vector4 GetCurrentColor()
817 Vector4 ret = new Vector4(Interop.ActorInternal.GetCurrentColor(SwigCPtr), true);
818 if (NDalicPINVOKE.SWIGPendingException.Pending)
819 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
822 internal ColorMode GetColorMode()
824 ColorMode ret = (ColorMode)Interop.ActorInternal.GetColorMode(SwigCPtr);
825 if (NDalicPINVOKE.SWIGPendingException.Pending)
826 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
830 internal Vector4 GetCurrentWorldColor()
832 Vector4 ret = new Vector4(Interop.ActorInternal.GetCurrentWorldColor(SwigCPtr), true);
833 if (NDalicPINVOKE.SWIGPendingException.Pending)
834 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
838 internal void SetDrawMode(DrawModeType drawMode)
840 Interop.ActorInternal.SetDrawMode(SwigCPtr, (int)drawMode);
841 if (NDalicPINVOKE.SWIGPendingException.Pending)
842 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
845 internal DrawModeType GetDrawMode()
847 DrawModeType ret = (DrawModeType)Interop.ActorInternal.GetDrawMode(SwigCPtr);
848 if (NDalicPINVOKE.SWIGPendingException.Pending)
849 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
853 internal void SetKeyboardFocusable(bool focusable)
855 Interop.ActorInternal.SetKeyboardFocusable(SwigCPtr, focusable);
856 if (NDalicPINVOKE.SWIGPendingException.Pending)
857 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
860 internal bool IsKeyboardFocusable()
862 bool ret = Interop.ActorInternal.IsKeyboardFocusable(SwigCPtr);
863 if (NDalicPINVOKE.SWIGPendingException.Pending)
864 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
868 internal void SetKeyboardFocusableChildren(bool focusable)
870 Interop.ActorInternal.SetKeyboardFocusableChildren(SwigCPtr, focusable);
871 if (NDalicPINVOKE.SWIGPendingException.Pending)
872 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
875 internal bool AreChildrenKeyBoardFocusable()
877 bool ret = Interop.ActorInternal.AreChildrenKeyBoardFocusable(SwigCPtr);
878 if (NDalicPINVOKE.SWIGPendingException.Pending)
879 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
883 internal void SetFocusableInTouch(bool enabled)
885 Interop.ActorInternal.SetFocusableInTouch(SwigCPtr, enabled);
886 if (NDalicPINVOKE.SWIGPendingException.Pending)
887 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
890 internal bool IsFocusableInTouch()
892 bool ret = Interop.ActorInternal.IsFocusableInTouch(SwigCPtr);
893 if (NDalicPINVOKE.SWIGPendingException.Pending)
894 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
898 internal void SetResizePolicy(ResizePolicyType policy, DimensionType dimension)
900 Interop.Actor.SetResizePolicy(SwigCPtr, (int)policy, (int)dimension);
901 if (NDalicPINVOKE.SWIGPendingException.Pending)
902 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
905 internal ResizePolicyType GetResizePolicy(DimensionType dimension)
907 ResizePolicyType ret = (ResizePolicyType)Interop.Actor.GetResizePolicy(SwigCPtr, (int)dimension);
908 if (NDalicPINVOKE.SWIGPendingException.Pending)
909 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
913 internal Vector3 GetSizeModeFactor()
915 Vector3 ret = new Vector3(Interop.Actor.GetSizeModeFactor(SwigCPtr), true);
916 if (NDalicPINVOKE.SWIGPendingException.Pending)
917 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
921 internal void SetMinimumSize(Vector2 size)
923 Interop.ActorInternal.SetMinimumSize(SwigCPtr, Vector2.getCPtr(size));
924 if (NDalicPINVOKE.SWIGPendingException.Pending)
925 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
928 internal Vector2 GetMinimumSize()
930 Vector2 ret = new Vector2(Interop.ActorInternal.GetMinimumSize(SwigCPtr), true);
931 if (NDalicPINVOKE.SWIGPendingException.Pending)
932 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
936 internal void SetMaximumSize(Vector2 size)
938 Interop.ActorInternal.SetMaximumSize(SwigCPtr, Vector2.getCPtr(size));
939 if (NDalicPINVOKE.SWIGPendingException.Pending)
940 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
943 internal Vector2 GetMaximumSize()
945 Vector2 ret = new Vector2(Interop.ActorInternal.GetMaximumSize(SwigCPtr), true);
946 if (NDalicPINVOKE.SWIGPendingException.Pending)
947 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
951 internal int GetHierarchyDepth()
953 int ret = Interop.Actor.GetHierarchyDepth(SwigCPtr);
954 if (NDalicPINVOKE.SWIGPendingException.Pending)
955 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
959 internal uint GetRendererCount()
961 uint ret = Interop.Actor.GetRendererCount(SwigCPtr);
962 if (NDalicPINVOKE.SWIGPendingException.Pending)
963 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
967 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(View obj)
969 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
972 internal bool IsTopLevelView()
974 if (GetParent() is Layer)
981 internal void SetKeyInputFocus()
983 Interop.ViewInternal.SetKeyInputFocus(SwigCPtr);
984 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
987 internal void ClearKeyInputFocus()
989 Interop.ViewInternal.ClearKeyInputFocus(SwigCPtr);
990 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
993 internal PinchGestureDetector GetPinchGestureDetector()
995 PinchGestureDetector ret = new PinchGestureDetector(Interop.ViewInternal.GetPinchGestureDetector(SwigCPtr), true);
996 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1000 internal PanGestureDetector GetPanGestureDetector()
1002 PanGestureDetector ret = new PanGestureDetector(Interop.ViewInternal.GetPanGestureDetector(SwigCPtr), true);
1003 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1007 internal TapGestureDetector GetTapGestureDetector()
1009 TapGestureDetector ret = new TapGestureDetector(Interop.ViewInternal.GetTapGestureDetector(SwigCPtr), true);
1010 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1014 internal LongPressGestureDetector GetLongPressGestureDetector()
1016 LongPressGestureDetector ret = new LongPressGestureDetector(Interop.ViewInternal.GetLongPressGestureDetector(SwigCPtr), true);
1017 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1021 internal IntPtr GetPtrfromView()
1023 return (IntPtr)SwigCPtr;
1026 internal void RemoveChild(View child)
1028 // Do actual child removal
1029 Interop.Actor.Remove(SwigCPtr, View.getCPtr(child));
1030 if (NDalicPINVOKE.SWIGPendingException.Pending)
1031 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1033 Children.Remove(child);
1034 child.InternalParent = null;
1035 LayoutCount -= child.LayoutCount;
1037 RemoveChildBindableObject(child);
1039 if (ChildRemoved != null)
1041 ChildRemovedEventArgs e = new ChildRemovedEventArgs
1045 ChildRemoved(this, e);
1050 /// Removes the layout from this View.
1052 internal void ResetLayout()
1059 internal ResourceLoadingStatusType GetBackgroundResourceStatus()
1061 return (ResourceLoadingStatusType)Interop.View.GetVisualResourceStatus(this.SwigCPtr, Property.BACKGROUND);
1064 /// TODO open as a protected level
1065 internal virtual void ApplyCornerRadius()
1067 if (backgroundExtraData == null) return;
1069 var cornerRadiusValue = backgroundExtraData.CornerRadius == null ? new PropertyValue() : new PropertyValue(backgroundExtraData.CornerRadius);
1070 var cornerRadiusPolicyValue = new PropertyValue((int)backgroundExtraData.CornerRadiusPolicy);
1072 // Make current propertyMap
1073 PropertyMap currentPropertyMap = new PropertyMap();
1074 currentPropertyMap[Visual.Property.CornerRadius] = cornerRadiusValue;
1075 currentPropertyMap[Visual.Property.CornerRadiusPolicy] = cornerRadiusPolicyValue;
1076 var temp = new PropertyValue(currentPropertyMap);
1078 // Update corner radius properties to background and shadow by ActionUpdateProperty
1079 DoAction(View.Property.BACKGROUND, ActionUpdateProperty, temp);
1080 DoAction(View.Property.SHADOW, ActionUpdateProperty, temp);
1083 currentPropertyMap.Dispose();
1084 cornerRadiusValue.Dispose();
1085 cornerRadiusPolicyValue.Dispose();
1088 /// TODO open as a protected level
1089 internal virtual void ApplyBorderline()
1091 if (backgroundExtraData == null) return;
1093 var borderlineWidthValue = new PropertyValue(backgroundExtraData.BorderlineWidth);
1094 var borderlineColorValue = backgroundExtraData.BorderlineColor == null ? new PropertyValue(Color.Black) : new PropertyValue(backgroundExtraData.BorderlineColor);
1095 var borderlineOffsetValue = new PropertyValue(backgroundExtraData.BorderlineOffset);
1097 // Make current propertyMap
1098 PropertyMap currentPropertyMap = new PropertyMap();
1099 currentPropertyMap[Visual.Property.BorderlineWidth] = borderlineWidthValue;
1100 currentPropertyMap[Visual.Property.BorderlineColor] = borderlineColorValue;
1101 currentPropertyMap[Visual.Property.BorderlineOffset] = borderlineOffsetValue;
1102 var temp = new PropertyValue(currentPropertyMap);
1104 // Update borderline properties to background by ActionUpdateProperty
1105 DoAction(View.Property.BACKGROUND, ActionUpdateProperty, temp);
1108 currentPropertyMap.Dispose();
1109 borderlineWidthValue.Dispose();
1110 borderlineColorValue.Dispose();
1111 borderlineOffsetValue.Dispose();
1115 /// Get selector value from the triggerable selector or related property.
1117 internal Selector<T> GetSelector<T>(TriggerableSelector<T> triggerableSelector, NUI.Binding.BindableProperty relatedProperty)
1119 var selector = triggerableSelector?.Get();
1120 if (selector != null)
1125 var value = (T)GetValue(relatedProperty);
1126 return value == null ? null : new Selector<T>(value);
1129 internal void SetThemeApplied()
1131 if (themeData == null) themeData = new ThemeData();
1132 themeData.ThemeApplied = true;
1134 if (ThemeChangeSensitive && !themeData.ListeningThemeChangeEvent)
1136 themeData.ListeningThemeChangeEvent = true;
1137 ThemeManager.ThemeChangedInternal.Add(OnThemeChanged);
1142 /// you can override it to clean-up your own resources.
1144 /// <param name="type">DisposeTypes</param>
1145 /// <since_tizen> 3 </since_tizen>
1146 protected override void Dispose(DisposeTypes type)
1153 DebugFileLogging.Instance.WriteLog($"View.Dispose({type}) START");
1154 DebugFileLogging.Instance.WriteLog($"type:{GetType()} copyNativeHandle:{GetBaseHandleCPtrHandleRef.Handle.ToString("X8")}");
1157 DebugFileLogging.Instance.WriteLog($"ID:{Interop.Actor.GetId(GetBaseHandleCPtrHandleRef)} Name:{Interop.Actor.GetName(GetBaseHandleCPtrHandleRef)}");
1161 DebugFileLogging.Instance.WriteLog($"has no native body!");
1164 //_mergedStyle = null;
1166 internalMaximumSize?.Dispose();
1167 internalMaximumSize = null;
1168 internalMinimumSize?.Dispose();
1169 internalMinimumSize = null;
1170 internalMargin?.Dispose();
1171 internalMargin = null;
1172 internalPadding?.Dispose();
1173 internalPadding = null;
1174 internalSizeModeFactor?.Dispose();
1175 internalSizeModeFactor = null;
1176 internalCellIndex?.Dispose();
1177 internalCellIndex = null;
1178 internalBackgroundColor?.Dispose();
1179 internalBackgroundColor = null;
1180 internalColor?.Dispose();
1181 internalColor = null;
1182 internalPivotPoint?.Dispose();
1183 internalPivotPoint = null;
1184 internalPosition?.Dispose();
1185 internalPosition = null;
1186 internalPosition2D?.Dispose();
1187 internalPosition2D = null;
1188 internalScale?.Dispose();
1189 internalScale = null;
1190 internalSize?.Dispose();
1191 internalSize = null;
1192 internalSize2D?.Dispose();
1193 internalSize2D = null;
1195 if (type == DisposeTypes.Explicit)
1198 //Release your own managed resources here.
1199 //You should release all of your own disposable objects here.
1200 if (themeData != null)
1202 themeData.selectorData?.Reset(this);
1203 if (themeData.ListeningThemeChangeEvent)
1205 ThemeManager.ThemeChangedInternal.Remove(OnThemeChanged);
1208 if (widthConstraint != null)
1210 widthConstraint.Remove();
1211 widthConstraint.Dispose();
1213 if (heightConstraint != null)
1215 heightConstraint.Remove();
1216 heightConstraint.Dispose();
1220 //Release your own unmanaged resources here.
1221 //You should not access any managed member here except static instance.
1222 //because the execution order of Finalizes is non-deterministic.
1224 DisConnectFromSignals();
1226 foreach (View view in Children)
1228 view.InternalParent = null;
1233 NUILog.Debug($"[Dispose] View.Dispose({type}) END");
1234 NUILog.Debug($"=============================");
1239 /// This will not be public opened.
1240 [EditorBrowsable(EditorBrowsableState.Never)]
1241 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1243 Interop.View.DeleteView(swigCPtr);
1247 /// The touch event handler for ControlState.
1248 /// Please change ControlState value by touch state if needed.
1250 /// <exception cref="ArgumentNullException"> Thrown when touch is null. </exception>
1251 [EditorBrowsable(EditorBrowsableState.Never)]
1252 protected virtual bool HandleControlStateOnTouch(Touch touch)
1256 throw new global::System.ArgumentNullException(nameof(touch));
1259 switch (touch.GetState(0))
1261 case PointStateType.Down:
1262 ControlState += ControlState.Pressed;
1264 case PointStateType.Interrupted:
1265 case PointStateType.Up:
1266 if (ControlState.Contains(ControlState.Pressed))
1268 ControlState -= ControlState.Pressed;
1277 private void DisConnectFromSignals()
1279 if (HasBody() == false)
1281 NUILog.Debug($"[Dispose] DisConnectFromSignals() No native body! No need to Disconnect Signals!");
1284 NUILog.Debug($"[Dispose] DisConnectFromSignals START");
1285 NUILog.Debug($"[Dispose] View.DisConnectFromSignals() type:{GetType()} copyNativeHandle:{GetBaseHandleCPtrHandleRef.Handle.ToString("X8")}");
1286 NUILog.Debug($"[Dispose] ID:{Interop.Actor.GetId(GetBaseHandleCPtrHandleRef)} Name:{Interop.Actor.GetName(GetBaseHandleCPtrHandleRef)}");
1288 if (onRelayoutEventCallback != null)
1290 NUILog.Debug($"[Dispose] onRelayoutEventCallback");
1292 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnRelayoutSignal(GetBaseHandleCPtrHandleRef), false);
1293 signal?.Disconnect(onRelayoutEventCallback);
1294 onRelayoutEventCallback = null;
1297 if (offWindowEventCallback != null)
1299 NUILog.Debug($"[Dispose] offWindowEventCallback");
1301 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOffSceneSignal(GetBaseHandleCPtrHandleRef), false);
1302 signal?.Disconnect(offWindowEventCallback);
1303 offWindowEventCallback = null;
1306 if (onWindowEventCallback != null)
1308 NUILog.Debug($"[Dispose] onWindowEventCallback");
1310 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(GetBaseHandleCPtrHandleRef), false);
1311 signal?.Disconnect(onWindowEventCallback);
1312 onWindowEventCallback = null;
1315 if (wheelEventCallback != null)
1317 NUILog.Debug($"[Dispose] wheelEventCallback");
1319 using WheelSignal signal = new WheelSignal(Interop.ActorSignal.ActorWheelEventSignal(GetBaseHandleCPtrHandleRef), false);
1320 signal?.Disconnect(wheelEventCallback);
1321 wheelEventCallback = null;
1324 if (WindowWheelEventHandler != null)
1326 NUILog.Debug($"[Dispose] WindowWheelEventHandler");
1328 NUIApplication.GetDefaultWindow().WheelEvent -= OnWindowWheelEvent;
1329 WindowWheelEventHandler = null;
1332 if (hoverEventCallback != null)
1334 NUILog.Debug($"[Dispose] hoverEventCallback");
1336 using HoverSignal signal = new HoverSignal(Interop.ActorSignal.ActorHoveredSignal(GetBaseHandleCPtrHandleRef), false);
1337 signal?.Disconnect(hoverEventCallback);
1338 hoverEventCallback = null;
1341 if (interceptTouchDataCallback != null)
1343 NUILog.Debug($"[Dispose] interceptTouchDataCallback");
1345 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorInterceptTouchSignal(GetBaseHandleCPtrHandleRef), false);
1346 signal?.Disconnect(interceptTouchDataCallback);
1347 interceptTouchDataCallback = null;
1350 if (touchDataCallback != null)
1352 NUILog.Debug($"[Dispose] touchDataCallback");
1354 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorTouchSignal(GetBaseHandleCPtrHandleRef), false);
1355 signal?.Disconnect(touchDataCallback);
1356 touchDataCallback = null;
1359 if (ResourcesLoadedCallback != null)
1361 NUILog.Debug($"[Dispose] ResourcesLoadedCallback");
1363 using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(GetBaseHandleCPtrHandleRef), false);
1364 signal?.Disconnect(ResourcesLoadedCallback);
1365 ResourcesLoadedCallback = null;
1368 if (keyCallback != null)
1370 NUILog.Debug($"[Dispose] keyCallback");
1372 using ControlKeySignal signal = new ControlKeySignal(Interop.ViewSignal.KeyEventSignal(GetBaseHandleCPtrHandleRef), false);
1373 signal?.Disconnect(keyCallback);
1377 if (keyInputFocusLostCallback != null)
1379 NUILog.Debug($"[Dispose] keyInputFocusLostCallback");
1381 using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusLostSignal(GetBaseHandleCPtrHandleRef), false);
1382 signal?.Disconnect(keyInputFocusLostCallback);
1383 keyInputFocusLostCallback = null;
1384 keyInputFocusLostEventHandler = null;
1387 if (keyInputFocusGainedCallback != null)
1389 NUILog.Debug($"[Dispose] keyInputFocusGainedCallback");
1391 using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusGainedSignal(GetBaseHandleCPtrHandleRef), false);
1392 signal?.Disconnect(keyInputFocusGainedCallback);
1393 keyInputFocusGainedCallback = null;
1394 keyInputFocusGainedEventHandler = null;
1397 if (backgroundResourceLoadedCallback != null)
1399 NUILog.Debug($"[Dispose] backgroundResourceLoadedCallback");
1401 using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(GetBaseHandleCPtrHandleRef), false);
1402 signal?.Disconnect(backgroundResourceLoadedCallback);
1403 backgroundResourceLoadedCallback = null;
1406 if (onWindowSendEventCallback != null)
1408 NUILog.Debug($"[Dispose] onWindowSendEventCallback");
1410 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(GetBaseHandleCPtrHandleRef), false);
1411 signal?.Disconnect(onWindowSendEventCallback);
1412 onWindowSendEventCallback = null;
1414 NUILog.Debug($"[Dispose] DisConnectFromSignals END");
1418 /// Apply initial style to the view.
1420 [EditorBrowsable(EditorBrowsableState.Never)]
1421 protected virtual void InitializeStyle(ViewStyle style = null)
1423 var initialStyle = ThemeManager.GetInitialStyleWithoutClone(GetType());
1426 ApplyStyle(initialStyle);
1430 var refinedStyle = style;
1431 if (style.IncludeDefaultStyle)
1433 refinedStyle = initialStyle?.Merge(style);
1435 ApplyStyle(refinedStyle);
1438 // Listen theme change event if needs.
1439 if (ThemeManager.PlatformThemeEnabled && initialStyle != null)
1445 private View ConvertIdToView(uint id)
1447 View view = GetParent()?.FindCurrentChildById(id);
1449 //If we can't find the parent's children, find in the top layer.
1452 Container parent = GetParent();
1453 while ((parent is View) && (parent != null))
1455 parent = parent.GetParent();
1456 if (parent is Layer)
1458 view = parent.FindCurrentChildById(id);
1467 private void OnScaleChanged(float x, float y, float z)
1469 Scale = new Vector3(x, y, z);
1472 private void OnBackgroundColorChanged(float r, float g, float b, float a)
1474 BackgroundColor = new Color(r, g, b, a);
1477 private void OnPaddingChanged(ushort start, ushort end, ushort top, ushort bottom)
1479 Padding = new Extents(start, end, top, bottom);
1482 private void OnMarginChanged(ushort start, ushort end, ushort top, ushort bottom)
1484 Margin = new Extents(start, end, top, bottom);
1487 private void OnAnchorPointChanged(float x, float y, float z)
1489 AnchorPoint = new Position(x, y, z);
1492 private void OnCellIndexChanged(float x, float y)
1494 CellIndex = new Vector2(x, y);
1497 private void OnFlexMarginChanged(float x, float y, float z, float w)
1499 FlexMargin = new Vector4(x, y, z, w);
1502 private void OnPaddingEXChanged(ushort start, ushort end, ushort top, ushort bottom)
1504 PaddingEX = new Extents(start, end, top, bottom);
1507 private void OnSizeModeFactorChanged(float x, float y, float z)
1509 SizeModeFactor = new Vector3(x, y, z);
1512 private bool EmptyOnTouch(object target, TouchEventArgs args)
1517 private ViewSelectorData EnsureSelectorData()
1519 if (themeData == null) themeData = new ThemeData();
1521 return themeData.selectorData ?? (themeData.selectorData = new ViewSelectorData());