ecef90c7d2932a4fc975bb57ff9b7d02690f9ddb
[platform/upstream/elementary.git] / src / lib / elm_widget_popup.h
1 #ifndef ELM_WIDGET_POPUP_H
2 #define ELM_WIDGET_POPUP_H
3
4 #include "Elementary.h"
5 #include "elm_widget_layout.h"
6
7 /* DO NOT USE THIS HEADER UNLESS YOU ARE PREPARED FOR BREAKING OF YOUR
8  * CODE. THIS IS ELEMENTARY'S INTERNAL WIDGET API (for now) AND IS NOT
9  * FINAL. CALL elm_widget_api_check(ELM_INTERNAL_API_VERSION) TO CHECK
10  * IT AT RUNTIME.
11  */
12
13 /**
14  * @internal
15  * @addtogroup Widget
16  * @{
17  *
18  * @section elm-popup-class The Elementary Popup Class
19  *
20  * Elementary, besides having the @ref Elm_Popup widget, exposes its
21  * foundation -- the Elementary Popup Class -- in order to create other
22  * widgets which are a popup with some more logic on top.
23  */
24
25 #define ELM_POPUP_ACTION_BUTTON_MAX 3
26
27 typedef struct _Action_Area_Data Action_Area_Data;
28
29 /**
30  * Base layout smart data extended with popup instance data.
31  */
32 typedef struct _Elm_Popup_Data Elm_Popup_Data;
33 struct _Elm_Popup_Data
34 {
35    Evas_Object          *notify;
36    Evas_Object          *main_layout;
37    Evas_Object          *title_icon;
38    Evas_Object          *content_area;
39    Evas_Object          *text_content_obj;
40    Evas_Object          *action_area;
41    Evas_Object          *box;
42    Evas_Object          *tbl;
43    Evas_Object          *spacer;
44    Evas_Object          *scr;
45    Evas_Object          *content;
46    Evas_Object          *parent; /**< Pointer to remove _parent_resize_cb when popup is deleted. */
47    Eina_List            *items;
48    const char           *title_text;
49    //TIZE_ONLY(20160922): add subtitle text code of popup
50    const char           *subtitle_text;
51    //
52    Action_Area_Data     *buttons[ELM_POPUP_ACTION_BUTTON_MAX];
53    Elm_Wrap_Type         content_text_wrap_type;
54    unsigned int          last_button_number;
55    Evas_Coord            max_sc_h;
56
57    //TIZEN_ONLY(20160623): Apply popup compress mode UX
58    Evas_Display_Mode     dispmode;
59    //
60
61    //TIZEN_ONLY(20161107): Supprot scrollable content
62    //FIXME: genlist only now, it should be changed to support other scrollable.
63    Evas_Coord            min_scrollable_content_h;
64    Eina_Bool             scrollable_content: 1;
65    //
66
67    Eina_Bool             visible : 1;
68    Eina_Bool             scr_size_recalc : 1;
69    Eina_Bool             scroll : 1;
70    Eina_Bool             theme_scroll : 1;
71
72    //TIZEN_ONLY(20160624): add a allow eval flag not to call another sizing eval during sizing eval
73    Eina_Bool             allow_eval : 1;
74    //
75 };
76
77 typedef struct _Elm_Popup_Item_Data Elm_Popup_Item_Data;
78 struct _Elm_Popup_Item_Data
79 {
80    Elm_Widget_Item_Data *base;
81
82    const char     *label;
83    Evas_Object    *icon;
84    Evas_Smart_Cb   func;
85    Eina_Bool       disabled : 1;
86 };
87
88 struct _Action_Area_Data
89 {
90    Evas_Object *obj;
91    Evas_Object *btn;
92    Eina_Bool    delete_me : 1;
93 };
94
95 /**
96  * @}
97  */
98
99 #define ELM_POPUP_DATA_GET(o, sd) \
100   Elm_Popup_Data * sd = eo_data_scope_get(o, ELM_POPUP_CLASS)
101
102 #define ELM_POPUP_DATA_GET_OR_RETURN(o, ptr)         \
103   ELM_POPUP_DATA_GET(o, ptr);                        \
104   if (EINA_UNLIKELY(!ptr))                           \
105     {                                                \
106        CRI("No widget data for object %p (%s)",      \
107            o, evas_object_type_get(o));              \
108        return;                                       \
109     }
110
111 #define ELM_POPUP_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
112   ELM_POPUP_DATA_GET(o, ptr);                         \
113   if (EINA_UNLIKELY(!ptr))                            \
114     {                                                 \
115        CRI("No widget data for object %p (%s)",       \
116            o, evas_object_type_get(o));               \
117        return val;                                    \
118     }
119
120 #define ELM_POPUP_CHECK(obj)                              \
121   if (EINA_UNLIKELY(!eo_isa((obj), ELM_POPUP_CLASS))) \
122     return
123
124 #define ELM_POPUP_ITEM_CHECK(it)                            \
125   ELM_WIDGET_ITEM_CHECK_OR_RETURN(it->base, ); \
126   ELM_POPUP_CHECK(it->base->widget);
127
128 #define ELM_POPUP_ITEM_CHECK_OR_RETURN(it, ...)                        \
129   ELM_WIDGET_ITEM_CHECK_OR_RETURN(it->base, __VA_ARGS__); \
130   ELM_POPUP_CHECK(it->base->widget) __VA_ARGS__;
131
132 #define ELM_POPUP_ITEM_DATA_GET(o, sd) \
133   Elm_Popup_Item_Data* sd = eo_data_scope_get(o, ELM_POPUP_ITEM_CLASS)
134
135 #endif