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.Get(this)?.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 cornerRadiusValue = backgroundExtraData.CornerRadius == null ? new PropertyValue() : new PropertyValue(backgroundExtraData.CornerRadius);
1027 var cornerRadiusPolicyValue = new PropertyValue((int)backgroundExtraData.CornerRadiusPolicy);
1029 // Make current propertyMap
1030 PropertyMap currentPropertyMap = new PropertyMap();
1031 currentPropertyMap[Visual.Property.CornerRadius] = cornerRadiusValue;
1032 currentPropertyMap[Visual.Property.CornerRadiusPolicy] = cornerRadiusPolicyValue;
1033 var temp = new PropertyValue(currentPropertyMap);
1035 // Update corner radius properties to background and shadow by ActionUpdateProperty
1036 DoAction(View.Property.BACKGROUND, ActionUpdateProperty, temp);
1037 DoAction(View.Property.SHADOW, ActionUpdateProperty, temp);
1040 currentPropertyMap.Dispose();
1041 cornerRadiusValue.Dispose();
1042 cornerRadiusPolicyValue.Dispose();
1045 /// TODO open as a protected level
1046 internal virtual void ApplyBorderline()
1048 if (backgroundExtraData == null) return;
1050 var borderlineWidthValue = new PropertyValue(backgroundExtraData.BorderlineWidth);
1051 var borderlineColorValue = backgroundExtraData.BorderlineColor == null ? new PropertyValue(Color.Black) : new PropertyValue(backgroundExtraData.BorderlineColor);
1052 var borderlineOffsetValue = new PropertyValue(backgroundExtraData.BorderlineOffset);
1054 // Make current propertyMap
1055 PropertyMap currentPropertyMap = new PropertyMap();
1056 currentPropertyMap[Visual.Property.BorderlineWidth] = borderlineWidthValue;
1057 currentPropertyMap[Visual.Property.BorderlineColor] = borderlineColorValue;
1058 currentPropertyMap[Visual.Property.BorderlineOffset] = borderlineOffsetValue;
1059 var temp = new PropertyValue(currentPropertyMap);
1061 // Update borderline properties to background by ActionUpdateProperty
1062 DoAction(View.Property.BACKGROUND, ActionUpdateProperty, temp);
1065 currentPropertyMap.Dispose();
1066 borderlineWidthValue.Dispose();
1067 borderlineColorValue.Dispose();
1068 borderlineOffsetValue.Dispose();
1072 /// Get selector value from the triggerable selector or related property.
1074 internal Selector<T> GetSelector<T>(TriggerableSelector<T> triggerableSelector, NUI.Binding.BindableProperty relatedProperty)
1076 var selector = triggerableSelector?.Get();
1077 if (selector != null)
1082 var value = (T)GetValue(relatedProperty);
1083 return value == null ? null : new Selector<T>(value);
1086 internal void SetThemeApplied()
1088 if (themeData == null) themeData = new ThemeData();
1089 themeData.ThemeApplied = true;
1091 if (ThemeChangeSensitive && !themeData.ListeningThemeChangeEvent)
1093 themeData.ListeningThemeChangeEvent = true;
1094 ThemeManager.ThemeChangedInternal.Add(OnThemeChanged);
1099 /// you can override it to clean-up your own resources.
1101 /// <param name="type">DisposeTypes</param>
1102 /// <since_tizen> 3 </since_tizen>
1103 protected override void Dispose(DisposeTypes type)
1111 NUILog.Debug($"[Dispose] View.Dispose({type}) START");
1112 NUILog.Debug($"[Dispose] type:{GetType()} copyNativeHandle:{GetBaseHandleCPtrHandleRef.Handle.ToString("X8")}");
1115 NUILog.Debug($"[Dispose] ID:{Interop.Actor.GetId(GetBaseHandleCPtrHandleRef)} Name:{Interop.Actor.GetName(GetBaseHandleCPtrHandleRef)}");
1119 NUILog.Debug($"has no native body!");
1124 //_mergedStyle = null;
1126 internalMaximumSize?.Dispose();
1127 internalMaximumSize = null;
1128 internalMinimumSize?.Dispose();
1129 internalMinimumSize = null;
1130 internalMargin?.Dispose();
1131 internalMargin = null;
1132 internalPadding?.Dispose();
1133 internalPadding = null;
1134 internalSizeModeFactor?.Dispose();
1135 internalSizeModeFactor = null;
1136 internalCellIndex?.Dispose();
1137 internalCellIndex = null;
1138 internalBackgroundColor?.Dispose();
1139 internalBackgroundColor = null;
1140 internalColor?.Dispose();
1141 internalColor = null;
1142 internalPivotPoint?.Dispose();
1143 internalPivotPoint = null;
1144 internalPosition?.Dispose();
1145 internalPosition = null;
1146 internalPosition2D?.Dispose();
1147 internalPosition2D = null;
1148 internalScale?.Dispose();
1149 internalScale = null;
1150 internalSize?.Dispose();
1151 internalSize = null;
1152 internalSize2D?.Dispose();
1153 internalSize2D = null;
1155 if (type == DisposeTypes.Explicit)
1158 //Release your own managed resources here.
1159 //You should release all of your own disposable objects here.
1160 if (themeData != null)
1162 themeData.selectorData?.Reset(this);
1163 if (themeData.ListeningThemeChangeEvent)
1165 ThemeManager.ThemeChangedInternal.Remove(OnThemeChanged);
1168 if (widthConstraint != null)
1170 widthConstraint.Remove();
1171 widthConstraint.Dispose();
1173 if (heightConstraint != null)
1175 heightConstraint.Remove();
1176 heightConstraint.Dispose();
1180 //Release your own unmanaged resources here.
1181 //You should not access any managed member here except static instance.
1182 //because the execution order of Finalizes is non-deterministic.
1184 DisConnectFromSignals();
1186 foreach (View view in Children)
1188 view.InternalParent = null;
1191 NUILog.Debug($"[Dispose] View.Dispose({type}) END");
1192 NUILog.Debug($"=============================");
1197 /// This will not be public opened.
1198 [EditorBrowsable(EditorBrowsableState.Never)]
1199 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1201 Interop.View.DeleteView(swigCPtr);
1205 /// The touch event handler for ControlState.
1206 /// Please change ControlState value by touch state if needed.
1208 /// <exception cref="ArgumentNullException"> Thrown when touch is null. </exception>
1209 [EditorBrowsable(EditorBrowsableState.Never)]
1210 protected virtual bool HandleControlStateOnTouch(Touch touch)
1214 throw new global::System.ArgumentNullException(nameof(touch));
1217 switch (touch.GetState(0))
1219 case PointStateType.Down:
1220 ControlState += ControlState.Pressed;
1222 case PointStateType.Interrupted:
1223 case PointStateType.Up:
1224 if (ControlState.Contains(ControlState.Pressed))
1226 ControlState -= ControlState.Pressed;
1235 private void DisConnectFromSignals()
1237 if (HasBody() == false)
1239 NUILog.Debug($"[Dispose] DisConnectFromSignals() No native body! No need to Disconnect Signals!");
1242 NUILog.Debug($"[Dispose] DisConnectFromSignals START");
1243 NUILog.Debug($"[Dispose] View.DisConnectFromSignals() type:{GetType()} copyNativeHandle:{GetBaseHandleCPtrHandleRef.Handle.ToString("X8")}");
1244 NUILog.Debug($"[Dispose] ID:{Interop.Actor.GetId(GetBaseHandleCPtrHandleRef)} Name:{Interop.Actor.GetName(GetBaseHandleCPtrHandleRef)}");
1246 if (onRelayoutEventCallback != null)
1248 NUILog.Debug($"[Dispose] onRelayoutEventCallback");
1250 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnRelayoutSignal(GetBaseHandleCPtrHandleRef), false);
1251 signal?.Disconnect(onRelayoutEventCallback);
1252 onRelayoutEventCallback = null;
1255 if (offWindowEventCallback != null)
1257 NUILog.Debug($"[Dispose] offWindowEventCallback");
1259 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOffSceneSignal(GetBaseHandleCPtrHandleRef), false);
1260 signal?.Disconnect(offWindowEventCallback);
1261 offWindowEventCallback = null;
1264 if (onWindowEventCallback != null)
1266 NUILog.Debug($"[Dispose] onWindowEventCallback");
1268 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(GetBaseHandleCPtrHandleRef), false);
1269 signal?.Disconnect(onWindowEventCallback);
1270 onWindowEventCallback = null;
1273 if (wheelEventCallback != null)
1275 NUILog.Debug($"[Dispose] wheelEventCallback");
1277 using WheelSignal signal = new WheelSignal(Interop.ActorSignal.ActorWheelEventSignal(GetBaseHandleCPtrHandleRef), false);
1278 signal?.Disconnect(wheelEventCallback);
1279 wheelEventCallback = null;
1282 if (WindowWheelEventHandler != null)
1284 NUILog.Debug($"[Dispose] WindowWheelEventHandler");
1286 NUIApplication.GetDefaultWindow().WheelEvent -= OnWindowWheelEvent;
1287 WindowWheelEventHandler = null;
1290 if (hoverEventCallback != null)
1292 NUILog.Debug($"[Dispose] hoverEventCallback");
1294 using HoverSignal signal = new HoverSignal(Interop.ActorSignal.ActorHoveredSignal(GetBaseHandleCPtrHandleRef), false);
1295 signal?.Disconnect(hoverEventCallback);
1296 hoverEventCallback = null;
1299 if (interceptTouchDataCallback != null)
1301 NUILog.Debug($"[Dispose] interceptTouchDataCallback");
1303 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorInterceptTouchSignal(GetBaseHandleCPtrHandleRef), false);
1304 signal?.Disconnect(interceptTouchDataCallback);
1305 interceptTouchDataCallback = null;
1308 if (touchDataCallback != null)
1310 NUILog.Debug($"[Dispose] touchDataCallback");
1312 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorTouchSignal(GetBaseHandleCPtrHandleRef), false);
1313 signal?.Disconnect(touchDataCallback);
1314 touchDataCallback = null;
1317 if (ResourcesLoadedCallback != null)
1319 NUILog.Debug($"[Dispose] ResourcesLoadedCallback");
1321 using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(GetBaseHandleCPtrHandleRef), false);
1322 signal?.Disconnect(ResourcesLoadedCallback);
1323 ResourcesLoadedCallback = null;
1326 if (keyCallback != null)
1328 NUILog.Debug($"[Dispose] keyCallback");
1330 using ControlKeySignal signal = new ControlKeySignal(Interop.ViewSignal.KeyEventSignal(GetBaseHandleCPtrHandleRef), false);
1331 signal?.Disconnect(keyCallback);
1335 if (keyInputFocusLostCallback != null)
1337 NUILog.Debug($"[Dispose] keyInputFocusLostCallback");
1339 using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusLostSignal(GetBaseHandleCPtrHandleRef), false);
1340 signal?.Disconnect(keyInputFocusLostCallback);
1341 keyInputFocusLostCallback = null;
1342 keyInputFocusLostEventHandler = null;
1345 if (keyInputFocusGainedCallback != null)
1347 NUILog.Debug($"[Dispose] keyInputFocusGainedCallback");
1349 using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusGainedSignal(GetBaseHandleCPtrHandleRef), false);
1350 signal?.Disconnect(keyInputFocusGainedCallback);
1351 keyInputFocusGainedCallback = null;
1352 keyInputFocusGainedEventHandler = null;
1355 if (backgroundResourceLoadedCallback != null)
1357 NUILog.Debug($"[Dispose] backgroundResourceLoadedCallback");
1359 using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(GetBaseHandleCPtrHandleRef), false);
1360 signal?.Disconnect(backgroundResourceLoadedCallback);
1361 backgroundResourceLoadedCallback = null;
1364 if (onWindowSendEventCallback != null)
1366 NUILog.Debug($"[Dispose] onWindowSendEventCallback");
1368 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(GetBaseHandleCPtrHandleRef), false);
1369 signal?.Disconnect(onWindowSendEventCallback);
1370 onWindowSendEventCallback = null;
1372 NUILog.Debug($"[Dispose] DisConnectFromSignals END");
1376 /// Apply initial style to the view.
1378 [EditorBrowsable(EditorBrowsableState.Never)]
1379 protected virtual void InitializeStyle(ViewStyle style = null)
1381 var initialStyle = ThemeManager.GetInitialStyleWithoutClone(GetType());
1384 ApplyStyle(initialStyle);
1388 var refinedStyle = style;
1389 if (style.IncludeDefaultStyle)
1391 refinedStyle = initialStyle?.Merge(style);
1393 ApplyStyle(refinedStyle);
1396 // Listen theme change event if needs.
1397 if (ThemeManager.PlatformThemeEnabled && initialStyle != null)
1403 private View ConvertIdToView(uint id)
1405 View view = GetParent()?.FindCurrentChildById(id);
1407 //If we can't find the parent's children, find in the top layer.
1410 Container parent = GetParent();
1411 while ((parent is View) && (parent != null))
1413 parent = parent.GetParent();
1414 if (parent is Layer)
1416 view = parent.FindCurrentChildById(id);
1425 private void OnScaleChanged(float x, float y, float z)
1427 Scale = new Vector3(x, y, z);
1430 private void OnBackgroundColorChanged(float r, float g, float b, float a)
1432 BackgroundColor = new Color(r, g, b, a);
1435 private void OnPaddingChanged(ushort start, ushort end, ushort top, ushort bottom)
1437 Padding = new Extents(start, end, top, bottom);
1440 private void OnMarginChanged(ushort start, ushort end, ushort top, ushort bottom)
1442 Margin = new Extents(start, end, top, bottom);
1445 private void OnAnchorPointChanged(float x, float y, float z)
1447 AnchorPoint = new Position(x, y, z);
1450 private void OnCellIndexChanged(float x, float y)
1452 CellIndex = new Vector2(x, y);
1455 private void OnFlexMarginChanged(float x, float y, float z, float w)
1457 FlexMargin = new Vector4(x, y, z, w);
1460 private void OnPaddingEXChanged(ushort start, ushort end, ushort top, ushort bottom)
1462 PaddingEX = new Extents(start, end, top, bottom);
1465 private void OnSizeModeFactorChanged(float x, float y, float z)
1467 SizeModeFactor = new Vector3(x, y, z);
1470 private bool EmptyOnTouch(object target, TouchEventArgs args)
1475 private ViewSelectorData EnsureSelectorData()
1477 if (themeData == null) themeData = new ThemeData();
1479 return themeData.selectorData ?? (themeData.selectorData = new ViewSelectorData());