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;
21 namespace Tizen.NUI.BaseComponents
24 /// View is the base class for all views.
26 /// <since_tizen> 3 </since_tizen>
27 public partial class View
29 internal string styleName;
31 internal virtual LayoutItem CreateDefaultLayout()
33 return new AbsoluteLayout();
36 internal class ThemeData
39 private enum States : byte
42 ControlStatePropagation = 1 << 0,
43 ThemeChangeSensitive = 1 << 1,
44 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.
45 // That indicates the view can have different styles by theme.
46 // Hence if the current state has ThemeApplied and ThemeChangeSensitive, the view will change its style by theme changing.
47 ListeningThemeChangeEvent = 1 << 3,
50 private States states = ThemeManager.ApplicationThemeChangeSensitive ? States.ThemeChangeSensitive : States.None;
51 public ViewStyle viewStyle;
52 public ControlState controlStates = ControlState.Normal;
53 public ViewSelectorData selectorData;
55 public bool ControlStatePropagation
57 get => ((states & States.ControlStatePropagation) != 0);
58 set => SetOption(States.ControlStatePropagation, value);
61 public bool ThemeChangeSensitive
63 get => ((states & States.ThemeChangeSensitive) != 0);
64 set => SetOption(States.ThemeChangeSensitive, value);
67 public bool ThemeApplied
69 get => ((states & States.ThemeApplied) != 0);
70 set => SetOption(States.ThemeApplied, value);
73 public bool ListeningThemeChangeEvent
75 get => ((states & States.ListeningThemeChangeEvent) != 0);
76 set => SetOption(States.ListeningThemeChangeEvent, value);
79 private void SetOption(States option, bool value)
81 if (value) states |= option;
82 else states &= ~option;
87 /// The color mode of View.
88 /// This specifies whether the View uses its own color, or inherits its parent color.
89 /// The default is ColorMode.UseOwnMultiplyParentColor.
91 internal ColorMode ColorMode
99 return GetColorMode();
103 internal LayoutLength SuggestedMinimumWidth
107 float result = Interop.Actor.GetSuggestedMinimumWidth(SwigCPtr);
108 if (NDalicPINVOKE.SWIGPendingException.Pending)
109 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
110 return new LayoutLength(result);
114 internal LayoutLength SuggestedMinimumHeight
118 float result = Interop.Actor.GetSuggestedMinimumHeight(SwigCPtr);
119 if (NDalicPINVOKE.SWIGPendingException.Pending)
120 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
121 return new LayoutLength(result);
125 internal float WorldPositionX
129 float returnValue = 0.0f;
130 PropertyValue wordPositionX = GetProperty(View.Property.WorldPositionX);
131 wordPositionX?.Get(out returnValue);
132 wordPositionX?.Dispose();
137 internal float WorldPositionY
141 float returnValue = 0.0f;
142 PropertyValue wordPositionY = GetProperty(View.Property.WorldPositionY);
143 wordPositionY?.Get(out returnValue);
144 wordPositionY?.Dispose();
149 internal float WorldPositionZ
153 float returnValue = 0.0f;
154 PropertyValue wordPositionZ = GetProperty(View.Property.WorldPositionZ);
155 wordPositionZ?.Get(out returnValue);
156 wordPositionZ?.Dispose();
161 internal bool FocusState
165 return IsKeyboardFocusable();
169 SetKeyboardFocusable(value);
173 internal void SetLayout(LayoutItem layout)
177 this.layout = layout;
178 this.layout?.AttachToOwner(this);
179 this.layout?.RequestLayout();
182 internal void AttachTransitionsToChildren(LayoutTransition transition)
184 // Iterate children, adding the transition unless a transition
185 // for the same condition and property has already been
187 foreach (View view in Children)
189 LayoutTransitionsHelper.AddTransitionForCondition(view.LayoutTransitions, transition.Condition, transition, false);
193 internal float ParentOriginX
197 float returnValue = 0.0f;
198 PropertyValue parentOriginX = GetProperty(View.Property.ParentOriginX);
199 parentOriginX?.Get(out returnValue);
200 parentOriginX?.Dispose();
205 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
206 SetProperty(View.Property.ParentOriginX, setValue);
208 NotifyPropertyChanged();
212 internal float ParentOriginY
216 float returnValue = 0.0f;
217 PropertyValue parentOriginY = GetProperty(View.Property.ParentOriginY);
218 parentOriginY?.Get(out returnValue);
219 parentOriginY?.Dispose();
224 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
225 SetProperty(View.Property.ParentOriginY, setValue);
227 NotifyPropertyChanged();
231 internal float ParentOriginZ
235 float returnValue = 0.0f;
236 PropertyValue parentOriginZ = GetProperty(View.Property.ParentOriginZ);
237 parentOriginZ?.Get(out returnValue);
238 parentOriginZ?.Dispose();
243 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
244 SetProperty(View.Property.ParentOriginZ, setValue);
246 NotifyPropertyChanged();
250 internal float PivotPointX
254 float returnValue = 0.0f;
255 PropertyValue anchorPointX = GetProperty(View.Property.AnchorPointX);
256 anchorPointX?.Get(out returnValue);
257 anchorPointX?.Dispose();
262 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
263 SetProperty(View.Property.AnchorPointX, setValue);
268 internal float PivotPointY
272 float returnValue = 0.0f;
273 PropertyValue anchorPointY = GetProperty(View.Property.AnchorPointY);
274 anchorPointY?.Get(out returnValue);
275 anchorPointY?.Dispose();
280 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
281 SetProperty(View.Property.AnchorPointY, setValue);
286 internal float PivotPointZ
290 float returnValue = 0.0f;
291 PropertyValue anchorPointZ = GetProperty(View.Property.AnchorPointZ);
292 anchorPointZ?.Get(out returnValue);
293 anchorPointZ?.Dispose();
298 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
299 SetProperty(View.Property.AnchorPointZ, setValue);
304 internal Matrix WorldMatrix
308 Matrix returnValue = new Matrix();
309 PropertyValue wordMatrix = GetProperty(View.Property.WorldMatrix);
310 wordMatrix?.Get(returnValue);
311 wordMatrix?.Dispose();
317 /// The number of layouts including view's layout and children's layouts.
318 /// This can be used to set/unset Process callback to calculate Layout.
320 internal int LayoutCount
329 if (layoutCount == value) return;
331 if (value < 0) throw new global::System.ArgumentOutOfRangeException(nameof(LayoutCount), "LayoutCount(" + LayoutCount + ") should not be less than zero");
333 int diff = value - layoutCount;
336 if (InternalParent != null)
338 var parentView = InternalParent as View;
339 if (parentView != null)
341 parentView.LayoutCount += diff;
345 var parentLayer = InternalParent as Layer;
346 if (parentLayer != null)
348 parentLayer.LayoutCount += diff;
356 /// Indicates that this View should listen Touch event to handle its ControlState.
358 private bool enableControlState = false;
360 private int LeftFocusableViewId
365 PropertyValue leftFocusableViewId = GetProperty(View.Property.LeftFocusableViewId);
366 leftFocusableViewId?.Get(out returnValue);
367 leftFocusableViewId?.Dispose();
372 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
373 SetProperty(View.Property.LeftFocusableViewId, setValue);
378 private int RightFocusableViewId
383 PropertyValue rightFocusableViewId = GetProperty(View.Property.RightFocusableViewId);
384 rightFocusableViewId?.Get(out returnValue);
385 rightFocusableViewId?.Dispose();
390 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
391 SetProperty(View.Property.RightFocusableViewId, setValue);
396 private int UpFocusableViewId
401 PropertyValue upFocusableViewId = GetProperty(View.Property.UpFocusableViewId);
402 upFocusableViewId?.Get(out returnValue);
403 upFocusableViewId?.Dispose();
408 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
409 SetProperty(View.Property.UpFocusableViewId, setValue);
414 private int DownFocusableViewId
419 PropertyValue downFocusableViewId = GetProperty(View.Property.DownFocusableViewId);
420 downFocusableViewId?.Get(out returnValue);
421 downFocusableViewId?.Dispose();
426 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
427 SetProperty(View.Property.DownFocusableViewId, setValue);
432 internal string GetName()
434 string ret = Interop.Actor.GetName(SwigCPtr);
435 if (NDalicPINVOKE.SWIGPendingException.Pending)
436 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
440 internal void SetName(string name)
442 Interop.Actor.SetName(SwigCPtr, name);
443 if (NDalicPINVOKE.SWIGPendingException.Pending)
444 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
447 internal uint GetId()
449 uint ret = Interop.Actor.GetId(SwigCPtr);
450 if (NDalicPINVOKE.SWIGPendingException.Pending)
451 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
455 internal bool IsRoot()
457 bool ret = Interop.ActorInternal.IsRoot(SwigCPtr);
458 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
462 internal bool OnWindow()
464 bool ret = Interop.Actor.OnStage(SwigCPtr);
465 if (NDalicPINVOKE.SWIGPendingException.Pending)
466 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
470 internal View FindChildById(uint id)
472 //to fix memory leak issue, match the handle count with native side.
473 IntPtr cPtr = Interop.Actor.FindChildById(SwigCPtr, id);
474 View ret = this.GetInstanceSafely<View>(cPtr);
475 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
479 internal override View FindCurrentChildById(uint id)
481 return FindChildById(id);
484 internal void SetParentOrigin(Vector3 origin)
486 Interop.ActorInternal.SetParentOrigin(SwigCPtr, Vector3.getCPtr(origin));
487 if (NDalicPINVOKE.SWIGPendingException.Pending)
488 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
491 internal Vector3 GetCurrentParentOrigin()
493 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentParentOrigin(SwigCPtr), true);
494 if (NDalicPINVOKE.SWIGPendingException.Pending)
495 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
499 internal void SetAnchorPoint(Vector3 anchorPoint)
501 Interop.Actor.SetAnchorPoint(SwigCPtr, Vector3.getCPtr(anchorPoint));
502 if (NDalicPINVOKE.SWIGPendingException.Pending)
503 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
506 internal Vector3 GetCurrentAnchorPoint()
508 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentAnchorPoint(SwigCPtr), true);
509 if (NDalicPINVOKE.SWIGPendingException.Pending)
510 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
514 internal void SetSize(float width, float height)
516 Interop.ActorInternal.SetSize(SwigCPtr, width, height);
517 if (NDalicPINVOKE.SWIGPendingException.Pending)
518 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
521 internal void SetSize(float width, float height, float depth)
523 Interop.ActorInternal.SetSize(SwigCPtr, width, height, depth);
524 if (NDalicPINVOKE.SWIGPendingException.Pending)
525 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
528 internal void SetSize(Vector2 size)
530 Interop.ActorInternal.SetSizeVector2(SwigCPtr, Vector2.getCPtr(size));
531 if (NDalicPINVOKE.SWIGPendingException.Pending)
532 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
535 internal void SetSize(Vector3 size)
537 Interop.ActorInternal.SetSizeVector3(SwigCPtr, Vector3.getCPtr(size));
538 if (NDalicPINVOKE.SWIGPendingException.Pending)
539 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
542 internal Vector3 GetTargetSize()
544 Vector3 ret = new Vector3(Interop.ActorInternal.GetTargetSize(SwigCPtr), true);
545 if (NDalicPINVOKE.SWIGPendingException.Pending)
546 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
550 internal Size2D GetCurrentSize()
552 Size ret = new Size(Interop.Actor.GetCurrentSize(SwigCPtr), true);
553 if (NDalicPINVOKE.SWIGPendingException.Pending)
554 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
555 Size2D size = new Size2D((int)ret.Width, (int)ret.Height);
560 internal Size2D GetCurrentSizeFloat()
562 Size ret = new Size(Interop.Actor.GetCurrentSize(SwigCPtr), true);
563 if (NDalicPINVOKE.SWIGPendingException.Pending)
564 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
569 /// GetNaturalSize() function behaviour can be changed for each subclass of View.
570 /// So we make GetNaturalSize() function virtual, and make subclass can define it's owned logic
572 internal virtual Vector3 GetNaturalSize()
574 Vector3 ret = new Vector3(Interop.Actor.GetNaturalSize(SwigCPtr), true);
575 if (NDalicPINVOKE.SWIGPendingException.Pending)
576 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
580 internal void SetPosition(float x, float y)
582 Interop.ActorInternal.SetPosition(SwigCPtr, x, y);
583 if (NDalicPINVOKE.SWIGPendingException.Pending)
584 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
587 internal void SetPosition(float x, float y, float z)
589 Interop.ActorInternal.SetPosition(SwigCPtr, x, y, z);
590 if (NDalicPINVOKE.SWIGPendingException.Pending)
591 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
594 internal void SetPosition(Vector3 position)
596 Interop.ActorInternal.SetPosition(SwigCPtr, Vector3.getCPtr(position));
597 if (NDalicPINVOKE.SWIGPendingException.Pending)
598 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
601 internal void SetX(float x)
603 Interop.ActorInternal.SetX(SwigCPtr, x);
604 if (NDalicPINVOKE.SWIGPendingException.Pending)
605 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
608 internal void SetY(float y)
610 Interop.ActorInternal.SetY(SwigCPtr, y);
611 if (NDalicPINVOKE.SWIGPendingException.Pending)
612 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
615 internal void SetZ(float z)
617 Interop.ActorInternal.SetZ(SwigCPtr, z);
618 if (NDalicPINVOKE.SWIGPendingException.Pending)
619 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
622 internal void TranslateBy(Vector3 distance)
624 Interop.ActorInternal.TranslateBy(SwigCPtr, Vector3.getCPtr(distance));
625 if (NDalicPINVOKE.SWIGPendingException.Pending)
626 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
629 internal Position GetCurrentPosition()
631 Position ret = new Position(Interop.Actor.GetCurrentPosition(SwigCPtr), true);
632 if (NDalicPINVOKE.SWIGPendingException.Pending)
633 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
637 internal Vector3 GetCurrentWorldPosition()
639 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentWorldPosition(SwigCPtr), true);
640 if (NDalicPINVOKE.SWIGPendingException.Pending)
641 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
645 internal void SetInheritPosition(bool inherit)
647 Interop.ActorInternal.SetInheritPosition(SwigCPtr, inherit);
648 if (NDalicPINVOKE.SWIGPendingException.Pending)
649 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
652 internal bool IsPositionInherited()
654 bool ret = Interop.ActorInternal.IsPositionInherited(SwigCPtr);
655 if (NDalicPINVOKE.SWIGPendingException.Pending)
656 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
660 internal void SetOrientation(Degree angle, Vector3 axis)
662 Interop.ActorInternal.SetOrientationDegree(SwigCPtr, Degree.getCPtr(angle), Vector3.getCPtr(axis));
663 if (NDalicPINVOKE.SWIGPendingException.Pending)
664 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
667 internal void SetOrientation(Radian angle, Vector3 axis)
669 Interop.ActorInternal.SetOrientationRadian(SwigCPtr, Radian.getCPtr(angle), Vector3.getCPtr(axis));
670 if (NDalicPINVOKE.SWIGPendingException.Pending)
671 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
674 internal void SetOrientation(Rotation orientation)
676 Interop.ActorInternal.SetOrientationQuaternion(SwigCPtr, Rotation.getCPtr(orientation));
677 if (NDalicPINVOKE.SWIGPendingException.Pending)
678 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
681 internal Rotation GetCurrentOrientation()
683 Rotation ret = new Rotation(Interop.ActorInternal.GetCurrentOrientation(SwigCPtr), true);
684 if (NDalicPINVOKE.SWIGPendingException.Pending)
685 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
689 internal void SetInheritOrientation(bool inherit)
691 Interop.ActorInternal.SetInheritOrientation(SwigCPtr, inherit);
692 if (NDalicPINVOKE.SWIGPendingException.Pending)
693 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
696 internal bool IsOrientationInherited()
698 bool ret = Interop.ActorInternal.IsOrientationInherited(SwigCPtr);
699 if (NDalicPINVOKE.SWIGPendingException.Pending)
700 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
704 internal Rotation GetCurrentWorldOrientation()
706 Rotation ret = new Rotation(Interop.ActorInternal.GetCurrentWorldOrientation(SwigCPtr), true);
707 if (NDalicPINVOKE.SWIGPendingException.Pending)
708 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
712 internal void SetScale(float scale)
714 Interop.ActorInternal.SetScale(SwigCPtr, scale);
715 if (NDalicPINVOKE.SWIGPendingException.Pending)
716 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
719 internal void SetScale(float scaleX, float scaleY, float scaleZ)
721 Interop.ActorInternal.SetScale(SwigCPtr, scaleX, scaleY, scaleZ);
722 if (NDalicPINVOKE.SWIGPendingException.Pending)
723 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
726 internal void SetScale(Vector3 scale)
728 Interop.ActorInternal.SetScale(SwigCPtr, Vector3.getCPtr(scale));
729 if (NDalicPINVOKE.SWIGPendingException.Pending)
730 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
733 internal Vector3 GetCurrentScale()
735 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentScale(SwigCPtr), true);
736 if (NDalicPINVOKE.SWIGPendingException.Pending)
737 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
741 internal Vector3 GetCurrentWorldScale()
743 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentWorldScale(SwigCPtr), true);
744 if (NDalicPINVOKE.SWIGPendingException.Pending)
745 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
749 internal void SetInheritScale(bool inherit)
751 Interop.ActorInternal.SetInheritScale(SwigCPtr, inherit);
752 if (NDalicPINVOKE.SWIGPendingException.Pending)
753 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
756 internal bool IsScaleInherited()
758 bool ret = Interop.ActorInternal.IsScaleInherited(SwigCPtr);
759 if (NDalicPINVOKE.SWIGPendingException.Pending)
760 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
764 internal Matrix GetCurrentWorldMatrix()
766 Matrix ret = new Matrix(Interop.ActorInternal.GetCurrentWorldMatrix(SwigCPtr), true);
767 if (NDalicPINVOKE.SWIGPendingException.Pending)
768 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
772 internal void SetVisible(bool visible)
774 Interop.Actor.SetVisible(SwigCPtr, visible);
775 if (NDalicPINVOKE.SWIGPendingException.Pending)
776 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
779 internal bool IsVisible()
781 bool ret = Interop.ActorInternal.IsVisible(SwigCPtr);
782 if (NDalicPINVOKE.SWIGPendingException.Pending)
783 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
787 internal void SetOpacity(float opacity)
789 Interop.ActorInternal.SetOpacity(SwigCPtr, opacity);
790 if (NDalicPINVOKE.SWIGPendingException.Pending)
791 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
794 internal float GetCurrentOpacity()
796 float ret = Interop.ActorInternal.GetCurrentOpacity(SwigCPtr);
797 if (NDalicPINVOKE.SWIGPendingException.Pending)
798 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
802 internal Vector4 GetCurrentColor()
804 Vector4 ret = new Vector4(Interop.ActorInternal.GetCurrentColor(SwigCPtr), true);
805 if (NDalicPINVOKE.SWIGPendingException.Pending)
806 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
809 internal ColorMode GetColorMode()
811 ColorMode ret = (ColorMode)Interop.ActorInternal.GetColorMode(SwigCPtr);
812 if (NDalicPINVOKE.SWIGPendingException.Pending)
813 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
817 internal Vector4 GetCurrentWorldColor()
819 Vector4 ret = new Vector4(Interop.ActorInternal.GetCurrentWorldColor(SwigCPtr), true);
820 if (NDalicPINVOKE.SWIGPendingException.Pending)
821 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
825 internal void SetDrawMode(DrawModeType drawMode)
827 Interop.ActorInternal.SetDrawMode(SwigCPtr, (int)drawMode);
828 if (NDalicPINVOKE.SWIGPendingException.Pending)
829 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
832 internal DrawModeType GetDrawMode()
834 DrawModeType ret = (DrawModeType)Interop.ActorInternal.GetDrawMode(SwigCPtr);
835 if (NDalicPINVOKE.SWIGPendingException.Pending)
836 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
840 internal void SetKeyboardFocusable(bool focusable)
842 Interop.ActorInternal.SetKeyboardFocusable(SwigCPtr, focusable);
843 if (NDalicPINVOKE.SWIGPendingException.Pending)
844 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
847 internal bool IsKeyboardFocusable()
849 bool ret = Interop.ActorInternal.IsKeyboardFocusable(SwigCPtr);
850 if (NDalicPINVOKE.SWIGPendingException.Pending)
851 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
855 internal void SetKeyboardFocusableChildren(bool focusable)
857 Interop.ActorInternal.SetKeyboardFocusableChildren(SwigCPtr, focusable);
858 if (NDalicPINVOKE.SWIGPendingException.Pending)
859 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
862 internal bool AreChildrenKeyBoardFocusable()
864 bool ret = Interop.ActorInternal.AreChildrenKeyBoardFocusable(SwigCPtr);
865 if (NDalicPINVOKE.SWIGPendingException.Pending)
866 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
870 internal void SetFocusableInTouch(bool enabled)
872 Interop.ActorInternal.SetFocusableInTouch(SwigCPtr, enabled);
873 if (NDalicPINVOKE.SWIGPendingException.Pending)
874 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
877 internal bool IsFocusableInTouch()
879 bool ret = Interop.ActorInternal.IsFocusableInTouch(SwigCPtr);
880 if (NDalicPINVOKE.SWIGPendingException.Pending)
881 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
885 internal void SetResizePolicy(ResizePolicyType policy, DimensionType dimension)
887 Interop.Actor.SetResizePolicy(SwigCPtr, (int)policy, (int)dimension);
888 if (NDalicPINVOKE.SWIGPendingException.Pending)
889 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
892 internal ResizePolicyType GetResizePolicy(DimensionType dimension)
894 ResizePolicyType ret = (ResizePolicyType)Interop.Actor.GetResizePolicy(SwigCPtr, (int)dimension);
895 if (NDalicPINVOKE.SWIGPendingException.Pending)
896 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
900 internal Vector3 GetSizeModeFactor()
902 Vector3 ret = new Vector3(Interop.Actor.GetSizeModeFactor(SwigCPtr), true);
903 if (NDalicPINVOKE.SWIGPendingException.Pending)
904 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
908 internal void SetMinimumSize(Vector2 size)
910 Interop.ActorInternal.SetMinimumSize(SwigCPtr, Vector2.getCPtr(size));
911 if (NDalicPINVOKE.SWIGPendingException.Pending)
912 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
915 internal Vector2 GetMinimumSize()
917 Vector2 ret = new Vector2(Interop.ActorInternal.GetMinimumSize(SwigCPtr), true);
918 if (NDalicPINVOKE.SWIGPendingException.Pending)
919 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
923 internal void SetMaximumSize(Vector2 size)
925 Interop.ActorInternal.SetMaximumSize(SwigCPtr, Vector2.getCPtr(size));
926 if (NDalicPINVOKE.SWIGPendingException.Pending)
927 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
930 internal Vector2 GetMaximumSize()
932 Vector2 ret = new Vector2(Interop.ActorInternal.GetMaximumSize(SwigCPtr), true);
933 if (NDalicPINVOKE.SWIGPendingException.Pending)
934 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
938 internal int GetHierarchyDepth()
940 int ret = Interop.Actor.GetHierarchyDepth(SwigCPtr);
941 if (NDalicPINVOKE.SWIGPendingException.Pending)
942 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
946 internal uint GetRendererCount()
948 uint ret = Interop.Actor.GetRendererCount(SwigCPtr);
949 if (NDalicPINVOKE.SWIGPendingException.Pending)
950 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
954 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(View obj)
956 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
959 internal bool IsTopLevelView()
961 if (GetParent() is Layer)
968 internal void SetKeyInputFocus()
970 Interop.ViewInternal.SetKeyInputFocus(SwigCPtr);
971 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
974 internal void ClearKeyInputFocus()
976 Interop.ViewInternal.ClearKeyInputFocus(SwigCPtr);
977 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
980 internal PinchGestureDetector GetPinchGestureDetector()
982 PinchGestureDetector ret = new PinchGestureDetector(Interop.ViewInternal.GetPinchGestureDetector(SwigCPtr), true);
983 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
987 internal PanGestureDetector GetPanGestureDetector()
989 PanGestureDetector ret = new PanGestureDetector(Interop.ViewInternal.GetPanGestureDetector(SwigCPtr), true);
990 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
994 internal TapGestureDetector GetTapGestureDetector()
996 TapGestureDetector ret = new TapGestureDetector(Interop.ViewInternal.GetTapGestureDetector(SwigCPtr), true);
997 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1001 internal LongPressGestureDetector GetLongPressGestureDetector()
1003 LongPressGestureDetector ret = new LongPressGestureDetector(Interop.ViewInternal.GetLongPressGestureDetector(SwigCPtr), true);
1004 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1008 internal IntPtr GetPtrfromView()
1010 return (IntPtr)SwigCPtr;
1013 internal void RemoveChild(View child)
1015 // Do actual child removal
1016 Interop.Actor.Remove(SwigCPtr, View.getCPtr(child));
1017 if (NDalicPINVOKE.SWIGPendingException.Pending)
1018 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1020 Children.Remove(child);
1021 child.InternalParent = null;
1022 LayoutCount -= child.LayoutCount;
1024 OnChildRemoved(child);
1025 if (ChildRemoved != null)
1027 ChildRemovedEventArgs e = new ChildRemovedEventArgs
1031 ChildRemoved(this, e);
1036 /// Removes the layout from this View.
1038 internal void ResetLayout()
1045 internal ResourceLoadingStatusType GetBackgroundResourceStatus()
1047 return (ResourceLoadingStatusType)Interop.View.GetVisualResourceStatus(this.SwigCPtr, Property.BACKGROUND);
1050 /// TODO open as a protected level
1051 internal virtual void ApplyCornerRadius()
1053 if (backgroundExtraData == null) return;
1055 var cornerRadiusValue = backgroundExtraData.CornerRadius == null ? new PropertyValue() : new PropertyValue(backgroundExtraData.CornerRadius);
1056 var cornerRadiusPolicyValue = new PropertyValue((int)backgroundExtraData.CornerRadiusPolicy);
1058 // Make current propertyMap
1059 PropertyMap currentPropertyMap = new PropertyMap();
1060 currentPropertyMap[Visual.Property.CornerRadius] = cornerRadiusValue;
1061 currentPropertyMap[Visual.Property.CornerRadiusPolicy] = cornerRadiusPolicyValue;
1062 var temp = new PropertyValue(currentPropertyMap);
1064 // Update corner radius properties to background and shadow by ActionUpdateProperty
1065 DoAction(View.Property.BACKGROUND, ActionUpdateProperty, temp);
1066 DoAction(View.Property.SHADOW, ActionUpdateProperty, temp);
1069 currentPropertyMap.Dispose();
1070 cornerRadiusValue.Dispose();
1071 cornerRadiusPolicyValue.Dispose();
1074 /// TODO open as a protected level
1075 internal virtual void ApplyBorderline()
1077 if (backgroundExtraData == null) return;
1079 var borderlineWidthValue = new PropertyValue(backgroundExtraData.BorderlineWidth);
1080 var borderlineColorValue = backgroundExtraData.BorderlineColor == null ? new PropertyValue(Color.Black) : new PropertyValue(backgroundExtraData.BorderlineColor);
1081 var borderlineOffsetValue = new PropertyValue(backgroundExtraData.BorderlineOffset);
1083 // Make current propertyMap
1084 PropertyMap currentPropertyMap = new PropertyMap();
1085 currentPropertyMap[Visual.Property.BorderlineWidth] = borderlineWidthValue;
1086 currentPropertyMap[Visual.Property.BorderlineColor] = borderlineColorValue;
1087 currentPropertyMap[Visual.Property.BorderlineOffset] = borderlineOffsetValue;
1088 var temp = new PropertyValue(currentPropertyMap);
1090 // Update borderline properties to background by ActionUpdateProperty
1091 DoAction(View.Property.BACKGROUND, ActionUpdateProperty, temp);
1094 currentPropertyMap.Dispose();
1095 borderlineWidthValue.Dispose();
1096 borderlineColorValue.Dispose();
1097 borderlineOffsetValue.Dispose();
1101 /// Get selector value from the triggerable selector or related property.
1103 internal Selector<T> GetSelector<T>(TriggerableSelector<T> triggerableSelector, NUI.Binding.BindableProperty relatedProperty)
1105 var selector = triggerableSelector?.Get();
1106 if (selector != null)
1111 var value = (T)GetValue(relatedProperty);
1112 return value == null ? null : new Selector<T>(value);
1115 internal void SetThemeApplied()
1117 if (themeData == null) themeData = new ThemeData();
1118 themeData.ThemeApplied = true;
1120 if (ThemeChangeSensitive && !themeData.ListeningThemeChangeEvent)
1122 themeData.ListeningThemeChangeEvent = true;
1123 ThemeManager.ThemeChangedInternal.Add(OnThemeChanged);
1128 /// you can override it to clean-up your own resources.
1130 /// <param name="type">DisposeTypes</param>
1131 /// <since_tizen> 3 </since_tizen>
1132 protected override void Dispose(DisposeTypes type)
1139 DebugFileLogging.Instance.WriteLog($"View.Dispose({type}) START");
1140 DebugFileLogging.Instance.WriteLog($"type:{GetType()} copyNativeHandle:{GetBaseHandleCPtrHandleRef.Handle.ToString("X8")}");
1143 DebugFileLogging.Instance.WriteLog($"ID:{Interop.Actor.GetId(GetBaseHandleCPtrHandleRef)} Name:{Interop.Actor.GetName(GetBaseHandleCPtrHandleRef)}");
1147 DebugFileLogging.Instance.WriteLog($"has no native body!");
1150 //_mergedStyle = null;
1152 internalMaximumSize?.Dispose();
1153 internalMaximumSize = null;
1154 internalMinimumSize?.Dispose();
1155 internalMinimumSize = null;
1156 internalMargin?.Dispose();
1157 internalMargin = null;
1158 internalPadding?.Dispose();
1159 internalPadding = null;
1160 internalSizeModeFactor?.Dispose();
1161 internalSizeModeFactor = null;
1162 internalCellIndex?.Dispose();
1163 internalCellIndex = null;
1164 internalBackgroundColor?.Dispose();
1165 internalBackgroundColor = null;
1166 internalColor?.Dispose();
1167 internalColor = null;
1168 internalPivotPoint?.Dispose();
1169 internalPivotPoint = null;
1170 internalPosition?.Dispose();
1171 internalPosition = null;
1172 internalPosition2D?.Dispose();
1173 internalPosition2D = null;
1174 internalScale?.Dispose();
1175 internalScale = null;
1176 internalSize?.Dispose();
1177 internalSize = null;
1178 internalSize2D?.Dispose();
1179 internalSize2D = null;
1181 if (type == DisposeTypes.Explicit)
1184 //Release your own managed resources here.
1185 //You should release all of your own disposable objects here.
1186 if (themeData != null)
1188 themeData.selectorData?.Reset(this);
1189 if (themeData.ListeningThemeChangeEvent)
1191 ThemeManager.ThemeChangedInternal.Remove(OnThemeChanged);
1194 if (widthConstraint != null)
1196 widthConstraint.Remove();
1197 widthConstraint.Dispose();
1199 if (heightConstraint != null)
1201 heightConstraint.Remove();
1202 heightConstraint.Dispose();
1206 //Release your own unmanaged resources here.
1207 //You should not access any managed member here except static instance.
1208 //because the execution order of Finalizes is non-deterministic.
1210 DisConnectFromSignals();
1212 foreach (View view in Children)
1214 view.InternalParent = null;
1219 NUILog.Debug($"[Dispose] View.Dispose({type}) END");
1220 NUILog.Debug($"=============================");
1225 /// This will not be public opened.
1226 [EditorBrowsable(EditorBrowsableState.Never)]
1227 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1229 Interop.View.DeleteView(swigCPtr);
1233 /// The touch event handler for ControlState.
1234 /// Please change ControlState value by touch state if needed.
1236 /// <exception cref="ArgumentNullException"> Thrown when touch is null. </exception>
1237 [EditorBrowsable(EditorBrowsableState.Never)]
1238 protected virtual bool HandleControlStateOnTouch(Touch touch)
1242 throw new global::System.ArgumentNullException(nameof(touch));
1245 switch (touch.GetState(0))
1247 case PointStateType.Down:
1248 ControlState += ControlState.Pressed;
1250 case PointStateType.Interrupted:
1251 case PointStateType.Up:
1252 if (ControlState.Contains(ControlState.Pressed))
1254 ControlState -= ControlState.Pressed;
1263 private void DisConnectFromSignals()
1265 if (HasBody() == false)
1267 NUILog.Debug($"[Dispose] DisConnectFromSignals() No native body! No need to Disconnect Signals!");
1270 NUILog.Debug($"[Dispose] DisConnectFromSignals START");
1271 NUILog.Debug($"[Dispose] View.DisConnectFromSignals() type:{GetType()} copyNativeHandle:{GetBaseHandleCPtrHandleRef.Handle.ToString("X8")}");
1272 NUILog.Debug($"[Dispose] ID:{Interop.Actor.GetId(GetBaseHandleCPtrHandleRef)} Name:{Interop.Actor.GetName(GetBaseHandleCPtrHandleRef)}");
1274 if (onRelayoutEventCallback != null)
1276 NUILog.Debug($"[Dispose] onRelayoutEventCallback");
1278 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnRelayoutSignal(GetBaseHandleCPtrHandleRef), false);
1279 signal?.Disconnect(onRelayoutEventCallback);
1280 onRelayoutEventCallback = null;
1283 if (offWindowEventCallback != null)
1285 NUILog.Debug($"[Dispose] offWindowEventCallback");
1287 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOffSceneSignal(GetBaseHandleCPtrHandleRef), false);
1288 signal?.Disconnect(offWindowEventCallback);
1289 offWindowEventCallback = null;
1292 if (onWindowEventCallback != null)
1294 NUILog.Debug($"[Dispose] onWindowEventCallback");
1296 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(GetBaseHandleCPtrHandleRef), false);
1297 signal?.Disconnect(onWindowEventCallback);
1298 onWindowEventCallback = null;
1301 if (wheelEventCallback != null)
1303 NUILog.Debug($"[Dispose] wheelEventCallback");
1305 using WheelSignal signal = new WheelSignal(Interop.ActorSignal.ActorWheelEventSignal(GetBaseHandleCPtrHandleRef), false);
1306 signal?.Disconnect(wheelEventCallback);
1307 wheelEventCallback = null;
1310 if (hoverEventCallback != null)
1312 NUILog.Debug($"[Dispose] hoverEventCallback");
1314 using HoverSignal signal = new HoverSignal(Interop.ActorSignal.ActorHoveredSignal(GetBaseHandleCPtrHandleRef), false);
1315 signal?.Disconnect(hoverEventCallback);
1316 hoverEventCallback = null;
1319 if (interceptTouchDataCallback != null)
1321 NUILog.Debug($"[Dispose] interceptTouchDataCallback");
1323 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorInterceptTouchSignal(GetBaseHandleCPtrHandleRef), false);
1324 signal?.Disconnect(interceptTouchDataCallback);
1325 interceptTouchDataCallback = null;
1328 if (touchDataCallback != null)
1330 NUILog.Debug($"[Dispose] touchDataCallback");
1332 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorTouchSignal(GetBaseHandleCPtrHandleRef), false);
1333 signal?.Disconnect(touchDataCallback);
1334 touchDataCallback = null;
1337 if (ResourcesLoadedCallback != null)
1339 NUILog.Debug($"[Dispose] ResourcesLoadedCallback");
1341 using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(GetBaseHandleCPtrHandleRef), false);
1342 signal?.Disconnect(ResourcesLoadedCallback);
1343 ResourcesLoadedCallback = null;
1346 if (keyCallback != null)
1348 NUILog.Debug($"[Dispose] keyCallback");
1350 using ControlKeySignal signal = new ControlKeySignal(Interop.ViewSignal.KeyEventSignal(GetBaseHandleCPtrHandleRef), false);
1351 signal?.Disconnect(keyCallback);
1355 if (keyInputFocusLostCallback != null)
1357 NUILog.Debug($"[Dispose] keyInputFocusLostCallback");
1359 using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusLostSignal(GetBaseHandleCPtrHandleRef), false);
1360 signal?.Disconnect(keyInputFocusLostCallback);
1361 keyInputFocusLostCallback = null;
1362 keyInputFocusLostEventHandler = null;
1365 if (keyInputFocusGainedCallback != null)
1367 NUILog.Debug($"[Dispose] keyInputFocusGainedCallback");
1369 using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusGainedSignal(GetBaseHandleCPtrHandleRef), false);
1370 signal?.Disconnect(keyInputFocusGainedCallback);
1371 keyInputFocusGainedCallback = null;
1372 keyInputFocusGainedEventHandler = null;
1375 if (backgroundResourceLoadedCallback != null)
1377 NUILog.Debug($"[Dispose] backgroundResourceLoadedCallback");
1379 using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(GetBaseHandleCPtrHandleRef), false);
1380 signal?.Disconnect(backgroundResourceLoadedCallback);
1381 backgroundResourceLoadedCallback = null;
1384 if (onWindowSendEventCallback != null)
1386 NUILog.Debug($"[Dispose] onWindowSendEventCallback");
1388 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(GetBaseHandleCPtrHandleRef), false);
1389 signal?.Disconnect(onWindowSendEventCallback);
1390 onWindowSendEventCallback = null;
1392 NUILog.Debug($"[Dispose] DisConnectFromSignals END");
1396 /// Apply initial style to the view.
1398 [EditorBrowsable(EditorBrowsableState.Never)]
1399 protected virtual void InitializeStyle(ViewStyle style = null)
1401 var initialStyle = ThemeManager.GetInitialStyleWithoutClone(GetType());
1404 ApplyStyle(initialStyle);
1408 var refinedStyle = style;
1409 if (style.IncludeDefaultStyle)
1411 refinedStyle = initialStyle?.Merge(style);
1413 ApplyStyle(refinedStyle);
1416 // Listen theme change event if needs.
1417 if (ThemeManager.PlatformThemeEnabled && initialStyle != null)
1423 private View ConvertIdToView(uint id)
1425 View view = GetParent()?.FindCurrentChildById(id);
1427 //If we can't find the parent's children, find in the top layer.
1430 Container parent = GetParent();
1431 while ((parent is View) && (parent != null))
1433 parent = parent.GetParent();
1434 if (parent is Layer)
1436 view = parent.FindCurrentChildById(id);
1445 private void OnScaleChanged(float x, float y, float z)
1447 Scale = new Vector3(x, y, z);
1450 private void OnBackgroundColorChanged(float r, float g, float b, float a)
1452 BackgroundColor = new Color(r, g, b, a);
1455 private void OnPaddingChanged(ushort start, ushort end, ushort top, ushort bottom)
1457 Padding = new Extents(start, end, top, bottom);
1460 private void OnMarginChanged(ushort start, ushort end, ushort top, ushort bottom)
1462 Margin = new Extents(start, end, top, bottom);
1465 private void OnAnchorPointChanged(float x, float y, float z)
1467 AnchorPoint = new Position(x, y, z);
1470 private void OnCellIndexChanged(float x, float y)
1472 CellIndex = new Vector2(x, y);
1475 private void OnFlexMarginChanged(float x, float y, float z, float w)
1477 FlexMargin = new Vector4(x, y, z, w);
1480 private void OnPaddingEXChanged(ushort start, ushort end, ushort top, ushort bottom)
1482 PaddingEX = new Extents(start, end, top, bottom);
1485 private void OnSizeModeFactorChanged(float x, float y, float z)
1487 SizeModeFactor = new Vector3(x, y, z);
1490 private bool EmptyOnTouch(object target, TouchEventArgs args)
1495 private ViewSelectorData EnsureSelectorData()
1497 if (themeData == null) themeData = new ThemeData();
1499 return themeData.selectorData ?? (themeData.selectorData = new ViewSelectorData());