On Thu, Oct 7, 2010 at 9:36 AM, Gustavo Sverzut Barbieri
<[email protected]> wrote:
> On Thu, Oct 7, 2010 at 8:52 AM, Rui Miguel Silva Seabra <[email protected]> wrote:
>> For the record, in case someone searchs for the same problem:
>>
>> <raster> [Rui]: textwrap doesnt work in genlist. its basically not
>> possible (without massive overhead). so dont do it.
>> <raster> [Rui]: dont put wrapped text there
>> <raster> dont use genlist
>> <raster> genlist places limits on layout because it makes assumptions
>> <raster> to speed things up
>
> yeah, that's something I never expected and find quite limiting...
> I'll try to see what is possible to do with compress mode, or
> introduce another mode that is similar to it.
Okay, the attached patch makes it work, but it is slow* as Raster
warned us with his -- sometimes annoying -- wisdom.
The slowness is just when list width changes, as it is obvious that we
need to invalidate all item geometry and calculate them again. I
really don't see how to avoid this, it is theoretically impossible as
it is dependent on the variable :-) But the fact that calc_job() is
blocking does most of the harm... and it may happen in other cases as
well (for instance if one invalidates all items by calling
elm_genlist_item_update()).
Thus I'd like Raster's opinion on this patch and whenever it is okay
to have calc_job() loop to be an idler that is started from the job.
This idler would be reset whenever calc_job is re-requested and an
existing was being executed. I'll try to do this patch and send it to
mail list, but if you think it is a "NO GO" then say now and save me
some work ;-)
--
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--------------------------------------
MSN: [email protected]
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202
Index: src/lib/elm_genlist.c
===================================================================
--- src/lib/elm_genlist.c (revision 53110)
+++ src/lib/elm_genlist.c (working copy)
@@ -248,7 +248,7 @@
Evas_Object *obj, *scr, *pan_smart;
Eina_Inlist *items, *blocks;
Pan *pan;
- Evas_Coord pan_x, pan_y, minw, minh, realminw;
+ Evas_Coord pan_x, pan_y, w, h, minw, minh, realminw;
Ecore_Job *calc_job, *update_job;
Ecore_Idler *queue_idler;
Eina_List *queue, *selected;
@@ -263,6 +263,7 @@
Eina_Bool no_select : 1;
Eina_Bool bring_in : 1;
Eina_Bool compress : 1;
+ Eina_Bool height_for_width : 1;
Eina_Bool homogeneous : 1;
Eina_Bool clear_me : 1;
int walking;
@@ -1185,7 +1186,9 @@
if (!it->mincalcd)
{
Evas_Coord mw = -1, mh = -1;
-
+
+ if (it->wd->height_for_width) mw = it->wd->w;
+
if (!it->display_only)
elm_coords_finger_size_adjust(1, &mw, 1, &mh);
edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw, mh);
@@ -1411,10 +1414,19 @@
{
Widget_Data *wd = data;
Item_Block *itb;
- Evas_Coord minw = -1, minh = 0, y = 0, ow, oh;
+ Evas_Coord minw = -1, minh = 0, y = 0, ow;
Item_Block *chb = NULL;
int in = 0, minw_change = 0;
+ Eina_Bool changed = EINA_FALSE;
if (!wd) return;
+
+ evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
+ if (wd->w != ow)
+ {
+ wd->w = ow;
+ if (wd->height_for_width) changed = EINA_TRUE;
+ }
+
EINA_INLIST_FOREACH(wd->blocks, itb)
{
int showme = 0;
@@ -1426,8 +1438,16 @@
{
if (itb->realized) _item_block_unrealize(itb);
}
- if (itb->changed)
+ if ((itb->changed) || (changed))
{
+ if (changed)
+ {
+ Eina_List *l;
+ Elm_Genlist_Item *it;
+ EINA_LIST_FOREACH(itb->items, l, it)
+ if (it->mincalcd) it->mincalcd = EINA_FALSE;
+ itb->changed = EINA_TRUE;
+ }
if (itb->realized) _item_block_unrealize(itb);
showme = _item_block_recalc(itb, in, 0, 1);
chb = itb;
@@ -1478,9 +1498,8 @@
if (itb->realized) _item_block_unrealize(itb);
}
}
- evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &oh);
wd->realminw = minw;
- if (minw < ow) minw = ow;
+ if (minw < wd->w) minw = wd->w;
if ((minw != wd->minw) || (minh != wd->minh))
{
wd->minw = minw;
@@ -3582,6 +3601,59 @@
}
/**
+ * Set height-for-width mode
+ *
+ * With height-for-width mode the item width will be fixed (restricted
+ * to a minimum of) to the list width when calculating its size in
+ * order to allow the height to be calculated based on it. This allow,
+ * for instance, text block to wrap lines if the Edje part is
+ * configured with "text.min: 0 1".
+ *
+ * @note This mode will make list resize slower as it will have to
+ * recalculate every item height again whenever the list width
+ * changes!
+ *
+ * @note When height-for-width mode is enabled, it also enables
+ * compress mode (see elm_genlist_compress_mode_set()) and
+ * disables homogeneous (see elm_genlist_homogeneous_set()).
+ *
+ * @param obj The genlist object
+ * @param setting The height-for-width mode (EINA_TRUE = on, EINA_FALSE = off)
+ *
+ * @ingroup Genlist
+ */
+EAPI void
+elm_genlist_height_for_width_mode_set(Evas_Object *obj, Eina_Bool height_for_width)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return;
+ wd->height_for_width = !!height_for_width;
+ if (wd->height_for_width)
+ {
+ elm_genlist_homogeneous_set(obj, EINA_FALSE);
+ elm_genlist_compress_mode_set(obj, EINA_TRUE);
+ }
+}
+
+/**
+ * Get the height-for-width mode
+ *
+ * @param obj The genlist object
+ * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE = off)
+ *
+ * @ingroup Genlist
+ */
+EAPI Eina_Bool
+elm_genlist_height_for_width_mode_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->height_for_width;
+}
+
+/**
* Set bounce mode
*
* This will enable or disable the scroller bounce mode for the genlist. See
Index: src/lib/Elementary.h.in
===================================================================
--- src/lib/Elementary.h.in (revision 53110)
+++ src/lib/Elementary.h.in (working copy)
@@ -1269,6 +1269,8 @@
EAPI Eina_Bool elm_genlist_no_select_mode_get(const Evas_Object *obj);
EAPI void elm_genlist_compress_mode_set(Evas_Object *obj, Eina_Bool compress);
EAPI Eina_Bool elm_genlist_compress_mode_get(const Evas_Object *obj);
+ EAPI void elm_genlist_height_for_width_mode_set(Evas_Object *obj, Eina_Bool height_for_width);
+ EAPI Eina_Bool elm_genlist_height_for_width_mode_get(const Evas_Object *obj);
EAPI void elm_genlist_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce);
EAPI void elm_genlist_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce);
EAPI void elm_genlist_homogeneous_set(Evas_Object *obj, Eina_Bool homogeneous);
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
Spend less time writing and rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel