1 #include <Elementary.h>
5 * @defgroup Separator Separator
7 * A separator is a widget that adds a very thin object to separate other objects.
8 * A separator can be vertical or horizontal.
11 typedef struct _Widget_Data Widget_Data;
19 static const char *widtype = NULL;
20 static void _del_hook(Evas_Object *obj);
21 static void _theme_hook(Evas_Object *obj);
22 static void _sizing_eval(Evas_Object *obj);
25 _del_hook(Evas_Object *obj)
27 Widget_Data *wd = elm_widget_data_get(obj);
33 _theme_hook(Evas_Object *obj)
35 Widget_Data *wd = elm_widget_data_get(obj);
38 _elm_theme_object_set(obj, wd->sep, "separator", "horizontal", elm_widget_style_get(obj));
40 _elm_theme_object_set(obj, wd->sep, "separator", "vertical", elm_widget_style_get(obj));
41 edje_object_scale_set(wd->sep, elm_widget_scale_get(obj) * _elm_config->scale);
46 _sizing_eval(Evas_Object *obj)
48 Widget_Data *wd = elm_widget_data_get(obj);
49 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
51 edje_object_size_min_calc(wd->sep, &minw, &minh);
52 evas_object_size_hint_min_set(obj, minw, minh);
53 evas_object_size_hint_max_set(obj, maxw, maxh);
54 evas_object_size_hint_align_set(obj, maxw, maxh);
58 * Add a separator object to @p parent
60 * @param parent The parent object
62 * @return The separator object, or NULL upon failure
67 elm_separator_add(Evas_Object *parent)
73 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
75 wd = ELM_NEW(Widget_Data);
76 e = evas_object_evas_get(parent);
78 obj = elm_widget_add(e);
79 ELM_SET_WIDTYPE(widtype, "separator");
80 wd->horizontal = EINA_FALSE;
81 elm_widget_type_set(obj, "separator");
82 elm_widget_sub_object_add(parent, obj);
83 elm_widget_data_set(obj, wd);
84 elm_widget_del_hook_set(obj, _del_hook);
85 elm_widget_theme_hook_set(obj, _theme_hook);
86 elm_widget_can_focus_set(obj, EINA_FALSE);
88 wd->sep = edje_object_add(e);
89 _elm_theme_object_set(obj, wd->sep, "separator", "vertical", "default");
90 elm_widget_resize_object_set(obj, wd->sep);
96 * Set the horizontal mode of a separator object
98 * @param obj The separator object
99 * @param horizontal If true, the separator is horizontal
104 elm_separator_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
106 ELM_CHECK_WIDTYPE(obj, widtype);
107 Widget_Data *wd = elm_widget_data_get(obj);
109 horizontal = !!horizontal;
110 if (wd->horizontal == horizontal) return;
111 wd->horizontal = horizontal;
116 * Get the horizontal mode of a separator object
118 * @param obj The separator object
119 * @return If true, the separator is horizontal
124 elm_separator_horizontal_get(const Evas_Object *obj)
126 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
127 Widget_Data *wd = elm_widget_data_get(obj);
128 if (!wd) return EINA_FALSE;
129 return wd->horizontal;