rimmed pushed a commit to branch master.

http://git.enlightenment.org/tools/eflete.git/commit/?id=7f1e5a69f11abead227f59feb73aa49f1065076b

commit 7f1e5a69f11abead227f59feb73aa49f1065076b
Author: Andrii Kroitor <[email protected]>
Date:   Tue Jun 14 17:26:32 2016 +0300

    property: add possibility to higlight non-default values
---
 src/bin/ui/property/property.c           | 11 +++++++++--
 src/bin/ui/property/property_color.c     |  6 ++++--
 src/bin/ui/property/property_common.c    | 18 ++++++++++++++++++
 src/bin/ui/property/property_demo.c      |  3 ++-
 src/bin/ui/property/property_dummy.c     |  3 ++-
 src/bin/ui/property/property_group.c     |  6 +++---
 src/bin/ui/property/property_image.c     |  5 +++--
 src/bin/ui/property/property_private.h   |  4 +++-
 src/bin/ui/property/property_sound.c     |  3 ++-
 src/bin/ui/property/property_textblock.c |  3 ++-
 10 files changed, 48 insertions(+), 14 deletions(-)

diff --git a/src/bin/ui/property/property.c b/src/bin/ui/property/property.c
index 0d73d39..ae3f52b 100644
--- a/src/bin/ui/property/property.c
+++ b/src/bin/ui/property/property.c
@@ -249,16 +249,23 @@ property_item_update(Property_Attribute *pa)
 
    if (!pa->realized) return;
 
+   pa->default_is = true;
+
    if (pa->action1.update_cb != NULL)
      {
         DBG("calling update_cb of %s (%s)", pa->name, (pa->action1.name) ? 
pa->action1.name : "unnamed");
-        pa->action1.update_cb(pa, &pa->action1);
+        pa->default_is = pa->default_is && pa->action1.update_cb(pa, 
&pa->action1);
      }
    if (pa->action2.update_cb != NULL)
      {
         DBG("calling update_cb of %s (%s)", pa->name, (pa->action2.name) ? 
pa->action2.name : "unnamed");
-        pa->action2.update_cb(pa, &pa->action2);
+        pa->default_is = pa->default_is && pa->action2.update_cb(pa, 
&pa->action2);
      }
+
+   if (pa->default_is)
+     elm_genlist_item_fields_update(pa->glit, "default", 
ELM_GENLIST_ITEM_FIELD_STATE);
+   else
+     elm_genlist_item_fields_update(pa->glit, "changed", 
ELM_GENLIST_ITEM_FIELD_STATE);
 }
 
 void
diff --git a/src/bin/ui/property/property_color.c 
b/src/bin/ui/property/property_color.c
index 0e8b8df..33b1521 100644
--- a/src/bin/ui/property/property_color.c
+++ b/src/bin/ui/property/property_color.c
@@ -62,7 +62,7 @@ _colorclass_update(ColorClassData *selected)
 
 /* Colorselector widget callbacks */
 #define COLORSELECTOR_CALLBACK(NUMBER) \
-static void \
+static Eina_Bool \
 _update_##NUMBER##_cb(Property_Attribute *pa __UNUSED__, Property_Action 
*action) \
 { \
    if (color_data.selected) \
@@ -74,6 +74,7 @@ _update_##NUMBER##_cb(Property_Attribute *pa __UNUSED__, 
Property_Action *action
                                     cc_it->b##NUMBER, \
                                     cc_it->a##NUMBER); \
      }\
+   return true; \
 } \
 static void \
 _on_changed_##NUMBER(Property_Attribute *pa __UNUSED__, Property_Action 
*action) \
@@ -108,7 +109,7 @@ _change_cb(Property_Attribute *pa __UNUSED__, 
Property_Action *action)
    eina_stringshare_del(text);
 }
 
-static void
+static Eina_Bool
 _update_cb(Property_Attribute *pa __UNUSED__, Property_Action *action)
 {
    Eina_Stringshare *description;
@@ -124,6 +125,7 @@ _update_cb(Property_Attribute *pa __UNUSED__, 
Property_Action *action)
           }
         edje_edit_string_free(description);
      }
+   return true;
 }
 
 static void
