Enlightenment CVS committal

Author  : jethomas
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/lib


Modified Files:
        ewl_mvc.c 


Log Message:
Bug 461 - no longer flicker the selections when selecting within mvc widget.

===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_mvc.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -3 -r1.45 -r1.46
--- ewl_mvc.c   7 May 2008 13:38:25 -0000       1.45
+++ ewl_mvc.c   21 Jul 2008 01:28:25 -0000      1.46
@@ -5,7 +5,7 @@
 #include "ewl_macros.h"
 #include "ewl_debug.h"
 
-static void ewl_mvc_selected_clear_private(Ewl_MVC *mvc);
+static void ewl_mvc_selected_clear_private(Ewl_MVC *mvc, Ewl_Selection *set);
 static unsigned int ewl_mvc_selected_goto(Ewl_MVC *mvc,
                         unsigned int row, unsigned int column);
 static void ewl_mvc_selected_insert(Ewl_MVC *mvc, const Ewl_Model *model,
@@ -30,7 +30,7 @@
                                 Ewl_Selection *sel, Ewl_Widget *w);
 static void ewl_mvc_cb_highlight_destroy(Ewl_Widget *w, void *ev, void *data);
 static void ewl_mvc_cb_sel_free(void *data);
-static void ewl_mvc_selection_free(Ewl_Selection *sel);
+static void ewl_mvc_selection_free(Ewl_Selection *sel, unsigned int set_state);
 
 /**
  * @param mvc: The MVC to initialize
@@ -284,6 +284,8 @@
 void
 ewl_mvc_selected_clear(Ewl_MVC *mvc)
 {
+        Ewl_Selection *sel;
+
         DENTER_FUNCTION(DLEVEL_STABLE);
         DCHECK_PARAM_PTR(mvc);
         DCHECK_TYPE(mvc, EWL_MVC_TYPE);
@@ -291,16 +293,22 @@
         if (mvc->selection_mode == EWL_SELECTION_MODE_NONE)
                 DRETURN(DLEVEL_STABLE);
 
-        ewl_mvc_selected_clear_private(mvc);
+        while ((sel = ecore_list_first_remove(mvc->selected)))
+                ewl_mvc_selection_free(sel, TRUE);
+
         ewl_mvc_selected_change_notify(mvc);
 
         DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
 static void
-ewl_mvc_selected_clear_private(Ewl_MVC *mvc)
+ewl_mvc_selected_clear_private(Ewl_MVC *mvc, Ewl_Selection *set)
 {
         Ewl_Selection *sel;
+        Ewl_Selection_Idx *i1, *i2;
+        Ewl_Selection_Range *r1;
+        int idx;
+        Ewl_Widget *w, *h;
 
         DENTER_FUNCTION(DLEVEL_STABLE);
         DCHECK_PARAM_PTR(mvc);
@@ -309,8 +317,43 @@
         if (mvc->selection_mode == EWL_SELECTION_MODE_NONE)
                 DRETURN(DLEVEL_STABLE);
 
+        i1 = EWL_SELECTION_IDX(set);
+
         while ((sel = ecore_list_first_remove(mvc->selected)))
-                ewl_mvc_selection_free(sel);
+        {
+                /* If index, deal with accordingly */
+                if (sel->type == EWL_SELECTION_TYPE_INDEX)
+                {
+                        i2 = EWL_SELECTION_IDX(sel);
+                        if ((i2->row != i1->row) || (i2->column != i1->column))
+                                ewl_mvc_selection_free(sel, TRUE);
+                        else
+                                ewl_mvc_selection_free(sel, FALSE);
+                }
+                /* If sel contains the current selection */
+                else if (ewl_mvc_selection_intersects(EWL_SELECTION_RANGE(sel),
+                                                                        set))
+                {
+                        r1 = EWL_SELECTION_RANGE(sel);
+                        idx = (i1->row - r1->start.row) *
+                                (r1->end.column - r1->start.column + 1) +
+                                (i1->column - r1->start.column);
+                        h = ecore_list_index_goto(sel->highlight, idx);
+
+                        ecore_list_first_goto(sel->highlight);
+                        while ((w = ecore_list_next(sel->highlight)))
+                        {
+                                if (w != h)
+                                {
+                                        ewl_widget_state_set(w, "deselect",
+                                                        EWL_STATE_PERSISTENT);
+                                }
+                        }
+                        ewl_mvc_selection_free(sel, FALSE);
+                }
+                else
+                        ewl_mvc_selection_free(sel, TRUE);
+        }
 
         DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
@@ -336,7 +379,7 @@
                 DRETURN(DLEVEL_STABLE);
 
         count = ewl_mvc_selected_count_get(mvc);
