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;
24 namespace Tizen.NUI.BaseComponents
27 /// View is the base class for all views.
29 /// <since_tizen> 3 </since_tizen>
30 public partial class View
32 internal string styleName;
34 internal class ThemeData
37 private enum States : byte
40 ControlStatePropagation = 1 << 0,
41 ThemeChangeSensitive = 1 << 1,
42 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.
43 // That indicates the view can have different styles by theme.
44 // Hence if the current state has ThemeApplied and ThemeChangeSensitive, the view will change its style by theme changing.
45 ListeningThemeChangeEvent = 1 << 3,
48 private States states = ThemeManager.ApplicationThemeChangeSensitive ? States.ThemeChangeSensitive : States.None;
49 public ViewStyle viewStyle;
50 public ControlState controlStates = ControlState.Normal;
51 public ViewSelectorData selectorData;
53 public bool ControlStatePropagation
55 get => ((states & States.ControlStatePropagation) != 0);
56 set => SetOption(States.ControlStatePropagation, value);
59 public bool ThemeChangeSensitive
61 get => ((states & States.ThemeChangeSensitive) != 0);
62 set => SetOption(States.ThemeChangeSensitive, value);
65 public bool ThemeApplied
67 get => ((states & States.ThemeApplied) != 0);
68 set => SetOption(States.ThemeApplied, value);
71 public bool ListeningThemeChangeEvent
73 get => ((states & States.ListeningThemeChangeEvent) != 0);
74 set => SetOption(States.ListeningThemeChangeEvent, value);
77 private void SetOption(States option, bool value)
79 if (value) states |= option;
80 else states &= ~option;
85 /// The color mode of View.
86 /// This specifies whether the View uses its own color, or inherits its parent color.
87 /// The default is ColorMode.UseOwnMultiplyParentColor.
89 internal ColorMode ColorMode
97 return GetColorMode();
101 internal LayoutLength SuggestedMinimumWidth
105 float result = Interop.Actor.GetSuggestedMinimumWidth(SwigCPtr);
106 if (NDalicPINVOKE.SWIGPendingException.Pending)
107 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
108 return new LayoutLength(result);
112 internal LayoutLength SuggestedMinimumHeight
116 float result = Interop.Actor.GetSuggestedMinimumHeight(SwigCPtr);
117 if (NDalicPINVOKE.SWIGPendingException.Pending)
118 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
119 return new LayoutLength(result);
123 internal float WorldPositionX
127 float returnValue = 0.0f;
128 PropertyValue wordPositionX = GetProperty(View.Property.WorldPositionX);
129 wordPositionX?.Get(out returnValue);
130 wordPositionX?.Dispose();
135 internal float WorldPositionY
139 float returnValue = 0.0f;
140 PropertyValue wordPositionY = GetProperty(View.Property.WorldPositionY);
141 wordPositionY?.Get(out returnValue);
142 wordPositionY?.Dispose();
147 internal float WorldPositionZ
151 float returnValue = 0.0f;
152 PropertyValue wordPositionZ = GetProperty(View.Property.WorldPositionZ);
153 wordPositionZ?.Get(out returnValue);
154 wordPositionZ?.Dispose();
159 internal bool FocusState
163 return IsKeyboardFocusable();
167 SetKeyboardFocusable(value);
171 internal void SetLayout(LayoutItem layout)
173 Window.Instance.LayoutController.CreateProcessCallback();
174 this.layout = layout;
175 this.layout?.AttachToOwner(this);
176 this.layout?.RequestLayout();
179 internal void AttachTransitionsToChildren(LayoutTransition transition)
181 // Iterate children, adding the transition unless a transition
182 // for the same condition and property has already been
184 foreach (View view in Children)
186 LayoutTransitionsHelper.AddTransitionForCondition(view.LayoutTransitions, transition.Condition, transition, false);
190 internal float ParentOriginX
194 float returnValue = 0.0f;
195 PropertyValue parentOriginX = GetProperty(View.Property.ParentOriginX);
196 parentOriginX?.Get(out returnValue);
197 parentOriginX?.Dispose();
202 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
203 SetProperty(View.Property.ParentOriginX, setValue);
205 NotifyPropertyChanged();
209 internal float ParentOriginY
213 float returnValue = 0.0f;
214 PropertyValue parentOriginY = GetProperty(View.Property.ParentOriginY);
215 parentOriginY?.Get(out returnValue);
216 parentOriginY?.Dispose();
221 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
222 SetProperty(View.Property.ParentOriginY, setValue);
224 NotifyPropertyChanged();
228 internal float ParentOriginZ
232 float returnValue = 0.0f;
233 PropertyValue parentOriginZ = GetProperty(View.Property.ParentOriginZ);
234 parentOriginZ?.Get(out returnValue);
235 parentOriginZ?.Dispose();
240 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
241 SetProperty(View.Property.ParentOriginZ, setValue);
243 NotifyPropertyChanged();
247 internal float PivotPointX
251 float returnValue = 0.0f;
252 PropertyValue anchorPointX = GetProperty(View.Property.AnchorPointX);
253 anchorPointX?.Get(out returnValue);
254 anchorPointX?.Dispose();
259 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
260 SetProperty(View.Property.AnchorPointX, setValue);
265 internal float PivotPointY
269 float returnValue = 0.0f;
270 PropertyValue anchorPointY = GetProperty(View.Property.AnchorPointY);
271 anchorPointY?.Get(out returnValue);
272 anchorPointY?.Dispose();
277 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
278 SetProperty(View.Property.AnchorPointY, setValue);
283 internal float PivotPointZ
287 float returnValue = 0.0f;
288 PropertyValue anchorPointZ = GetProperty(View.Property.AnchorPointZ);
289 anchorPointZ?.Get(out returnValue);
290 anchorPointZ?.Dispose();
295 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
296 SetProperty(View.Property.AnchorPointZ, setValue);
301 internal Matrix WorldMatrix
305 Matrix returnValue = new Matrix();
306 PropertyValue wordMatrix = GetProperty(View.Property.WorldMatrix);
307 wordMatrix?.Get(returnValue);
308 wordMatrix?.Dispose();
314 /// Indicates that this View should listen Touch event to handle its ControlState.
316 private bool enableControlState = false;
318 private int LeftFocusableViewId
323 PropertyValue leftFocusableViewId = GetProperty(View.Property.LeftFocusableViewId);
324 leftFocusableViewId?.Get(out returnValue);
325 leftFocusableViewId?.Dispose();
330 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
331 SetProperty(View.Property.LeftFocusableViewId, setValue);
336 private int RightFocusableViewId
341 PropertyValue rightFocusableViewId = GetProperty(View.Property.RightFocusableViewId);
342 rightFocusableViewId?.Get(out returnValue);
343 rightFocusableViewId?.Dispose();
348 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
349 SetProperty(View.Property.RightFocusableViewId, setValue);
354 private int UpFocusableViewId
359 PropertyValue upFocusableViewId = GetProperty(View.Property.UpFocusableViewId);
360 upFocusableViewId?.Get(out returnValue);
361 upFocusableViewId?.Dispose();
366 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
367 SetProperty(View.Property.UpFocusableViewId, setValue);
372 private int DownFocusableViewId
377 PropertyValue downFocusableViewId = GetProperty(View.Property.DownFocusableViewId);
378 downFocusableViewId?.Get(out returnValue);
379 downFocusableViewId?.Dispose();
384 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
385 SetProperty(View.Property.DownFocusableViewId, setValue);
390 internal void Raise()
392 var parentChildren = GetParent()?.Children;
394 if (parentChildren != null)
396 int currentIndex = parentChildren.IndexOf(this);
398 // If the view is not already the last item in the list.
399 if (currentIndex >= 0 && currentIndex < parentChildren.Count - 1)
401 View temp = parentChildren[currentIndex + 1];
402 parentChildren[currentIndex + 1] = this;
403 parentChildren[currentIndex] = temp;
405 Interop.NDalic.Raise(SwigCPtr);
406 if (NDalicPINVOKE.SWIGPendingException.Pending)
407 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
412 internal void Lower()
414 var parentChildren = GetParent()?.Children;
416 if (parentChildren != null)
418 int currentIndex = parentChildren.IndexOf(this);
420 // If the view is not already the first item in the list.
421 if (currentIndex > 0 && currentIndex < parentChildren.Count)
423 View temp = parentChildren[currentIndex - 1];
424 parentChildren[currentIndex - 1] = this;
425 parentChildren[currentIndex] = temp;
427 Interop.NDalic.Lower(SwigCPtr);
428 if (NDalicPINVOKE.SWIGPendingException.Pending)
429 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
435 /// Raises the view to above the target view.
437 /// <remarks>The sibling order of views within the parent will be updated automatically.
438 /// Views on the level above the target view will still be shown above this view.
439 /// Raising this view above views with the same sibling order as each other will raise this view above them.
440 /// Once a raise or lower API is used that view will then have an exclusive sibling order independent of insertion.
442 /// <param name="target">Will be raised above this view.</param>
443 internal void RaiseAbove(View target)
445 var parentChildren = GetParent()?.Children;
447 if (parentChildren != null)
449 int currentIndex = parentChildren.IndexOf(this);
450 int targetIndex = parentChildren.IndexOf(target);
452 if (currentIndex < 0 || targetIndex < 0 ||
453 currentIndex >= parentChildren.Count || targetIndex >= parentChildren.Count)
455 NUILog.Error("index should be bigger than 0 and less than children of layer count");
458 // If the currentIndex is less than the target index and the target has the same parent.
459 if (currentIndex < targetIndex)
461 parentChildren.Remove(this);
462 parentChildren.Insert(targetIndex, this);
464 Interop.NDalic.RaiseAbove(SwigCPtr, View.getCPtr(target));
465 if (NDalicPINVOKE.SWIGPendingException.Pending)
466 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
473 /// Lowers the view to below the target view.
475 /// <remarks>The sibling order of views within the parent will be updated automatically.
476 /// Lowering this view below views with the same sibling order as each other will lower this view above them.
477 /// Once a raise or lower API is used that view will then have an exclusive sibling order independent of insertion.
479 /// <param name="target">Will be lowered below this view.</param>
480 internal void LowerBelow(View target)
482 var parentChildren = GetParent()?.Children;
484 if (parentChildren != null)
486 int currentIndex = parentChildren.IndexOf(this);
487 int targetIndex = parentChildren.IndexOf(target);
488 if (currentIndex < 0 || targetIndex < 0 ||
489 currentIndex >= parentChildren.Count || targetIndex >= parentChildren.Count)
491 NUILog.Error("index should be bigger than 0 and less than children of layer count");
495 // If the currentIndex is not already the 0th index and the target has the same parent.
496 if ((currentIndex != 0) && (targetIndex != -1) &&
497 (currentIndex > targetIndex))
499 parentChildren.Remove(this);
500 parentChildren.Insert(targetIndex, this);
502 Interop.NDalic.LowerBelow(SwigCPtr, View.getCPtr(target));
503 if (NDalicPINVOKE.SWIGPendingException.Pending)
504 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
510 internal string GetName()
512 string ret = Interop.Actor.GetName(SwigCPtr);
513 if (NDalicPINVOKE.SWIGPendingException.Pending)
514 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
518 internal void SetName(string name)
520 Interop.Actor.SetName(SwigCPtr, name);
521 if (NDalicPINVOKE.SWIGPendingException.Pending)
522 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
525 internal uint GetId()
527 uint ret = Interop.Actor.GetId(SwigCPtr);
528 if (NDalicPINVOKE.SWIGPendingException.Pending)
529 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
533 internal bool IsRoot()
535 bool ret = Interop.ActorInternal.IsRoot(SwigCPtr);
536 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
540 internal bool OnWindow()
542 bool ret = Interop.Actor.OnStage(SwigCPtr);
543 if (NDalicPINVOKE.SWIGPendingException.Pending)
544 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
548 internal View FindChildById(uint id)
550 //to fix memory leak issue, match the handle count with native side.
551 IntPtr cPtr = Interop.Actor.FindChildById(SwigCPtr, id);
552 View ret = this.GetInstanceSafely<View>(cPtr);
553 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
557 internal override View FindCurrentChildById(uint id)
559 return FindChildById(id);
562 internal void SetParentOrigin(Vector3 origin)
564 Interop.ActorInternal.SetParentOrigin(SwigCPtr, Vector3.getCPtr(origin));
565 if (NDalicPINVOKE.SWIGPendingException.Pending)
566 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
569 internal Vector3 GetCurrentParentOrigin()
571 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentParentOrigin(SwigCPtr), true);
572 if (NDalicPINVOKE.SWIGPendingException.Pending)
573 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
577 internal void SetAnchorPoint(Vector3 anchorPoint)
579 Interop.Actor.SetAnchorPoint(SwigCPtr, Vector3.getCPtr(anchorPoint));
580 if (NDalicPINVOKE.SWIGPendingException.Pending)
581 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
584 internal Vector3 GetCurrentAnchorPoint()
586 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentAnchorPoint(SwigCPtr), true);
587 if (NDalicPINVOKE.SWIGPendingException.Pending)
588 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
592 internal void SetSize(float width, float height)
594 Interop.ActorInternal.SetSize(SwigCPtr, width, height);
595 if (NDalicPINVOKE.SWIGPendingException.Pending)
596 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
599 internal void SetSize(float width, float height, float depth)
601 Interop.ActorInternal.SetSize(SwigCPtr, width, height, depth);
602 if (NDalicPINVOKE.SWIGPendingException.Pending)
603 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
606 internal void SetSize(Vector2 size)
608 Interop.ActorInternal.SetSizeVector2(SwigCPtr, Vector2.getCPtr(size));
609 if (NDalicPINVOKE.SWIGPendingException.Pending)
610 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
613 internal void SetSize(Vector3 size)
615 Interop.ActorInternal.SetSizeVector3(SwigCPtr, Vector3.getCPtr(size));
616 if (NDalicPINVOKE.SWIGPendingException.Pending)
617 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
620 internal Vector3 GetTargetSize()
622 Vector3 ret = new Vector3(Interop.ActorInternal.GetTargetSize(SwigCPtr), true);
623 if (NDalicPINVOKE.SWIGPendingException.Pending)
624 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
628 internal Size2D GetCurrentSize()
630 Size ret = new Size(Interop.Actor.GetCurrentSize(SwigCPtr), true);
631 if (NDalicPINVOKE.SWIGPendingException.Pending)
632 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
633 Size2D size = new Size2D((int)ret.Width, (int)ret.Height);
638 internal Size2D GetCurrentSizeFloat()
640 Size ret = new Size(Interop.Actor.GetCurrentSize(SwigCPtr), true);
641 if (NDalicPINVOKE.SWIGPendingException.Pending)
642 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
646 internal Vector3 GetNaturalSize()
648 Vector3 ret = new Vector3(Interop.Actor.GetNaturalSize(SwigCPtr), true);
649 if (NDalicPINVOKE.SWIGPendingException.Pending)
650 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
654 internal void SetPosition(float x, float y)
656 Interop.ActorInternal.SetPosition(SwigCPtr, x, y);
657 if (NDalicPINVOKE.SWIGPendingException.Pending)
658 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
661 internal void SetPosition(float x, float y, float z)
663 Interop.ActorInternal.SetPosition(SwigCPtr, x, y, z);
664 if (NDalicPINVOKE.SWIGPendingException.Pending)
665 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
668 internal void SetPosition(Vector3 position)
670 Interop.ActorInternal.SetPosition(SwigCPtr, Vector3.getCPtr(position));
671 if (NDalicPINVOKE.SWIGPendingException.Pending)
672 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
675 internal void SetX(float x)
677 Interop.ActorInternal.SetX(SwigCPtr, x);
678 if (NDalicPINVOKE.SWIGPendingException.Pending)
679 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
682 internal void SetY(float y)
684 Interop.ActorInternal.SetY(SwigCPtr, y);
685 if (NDalicPINVOKE.SWIGPendingException.Pending)
686 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
689 internal void SetZ(float z)
691 Interop.ActorInternal.SetZ(SwigCPtr, z);
692 if (NDalicPINVOKE.SWIGPendingException.Pending)
693 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
696 internal void TranslateBy(Vector3 distance)
698 Interop.ActorInternal.TranslateBy(SwigCPtr, Vector3.getCPtr(distance));
699 if (NDalicPINVOKE.SWIGPendingException.Pending)
700 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
703 internal Position GetCurrentPosition()
705 Position ret = new Position(Interop.Actor.GetCurrentPosition(SwigCPtr), true);
706 if (NDalicPINVOKE.SWIGPendingException.Pending)
707 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
711 internal Vector3 GetCurrentWorldPosition()
713 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentWorldPosition(SwigCPtr), true);
714 if (NDalicPINVOKE.SWIGPendingException.Pending)
715 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
719 internal void SetInheritPosition(bool inherit)
721 Interop.ActorInternal.SetInheritPosition(SwigCPtr, inherit);
722 if (NDalicPINVOKE.SWIGPendingException.Pending)
723 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
726 internal bool IsPositionInherited()
728 bool ret = Interop.ActorInternal.IsPositionInherited(SwigCPtr);
729 if (NDalicPINVOKE.SWIGPendingException.Pending)
730 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
734 internal void SetOrientation(Degree angle, Vector3 axis)
736 Interop.ActorInternal.SetOrientationDegree(SwigCPtr, Degree.getCPtr(angle), Vector3.getCPtr(axis));
737 if (NDalicPINVOKE.SWIGPendingException.Pending)
738 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
741 internal void SetOrientation(Radian angle, Vector3 axis)
743 Interop.ActorInternal.SetOrientationRadian(SwigCPtr, Radian.getCPtr(angle), Vector3.getCPtr(axis));
744 if (NDalicPINVOKE.SWIGPendingException.Pending)
745 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
748 internal void SetOrientation(Rotation orientation)
750 Interop.ActorInternal.SetOrientationQuaternion(SwigCPtr, Rotation.getCPtr(orientation));
751 if (NDalicPINVOKE.SWIGPendingException.Pending)
752 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
755 internal Rotation GetCurrentOrientation()
757 Rotation ret = new Rotation(Interop.ActorInternal.GetCurrentOrientation(SwigCPtr), true);
758 if (NDalicPINVOKE.SWIGPendingException.Pending)
759 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
763 internal void SetInheritOrientation(bool inherit)
765 Interop.ActorInternal.SetInheritOrientation(SwigCPtr, inherit);
766 if (NDalicPINVOKE.SWIGPendingException.Pending)
767 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
770 internal bool IsOrientationInherited()
772 bool ret = Interop.ActorInternal.IsOrientationInherited(SwigCPtr);
773 if (NDalicPINVOKE.SWIGPendingException.Pending)
774 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
778 internal Rotation GetCurrentWorldOrientation()
780 Rotation ret = new Rotation(Interop.ActorInternal.GetCurrentWorldOrientation(SwigCPtr), true);
781 if (NDalicPINVOKE.SWIGPendingException.Pending)
782 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
786 internal void SetScale(float scale)
788 Interop.ActorInternal.SetScale(SwigCPtr, scale);
789 if (NDalicPINVOKE.SWIGPendingException.Pending)
790 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
793 internal void SetScale(float scaleX, float scaleY, float scaleZ)
795 Interop.ActorInternal.SetScale(SwigCPtr, scaleX, scaleY, scaleZ);
796 if (NDalicPINVOKE.SWIGPendingException.Pending)
797 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
800 internal void SetScale(Vector3 scale)
802 Interop.ActorInternal.SetScale(SwigCPtr, Vector3.getCPtr(scale));
803 if (NDalicPINVOKE.SWIGPendingException.Pending)
804 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
807 internal Vector3 GetCurrentScale()
809 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentScale(SwigCPtr), true);
810 if (NDalicPINVOKE.SWIGPendingException.Pending)
811 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
815 internal Vector3 GetCurrentWorldScale()
817 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentWorldScale(SwigCPtr), true);
818 if (NDalicPINVOKE.SWIGPendingException.Pending)
819 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
823 internal void SetInheritScale(bool inherit)
825 Interop.ActorInternal.SetInheritScale(SwigCPtr, inherit);
826 if (NDalicPINVOKE.SWIGPendingException.Pending)
827 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
830 internal bool IsScaleInherited()
832 bool ret = Interop.ActorInternal.IsScaleInherited(SwigCPtr);
833 if (NDalicPINVOKE.SWIGPendingException.Pending)
834 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
838 internal Matrix GetCurrentWorldMatrix()
840 Matrix ret = new Matrix(Interop.ActorInternal.GetCurrentWorldMatrix(SwigCPtr), true);
841 if (NDalicPINVOKE.SWIGPendingException.Pending)
842 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
846 internal void SetVisible(bool visible)
848 Interop.Actor.SetVisible(SwigCPtr, visible);
849 if (NDalicPINVOKE.SWIGPendingException.Pending)
850 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
853 internal bool IsVisible()
855 bool ret = Interop.ActorInternal.IsVisible(SwigCPtr);
856 if (NDalicPINVOKE.SWIGPendingException.Pending)
857 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
861 internal void SetOpacity(float opacity)
863 Interop.ActorInternal.SetOpacity(SwigCPtr, opacity);
864 if (NDalicPINVOKE.SWIGPendingException.Pending)
865 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
868 internal float GetCurrentOpacity()
870 float ret = Interop.ActorInternal.GetCurrentOpacity(SwigCPtr);
871 if (NDalicPINVOKE.SWIGPendingException.Pending)
872 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
876 internal Vector4 GetCurrentColor()
878 Vector4 ret = new Vector4(Interop.ActorInternal.GetCurrentColor(SwigCPtr), true);
879 if (NDalicPINVOKE.SWIGPendingException.Pending)
880 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
883 internal ColorMode GetColorMode()
885 ColorMode ret = (ColorMode)Interop.ActorInternal.GetColorMode(SwigCPtr);
886 if (NDalicPINVOKE.SWIGPendingException.Pending)
887 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
891 internal Vector4 GetCurrentWorldColor()
893 Vector4 ret = new Vector4(Interop.ActorInternal.GetCurrentWorldColor(SwigCPtr), true);
894 if (NDalicPINVOKE.SWIGPendingException.Pending)
895 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
899 internal void SetDrawMode(DrawModeType drawMode)
901 Interop.ActorInternal.SetDrawMode(SwigCPtr, (int)drawMode);
902 if (NDalicPINVOKE.SWIGPendingException.Pending)
903 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
906 internal DrawModeType GetDrawMode()
908 DrawModeType ret = (DrawModeType)Interop.ActorInternal.GetDrawMode(SwigCPtr);
909 if (NDalicPINVOKE.SWIGPendingException.Pending)
910 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
914 internal void SetKeyboardFocusable(bool focusable)
916 Interop.ActorInternal.SetKeyboardFocusable(SwigCPtr, focusable);
917 if (NDalicPINVOKE.SWIGPendingException.Pending)
918 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
921 internal bool IsKeyboardFocusable()
923 bool ret = Interop.ActorInternal.IsKeyboardFocusable(SwigCPtr);
924 if (NDalicPINVOKE.SWIGPendingException.Pending)
925 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
929 internal void SetFocusableInTouch(bool enabled)
931 Interop.ActorInternal.SetFocusableInTouch(SwigCPtr, enabled);
932 if (NDalicPINVOKE.SWIGPendingException.Pending)
933 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
936 internal bool IsFocusableInTouch()
938 bool ret = Interop.ActorInternal.IsFocusableInTouch(SwigCPtr);
939 if (NDalicPINVOKE.SWIGPendingException.Pending)
940 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
944 internal void SetResizePolicy(ResizePolicyType policy, DimensionType dimension)
946 Interop.Actor.SetResizePolicy(SwigCPtr, (int)policy, (int)dimension);
947 if (NDalicPINVOKE.SWIGPendingException.Pending)
948 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
951 internal ResizePolicyType GetResizePolicy(DimensionType dimension)
953 ResizePolicyType ret = (ResizePolicyType)Interop.Actor.GetResizePolicy(SwigCPtr, (int)dimension);
954 if (NDalicPINVOKE.SWIGPendingException.Pending)
955 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
959 internal Vector3 GetSizeModeFactor()
961 Vector3 ret = new Vector3(Interop.Actor.GetSizeModeFactor(SwigCPtr), true);
962 if (NDalicPINVOKE.SWIGPendingException.Pending)
963 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
967 internal void SetMinimumSize(Vector2 size)
969 Interop.ActorInternal.SetMinimumSize(SwigCPtr, Vector2.getCPtr(size));
970 if (NDalicPINVOKE.SWIGPendingException.Pending)
971 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
974 internal Vector2 GetMinimumSize()
976 Vector2 ret = new Vector2(Interop.ActorInternal.GetMinimumSize(SwigCPtr), true);
977 if (NDalicPINVOKE.SWIGPendingException.Pending)
978 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
982 internal void SetMaximumSize(Vector2 size)
984 Interop.ActorInternal.SetMaximumSize(SwigCPtr, Vector2.getCPtr(size));
985 if (NDalicPINVOKE.SWIGPendingException.Pending)
986 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
989 internal Vector2 GetMaximumSize()
991 Vector2 ret = new Vector2(Interop.ActorInternal.GetMaximumSize(SwigCPtr), true);
992 if (NDalicPINVOKE.SWIGPendingException.Pending)
993 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
997 internal int GetHierarchyDepth()
999 int ret = Interop.Actor.GetHierarchyDepth(SwigCPtr);
1000 if (NDalicPINVOKE.SWIGPendingException.Pending)
1001 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1005 internal uint GetRendererCount()
1007 uint ret = Interop.Actor.GetRendererCount(SwigCPtr);
1008 if (NDalicPINVOKE.SWIGPendingException.Pending)
1009 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1013 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(View obj)
1015 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
1018 internal bool IsTopLevelView()
1020 if (GetParent() is Layer)
1027 internal void SetKeyInputFocus()
1029 Interop.ViewInternal.SetKeyInputFocus(SwigCPtr);
1030 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1033 internal void ClearKeyInputFocus()
1035 Interop.ViewInternal.ClearKeyInputFocus(SwigCPtr);
1036 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1039 internal PinchGestureDetector GetPinchGestureDetector()
1041 PinchGestureDetector ret = new PinchGestureDetector(Interop.ViewInternal.GetPinchGestureDetector(SwigCPtr), true);
1042 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1046 internal PanGestureDetector GetPanGestureDetector()
1048 PanGestureDetector ret = new PanGestureDetector(Interop.ViewInternal.GetPanGestureDetector(SwigCPtr), true);
1049 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1053 internal TapGestureDetector GetTapGestureDetector()
1055 TapGestureDetector ret = new TapGestureDetector(Interop.ViewInternal.GetTapGestureDetector(SwigCPtr), true);
1056 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1060 internal LongPressGestureDetector GetLongPressGestureDetector()
1062 LongPressGestureDetector ret = new LongPressGestureDetector(Interop.ViewInternal.GetLongPressGestureDetector(SwigCPtr), true);
1063 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1067 internal IntPtr GetPtrfromView()
1069 return (IntPtr)SwigCPtr;
1072 internal void RemoveChild(View child)
1074 // Do actual child removal
1075 Interop.Actor.Remove(SwigCPtr, View.getCPtr(child));
1076 if (NDalicPINVOKE.SWIGPendingException.Pending)
1077 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1079 Children.Remove(child);
1080 child.InternalParent = null;
1082 RemoveChildBindableObject(child);
1084 if (ChildRemoved != null)
1086 ChildRemovedEventArgs e = new ChildRemovedEventArgs
1090 ChildRemoved(this, e);
1095 /// Removes the layout from this View.
1097 internal void ResetLayout()
1102 internal ResourceLoadingStatusType GetBackgroundResourceStatus()
1104 return (ResourceLoadingStatusType)Interop.View.GetVisualResourceStatus(this.SwigCPtr, Property.BACKGROUND);
1107 /// TODO open as a protected level
1108 internal virtual void ApplyCornerRadius()
1110 if (backgroundExtraData == null) return;
1112 var cornerRadius = backgroundExtraData.CornerRadius == null ? new PropertyValue() : new PropertyValue(backgroundExtraData.CornerRadius);
1114 // Apply to the background visual
1115 PropertyMap backgroundMap = new PropertyMap();
1116 PropertyValue background = Tizen.NUI.Object.GetProperty(SwigCPtr, View.Property.BACKGROUND);
1118 if (background.Get(backgroundMap) && !backgroundMap.Empty())
1120 backgroundMap[Visual.Property.CornerRadius] = cornerRadius;
1121 backgroundMap[Visual.Property.CornerRadiusPolicy] = new PropertyValue((int)backgroundExtraData.CornerRadiusPolicy);
1122 var temp = new PropertyValue(backgroundMap);
1123 Tizen.NUI.Object.SetProperty(SwigCPtr, View.Property.BACKGROUND, temp);
1126 backgroundMap.Dispose();
1127 background.Dispose();
1129 // Apply to the shadow visual
1130 PropertyMap shadowMap = new PropertyMap();
1131 PropertyValue shadow = Tizen.NUI.Object.GetProperty(SwigCPtr, View.Property.SHADOW);
1132 if (shadow.Get(shadowMap) && !shadowMap.Empty())
1134 shadowMap[Visual.Property.CornerRadius] = cornerRadius;
1135 shadowMap[Visual.Property.CornerRadiusPolicy] = new PropertyValue((int)backgroundExtraData.CornerRadiusPolicy);
1136 var temp = new PropertyValue(shadowMap);
1137 Tizen.NUI.Object.SetProperty(SwigCPtr, View.Property.SHADOW, temp);
1140 shadowMap.Dispose();
1142 cornerRadius.Dispose();
1145 /// TODO open as a protected level
1146 internal virtual void ApplyBorderline()
1148 if (backgroundExtraData == null) return;
1150 var borderlineColor = backgroundExtraData.BorderlineColor == null ? new PropertyValue(Color.Black) : new PropertyValue(backgroundExtraData.BorderlineColor);
1152 // Apply to the background visual
1153 PropertyMap backgroundMap = new PropertyMap();
1154 PropertyValue background = Tizen.NUI.Object.GetProperty(SwigCPtr, View.Property.BACKGROUND);
1155 if (background.Get(backgroundMap) && !backgroundMap.Empty())
1157 backgroundMap[Visual.Property.BorderlineWidth] = new PropertyValue(backgroundExtraData.BorderlineWidth);
1158 backgroundMap[Visual.Property.BorderlineColor] = borderlineColor;
1159 backgroundMap[Visual.Property.BorderlineOffset] = new PropertyValue(backgroundExtraData.BorderlineOffset);
1160 var temp = new PropertyValue(backgroundMap);
1161 Tizen.NUI.Object.SetProperty(SwigCPtr, View.Property.BACKGROUND, temp);
1164 backgroundMap.Dispose();
1165 background.Dispose();
1166 borderlineColor.Dispose();
1170 /// Get selector value from the triggerable selector or related property.
1172 internal Selector<T> GetSelector<T>(TriggerableSelector<T> triggerableSelector, NUI.Binding.BindableProperty relatedProperty)
1174 var selector = triggerableSelector?.Get();
1175 if (selector != null)
1180 var value = (T)GetValue(relatedProperty);
1181 return value == null ? null : new Selector<T>(value);
1184 internal void SetThemeApplied()
1186 if (themeData == null) themeData = new ThemeData();
1187 themeData.ThemeApplied = true;
1189 if (ThemeChangeSensitive && !themeData.ListeningThemeChangeEvent)
1191 themeData.ListeningThemeChangeEvent = true;
1192 ThemeManager.ThemeChangedInternal.Add(OnThemeChanged);
1197 /// you can override it to clean-up your own resources.
1199 /// <param name="type">DisposeTypes</param>
1200 /// <since_tizen> 3 </since_tizen>
1201 protected override void Dispose(DisposeTypes type)
1208 //_mergedStyle = null;
1210 if (type == DisposeTypes.Explicit)
1213 //Release your own managed resources here.
1214 //You should release all of your own disposable objects here.
1215 if (themeData != null)
1217 themeData.selectorData?.Reset(this);
1218 if (themeData.ListeningThemeChangeEvent)
1220 ThemeManager.ThemeChangedInternal.Remove(OnThemeChanged);
1223 if(widthConstraint != null)
1225 widthConstraint.Remove();
1226 widthConstraint.Dispose();
1228 if(heightConstraint != null)
1230 heightConstraint.Remove();
1231 heightConstraint.Dispose();
1237 //Release your own unmanaged resources here.
1238 //You should not access any managed member here except static instance.
1239 //because the execution order of Finalizes is non-deterministic.
1241 // equivalent to "if (this != null)". more clear to understand.
1244 DisConnectFromSignals();
1246 foreach (View view in Children)
1248 view.InternalParent = null;
1256 /// This will not be public opened.
1257 [EditorBrowsable(EditorBrowsableState.Never)]
1258 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1260 Interop.View.DeleteView(swigCPtr);
1264 /// The touch event handler for ControlState.
1265 /// Please change ControlState value by touch state if needed.
1267 /// <exception cref="ArgumentNullException"> Thrown when touch is null. </exception>
1268 [EditorBrowsable(EditorBrowsableState.Never)]
1269 protected virtual bool HandleControlStateOnTouch(Touch touch)
1273 throw new global::System.ArgumentNullException(nameof(touch));
1276 switch (touch.GetState(0))
1278 case PointStateType.Down:
1279 ControlState += ControlState.Pressed;
1281 case PointStateType.Interrupted:
1282 case PointStateType.Up:
1283 if (ControlState.Contains(ControlState.Pressed))
1285 ControlState -= ControlState.Pressed;
1294 private void DisConnectFromSignals()
1296 // Save current CPtr.
1297 global::System.Runtime.InteropServices.HandleRef currentCPtr = SwigCPtr;
1299 // Use BaseHandle CPtr as current might have been deleted already in derived classes.
1300 SwigCPtr = GetBaseHandleCPtrHandleRef;
1302 if (onRelayoutEventCallback != null)
1304 ViewSignal signal = this.OnRelayoutSignal();
1305 signal?.Disconnect(onRelayoutEventCallback);
1307 onRelayoutEventCallback = null;
1310 if (offWindowEventCallback != null)
1312 ViewSignal signal = this.OffWindowSignal();
1313 signal?.Disconnect(offWindowEventCallback);
1315 offWindowEventCallback = null;
1318 if (onWindowEventCallback != null)
1320 ViewSignal signal = this.OnWindowSignal();
1321 signal?.Disconnect(onWindowEventCallback);
1323 onWindowEventCallback = null;
1326 if (wheelEventCallback != null)
1328 WheelSignal signal = this.WheelEventSignal();
1329 signal?.Disconnect(wheelEventCallback);
1333 if (WindowWheelEventHandler != null)
1335 NUIApplication.GetDefaultWindow().WheelEvent -= OnWindowWheelEvent;
1338 if (hoverEventCallback != null)
1340 HoverSignal signal = this.HoveredSignal();
1341 signal?.Disconnect(hoverEventCallback);
1345 if (interceptTouchDataCallback != null)
1347 TouchDataSignal signal = this.InterceptTouchSignal();
1348 signal?.Disconnect(interceptTouchDataCallback);
1352 if (touchDataCallback != null)
1354 TouchDataSignal signal = this.TouchSignal();
1355 signal?.Disconnect(touchDataCallback);
1359 if (ResourcesLoadedCallback != null)
1361 ViewSignal signal = this.ResourcesLoadedSignal();
1362 signal?.Disconnect(ResourcesLoadedCallback);
1364 ResourcesLoadedCallback = null;
1367 if (keyCallback != null)
1369 ControlKeySignal signal = this.KeyEventSignal();
1370 signal?.Disconnect(keyCallback);
1374 if (keyInputFocusLostCallback != null)
1376 KeyInputFocusSignal signal = this.KeyInputFocusLostSignal();
1377 signal?.Disconnect(keyInputFocusLostCallback);
1381 if (keyInputFocusGainedCallback != null)
1383 KeyInputFocusSignal signal = this.KeyInputFocusGainedSignal();
1384 signal?.Disconnect(keyInputFocusGainedCallback);
1388 if (backgroundResourceLoadedCallback != null)
1390 ViewSignal signal = this.ResourcesLoadedSignal();
1391 signal?.Disconnect(backgroundResourceLoadedCallback);
1393 backgroundResourceLoadedCallback = null;
1396 if (onWindowSendEventCallback != null)
1398 ViewSignal signal = this.OnWindowSignal();
1399 signal?.Disconnect(onWindowSendEventCallback);
1401 onWindowSendEventCallback = null;
1404 // BaseHandle CPtr is used in Registry and there is danger of deletion if we keep using it here.
1405 // Restore current CPtr.
1406 SwigCPtr = currentCPtr;
1410 /// Apply initial style to the view.
1412 [EditorBrowsable(EditorBrowsableState.Never)]
1413 protected virtual void InitializeStyle(ViewStyle style = null)
1415 var initialStyle = ThemeManager.GetInitialStyleWithoutClone(GetType());
1418 ApplyStyle(initialStyle);
1422 var refinedStyle = style;
1423 if (style.IncludeDefaultStyle)
1425 refinedStyle = initialStyle?.Merge(style);
1430 // Listen theme change event if needs.
1431 if (ThemeManager.PlatformThemeEnabled && initialStyle != null)
1437 private View ConvertIdToView(uint id)
1439 View view = GetParent()?.FindCurrentChildById(id);
1441 //If we can't find the parent's children, find in the top layer.
1444 Container parent = GetParent();
1445 while ((parent is View) && (parent != null))
1447 parent = parent.GetParent();
1448 if (parent is Layer)
1450 view = parent.FindCurrentChildById(id);
1459 private void OnScaleChanged(float x, float y, float z)
1461 Scale = new Vector3(x, y, z);
1464 private void OnBackgroundColorChanged(float r, float g, float b, float a)
1466 BackgroundColor = new Color(r, g, b, a);
1469 private void OnPaddingChanged(ushort start, ushort end, ushort top, ushort bottom)
1471 Padding = new Extents(start, end, top, bottom);
1474 private void OnMarginChanged(ushort start, ushort end, ushort top, ushort bottom)
1476 Margin = new Extents(start, end, top, bottom);
1479 private void OnColorChanged(float r, float g, float b, float a)
1481 Color = new Color(r, g, b, a);
1484 private void OnAnchorPointChanged(float x, float y, float z)
1486 AnchorPoint = new Position(x, y, z);
1489 private void OnCellIndexChanged(float x, float y)
1491 CellIndex = new Vector2(x, y);
1494 private void OnFlexMarginChanged(float x, float y, float z, float w)
1496 FlexMargin = new Vector4(x, y, z, w);
1499 private void OnPaddingEXChanged(ushort start, ushort end, ushort top, ushort bottom)
1501 PaddingEX = new Extents(start, end, top, bottom);
1504 private void OnSizeModeFactorChanged(float x, float y, float z)
1506 SizeModeFactor = new Vector3(x, y, z);
1509 private bool EmptyOnTouch(object target, TouchEventArgs args)
1514 private ViewSelectorData EnsureSelectorData()
1516 if (themeData == null) themeData = new ThemeData();
1518 return themeData.selectorData ?? (themeData.selectorData = new ViewSelectorData());