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);
427 if (NDalicPINVOKE.SWIGPendingException.Pending)
428 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
432 internal bool IsRoot()
434 bool ret = Interop.ActorInternal.IsRoot(SwigCPtr);
435 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
439 internal bool OnWindow()
441 bool ret = Interop.Actor.OnStage(SwigCPtr);
442 if (NDalicPINVOKE.SWIGPendingException.Pending)
443 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
447 internal View FindChildById(uint id)
449 //to fix memory leak issue, match the handle count with native side.
450 IntPtr cPtr = Interop.Actor.FindChildById(SwigCPtr, id);
451 View ret = this.GetInstanceSafely<View>(cPtr);
452 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
456 internal override View FindCurrentChildById(uint id)
458 return FindChildById(id);
461 internal void SetParentOrigin(Vector3 origin)
463 Interop.ActorInternal.SetParentOrigin(SwigCPtr, Vector3.getCPtr(origin));
464 if (NDalicPINVOKE.SWIGPendingException.Pending)
465 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
468 internal Vector3 GetCurrentParentOrigin()
470 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentParentOrigin(SwigCPtr), true);
471 if (NDalicPINVOKE.SWIGPendingException.Pending)
472 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
476 internal void SetAnchorPoint(Vector3 anchorPoint)
478 Interop.Actor.SetAnchorPoint(SwigCPtr, Vector3.getCPtr(anchorPoint));
479 if (NDalicPINVOKE.SWIGPendingException.Pending)
480 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
483 internal Vector3 GetCurrentAnchorPoint()
485 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentAnchorPoint(SwigCPtr), true);
486 if (NDalicPINVOKE.SWIGPendingException.Pending)
487 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
491 internal void SetSize(float width, float height)
493 Interop.ActorInternal.SetSize(SwigCPtr, width, height);
494 if (NDalicPINVOKE.SWIGPendingException.Pending)
495 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
498 internal void SetSize(float width, float height, float depth)
500 Interop.ActorInternal.SetSize(SwigCPtr, width, height, depth);
501 if (NDalicPINVOKE.SWIGPendingException.Pending)
502 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
505 internal void SetSize(Vector2 size)
507 Interop.ActorInternal.SetSizeVector2(SwigCPtr, Vector2.getCPtr(size));
508 if (NDalicPINVOKE.SWIGPendingException.Pending)
509 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
512 internal void SetSize(Vector3 size)
514 Interop.ActorInternal.SetSizeVector3(SwigCPtr, Vector3.getCPtr(size));
515 if (NDalicPINVOKE.SWIGPendingException.Pending)
516 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
519 internal Vector3 GetTargetSize()
521 Vector3 ret = new Vector3(Interop.ActorInternal.GetTargetSize(SwigCPtr), true);
522 if (NDalicPINVOKE.SWIGPendingException.Pending)
523 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
527 internal Size2D GetCurrentSize()
529 Size ret = new Size(Interop.Actor.GetCurrentSize(SwigCPtr), true);
530 if (NDalicPINVOKE.SWIGPendingException.Pending)
531 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
532 Size2D size = new Size2D((int)ret.Width, (int)ret.Height);
537 internal Size2D GetCurrentSizeFloat()
539 Size ret = new Size(Interop.Actor.GetCurrentSize(SwigCPtr), true);
540 if (NDalicPINVOKE.SWIGPendingException.Pending)
541 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
545 internal Vector3 GetNaturalSize()
547 Vector3 ret = new Vector3(Interop.Actor.GetNaturalSize(SwigCPtr), true);
548 if (NDalicPINVOKE.SWIGPendingException.Pending)
549 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
553 internal void SetPosition(float x, float y)
555 Interop.ActorInternal.SetPosition(SwigCPtr, x, y);
556 if (NDalicPINVOKE.SWIGPendingException.Pending)
557 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
560 internal void SetPosition(float x, float y, float z)
562 Interop.ActorInternal.SetPosition(SwigCPtr, x, y, z);
563 if (NDalicPINVOKE.SWIGPendingException.Pending)
564 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
567 internal void SetPosition(Vector3 position)
569 Interop.ActorInternal.SetPosition(SwigCPtr, Vector3.getCPtr(position));
570 if (NDalicPINVOKE.SWIGPendingException.Pending)
571 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
574 internal void SetX(float x)
576 Interop.ActorInternal.SetX(SwigCPtr, x);
577 if (NDalicPINVOKE.SWIGPendingException.Pending)
578 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
581 internal void SetY(float y)
583 Interop.ActorInternal.SetY(SwigCPtr, y);
584 if (NDalicPINVOKE.SWIGPendingException.Pending)
585 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
588 internal void SetZ(float z)
590 Interop.ActorInternal.SetZ(SwigCPtr, z);
591 if (NDalicPINVOKE.SWIGPendingException.Pending)
592 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
595 internal void TranslateBy(Vector3 distance)
597 Interop.ActorInternal.TranslateBy(SwigCPtr, Vector3.getCPtr(distance));
598 if (NDalicPINVOKE.SWIGPendingException.Pending)
599 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
602 internal Position GetCurrentPosition()
604 Position ret = new Position(Interop.Actor.GetCurrentPosition(SwigCPtr), true);
605 if (NDalicPINVOKE.SWIGPendingException.Pending)
606 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
610 internal Vector3 GetCurrentWorldPosition()
612 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentWorldPosition(SwigCPtr), true);
613 if (NDalicPINVOKE.SWIGPendingException.Pending)
614 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
618 internal void SetInheritPosition(bool inherit)
620 Interop.ActorInternal.SetInheritPosition(SwigCPtr, inherit);
621 if (NDalicPINVOKE.SWIGPendingException.Pending)
622 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
625 internal bool IsPositionInherited()
627 bool ret = Interop.ActorInternal.IsPositionInherited(SwigCPtr);
628 if (NDalicPINVOKE.SWIGPendingException.Pending)
629 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
633 internal void SetOrientation(Degree angle, Vector3 axis)
635 Interop.ActorInternal.SetOrientationDegree(SwigCPtr, Degree.getCPtr(angle), Vector3.getCPtr(axis));
636 if (NDalicPINVOKE.SWIGPendingException.Pending)
637 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
640 internal void SetOrientation(Radian angle, Vector3 axis)
642 Interop.ActorInternal.SetOrientationRadian(SwigCPtr, Radian.getCPtr(angle), Vector3.getCPtr(axis));
643 if (NDalicPINVOKE.SWIGPendingException.Pending)
644 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
647 internal void SetOrientation(Rotation orientation)
649 Interop.ActorInternal.SetOrientationQuaternion(SwigCPtr, Rotation.getCPtr(orientation));
650 if (NDalicPINVOKE.SWIGPendingException.Pending)
651 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
654 internal Rotation GetCurrentOrientation()
656 Rotation ret = new Rotation(Interop.ActorInternal.GetCurrentOrientation(SwigCPtr), true);
657 if (NDalicPINVOKE.SWIGPendingException.Pending)
658 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
662 internal void SetInheritOrientation(bool inherit)
664 Interop.ActorInternal.SetInheritOrientation(SwigCPtr, inherit);
665 if (NDalicPINVOKE.SWIGPendingException.Pending)
666 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
669 internal bool IsOrientationInherited()
671 bool ret = Interop.ActorInternal.IsOrientationInherited(SwigCPtr);
672 if (NDalicPINVOKE.SWIGPendingException.Pending)
673 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
677 internal Rotation GetCurrentWorldOrientation()
679 Rotation ret = new Rotation(Interop.ActorInternal.GetCurrentWorldOrientation(SwigCPtr), true);
680 if (NDalicPINVOKE.SWIGPendingException.Pending)
681 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
685 internal void SetScale(float scale)
687 Interop.ActorInternal.SetScale(SwigCPtr, scale);
688 if (NDalicPINVOKE.SWIGPendingException.Pending)
689 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
692 internal void SetScale(float scaleX, float scaleY, float scaleZ)
694 Interop.ActorInternal.SetScale(SwigCPtr, scaleX, scaleY, scaleZ);
695 if (NDalicPINVOKE.SWIGPendingException.Pending)
696 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
699 internal void SetScale(Vector3 scale)
701 Interop.ActorInternal.SetScale(SwigCPtr, Vector3.getCPtr(scale));
702 if (NDalicPINVOKE.SWIGPendingException.Pending)
703 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
706 internal Vector3 GetCurrentScale()
708 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentScale(SwigCPtr), true);
709 if (NDalicPINVOKE.SWIGPendingException.Pending)
710 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
714 internal Vector3 GetCurrentWorldScale()
716 Vector3 ret = new Vector3(Interop.ActorInternal.GetCurrentWorldScale(SwigCPtr), true);
717 if (NDalicPINVOKE.SWIGPendingException.Pending)
718 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
722 internal void SetInheritScale(bool inherit)
724 Interop.ActorInternal.SetInheritScale(SwigCPtr, inherit);
725 if (NDalicPINVOKE.SWIGPendingException.Pending)
726 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
729 internal bool IsScaleInherited()
731 bool ret = Interop.ActorInternal.IsScaleInherited(SwigCPtr);
732 if (NDalicPINVOKE.SWIGPendingException.Pending)
733 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
737 internal Matrix GetCurrentWorldMatrix()
739 Matrix ret = new Matrix(Interop.ActorInternal.GetCurrentWorldMatrix(SwigCPtr), true);
740 if (NDalicPINVOKE.SWIGPendingException.Pending)
741 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
745 internal void SetVisible(bool visible)
747 Interop.Actor.SetVisible(SwigCPtr, visible);
748 if (NDalicPINVOKE.SWIGPendingException.Pending)
749 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
752 internal bool IsVisible()
754 bool ret = Interop.ActorInternal.IsVisible(SwigCPtr);
755 if (NDalicPINVOKE.SWIGPendingException.Pending)
756 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
760 internal void SetOpacity(float opacity)
762 Interop.ActorInternal.SetOpacity(SwigCPtr, opacity);
763 if (NDalicPINVOKE.SWIGPendingException.Pending)
764 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
767 internal float GetCurrentOpacity()
769 float ret = Interop.ActorInternal.GetCurrentOpacity(SwigCPtr);
770 if (NDalicPINVOKE.SWIGPendingException.Pending)
771 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
775 internal Vector4 GetCurrentColor()
777 Vector4 ret = new Vector4(Interop.ActorInternal.GetCurrentColor(SwigCPtr), true);
778 if (NDalicPINVOKE.SWIGPendingException.Pending)
779 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
782 internal ColorMode GetColorMode()
784 ColorMode ret = (ColorMode)Interop.ActorInternal.GetColorMode(SwigCPtr);
785 if (NDalicPINVOKE.SWIGPendingException.Pending)
786 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
790 internal Vector4 GetCurrentWorldColor()
792 Vector4 ret = new Vector4(Interop.ActorInternal.GetCurrentWorldColor(SwigCPtr), true);
793 if (NDalicPINVOKE.SWIGPendingException.Pending)
794 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
798 internal void SetDrawMode(DrawModeType drawMode)
800 Interop.ActorInternal.SetDrawMode(SwigCPtr, (int)drawMode);
801 if (NDalicPINVOKE.SWIGPendingException.Pending)
802 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
805 internal DrawModeType GetDrawMode()
807 DrawModeType ret = (DrawModeType)Interop.ActorInternal.GetDrawMode(SwigCPtr);
808 if (NDalicPINVOKE.SWIGPendingException.Pending)
809 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
813 internal void SetKeyboardFocusable(bool focusable)
815 Interop.ActorInternal.SetKeyboardFocusable(SwigCPtr, focusable);
816 if (NDalicPINVOKE.SWIGPendingException.Pending)
817 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
820 internal bool IsKeyboardFocusable()
822 bool ret = Interop.ActorInternal.IsKeyboardFocusable(SwigCPtr);
823 if (NDalicPINVOKE.SWIGPendingException.Pending)
824 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
828 internal void SetKeyboardFocusableChildren(bool focusable)
830 Interop.ActorInternal.SetKeyboardFocusableChildren(SwigCPtr, focusable);
831 if (NDalicPINVOKE.SWIGPendingException.Pending)
832 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
835 internal bool AreChildrenKeyBoardFocusable()
837 bool ret = Interop.ActorInternal.AreChildrenKeyBoardFocusable(SwigCPtr);
838 if (NDalicPINVOKE.SWIGPendingException.Pending)
839 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
843 internal void SetFocusableInTouch(bool enabled)
845 Interop.ActorInternal.SetFocusableInTouch(SwigCPtr, enabled);
846 if (NDalicPINVOKE.SWIGPendingException.Pending)
847 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
850 internal bool IsFocusableInTouch()
852 bool ret = Interop.ActorInternal.IsFocusableInTouch(SwigCPtr);
853 if (NDalicPINVOKE.SWIGPendingException.Pending)
854 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
858 internal void SetResizePolicy(ResizePolicyType policy, DimensionType dimension)
860 Interop.Actor.SetResizePolicy(SwigCPtr, (int)policy, (int)dimension);
861 if (NDalicPINVOKE.SWIGPendingException.Pending)
862 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
865 internal ResizePolicyType GetResizePolicy(DimensionType dimension)
867 ResizePolicyType ret = (ResizePolicyType)Interop.Actor.GetResizePolicy(SwigCPtr, (int)dimension);
868 if (NDalicPINVOKE.SWIGPendingException.Pending)
869 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
873 internal Vector3 GetSizeModeFactor()
875 Vector3 ret = new Vector3(Interop.Actor.GetSizeModeFactor(SwigCPtr), true);
876 if (NDalicPINVOKE.SWIGPendingException.Pending)
877 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
881 internal void SetMinimumSize(Vector2 size)
883 Interop.ActorInternal.SetMinimumSize(SwigCPtr, Vector2.getCPtr(size));
884 if (NDalicPINVOKE.SWIGPendingException.Pending)
885 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
888 internal Vector2 GetMinimumSize()
890 Vector2 ret = new Vector2(Interop.ActorInternal.GetMinimumSize(SwigCPtr), true);
891 if (NDalicPINVOKE.SWIGPendingException.Pending)
892 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
896 internal void SetMaximumSize(Vector2 size)
898 Interop.ActorInternal.SetMaximumSize(SwigCPtr, Vector2.getCPtr(size));
899 if (NDalicPINVOKE.SWIGPendingException.Pending)
900 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
903 internal Vector2 GetMaximumSize()
905 Vector2 ret = new Vector2(Interop.ActorInternal.GetMaximumSize(SwigCPtr), true);
906 if (NDalicPINVOKE.SWIGPendingException.Pending)
907 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
911 internal int GetHierarchyDepth()
913 int ret = Interop.Actor.GetHierarchyDepth(SwigCPtr);
914 if (NDalicPINVOKE.SWIGPendingException.Pending)
915 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
919 internal uint GetRendererCount()
921 uint ret = Interop.Actor.GetRendererCount(SwigCPtr);
922 if (NDalicPINVOKE.SWIGPendingException.Pending)
923 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
927 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(View obj)
929 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
932 internal bool IsTopLevelView()
934 if (GetParent() is Layer)
941 internal void SetKeyInputFocus()
943 Interop.ViewInternal.SetKeyInputFocus(SwigCPtr);
944 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
947 internal void ClearKeyInputFocus()
949 Interop.ViewInternal.ClearKeyInputFocus(SwigCPtr);
950 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
953 internal PinchGestureDetector GetPinchGestureDetector()
955 PinchGestureDetector ret = new PinchGestureDetector(Interop.ViewInternal.GetPinchGestureDetector(SwigCPtr), true);
956 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
960 internal PanGestureDetector GetPanGestureDetector()
962 PanGestureDetector ret = new PanGestureDetector(Interop.ViewInternal.GetPanGestureDetector(SwigCPtr), true);
963 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
967 internal TapGestureDetector GetTapGestureDetector()
969 TapGestureDetector ret = new TapGestureDetector(Interop.ViewInternal.GetTapGestureDetector(SwigCPtr), true);
970 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
974 internal LongPressGestureDetector GetLongPressGestureDetector()
976 LongPressGestureDetector ret = new LongPressGestureDetector(Interop.ViewInternal.GetLongPressGestureDetector(SwigCPtr), true);
977 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
981 internal IntPtr GetPtrfromView()
983 return (IntPtr)SwigCPtr;
986 internal void RemoveChild(View child)
988 // Do actual child removal
989 Interop.Actor.Remove(SwigCPtr, View.getCPtr(child));
990 if (NDalicPINVOKE.SWIGPendingException.Pending)
991 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
993 Children.Remove(child);
994 child.InternalParent = null;
996 RemoveChildBindableObject(child);
998 if (ChildRemoved != null)
1000 ChildRemovedEventArgs e = new ChildRemovedEventArgs
1004 ChildRemoved(this, e);
1009 /// Removes the layout from this View.
1011 internal void ResetLayout()
1016 internal ResourceLoadingStatusType GetBackgroundResourceStatus()
1018 return (ResourceLoadingStatusType)Interop.View.GetVisualResourceStatus(this.SwigCPtr, Property.BACKGROUND);
1021 /// TODO open as a protected level
1022 internal virtual void ApplyCornerRadius()
1024 if (backgroundExtraData == null) return;
1026 var cornerRadius = backgroundExtraData.CornerRadius == null ? new PropertyValue() : new PropertyValue(backgroundExtraData.CornerRadius);
1028 // Apply to the background visual
1029 PropertyMap backgroundMap = new PropertyMap();
1030 PropertyValue background = Tizen.NUI.Object.GetProperty(SwigCPtr, View.Property.BACKGROUND);
1032 if (background.Get(backgroundMap) && !backgroundMap.Empty())
1034 backgroundMap[Visual.Property.CornerRadius] = cornerRadius;
1035 backgroundMap[Visual.Property.CornerRadiusPolicy] = new PropertyValue((int)backgroundExtraData.CornerRadiusPolicy);
1036 var temp = new PropertyValue(backgroundMap);
1037 Tizen.NUI.Object.SetProperty(SwigCPtr, View.Property.BACKGROUND, temp);
1040 backgroundMap.Dispose();
1041 background.Dispose();
1043 // Apply to the shadow visual
1044 PropertyMap shadowMap = new PropertyMap();
1045 PropertyValue shadow = Tizen.NUI.Object.GetProperty(SwigCPtr, View.Property.SHADOW);
1046 if (shadow.Get(shadowMap) && !shadowMap.Empty())
1048 shadowMap[Visual.Property.CornerRadius] = cornerRadius;
1049 shadowMap[Visual.Property.CornerRadiusPolicy] = new PropertyValue((int)backgroundExtraData.CornerRadiusPolicy);
1050 var temp = new PropertyValue(shadowMap);
1051 Tizen.NUI.Object.SetProperty(SwigCPtr, View.Property.SHADOW, temp);
1054 shadowMap.Dispose();
1056 cornerRadius.Dispose();
1059 /// TODO open as a protected level
1060 internal virtual void ApplyBorderline()
1062 if (backgroundExtraData == null) return;
1064 var borderlineColor = backgroundExtraData.BorderlineColor == null ? new PropertyValue(Color.Black) : new PropertyValue(backgroundExtraData.BorderlineColor);
1066 // Apply to the background visual
1067 PropertyMap backgroundMap = new PropertyMap();
1068 PropertyValue background = Tizen.NUI.Object.GetProperty(SwigCPtr, View.Property.BACKGROUND);
1069 if (background.Get(backgroundMap) && !backgroundMap.Empty())
1071 backgroundMap[Visual.Property.BorderlineWidth] = new PropertyValue(backgroundExtraData.BorderlineWidth);
1072 backgroundMap[Visual.Property.BorderlineColor] = borderlineColor;
1073 backgroundMap[Visual.Property.BorderlineOffset] = new PropertyValue(backgroundExtraData.BorderlineOffset);
1074 var temp = new PropertyValue(backgroundMap);
1075 Tizen.NUI.Object.SetProperty(SwigCPtr, View.Property.BACKGROUND, temp);
1078 backgroundMap.Dispose();
1079 background.Dispose();
1080 borderlineColor.Dispose();
1084 /// Get selector value from the triggerable selector or related property.
1086 internal Selector<T> GetSelector<T>(TriggerableSelector<T> triggerableSelector, NUI.Binding.BindableProperty relatedProperty)
1088 var selector = triggerableSelector?.Get();
1089 if (selector != null)
1094 var value = (T)GetValue(relatedProperty);
1095 return value == null ? null : new Selector<T>(value);
1098 internal void SetThemeApplied()
1100 if (themeData == null) themeData = new ThemeData();
1101 themeData.ThemeApplied = true;
1103 if (ThemeChangeSensitive && !themeData.ListeningThemeChangeEvent)
1105 themeData.ListeningThemeChangeEvent = true;
1106 ThemeManager.ThemeChangedInternal.Add(OnThemeChanged);
1111 /// you can override it to clean-up your own resources.
1113 /// <param name="type">DisposeTypes</param>
1114 /// <since_tizen> 3 </since_tizen>
1115 protected override void Dispose(DisposeTypes type)
1123 NUILog.Debug($"[Dispose] View.Dispose({type}) START");
1124 NUILog.Debug($"[Dispose] type:{GetType()} copyNativeHandle:{GetBaseHandleCPtrHandleRef.Handle.ToString("X8")}");
1127 NUILog.Debug($"[Dispose] ID:{Interop.Actor.GetId(GetBaseHandleCPtrHandleRef)} Name:{Interop.Actor.GetName(GetBaseHandleCPtrHandleRef)}");
1131 NUILog.Debug($"has no native body!");
1136 //_mergedStyle = null;
1138 internalMaximumSize?.Dispose();
1139 internalMaximumSize = null;
1140 internalMinimumSize?.Dispose();
1141 internalMinimumSize = null;
1142 internalMargin?.Dispose();
1143 internalMargin = null;
1144 internalPadding?.Dispose();
1145 internalPadding = null;
1146 internalSizeModeFactor?.Dispose();
1147 internalSizeModeFactor = null;
1148 internalCellIndex?.Dispose();
1149 internalCellIndex = null;
1150 internalBackgroundColor?.Dispose();
1151 internalBackgroundColor = null;
1152 internalColor?.Dispose();
1153 internalColor = null;
1154 internalPivotPoint?.Dispose();
1155 internalPivotPoint = null;
1156 internalPosition?.Dispose();
1157 internalPosition = null;
1158 internalPosition2D?.Dispose();
1159 internalPosition2D = null;
1160 internalScale?.Dispose();
1161 internalScale = null;
1162 internalSize?.Dispose();
1163 internalSize = null;
1164 internalSize2D?.Dispose();
1165 internalSize2D = null;
1167 if (type == DisposeTypes.Explicit)
1170 //Release your own managed resources here.
1171 //You should release all of your own disposable objects here.
1172 if (themeData != null)
1174 themeData.selectorData?.Reset(this);
1175 if (themeData.ListeningThemeChangeEvent)
1177 ThemeManager.ThemeChangedInternal.Remove(OnThemeChanged);
1180 if(widthConstraint != null)
1182 widthConstraint.Remove();
1183 widthConstraint.Dispose();
1185 if(heightConstraint != null)
1187 heightConstraint.Remove();
1188 heightConstraint.Dispose();
1192 //Release your own unmanaged resources here.
1193 //You should not access any managed member here except static instance.
1194 //because the execution order of Finalizes is non-deterministic.
1196 DisConnectFromSignals();
1198 foreach (View view in Children)
1200 view.InternalParent = null;
1203 NUILog.Debug($"[Dispose] View.Dispose({type}) END");
1204 NUILog.Debug($"=============================");
1209 /// This will not be public opened.
1210 [EditorBrowsable(EditorBrowsableState.Never)]
1211 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1213 Interop.View.DeleteView(swigCPtr);
1217 /// The touch event handler for ControlState.
1218 /// Please change ControlState value by touch state if needed.
1220 /// <exception cref="ArgumentNullException"> Thrown when touch is null. </exception>
1221 [EditorBrowsable(EditorBrowsableState.Never)]
1222 protected virtual bool HandleControlStateOnTouch(Touch touch)
1226 throw new global::System.ArgumentNullException(nameof(touch));
1229 switch (touch.GetState(0))
1231 case PointStateType.Down:
1232 ControlState += ControlState.Pressed;
1234 case PointStateType.Interrupted:
1235 case PointStateType.Up:
1236 if (ControlState.Contains(ControlState.Pressed))
1238 ControlState -= ControlState.Pressed;
1247 private void DisConnectFromSignals()
1249 if (HasBody() == false)
1251 NUILog.Debug($"[Dispose] DisConnectFromSignals() No native body! No need to Disconnect Signals!");
1254 NUILog.Debug($"[Dispose] DisConnectFromSignals START");
1255 NUILog.Debug($"[Dispose] View.DisConnectFromSignals() type:{GetType()} copyNativeHandle:{GetBaseHandleCPtrHandleRef.Handle.ToString("X8")}");
1256 NUILog.Debug($"[Dispose] ID:{Interop.Actor.GetId(GetBaseHandleCPtrHandleRef)} Name:{Interop.Actor.GetName(GetBaseHandleCPtrHandleRef)}");
1258 if (onRelayoutEventCallback != null)
1260 NUILog.Debug($"[Dispose] onRelayoutEventCallback");
1262 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnRelayoutSignal(GetBaseHandleCPtrHandleRef), false);
1263 signal?.Disconnect(onRelayoutEventCallback);
1264 onRelayoutEventCallback = null;
1267 if (offWindowEventCallback != null)
1269 NUILog.Debug($"[Dispose] offWindowEventCallback");
1271 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOffSceneSignal(GetBaseHandleCPtrHandleRef), false);
1272 signal?.Disconnect(offWindowEventCallback);
1273 offWindowEventCallback = null;
1276 if (onWindowEventCallback != null)
1278 NUILog.Debug($"[Dispose] onWindowEventCallback");
1280 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(GetBaseHandleCPtrHandleRef), false);
1281 signal?.Disconnect(onWindowEventCallback);
1282 onWindowEventCallback = null;
1285 if (wheelEventCallback != null)
1287 NUILog.Debug($"[Dispose] wheelEventCallback");
1289 using WheelSignal signal = new WheelSignal(Interop.ActorSignal.ActorWheelEventSignal(GetBaseHandleCPtrHandleRef), false);
1290 signal?.Disconnect(wheelEventCallback);
1291 wheelEventCallback = null;
1294 if (WindowWheelEventHandler != null)
1296 NUILog.Debug($"[Dispose] WindowWheelEventHandler");
1298 NUIApplication.GetDefaultWindow().WheelEvent -= OnWindowWheelEvent;
1299 WindowWheelEventHandler = null;
1302 if (hoverEventCallback != null)
1304 NUILog.Debug($"[Dispose] hoverEventCallback");
1306 using HoverSignal signal = new HoverSignal(Interop.ActorSignal.ActorHoveredSignal(GetBaseHandleCPtrHandleRef), false);
1307 signal?.Disconnect(hoverEventCallback);
1308 hoverEventCallback = null;
1311 if (interceptTouchDataCallback != null)
1313 NUILog.Debug($"[Dispose] interceptTouchDataCallback");
1315 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorInterceptTouchSignal(GetBaseHandleCPtrHandleRef), false);
1316 signal?.Disconnect(interceptTouchDataCallback);
1317 interceptTouchDataCallback = null;
1320 if (touchDataCallback != null)
1322 NUILog.Debug($"[Dispose] touchDataCallback");
1324 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorTouchSignal(GetBaseHandleCPtrHandleRef), false);
1325 signal?.Disconnect(touchDataCallback);
1326 touchDataCallback = null;
1329 if (ResourcesLoadedCallback != null)
1331 NUILog.Debug($"[Dispose] ResourcesLoadedCallback");
1333 using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(GetBaseHandleCPtrHandleRef), false);
1334 signal?.Disconnect(ResourcesLoadedCallback);
1335 ResourcesLoadedCallback = null;
1338 if (keyCallback != null)
1340 NUILog.Debug($"[Dispose] keyCallback");
1342 using ControlKeySignal signal = new ControlKeySignal(Interop.ViewSignal.KeyEventSignal(GetBaseHandleCPtrHandleRef), false);
1343 signal?.Disconnect(keyCallback);
1347 if (keyInputFocusLostCallback != null)
1349 NUILog.Debug($"[Dispose] keyInputFocusLostCallback");
1351 using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusLostSignal(GetBaseHandleCPtrHandleRef), false);
1352 signal?.Disconnect(keyInputFocusLostCallback);
1353 keyInputFocusLostCallback = null;
1356 if (keyInputFocusGainedCallback != null)
1358 NUILog.Debug($"[Dispose] keyInputFocusGainedCallback");
1360 using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusGainedSignal(GetBaseHandleCPtrHandleRef), false);
1361 signal?.Disconnect(keyInputFocusGainedCallback);
1362 keyInputFocusGainedCallback = null;
1365 if (backgroundResourceLoadedCallback != null)
1367 NUILog.Debug($"[Dispose] backgroundResourceLoadedCallback");
1369 using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(GetBaseHandleCPtrHandleRef), false);
1370 signal?.Disconnect(backgroundResourceLoadedCallback);
1371 backgroundResourceLoadedCallback = null;
1374 if (onWindowSendEventCallback != null)
1376 NUILog.Debug($"[Dispose] onWindowSendEventCallback");
1378 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(GetBaseHandleCPtrHandleRef), false);
1379 signal?.Disconnect(onWindowSendEventCallback);
1380 onWindowSendEventCallback = null;
1382 NUILog.Debug($"[Dispose] DisConnectFromSignals END");
1386 /// Apply initial style to the view.
1388 [EditorBrowsable(EditorBrowsableState.Never)]
1389 protected virtual void InitializeStyle(ViewStyle style = null)
1391 var initialStyle = ThemeManager.GetInitialStyleWithoutClone(GetType());
1394 ApplyStyle(initialStyle);
1398 var refinedStyle = style;
1399 if (style.IncludeDefaultStyle)
1401 refinedStyle = initialStyle?.Merge(style);
1403 ApplyStyle(refinedStyle);
1406 // Listen theme change event if needs.
1407 if (ThemeManager.PlatformThemeEnabled && initialStyle != null)
1413 private View ConvertIdToView(uint id)
1415 View view = GetParent()?.FindCurrentChildById(id);
1417 //If we can't find the parent's children, find in the top layer.
1420 Container parent = GetParent();
1421 while ((parent is View) && (parent != null))
1423 parent = parent.GetParent();
1424 if (parent is Layer)
1426 view = parent.FindCurrentChildById(id);
1435 private void OnScaleChanged(float x, float y, float z)
1437 Scale = new Vector3(x, y, z);
1440 private void OnBackgroundColorChanged(float r, float g, float b, float a)
1442 BackgroundColor = new Color(r, g, b, a);
1445 private void OnPaddingChanged(ushort start, ushort end, ushort top, ushort bottom)
1447 Padding = new Extents(start, end, top, bottom);
1450 private void OnMarginChanged(ushort start, ushort end, ushort top, ushort bottom)
1452 Margin = new Extents(start, end, top, bottom);
1455 private void OnAnchorPointChanged(float x, float y, float z)
1457 AnchorPoint = new Position(x, y, z);
1460 private void OnCellIndexChanged(float x, float y)
1462 CellIndex = new Vector2(x, y);
1465 private void OnFlexMarginChanged(float x, float y, float z, float w)
1467 FlexMargin = new Vector4(x, y, z, w);
1470 private void OnPaddingEXChanged(ushort start, ushort end, ushort top, ushort bottom)
1472 PaddingEX = new Extents(start, end, top, bottom);
1475 private void OnSizeModeFactorChanged(float x, float y, float z)
1477 SizeModeFactor = new Vector3(x, y, z);
1480 private bool EmptyOnTouch(object target, TouchEventArgs args)
1485 private ViewSelectorData EnsureSelectorData()
1487 if (themeData == null) themeData = new ThemeData();
1489 return themeData.selectorData ?? (themeData.selectorData = new ViewSelectorData());