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.
18 using System.ComponentModel;
22 using global::System.Runtime.InteropServices;
25 /// An abstract base class for Constraints.
26 /// This class only use for inhouse currently.
28 /// This can be used to constrain a property of an object, after animations have been applied.
29 /// Constraints are applied in the following order:
30 /// - Constraints are applied to on-stage views in a depth-first traversal.
31 /// - For each view, the constraints are applied in the same order as the calls to Apply().
32 /// - Constraints are not applied to off-stage views.
34 /// Create a constraint using one of the New method depending on the type of callback functions used.
36 /// Note : This function will called every frame. Maybe reduce performance if you applyed too many constraints.
38 /// TODO : AddSource(ConstraintSource); API need to be implemented.
39 /// To implement this, we have to bind ConstraintSource.
40 /// TODO : Currently We don't support custom functions.
41 /// To implement this, we have to bind PropertyInputContainer
43 internal class Constraint : BaseHandle
45 internal Constraint(IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
49 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Constraint obj)
51 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
55 /// Apply current constraint.
56 /// Constraint will work until Remove called.
60 Interop.Constraint.Apply(SwigCPtr);
61 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
64 /// Remove current constraint.
66 internal void Remove()
68 Interop.Constraint.Remove(SwigCPtr);
69 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
74 /// Remove action. Determine the target values action after remove current constriant.
75 /// Default is RemoveActionType.Bake
77 internal RemoveActionType RemoveAction
79 set => Interop.Constraint.SetRemoveAction(SwigCPtr, (int)value);
80 get => (RemoveActionType) Interop.Constraint.GetRemoveAction(SwigCPtr);
84 /// Tag number. It will be useful when you want to seperate constraints
88 set => Interop.Constraint.SetTag(SwigCPtr, value);
89 get => Interop.Constraint.GetTag(SwigCPtr);
93 /// Get constrainted target object
95 internal BaseHandle GetTargetObject()
97 BaseHandle handle = new BaseHandle(Interop.Constraint.GetTargetObject(SwigCPtr), true);
98 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
102 /// Get constrainted target property index
104 internal int GetTargetPropert()
106 int index = Interop.Constraint.GetTargetProperty(SwigCPtr);
107 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
114 /// <param name="type"></param>
115 [EditorBrowsable(EditorBrowsableState.Never)]
116 protected override void Dispose(DisposeTypes type)
122 if(type == DisposeTypes.Explicit)
125 //Release your own managed resources here.
126 //You should release all of your own disposable objects here.
131 /// This will not be public opened.
132 [EditorBrowsable(EditorBrowsableState.Never)]
133 protected override void ReleaseSwigCPtr(HandleRef swigCPtr)
135 Interop.Constraint.DeleteConstraint(swigCPtr);
136 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
140 /// Determinate how objects property will be when constraint removed.
143 internal enum RemoveActionType
146 /// Target objects property will bake when constraint removed.
148 [EditorBrowsable(EditorBrowsableState.Never)]
151 /// Target objects property will be original value when constraint removed.
153 [EditorBrowsable(EditorBrowsableState.Never)]