bu5hm4n pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=011022ae1bba69334c42a70ae620f9acc9ff792a

commit 011022ae1bba69334c42a70ae620f9acc9ff792a
Author: Mike Blumenkrantz <[email protected]>
Date:   Tue Sep 17 14:00:19 2019 -0400

    efl/radio/box: handle non-radio-objects
    
    this improves the usefulness of radio box by presenting it as a box widget
    which has the additional feature of being able to manage radio widgets
    
    also fix all the image cases in elm_test which relied on there being only
    a single box in the window
    
    Reviewed-by: Marcel Hollerbach <[email protected]>
    Differential Revision: https://phab.enlightenment.org/D9998
---
 src/bin/elementary/test_ui_image.c     |  5 ++---
 src/lib/elementary/efl_ui_radio_box.c  | 17 ++++++++---------
 src/lib/elementary/efl_ui_radio_box.eo |  2 +-
 3 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/src/bin/elementary/test_ui_image.c 
b/src/bin/elementary/test_ui_image.c
index c93fd4ce7e..5e7e25400a 100644
--- a/src/bin/elementary/test_ui_image.c
+++ b/src/bin/elementary/test_ui_image.c
@@ -73,7 +73,7 @@ test_ui_image(void *data EINA_UNUSED, Eo *obj  EINA_UNUSED, 
void *event_info EIN
    efl_key_data_set(win, "rdg", box);
 
    im = img_add(win, "/images/logo.png");
-   efl_content_set(win, im);
+   efl_pack(box, im);
 
    for (i = 0; images_orient[i].name; ++i)
      {
@@ -152,7 +152,7 @@ test_ui_image_scale_type(void *data EINA_UNUSED, Eo *obj  
EINA_UNUSED, void *eve
    elm_image_file_set(im, buf, NULL);
    efl_gfx_hint_weight_set(im, 1.0, 1.0);
    efl_gfx_hint_fill_set(im, EINA_TRUE, EINA_TRUE);
-   efl_content_set(win, im);
+   efl_pack(box, im);
 
    efl_key_data_set(win, "im", im);
 
@@ -320,7 +320,6 @@ test_remote_ui_image(void *data EINA_UNUSED, Eo *obj  
EINA_UNUSED, void *event_i
 
    box2 = efl_add(EFL_UI_RADIO_BOX_CLASS, win);
    efl_gfx_hint_weight_set(box2, 1.0, 1.0);
-   efl_content_set(win, box2);
    efl_key_data_set(win, "rdg", box2);
    efl_pack(box, box2);
 
diff --git a/src/lib/elementary/efl_ui_radio_box.c 
b/src/lib/elementary/efl_ui_radio_box.c
index 92918ea7eb..1e18f0f5fc 100644
--- a/src/lib/elementary/efl_ui_radio_box.c
+++ b/src/lib/elementary/efl_ui_radio_box.c
@@ -2,7 +2,6 @@
 # include "elementary_config.h"
 #endif
 
-#include <Elementary.h>
 #include "elm_priv.h"
 
 #define MY_CLASS EFL_UI_RADIO_BOX_CLASS
@@ -13,10 +12,10 @@ typedef struct {
 } Efl_Ui_Radio_Box_Data;
 
 static inline Eina_Bool
-register_safe_in_group_begin(Eo *subobj, Efl_Ui_Radio_Box_Data *pd)
+register_safe_in_group_begin(Eo *subobj, Efl_Ui_Radio_Box_Data *pd, Eina_Bool 
is_radio)
 {
-   EINA_SAFETY_ON_FALSE_RETURN_VAL(efl_isa(subobj, EFL_UI_RADIO_CLASS), 
EINA_FALSE);
-   if (!pd->in_pack)
+   if (pd->in_pack) return EINA_TRUE;
+   if (is_radio)
      efl_ui_radio_group_register(pd->group, subobj);
    pd->in_pack = EINA_TRUE;
 
@@ -24,9 +23,9 @@ register_safe_in_group_begin(Eo *subobj, 
Efl_Ui_Radio_Box_Data *pd)
 }
 
 static inline Eina_Bool
-register_safe_group_end(Eo *subobj, Efl_Ui_Radio_Box_Data *pd, Eina_Bool 
result)
+register_safe_group_end(Eo *subobj, Efl_Ui_Radio_Box_Data *pd, Eina_Bool 
is_radio, Eina_Bool result)
 {
-   if (!result)
+   if (is_radio && (!result))
      efl_ui_radio_group_unregister(pd->group, subobj);
    pd->in_pack = EINA_FALSE;
 
@@ -34,11 +33,11 @@ register_safe_group_end(Eo *subobj, Efl_Ui_Radio_Box_Data 
*pd, Eina_Bool result)
 }
 
 #define REGISTER_SAFE(f) \
-  Eina_Bool result; \
-  if (!register_safe_in_group_begin(subobj, pd)) \
+  Eina_Bool result, is_radio = efl_isa(subobj, EFL_UI_RADIO_CLASS); \
+  if (!register_safe_in_group_begin(subobj, pd, is_radio)) \
     return EINA_FALSE; \
   result = f ; \
-  return register_safe_group_end(subobj, pd, result);
+  return register_safe_group_end(subobj, pd, is_radio, result);
 
 static void
 unpack_from_logical(Eo *obj, Efl_Ui_Radio_Box_Data *pd)
diff --git a/src/lib/elementary/efl_ui_radio_box.eo 
b/src/lib/elementary/efl_ui_radio_box.eo
index 54bd92e3df..15f6b3ee13 100644
--- a/src/lib/elementary/efl_ui_radio_box.eo
+++ b/src/lib/elementary/efl_ui_radio_box.eo
@@ -2,7 +2,7 @@ class @beta Efl.Ui.Radio_Box extends Efl.Ui.Box implements 
Efl.Ui.Radio_Group
    composite Efl.Ui.Radio_Group
 {
    [[A standard @Efl.Ui.Box container which automatically handles grouping of 
any @Efl.Ui.Radio
-     widget added to it.
+     widget added to it in addition to regular widgets.
 
      All @Efl.Ui.Radio widgets are added to the same internal group which you 
only indirectly
      access through this object.

-- 


Reply via email to