1 #ifndef DALI_STYLE_MONITOR_H
2 #define DALI_STYLE_MONITOR_H
5 * Copyright (c) 2022 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.
24 #include <dali/public-api/object/base-handle.h>
25 #include <dali/public-api/signals/dali-signal.h>
28 #include <dali/public-api/adaptor-framework/style-change.h>
32 namespace Internal DALI_INTERNAL
38 } // namespace DALI_INTERNAL
41 * @brief Monitors the platform for style changes.
43 * This is a handle to the adaptor's style monitor which holds the platform's style information.
44 * It provides a signal when any aspect of the default style changes on the device.
45 * @see Adaptor::GetStyleMonitor
47 class DALI_ADAPTOR_API StyleMonitor : public BaseHandle
50 typedef Signal<void(StyleMonitor, StyleChange::Type)> StyleChangeSignalType; ///< StyleChange Signal type
52 public: // Creation & Destruction
54 * @brief Create an uninitialized StyleMonitor handle.
56 * Tthis can be set by retrieving the style monitor from the Adaptor
57 * or the Application classes. Calling member functions when
58 * uninitialized is not allowed.
63 * @brief Creates a copy of the handle.
65 * The copy will point to the same implementation as the original.
66 * @param[in] monitor The Style Monitor to copy from.
68 StyleMonitor(const StyleMonitor& monitor);
71 * @brief Assignment operator.
73 * The handle points to the same implementation as the one being copied from.
74 * @param[in] monitor The Style Monitor to copy from.
75 * @return reference to this object
77 StyleMonitor& operator=(const StyleMonitor& monitor);
80 * @brief Creates a move of the handle.
82 * The move will point to the same implementation as the original.
83 * @param[in] monitor The Style Monitor to move from.
85 StyleMonitor(StyleMonitor&& monitor);
88 * @brief Move assignment operator.
90 * The handle points to the same implementation as the one being moved from.
91 * @param[in] monitor The Style Monitor to move from.
92 * @return reference to this object
94 StyleMonitor& operator=(StyleMonitor&& monitor);
97 * @brief Retrieve the initialized instance of the StyleMonitor.
98 * @return Handle to StyleMonitor.
100 static StyleMonitor Get();
105 * This is non-virtual since derived Handle types must not contain data or virtual methods.
110 * @brief Downcast an Object handle to StyleMonitor handle.
112 * If handle points to a StyleMonitor object the downcast produces a
113 * valid handle. If not the returned handle is left uninitialized.
115 * @param[in] handle to An object @return handle to a Timer object
116 * or an uninitialized handle
118 static StyleMonitor DownCast(BaseHandle handle);
120 public: // Style Information
123 * @brief Ensure the font client has been created.
125 * If font client doesn't exist, create it and set default values.
126 * @return true if the font client has been created.
128 bool EnsureFontClientCreated();
131 * @brief Retrieves the default font family.
132 * @return The default font family.
134 std::string GetDefaultFontFamily() const;
137 * @brief Retrieves the default font style.
138 * @return The default font style.
140 std::string GetDefaultFontStyle() const;
143 * @brief Retrieves the default font size.
145 * This is an logical size, which is mapped to a UI Control specific point-size in stylesheets.
146 * For example if zero the smallest size, this could potentially map to TextLabel point-size 8.
147 * @return The default font size, or a negative value if not set.
149 int GetDefaultFontSize() const;
152 * @brief Retrieves the user defined Theme.
153 * @return The user defined Theme.
155 const std::string& GetTheme() const;
158 * @brief Sets an user defined Theme.
159 * @param[in] themeFilePath Path of the user defined theme
161 void SetTheme(const std::string& themeFilePath);
164 * @brief Utility to load a theme file
165 * @param filename of the theme
166 * @param output to write the contents to
167 * @return true if the load is successful
169 bool LoadThemeFile(const std::string& filename, std::string& output);
173 * @brief This signal is emitted whenever the style changes on the device.
175 * A callback of the following type may be connected:
177 * void YourCallbackName(StyleMonitor styleMonitor, StyleChange change);
179 * @return The signal to connect to.
181 StyleChangeSignalType& StyleChangeSignal();
183 public: // Not intended for application developers
185 * @brief This constructor is used internally to create a handle from an object pointer.
186 * @param [in] styleMonitor A pointer the internal style monitor.
188 explicit DALI_INTERNAL StyleMonitor(Internal::Adaptor::StyleMonitor* styleMonitor);
193 #endif // DALI_STYLE_MONITOR_H