1 #include <Elementary.h>
5 * @defgroup Separator Separator
7 * A separator is a widget that adds a very thin object to separate other
9 * A separator can be vertical or horizontal.
12 typedef struct _Widget_Data Widget_Data;
20 static const char *widtype = NULL;
21 static void _del_hook(Evas_Object *obj);
22 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
23 static void _theme_hook(Evas_Object *obj);
24 static void _sizing_eval(Evas_Object *obj);
27 _del_hook(Evas_Object *obj)
29 Widget_Data *wd = elm_widget_data_get(obj);
35 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
37 Widget_Data *wd = elm_widget_data_get(obj);
39 edje_object_mirrored_set(wd->sep, rtl);
43 _theme_hook(Evas_Object *obj)
45 Widget_Data *wd = elm_widget_data_get(obj);
47 _elm_widget_mirrored_reload(obj);
48 _mirrored_set(obj, elm_widget_mirrored_get(obj));
50 _elm_theme_object_set(obj, wd->sep, "separator", "horizontal", elm_widget_style_get(obj));
52 _elm_theme_object_set(obj, wd->sep, "separator", "vertical", elm_widget_style_get(obj));
53 edje_object_scale_set(wd->sep, elm_widget_scale_get(obj) * _elm_config->scale);
58 _sizing_eval(Evas_Object *obj)
60 Widget_Data *wd = elm_widget_data_get(obj);
61 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
63 edje_object_size_min_calc(wd->sep, &minw, &minh);
64 evas_object_size_hint_min_set(obj, minw, minh);
65 evas_object_size_hint_max_set(obj, maxw, maxh);
66 evas_object_size_hint_align_set(obj, maxw, maxh);
70 * Add a separator object to @p parent
72 * @param parent The parent object
74 * @return The separator object, or NULL upon failure
79 elm_separator_add(Evas_Object *parent)
85 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
87 ELM_SET_WIDTYPE(widtype, "separator");
88 wd->horizontal = EINA_FALSE;
89 elm_widget_type_set(obj, "separator");
90 elm_widget_sub_object_add(parent, obj);
91 elm_widget_data_set(obj, wd);
92 elm_widget_del_hook_set(obj, _del_hook);
93 elm_widget_theme_hook_set(obj, _theme_hook);
94 elm_widget_can_focus_set(obj, EINA_FALSE);
96 wd->sep = edje_object_add(e);
97 _elm_theme_object_set(obj, wd->sep, "separator", "vertical", "default");
98 elm_widget_resize_object_set(obj, wd->sep);
99 _mirrored_set(obj, elm_widget_mirrored_get(obj));
105 * Set the horizontal mode of a separator object
107 * @param obj The separator object
108 * @param horizontal If true, the separator is horizontal
113 elm_separator_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
115 ELM_CHECK_WIDTYPE(obj, widtype);
116 Widget_Data *wd = elm_widget_data_get(obj);
118 horizontal = !!horizontal;
119 if (wd->horizontal == horizontal) return;
120 wd->horizontal = horizontal;
125 * Get the horizontal mode of a separator object
127 * @param obj The separator object
128 * @return If true, the separator is horizontal
133 elm_separator_horizontal_get(const Evas_Object *obj)
135 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
136 Widget_Data *wd = elm_widget_data_get(obj);
137 if (!wd) return EINA_FALSE;
138 return wd->horizontal;