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 Flora License, Version 1.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://floralicense.org/license/
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.
21 #include <dali/dali.h>
22 #include <dali-toolkit/public-api/controls/control-impl.h>
23 #include <dali-toolkit/public-api/controls/image-view/masked-image-view.h>
35 * @copydoc Dali::Toolkit::MaskedImageView
37 class MaskedImageView : public ControlImpl
41 typedef Dali::Toolkit::MaskedImageView::ImageRotation ImageRotation;
44 * Create a new MaskedImageView.
45 * @return A public handle to the newly allocated MaskedImageView.
47 static Dali::Toolkit::MaskedImageView New( unsigned int targetWidth,
48 unsigned int targetHeight,
53 * @copydoc Dali::Toolkit::MaskedImageView::SetSourceImage()
55 void SetSourceImage( Image sourceImage );
58 * @copydoc Dali::Toolkit::MaskedImageView::GetSourceImage()
60 Image GetSourceImage();
63 * @copydoc Dali::Toolkit::MaskedImageView::SetMaskImage()
65 void SetMaskImage( Image maskImage );
68 * @copydoc Dali::Toolkit::MaskedImageView::GetMaskImage()
73 * @copydoc Dali::Toolkit::MaskedImageView::GetPropertyIndex()
75 Property::Index GetPropertyIndex( Dali::Toolkit::MaskedImageView::CustomProperty customProperty ) const;
78 * @copydoc Dali::Toolkit::MaskedImageView::Pause()
83 * @copydoc Dali::Toolkit::MaskedImageView::Resume()
88 * @copydoc Dali::Toolkit::MaskedImageView::IsPaused()
90 bool IsPaused() const;
93 * @copydoc Dali::Toolkit::MaskedImageView::SetEditMode()
95 void SetEditMode( Dali::Toolkit::MaskedImageView::EditMode editMode );
98 * @copydoc Dali::Toolkit::MaskedImageView::GetEditMode()
100 Dali::Toolkit::MaskedImageView::EditMode GetEditMode() const;
103 * @copydoc Dali::Toolkit::MaskedImageView::SetSourceAspectRatio()
105 void SetSourceAspectRatio( float widthOverHeight );
108 * @copydoc Dali::Toolkit::MaskedImageView::GetSourceAspectRatio()
110 float GetSourceAspectRatio() const;
113 * @copydoc Dali::Toolkit::MaskedImageView::SetMaximumSourceScale()
115 void SetMaximumSourceScale( float scale );
118 * @copydoc Dali::Toolkit::MaskedImageView::GetMaximumSourceScale()
120 float GetMaximumSourceScale() const;
123 * @copydoc Dali::Toolkit::MaskedImageView::SetSourceRotation()
125 void SetSourceRotation( ImageRotation rotation );
128 * @copydoc Dali::Toolkit::MaskedImageView::GetSourceRotation()
130 ImageRotation GetSourceRotation() const;
133 * @copydoc Dali::Toolkit::MaskedImageView::RenderFinishedSignal
135 Dali::RenderTask::RenderTaskSignalV2& RenderFinishedSignal()
137 return mRenderTask.FinishedSignal();
141 * @copydoc Dali::Toolkit::MaskedImageView::MaskFinishedSignal
143 Dali::Toolkit::MaskedImageView::MaskedImageViewSignal& MaskFinishedSignal();
148 * @copydoc Dali::CustomActorImpl::OnPropertySet()
150 void OnPropertySet( Property::Index index, Property::Value propertyValue );
153 * Helper for edit mode.
155 void OnPan( Actor source, PanGesture gesture );
158 * Helper for edit mode.
160 void OnPinch( Actor actor, PinchGesture pinch );
163 * Construct a new MaskedImageView.
168 * 2nd-phase initialization.
170 void Initialize( unsigned int targetWidth,
171 unsigned int targetHeight,
176 * Helper to apply the desired shader-effect for a given rotation.
177 * @param[in] rotation The rotation to apply to the source image.
179 void ApplyMaskedImageShader( ImageRotation rotation );
182 * Helper to clamp the source image properties (only in edit mode).
184 void ClampSourceSizeAndOffset();
187 * A reference counted object may only be deleted by calling Unreference()
189 virtual ~MaskedImageView();
194 MaskedImageView(const MaskedImageView&);
197 MaskedImageView& operator=(const MaskedImageView& rhs);
200 * Emit MaskFinishedSignal when the render task finished rendering
201 * @param[in] renderTask the off-screen render task
203 void OnRenderTaskFinished( Dali::RenderTask& renderTask );
209 Property::Index mCustomProperties[ Dali::Toolkit::MaskedImageView::CUSTOM_PROPERTY_COUNT ];
211 // Used for off-screen rendering
212 RenderTask mRenderTask;
213 ImageActor mSourceImageActor;
214 FrameBufferImage mDestinationImage;
216 // Create actor to display result of off-screen rendering
217 ImageActor mDestinationImageActor;
219 // Because ShaderEffect doesn't have a GetEffectImage()
223 Dali::Toolkit::MaskedImageView::EditMode mEditMode;
224 PanGestureDetector mPanGestureDetector;
225 PinchGestureDetector mPinchDetector;
226 bool mSelfPropertySetting;
231 Vector2 mStartPinchSize;
232 Vector2 mCurrentPinchSize;
234 ImagePosition mSourcePosition;
235 ImagePosition mMaskPosition;
237 ImageRotation mSourceRotation;
239 // Limits for edit mode
240 float mWidthOverHeight;
241 float mMaximumSourceScale;
243 Dali::Toolkit::MaskedImageView::MaskedImageViewSignal mMaskFinishedSignal;
246 } // namespace Internal
248 // Helpers for public-api forwarding methods
250 inline Toolkit::Internal::MaskedImageView& GetImpl(Toolkit::MaskedImageView& pub)
252 DALI_ASSERT_ALWAYS(pub);
254 Dali::RefObject& handle = pub.GetImplementation();
256 return static_cast<Toolkit::Internal::MaskedImageView&>(handle);
259 inline const Toolkit::Internal::MaskedImageView& GetImpl(const Toolkit::MaskedImageView& pub)
261 DALI_ASSERT_ALWAYS(pub);
263 const Dali::RefObject& handle = pub.GetImplementation();
265 return static_cast<const Toolkit::Internal::MaskedImageView&>(handle);
268 } // namespace Toolkit
272 #endif // __DALI_TOOLKIT_INTERNAL_MASKED_IMAGE_VIEW_H__