summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaeun Choi <jaeun12.choi@samsung.com>2017-03-27 15:24:35 +0900
committerJaeun Choi <jaeun12.choi@samsung.com>2017-03-29 11:25:52 +0900
commitc19920aa2a69d8bb315ac64f9279a1aa01668912 (patch)
tree3df29183438faf8a2c194003f543f2247009e791
parenteff7bab48fda4c805008c88007f0bb2c0322642d (diff)
efl_ui_panel: create a new classdevs/eunue/panel
made it work for a simple use case of a left panel thumbscroll is disabled for now - toggled only by API example: src/examples/elementary/efl_ui_panel_example.c
-rw-r--r--src/Makefile_Elementary.am5
-rw-r--r--src/examples/elementary/efl_ui_panel_example.c60
-rw-r--r--src/lib/elementary/Elementary.h1
-rw-r--r--src/lib/elementary/efl_ui_panel.c219
-rw-r--r--src/lib/elementary/efl_ui_panel.eo26
-rw-r--r--src/lib/elementary/efl_ui_panel.h3
-rw-r--r--src/lib/elementary/efl_ui_panel_eo.h1
-rw-r--r--src/lib/elementary/efl_ui_widget_panel.h23
8 files changed, 338 insertions, 0 deletions
diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am
index 0f6973cae3..2b11293a9d 100644
--- a/src/Makefile_Elementary.am
+++ b/src/Makefile_Elementary.am
@@ -51,6 +51,7 @@ elm_public_eolian_files = \
51 lib/elementary/efl_ui_nstate.eo \ 51 lib/elementary/efl_ui_nstate.eo \
52 lib/elementary/elm_pan.eo \ 52 lib/elementary/elm_pan.eo \
53 lib/elementary/elm_panel.eo \ 53 lib/elementary/elm_panel.eo \
54 lib/elementary/efl_ui_panel.eo \
54 lib/elementary/elm_panes.eo \ 55 lib/elementary/elm_panes.eo \
55 lib/elementary/elm_photocam.eo \ 56 lib/elementary/elm_photocam.eo \
56 lib/elementary/elm_photocam_pan.eo \ 57 lib/elementary/elm_photocam_pan.eo \
@@ -248,6 +249,7 @@ includesunstable_HEADERS = \
248 lib/elementary/elm_widget_naviframe.h \ 249 lib/elementary/elm_widget_naviframe.h \
249 lib/elementary/elm_widget_notify.h \ 250 lib/elementary/elm_widget_notify.h \
250 lib/elementary/elm_widget_panel.h \ 251 lib/elementary/elm_widget_panel.h \
252 lib/elementary/efl_ui_widget_panel.h \
251 lib/elementary/elm_widget_panes.h \ 253 lib/elementary/elm_widget_panes.h \
252 lib/elementary/elm_widget_photo.h \ 254 lib/elementary/elm_widget_photo.h \
253 lib/elementary/elm_widget_photocam.h \ 255 lib/elementary/elm_widget_photocam.h \
@@ -445,6 +447,8 @@ includesub_HEADERS = \
445 lib/elementary/elm_panel_common.h \ 447 lib/elementary/elm_panel_common.h \
446 lib/elementary/elm_panel_eo.h \ 448 lib/elementary/elm_panel_eo.h \
447 lib/elementary/elm_panel_legacy.h \ 449 lib/elementary/elm_panel_legacy.h \
450 lib/elementary/efl_ui_panel.h \
451 lib/elementary/efl_ui_panel_eo.h \
448 lib/elementary/elm_panes.h \ 452 lib/elementary/elm_panes.h \
449 lib/elementary/elm_panes_eo.h \ 453 lib/elementary/elm_panes_eo.h \
450 lib/elementary/elm_panes_legacy.h \ 454 lib/elementary/elm_panes_legacy.h \
@@ -617,6 +621,7 @@ lib_elementary_libelementary_la_SOURCES = \
617 lib/elementary/elm_notify.c \ 621 lib/elementary/elm_notify.c \
618 lib/elementary/efl_ui_nstate.c \ 622 lib/elementary/efl_ui_nstate.c \
619 lib/elementary/elm_panel.c \ 623 lib/elementary/elm_panel.c \
624 lib/elementary/efl_ui_panel.c \
620 lib/elementary/elm_panes.c \ 625 lib/elementary/elm_panes.c \
621 lib/elementary/elm_photo.c \ 626 lib/elementary/elm_photo.c \
622 lib/elementary/elm_photocam.c \ 627 lib/elementary/elm_photocam.c \
diff --git a/src/examples/elementary/efl_ui_panel_example.c b/src/examples/elementary/efl_ui_panel_example.c
new file mode 100644
index 0000000000..a45b8a212e
--- /dev/null
+++ b/src/examples/elementary/efl_ui_panel_example.c
@@ -0,0 +1,60 @@
1//Compile with:
2//gcc -g efl_ui_panel_example.c -o efl_ui_panel_example `pkg-config --cflags --libs elementary`
3
4#define EFL_BETA_API_SUPPORT
5#define EFL_EO_API_SUPPORT
6
7#include <Elementary.h>
8
9
10static void
11_win_del(void *data EINA_UNUSED,
12 Evas_Object *obj EINA_UNUSED,
13 void *event_info EINA_UNUSED)
14{
15 elm_exit();
16}
17
18static void
19_clicked_cb(void *data,
20 Evas_Object *obj EINA_UNUSED,
21 void *event_info)
22{
23 efl_ui_panel_toggle(data);
24}
25
26EAPI_MAIN int
27elm_main(int argc,
28 char **argv)
29{
30 Eo *win, *obj, *rect, *btn;
31
32 win = efl_add(EFL_UI_WIN_STANDARD_CLASS, NULL, "test", "test");
33 evas_object_smart_callback_add(win, "delete,request", _win_del, NULL);
34 efl_gfx_size_set(win, 360, 640);
35 efl_gfx_visible_set(win, EINA_TRUE);
36
37 obj = efl_add(EFL_UI_PANEL_CLASS, win);
38 efl_gfx_visible_set(obj, EINA_TRUE);
39 efl_content_set(win, obj);
40 efl_gfx_size_hint_weight_set(obj, EFL_GFX_SIZE_HINT_EXPAND,
41 EFL_GFX_SIZE_HINT_EXPAND);
42
43 rect = efl_add(EFL_CANVAS_RECTANGLE_CLASS, evas_object_evas_get(obj));
44 efl_gfx_color_set(rect, 0, 0, 255, 255);
45 efl_gfx_visible_set(rect, EINA_TRUE);
46 efl_content_set(obj, rect);
47 efl_gfx_size_hint_align_set(rect, EFL_GFX_SIZE_HINT_FILL,
48 EFL_GFX_SIZE_HINT_FILL);
49
50 btn = efl_add(ELM_BUTTON_CLASS, win);
51 efl_gfx_visible_set(btn, EINA_TRUE);
52 efl_gfx_size_set(btn, 100, 50);
53 elm_object_text_set(btn, "toggle");
54 evas_object_smart_callback_add(btn, "clicked", _clicked_cb, obj);
55
56 elm_run();
57
58 return 0;
59}
60ELM_MAIN()
diff --git a/src/lib/elementary/Elementary.h b/src/lib/elementary/Elementary.h
index d917a572c0..beb19957de 100644
--- a/src/lib/elementary/Elementary.h
+++ b/src/lib/elementary/Elementary.h
@@ -223,6 +223,7 @@ EAPI extern Elm_Version *elm_version;
223#include <elm_object.h> 223#include <elm_object.h>
224 224
225#include <elm_panel.h> 225#include <elm_panel.h>
226#include <efl_ui_panel.h>
226#include <elm_panes.h> 227#include <elm_panes.h>
227#include <elm_photocam.h> 228#include <elm_photocam.h>
228#include <elm_photo.h> 229#include <elm_photo.h>
diff --git a/src/lib/elementary/efl_ui_panel.c b/src/lib/elementary/efl_ui_panel.c
new file mode 100644
index 0000000000..548516fe15
--- /dev/null
+++ b/src/lib/elementary/efl_ui_panel.c
@@ -0,0 +1,219 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#define ELM_LAYOUT_PROTECTED
6
7#include <Elementary.h>
8#include "elm_priv.h"
9#include "efl_ui_widget_panel.h"
10
11#define MY_CLASS EFL_UI_PANEL_CLASS
12
13#define MY_CLASS_NAME "Efl_Ui_Panel"
14
15
16
17EOLIAN static void
18_efl_ui_panel_toggle(Eo *obj EINA_UNUSED, Efl_Ui_Panel_Data *sd)
19{
20 if (sd->state == EFL_UI_PANEL_STATE_CLOSED)
21 {
22 switch (sd->orient)
23 {
24 case EFL_ORIENT_LEFT:
25 elm_interface_scrollable_region_bring_in(sd->scroller,
26 0, 0, sd->w, sd->h);
27 break;
28 case EFL_ORIENT_RIGHT:
29 case EFL_ORIENT_UP:
30 case EFL_ORIENT_DOWN:
31 break;
32 }
33 sd->state = EFL_UI_PANEL_STATE_OPEN;
34 }
35 else if (sd->state == EFL_UI_PANEL_STATE_OPEN)
36 {
37 switch (sd->orient)
38 {
39 case EFL_ORIENT_LEFT:
40 elm_interface_scrollable_region_bring_in(sd->scroller,
41 (sd->w * 0.8), 0, sd->w, sd->h);
42 break;
43 case EFL_ORIENT_RIGHT:
44 case EFL_ORIENT_UP:
45 case EFL_ORIENT_DOWN:
46 break;
47 }
48 sd->state = EFL_UI_PANEL_STATE_CLOSED;
49 }
50}
51
52EOLIAN static void
53_efl_ui_panel_efl_orientation_orientation_set(Eo *obj EINA_UNUSED,
54 Efl_Ui_Panel_Data *sd,
55 Efl_Orient orient)
56{
57 if (sd->orient == orient) return;
58
59 sd->orient = orient;
60 //TODO change orientation
61
62 switch (orient)
63 {
64 case EFL_ORIENT_LEFT:
65 case EFL_ORIENT_RIGHT:
66 case EFL_ORIENT_UP:
67 case EFL_ORIENT_DOWN:
68 break;
69 }
70}
71
72EOLIAN static void
73_efl_ui_panel_efl_gfx_visible_set(Eo *obj, Efl_Ui_Panel_Data *sd, Eina_Bool vis)
74{
75 efl_gfx_visible_set(efl_super(obj, MY_CLASS), vis);
76
77 efl_gfx_visible_set(sd->scroller, vis);
78 efl_gfx_visible_set(sd->box, vis);
79 efl_gfx_visible_set(sd->content_table, vis);
80 efl_gfx_visible_set(sd->content_spacer, vis);
81 efl_gfx_visible_set(sd->event_spacer, vis);
82
83 efl_gfx_visible_set(sd->event_block, vis);
84}
85
86EOLIAN static void
87_efl_ui_panel_efl_gfx_position_set(Eo *obj, Efl_Ui_Panel_Data *sd,
88 Evas_Coord x, Evas_Coord y)
89{
90 sd->x = x;
91 sd->y = y;
92
93 efl_gfx_position_set(efl_super(obj, MY_CLASS), x, y);
94
95 efl_gfx_position_set(sd->scroller, x, y);
96 efl_gfx_position_set(sd->event_block, x, y);
97}
98
99EOLIAN static void
100_efl_ui_panel_efl_gfx_size_set(Eo *obj, Efl_Ui_Panel_Data *sd,
101 Evas_Coord w, Evas_Coord h)
102{
103 Evas_Coord content_w = w, content_h = h;
104
105 sd->w = w;
106 sd->h = h;
107
108 efl_gfx_size_set(efl_super(obj, MY_CLASS), w, h);
109
110 switch (sd->orient)
111 {
112 case EFL_ORIENT_LEFT:
113 case EFL_ORIENT_RIGHT:
114 content_w = w * 0.8;
115 break;
116 case EFL_ORIENT_UP:
117 case EFL_ORIENT_DOWN:
118 content_h = h * 0.8;
119 break;
120 }
121
122 efl_gfx_size_set(sd->scroller, w, h);
123 efl_gfx_size_set(sd->event_block, w, h);
124
125 evas_object_size_hint_min_set(sd->content_spacer, content_w, content_h);
126 evas_object_size_hint_min_set(sd->event_spacer, w, h);
127
128 if (sd->state == EFL_UI_PANEL_STATE_CLOSED)
129 {
130 switch (sd->orient)
131 {
132 case EFL_ORIENT_LEFT:
133 elm_interface_scrollable_content_region_show(sd->scroller,
134 content_w, 0, w, h);
135 break;
136 case EFL_ORIENT_RIGHT:
137 case EFL_ORIENT_UP:
138 case EFL_ORIENT_DOWN:
139 break;
140 }
141 }
142}
143
144EOLIAN static Eina_Bool
145_efl_ui_panel_efl_container_content_set(Eo *obj EINA_UNUSED, Efl_Ui_Panel_Data *sd,
146 Evas_Object *content)
147{
148 if (sd->content == content) return EINA_TRUE;
149
150 if (sd->content)
151 elm_table_unpack(sd->content_table, sd->content);
152
153 sd->content = content;
154 elm_table_pack(sd->content_table, content, 0, 0, 1, 1);
155
156 return EINA_TRUE;
157}
158
159EOLIAN static void
160_efl_ui_panel_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Panel_Data *sd)
161{
162 /** in case of a left panel
163 *
164 * -------- scroller ---------
165 * | --------- box --------- |
166 * | | - table - - rect -- | |
167 * | | | rect | | | | |
168 * | | | / obj | | | | |
169 * | | --------- --------- | |
170 * | ----------------------- |
171 * ---------------------------
172 */
173
174 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
175
176 efl_canvas_group_add(efl_super(obj, MY_CLASS));
177 elm_widget_sub_object_parent_add(obj);
178
179 sd->orient = EFL_ORIENT_LEFT; // left panel by default
180 sd->state = EFL_UI_PANEL_STATE_CLOSED; // closed by default
181
182 sd->scroller = efl_add(ELM_SCROLLER_CLASS, obj);
183 //TODO set "panel" style to the scroller
184 elm_widget_sub_object_add(obj, sd->scroller);
185 elm_interface_scrollable_bounce_allow_set(sd->scroller, EINA_FALSE, EINA_FALSE);
186 elm_interface_scrollable_policy_set(sd->scroller, ELM_SCROLLER_POLICY_OFF,
187 ELM_SCROLLER_POLICY_OFF);
188
189 sd->box = efl_add(EFL_UI_BOX_CLASS, sd->scroller);
190 efl_orientation_set(sd->box, EFL_ORIENT_RIGHT);
191 elm_widget_sub_object_add(obj, sd->box);
192 elm_object_content_set(sd->scroller, sd->box);
193
194 sd->content_table = elm_table_add(sd->box);
195 elm_widget_sub_object_add(obj, sd->content_table);
196 efl_pack_end(sd->box, sd->content_table);
197
198 sd->content_spacer = efl_add(EFL_CANVAS_RECTANGLE_CLASS, evas_object_evas_get(obj));
199 efl_gfx_color_set(sd->content_spacer, 0, 0, 0, 0);
200 elm_table_pack(sd->content_table, sd->content_spacer, 0, 0, 1, 1);
201
202 sd->event_spacer = efl_add(EFL_CANVAS_RECTANGLE_CLASS, evas_object_evas_get(obj));
203 efl_gfx_color_set(sd->event_spacer, 0, 0, 0, 0);
204 efl_pack_end(sd->box, sd->event_spacer);
205
206 sd->event_block = efl_add(EFL_CANVAS_RECTANGLE_CLASS, evas_object_evas_get(obj));
207 efl_gfx_color_set(sd->event_block, 0, 0, 0, 0);
208}
209
210EOLIAN static Eo *
211_efl_ui_panel_efl_object_constructor(Eo *obj,
212 Efl_Ui_Panel_Data *sd EINA_UNUSED)
213{
214 obj = efl_constructor(efl_super(obj, MY_CLASS));
215
216 return obj;
217}
218
219#include "efl_ui_panel.eo.c"
diff --git a/src/lib/elementary/efl_ui_panel.eo b/src/lib/elementary/efl_ui_panel.eo
new file mode 100644
index 0000000000..c532e8b11a
--- /dev/null
+++ b/src/lib/elementary/efl_ui_panel.eo
@@ -0,0 +1,26 @@
1enum Efl.Ui.Panel.State
2{
3 open, [[]]
4 closed [[]]
5}
6
7class Efl.Ui.Panel (Elm.Widget, Efl.Container, Efl.Orientation)
8{
9 [[Elementary panel class]]
10 eo_prefix: efl_ui_panel;
11 event_prefix: efl_ui_panel;
12 methods {
13 toggle {
14 [[toggle panel]]
15 }
16 }
17 implements {
18 Efl.Object.constructor;
19 Efl.Canvas.Group.group_add;
20 Efl.Gfx.position { set; }
21 Efl.Gfx.size { set; }
22 Efl.Gfx.visible { set; }
23 Efl.Container.content { set; }
24 Efl.Orientation.orientation { set; }
25 }
26}
diff --git a/src/lib/elementary/efl_ui_panel.h b/src/lib/elementary/efl_ui_panel.h
new file mode 100644
index 0000000000..0c211ac2b8
--- /dev/null
+++ b/src/lib/elementary/efl_ui_panel.h
@@ -0,0 +1,3 @@
1#ifdef EFL_EO_API_SUPPORT
2#include "efl_ui_panel_eo.h"
3#endif
diff --git a/src/lib/elementary/efl_ui_panel_eo.h b/src/lib/elementary/efl_ui_panel_eo.h
new file mode 100644
index 0000000000..c94e9131ec
--- /dev/null
+++ b/src/lib/elementary/efl_ui_panel_eo.h
@@ -0,0 +1 @@
#include "efl_ui_panel.eo.h"
diff --git a/src/lib/elementary/efl_ui_widget_panel.h b/src/lib/elementary/efl_ui_widget_panel.h
new file mode 100644
index 0000000000..83429a1100
--- /dev/null
+++ b/src/lib/elementary/efl_ui_widget_panel.h
@@ -0,0 +1,23 @@
1#ifndef EFL_UI_WIDGET_PANEL_H
2#define EFL_UI_WIDGET_PANEL_H
3
4#include "Elementary.h"
5
6typedef struct _Efl_Ui_Panel_Data
7{
8 Evas_Object *scroller;
9 Evas_Object *box;
10 Evas_Object *content_table;
11 Evas_Object *content_spacer;
12 Evas_Object *event_spacer;
13 Evas_Object *content;
14 Evas_Object *event_block;
15
16 Evas_Coord x, y, w, h;
17
18 Efl_Orient orient;
19 Efl_Ui_Panel_State state;
20
21} Efl_Ui_Panel_Data;
22
23#endif