Region changed system event is added
[apps/livebox/livebox.git] / include / livebox.h
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.tizenopensource.org/license
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __LIVEBOX_HELPER_H
18 #define __LIVEBOX_HELPER_H
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 struct livebox_buffer; /* Defined by provider */
25
26 /*!
27  * \brief
28  * Return values of livebox programming interfaces.
29  */
30 extern const int DONE; /*!< Operation is successfully done */
31 extern const int OUTPUT_UPDATED; /*!< Contents is updated */
32
33 extern const int NEED_TO_SCHEDULE; /*!< Need to call the livebox_need_to_update and livebox_update_content */
34 extern const int NEED_TO_CREATE; /*!< Need to create a new instance */
35 extern const int NEED_TO_DESTROY; /*!< Need to destroy this instance */
36 extern const int NEED_TO_UPDATE;
37
38 extern const int USE_NET; /*!< Using network */
39
40 extern const int LB_SYS_EVENT_FONT_CHANGED; /*!< System font is changed */
41 extern const int LB_SYS_EVENT_LANG_CHANGED; /*!< System language is changed */
42 extern const int LB_SYS_EVENT_TIME_CHANGED; /*!< System time is changed */
43 extern const int LB_SYS_EVENT_REGION_CHANGED; /*!< Region changed */
44 extern const int LB_SYS_EVENT_PAUSED;
45 extern const int LB_SYS_EVENT_RESUMED;
46
47 #define LB_DESC_TYPE_COLOR "color"
48 #define LB_DESC_TYPE_TEXT "text"
49 #define LB_DESC_TYPE_IMAGE "image"
50 #define LB_DESC_TYPE_SIGNAL "signal"
51 #define LB_DESC_TYPE_INFO "info"
52 #define LB_DESC_TYPE_DRAG "drag"
53 #define LB_DESC_TYPE_SCRIPT "script"
54
55 /*!
56  * \brief
57  * Extra event informatino for livebox_content_event interface function
58  */
59 #ifndef __PROVIDER_H
60 struct event_info {
61         struct {
62                 double x;
63                 double y;
64                 int down;
65         } pointer; /*!< Down/Up state and mouse position */
66
67         struct {
68                 double sx;
69                 double sy;
70                 double ex;
71                 double ey;
72         } part; /*!< Geometry of event received part */
73 };
74 #endif
75
76 struct livebox_desc;
77
78 /*!
79  * \brief Update a description file.
80  * \param[in] filename
81  * \param[in] for_pd
82  * \return handle
83  */
84 extern struct livebox_desc *livebox_desc_open(const char *filename, int for_pd);
85
86 /*!
87  * \brief Complete the description file updating
88  * \param[in] handle
89  * \return int
90  */
91 extern int livebox_desc_close(struct livebox_desc *handle);
92
93 /*!
94  * \brief Set the category information of current description data
95  * \param[in] handle
96  * \param[in] id
97  * \param[in] category
98  * \return int
99  */
100 extern int livebox_desc_set_category(struct livebox_desc *handle, const char *id, const char *category);
101
102 /*!
103  * \brief Set the content size
104  * \param[in] handle
105  * \param[in] id
106  * \param[in] w
107  * \param[in] h
108  * \return int
109  */
110 extern int livebox_desc_set_size(struct livebox_desc *handle, const char *id, int w, int h);
111
112 /*!
113  * \breif Set the target id of given block
114  *        Only available for the script block
115  * \param[in] handle
116  * \param[in] idx
117  * \param[in] id
118  * \return ret
119  */
120 extern int livebox_desc_set_id(struct livebox_desc *handle, int idx, const char *id);
121
122 /*!
123  * \brief Add a new block
124  * \param[in] handle
125  * \param[in] id ID of source script object
126  * \param[in] type image|text|script|signal|...
127  * \param[in] part target part to update with given content(data)
128  * \param[in] data content for specified part
129  * \param[in] option option for the block. (script: group, image: option, ...)
130  * \return idx Index of current description block
131  */
132 extern int livebox_desc_add_block(struct livebox_desc *handle, const char *id, const char *type, const char *part, const char *data, const char *option);
133
134 /*!
135  * \brief Delete a added block
136  * \param[in] handle
137  * \param[in] idx Index of added block
138  * \return int
139  */
140 extern int livebox_desc_del_block(struct livebox_desc *handle, int idx);
141
142 /*!
143  * \brief Replace '\n' with '<br>'
144  * \param[in] str Source string
145  * \return char* allocated string
146  */
147 extern char *livebox_util_nl2br(const char *str);
148
149
150 /*!
151  * Interfaces for direct buffer management (Available only for the PD area)
152  */
153
154
155 #ifndef __PROVIDER_BUFFER_H
156 /*!
157  * \NOTE
158  * This enumeration value should be sync'd with provider
159  */
160 enum buffer_event {
161         BUFFER_EVENT_ENTER, /*!< Mouse cursor enter */
162         BUFFER_EVENT_LEAVE, /*!< Mouse cursor leave */
163         BUFFER_EVENT_DOWN, /*!< Mouse down */
164         BUFFER_EVENT_MOVE, /*!< Mouse move */
165         BUFFER_EVENT_UP, /*!< Mouse up */
166
167         BUFFER_EVENT_KEY_DOWN, /*!< Key down */
168         BUFFER_EVENT_KEY_UP, /*!< Key up */
169 };
170 #endif
171
172 /*!
173  * \brief Acquire a buffer for PD or LB, Currently, we only supporting the PD.
174  * \param[in] id Id of a livebox instance
175  * \param[in] is_pd 1 for PD or 0 for livebox
176  * \param[in] width Width
177  * \param[in] height Height
178  * \param[in] handler Event handling callback
179  * \param[in] data user data for event handling callback
180  * \return handler Buffer handle
181  */
182 extern struct livebox_buffer *livebox_acquire_buffer(const char *id, int is_pd, int width, int height, int (*handler)(struct livebox_buffer *, enum buffer_event, double, double, double, void *), void *data);
183
184 /*!
185  * \brief Acquire the ID of pixmap resource
186  *        Only if the provider uses pixmap for providing render buffer.
187  * \param[in] handle Buffer handle
188  * \return pixmap ID if succeed or 0lu
189  * \see livebox_acquire_buffer
190  */
191 extern unsigned long livebox_pixmap_id(struct livebox_buffer *handle);
192
193 /*!
194  * \brief
195  * \param[in] handle Buffer handle
196  * \return int
197  * \see livebox_acquire_buffer
198  */
199 extern int livebox_release_buffer(struct livebox_buffer *handle);
200
201 /*!
202  * \brief Get the address of S/W render buffer.
203  *        If you try to use this, after create_hw_buffer, you will get NULL
204  * \param[in] handle Buffer handle
205  * \return void* address of the render buffer
206  * \see livebox_unref_buffer
207  */
208 extern void *livebox_ref_buffer(struct livebox_buffer *handle);
209
210 /*!
211  * \brief Release the S/W render buffer.
212  * \param[in] void* Address of render buffer
213  * \return int 0 if succeed or errno < 0
214  * \see livebox_ref_buffer
215  */
216 extern int livebox_unref_buffer(void *buffer);
217
218 /*!
219  * \brief Sync the updated buffer
220  *        This is only needed for non-H/W accelerated buffer
221  * \param[in] handler Buffer handle
222  * \return int 0 if succeed or errno < 0
223  * \see livebox_acquire_buffer
224  */
225 extern int livebox_sync_buffer(struct livebox_buffer *handle);
226
227 /*!
228  * \brief Request schedule the update operation to a provider.
229  * \param[in] id Livebox Id
230  * \return int 0 if succeed or errno < 0
231  */
232 extern int livebox_request_update(const char *id);
233
234 /*!
235  * \brief Checking wether the livebox support H/W acceleration or not.
236  * \param[in] handle Buffer handle.
237  * \return 1 if support or 0
238  * \see livebox_acquire_buffer
239  */
240 extern int livebox_support_hw_buffer(struct livebox_buffer *handle);
241
242 /*!
243  * \brief Create the H/W accelerated buffer.
244  * \param[in] handle Buffer handle
245  * \return 0 if succeed to create it or errno < 0
246  * \see livebox_support_hw_buffer
247  */
248 extern int livebox_create_hw_buffer(struct livebox_buffer *handle);
249
250 /*!
251  * \brief Destroy the H/W accelerated buffer.
252  * \param[in] handle Buffer handle
253  * \return 0 if succeed to destroy it or errno < 0
254  * \see livebox_create_hw_buffer
255  */
256 extern int livebox_destroy_hw_buffer(struct livebox_buffer *handle);
257
258 /*!
259  * \brief Get the address of accelerated H/W buffer
260  * \param[in] handle Buffer handle
261  * \return void
262  * \see livebox_create_hw_buffer
263  */
264 extern void *livebox_buffer_hw_buffer(struct livebox_buffer *handle);
265
266 /*!
267  * \brief Pre-processing for rendering content.
268  *        This is only needed for accessing H/W accelerated buffer.
269  * \param[in] handle Buffer handle
270  * \return 0 if succeed or errno < 0
271  * \see livebox_support_hw_buffer
272  */
273 extern int livebox_buffer_pre_render(struct livebox_buffer *handle);
274
275 /*!
276  * \brief Post-processing for rendering content.
277  * \param[in] handle Buffer handle
278  * \return 0 if succeed or errno < 0
279  * \see livebox_support_hw_buffer
280  */
281 extern int livebox_buffer_post_render(struct livebox_buffer *handle);
282
283 #ifdef __cplusplus
284 }
285 #endif
286
287 #endif
288 /* End of a file */