aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/elementary/src/lib/elm_separator.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--libraries/elementary/src/lib/elm_separator.c106
1 files changed, 106 insertions, 0 deletions
diff --git a/libraries/elementary/src/lib/elm_separator.c b/libraries/elementary/src/lib/elm_separator.c
new file mode 100644
index 0000000..e852d5e
--- /dev/null
+++ b/libraries/elementary/src/lib/elm_separator.c
@@ -0,0 +1,106 @@
1#include <Elementary.h>
2#include "elm_priv.h"
3
4typedef struct _Widget_Data Widget_Data;
5
6struct _Widget_Data
7{
8 Evas_Object *sep;
9 Eina_Bool horizontal;
10};
11
12static const char *widtype = NULL;
13static void _del_hook(Evas_Object *obj);
14static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
15static void _theme_hook(Evas_Object *obj);
16static void _sizing_eval(Evas_Object *obj);
17
18static void
19_del_hook(Evas_Object *obj)
20{
21 Widget_Data *wd = elm_widget_data_get(obj);
22 if (!wd) return;
23 free(wd);
24}
25
26static void
27_mirrored_set(Evas_Object *obj, Eina_Bool rtl)
28{
29 Widget_Data *wd = elm_widget_data_get(obj);
30 if (!wd) return;
31 edje_object_mirrored_set(wd->sep, rtl);
32}
33
34static void
35_theme_hook(Evas_Object *obj)
36{
37 Widget_Data *wd = elm_widget_data_get(obj);
38 if (!wd) return;
39 _elm_widget_mirrored_reload(obj);
40 _mirrored_set(obj, elm_widget_mirrored_get(obj));
41 if (wd->horizontal)
42 _elm_theme_object_set(obj, wd->sep, "separator", "horizontal", elm_widget_style_get(obj));
43 else
44 _elm_theme_object_set(obj, wd->sep, "separator", "vertical", elm_widget_style_get(obj));
45 edje_object_scale_set(wd->sep, elm_widget_scale_get(obj) * _elm_config->scale);
46 _sizing_eval(obj);
47}
48
49static void
50_sizing_eval(Evas_Object *obj)
51{
52 Widget_Data *wd = elm_widget_data_get(obj);
53 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
54 if (!wd) return;
55 edje_object_size_min_calc(wd->sep, &minw, &minh);
56 evas_object_size_hint_min_set(obj, minw, minh);
57 evas_object_size_hint_max_set(obj, maxw, maxh);
58 evas_object_size_hint_align_set(obj, maxw, maxh);
59}
60
61EAPI Evas_Object *
62elm_separator_add(Evas_Object *parent)
63{
64 Evas_Object *obj;
65 Evas *e;
66 Widget_Data *wd;
67
68 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
69
70 ELM_SET_WIDTYPE(widtype, "separator");
71 wd->horizontal = EINA_FALSE;
72 elm_widget_type_set(obj, "separator");
73 elm_widget_sub_object_add(parent, obj);
74 elm_widget_data_set(obj, wd);
75 elm_widget_del_hook_set(obj, _del_hook);
76 elm_widget_theme_hook_set(obj, _theme_hook);
77 elm_widget_can_focus_set(obj, EINA_FALSE);
78
79 wd->sep = edje_object_add(e);
80 _elm_theme_object_set(obj, wd->sep, "separator", "vertical", "default");
81 elm_widget_resize_object_set(obj, wd->sep);
82 _mirrored_set(obj, elm_widget_mirrored_get(obj));
83 _sizing_eval(obj);
84 return obj;
85}
86
87EAPI void
88elm_separator_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
89{
90 ELM_CHECK_WIDTYPE(obj, widtype);
91 Widget_Data *wd = elm_widget_data_get(obj);
92 if (!wd) return;
93 horizontal = !!horizontal;
94 if (wd->horizontal == horizontal) return;
95 wd->horizontal = horizontal;
96 _theme_hook(obj);
97}
98
99EAPI Eina_Bool
100elm_separator_horizontal_get(const Evas_Object *obj)
101{
102 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
103 Widget_Data *wd = elm_widget_data_get(obj);
104 if (!wd) return EINA_FALSE;
105 return wd->horizontal;
106}