diff --git a/src/bin/ui/property/property_common.c 
b/src/bin/ui/property/property_common.c
index eeeb1cb..c0243dd 100644
--- a/src/bin/ui/property/property_common.c
+++ b/src/bin/ui/property/property_common.c
@@ -532,6 +532,22 @@ _filter(void *data,
    return true;
 }
 
+static Eina_Bool
+_state_get(void *data,
+           Evas_Object *obj __UNUSED__,
+           const char *state)
+{
+   Property_Attribute *pa = data;
+
+   assert(pa != NULL);
+
+   if ((pa->default_is) && ((!strcmp(state, "default"))))
+     return true;
+   if ((!pa->default_is) && ((!strcmp(state, "changed"))))
+     return true;
+   return false;
+}
+
 void
 property_common_itc_init(Property_Data *pd)
 {
@@ -551,6 +567,7 @@ property_common_itc_init(Property_Data *pd)
    pd->itc_1swallow->func.content_get = _1swallow_content_get;
    pd->itc_1swallow->func.del = _del;
    pd->itc_1swallow->func.filter_get = _filter;
+   pd->itc_1swallow->func.state_get = _state_get;
 
    pd->itc_2swallow = elm_genlist_item_class_new();
    pd->itc_2swallow->item_style = "2swallow";
@@ -558,6 +575,7 @@ property_common_itc_init(Property_Data *pd)
    pd->itc_2swallow->func.content_get = _2swallow_content_get;
    pd->itc_2swallow->func.del = _del;
    pd->itc_2swallow->func.filter_get = _filter;
+   pd->itc_2swallow->func.state_get = _state_get;
 
    /* map control pairs to item classes */
    pd->item_classes[PROPERTY_CONTROL_NONE]           [PROPERTY_CONTROL_NONE]   
  = pd->itc_caption;
diff --git a/src/bin/ui/property/property_demo.c 
b/src/bin/ui/property/property_demo.c
index 20513c0..95946d2 100644
--- a/src/bin/ui/property/property_demo.c
+++ b/src/bin/ui/property/property_demo.c
@@ -256,7 +256,7 @@ _change_cb(Property_Attribute *pa, Property_Action *action)
      }
 }
 
-static void
+static Eina_Bool
 _update_cb(Property_Attribute *pa, Property_Action *action)
 {
    assert(pa != NULL);
@@ -328,6 +328,7 @@ _update_cb(Property_Attribute *pa, Property_Action *action)
          abort();
          break;
      }
+   return true;
 }
 
 static void
diff --git a/src/bin/ui/property/property_dummy.c 
b/src/bin/ui/property/property_dummy.c
index 776f552..c14c87b 100644
--- a/src/bin/ui/property/property_dummy.c
+++ b/src/bin/ui/property/property_dummy.c
@@ -105,10 +105,11 @@ _change_cb(Property_Attribute *pa, Property_Action 
*action)
    DBG("change of %s->%s", pa->name, action->name);
 }
 
-static void
+static Eina_Bool
 _update_cb(Property_Attribute *pa, Property_Action *action)
 {
    DBG("update of %s->%s", pa->name, action->name);
+   return true;
 }
 
 static void
diff --git a/src/bin/ui/property/property_group.c 
b/src/bin/ui/property/property_group.c
index c24657e..3eaee16 100644
--- a/src/bin/ui/property/property_group.c
+++ b/src/bin/ui/property/property_group.c
@@ -381,8 +381,7 @@ _on_editor_attribute_changed(void *data __UNUSED__,
    assert(action != NULL);
    assert(action->update_cb != NULL);
 
-   if (pa->realized)
-     action->update_cb(pa, action);
+   property_item_update(pa);
 }
 
 static Eina_Bool
@@ -1414,7 +1413,7 @@ _targets_get(Property_Attribute *pa __UNUSED__)
    return items;
 }
 
-static void
+static Eina_Bool
 _update_cb(Property_Attribute *pa, Property_Action *action)
 {
    int int_val1, int_val2, int_val3, int_val4;
@@ -2249,6 +2248,7 @@ _update_cb(Property_Attribute *pa, Property_Action 
*action)
          abort();
          break;
      }
+   return true;
 }
 
 static void
