1 #ifndef __DALI_TOOLKIT_INTERNAL_MASKED_IMAGE_VIEW_H__
2 #define __DALI_TOOLKIT_INTERNAL_MASKED_IMAGE_VIEW_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/dali.h>
23 #include <dali-toolkit/public-api/controls/control-impl.h>
24 #include <dali-toolkit/public-api/controls/image-view/masked-image-view.h>
36 * @copydoc Dali::Toolkit::MaskedImageView
38 class MaskedImageView : public ControlImpl
42 typedef Dali::Toolkit::MaskedImageView::ImageRotation ImageRotation;
45 * Create a new MaskedImageView.
46 * @return A public handle to the newly allocated MaskedImageView.
48 static Dali::Toolkit::MaskedImageView New( unsigned int targetWidth,
49 unsigned int targetHeight,
54 * @copydoc Dali::Toolkit::MaskedImageView::SetSourceImage()
56 void SetSourceImage( Image sourceImage );
59 * @copydoc Dali::Toolkit::MaskedImageView::GetSourceImage()
61 Image GetSourceImage();
64 * @copydoc Dali::Toolkit::MaskedImageView::SetMaskImage()
66 void SetMaskImage( Image maskImage );
69 * @copydoc Dali::Toolkit::MaskedImageView::GetMaskImage()
74 * @copydoc Dali::Toolkit::MaskedImageView::GetPropertyIndex()
76 Property::Index GetPropertyIndex( Dali::Toolkit::MaskedImageView::CustomProperty customProperty ) const;
79 * @copydoc Dali::Toolkit::MaskedImageView::Pause()
84 * @copydoc Dali::Toolkit::MaskedImageView::Resume()
89 * @copydoc Dali::Toolkit::MaskedImageView::IsPaused()
91 bool IsPaused() const;
94 * @copydoc Dali::Toolkit::MaskedImageView::SetEditMode()
96 void SetEditMode( Dali::Toolkit::MaskedImageView::EditMode editMode );
99 * @copydoc Dali::Toolkit::MaskedImageView::GetEditMode()
101 Dali::Toolkit::MaskedImageView::EditMode GetEditMode() const;
104 * @copydoc Dali::Toolkit::MaskedImageView::SetSourceAspectRatio()
106 void SetSourceAspectRatio( float widthOverHeight );
109 * @copydoc Dali::Toolkit::MaskedImageView::GetSourceAspectRatio()
111 float GetSourceAspectRatio() const;
114 * @copydoc Dali::Toolkit::MaskedImageView::SetMaximumSourceScale()
116 void SetMaximumSourceScale( float scale );
119 * @copydoc Dali::Toolkit::MaskedImageView::GetMaximumSourceScale()
121 float GetMaximumSourceScale() const;
124 * @copydoc Dali::Toolkit::MaskedImageView::SetSourceRotation()
126 void SetSourceRotation( ImageRotation rotation );
129 * @copydoc Dali::Toolkit::MaskedImageView::GetSourceRotation()
131 ImageRotation GetSourceRotation() const;
134 * @copydoc Dali::Toolkit::MaskedImageView::RenderFinishedSignal
136 Dali::RenderTask::RenderTaskSignalV2& RenderFinishedSignal()
138 return mRenderTask.FinishedSignal();
142 * @copydoc Dali::Toolkit::MaskedImageView::MaskFinishedSignal
144 Dali::Toolkit::MaskedImageView::MaskedImageViewSignal& MaskFinishedSignal();
149 * @copydoc Dali::CustomActorImpl::OnPropertySet()
151 void OnPropertySet( Property::Index index, Property::Value propertyValue );
154 * Helper for edit mode.
156 void OnPan( Actor source, PanGesture gesture );
159 * Helper for edit mode.
161 void OnPinch( Actor actor, PinchGesture pinch );
164 * Construct a new MaskedImageView.
169 * 2nd-phase initialization.
171 void Initialize( unsigned int targetWidth,
172 unsigned int targetHeight,
177 * Helper to apply the desired shader-effect for a given rotation.
178 * @param[in] rotation The rotation to apply to the source image.
180 void ApplyMaskedImageShader( ImageRotation rotation );
183 * Helper to clamp the source image properties (only in edit mode).
185 void ClampSourceSizeAndOffset();
188 * A reference counted object may only be deleted by calling Unreference()
190 virtual ~MaskedImageView();
195 MaskedImageView(const MaskedImageView&);
198 MaskedImageView& operator=(const MaskedImageView& rhs);
201 * Emit MaskFinishedSignal when the render task finished rendering
202 * @param[in] renderTask the off-screen render task
204 void OnRenderTaskFinished( Dali::RenderTask& renderTask );
210 Property::Index mCustomProperties[ Dali::Toolkit::MaskedImageView::CUSTOM_PROPERTY_COUNT ];
212 // Used for off-screen rendering
213 RenderTask mRenderTask;
214 ImageActor mSourceImageActor;
215 FrameBufferImage mDestinationImage;
217 // Create actor to display result of off-screen rendering
218 ImageActor mDestinationImageActor;
220 // Because ShaderEffect doesn't have a GetEffectImage()
224 Dali::Toolkit::MaskedImageView::EditMode mEditMode;
225 PanGestureDetector mPanGestureDetector;
226 PinchGestureDetector mPinchDetector;
227 bool mSelfPropertySetting;
232 Vector2 mStartPinchSize;
233 Vector2 mCurrentPinchSize;
235 ImagePosition mSourcePosition;
236 ImagePosition mMaskPosition;
238 ImageRotation mSourceRotation;
240 // Limits for edit mode
241 float mWidthOverHeight;
242 float mMaximumSourceScale;
244 Dali::Toolkit::MaskedImageView::MaskedImageViewSignal mMaskFinishedSignal;
247 } // namespace Internal
249 // Helpers for public-api forwarding methods
251 inline Toolkit::Internal::MaskedImageView& GetImpl(Toolkit::MaskedImageView& pub)
253 DALI_ASSERT_ALWAYS(pub);
255 Dali::RefObject& handle = pub.GetImplementation();
257 return static_cast<Toolkit::Internal::MaskedImageView&>(handle);
260 inline const Toolkit::Internal::MaskedImageView& GetImpl(const Toolkit::MaskedImageView& pub)
262 DALI_ASSERT_ALWAYS(pub);
264 const Dali::RefObject& handle = pub.GetImplementation();
266 return static_cast<const Toolkit::Internal::MaskedImageView&>(handle);
269 } // namespace Toolkit
273 #endif // __DALI_TOOLKIT_INTERNAL_MASKED_IMAGE_VIEW_H__