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)
192 Window.Instance.LayoutController.CreateProcessCallback();
193 this.layout = layout;
194 this.layout?.AttachToOwner(this);
195 this.layout?.RequestLayout();
198 internal void AttachTransitionsToChildren(LayoutTransition transition)
200 // Iterate children, adding the transition unless a transition
201 // for the same condition and property has already been
203 foreach (View view in Children)
205 LayoutTransitionsHelper.AddTransitionForCondition(view.LayoutTransitions, transition.Condition, transition, false);
209 internal float ParentOriginX
213 float returnValue = 0.0f;
214 PropertyValue parentOriginX = GetProperty(View.Property.ParentOriginX);
215 parentOriginX?.Get(out returnValue);
216 parentOriginX?.Dispose();
221 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
222 SetProperty(View.Property.ParentOriginX, setValue);
224 NotifyPropertyChanged();
228 internal float ParentOriginY
232 float returnValue = 0.0f;
233 PropertyValue parentOriginY = GetProperty(View.Property.ParentOriginY);
234 parentOriginY?.Get(out returnValue);
235 parentOriginY?.Dispose();
240 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
241 SetProperty(View.Property.ParentOriginY, setValue);
243 NotifyPropertyChanged();
247 internal float ParentOriginZ
251 float returnValue = 0.0f;
252 PropertyValue parentOriginZ = GetProperty(View.Property.ParentOriginZ);
253 parentOriginZ?.Get(out returnValue);
254 parentOriginZ?.Dispose();
259 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
260 SetProperty(View.Property.ParentOriginZ, setValue);
262 NotifyPropertyChanged();
266 internal float PivotPointX
270 float returnValue = 0.0f;
271 PropertyValue anchorPointX = GetProperty(View.Property.AnchorPointX);
272 anchorPointX?.Get(out returnValue);
273 anchorPointX?.Dispose();
278 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
279 SetProperty(View.Property.AnchorPointX, setValue);
284 internal float PivotPointY
288 float returnValue = 0.0f;
289 PropertyValue anchorPointY = GetProperty(View.Property.AnchorPointY);
290 anchorPointY?.Get(out returnValue);
291 anchorPointY?.Dispose();
296 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
297 SetProperty(View.Property.AnchorPointY, setValue);
302 internal float PivotPointZ
306 float returnValue = 0.0f;
307 PropertyValue anchorPointZ = GetProperty(View.Property.AnchorPointZ);
308 anchorPointZ?.Get(out returnValue);
309 anchorPointZ?.Dispose();
314 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
315 SetProperty(View.Property.AnchorPointZ, setValue);
320 internal Matrix WorldMatrix
324 Matrix returnValue = new Matrix();
325 PropertyValue wordMatrix = GetProperty(View.Property.WorldMatrix);
326 wordMatrix?.Get(returnValue);
327 wordMatrix?.Dispose();
333 /// Indicates that this View should listen Touch event to handle its ControlState.
335 private bool enableControlState = false;
337 private int LeftFocusableViewId
342 PropertyValue leftFocusableViewId = GetProperty(View.Property.LeftFocusableViewId);
343 leftFocusableViewId?.Get(out returnValue);
344 leftFocusableViewId?.Dispose();
349 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
350 SetProperty(View.Property.LeftFocusableViewId, setValue);
355 private int RightFocusableViewId
360 PropertyValue rightFocusableViewId = GetProperty(View.Property.RightFocusableViewId);
361 rightFocusableViewId?.Get(out returnValue);
362 rightFocusableViewId?.Dispose();
367 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
368 SetProperty(View.Property.RightFocusableViewId, setValue);
373 private int UpFocusableViewId
378 PropertyValue upFocusableViewId = GetProperty(View.Property.UpFocusableViewId);
379 upFocusableViewId?.Get(out returnValue);
380 upFocusableViewId?.Dispose();
385 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
386 SetProperty(View.Property.UpFocusableViewId, setValue);
391 private int DownFocusableViewId
396 PropertyValue downFocusableViewId = GetProperty(View.Property.DownFocusableViewId);
397 downFocusableViewId?.Get(out returnValue);
398 downFocusableViewId?.Dispose();
403 PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
404 SetProperty(View.Property.DownFocusableViewId, setValue);
409 internal string GetName()
411 string ret = Interop.Actor.GetName(SwigCPtr);
412 if (NDalicPINVOKE.SWIGPendingException.Pending)
413 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
417 internal void SetName(string name)
419 Interop.Actor.SetName(SwigCPtr, name);
420 if (NDalicPINVOKE.SWIGPendingException.Pending)
421 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
424 internal uint GetId()
426 uint ret = Interop.Actor.GetId(SwigCPtr);
428 //this is temporary debugging code. will be removed in 2 weeks
431 uint errorRet = (uint)minusOne;
432 if (ret == errorRet || SwigCPtr.Handle == IntPtr.Zero)
434 var process = global::System.Diagnostics.Process.GetCurrentProcess().Id;
435 var thread = global::System.Threading.Thread.CurrentThread.ManagedThreadId;
436 var me = this.GetType().FullName;
438 Log.Fatal("NUI", $"Error! GetId error OR swigCPtr.Handle == IntPtr.Zero ! please check! \n" +
439 $" process:{process} thread:{thread}, isDisposed:{this.Disposed}, isDisposeQueued:{this.IsDisposeQueued}, me:{me}\n");
443 if (NDalicPINVOKE.SWIGPendingException.Pending)
444 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
448 internal bool IsRoot()
450 bool ret = Interop.ActorInternal.IsRoot(SwigCPtr);
451 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
455 internal bool OnWindow()
457 bool ret = Interop.Actor.OnStage(SwigCPtr);
458 if (NDalicPINVOKE.SWIGPendingException.Pending)
459 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
463 internal View FindChildById(uint id)
465 //to fix memory leak issue, match the handle count with native side.
466 IntPtr cPtr = Interop.Actor.FindChildById(SwigCPtr, id);
467 View ret = this.GetInstanceSafely<View>(cPtr);
468 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
472 internal override View FindCurrentChildById(uint id)
474 return FindChildById(id);
477 internal void SetParentOrigin(Vector3 origin)
479 Interop.ActorInternal.SetParentOrigin(SwigCPtr, Vector3.getCPtr(origin));
480 if (NDalicPINVOKE.SWIGPendingException.Pending)
481 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
484 internal Vector3 GetCurrentParentOrigin()
486 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentParentOrigin(SwigCPtr), true);
487 if (NDalicPINVOKE.SWIGPendingException.Pending)
488 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
492 internal void SetAnchorPoint(Vector3 anchorPoint)
494 Interop.Actor.SetAnchorPoint(SwigCPtr, Vector3.getCPtr(anchorPoint));
495 if (NDalicPINVOKE.SWIGPendingException.Pending)
496 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
499 internal Vector3 GetCurrentAnchorPoint()
501 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentAnchorPoint(SwigCPtr), true);
502 if (NDalicPINVOKE.SWIGPendingException.Pending)
503 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
507 internal void SetSize(float width, float height)
509 Interop.ActorInternal.SetSize(SwigCPtr, width, height);
510 if (NDalicPINVOKE.SWIGPendingException.Pending)
511 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
514 internal void SetSize(float width, float height, float depth)
516 Interop.ActorInternal.SetSize(SwigCPtr, width, height, depth);
517 if (NDalicPINVOKE.SWIGPendingException.Pending)
518 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
521 internal void SetSize(Vector2 size)
523 Interop.ActorInternal.SetSizeVector2(SwigCPtr, Vector2.getCPtr(size));
524 if (NDalicPINVOKE.SWIGPendingException.Pending)
525 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
528 internal void SetSize(Vector3 size)
530 Interop.ActorInternal.SetSizeVector3(SwigCPtr, Vector3.getCPtr(size));
531 if (NDalicPINVOKE.SWIGPendingException.Pending)
532 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
535 internal Vector3 GetTargetSize()
537 Vector3 ret = new Vector3(Interop.ActorInternal.GetTargetSize(SwigCPtr), true);
538 if (NDalicPINVOKE.SWIGPendingException.Pending)
539 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
543 internal Size2D GetCurrentSize()
545 Size ret = new Size(Interop.Actor.GetCurrentSize(SwigCPtr), true);
546 if (NDalicPINVOKE.SWIGPendingException.Pending)
547 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
548 Size2D size = new Size2D((int)ret.Width, (int)ret.Height);
553 internal Size2D GetCurrentSizeFloat()
555 Size ret = new Size(Interop.Actor.GetCurrentSize(SwigCPtr), true);
556 if (NDalicPINVOKE.SWIGPendingException.Pending)
557 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
561 internal Vector3 GetNaturalSize()
563 Vector3 ret = new Vector3(Interop.Actor.GetNaturalSize(SwigCPtr), true);
564 if (NDalicPINVOKE.SWIGPendingException.Pending)
565 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
569 internal void SetPosition(float x, float y)
571 Interop.ActorInternal.SetPosition(SwigCPtr, x, y);
572 if (NDalicPINVOKE.SWIGPendingException.Pending)
573 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
576 internal void SetPosition(float x, float y, float z)
578 Interop.ActorInternal.SetPosition(SwigCPtr, x, y, z);
579 if (NDalicPINVOKE.SWIGPendingException.Pending)
580 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
583 internal void SetPosition(Vector3 position)
585 Interop.ActorInternal.SetPosition(SwigCPtr, Vector3.getCPtr(position));
586 if (NDalicPINVOKE.SWIGPendingException.Pending)
587 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
590 internal void SetX(float x)
592 Interop.ActorInternal.SetX(SwigCPtr, x);
593 if (NDalicPINVOKE.SWIGPendingException.Pending)
594 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
597 internal void SetY(float y)
599 Interop.ActorInternal.SetY(SwigCPtr, y);
600 if (NDalicPINVOKE.SWIGPendingException.Pending)
601 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
604 internal void SetZ(float z)
606 Interop.ActorInternal.SetZ(SwigCPtr, z);
607 if (NDalicPINVOKE.SWIGPendingException.Pending)
608 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
611 internal void TranslateBy(Vector3 distance)
613 Interop.ActorInternal.TranslateBy(SwigCPtr, Vector3.getCPtr(distance));
614 if (NDalicPINVOKE.SWIGPendingException.Pending)
615 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
618 internal Position GetCurrentPosition()
620 Position ret = new Position(Interop.Actor.GetCurrentPosition(SwigCPtr), true);
621 if (NDalicPINVOKE.SWIGPendingException.Pending)
622 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
626 internal Vector3 GetCurrentWorldPosition()
628 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentWorldPosition(SwigCPtr), true);
629 if (NDalicPINVOKE.SWIGPendingException.Pending)
630 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
634 internal void SetInheritPosition(bool inherit)
636 Interop.ActorInternal.SetInheritPosition(SwigCPtr, inherit);
637 if (NDalicPINVOKE.SWIGPendingException.Pending)
638 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
641 internal bool IsPositionInherited()
643 bool ret = Interop.ActorInternal.IsPositionInherited(SwigCPtr);
644 if (NDalicPINVOKE.SWIGPendingException.Pending)
645 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
649 internal void SetOrientation(Degree angle, Vector3 axis)
651 Interop.ActorInternal.SetOrientationDegree(SwigCPtr, Degree.getCPtr(angle), Vector3.getCPtr(axis));
652 if (NDalicPINVOKE.SWIGPendingException.Pending)
653 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
656 internal void SetOrientation(Radian angle, Vector3 axis)
658 Interop.ActorInternal.SetOrientationRadian(SwigCPtr, Radian.getCPtr(angle), Vector3.getCPtr(axis));
659 if (NDalicPINVOKE.SWIGPendingException.Pending)
660 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
663 internal void SetOrientation(Rotation orientation)
665 Interop.ActorInternal.SetOrientationQuaternion(SwigCPtr, Rotation.getCPtr(orientation));
666 if (NDalicPINVOKE.SWIGPendingException.Pending)
667 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
670 internal Rotation GetCurrentOrientation()
672 Rotation ret = new Rotation(Interop.ActorInternal.GetCurrentOrientation(SwigCPtr), true);
673 if (NDalicPINVOKE.SWIGPendingException.Pending)
674 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
678 internal void SetInheritOrientation(bool inherit)
680 Interop.ActorInternal.SetInheritOrientation(SwigCPtr, inherit);
681 if (NDalicPINVOKE.SWIGPendingException.Pending)
682 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
685 internal bool IsOrientationInherited()
687 bool ret = Interop.ActorInternal.IsOrientationInherited(SwigCPtr);
688 if (NDalicPINVOKE.SWIGPendingException.Pending)
689 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
693 internal Rotation GetCurrentWorldOrientation()
695 Rotation ret = new Rotation(Interop.ActorInternal.GetCurrentWorldOrientation(SwigCPtr), true);
696 if (NDalicPINVOKE.SWIGPendingException.Pending)
697 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
701 internal void SetScale(float scale)
703 Interop.ActorInternal.SetScale(SwigCPtr, scale);
704 if (NDalicPINVOKE.SWIGPendingException.Pending)
705 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
708 internal void SetScale(float scaleX, float scaleY, float scaleZ)
710 Interop.ActorInternal.SetScale(SwigCPtr, scaleX, scaleY, scaleZ);
711 if (NDalicPINVOKE.SWIGPendingException.Pending)
712 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
715 internal void SetScale(Vector3 scale)
717 Interop.ActorInternal.SetScale(SwigCPtr, Vector3.getCPtr(scale));
718 if (NDalicPINVOKE.SWIGPendingException.Pending)
719 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
722 internal Vector3 GetCurrentScale()
724 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentScale(SwigCPtr), true);
725 if (NDalicPINVOKE.SWIGPendingException.Pending)
726 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
730 internal Vector3 GetCurrentWorldScale()
732 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentWorldScale(SwigCPtr), true);
733 if (NDalicPINVOKE.SWIGPendingException.Pending)
734 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
738 internal void SetInheritScale(bool inherit)
740 Interop.ActorInternal.SetInheritScale(SwigCPtr, inherit);
741 if (NDalicPINVOKE.SWIGPendingException.Pending)
742 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
745 internal bool IsScaleInherited()
747 bool ret = Interop.ActorInternal.IsScaleInherited(SwigCPtr);
748 if (NDalicPINVOKE.SWIGPendingException.Pending)
749 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
753 internal Matrix GetCurrentWorldMatrix()
755 Matrix ret = new Matrix(Interop.ActorInternal.GetCurrentWorldMatrix(SwigCPtr), true);
756 if (NDalicPINVOKE.SWIGPendingException.Pending)
757 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
761 internal void SetVisible(bool visible)
763 Interop.Actor.SetVisible(SwigCPtr, visible);
764 if (NDalicPINVOKE.SWIGPendingException.Pending)
765 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
768 internal bool IsVisible()
770 bool ret = Interop.ActorInternal.IsVisible(SwigCPtr);
771 if (NDalicPINVOKE.SWIGPendingException.Pending)
772 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
776 internal void SetOpacity(float opacity)
778 Interop.ActorInternal.SetOpacity(SwigCPtr, opacity);
779 if (NDalicPINVOKE.SWIGPendingException.Pending)
780 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
783 internal float GetCurrentOpacity()
785 float ret = Interop.ActorInternal.GetCurrentOpacity(SwigCPtr);
786 if (NDalicPINVOKE.SWIGPendingException.Pending)
787 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
791 internal Vector4 GetCurrentColor()
793 Vector4 ret = new Vector4(Interop.ActorInternal.GetCurrentColor(SwigCPtr), true);
794 if (NDalicPINVOKE.SWIGPendingException.Pending)
795 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
798 internal ColorMode GetColorMode()
800 ColorMode ret = (ColorMode)Interop.ActorInternal.GetColorMode(SwigCPtr);
801 if (NDalicPINVOKE.SWIGPendingException.Pending)
802 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
806 internal Vector4 GetCurrentWorldColor()
808 Vector4 ret = new Vector4(Interop.ActorInternal.GetCurrentWorldColor(SwigCPtr), true);
809 if (NDalicPINVOKE.SWIGPendingException.Pending)
810 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
814 internal void SetDrawMode(DrawModeType drawMode)
816 Interop.ActorInternal.SetDrawMode(SwigCPtr, (int)drawMode);
817 if (NDalicPINVOKE.SWIGPendingException.Pending)
818 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
821 internal DrawModeType GetDrawMode()
823 DrawModeType ret = (DrawModeType)Interop.ActorInternal.GetDrawMode(SwigCPtr);
824 if (NDalicPINVOKE.SWIGPendingException.Pending)
825 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
829 internal void SetKeyboardFocusable(bool focusable)
831 Interop.ActorInternal.SetKeyboardFocusable(SwigCPtr, focusable);
832 if (NDalicPINVOKE.SWIGPendingException.Pending)
833 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
836 internal bool IsKeyboardFocusable()
838 bool ret = Interop.ActorInternal.IsKeyboardFocusable(SwigCPtr);
839 if (NDalicPINVOKE.SWIGPendingException.Pending)
840 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
844 internal void SetKeyboardFocusableChildren(bool focusable)
846 Interop.ActorInternal.SetKeyboardFocusableChildren(SwigCPtr, focusable);
847 if (NDalicPINVOKE.SWIGPendingException.Pending)
848 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
851 internal bool AreChildrenKeyBoardFocusable()
853 bool ret = Interop.ActorInternal.AreChildrenKeyBoardFocusable(SwigCPtr);
854 if (NDalicPINVOKE.SWIGPendingException.Pending)
855 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
859 internal void SetFocusableInTouch(bool enabled)
861 Interop.ActorInternal.SetFocusableInTouch(SwigCPtr, enabled);
862 if (NDalicPINVOKE.SWIGPendingException.Pending)
863 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
866 internal bool IsFocusableInTouch()
868 bool ret = Interop.ActorInternal.IsFocusableInTouch(SwigCPtr);
869 if (NDalicPINVOKE.SWIGPendingException.Pending)
870 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
874 internal void SetResizePolicy(ResizePolicyType policy, DimensionType dimension)
876 Interop.Actor.SetResizePolicy(SwigCPtr, (int)policy, (int)dimension);
877 if (NDalicPINVOKE.SWIGPendingException.Pending)
878 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
881 internal ResizePolicyType GetResizePolicy(DimensionType dimension)
883 ResizePolicyType ret = (ResizePolicyType)Interop.Actor.GetResizePolicy(SwigCPtr, (int)dimension);
884 if (NDalicPINVOKE.SWIGPendingException.Pending)
885 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
889 internal Vector3 GetSizeModeFactor()
891 Vector3 ret = new Vector3(Interop.Actor.GetSizeModeFactor(SwigCPtr), true);
892 if (NDalicPINVOKE.SWIGPendingException.Pending)
893 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
897 internal void SetMinimumSize(Vector2 size)
899 Interop.ActorInternal.SetMinimumSize(SwigCPtr, Vector2.getCPtr(size));
900 if (NDalicPINVOKE.SWIGPendingException.Pending)
901 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
904 internal Vector2 GetMinimumSize()
906 Vector2 ret = new Vector2(Interop.ActorInternal.GetMinimumSize(SwigCPtr), true);
907 if (NDalicPINVOKE.SWIGPendingException.Pending)
908 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
912 internal void SetMaximumSize(Vector2 size)
914 Interop.ActorInternal.SetMaximumSize(SwigCPtr, Vector2.getCPtr(size));
915 if (NDalicPINVOKE.SWIGPendingException.Pending)
916 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
919 internal Vector2 GetMaximumSize()
921 Vector2 ret = new Vector2(Interop.ActorInternal.GetMaximumSize(SwigCPtr), true);
922 if (NDalicPINVOKE.SWIGPendingException.Pending)
923 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
927 internal int GetHierarchyDepth()
929 int ret = Interop.Actor.GetHierarchyDepth(SwigCPtr);
930 if (NDalicPINVOKE.SWIGPendingException.Pending)
931 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
935 internal uint GetRendererCount()
937 uint ret = Interop.Actor.GetRendererCount(SwigCPtr);
938 if (NDalicPINVOKE.SWIGPendingException.Pending)
939 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
943 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(View obj)
945 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
948 internal bool IsTopLevelView()
950 if (GetParent() is Layer)
957 internal void SetKeyInputFocus()
959 Interop.ViewInternal.SetKeyInputFocus(SwigCPtr);
960 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
963 internal void ClearKeyInputFocus()
965 Interop.ViewInternal.ClearKeyInputFocus(SwigCPtr);
966 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
969 internal PinchGestureDetector GetPinchGestureDetector()
971 PinchGestureDetector ret = new PinchGestureDetector(Interop.ViewInternal.GetPinchGestureDetector(SwigCPtr), true);
972 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
976 internal PanGestureDetector GetPanGestureDetector()
978 PanGestureDetector ret = new PanGestureDetector(Interop.ViewInternal.GetPanGestureDetector(SwigCPtr), true);
979 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
983 internal TapGestureDetector GetTapGestureDetector()
985 TapGestureDetector ret = new TapGestureDetector(Interop.ViewInternal.GetTapGestureDetector(SwigCPtr), true);
986 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
990 internal LongPressGestureDetector GetLongPressGestureDetector()
992 LongPressGestureDetector ret = new LongPressGestureDetector(Interop.ViewInternal.GetLongPressGestureDetector(SwigCPtr), true);
993 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
997 internal IntPtr GetPtrfromView()
999 return (IntPtr)SwigCPtr;
1002 internal void RemoveChild(View child)
1004 // Do actual child removal
1005 Interop.Actor.Remove(SwigCPtr, View.getCPtr(child));
1006 if (NDalicPINVOKE.SWIGPendingException.Pending)
1007 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1009 Children.Remove(child);
1010 child.InternalParent = null;
1012 RemoveChildBindableObject(child);
1014 if (ChildRemoved != null)
1016 ChildRemovedEventArgs e = new ChildRemovedEventArgs
1020 ChildRemoved(this, e);
1025 /// Removes the layout from this View.
1027 internal void ResetLayout()
1032 internal ResourceLoadingStatusType GetBackgroundResourceStatus()
1034 return (ResourceLoadingStatusType)Interop.View.GetVisualResourceStatus(this.SwigCPtr, Property.BACKGROUND);
1037 /// TODO open as a protected level
1038 internal virtual void ApplyCornerRadius()
1040 if (backgroundExtraData == null) return;
1042 var cornerRadius = backgroundExtraData.CornerRadius == null ? new PropertyValue() : new PropertyValue(backgroundExtraData.CornerRadius);
1044 // Apply to the background visual
1045 PropertyMap backgroundMap = new PropertyMap();
1046 PropertyValue background = Tizen.NUI.Object.GetProperty(SwigCPtr, View.Property.BACKGROUND);
1048 if (background.Get(backgroundMap) && !backgroundMap.Empty())
1050 backgroundMap[Visual.Property.CornerRadius] = cornerRadius;
1051 backgroundMap[Visual.Property.CornerRadiusPolicy] = new PropertyValue((int)backgroundExtraData.CornerRadiusPolicy);
1052 var temp = new PropertyValue(backgroundMap);
1053 Tizen.NUI.Object.SetProperty(SwigCPtr, View.Property.BACKGROUND, temp);
1056 backgroundMap.Dispose();
1057 background.Dispose();
1059 // Apply to the shadow visual
1060 PropertyMap shadowMap = new PropertyMap();
1061 PropertyValue shadow = Tizen.NUI.Object.GetProperty(SwigCPtr, View.Property.SHADOW);
1062 if (shadow.Get(shadowMap) && !shadowMap.Empty())
1064 shadowMap[Visual.Property.CornerRadius] = cornerRadius;
1065 shadowMap[Visual.Property.CornerRadiusPolicy] = new PropertyValue((int)backgroundExtraData.CornerRadiusPolicy);
1066 var temp = new PropertyValue(shadowMap);
1067 Tizen.NUI.Object.SetProperty(SwigCPtr, View.Property.SHADOW, temp);
1070 shadowMap.Dispose();
1072 cornerRadius.Dispose();
1075 /// TODO open as a protected level
1076 internal virtual void ApplyBorderline()
1078 if (backgroundExtraData == null) return;
1080 var borderlineColor = backgroundExtraData.BorderlineColor == null ? new PropertyValue(Color.Black) : new PropertyValue(backgroundExtraData.BorderlineColor);
1082 // Apply to the background visual
1083 PropertyMap backgroundMap = new PropertyMap();
1084 PropertyValue background = Tizen.NUI.Object.GetProperty(SwigCPtr, View.Property.BACKGROUND);
1085 if (background.Get(backgroundMap) && !backgroundMap.Empty())
1087 backgroundMap[Visual.Property.BorderlineWidth] = new PropertyValue(backgroundExtraData.BorderlineWidth);
1088 backgroundMap[Visual.Property.BorderlineColor] = borderlineColor;
1089 backgroundMap[Visual.Property.BorderlineOffset] = new PropertyValue(backgroundExtraData.BorderlineOffset);
1090 var temp = new PropertyValue(backgroundMap);
1091 Tizen.NUI.Object.SetProperty(SwigCPtr, View.Property.BACKGROUND, temp);
1094 backgroundMap.Dispose();
1095 background.Dispose();
1096 borderlineColor.Dispose();
1100 /// Get selector value from the triggerable selector or related property.
1102 internal Selector<T> GetSelector<T>(TriggerableSelector<T> triggerableSelector, NUI.Binding.BindableProperty relatedProperty)
1104 var selector = triggerableSelector?.Get();
1105 if (selector != null)
1110 var value = (T)GetValue(relatedProperty);
1111 return value == null ? null : new Selector<T>(value);
1114 internal void SetThemeApplied()
1116 if (themeData == null) themeData = new ThemeData();
1117 themeData.ThemeApplied = true;
1119 if (ThemeChangeSensitive && !themeData.ListeningThemeChangeEvent)
1121 themeData.ListeningThemeChangeEvent = true;
1122 ThemeManager.ThemeChangedInternal.Add(OnThemeChanged);
1127 /// you can override it to clean-up your own resources.
1129 /// <param name="type">DisposeTypes</param>
1130 /// <since_tizen> 3 </since_tizen>
1131 protected override void Dispose(DisposeTypes type)
1138 //_mergedStyle = null;
1140 if (type == DisposeTypes.Explicit)
1143 //Release your own managed resources here.
1144 //You should release all of your own disposable objects here.
1145 if (themeData != null)
1147 themeData.selectorData?.Reset(this);
1148 if (themeData.ListeningThemeChangeEvent)
1150 ThemeManager.ThemeChangedInternal.Remove(OnThemeChanged);
1153 if (widthConstraint != null)
1155 widthConstraint.Remove();
1156 widthConstraint.Dispose();
1158 if (heightConstraint != null)
1160 heightConstraint.Remove();
1161 heightConstraint.Dispose();
1165 //Release your own unmanaged resources here.
1166 //You should not access any managed member here except static instance.
1167 //because the execution order of Finalizes is non-deterministic.
1169 DisConnectFromSignals();
1171 foreach (View view in Children)
1173 view.InternalParent = null;
1179 /// This will not be public opened.
1180 [EditorBrowsable(EditorBrowsableState.Never)]
1181 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1183 Interop.View.DeleteView(swigCPtr);
1187 /// The touch event handler for ControlState.
1188 /// Please change ControlState value by touch state if needed.
1190 /// <exception cref="ArgumentNullException"> Thrown when touch is null. </exception>
1191 [EditorBrowsable(EditorBrowsableState.Never)]
1192 protected virtual bool HandleControlStateOnTouch(Touch touch)
1196 throw new global::System.ArgumentNullException(nameof(touch));
1199 switch (touch.GetState(0))
1201 case PointStateType.Down:
1202 ControlState += ControlState.Pressed;
1204 case PointStateType.Interrupted:
1205 case PointStateType.Up:
1206 if (ControlState.Contains(ControlState.Pressed))
1208 ControlState -= ControlState.Pressed;
1217 private void DisConnectFromSignals()
1219 if (onRelayoutEventCallback != null)
1221 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnRelayoutSignal(GetBaseHandleCPtrHandleRef), false);
1222 signal?.Disconnect(onRelayoutEventCallback);
1223 onRelayoutEventCallback = null;
1226 if (offWindowEventCallback != null)
1228 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOffSceneSignal(GetBaseHandleCPtrHandleRef), false);
1229 signal?.Disconnect(offWindowEventCallback);
1230 offWindowEventCallback = null;
1233 if (onWindowEventCallback != null)
1235 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(GetBaseHandleCPtrHandleRef), false);
1236 signal?.Disconnect(onWindowEventCallback);
1237 onWindowEventCallback = null;
1240 if (wheelEventCallback != null)
1242 using WheelSignal signal = new WheelSignal(Interop.ActorSignal.ActorWheelEventSignal(GetBaseHandleCPtrHandleRef), false);
1243 signal?.Disconnect(wheelEventCallback);
1244 wheelEventCallback = null;
1247 if (WindowWheelEventHandler != null)
1249 NUIApplication.GetDefaultWindow().WheelEvent -= OnWindowWheelEvent;
1250 WindowWheelEventHandler = null;
1253 if (hoverEventCallback != null)
1255 using HoverSignal signal = new HoverSignal(Interop.ActorSignal.ActorHoveredSignal(GetBaseHandleCPtrHandleRef), false);
1256 signal?.Disconnect(hoverEventCallback);
1257 hoverEventCallback = null;
1260 if (interceptTouchDataCallback != null)
1262 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorInterceptTouchSignal(GetBaseHandleCPtrHandleRef), false);
1263 signal?.Disconnect(interceptTouchDataCallback);
1264 interceptTouchDataCallback = null;
1267 if (touchDataCallback != null)
1269 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorTouchSignal(GetBaseHandleCPtrHandleRef), false);
1270 signal?.Disconnect(touchDataCallback);
1271 touchDataCallback = null;
1274 if (ResourcesLoadedCallback != null)
1276 using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(GetBaseHandleCPtrHandleRef), false);
1277 signal?.Disconnect(ResourcesLoadedCallback);
1278 ResourcesLoadedCallback = null;
1281 if (keyCallback != null)
1283 using ControlKeySignal signal = new ControlKeySignal(Interop.ViewSignal.KeyEventSignal(GetBaseHandleCPtrHandleRef), false);
1284 signal?.Disconnect(keyCallback);
1288 if (keyInputFocusLostCallback != null)
1290 using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusLostSignal(GetBaseHandleCPtrHandleRef), false);
1291 signal?.Disconnect(keyInputFocusLostCallback);
1292 keyInputFocusLostCallback = null;
1293 keyInputFocusLostEventHandler = null;
1296 if (keyInputFocusGainedCallback != null)
1298 using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusGainedSignal(GetBaseHandleCPtrHandleRef), false);
1299 signal?.Disconnect(keyInputFocusGainedCallback);
1300 keyInputFocusGainedCallback = null;
1301 keyInputFocusGainedEventHandler = null;
1304 if (backgroundResourceLoadedCallback != null)
1306 using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(GetBaseHandleCPtrHandleRef), false);
1307 signal?.Disconnect(backgroundResourceLoadedCallback);
1308 backgroundResourceLoadedCallback = null;
1311 if (onWindowSendEventCallback != null)
1313 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(GetBaseHandleCPtrHandleRef), false);
1314 signal?.Disconnect(onWindowSendEventCallback);
1315 onWindowSendEventCallback = null;
1320 /// Apply initial style to the view.
1322 [EditorBrowsable(EditorBrowsableState.Never)]
1323 protected virtual void InitializeStyle(ViewStyle style = null)
1325 var initialStyle = ThemeManager.GetInitialStyleWithoutClone(GetType());
1328 ApplyStyle(initialStyle);
1332 var refinedStyle = style;
1333 if (style.IncludeDefaultStyle)
1335 refinedStyle = initialStyle?.Merge(style);
1337 ApplyStyle(refinedStyle);
1340 // Listen theme change event if needs.
1341 if (ThemeManager.PlatformThemeEnabled && initialStyle != null)
1347 private View ConvertIdToView(uint id)
1349 View view = GetParent()?.FindCurrentChildById(id);
1351 //If we can't find the parent's children, find in the top layer.
1354 Container parent = GetParent();
1355 while ((parent is View) && (parent != null))
1357 parent = parent.GetParent();
1358 if (parent is Layer)
1360 view = parent.FindCurrentChildById(id);
1369 private void OnScaleChanged(float x, float y, float z)
1371 Scale = new Vector3(x, y, z);
1374 private void OnBackgroundColorChanged(float r, float g, float b, float a)
1376 BackgroundColor = new Color(r, g, b, a);
1379 private void OnPaddingChanged(ushort start, ushort end, ushort top, ushort bottom)
1381 Padding = new Extents(start, end, top, bottom);
1384 private void OnMarginChanged(ushort start, ushort end, ushort top, ushort bottom)
1386 Margin = new Extents(start, end, top, bottom);
1389 private void OnColorChanged(float r, float g, float b, float a)
1391 Color = new Color(r, g, b, a);
1394 private void OnAnchorPointChanged(float x, float y, float z)
1396 AnchorPoint = new Position(x, y, z);
1399 private void OnCellIndexChanged(float x, float y)
1401 CellIndex = new Vector2(x, y);
1404 private void OnFlexMarginChanged(float x, float y, float z, float w)
1406 FlexMargin = new Vector4(x, y, z, w);
1409 private void OnPaddingEXChanged(ushort start, ushort end, ushort top, ushort bottom)
1411 PaddingEX = new Extents(start, end, top, bottom);
1414 private void OnSizeModeFactorChanged(float x, float y, float z)
1416 SizeModeFactor = new Vector3(x, y, z);
1419 private bool EmptyOnTouch(object target, TouchEventArgs args)
1424 private ViewSelectorData EnsureSelectorData()
1426 if (themeData == null) themeData = new ThemeData();
1428 return themeData.selectorData ?? (themeData.selectorData = new ViewSelectorData());