diff --git a/src/bin/ui/property/property_image.c 
b/src/bin/ui/property/property_image.c
index 6dd851a..2698eae 100644
--- a/src/bin/ui/property/property_image.c
+++ b/src/bin/ui/property/property_image.c
@@ -83,7 +83,7 @@ _image_info_type_setup(Property_Action *action, const char 
*image_name)
    elm_object_text_set(action->control, buf);
 }
 
-static void
+static Eina_Bool
 _update_cb(Property_Attribute *pa __UNUSED__, Property_Action *action)
 {
    Eina_Stringshare *str;
@@ -91,7 +91,7 @@ _update_cb(Property_Attribute *pa __UNUSED__, Property_Action 
*action)
    if (!image_data.image)
      {
         elm_object_text_set(action->control, EMPTY_VALUE);
-        return;
+        return true;
      }
 
    switch (action->type.attribute_image)
@@ -139,6 +139,7 @@ _update_cb(Property_Attribute *pa __UNUSED__, 
Property_Action *action)
       default:
          break;
      }
+   return true;
 }
 
 static void
diff --git a/src/bin/ui/property/property_private.h 
b/src/bin/ui/property/property_private.h
index 9c1bcb2..10a07d6 100644
--- a/src/bin/ui/property/property_private.h
+++ b/src/bin/ui/property/property_private.h
@@ -63,6 +63,7 @@ typedef struct {
 } Property_Data;
 
 typedef void (* Property_Cb) (Property_Attribute *, Property_Action *);
+typedef Eina_Bool (* Property_Update_Cb) (Property_Attribute *, 
Property_Action *);
 typedef Eina_Bool (* Property_Attribute_Filter_Cb) (Property_Attribute *);
 typedef void (* Property_Attribute_Del_Cb) (Property_Attribute *);
 typedef Eina_List * (* Property_Expand_Cb) (Property_Attribute *);
@@ -163,7 +164,7 @@ struct _Property_Action {
    Property_Cb start_cb;
    Property_Cb change_cb;
    Property_Cb stop_cb;
-   Property_Cb update_cb; /**< called when item is realized and control's 
values should be updated */
+   Property_Update_Cb update_cb; /**< called when item is realized and 
control's values should be updated */
 };
 
 /* Enum of property_group items. Can't use Attribute here because items can 
have
@@ -457,6 +458,7 @@ struct _Property_Attribute {
    Eina_Bool expandable : 1; /**< if true  item is tree node */
    Eina_Bool expanded : 1; /**< if true initial state will be expanded. */
    Eina_Bool realized : 1; /**< if item is not realized update callback will 
not be called */
+   Eina_Bool default_is : 1; /**< if attribute is in default state */
 };
 
 void
diff --git a/src/bin/ui/property/property_sound.c 
b/src/bin/ui/property/property_sound.c
index b4d293a..b7ac49c 100644
--- a/src/bin/ui/property/property_sound.c
+++ b/src/bin/ui/property/property_sound.c
@@ -107,7 +107,7 @@ _init_cb(Property_Attribute *pa, Property_Action *action)
      }
 }
 
-static void
+static Eina_Bool
 _update_cb(Property_Attribute *pa, Property_Action *action)
 {
    Eina_Stringshare *str_val1;
@@ -170,6 +170,7 @@ _update_cb(Property_Attribute *pa, Property_Action *action)
          abort();
          break;
      }
+   return true;
 }
 
 /* blocks */
diff --git a/src/bin/ui/property/property_textblock.c 
b/src/bin/ui/property/property_textblock.c
index 04b1e83..73cc0b9 100644
--- a/src/bin/ui/property/property_textblock.c
+++ b/src/bin/ui/property/property_textblock.c
@@ -890,7 +890,7 @@ _change_cb(Property_Attribute *pa, Property_Action *action)
      }
 }
 
-static void
+static Eina_Bool
 _update_cb(Property_Attribute *pa, Property_Action *action)
 {
    assert(pa != NULL);
@@ -1036,6 +1036,7 @@ _update_cb(Property_Attribute *pa, Property_Action 
*action)
          abort();
          break;
      }
+   return true;
 }
 
 static void

-- 


Reply via email to