-        ewl_mvc_selected_clear_private(mvc);
+        ewl_mvc_selected_clear(mvc);
 
         if (!list || (ecore_list_count(list) == 0))
         {
@@ -451,6 +494,8 @@
 ewl_mvc_selected_set(Ewl_MVC *mvc, const Ewl_Model *model, void *data,
                                 unsigned int row, unsigned int column)
 {
+        Ewl_Selection *sel;
+
         DENTER_FUNCTION(DLEVEL_STABLE);
         DCHECK_PARAM_PTR(mvc);
         DCHECK_TYPE(mvc, EWL_MVC_TYPE);
@@ -458,7 +503,8 @@
         if (mvc->selection_mode == EWL_SELECTION_MODE_NONE)
                 DRETURN(DLEVEL_STABLE);
 
-        ewl_mvc_selected_clear_private(mvc);
+        sel = ewl_mvc_selection_index_new(model, data, row, column);
+        ewl_mvc_selected_clear_private(mvc, sel);
         ewl_mvc_selected_add(mvc, model, data, row, column);
 
         DLEAVE_FUNCTION(DLEVEL_STABLE);
@@ -573,7 +619,7 @@
                 if (sel->type == EWL_SELECTION_TYPE_INDEX)
                 {
                         sel = ecore_list_remove(mvc->selected);
-                        ewl_mvc_selection_free(sel);
+                        ewl_mvc_selection_free(sel, TRUE);
                 }
                 else
                         ewl_mvc_selected_range_split(mvc,
@@ -723,7 +769,7 @@
                 idx = EWL_SELECTION_IDX(sel);
                 if (ewl_mvc_selected_goto(mvc, idx->row, idx->column))
                 {
-                        ewl_mvc_selection_free(sel);
+                        ewl_mvc_selection_free(sel, FALSE);
                         DRETURN(DLEVEL_STABLE);
                 }
 
@@ -752,7 +798,7 @@
                         /* just free indexes as their covered by the
                          * range and don't need to be re-inserted */
                         if (cur->type == EWL_SELECTION_TYPE_INDEX)
-                                ewl_mvc_selection_free(cur);
+                                ewl_mvc_selection_free(cur, FALSE);
                         else
                                 ecore_list_append(intersections, cur);
 
@@ -784,7 +830,8 @@
                         if (ewl_mvc_selection_contained(ptr, range))
                         {
                                 ecore_list_append(mvc->selected, ptr);
-                                ewl_mvc_selection_free(EWL_SELECTION(range));
+                                ewl_mvc_selection_free(EWL_SELECTION(range),
+                                                FALSE);
                                 range = NULL;
                                 break;
                         }
@@ -817,7 +864,7 @@
          * range */
         if (ewl_mvc_selection_contained(range, cur))
         {
-                ewl_mvc_selection_free(EWL_SELECTION(cur));
+                ewl_mvc_selection_free(EWL_SELECTION(cur), FALSE);
                 DRETURN(DLEVEL_STABLE);
         }
 
@@ -832,7 +879,7 @@
                 range->end.row = MAX(range->end.row, cur->end.row);
                 range->end.column = MAX(range->end.column, cur->end.column);
 
-                ewl_mvc_selection_free(EWL_SELECTION(cur));
+                ewl_mvc_selection_free(EWL_SELECTION(cur), FALSE);
                 DRETURN(DLEVEL_STABLE);
         }
 
@@ -892,7 +939,7 @@
                                                 cur->end.column);
                 ecore_list_append(list, sel);
         }
-        ewl_mvc_selection_free(EWL_SELECTION(cur));
+        ewl_mvc_selection_free(EWL_SELECTION(cur), FALSE);
 
         DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
@@ -1037,6 +1084,8 @@
         Ewl_Selection *sel;
         const Ewl_Model *model;
         void *data;
+        int idx;
+        Ewl_Widget *w;
 
         DENTER_FUNCTION(DLEVEL_STABLE);
         DCHECK_PARAM_PTR(mvc);
@@ -1048,6 +1097,13 @@
         model = EWL_SELECTION(range)->model;
         data = EWL_SELECTION(range)->data;
 
+        /* We need to unselect the widget being split around here */
+        idx = (row - range->start.row) * (range->end.column - 
+                        range->start.column + 1) +
+                        (column - range->start.column);
+        w = ecore_list_index_goto(EWL_SELECTION(range)->highlight, idx);
+        ewl_widget_state_set(w, "deselect", EWL_STATE_PERSISTENT);
+
         /* we have something above, case 1 */
         if (range->start.row < row)
         {
@@ -1085,7 +1141,7 @@
                 ecore_list_append(mvc->selected, sel);
         }
 
-        ewl_mvc_selection_free(EWL_SELECTION(range));
+        ewl_mvc_selection_free(EWL_SELECTION(range), FALSE);
 
         DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
@@ -1369,14 +1425,14 @@
         DENTER_FUNCTION(DLEVEL_STABLE);
         DCHECK_PARAM_PTR(data);
 
-        ewl_mvc_selection_free(EWL_SELECTION(data));
+        ewl_mvc_selection_free(EWL_SELECTION(data), TRUE);
         data = NULL;
 
         DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
 static void
-ewl_mvc_selection_free(Ewl_Selection *sel)
+ewl_mvc_selection_free(Ewl_Selection *sel, unsigned int set_state)
 {
         DENTER_FUNCTION(DLEVEL_STABLE);
         DCHECK_PARAM_PTR(sel);
@@ -1390,8 +1446,10 @@
                 {
                         ewl_callback_del(sel->highlight, EWL_CALLBACK_DESTROY,
                                         ewl_mvc_cb_highlight_destroy);
-                        ewl_widget_state_set(sel->highlight, "deselect",
-                                        EWL_STATE_PERSISTENT);
+
+                        if (set_state)
+                                ewl_widget_state_set(sel->highlight,
+                                        "deselect",EWL_STATE_PERSISTENT);
                 }
                 else
                 {
@@ -1401,8 +1459,10 @@
                         {
                                 ewl_callback_del(w, EWL_CALLBACK_DESTROY,
                                                 ewl_mvc_cb_highlight_destroy);
-                                ewl_widget_state_set(w, "deselect",
-                                        EWL_STATE_PERSISTENT);
+                                
+                                if (set_state)
+                                        ewl_widget_state_set(w, "deselect",
+                                                EWL_STATE_PERSISTENT);
                         }
 
                         IF_FREE_LIST(sel->highlight);



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to