1 #include "private.h"
2 
3 static Evas_Object *
elm_prefs_vertical_frame_add(const Elm_Prefs_Page_Iface * iface EINA_UNUSED,Evas_Object * prefs)4 elm_prefs_vertical_frame_add(const Elm_Prefs_Page_Iface *iface EINA_UNUSED,
5                              Evas_Object *prefs)
6 {
7    Evas_Object *bx, *obj = elm_frame_add(prefs);
8 
9    bx = elm_box_add(obj);
10    evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
11    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
12 
13    elm_layout_content_set(obj, NULL, bx);
14 
15    evas_object_data_set(obj, "bx_container", bx);
16 
17    return obj;
18 }
19 
20 static Eina_Bool
elm_prefs_vertical_frame_title_set(Evas_Object * obj,const char * title)21 elm_prefs_vertical_frame_title_set(Evas_Object *obj,
22                                    const char *title)
23 {
24    elm_layout_text_set(obj, NULL, title);
25 
26    return EINA_TRUE;
27 }
28 
29 static Eina_Bool
elm_prefs_vertical_frame_item_pack(Evas_Object * obj,Evas_Object * it,const Elm_Prefs_Item_Type type,const Elm_Prefs_Item_Iface * iface)30 elm_prefs_vertical_frame_item_pack(Evas_Object *obj,
31                                    Evas_Object *it,
32                                    const Elm_Prefs_Item_Type type,
33                                    const Elm_Prefs_Item_Iface *iface)
34 {
35    Evas_Object *l, *bx = evas_object_data_get(obj, "bx_container");
36 
37    if ((type == ELM_PREFS_TYPE_SEPARATOR) &&
38        (!elm_prefs_page_item_value_set(it, iface, EINA_TRUE)))
39      return EINA_FALSE;
40 
41    l = evas_object_data_get(it, "label_widget");
42    if (l)
43      evas_object_size_hint_align_set(l, 0.0, 1.0);
44 
45    elm_prefs_vertical_page_common_pack(it, bx, iface);
46 
47    return EINA_TRUE;
48 }
49 
50 static Eina_Bool
elm_prefs_vertical_frame_item_unpack(Evas_Object * obj,Evas_Object * it)51 elm_prefs_vertical_frame_item_unpack(Evas_Object *obj,
52                                      Evas_Object *it)
53 {
54    Evas_Object *bx = evas_object_data_get(obj, "bx_container");
55 
56    /* back to defaults */
57    evas_object_size_hint_align_set(it, 0.5, 0.5);
58    evas_object_size_hint_weight_set(it, 0.0, 0.0);
59 
60    elm_prefs_page_common_unpack(it, bx);
61 
62    return EINA_TRUE;
63 }
64 
65 
66 static Eina_Bool
elm_prefs_vertical_frame_item_pack_before(Evas_Object * obj,Evas_Object * it,Evas_Object * it_before,const Elm_Prefs_Item_Type type,const Elm_Prefs_Item_Iface * iface)67 elm_prefs_vertical_frame_item_pack_before(Evas_Object *obj,
68                                           Evas_Object *it,
69                                           Evas_Object *it_before,
70                                           const Elm_Prefs_Item_Type type,
71                                           const Elm_Prefs_Item_Iface *iface)
72 {
73    Evas_Object *l, *bx = evas_object_data_get(obj, "bx_container");
74 
75    if ((type == ELM_PREFS_TYPE_SEPARATOR) &&
76        (!elm_prefs_page_item_value_set(it, iface, EINA_TRUE)))
77      return EINA_FALSE;
78 
79    l = evas_object_data_get(it, "label_widget");
80    if (l)
81      evas_object_size_hint_align_set(l, 0.0, 1.0);
82 
83    elm_prefs_vertical_page_common_pack_before(it, it_before, bx, iface);
84 
85    return EINA_TRUE;
86 }
87 
88 static Eina_Bool
elm_prefs_vertical_frame_item_pack_after(Evas_Object * obj,Evas_Object * it,Evas_Object * it_after,const Elm_Prefs_Item_Type type,const Elm_Prefs_Item_Iface * iface)89 elm_prefs_vertical_frame_item_pack_after(Evas_Object *obj,
90                                          Evas_Object *it,
91                                          Evas_Object *it_after,
92                                          const Elm_Prefs_Item_Type type,
93                                          const Elm_Prefs_Item_Iface *iface)
94 {
95    Evas_Object *l, *bx = evas_object_data_get(obj, "bx_container");
96 
97    if ((type == ELM_PREFS_TYPE_SEPARATOR) &&
98        (!elm_prefs_page_item_value_set(it, iface, EINA_TRUE)))
99      return EINA_FALSE;
100 
101    l = evas_object_data_get(it, "label_widget");
102    if (l)
103      evas_object_size_hint_align_set(l, 0.0, 1.0);
104 
105    elm_prefs_vertical_page_common_pack_after(it, it_after, bx, iface);
106 
107    return EINA_TRUE;
108 }
109 
110 PREFS_PAGE_WIDGET_ADD(vertical_frame,
111                       elm_prefs_vertical_frame_title_set,
112                       NULL,
113                       NULL,
114                       elm_prefs_vertical_frame_item_pack,
115                       elm_prefs_vertical_frame_item_unpack,
116                       elm_prefs_vertical_frame_item_pack_before,
117                       elm_prefs_vertical_frame_item_pack_after);
118