From 7e8722be00f9ce7d1d9f5b43c622fb71baf2fe82 Mon Sep 17 00:00:00 2001 From: Jaehyun Cho Date: Thu, 12 Apr 2018 21:30:05 +0900 Subject: [PATCH] efl_ui_navigation_layout: Add Efl.Ui.Navigation_Layout class Efl.Ui.Navigation_Layout is a widget which provides a layout form useful for navigation. --- data/elementary/themes/Makefile.am | 1 + data/elementary/themes/default.edc | 1 + .../themes/edc/efl/navigation_layout.edc | 27 +++++++++ src/Makefile_Elementary.am | 3 + src/lib/elementary/Elementary.h | 1 + src/lib/elementary/efl_ui_navigation_layout.c | 59 +++++++++++++++++++ .../elementary/efl_ui_navigation_layout.eo | 29 +++++++++ .../efl_ui_navigation_layout_private.h | 20 +++++++ 8 files changed, 141 insertions(+) create mode 100644 data/elementary/themes/edc/efl/navigation_layout.edc create mode 100644 src/lib/elementary/efl_ui_navigation_layout.c create mode 100644 src/lib/elementary/efl_ui_navigation_layout.eo create mode 100644 src/lib/elementary/efl_ui_navigation_layout_private.h diff --git a/data/elementary/themes/Makefile.am b/data/elementary/themes/Makefile.am index e91113c1cc..a52bd6538f 100644 --- a/data/elementary/themes/Makefile.am +++ b/data/elementary/themes/Makefile.am @@ -1022,6 +1022,7 @@ elementary/themes/edc/efl/uiclock.edc \ elementary/themes/edc/efl/cursor.edc \ elementary/themes/edc/efl/focus.edc \ elementary/themes/edc/efl/frame.edc \ +elementary/themes/edc/efl/navigation_layout.edc \ elementary/themes/edc/efl/multibuttonentry.edc \ elementary/themes/edc/efl/nstate.edc \ elementary/themes/edc/efl/panes.edc \ diff --git a/data/elementary/themes/default.edc b/data/elementary/themes/default.edc index 3b851409f5..29733f6d1d 100644 --- a/data/elementary/themes/default.edc +++ b/data/elementary/themes/default.edc @@ -168,6 +168,7 @@ collections { #include "edc/efl/bg.edc" #include "edc/efl/button.edc" #include "edc/efl/calendar.edc" +#include "edc/efl/navigation_layout.edc" #include "edc/efl/nstate.edc" // XXX: mobile mode needs invisible scrollers... make signals that do this #include "edc/efl/scroller.edc" diff --git a/data/elementary/themes/edc/efl/navigation_layout.edc b/data/elementary/themes/edc/efl/navigation_layout.edc new file mode 100644 index 0000000000..c3765cce9f --- /dev/null +++ b/data/elementary/themes/edc/efl/navigation_layout.edc @@ -0,0 +1,27 @@ +//Efl.Ui.Navigation_Layout Themes +group { "efl/navigation_layout"; + parts { + spacer { "base"; + desc { "default"; + } + } + swallow { "bar"; + desc { "default"; + fixed: 0 1; + min: 0 40; + rel2.relative: 1.0 0.0; + align: 0.5 0.0; + } + } + swallow { "content"; + desc { "default"; + rel1 { + to_x: "base"; + to_y: "bar"; + relative: 0.0 1.0; + } + rel2.to_x: "base"; + } + } + } +} diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am index a9e1dc252b..e86f93d28f 100644 --- a/src/Makefile_Elementary.am +++ b/src/Makefile_Elementary.am @@ -16,6 +16,7 @@ elm_public_eolian_files = \ lib/elementary/efl_ui_image_zoomable.eo \ lib/elementary/efl_ui_layout.eo \ lib/elementary/efl_ui_nstate.eo \ + lib/elementary/efl_ui_navigation_layout.eo \ lib/elementary/efl_ui_panes.eo \ lib/elementary/efl_ui_progressbar.eo \ lib/elementary/efl_ui_radio.eo \ @@ -351,6 +352,7 @@ includesunstable_HEADERS = \ lib/elementary/elm_widget_menu.h \ lib/elementary/elm_widget_multibuttonentry.h \ lib/elementary/elm_widget_naviframe.h \ + lib/elementary/efl_ui_navigation_layout_private.h \ lib/elementary/elm_widget_notify.h \ lib/elementary/elm_widget_panel.h \ lib/elementary/efl_ui_panes_private.h \ @@ -625,6 +627,7 @@ lib_elementary_libelementary_la_SOURCES = \ lib/elementary/elc_hoversel.c \ lib/elementary/elc_multibuttonentry.c \ lib/elementary/elc_naviframe.c \ + lib/elementary/efl_ui_navigation_layout.c \ lib/elementary/elc_player.c \ lib/elementary/elc_popup.c \ lib/elementary/elc_scrolled_entry.c \ diff --git a/src/lib/elementary/Elementary.h b/src/lib/elementary/Elementary.h index 4099503810..38b814c3ba 100644 --- a/src/lib/elementary/Elementary.h +++ b/src/lib/elementary/Elementary.h @@ -336,6 +336,7 @@ typedef Eo Efl_Ui_Focus_Manager; # include # include # include +# include # include #endif diff --git a/src/lib/elementary/efl_ui_navigation_layout.c b/src/lib/elementary/efl_ui_navigation_layout.c new file mode 100644 index 0000000000..3d280dc528 --- /dev/null +++ b/src/lib/elementary/efl_ui_navigation_layout.c @@ -0,0 +1,59 @@ +#ifdef HAVE_CONFIG_H +# include "elementary_config.h" +#endif + +#include + +#include "elm_priv.h" +#include "efl_ui_navigation_layout_private.h" +#include "elm_part_helper.h" + +#define MY_CLASS EFL_UI_NAVIGATION_LAYOUT_CLASS +#define MY_CLASS_NAME "Efl.Ui.Navigation_Layout" + +EOLIAN static void +_efl_ui_navigation_layout_bar_set(Eo *obj, Efl_Ui_Navigation_Layout_Data *pd, Efl_Ui_Layout *bar) +{ + EINA_SAFETY_ON_FALSE_RETURN(efl_isa(bar, EFL_UI_LAYOUT_CLASS)); + + efl_content_set(efl_part(obj, "bar"), bar); + pd->bar = bar; +} + +EOLIAN static Efl_Ui_Layout * +_efl_ui_navigation_layout_bar_get(const Eo *obj EINA_UNUSED, Efl_Ui_Navigation_Layout_Data *pd) +{ + return pd->bar; +} + +EOLIAN static Eo * +_efl_ui_navigation_layout_efl_object_constructor(Eo *obj, Efl_Ui_Navigation_Layout_Data *pd EINA_UNUSED) +{ + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL); + + if (!elm_widget_theme_klass_get(obj)) + elm_widget_theme_klass_set(obj, "navigation_layout"); + obj = efl_constructor(efl_super(obj, MY_CLASS)); + efl_canvas_object_type_set(obj, MY_CLASS_NAME); + + elm_widget_sub_object_parent_add(obj); + + elm_widget_can_focus_set(obj, EINA_TRUE); + if (!elm_widget_theme_object_set(obj, wd->resize_obj, + elm_widget_theme_klass_get(obj), + elm_widget_theme_element_get(obj), + elm_widget_theme_style_get(obj))) + CRI("Failed to set layout!"); + + return obj; +} + +/* Standard widget overrides */ +ELM_PART_CONTENT_DEFAULT_GET(efl_ui_navigation_layout, "content") +ELM_PART_CONTENT_DEFAULT_IMPLEMENT(efl_ui_navigation_layout, Efl_Ui_Navigation_Layout_Data) + +/* Internal EO APIs and hidden overrides */ +#define EFL_UI_NAVIGATION_LAYOUT_EXTRA_OPS \ + ELM_PART_CONTENT_DEFAULT_OPS(efl_ui_navigation_layout) + +#include "efl_ui_navigation_layout.eo.c" diff --git a/src/lib/elementary/efl_ui_navigation_layout.eo b/src/lib/elementary/efl_ui_navigation_layout.eo new file mode 100644 index 0000000000..aea7b8b2b8 --- /dev/null +++ b/src/lib/elementary/efl_ui_navigation_layout.eo @@ -0,0 +1,29 @@ +class Efl.Ui.Navigation_Layout (Efl.Ui.Layout, Efl.Content) +{ + [[Navigation_Layout widget. + + Navigation_Layout widget provides a layout form useful for navigation. + Navigation_Layout widget is used to be pushed to or popped from Stack + widget(Efl.Ui.Stack class) as a content. + ]] + methods { + @property bar { + [[The bar object which is located at the top area as a title. + ]] + set { + } + get { + } + values { + value: Efl.Ui.Layout; + [[The bar object located at the top area of the Navigation Layout. + ]] + } + } + } + implements { + Efl.Object.constructor; + Efl.Content.content { set; get; } + Efl.Content.content_unset; + } +} diff --git a/src/lib/elementary/efl_ui_navigation_layout_private.h b/src/lib/elementary/efl_ui_navigation_layout_private.h new file mode 100644 index 0000000000..47d3e4464d --- /dev/null +++ b/src/lib/elementary/efl_ui_navigation_layout_private.h @@ -0,0 +1,20 @@ +#ifndef EFL_UI_WIDGET_NAVIGATION_LAYOUT_H +#define EFL_UI_WIDGET_NAVIGATION_LAYOUT_H + +typedef struct _Efl_Ui_Navigation_Layout_Data Efl_Ui_Navigation_Layout_Data; +struct _Efl_Ui_Navigation_Layout_Data +{ + Efl_Ui_Layout *bar; +}; + +#define EFL_UI_NAVIGATION_LAYOUT_DATA_GET_OR_RETURN(o, ptr, ...) \ + Efl_Ui_Navigation_Layout_Data *ptr; \ + ptr = efl_data_scope_get(o, EFL_UI_NAVIGATION_LAYOUT_CLASS); \ + if (EINA_UNLIKELY(!ptr)) \ + { \ + CRI("no ui navigation layout data for object %p (%s)", \ + o, evas_object_type_get(o)); \ + return __VA_ARGS__; \ + } + +#endif