1 #ifndef DALI_INTERNAL_TOOLTIP_H
2 #define DALI_INTERNAL_TOOLTIP_H
5 * Copyright (c) 2017 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.
23 #include <dali/public-api/adaptor-framework/timer.h>
24 #include <dali/public-api/common/intrusive-ptr.h>
25 #include <dali/public-api/object/property-array.h>
26 #include <dali/public-api/object/property-map.h>
27 #include <dali/public-api/object/ref-object.h>
28 #include <dali/public-api/signals/connection-tracker.h>
29 #include <dali/public-api/object/weak-handle.h>
32 #include <dali-toolkit/public-api/controls/control.h>
33 #include <dali-toolkit/devel-api/controls/popup/popup.h>
34 #include <dali-toolkit/devel-api/controls/tooltip/tooltip-properties.h>
46 typedef IntrusivePtr< Tooltip > TooltipPtr;
49 * @brief Handles all the required tooltip related functionality for a control.
51 * Connects to the Hovered signal of the control.
52 * Styling is achieved by merging the properties set so that new properties override previous but existing properties are still kept.
54 class Tooltip : public RefObject, public ConnectionTracker
59 * @brief Creates an instance of the Tooltip class.
60 * @param[in] control The control the tooltip should be shown on.
62 static TooltipPtr New( Toolkit::Control control );
65 * @brief Sets the properties of the Tooltip.
66 * @details The properties are merged over the currently stored properties.
67 * If a Property::STRING is passed, then the style set previously by the stylesheet is used.
68 * If a Property::MAP then the map is merged.
69 * If a Property::ARRAY of Visuals then all are displayed in one row.
70 * @param[in] value This can either be a Property::STRING, Property::MAP or Property::ARRAY.
72 void SetProperties( const Property::Value& value );
75 * @brief Creates a property map of the tooltip properties.
76 * @param[out] map Filled with all the properties of the tooltip.
77 * @note map should be empty.
79 void CreatePropertyMap( Property::Map& map ) const;
84 * @brief Private constructor.
86 Tooltip( Toolkit::Control control );
89 * @brief Private destructor.
93 Tooltip( const Tooltip& ); ///< Undefined
94 Tooltip& operator=( const Tooltip& ); ///< ///< Undefined
97 * @brief Sets the content of the tooltip.
98 * @details Connects to the signals if there is real content to display.
99 * @param[in] control Is used to connect to this control's signals.
100 * @param[in] value The content property value.
102 void SetContent( Toolkit::Control& control, const Property::Value& value );
105 * @brief Sets the background properties of the tooltip.
106 * @param[in] value The background property value.
108 void SetBackground( const Property::Value& value );
111 * @brief Sets the tail properties of the tooltip.
112 * @param[in] value The tail property value.
114 void SetTail( const Property::Value& value );
117 * @brief Method used to connect to the control's Hovered signal.
118 * @param[in] hover The hover event.
120 bool OnHovered( Actor /* actor */, const HoverEvent& hover );
123 * @brief Method used to connect to the internal timer used by Tooltip.
124 * @return Always return false as we're only interested in one timeout.
129 * @brief Used to know when the we're laying out the actor used to display the tooltip.
130 * @details This is required so we can appropriately position it.
131 * @param[in] actor The actor being laid out.
133 void OnRelayout( Actor actor );
137 Toolkit::Popup mPopup; ///< The Popup class is used to display the actual tooltip.
138 Timer mTooltipTimer; ///< Timer used to wait a certain length of time before we display the tooltip.
140 WeakHandle< Toolkit::Control > mControl; ///< A weak handle to the control we are setting the tooltip on.
142 Property::Map mContentTextVisual; ///< If using just one visual, then this is set.
143 Property::Map mTailImages; ///< The different images used by the tail.
144 Property::Array mContentArray; ///< If using an array of visuals, then this is used.
146 Rect< int > mBackgroundBorder; ///< The size of the background border in the order: left, right, bottom, top. @see Toolkit::Tooltip::Border::Property::BORDER
148 Vector2 mLayout; ///< The layout of the content if using an array.
149 Vector2 mHoverPoint; ///< The first point where hover starts.
150 Vector2 mHoverPointOffset; ///< The tooltip is displayed with this offset from hover point if using Toolkit::Tooltip::Position::HOVER_POINT.
152 std::string mBackgroundImage; ///< The path to the background image used for the tooltip.
154 float mMovementThreshold; ///< This is the allowable movement of the hover before the tooltip processing is cancelled.
156 int mWaitTime; ///< Time in milliseconds to wait before we display the tooltip.
158 Toolkit::Tooltip::Position::Type mPositionType; ///< The position of the tooltip.
159 bool mTailVisibility; ///< Whether we are showing a tail or not.
160 bool mDisappearOnMovement; ///< Whether the tooltip is set to disappear on movement or when we go out of the bounds of mControl.
161 bool mSignalsConnected; ///< Whether any signals required for Tooltip functionality have been connected.
164 } // namespace Internal
166 } // namespace Toolkit
170 #endif // DALI_INTERNAL_TOOLTIP_H