aboutsummaryrefslogtreecommitdiffstats
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
parentEina_Value: strdup() is used, so include string.h (diff)
downloadefl-devs/eunue/panel.tar.gz
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 = \
lib/elementary/efl_ui_nstate.eo \
lib/elementary/elm_pan.eo \
lib/elementary/elm_panel.eo \
+ lib/elementary/efl_ui_panel.eo \
lib/elementary/elm_panes.eo \
lib/elementary/elm_photocam.eo \
lib/elementary/elm_photocam_pan.eo \
@@ -248,6 +249,7 @@ includesunstable_HEADERS = \
lib/elementary/elm_widget_naviframe.h \
lib/elementary/elm_widget_notify.h \
lib/elementary/elm_widget_panel.h \
+ lib/elementary/efl_ui_widget_panel.h \
lib/elementary/elm_widget_panes.h \
lib/elementary/elm_widget_photo.h \
lib/elementary/elm_widget_photocam.h \
@@ -445,6 +447,8 @@ includesub_HEADERS = \
lib/elementary/elm_panel_common.h \
lib/elementary/elm_panel_eo.h \
lib/elementary/elm_panel_legacy.h \
+ lib/elementary/efl_ui_panel.h \
+ lib/elementary/efl_ui_panel_eo.h \
lib/elementary/elm_panes.h \
lib/elementary/elm_panes_eo.h \
lib/elementary/elm_panes_legacy.h \
@@ -617,6 +621,7 @@ lib_elementary_libelementary_la_SOURCES = \
lib/elementary/elm_notify.c \
lib/elementary/efl_ui_nstate.c \
lib/elementary/elm_panel.c \
+ lib/elementary/efl_ui_panel.c \
lib/elementary/elm_panes.c \
lib/elementary/elm_photo.c \
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 @@
+//Compile with:
+//gcc -g efl_ui_panel_example.c -o efl_ui_panel_example `pkg-config --cflags --libs elementary`
+
+#define EFL_BETA_API_SUPPORT
+#define EFL_EO_API_SUPPORT
+
+#include <Elementary.h>
+
+
+static void
+_win_del(void *data EINA_UNUSED,
+ Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
+{
+ elm_exit();
+}
+
+static void
+_clicked_cb(void *data,
+ Evas_Object *obj EINA_UNUSED,
+ void *event_info)
+{
+ efl_ui_panel_toggle(data);
+}
+
+EAPI_MAIN int
+elm_main(int argc,
+ char **argv)
+{
+ Eo *win, *obj, *rect, *btn;
+
+ win = efl_add(EFL_UI_WIN_STANDARD_CLASS, NULL, "test", "test");
+ evas_object_smart_callback_add(win, "delete,request", _win_del, NULL);
+ efl_gfx_size_set(win, 360, 640);
+ efl_gfx_visible_set(win, EINA_TRUE);
+
+ obj = efl_add(EFL_UI_PANEL_CLASS, win);
+ efl_gfx_visible_set(obj, EINA_TRUE);
+ efl_content_set(win, obj);
+ efl_gfx_size_hint_weight_set(obj, EFL_GFX_SIZE_HINT_EXPAND,
+ EFL_GFX_SIZE_HINT_EXPAND);
+
+ rect = efl_add(EFL_CANVAS_RECTANGLE_CLASS, evas_object_evas_get(obj));
+ efl_gfx_color_set(rect, 0, 0, 255, 255);
+ efl_gfx_visible_set(rect, EINA_TRUE);
+ efl_content_set(obj, rect);
+ efl_gfx_size_hint_align_set(rect, EFL_GFX_SIZE_HINT_FILL,
+ EFL_GFX_SIZE_HINT_FILL);
+
+ btn = efl_add(ELM_BUTTON_CLASS, win);
+ efl_gfx_visible_set(btn, EINA_TRUE);
+ efl_gfx_size_set(btn, 100, 50);
+ elm_object_text_set(btn, "toggle");
+ evas_object_smart_callback_add(btn, "clicked", _clicked_cb, obj);
+
+ elm_run();
+
+ return 0;
+}
+ELM_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;
#include <elm_object.h>
#include <elm_panel.h>
+#include <efl_ui_panel.h>
#include <elm_panes.h>
#include <elm_photocam.h>
#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 @@
+#ifdef HAVE_CONFIG_H
+# include "elementary_config.h"
+#endif
+
+#define ELM_LAYOUT_PROTECTED
+
+#include <Elementary.h>
+#include "elm_priv.h"
+#include "efl_ui_widget_panel.h"
+
+#define MY_CLASS EFL_UI_PANEL_CLASS
+
+#define MY_CLASS_NAME "Efl_Ui_Panel"
+
+
+
+EOLIAN static void
+_efl_ui_panel_toggle(Eo *obj EINA_UNUSED, Efl_Ui_Panel_Data *sd)
+{
+ if (sd->state == EFL_UI_PANEL_STATE_CLOSED)
+ {
+ switch (sd->orient)
+ {
+ case EFL_ORIENT_LEFT:
+ elm_interface_scrollable_region_bring_in(sd->scroller,
+ 0, 0, sd->w, sd->h);
+ break;
+ case EFL_ORIENT_RIGHT:
+ case EFL_ORIENT_UP:
+ case EFL_ORIENT_DOWN:
+ break;
+ }
+ sd->state = EFL_UI_PANEL_STATE_OPEN;
+ }
+ else if (sd->state == EFL_UI_PANEL_STATE_OPEN)
+ {
+ switch (sd->orient)
+ {
+ case EFL_ORIENT_LEFT:
+ elm_interface_scrollable_region_bring_in(sd->scroller,
+ (sd->w * 0.8), 0, sd->w, sd->h);
+ break;
+ case EFL_ORIENT_RIGHT:
+ case EFL_ORIENT_UP:
+ case EFL_ORIENT_DOWN:
+ break;
+ }
+ sd->state = EFL_UI_PANEL_STATE_CLOSED;
+ }
+}
+
+EOLIAN static void
+_efl_ui_panel_efl_orientation_orientation_set(Eo *obj EINA_UNUSED,
+ Efl_Ui_Panel_Data *sd,
+ Efl_Orient orient)
+{
+ if (sd->orient == orient) return;
+
+ sd->orient = orient;
+ //TODO change orientation
+
+ switch (orient)
+ {
+ case EFL_ORIENT_LEFT:
+ case EFL_ORIENT_RIGHT:
+ case EFL_ORIENT_UP:
+ case EFL_ORIENT_DOWN:
+ break;
+ }
+}
+
+EOLIAN static void
+_efl_ui_panel_efl_gfx_visible_set(Eo *obj, Efl_Ui_Panel_Data *sd, Eina_Bool vis)
+{
+ efl_gfx_visible_set(efl_super(obj, MY_CLASS), vis);
+
+ efl_gfx_visible_set(sd->scroller, vis);
+ efl_gfx_visible_set(sd->box, vis);
+ efl_gfx_visible_set(sd->content_table, vis);
+ efl_gfx_visible_set(sd->content_spacer, vis);
+ efl_gfx_visible_set(sd->event_spacer, vis);
+
+ efl_gfx_visible_set(sd->event_block, vis);
+}
+
+EOLIAN static void
+_efl_ui_panel_efl_gfx_position_set(Eo *obj, Efl_Ui_Panel_Data *sd,
+ Evas_Coord x, Evas_Coord y)
+{
+ sd->x = x;
+ sd->y = y;
+
+ efl_gfx_position_set(efl_super(obj, MY_CLASS), x, y);
+
+ efl_gfx_position_set(sd->scroller, x, y);
+ efl_gfx_position_set(sd->event_block, x, y);
+}
+
+EOLIAN static void
+_efl_ui_panel_efl_gfx_size_set(Eo *obj, Efl_Ui_Panel_Data *sd,
+ Evas_Coord w, Evas_Coord h)
+{
+ Evas_Coord content_w = w, content_h = h;
+
+ sd->w = w;
+ sd->h = h;
+
+ efl_gfx_size_set(efl_super(obj, MY_CLASS), w, h);
+
+ switch (sd->orient)
+ {
+ case EFL_ORIENT_LEFT:
+ case EFL_ORIENT_RIGHT:
+ content_w = w * 0.8;
+ break;
+ case EFL_ORIENT_UP:
+ case EFL_ORIENT_DOWN:
+ content_h = h * 0.8;
+ break;
+ }
+
+ efl_gfx_size_set(sd->scroller, w, h);
+ efl_gfx_size_set(sd->event_block, w, h);
+
+ evas_object_size_hint_min_set(sd->content_spacer, content_w, content_h);
+ evas_object_size_hint_min_set(sd->event_spacer, w, h);
+
+ if (sd->state == EFL_UI_PANEL_STATE_CLOSED)
+ {
+ switch (sd->orient)
+ {
+ case EFL_ORIENT_LEFT:
+ elm_interface_scrollable_content_region_show(sd->scroller,
+ content_w, 0, w, h);
+ break;
+ case EFL_ORIENT_RIGHT:
+ case EFL_ORIENT_UP:
+ case EFL_ORIENT_DOWN:
+ break;
+ }
+ }
+}
+
+EOLIAN static Eina_Bool
+_efl_ui_panel_efl_container_content_set(Eo *obj EINA_UNUSED, Efl_Ui_Panel_Data *sd,
+ Evas_Object *content)
+{
+ if (sd->content == content) return EINA_TRUE;
+
+ if (sd->content)
+ elm_table_unpack(sd->content_table, sd->content);
+
+ sd->content = content;
+ elm_table_pack(sd->content_table, content, 0, 0, 1, 1);
+
+ return EINA_TRUE;
+}
+
+EOLIAN static void
+_efl_ui_panel_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Panel_Data *sd)
+{
+ /** in case of a left panel
+ *
+ * -------- scroller ---------
+ * | --------- box --------- |
+ * | | - table - - rect -- | |
+ * | | | rect | | | | |
+ * | | | / obj | | | | |
+ * | | --------- --------- | |
+ * | ----------------------- |
+ * ---------------------------
+ */
+
+ ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
+
+ efl_canvas_group_add(efl_super(obj, MY_CLASS));
+ elm_widget_sub_object_parent_add(obj);
+
+ sd->orient = EFL_ORIENT_LEFT; // left panel by default
+ sd->state = EFL_UI_PANEL_STATE_CLOSED; // closed by default
+
+ sd->scroller = efl_add(ELM_SCROLLER_CLASS, obj);
+ //TODO set "panel" style to the scroller
+ elm_widget_sub_object_add(obj, sd->scroller);
+ elm_interface_scrollable_bounce_allow_set(sd->scroller, EINA_FALSE, EINA_FALSE);
+ elm_interface_scrollable_policy_set(sd->scroller, ELM_SCROLLER_POLICY_OFF,
+ ELM_SCROLLER_POLICY_OFF);
+
+ sd->box = efl_add(EFL_UI_BOX_CLASS, sd->scroller);
+ efl_orientation_set(sd->box, EFL_ORIENT_RIGHT);
+ elm_widget_sub_object_add(obj, sd->box);
+ elm_object_content_set(sd->scroller, sd->box);
+
+ sd->content_table = elm_table_add(sd->box);
+ elm_widget_sub_object_add(obj, sd->content_table);
+ efl_pack_end(sd->box, sd->content_table);
+
+ sd->content_spacer = efl_add(EFL_CANVAS_RECTANGLE_CLASS, evas_object_evas_get(obj));
+ efl_gfx_color_set(sd->content_spacer, 0, 0, 0, 0);
+ elm_table_pack(sd->content_table, sd->content_spacer, 0, 0, 1, 1);
+
+ sd->event_spacer = efl_add(EFL_CANVAS_RECTANGLE_CLASS, evas_object_evas_get(obj));
+ efl_gfx_color_set(sd->event_spacer, 0, 0, 0, 0);
+ efl_pack_end(sd->box, sd->event_spacer);
+
+ sd->event_block = efl_add(EFL_CANVAS_RECTANGLE_CLASS, evas_object_evas_get(obj));
+ efl_gfx_color_set(sd->event_block, 0, 0, 0, 0);
+}
+
+EOLIAN static Eo *
+_efl_ui_panel_efl_object_constructor(Eo *obj,
+ Efl_Ui_Panel_Data *sd EINA_UNUSED)
+{
+ obj = efl_constructor(efl_super(obj, MY_CLASS));
+
+ return obj;
+}
+
+#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 @@
+enum Efl.Ui.Panel.State
+{
+ open, [[]]
+ closed [[]]
+}
+
+class Efl.Ui.Panel (Elm.Widget, Efl.Container, Efl.Orientation)
+{
+ [[Elementary panel class]]
+ eo_prefix: efl_ui_panel;
+ event_prefix: efl_ui_panel;
+ methods {
+ toggle {
+ [[toggle panel]]
+ }
+ }
+ implements {
+ Efl.Object.constructor;
+ Efl.Canvas.Group.group_add;
+ Efl.Gfx.position { set; }
+ Efl.Gfx.size { set; }
+ Efl.Gfx.visible { set; }
+ Efl.Container.content { set; }
+ Efl.Orientation.orientation { set; }
+ }
+}
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 @@
+#ifdef EFL_EO_API_SUPPORT
+#include "efl_ui_panel_eo.h"
+#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 @@
+#ifndef EFL_UI_WIDGET_PANEL_H
+#define EFL_UI_WIDGET_PANEL_H
+
+#include "Elementary.h"
+
+typedef struct _Efl_Ui_Panel_Data
+{
+ Evas_Object *scroller;
+ Evas_Object *box;
+ Evas_Object *content_table;
+ Evas_Object *content_spacer;
+ Evas_Object *event_spacer;
+ Evas_Object *content;
+ Evas_Object *event_block;
+
+ Evas_Coord x, y, w, h;
+
+ Efl_Orient orient;
+ Efl_Ui_Panel_State state;
+
+} Efl_Ui_Panel_Data;
+
+#endif