slider: fix slider vector logic for supporting slider popup.
[platform/upstream/elementary.git] / src / lib / elm_priv.h
1 #ifndef ELM_PRIV_H
2 #define ELM_PRIV_H
3 #ifdef HAVE_ELEMENTARY_X
4 #include <Ecore_X.h>
5 #endif
6 #ifdef HAVE_ELEMENTARY_FB
7 #include <Ecore_Fb.h>
8 #endif
9 #ifdef HAVE_ELEMENTARY_WAYLAND
10 #include <Ecore_Wayland.h>
11 #endif
12 #ifdef HAVE_ELEMENTARY_DRM
13 #include <Ecore_Drm.h>
14 #endif
15
16 #include <Eio.h>
17
18 #ifdef EAPI
19 # undef EAPI
20 #endif
21
22 #ifdef _WIN32
23 # ifdef ELEMENTARY_BUILD
24 #  ifdef DLL_EXPORT
25 #   define EAPI __declspec(dllexport)
26 #  else
27 #   define EAPI
28 #  endif /* ! DLL_EXPORT */
29 # else
30 #  define EAPI __declspec(dllimport)
31 # endif /* ! EFL_EVAS_BUILD */
32 #else
33 # ifdef __GNUC__
34 #  if __GNUC__ >= 4
35 #   define EAPI __attribute__ ((visibility("default")))
36 #  else
37 #   define EAPI
38 #  endif
39 # else
40 #  define EAPI
41 # endif
42 #endif /* ! _WIN32 */
43
44 #include "elm_widget.h"
45
46 #ifdef HAVE_LANGINFO_H
47 # include <langinfo.h>
48 #endif
49
50 #define CRI(...)      EINA_LOG_DOM_CRIT(_elm_log_dom, __VA_ARGS__)
51 #define ERR(...)      EINA_LOG_DOM_ERR(_elm_log_dom, __VA_ARGS__)
52 #define WRN(...)      EINA_LOG_DOM_WARN(_elm_log_dom, __VA_ARGS__)
53 #define INF(...)      EINA_LOG_DOM_INFO(_elm_log_dom, __VA_ARGS__)
54 #define DBG(...)      EINA_LOG_DOM_DBG(_elm_log_dom, __VA_ARGS__)
55
56 #ifdef ENABLE_NLS
57 # include <libintl.h>
58 # define E_(string)    _elm_dgettext(string)
59 #else
60 # ifndef setlocale
61 #  define setlocale(c, l)
62 # endif
63 # ifndef libintl_setlocale
64 #  define libintl_setlocale(c, l)
65 # endif
66 # ifndef bindtextdomain
67 #  define bindtextdomain(domain, dir)
68 # endif
69 # ifndef libintl_bindtextdomain
70 #  define libintl_bindtextdomain(domain, dir)
71 # endif
72 # define E_(string) (string)
73 #endif
74 #define N_(string) (string)
75
76 typedef struct _Elm_Theme_Files          Elm_Theme_Files;
77 typedef struct _Edje_Signal_Data         Edje_Signal_Data;
78 typedef struct _Elm_Config               Elm_Config;
79 typedef struct _Elm_Config_Bindings_Widget   Elm_Config_Bindings_Widget;
80 typedef struct _Elm_Config_Binding_Key   Elm_Config_Binding_Key;
81 typedef struct _Elm_Config_Binding_Modifier  Elm_Config_Binding_Modifier;
82 typedef struct _Elm_Module               Elm_Module;
83
84 struct _Edje_Signal_Data
85 {
86    Evas_Object   *obj;
87    Edje_Signal_Cb func;
88    const char    *emission;
89    const char    *source;
90    void          *data;
91 };
92
93 struct _Elm_Theme_Files
94 {
95    /*
96     * We are conserving a list of path even if that's duplicated
97     * because we expose those directly to the outside world :'(
98     */
99    Eina_List *items;
100    Eina_List *handles;
101 };
102
103 struct _Elm_Theme
104 {
105    Elm_Theme_Files overlay;
106    Elm_Theme_Files themes;
107    Elm_Theme_Files extension;
108
109    Eina_Hash  *cache;
110    Eina_Hash  *cache_data;
111    Elm_Theme  *ref_theme;
112    Eina_List  *referrers;
113    const char *theme;
114    int         ref;
115    Eina_Hash  *cache_style_load_failed;
116 };
117
118 /* increment this whenever we change config enough that you need new
119  * defaults for elm to work.
120  */
121 #define ELM_CONFIG_EPOCH           0x0002
122 /* increment this whenever a new set of config values are added but
123  * the users config doesn't need to be wiped - simply new values need
124  * to be put in
125  */
126 #define ELM_CONFIG_FILE_GENERATION 0x0001
127 #define ELM_CONFIG_VERSION_EPOCH_OFFSET 16
128 #define ELM_CONFIG_VERSION         ((ELM_CONFIG_EPOCH << ELM_CONFIG_VERSION_EPOCH_OFFSET) | \
129                                     ELM_CONFIG_FILE_GENERATION)
130 /* NB: profile configuration files (.src) must have their
131  * "config_version" entry's value up-to-date with ELM_CONFIG_VERSION
132  * (in decimal)!! */
133
134 /* note: always remember to sync it with elm_config.c */
135 extern const char *_elm_engines[];
136
137 #define ELM_SOFTWARE_X11      (_elm_engines[0])
138 #define ELM_SOFTWARE_FB       (_elm_engines[1])
139 #define ELM_OPENGL_X11        (_elm_engines[2])
140 #define ELM_SOFTWARE_WIN32    (_elm_engines[3])
141 #define ELM_SOFTWARE_SDL      (_elm_engines[4])
142 #define ELM_OPENGL_SDL        (_elm_engines[5])
143 #define ELM_BUFFER            (_elm_engines[6])
144 #define ELM_EWS               (_elm_engines[7])
145 #define ELM_OPENGL_COCOA      (_elm_engines[8])
146 #define ELM_SOFTWARE_PSL1GHT  (_elm_engines[9])
147 #define ELM_WAYLAND_SHM       (_elm_engines[10])
148 #define ELM_WAYLAND_EGL       (_elm_engines[11])
149 #define ELM_DRM               (_elm_engines[12])
150 #define ELM_SOFTWARE_DDRAW    (_elm_engines[13])
151
152 #define ELM_FONT_TOKEN_STYLE  ":style="
153
154 #define ELM_ACCESS_MODE_OFF   EINA_FALSE
155 #define ELM_ACCESS_MODE_ON    EINA_TRUE
156
157 #define ELM_ATSPI_MODE_OFF   EINA_FALSE
158 #define ELM_ATSPI_MODE_ON    EINA_TRUE
159
160 /* convenience macro to compress code and avoid typos */
161 #undef MIN
162 #define MIN(x, y) (((x) < (y)) ? (x) : (y))
163 #undef MAX
164 #define MAX(x, y) (((x) > (y)) ? (x) : (y))
165 #undef CEIL
166 #define CEIL(a)   (((a) % 2 != 0) ? ((a) / 2 + 1) : ((a) / 2))
167
168
169 #define ELM_SAFE_FREE(_h, _fn) do { _fn((void*)_h); _h = NULL; } while (0)
170
171 #define ELM_PRIV_STATIC_VARIABLE_DECLARE(name, signal, type) \
172    static const char name[] = signal;
173
174 #define ELM_PRIV_SMART_CALLBACKS_DESC(name, signal, type) \
175    {name, type},
176
177 struct _Elm_Config
178 {
179    int           config_version;
180    const char   *engine;
181    const char   *accel;
182    unsigned char accel_override;
183    unsigned char vsync;
184    unsigned char thumbscroll_enable;
185    int           thumbscroll_threshold;
186    int           thumbscroll_hold_threshold;
187    double        thumbscroll_momentum_threshold;
188    int           thumbscroll_flick_distance_tolerance;
189    double        thumbscroll_friction;
190    double        thumbscroll_min_friction;
191    double        thumbscroll_friction_standard;
192    double        thumbscroll_bounce_friction;
193    double        thumbscroll_acceleration_threshold;
194    double        thumbscroll_acceleration_time_limit;
195    double        thumbscroll_acceleration_weight;
196    double        page_scroll_friction;
197    double        bring_in_scroll_friction;
198    double        zoom_friction;
199    unsigned char thumbscroll_bounce_enable;
200    double        thumbscroll_border_friction;
201    double        thumbscroll_sensitivity_friction;
202    unsigned char scroll_smooth_start_enable;
203    double        scroll_smooth_time_interval;
204    double        scroll_smooth_amount;
205    double        scroll_smooth_history_weight;
206    double        scroll_smooth_future_time;
207    double        scroll_smooth_time_window;
208    double        scale;
209    int           win_no_border;
210    int           bgpixmap;
211    int           compositing;
212    Eina_List    *font_dirs;
213    Eina_List    *font_overlays;
214    int           font_hinting;
215    int           cache_flush_poll_interval;
216    unsigned char cache_flush_enable;
217    int           image_cache;
218    int           font_cache;
219    int           edje_cache;
220    int           edje_collection_cache;
221    int           finger_size;
222    double        fps;
223    const char   *theme;
224    const char   *modules;
225    double        tooltip_delay;
226    unsigned char cursor_engine_only;
227    unsigned char focus_highlight_enable;
228    unsigned char focus_highlight_animate;
229    unsigned char focus_highlight_clip_disable; /**< This shows disabled status of focus highlight clip feature. This value is false by default so the focus highlight is clipped. */
230    unsigned char focus_move_policy; /**< This show how the elementary focus is moved to another object. Focus can be moved by click or mouse_in. */
231    unsigned char item_select_on_focus_disable; /**< This shows the disabled status of select on focus feature. This value is false by default so that select on focus feature is enabled by default.*/
232    unsigned char first_item_focus_on_first_focus_in;  /**< This sets the first item focus on first focus in feature*/
233    Elm_Focus_Autoscroll_Mode focus_autoscroll_mode; /**< This shows the focus auto scroll mode. By default, @c ELM_FOCUS_AUTOSCROLL_MODE_SHOW is set. */
234    Elm_Slider_Indicator_Visible_Mode  slider_indicator_visible_mode;  /**< this sets the slider indicator visible mode */
235    int           toolbar_shrink_mode;
236    unsigned char fileselector_expand_enable;
237    unsigned char fileselector_double_tap_navigation_enable;
238    unsigned char inwin_dialogs_enable;
239    int           icon_size;
240    double        longpress_timeout;
241    unsigned char effect_enable;
242    unsigned char desktop_entry;
243    unsigned char password_show_last;
244    double        password_show_last_timeout;
245    unsigned char glayer_zoom_finger_enable;
246    double        glayer_zoom_finger_factor;
247    double        glayer_zoom_wheel_factor;
248    double        glayer_zoom_distance_tolerance;
249    double        glayer_rotate_finger_enable;
250    double        glayer_rotate_angular_tolerance;
251    double        glayer_line_min_length;
252    double        glayer_line_distance_tolerance;
253    double        glayer_line_angular_tolerance;
254    unsigned int  glayer_flick_time_limit_ms;
255    double        glayer_long_tap_start_timeout;
256    double        glayer_double_tap_timeout;
257    Eina_Bool     access_mode;
258    unsigned char glayer_continues_enable;
259    int           week_start;
260    int           weekend_start;
261    int           weekend_len;
262    int           year_min;
263    int           year_max;
264    Eina_List    *color_overlays;
265    Eina_List    *color_palette;
266    unsigned char softcursor_mode;
267    unsigned char auto_norender_withdrawn;
268    unsigned char auto_norender_iconified_same_as_withdrawn;
269    unsigned char auto_flush_withdrawn;
270    unsigned char auto_dump_withdrawn;
271    unsigned char auto_throttle;
272    double        auto_throttle_amount;
273    const char   *indicator_service_0;
274    const char   *indicator_service_90;
275    const char   *indicator_service_180;
276    const char   *indicator_service_270;
277    unsigned char selection_clear_enable;
278    unsigned char disable_external_menu;
279    unsigned char clouseau_enable;
280    unsigned char magnifier_enable;
281    double        magnifier_scale;
282    unsigned char audio_mute_effect;
283    unsigned char audio_mute_background;
284    unsigned char audio_mute_music;
285    unsigned char audio_mute_foreground;
286    unsigned char audio_mute_interface;
287    unsigned char audio_mute_input;
288    unsigned char audio_mute_alert;
289    unsigned char audio_mute_all;
290    Eina_List    *bindings;
291    Eina_Bool     atspi_mode;
292
293    /* Not part of the EET file */
294    Eina_Bool     is_mirrored : 1;
295    Eina_Bool     translate : 1;
296 };
297
298 struct _Elm_Config_Bindings_Widget
299 {
300    const char   *name;
301    Eina_List    *key_bindings;
302 };
303
304 struct _Elm_Config_Binding_Key
305 {
306    int           context;
307    const char   *key;
308    const char   *action;
309    const char   *params;
310    Eina_List    *modifiers;
311 };
312
313 struct _Elm_Config_Binding_Modifier
314 {
315    const char   *mod;
316    unsigned char flag;
317 };
318
319 struct _Elm_Module
320 {
321    int          version;
322    const char  *name;
323    const char  *as;
324    const char  *so_path;
325    const char  *data_dir;
326    const char  *bin_dir;
327    Eina_Module *module;
328    void        *data;
329    void        *api;
330    int          (*init_func)(Elm_Module *m);
331    int          (*shutdown_func)(Elm_Module *m);
332    int          references;
333 };
334
335 Eo                   *_elm_atspi_bridge_root_get(void);
336 void                 _elm_atspi_bridge_init(void);
337 void                 _elm_atspi_bridge_shutdown(void);
338
339 void                 _elm_prefs_init(void);
340 void                 _elm_prefs_shutdown(void);
341
342 /* these already issued by the two above, respectively */
343 void                 _elm_prefs_data_init(void);
344 void                 _elm_prefs_data_shutdown(void);
345
346 void                 _elm_emotion_init(void);
347 void                 _elm_emotion_shutdown(void);
348
349 int                  _elm_ews_wm_init(void);
350 void                 _elm_ews_wm_shutdown(void);
351 void                 _elm_ews_wm_rescale(Elm_Theme *th,
352                                          Eina_Bool use_theme);
353
354 void                 _elm_win_shutdown(void);
355 void                 _elm_win_rescale(Elm_Theme *th,
356                                       Eina_Bool use_theme);
357 void                 _elm_win_access(Eina_Bool is_access);
358 void                 _elm_win_translate(void);
359
360 Ecore_X_Window       _elm_ee_xwin_get(const Ecore_Evas *ee);
361
362 Eina_Bool            _elm_theme_object_set(Evas_Object *parent,
363                                            Evas_Object *o,
364                                            const char *clas,
365                                            const char *group,
366                                            const char *style);
367 Eina_Bool            _elm_theme_object_icon_set(Evas_Object *o,
368                                                 const char *group,
369                                                 const char *style);
370 Eina_Bool            _elm_theme_set(Elm_Theme *th,
371                                     Evas_Object *o,
372                                     const char *clas,
373                                     const char *group,
374                                     const char *style);
375 Eina_Bool            _elm_theme_icon_set(Elm_Theme *th,
376                                          Evas_Object *o,
377                                          const char *group,
378                                          const char *style);
379 Eina_Bool            _elm_theme_parse(Elm_Theme *th,
380                                       const char *theme);
381 void                 _elm_theme_shutdown(void);
382
383 void                 _elm_module_init(void);
384 void                 _elm_module_shutdown(void);
385 void                 _elm_module_parse(const char *s);
386 Elm_Module          *_elm_module_find_as(const char *as);
387 Elm_Module          *_elm_module_add(const char *name,
388                                      const char *as);
389 void                 _elm_module_del(Elm_Module *m);
390 Eina_Bool            _elm_module_load(Elm_Module *m);
391 void                 _elm_module_unload(Elm_Module *m);
392 const void          *_elm_module_symbol_get(Elm_Module *m,
393                                             const char *name);
394
395 void                 _elm_widget_top_win_focused_set(Evas_Object *obj,
396                                                      Eina_Bool top_win_focused);
397 Eina_Bool            _elm_widget_top_win_focused_get(const Evas_Object *obj);
398
399 void                 _elm_unneed_systray(void);
400 void                 _elm_unneed_sys_notify(void);
401 void                 _elm_unneed_ethumb(void);
402 void                 _elm_unneed_web(void);
403
404 void                 _elm_rescale(void);
405 Eina_Bool            _elm_clouseau_reload(void);
406
407 void                 _elm_config_init(void);
408 void                 _elm_config_sub_init(void);
409 void                 _elm_config_shutdown(void);
410 void                 _elm_config_sub_shutdown(void);
411 Eina_Bool            _elm_config_save(void);
412 void                 _elm_config_reload(void);
413 size_t               _elm_config_user_dir_snprintf(char *dst, size_t size,
414                                                    const char *fmt, ...)
415                                                    EINA_PRINTF(3, 4);
416
417 void                 _elm_recache(void);
418
419 const char          *_elm_config_current_profile_get(void);
420 const char          *_elm_config_profile_dir_get(const char *prof,
421                                                  Eina_Bool is_user);
422 Eina_List           *_elm_config_profiles_list(void);
423 void                 _elm_config_all_update(void);
424 void                 _elm_config_profile_set(const char *profile);
425
426 void                 _elm_config_engine_set(const char *engine);
427
428 Eina_List           *_elm_config_font_overlays_list(void);
429 void                 _elm_config_font_overlay_set(const char *text_class,
430                                                   const char *font,
431                                                   Evas_Font_Size size);
432 void                 _elm_config_font_overlay_remove(const char *text_class);
433 void                 _elm_config_font_overlay_apply(void);
434 Eina_List           *_elm_config_text_classes_get(void);
435 void                 _elm_config_text_classes_free(Eina_List *l);
436
437 Eina_List           *_elm_config_color_classes_get(void);
438 void                 _elm_config_color_classes_free(Eina_List *l);
439 Eina_List           *_elm_config_color_overlays_list(void);
440 void                 _elm_config_color_overlay_set(const char *color_class,
441                                                    int r, int g, int b, int a,
442                                                    int r2, int g2, int b2, int a2,
443                                                    int r3, int g3, int b3, int a3);
444 void                 _elm_config_color_overlay_remove(const char *color_class);
445 void                 _elm_config_color_overlay_apply(void);
446
447 Eina_Bool            _elm_config_access_get(void);
448 void                 _elm_config_access_set(Eina_Bool is_access);
449
450 Eina_Bool            _elm_config_key_binding_call(Evas_Object *obj,
451                                                   const Evas_Event_Key_Down *ev,
452                                                   const Elm_Action *actions);
453
454 Elm_Font_Properties *_elm_font_properties_get(Eina_Hash **font_hash,
455                                               const char *font);
456 Eina_Hash           *_elm_font_available_hash_add(Eina_Hash *font_hash,
457                                                   const char *full_name);
458 void                 _elm_font_available_hash_del(Eina_Hash *hash);
459
460 void                 elm_tooltip_theme(Elm_Tooltip *tt);
461 void                 elm_object_sub_tooltip_content_cb_set(Evas_Object *eventarea,
462                                                            Evas_Object *owner,
463                                                            Elm_Tooltip_Content_Cb func,
464                                                            const void *data,
465                                                            Evas_Smart_Cb del_cb);
466 void                 elm_cursor_theme(Elm_Cursor *cur);
467 void                 elm_object_sub_cursor_set(Evas_Object *eventarea,
468                                                Evas_Object *owner,
469                                                const char *cursor);
470
471 void                 elm_menu_clone(Evas_Object *from_menu,
472                                     Evas_Object *to_menu,
473                                     Elm_Object_Item *parent);
474
475 char                *_elm_util_mkup_to_text(const char *mkup);
476 char                *_elm_util_text_to_mkup(const char *text);
477
478 Eina_Bool            _elm_video_check(Evas_Object *video);
479
480 Eina_List           *_elm_config_color_list_get(const char *palette_name);
481 void                 _elm_config_color_set(const char *palette_name,
482                                            int r,
483                                            int g,
484                                            int b,
485                                            int a);
486 void                 _elm_config_colors_free(const char *palette_name);
487
488 typedef struct _Elm_DBus_Menu Elm_DBus_Menu;
489
490 const char          *_elm_dbus_menu_register(Eo *obj);
491 void                 _elm_dbus_menu_unregister(Eo *obj);
492 int                  _elm_dbus_menu_item_add(Elm_DBus_Menu *dbus_menu,
493                                              Elm_Object_Item *item);
494 void                 _elm_dbus_menu_update(Elm_DBus_Menu *dbus_menu);
495 void                 _elm_dbus_menu_item_delete(Elm_DBus_Menu *dbus_menu,
496                                                 int id);
497
498 void                 _elm_dbus_menu_app_menu_register(Ecore_X_Window xid, Eo *obj,
499                                                       void (*result_cb)(Eina_Bool, void *),
500                                                       void *data);
501 void                 _elm_dbus_menu_app_menu_unregister(Eo *obj);
502 void                 _elm_dbus_menu_item_select_cb(Elm_Object_Item *obj_item);
503
504 void                 _elm_menu_menu_bar_set(Eo *obj, Eina_Bool menu_bar);
505 void                 _elm_menu_menu_bar_hide(Eo *obj);
506
507 /* DEPRECATED, will be removed on next release */
508 void                 _elm_icon_signal_emit(Evas_Object *obj,
509                                            const char *emission,
510                                            const char *source);
511 void                 _elm_icon_signal_callback_add(Evas_Object *obj,
512                                                    const char *emission,
513                                                    const char *source,
514                                                    Edje_Signal_Cb func_cb,
515                                                    void *data);
516 void                *_elm_icon_signal_callback_del(Evas_Object *obj,
517                                                    const char *emission,
518                                                    const char *source,
519                                                    Edje_Signal_Cb func_cb);
520 /* end of DEPRECATED */
521
522
523 /* Elm helper to download content */
524 typedef struct _Elm_Url Elm_Url;
525
526 typedef void (*Elm_Url_Done)(void *data, Elm_Url *url, Eina_Binbuf *download);
527 typedef void (*Elm_Url_Cancel)(void *data, Elm_Url *url, int error);
528 typedef void (*Elm_Url_Progress)(void *data, Elm_Url *url, double now, double total);
529
530 Elm_Url *_elm_url_download(const char *url, Elm_Url_Done done_cb, Elm_Url_Cancel cancel_cb, Elm_Url_Progress progress_cb, const void *data);
531 void _elm_url_cancel(Elm_Url *r);
532 const char *_elm_url_get(Elm_Url *r);
533
534 extern char *_elm_appname;
535 extern Elm_Config *_elm_config;
536 extern const char *_elm_data_dir;
537 extern const char *_elm_lib_dir;
538 extern int _elm_log_dom;
539 extern Eina_List *_elm_win_list;
540 extern int _elm_win_deferred_free;
541 extern const char *_elm_preferred_engine;
542 extern const char *_elm_accel_preference;
543 extern const char SIG_WIDGET_FOCUSED[];
544 extern const char SIG_WIDGET_UNFOCUSED[];
545 extern const char SIG_WIDGET_LANG_CHANGED[];
546 extern const char SIG_WIDGET_ACCESS_CHANGED[];
547 extern const char SIG_LAYOUT_FOCUSED[];
548 extern const char SIG_LAYOUT_UNFOCUSED[];
549
550 #ifdef ENABLE_NLS
551 /* Our gettext wrapper, used to disable translation of elm if the app
552  * is not translated. */
553 static inline const char *
554 _elm_dgettext(const char *string)
555 {
556    if (EINA_UNLIKELY(_elm_config->translate == EINA_FALSE))
557      {
558         return string;
559      }
560
561    return dgettext(PACKAGE, string);
562 }
563
564 #endif
565
566 /* Used by the paste handler */
567 void   _elm_entry_entry_paste(Evas_Object *obj, const char *entry);
568
569 double _elm_atof(const char *s);
570
571 #define TIZEN_VECTOR_UX 1
572
573 #ifdef TIZEN_VECTOR_UX
574 void tizen_vg_button_set(Elm_Button *obj);
575 void tizen_vg_check_set(Elm_Check *obj);
576 void tizen_vg_radio_set(Elm_Radio *obj);
577 void tizen_vg_progressbar_set(Elm_Progressbar *obj);
578 void tizen_vg_slider_set(Elm_Slider *obj, Evas_Object *popup);
579 void tizen_vg_check_state_set(Elm_Check *obj);
580 #endif
581
582
583
584 #endif