elementary: add a filled state to gengrid. auto fill the first line if not
authoryoz <yoz@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 4 Jan 2012 14:33:39 +0000 (14:33 +0000)
committeryoz <yoz@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 4 Jan 2012 14:33:39 +0000 (14:33 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@66869 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/elm_gen_common.h
src/lib/elm_gengrid.c
src/lib/elm_gengrid.h

index 08cdc97..e67a07a 100644 (file)
@@ -171,6 +171,7 @@ struct _Widget_Data
    Eina_Bool                      horizontal : 1;
    Eina_Bool                      move_effect_enabled : 1;
    Eina_Bool                      reorder_item_changed : 1;
+   Eina_Bool                      filled : 1;
 };
 
 Elm_Gen_Item *_elm_genlist_item_new(Widget_Data *wd, const Elm_Gen_Item_Class *itc, const void *data, Elm_Gen_Item *parent, Evas_Smart_Cb func, const void *func_data);
index 5e03fa1..c2fce07 100644 (file)
@@ -799,6 +799,7 @@ _mouse_down(void        *data,
    it->wd->longpressed = EINA_FALSE;
    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
    else it->wd->on_hold = EINA_FALSE;
+   if (it->wd->on_hold) return;
    it->wd->wasselected = it->selected;
    _item_highlight(it);
    if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
@@ -1195,7 +1196,11 @@ _item_place(Elm_Gen_Item *it,
         items_row = items_visible;
         if (items_row > it->wd->count)
           items_row = it->wd->count;
-        tch = items_row * it->wd->item_height;
+         if (it->wd->filled
+             && (unsigned int)it->wd->nmax > (unsigned int)it->wd->count)
+           tch = it->wd->nmax * it->wd->item_height;
+         else
+           tch = items_row * it->wd->item_height;
         alignh = (vh - tch) * it->wd->align_y;
      }
    else
@@ -1217,7 +1222,11 @@ _item_place(Elm_Gen_Item *it,
         items_col = items_visible;
         if (items_col > it->wd->count)
           items_col = it->wd->count;
-        tcw = items_col * it->wd->item_width;
+         if (it->wd->filled
+             && (unsigned int)it->wd->nmax > (unsigned int)it->wd->count)
+           tcw = it->wd->nmax * it->wd->item_width;
+         else
+           tcw = items_col * it->wd->item_width;
         alignw = (vw - tcw) * it->wd->align_x;
      }
 
@@ -2716,3 +2725,24 @@ elm_gengrid_item_bring_in(Elm_Gen_Item *it)
                                         it->wd->item_width,
                                         it->wd->item_height);
 }
+
+EAPI void
+elm_gengrid_filled_set(Evas_Object *obj, Eina_Bool fill)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype);
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return;
+   fill = !!fill;
+   if (wd->filled != fill)
+     wd->filled = fill;
+}
+
+EAPI Eina_Bool
+elm_gengrid_filled_get(const Evas_Object *obj)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return EINA_FALSE;
+   return wd->filled;
+}
+
index ce49e39..f22dd06 100644 (file)
@@ -1511,5 +1511,44 @@ EAPI Elm_Gengrid_Item             *elm_gengrid_selected_item_get(const Evas_Obje
 EAPI const Eina_List              *elm_gengrid_selected_items_get(const Evas_Object *obj);
 
 /**
+ * Set how the items grid's filled within a given gengrid widget
+ *
+ * @param obj The gengrid object.
+ * @param fill Filled if True
+ *
+ * This sets the fill state of the whole grid of items of a gengrid
+ * within its given viewport. By default, this value is False, meaning
+ * that if the first line of items grid's aren't filled
+ *
+ * Set how the items grid's filled within a given gengrid widget.
+ * This sets the fill state of the whole grid of items of a gengrid
+ * within its given viewport. By default, this value is false, meaning
+ * that if the first line of items grid's isn't filled, the items are
+ * centered with the alignment
+ *
+ * @see elm_gengrid_filled_get()
+ *
+ * @ingroup Gengrid
+ */
+EAPI void                          elm_gengrid_filled_set(Evas_Object *obj, Eina_Bool fill);
+
+
+/**
+ * Get how the items grid's filled within a given gengrid widget
+ *
+ * @param obj The gengrid object.
+ * @return @c EINA_TRUE, if filled is on, @c EINA_FALSE if it's
+ * off
+ *
+ * @note Use @c NULL pointers on the alignment values you're not
+ * interested in: they'll be ignored by the function.
+ *
+ * @see elm_gengrid_align_set() for more details
+ *
+ * @ingroup Gengrid
+ */
+EAPI Eina_Bool                     elm_gengrid_filled_get(const Evas_Object *obj);
+
+/**
  * @}
  */