[NUI] Sync with dalihub (#969)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / GaussianBlurView.cs
1 /*
2  * Copyright(c) 2019 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 using Tizen.NUI.BaseComponents;
19
20 namespace Tizen.NUI
21 {
22
23     using System;
24     using System.Runtime.InteropServices;
25
26
27     internal class GaussianBlurView : View
28     {
29         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
30
31         internal GaussianBlurView(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.GaussianBlurView.GaussianBlurView_SWIGUpcast(cPtr), cMemoryOwn)
32         {
33             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
34         }
35
36         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(GaussianBlurView obj)
37         {
38             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
39         }
40
41         protected override void Dispose(DisposeTypes type)
42         {
43             if (disposed)
44             {
45                 return;
46             }
47
48             if (type == DisposeTypes.Explicit)
49             {
50                 //Called by User
51                 //Release your own managed resources here.
52                 //You should release all of your own disposable objects here.
53
54             }
55
56             //Release your own unmanaged resources here.
57             //You should not access any managed member here except static instance.
58             //because the execution order of Finalizes is non-deterministic.
59
60             if (swigCPtr.Handle != global::System.IntPtr.Zero)
61             {
62                 if (swigCMemOwn)
63                 {
64                     swigCMemOwn = false;
65                     Interop.GaussianBlurView.delete_GaussianBlurView(swigCPtr);
66                 }
67                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
68             }
69
70             base.Dispose(type);
71         }
72
73
74
75         /// <since_tizen> 3 </since_tizen>
76         public class FinishedEventArgs : EventArgs
77         {
78             private GaussianBlurView _gaussianBlurView;
79
80             /// <since_tizen> 3 </since_tizen>
81             public GaussianBlurView GaussianBlurView
82             {
83                 get
84                 {
85                     return _gaussianBlurView;
86                 }
87                 set
88                 {
89                     _gaussianBlurView = value;
90                 }
91             }
92         }
93
94         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
95         private delegate void FinishedEventCallbackDelegate(IntPtr application);
96         private DaliEventHandler<object, FinishedEventArgs> _gaussianFinishedEventHandler;
97         private FinishedEventCallbackDelegate _gaussianFinishedEventCallbackDelegate;
98
99         public event DaliEventHandler<object, FinishedEventArgs> Finished
100         {
101             add
102             {
103                 lock (this)
104                 {
105                     // Restricted to only one listener
106                     if (_gaussianFinishedEventHandler == null)
107                     {
108                         _gaussianFinishedEventHandler += value;
109
110                         _gaussianFinishedEventCallbackDelegate = new FinishedEventCallbackDelegate(OnFinished);
111                         this.FinishedSignal().Connect(_gaussianFinishedEventCallbackDelegate);
112                     }
113                 }
114             }
115
116             remove
117             {
118                 lock (this)
119                 {
120                     if (_gaussianFinishedEventHandler != null)
121                     {
122                         this.FinishedSignal().Disconnect(_gaussianFinishedEventCallbackDelegate);
123                     }
124
125                     _gaussianFinishedEventHandler -= value;
126                 }
127             }
128         }
129
130         // Callback for GaussianBlurView FinishedSignal
131         private void OnFinished(IntPtr data)
132         {
133             FinishedEventArgs e = new FinishedEventArgs();
134
135             // Populate all members of "e" (FinishedEventArgs) with real data
136             e.GaussianBlurView = Registry.GetManagedBaseHandleFromNativePtr(data) as GaussianBlurView;
137
138             if (_gaussianFinishedEventHandler != null)
139             {
140                 //here we send all data to user event handlers
141                 _gaussianFinishedEventHandler(this, e);
142             }
143         }
144
145         public GaussianBlurView() : this(Interop.GaussianBlurView.GaussianBlurView_New__SWIG_0(), true)
146         {
147             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
148
149         }
150         public GaussianBlurView(uint numSamples, float blurBellCurveWidth, PixelFormat renderTargetPixelFormat, float downsampleWidthScale, float downsampleHeightScale, bool blurUserImage) : this(Interop.GaussianBlurView.GaussianBlurView_New__SWIG_1(numSamples, blurBellCurveWidth, (int)renderTargetPixelFormat, downsampleWidthScale, downsampleHeightScale, blurUserImage), true)
151         {
152             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
153
154         }
155         public GaussianBlurView(uint numSamples, float blurBellCurveWidth, PixelFormat renderTargetPixelFormat, float downsampleWidthScale, float downsampleHeightScale) : this(Interop.GaussianBlurView.GaussianBlurView_New__SWIG_2(numSamples, blurBellCurveWidth, (int)renderTargetPixelFormat, downsampleWidthScale, downsampleHeightScale), true)
156         {
157             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
158
159         }
160         public GaussianBlurView(GaussianBlurView handle) : this(Interop.GaussianBlurView.new_GaussianBlurView__SWIG_1(GaussianBlurView.getCPtr(handle)), true)
161         {
162             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
163         }
164
165         public GaussianBlurView Assign(GaussianBlurView ZoomView)
166         {
167             GaussianBlurView ret = new GaussianBlurView(Interop.GaussianBlurView.GaussianBlurView_Assign(swigCPtr, GaussianBlurView.getCPtr(ZoomView)), false);
168             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
169             return ret;
170         }
171
172         public static GaussianBlurView DownCast(BaseHandle handle)
173         {
174             GaussianBlurView ret =  Registry.GetManagedBaseHandleFromNativePtr(handle) as GaussianBlurView;
175             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
176             return ret;
177         }
178
179         public new void Add(View child)
180         {
181             Interop.GaussianBlurView.GaussianBlurView_Add(swigCPtr, View.getCPtr(child));
182             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
183         }
184
185         public new void Remove(View child)
186         {
187             Interop.GaussianBlurView.GaussianBlurView_Remove(swigCPtr, View.getCPtr(child));
188             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
189         }
190
191         public void Activate()
192         {
193             Interop.GaussianBlurView.GaussianBlurView_Activate(swigCPtr);
194             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
195         }
196
197         public void ActivateOnce()
198         {
199             Interop.GaussianBlurView.GaussianBlurView_ActivateOnce(swigCPtr);
200             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
201         }
202
203         public void Deactivate()
204         {
205             Interop.GaussianBlurView.GaussianBlurView_Deactivate(swigCPtr);
206             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
207         }
208
209         public void SetUserImageAndOutputRenderTarget(Texture inputTexture, FrameBuffer outputRenderTarget)
210         {
211             Interop.GaussianBlurView.GaussianBlurView_SetUserImageAndOutputRenderTarget(swigCPtr, Texture.getCPtr(inputTexture), FrameBuffer.getCPtr(outputRenderTarget));
212             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
213         }
214
215         public int GetBlurStrengthPropertyIndex()
216         {
217             int ret = Interop.GaussianBlurView.GaussianBlurView_GetBlurStrengthPropertyIndex(swigCPtr);
218             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
219             return ret;
220         }
221
222         public FrameBufferImage GetBlurredRenderTarget()
223         {
224             FrameBufferImage ret = new FrameBufferImage(Interop.GaussianBlurView.GaussianBlurView_GetBlurredRenderTarget(swigCPtr), true);
225             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
226             return ret;
227         }
228
229         public void SetBackgroundColor(Vector4 color)
230         {
231             Interop.GaussianBlurView.GaussianBlurView_SetBackgroundColor(swigCPtr, Vector4.getCPtr(color));
232             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
233         }
234
235         public Vector4 GetBackgroundColor()
236         {
237             Vector4 ret = new Vector4(Interop.GaussianBlurView.GaussianBlurView_GetBackgroundColor(swigCPtr), true);
238             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
239             return ret;
240         }
241
242         public GaussianBlurViewSignal FinishedSignal()
243         {
244             GaussianBlurViewSignal ret = new GaussianBlurViewSignal(Interop.GaussianBlurView.GaussianBlurView_FinishedSignal(swigCPtr), false);
245             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
246             return ret;
247         }
248
249     }
250
251 }