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 Control
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::MaskFinishedSignal
136 Dali::Toolkit::MaskedImageView::MaskedImageViewSignal& MaskFinishedSignal();
141 * @copydoc Dali::CustomActorImpl::OnPropertySet()
143 void OnPropertySet( Property::Index index, Property::Value propertyValue );
146 * Helper for edit mode.
148 void OnPan( Actor source, PanGesture gesture );
151 * Helper for edit mode.
153 void OnPinch( Actor actor, PinchGesture pinch );
156 * Construct a new MaskedImageView.
161 * 2nd-phase initialization.
163 void Initialize( unsigned int targetWidth,
164 unsigned int targetHeight,
169 * Helper to apply the desired shader-effect for a given rotation.
170 * @param[in] rotation The rotation to apply to the source image.
172 void ApplyMaskedImageShader( ImageRotation rotation );
175 * Helper to clamp the source image properties (only in edit mode).
177 void ClampSourceSizeAndOffset();
180 * A reference counted object may only be deleted by calling Unreference()
182 virtual ~MaskedImageView();
187 MaskedImageView(const MaskedImageView&);
190 MaskedImageView& operator=(const MaskedImageView& rhs);
193 * Emit MaskFinishedSignal when the render task finished rendering
194 * @param[in] renderTask the off-screen render task
196 void OnRenderTaskFinished( Dali::RenderTask& renderTask );
202 Property::Index mCustomProperties[ Dali::Toolkit::MaskedImageView::CUSTOM_PROPERTY_COUNT ];
204 // Used for off-screen rendering
205 RenderTask mRenderTask;
206 ImageActor mSourceImageActor;
207 FrameBufferImage mDestinationImage;
209 // Create actor to display result of off-screen rendering
210 ImageActor mDestinationImageActor;
212 // Because ShaderEffect doesn't have a GetEffectImage()
216 Dali::Toolkit::MaskedImageView::EditMode mEditMode;
217 PanGestureDetector mPanGestureDetector;
218 PinchGestureDetector mPinchDetector;
219 bool mSelfPropertySetting;
224 Vector2 mStartPinchSize;
225 Vector2 mCurrentPinchSize;
227 ImagePosition mSourcePosition;
228 ImagePosition mMaskPosition;
230 ImageRotation mSourceRotation;
232 // Limits for edit mode
233 float mWidthOverHeight;
234 float mMaximumSourceScale;
236 Dali::Toolkit::MaskedImageView::MaskedImageViewSignal mMaskFinishedSignal;
239 } // namespace Internal
241 // Helpers for public-api forwarding methods
243 inline Toolkit::Internal::MaskedImageView& GetImpl(Toolkit::MaskedImageView& pub)
245 DALI_ASSERT_ALWAYS(pub);
247 Dali::RefObject& handle = pub.GetImplementation();
249 return static_cast<Toolkit::Internal::MaskedImageView&>(handle);
252 inline const Toolkit::Internal::MaskedImageView& GetImpl(const Toolkit::MaskedImageView& pub)
254 DALI_ASSERT_ALWAYS(pub);
256 const Dali::RefObject& handle = pub.GetImplementation();
258 return static_cast<const Toolkit::Internal::MaskedImageView&>(handle);
261 } // namespace Toolkit
265 #endif // __DALI_TOOLKIT_INTERNAL_MASKED_IMAGE_VIEW_H__