1 #ifndef DALI_TOOLKIT_INTERNAL_MAGNIFIER_H
2 #define DALI_TOOLKIT_INTERNAL_MAGNIFIER_H
5 * Copyright (c) 2021 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/public-api/actors/camera-actor.h>
23 #include <dali/public-api/actors/layer.h>
24 #include <dali/public-api/render-tasks/render-task.h>
27 #include <dali-toolkit/devel-api/controls/magnifier/magnifier.h>
28 #include <dali-toolkit/public-api/controls/control-impl.h>
38 typedef IntrusivePtr<Magnifier> MagnifierPtr;
41 * @copydoc Toolkit::Magnifier
43 class Magnifier : public Control
47 * Create a new Magnifier.
48 * @return A public handle to the newly allocated Magnifier.
50 static Dali::Toolkit::Magnifier New();
54 * @copydoc Toolkit::ImageView::SetSourceActor
56 void SetSourceActor(Actor actor);
59 * Returns whether the frame is visible or not.
60 * @return true if frame is visible, false if not.
62 bool GetFrameVisibility() const;
65 * Sets whether the frame part of the magnifier should be visible or not.
66 * @param[in] visible true to display frame, false to hide frame.
68 void SetFrameVisibility(bool visible);
71 * Get the magnification factor of the magnifier
72 * The larger the value the larger the contents magnified.
73 * A value of 1.0f indications 1x magnification.
74 * @return Magnification factor is returned
76 float GetMagnificationFactor() const;
79 * Set the magnification factor of the magnifier
80 * The larger the value the larger the contents magnified.
81 * A value of 1.0f indications 1x magnification.
82 * @param[in] value Magnification factor.
84 void SetMagnificationFactor(float value);
87 * Update magnification
94 * Called when a property of an object of this type is set.
95 * @param[in] object The object whose property is set.
96 * @param[in] index The property index.
97 * @param[in] value The new property value.
99 static void SetProperty(BaseObject* object, Property::Index index, const Property::Value& value);
102 * Called to retrieve a property of an object of this type.
103 * @param[in] object The object whose property is to be retrieved.
104 * @param[in] index The property index.
105 * @return The current value of the property.
107 static Property::Value GetProperty(BaseObject* object, Property::Index index);
111 * Construct a new Magnifier.
116 * 2nd-phase initialization.
121 * A reference counted object may only be deleted by calling Unreference()
123 virtual ~Magnifier();
127 * Initializes the render task required to render contents.
129 void InitializeRenderTask();
132 void OnSizeSet(const Vector3& targetSize) override;
136 Magnifier(const Magnifier&);
139 Magnifier& operator=(const Magnifier& rhs);
142 RenderTask mTask; ///< Render Task to render the source actor contents.
143 CameraActor mCameraActor; ///< CameraActor attached to RenderTask
144 Actor mFrame; ///< The Magnifier Frame
145 Actor mSourceActor; ///< Source Delegate Actor represents the source position to read.
146 float mDefaultCameraDistance; ///< Default RenderTask's camera distance from target.
147 Vector3 mActorSize; ///< The Actor size
148 float mMagnificationFactor; ///< Magnification factor 1.0f is default. same as content.
151 } // namespace Internal
153 // Helpers for public-api forwarding methods
155 inline Toolkit::Internal::Magnifier& GetImpl(Toolkit::Magnifier& pub)
157 DALI_ASSERT_ALWAYS(pub);
159 Dali::RefObject& handle = pub.GetImplementation();
161 return static_cast<Toolkit::Internal::Magnifier&>(handle);
164 inline const Toolkit::Internal::Magnifier& GetImpl(const Toolkit::Magnifier& pub)
166 DALI_ASSERT_ALWAYS(pub);
168 const Dali::RefObject& handle = pub.GetImplementation();
170 return static_cast<const Toolkit::Internal::Magnifier&>(handle);
173 } // namespace Toolkit
177 #endif // DALI_TOOLKIT_INTERNAL_MAGNIFIER_H