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