summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-11-24 15:17:05 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-11-24 16:12:31 +0900
commit8608e8dc7047bfe074a71e638bc44b0eec198827 (patch)
treebe21be37d6b0ccfbd92c9f76fdbf9d68c2d77d5a
parent3c47a4f9f9ef7705992a61148f1f53311bcade49 (diff)
part bg: Fix up some unnecessary complexity
See previous commit :) Note: right now the background part has a small 3d indent which comes from the legacy theme being used. This will be fixed soon.
-rw-r--r--src/bin/elementary/test.c2
-rw-r--r--src/lib/elementary/efl_ui_layout.c104
-rw-r--r--src/lib/elementary/efl_ui_layout_part_bg.eo7
-rw-r--r--src/lib/elementary/efl_ui_widget_part_bg.eo15
-rw-r--r--src/lib/elementary/elm_part_helper.h26
-rw-r--r--src/lib/elementary/elm_widget.c40
-rw-r--r--src/lib/elementary/elm_widget.h2
7 files changed, 76 insertions, 120 deletions
diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c
index e4ba05f..c4f5e9b 100644
--- a/src/bin/elementary/test.c
+++ b/src/bin/elementary/test.c
@@ -1133,7 +1133,7 @@ add_tests:
1133 ADD_TEST(NULL, "Widgets Disable/Enable", "Layout", test_layout_disable); 1133 ADD_TEST(NULL, "Widgets Disable/Enable", "Layout", test_layout_disable);
1134 1134
1135 //------------------------------// 1135 //------------------------------//
1136 ADD_TEST(NULL, "Widgets Part", "Part Background", test_part_background); 1136 ADD_TEST_EO(NULL, "Widgets Part", "Part Background", test_part_background);
1137#undef ADD_TEST 1137#undef ADD_TEST
1138 1138
1139 if (autorun) 1139 if (autorun)
diff --git a/src/lib/elementary/efl_ui_layout.c b/src/lib/elementary/efl_ui_layout.c
index a4cd798..abe8554 100644
--- a/src/lib/elementary/efl_ui_layout.c
+++ b/src/lib/elementary/efl_ui_layout.c
@@ -2383,17 +2383,33 @@ _efl_ui_layout_efl_part_part(const Eo *obj, Efl_Ui_Layout_Data *sd, const char *
2383 EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL); 2383 EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL);
2384 ELM_WIDGET_DATA_GET_OR_RETURN((Eo *) obj, wd, NULL); 2384 ELM_WIDGET_DATA_GET_OR_RETURN((Eo *) obj, wd, NULL);
2385 2385
2386 if (eina_streq(part, "background"))
2387 return ELM_PART_IMPLEMENT(EFL_UI_LAYOUT_PART_BG_CLASS, obj, part);
2388 // Check part type without using edje_object_part_object_get(), as this 2386 // Check part type without using edje_object_part_object_get(), as this
2389 // can cause recalc, which has side effects... and could be slow. 2387 // can cause recalc, which has side effects... and could be slow.
2390 type = efl_canvas_layout_part_type_get(efl_part(wd->resize_obj, part)); 2388 type = efl_canvas_layout_part_type_get(efl_part(wd->resize_obj, part));
2391 2389
2390 if (eina_streq(part, "background"))
2391 {
2392 if (type != EFL_CANVAS_LAYOUT_PART_TYPE_SWALLOW)
2393 {
2394 if (type < EFL_CANVAS_LAYOUT_PART_TYPE_LAST)
2395 {
2396 const char *file = NULL, *key = NULL;
2397 efl_file_get(wd->resize_obj, &file, &key);
2398 WRN("Layout has a background but it's not a swallow: '%s:%s'",
2399 file, key);
2400 }
2401 return efl_part(efl_super(obj, MY_CLASS), part);
2402 }
2403
2404 return ELM_PART_IMPLEMENT(EFL_UI_LAYOUT_PART_BG_CLASS, obj, part);
2405 }
2406
2392 if (type >= EFL_CANVAS_LAYOUT_PART_TYPE_LAST) 2407 if (type >= EFL_CANVAS_LAYOUT_PART_TYPE_LAST)
2393 { 2408 {
2394 ERR("Invalid type found for part '%s' in group '%s'", part, sd->group); 2409 ERR("Invalid type found for part '%s' in group '%s'", part, sd->group);
2395 return NULL; 2410 return NULL;
2396 } 2411 }
2412
2397 switch (type) 2413 switch (type)
2398 { 2414 {
2399 case EFL_CANVAS_LAYOUT_PART_TYPE_BOX: 2415 case EFL_CANVAS_LAYOUT_PART_TYPE_BOX:
@@ -2528,78 +2544,28 @@ _efl_ui_layout_part_legacy_efl_ui_translatable_translatable_text_set(Eo *obj, vo
2528 elm_widget_part_translatable_text_set(pd->obj, pd->part, label, domain); 2544 elm_widget_part_translatable_text_set(pd->obj, pd->part, label, domain);
2529} 2545}
2530 2546
2531/* Efl.Ui.Layout.Part.Bg (common) */ 2547/* Efl.Ui.Layout.Part_Bg (common) */
2532EOLIAN static void
2533_efl_ui_layout_part_bg_efl_ui_widget_part_bg_bg_set(Eo *obj, void *_pd EINA_UNUSED, Efl_Canvas_Object *bg)
2534{
2535 Efl_Canvas_Layout_Part_Type type;
2536 Elm_Part_Data *pd = efl_data_scope_get(obj, EFL_UI_WIDGET_PART_CLASS);
2537 Efl_Ui_Layout_Data *sd = efl_data_scope_get(pd->obj, MY_CLASS);
2538 ELM_WIDGET_DATA_GET_OR_RETURN(pd->obj, wd);
2539
2540 // Check part type without using edje_object_part_object_get(), as this
2541 // can cause recalc, which has side effects... and could be slow.
2542 type = efl_canvas_layout_part_type_get(efl_part(wd->resize_obj, "background"));
2543 if (type != EFL_CANVAS_LAYOUT_PART_TYPE_SWALLOW)
2544 efl_ui_widget_part_bg_set(efl_super(obj, EFL_UI_LAYOUT_PART_BG_CLASS), bg);
2545
2546 if (wd->bg == bg)
2547 return;
2548
2549 efl_del(wd->bg);
2550 wd->bg = bg;
2551 if (!wd->bg)
2552 return;
2553
2554 _efl_ui_layout_content_set(pd->obj, sd, "background", bg);
2555}
2556
2557EOLIAN static Eina_Bool
2558_efl_ui_layout_part_bg_efl_file_file_set(Eo *obj, void *pd EINA_UNUSED, const char *file, const char *key)
2559{
2560 Evas_Object *bg_obj = efl_ui_widget_part_bg_get(obj);
2561
2562 return efl_file_set(bg_obj, file, key);
2563}
2564
2565EOLIAN static void
2566_efl_ui_layout_part_bg_efl_file_file_get(Eo *obj, void *pd EINA_UNUSED, const char **file, const char **key)
2567{
2568 Evas_Object *bg_obj = efl_ui_widget_part_bg_get(obj);
2569
2570 efl_file_get(bg_obj, file, key);
2571}
2572
2573EOLIAN static void
2574_efl_ui_layout_part_bg_efl_gfx_color_set(Eo *obj, void *pd EINA_UNUSED, int r, int g, int b, int a)
2575{
2576 Evas_Object *bg_obj = efl_ui_widget_part_bg_get(obj);
2577
2578 efl_gfx_color_set(bg_obj, r, g, b, a);
2579}
2580
2581EOLIAN static void
2582_efl_ui_layout_part_bg_efl_gfx_color_get(Eo *obj, void *pd EINA_UNUSED, int *r, int *g, int *b, int *a)
2583{
2584 Evas_Object *bg_obj = efl_ui_widget_part_bg_get(obj);
2585 2548
2586 efl_gfx_color_get(bg_obj, r, g, b, a); 2549EOLIAN static Efl_Object *
2587} 2550_efl_ui_layout_part_bg_efl_object_finalize(Eo *obj, void *_pd EINA_UNUSED)
2588
2589EOLIAN static void
2590_efl_ui_layout_part_bg_efl_ui_image_scale_type_set(Eo *obj, void *pd EINA_UNUSED, Efl_Ui_Image_Scale_Type scale_type)
2591{ 2551{
2592 Evas_Object *bg_obj = efl_ui_widget_part_bg_get(obj); 2552 Efl_Ui_Layout_Data *sd;
2553 Elm_Part_Data *pd;
2554 Eo *bg;
2593 2555
2594 efl_ui_image_scale_type_set(bg_obj, scale_type); 2556 obj = efl_finalize(efl_super(obj, EFL_UI_LAYOUT_PART_BG_CLASS));
2595} 2557 if (!obj) return NULL;
2596 2558
2597EOLIAN static Efl_Ui_Image_Scale_Type 2559 pd = efl_data_scope_get(obj, EFL_UI_WIDGET_PART_CLASS);
2598_efl_ui_layout_part_bg_efl_ui_image_scale_type_get(Eo *obj, void *pd EINA_UNUSED) 2560 sd = efl_data_scope_get(pd->obj, MY_CLASS);
2599{ 2561 bg = _efl_ui_widget_bg_get(pd->obj);
2600 Evas_Object *bg_obj = efl_ui_widget_part_bg_get(obj); 2562 if (!_efl_ui_layout_content_set(pd->obj, sd, "background", bg))
2563 {
2564 ERR("Failed to swallow new background object!");
2565 // Shouldn't happen. What now? del bg? call super? return null?
2566 }
2601 2567
2602 return efl_ui_image_scale_type_get(bg_obj); 2568 return obj;
2603} 2569}
2604 2570
2605/* Efl.Ui.Layout.Part_Xxx includes */ 2571/* Efl.Ui.Layout.Part_Xxx includes */
diff --git a/src/lib/elementary/efl_ui_layout_part_bg.eo b/src/lib/elementary/efl_ui_layout_part_bg.eo
index 9da3921..dc157d2 100644
--- a/src/lib/elementary/efl_ui_layout_part_bg.eo
+++ b/src/lib/elementary/efl_ui_layout_part_bg.eo
@@ -1,11 +1,8 @@
1class Efl.Ui.Layout.Part.Bg (Efl.Ui.Widget.Part.Bg, Efl.Ui.Bg) 1class Efl.Ui.Layout.Part_Bg (Efl.Ui.Widget.Part_Bg)
2{ 2{
3 [[Elementary layout internal part background class]] 3 [[Elementary layout internal part background class]]
4 data: null; 4 data: null;
5 implements { 5 implements {
6 Efl.Ui.Widget.Part.Bg.bg { set; } 6 Efl.Object.finalize;
7 Efl.File.file { get; set; }
8 Efl.Gfx.color { set; get; }
9 Efl.Ui.Image.scale_type { get; set; }
10 } 7 }
11} 8}
diff --git a/src/lib/elementary/efl_ui_widget_part_bg.eo b/src/lib/elementary/efl_ui_widget_part_bg.eo
index 47e5c6e..f35d4f6 100644
--- a/src/lib/elementary/efl_ui_widget_part_bg.eo
+++ b/src/lib/elementary/efl_ui_widget_part_bg.eo
@@ -1,21 +1,10 @@
1class Efl.Ui.Widget.Part.Bg (Efl.Ui.Widget.Part, Efl.Ui.Bg) 1class Efl.Ui.Widget.Part_Bg (Efl.Ui.Widget.Part, Efl.Ui.Bg)
2{ 2{
3 [[Elementary widget internal part background class]] 3 [[Elementary widget internal part background class]]
4 data: null; 4 data: null;
5 methods {
6 @property bg @protected {
7 [[Background object]]
8 set {
9 }
10 get {
11 }
12 values {
13 bg: Efl.Canvas.Object;
14 }
15 }
16 }
17 implements { 5 implements {
18 Efl.File.file { get; set; } 6 Efl.File.file { get; set; }
7 //Efl.File.mmap { get; set; }
19 Efl.Gfx.color { set; get; } 8 Efl.Gfx.color { set; get; }
20 Efl.Ui.Image.scale_type { get; set; } 9 Efl.Ui.Image.scale_type { get; set; }
21 } 10 }
diff --git a/src/lib/elementary/elm_part_helper.h b/src/lib/elementary/elm_part_helper.h
index b74bd57..eef0d2f 100644
--- a/src/lib/elementary/elm_part_helper.h
+++ b/src/lib/elementary/elm_part_helper.h
@@ -1,6 +1,8 @@
1#ifndef _ELM_PART_HELPER_H 1#ifndef _ELM_PART_HELPER_H
2#define _ELM_PART_HELPER_H 2#define _ELM_PART_HELPER_H
3 3
4#include "Elementary.h"
5#include "elm_priv.h"
4#include "efl_ui_layout_part_legacy.eo.h" 6#include "efl_ui_layout_part_legacy.eo.h"
5 7
6//#define ELM_PART_HOOK do { ERR("%s@%p:%s [%d]", efl_class_name_get(pd->obj), pd->obj, pd->part, (int) pd->temp); } while(0) 8//#define ELM_PART_HOOK do { ERR("%s@%p:%s [%d]", efl_class_name_get(pd->obj), pd->obj, pd->part, (int) pd->temp); } while(0)
@@ -63,15 +65,23 @@ _elm_part_alias_find(const Elm_Layout_Part_Alias_Description *aliases, const cha
63 return EINA_FALSE; 65 return EINA_FALSE;
64} 66}
65 67
68static inline Eo *
69_elm_part_initialize(Eo *proxy, Eo *obj, const char *part)
70{
71 Elm_Part_Data *pd = efl_data_scope_get(proxy, EFL_UI_WIDGET_PART_CLASS);
72
73 EINA_SAFETY_ON_FALSE_RETURN_VAL(pd && obj && part, NULL);
74 efl_allow_parent_unref_set(proxy, 1);
75 // efl_auto_unref_set(proxy, 1);
76 pd->part = eina_tmpstr_add(part);
77 pd->obj = obj;
78
79 return proxy;
80}
81
66#define ELM_PART_IMPLEMENT(PART_CLASS, _obj, _part) ({ \ 82#define ELM_PART_IMPLEMENT(PART_CLASS, _obj, _part) ({ \
67 EINA_SAFETY_ON_NULL_RETURN_VAL(_obj, NULL); \ 83 Eo *proxy = efl_add(PART_CLASS, (Eo *) _obj, \
68 EINA_SAFETY_ON_NULL_RETURN_VAL(_part, NULL); \ 84 _elm_part_initialize(efl_added, (Eo *) _obj, _part)); \
69 Eo *proxy = efl_add(PART_CLASS, (Eo *) _obj); \
70 Elm_Part_Data *pd = efl_data_scope_get(proxy, EFL_UI_WIDGET_PART_CLASS); \
71 EINA_SAFETY_ON_NULL_RETURN_VAL(pd, NULL); \
72 pd->obj = (Eo *) _obj; \
73 pd->part = eina_tmpstr_add(_part); \
74 efl_allow_parent_unref_set(proxy, 1); \
75 efl_auto_unref_set(proxy, 1); \ 85 efl_auto_unref_set(proxy, 1); \
76 proxy; }) 86 proxy; })
77 87
diff --git a/src/lib/elementary/elm_widget.c b/src/lib/elementary/elm_widget.c
index c4e6823..e629d7c 100644
--- a/src/lib/elementary/elm_widget.c
+++ b/src/lib/elementary/elm_widget.c
@@ -5550,41 +5550,33 @@ _efl_ui_widget_part_efl_object_destructor(Eo *obj, Elm_Part_Data *pd)
5550/* Efl.Part end */ 5550/* Efl.Part end */
5551 5551
5552/* Efl.Part Bg implementation */ 5552/* Efl.Part Bg implementation */
5553EOLIAN static void
5554_efl_ui_widget_part_bg_bg_set(Eo *obj, void *_pd EINA_UNUSED, Efl_Canvas_Object *bg)
5555{
5556 Elm_Part_Data *pd = efl_data_scope_get(obj, EFL_UI_WIDGET_PART_CLASS);
5557 Elm_Widget_Smart_Data *sd = efl_data_scope_get(pd->obj, MY_CLASS);
5558
5559 if (sd->bg == bg)
5560 return;
5561 5553
5562 efl_del(sd->bg); 5554Efl_Canvas_Object *
5563 sd->bg = bg; 5555_efl_ui_widget_bg_get(Elm_Widget *obj)
5564 if (!sd->bg)
5565 return;
5566
5567 efl_canvas_group_member_add(pd->obj, sd->bg);
5568 evas_object_stack_below(sd->bg, sd->resize_obj);
5569 _smart_reconfigure(sd);
5570}
5571
5572EOLIAN static Efl_Canvas_Object *
5573_efl_ui_widget_part_bg_bg_get(Eo *obj, void *_pd EINA_UNUSED)
5574{ 5556{
5575 Elm_Part_Data *pd = efl_data_scope_get(obj, EFL_UI_WIDGET_PART_CLASS); 5557 Elm_Widget_Smart_Data *sd = efl_data_scope_get(obj, MY_CLASS);
5576 Elm_Widget_Smart_Data *sd = efl_data_scope_get(pd->obj, MY_CLASS);
5577 Evas_Object *bg_obj = sd->bg; 5558 Evas_Object *bg_obj = sd->bg;
5578 5559
5579 if (!bg_obj) 5560 if (!bg_obj)
5580 { 5561 {
5581 bg_obj = efl_add(EFL_UI_BG_CLASS, pd->obj); 5562 bg_obj = efl_add(EFL_UI_BG_CLASS, obj);
5582 efl_ui_widget_part_bg_set(obj, bg_obj); 5563 EINA_SAFETY_ON_NULL_RETURN_VAL(bg_obj, NULL);
5564 sd->bg = bg_obj;
5565 efl_canvas_group_member_add(obj, sd->bg);
5566 evas_object_stack_below(sd->bg, sd->resize_obj);
5567 _smart_reconfigure(sd);
5583 } 5568 }
5584 5569
5585 return bg_obj; 5570 return bg_obj;
5586} 5571}
5587 5572
5573static inline Efl_Canvas_Object *
5574efl_ui_widget_part_bg_get(Eo *part_obj)
5575{
5576 Elm_Part_Data *pd = efl_data_scope_get(part_obj, EFL_UI_WIDGET_PART_CLASS);
5577 return _efl_ui_widget_bg_get(pd->obj);
5578}
5579
5588EOLIAN static Eina_Bool 5580EOLIAN static Eina_Bool
5589_efl_ui_widget_part_bg_efl_file_file_set(Eo *obj, void *pd EINA_UNUSED, const char *file, const char *key) 5581_efl_ui_widget_part_bg_efl_file_file_set(Eo *obj, void *pd EINA_UNUSED, const char *file, const char *key)
5590{ 5582{
diff --git a/src/lib/elementary/elm_widget.h b/src/lib/elementary/elm_widget.h
index b37fed5..abc9279 100644
--- a/src/lib/elementary/elm_widget.h
+++ b/src/lib/elementary/elm_widget.h
@@ -751,6 +751,8 @@ EAPI Eina_Bool _elm_widget_item_onscreen_is(Elm_Object_Item *item);
751const char* _elm_widget_accessible_plain_name_get(Evas_Object *obj, const char* name); 751const char* _elm_widget_accessible_plain_name_get(Evas_Object *obj, const char* name);
752const char* _elm_widget_item_accessible_plain_name_get(Elm_Object_Item *item, const char* name); 752const char* _elm_widget_item_accessible_plain_name_get(Elm_Object_Item *item, const char* name);
753 753
754Efl_Canvas_Object * _efl_ui_widget_bg_get(Elm_Widget *obj);
755
754#define ELM_WIDGET_DATA_GET_OR_RETURN(o, ptr, ...) \ 756#define ELM_WIDGET_DATA_GET_OR_RETURN(o, ptr, ...) \
755 Elm_Widget_Smart_Data *ptr; \ 757 Elm_Widget_Smart_Data *ptr; \
756 ptr = efl_data_scope_get(o, ELM_WIDGET_CLASS); \ 758 ptr = efl_data_scope_get(o, ELM_WIDGET_CLASS); \