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