Guys,
Batch of patches covering most of SVN. I changed it a bit, but on top
of Cedric changes.
New version provides a need_recalculate flag for smart objects, this
flag, when set and SmartObject provides calculate(), will call this
function before doing any work on render. If not provided, this flag
will be untouched. There is also a way for users to call calculate
themselves, this is evas_object_smart_calculate(), that will help and
unset need_calculate.
With this change, we can even avoid the dirty flags spread all over
our code, replacing them with need_recalculate. This also gives a
common name, calculate, avoiding things like reconfigure, recalc, ...
So far edje makes minimal use of it, others don't use it at all.
Python bindings are exporting that to its users, but no example code
is provided yet.
TODO: we add objects to e->calculate_objects, but do not remove then
until render phase. If you have a need_render_set, unset, then set
again, you'll end with 2 entries for that object in the array. It's
not a big problem, because we check for need_recalculate before
calling the function and this flag is unset after the first call.
As Cedric, I'm using e17 with this patch and it works nicely. Please
comment on it, let's try to include it soon.
--
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--------------------------------------
MSN: [EMAIL PROTECTED]
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202
Index: edje/src/lib/edje_util.c
===================================================================
--- edje/src/lib/edje_util.c (revision 35583)
+++ edje/src/lib/edje_util.c (working copy)
@@ -715,6 +715,10 @@
ed = _edje_fetch(obj);
if ((!ed) || (!part)) return NULL;
+
+ /* Need to recalc before providing the object. */
+ _edje_recalc_do(ed);
+
rp = _edje_real_part_recursive_get(ed, (char *)part);
if (!rp) return NULL;
return rp->object;
@@ -748,6 +752,10 @@
if (h) *h = 0;
return;
}
+
+ /* Need to recalc before providing the object. */
+ _edje_recalc_do(ed);
+
rp = _edje_real_part_recursive_get(ed, (char *)part);
if (!rp)
{
@@ -828,6 +836,10 @@
ed = _edje_fetch(obj);
if ((!ed) || (!part)) return NULL;
+
+ /* Need to recalc before providing the object. */
+ _edje_recalc_do(ed);
+
rp = _edje_real_part_recursive_get(ed, (char *)part);
if (!rp) return NULL;
if (rp->part->type == EDJE_PART_TYPE_TEXT)
@@ -855,6 +867,10 @@
ed = _edje_fetch(obj);
if ((!ed) || (!part)) return;
+
+ /* Need to recalc before providing the object. */
+ _edje_recalc_do(ed);
+
rp = _edje_real_part_recursive_get(ed, (char *)part);
if (!rp) return;
if (rp->part->type != EDJE_PART_TYPE_SWALLOW) return;
@@ -1021,7 +1037,7 @@
rp->swallow_params.max.w = 0;
rp->swallow_params.max.h = 0;
rp->edje->dirty = 1;
- _edje_recalc(rp->edje);
+ _edje_recalc_do(rp->edje);
return;
}
}
@@ -1039,6 +1055,10 @@
ed = _edje_fetch(obj);
if ((!ed) || (!part)) return NULL;
+
+ /* Need to recalc before providing the object. */
+ _edje_recalc_do(ed);
+
rp = _edje_real_part_recursive_get(ed, (char *)part);
if (!rp) return NULL;
return rp->swallowed_object;
@@ -1088,6 +1108,10 @@
if (maxh) *maxh = 0;
return;
}
+
+ /* Need to recalc before providing the object. */
+ _edje_recalc_do(ed);
+
if (ed->collection->prop.max.w == 0)
{
/* XXX TODO: convert maxw to 0, fix things that break. */
@@ -1125,7 +1149,7 @@
ed->dirty = 1;
pf = ed->freeze;
ed->freeze = 0;
- _edje_recalc(ed);
+ _edje_recalc_do(ed);
ed->freeze = pf;
}
@@ -1187,7 +1211,7 @@
ok = 0;
ed->dirty = 1;
- _edje_recalc(ed);
+ _edje_recalc_do(ed);
if (reset_maxwh)
{
maxw = 0;
@@ -1291,6 +1315,10 @@
if (val_ret) *val_ret = 0;
return "";
}
+
+ /* Need to recalc before providing the object. */
+ _edje_recalc_do(ed);
+
rp = _edje_real_part_recursive_get(ed, (char *)part);
if (!rp)
{
@@ -1335,6 +1363,10 @@
ed = _edje_fetch(obj);
if ((!ed) || (!part)) return EDJE_DRAG_DIR_NONE;
+
+ /* Need to recalc before providing the object. */
+ _edje_recalc_do(ed);
+
rp = _edje_real_part_recursive_get(ed, (char *)part);
if (!rp) return EDJE_DRAG_DIR_NONE;
if ((rp->part->dragable.x) && (rp->part->dragable.y)) return
EDJE_DRAG_DIR_XY;
@@ -1399,6 +1431,10 @@
if (dy) *dy = 0;
return;
}
+
+ /* Need to recalc before providing the object. */
+ _edje_recalc_do(ed);
+
rp = _edje_real_part_recursive_get(ed, (char *)part);
if (!rp)
{
@@ -1464,6 +1500,10 @@
if (dh) *dh = 0;
return;
}
+
+ /* Need to recalc before providing the object. */
+ _edje_recalc_do(ed);
+
rp = _edje_real_part_recursive_get(ed, (char *)part);
if (!rp)
{
@@ -1522,6 +1562,10 @@
if (dy) *dy = 0;
return;
}
+
+ /* Need to recalc before providing the object. */
+ _edje_recalc_do(ed);
+
rp = _edje_real_part_recursive_get(ed, (char *)part);
if (!rp)
{
@@ -1580,6 +1624,10 @@
if (dy) *dy = 0;
return;
}
+
+ /* Need to recalc before providing the object. */
+ _edje_recalc_do(ed);
+
rp = _edje_real_part_recursive_get(ed, (char *)part);
if (!rp)
{
@@ -2097,5 +2145,5 @@
evas_object_precise_is_inside_set(obj_swallow, 1);
rp->edje->dirty = 1;
- _edje_recalc(rp->edje);
+ _edje_recalc_do(rp->edje);
}
Index: edje/src/lib/edje_private.h
===================================================================
--- edje/src/lib/edje_private.h (revision 35583)
+++ edje/src/lib/edje_private.h (working copy)
@@ -681,6 +681,7 @@
unsigned short walking_actions : 1;
unsigned short block_break : 1;
unsigned short delete_me : 1;
+ unsigned short postponed : 1;
};
struct _Edje_Real_Part
@@ -1007,6 +1008,7 @@
Edje_Part_Description *_edje_part_description_find(Edje *ed, Edje_Real_Part
*rp, const char *name, double val);
void _edje_part_description_apply(Edje *ed, Edje_Real_Part *ep, const char
*d1, double v1, const char *d2, double v2);
void _edje_recalc(Edje *ed);
+void _edje_recalc_do(Edje *ed);
int _edje_part_dragable_calc(Edje *ed, Edje_Real_Part *ep, double *x, double
*y);
void _edje_dragable_pos_set(Edje *ed, Edje_Real_Part *ep, double x, double y);
Index: edje/src/lib/edje_smart.c
===================================================================
--- edje/src/lib/edje_smart.c (revision 35583)
+++ edje/src/lib/edje_smart.c (working copy)
@@ -13,6 +13,7 @@
static void _edje_smart_color_set(Evas_Object * obj, int r, int g, int b, int
a);
static void _edje_smart_clip_set(Evas_Object * obj, Evas_Object * clip);
static void _edje_smart_clip_unset(Evas_Object * obj);
+static void _edje_smart_calculate(Evas_Object * obj);
static Evas_Smart *_edje_smart = NULL;
@@ -45,6 +46,7 @@
_edje_smart_color_set,
_edje_smart_clip_set,
_edje_smart_clip_unset,
+ _edje_smart_calculate,
NULL
};
_edje_smart = evas_smart_class_new(&sc);
@@ -237,3 +239,13 @@
evas_object_clip_unset(ed->clipper);
// _edje_emit(ed, "clip_unset", NULL);
}
+
+static void
+_edje_smart_calculate(Evas_Object *obj)
+{
+ Edje *ed;
+
+ ed = evas_object_smart_data_get(obj);
+ if (!ed) return;
+ _edje_recalc_do(ed);
+}
Index: edje/src/lib/edje_calc.c
===================================================================
--- edje/src/lib/edje_calc.c (revision 35583)
+++ edje/src/lib/edje_calc.c (working copy)
@@ -136,13 +136,22 @@
void
_edje_recalc(Edje *ed)
{
+ if (ed->postponed) return ;
+ evas_object_smart_changed(ed->obj);
+ ed->postponed = 1;
+}
+
+void
+_edje_recalc_do(Edje *ed)
+{
int i;
if (!ed->dirty) return;
if (ed->freeze)
{
ed->recalc = 1;
- if (!ed->calc_only) return;
+ if (!ed->calc_only &&
+ !ed->postponed) return;
}
for (i = 0; i < ed->table_parts_size; i++)
{
@@ -161,6 +170,7 @@
_edje_part_recalc(ed, ep, (~ep->calculated) & FLAG_XY);
}
ed->dirty = 0;
+ ed->postponed = 0;
if (!ed->calc_only) ed->recalc = 0;
}
Index: e/src/bin/e_fm.c
===================================================================
--- e/src/bin/e_fm.c (revision 35583)
+++ e/src/bin/e_fm.c (working copy)
@@ -418,6 +418,7 @@
_e_fm2_smart_color_set, /* color_set */
_e_fm2_smart_clip_set, /* clip_set */
_e_fm2_smart_clip_unset, /* clip_unset */
+ NULL,
NULL
};
_e_fm2_smart = evas_smart_class_new(&sc);
Index: e/src/bin/e_box.c
===================================================================
--- e/src/bin/e_box.c (revision 35583)
+++ e/src/bin/e_box.c (working copy)
@@ -652,6 +652,7 @@
_e_box_smart_color_set,
_e_box_smart_clip_set,
_e_box_smart_clip_unset,
+ NULL,
NULL
};
_e_smart = evas_smart_class_new(&sc);
Index: e/src/bin/e_gadcon.c
===================================================================
--- e/src/bin/e_gadcon.c (revision 35583)
+++ e/src/bin/e_gadcon.c (working copy)
@@ -3108,6 +3108,7 @@
_e_gadcon_layout_smart_color_set,
_e_gadcon_layout_smart_clip_set,
_e_gadcon_layout_smart_clip_unset,
+ NULL,
NULL
};
_e_smart = evas_smart_class_new(&sc);
Index: e/src/bin/e_ilist.c
===================================================================
--- e/src/bin/e_ilist.c (revision 35583)
+++ e/src/bin/e_ilist.c (working copy)
@@ -799,6 +799,7 @@
_e_smart_color_set,
_e_smart_clip_set,
_e_smart_clip_unset,
+ NULL,
NULL
};
_e_smart = evas_smart_class_new(&sc);
Index: e/src/bin/e_livethumb.c
===================================================================
--- e/src/bin/e_livethumb.c (revision 35583)
+++ e/src/bin/e_livethumb.c (working copy)
@@ -210,6 +210,7 @@
_e_smart_color_set,
_e_smart_clip_set,
_e_smart_clip_unset,
+ NULL,
NULL
};
_e_smart = evas_smart_class_new(&sc);
Index: e/src/bin/e_flowlayout.c
===================================================================
--- e/src/bin/e_flowlayout.c (revision 35583)
+++ e/src/bin/e_flowlayout.c (working copy)
@@ -836,6 +836,7 @@
_e_flowlayout_smart_color_set,
_e_flowlayout_smart_clip_set,
_e_flowlayout_smart_clip_unset,
+ NULL,
NULL
};
_e_smart = evas_smart_class_new(&sc);
Index: e/src/bin/e_tlist.c
===================================================================
--- e/src/bin/e_tlist.c (revision 35583)
+++ e/src/bin/e_tlist.c (working copy)
@@ -537,7 +537,7 @@
EVAS_SMART_CLASS_VERSION,
_e_smart_add, _e_smart_del, _e_smart_move, _e_smart_resize,
_e_smart_show, _e_smart_hide, _e_smart_color_set,
- _e_smart_clip_set, _e_smart_clip_unset, NULL
+ _e_smart_clip_set, _e_smart_clip_unset, NULL, NULL
};
_e_smart = evas_smart_class_new(&sc);
}
Index: e/src/bin/e_icon.c
===================================================================
--- e/src/bin/e_icon.c (revision 35583)
+++ e/src/bin/e_icon.c (working copy)
@@ -345,6 +345,7 @@
_e_icon_smart_color_set,
_e_icon_smart_clip_set,
_e_icon_smart_clip_unset,
+ NULL,
NULL
};
_e_smart = evas_smart_class_new(&sc);
Index: e/src/bin/e_spectrum.c
===================================================================
--- e/src/bin/e_spectrum.c (revision 35583)
+++ e/src/bin/e_spectrum.c (working copy)
@@ -167,6 +167,7 @@
_e_spectrum_smart_color_set,
_e_spectrum_smart_clip_set,
_e_spectrum_smart_clip_unset,
+ NULL,
NULL
};
_e_spectrum_smart = evas_smart_class_new(&sc);
Index: e/src/bin/e_entry.c
===================================================================
--- e/src/bin/e_entry.c (revision 35583)
+++ e/src/bin/e_entry.c (working copy)
@@ -99,6 +99,7 @@
_e_entry_color_set,
_e_entry_clip_set,
_e_entry_clip_unset,
+ NULL,
NULL
};
_e_entry_smart = evas_smart_class_new(&sc);
Index: e/src/bin/e_pan.c
===================================================================
--- e/src/bin/e_pan.c (revision 35583)
+++ e/src/bin/e_pan.c (working copy)
@@ -263,6 +263,7 @@
_e_smart_color_set,
_e_smart_clip_set,
_e_smart_clip_unset,
+ NULL,
NULL
};
_e_smart = evas_smart_class_new(&sc);
Index: e/src/bin/e_layout.c
===================================================================
--- e/src/bin/e_layout.c (revision 35583)
+++ e/src/bin/e_layout.c (working copy)
@@ -364,6 +364,7 @@
_e_layout_smart_color_set,
_e_layout_smart_clip_set,
_e_layout_smart_clip_unset,
+ NULL,
NULL
};
_e_smart = evas_smart_class_new(&sc);
Index: e/src/bin/e_table.c
===================================================================
--- e/src/bin/e_table.c (revision 35583)
+++ e/src/bin/e_table.c (working copy)
@@ -839,6 +839,7 @@
_e_table_smart_color_set,
_e_table_smart_clip_set,
_e_table_smart_clip_unset,
+ NULL,
NULL
};
_e_smart = evas_smart_class_new(&sc);
Index: e/src/bin/e_scrollframe.c
===================================================================
--- e/src/bin/e_scrollframe.c (revision 35583)
+++ e/src/bin/e_scrollframe.c (working copy)
@@ -1042,6 +1042,7 @@
_e_smart_color_set,
_e_smart_clip_set,
_e_smart_clip_unset,
+ NULL,
NULL
};
_e_smart = evas_smart_class_new(&sc);
Index: e/src/bin/e_slidesel.c
===================================================================
--- e/src/bin/e_slidesel.c (revision 35583)
+++ e/src/bin/e_slidesel.c (working copy)
@@ -366,6 +366,7 @@
_e_smart_color_set,
_e_smart_clip_set,
_e_smart_clip_unset,
+ NULL,
NULL
};
_e_smart = evas_smart_class_new(&sc);
Index: e/src/bin/e_slidecore.c
===================================================================
--- e/src/bin/e_slidecore.c (revision 35583)
+++ e/src/bin/e_slidecore.c (working copy)
@@ -410,6 +410,7 @@
_e_smart_color_set,
_e_smart_clip_set,
_e_smart_clip_unset,
+ NULL,
NULL
};
_e_smart = evas_smart_class_new(&sc);
Index: e/src/bin/e_editable.c
===================================================================
--- e/src/bin/e_editable.c (revision 35583)
+++ e/src/bin/e_editable.c (working copy)
@@ -87,6 +87,7 @@
_e_editable_color_set,
_e_editable_clip_set,
_e_editable_clip_unset,
+ NULL,
NULL
};
_e_editable_smart = evas_smart_class_new(&sc);
Index: e/src/bin/e_slider.c
===================================================================
--- e/src/bin/e_slider.c (revision 35583)
+++ e/src/bin/e_slider.c (working copy)
@@ -542,6 +542,7 @@
_e_smart_color_set,
_e_smart_clip_set,
_e_smart_clip_unset,
+ NULL,
NULL
};
_e_smart = evas_smart_class_new(&sc);
Index: e/src/bin/e_widget.c
===================================================================
--- e/src/bin/e_widget.c (revision 35583)
+++ e/src/bin/e_widget.c (working copy)
@@ -577,6 +577,7 @@
_e_smart_color_set,
_e_smart_clip_set,
_e_smart_clip_unset,
+ NULL,
NULL
};
_e_smart = evas_smart_class_new(&sc);
Index: etk/src/lib/etk_editable.c
===================================================================
--- etk/src/lib/etk_editable.c (revision 35583)
+++ etk/src/lib/etk_editable.c (working copy)
@@ -117,6 +117,7 @@
_etk_editable_color_set,
_etk_editable_clip_set,
_etk_editable_clip_unset,
+ NULL,
NULL
};
_etk_editable_smart = evas_smart_class_new(&sc);
Index: etk/src/lib/etk_colorpicker.c
===================================================================
--- etk/src/lib/etk_colorpicker.c (revision 35583)
+++ etk/src/lib/etk_colorpicker.c (working copy)
@@ -938,6 +938,7 @@
NULL,
_etk_colorpicker_picker_smart_clip_set,
_etk_colorpicker_picker_smart_clip_unset,
+ NULL,
NULL
};
_etk_colorpicker_picker_smart = evas_smart_class_new(&sc);
Index: etk/src/lib/etk_widget.c
===================================================================
--- etk/src/lib/etk_widget.c (revision 35583)
+++ etk/src/lib/etk_widget.c (working copy)
@@ -3157,6 +3157,7 @@
_etk_widget_smart_object_color_set_cb, /* color_set */
_etk_widget_smart_object_clip_set_cb, /* clip_set */
_etk_widget_smart_object_clip_unset_cb, /* clip_unset */
+ NULL,
NULL
};
_etk_widget_smart_object_smart = evas_smart_class_new(&sc);
@@ -3477,6 +3478,7 @@
NULL, /* color_set */
_etk_widget_content_object_clip_set_cb, /* clip_set */
_etk_widget_content_object_clip_unset_cb, /* clip_unset */
+ NULL,
NULL
};
_etk_widget_content_object_smart = evas_smart_class_new(&sc);
Index: etk/src/lib/etk_textblock.c
===================================================================
--- etk/src/lib/etk_textblock.c (revision 35583)
+++ etk/src/lib/etk_textblock.c (working copy)
@@ -1095,6 +1095,7 @@
_etk_tb_object_smart_color_set,
_etk_tb_object_smart_clip_set,
_etk_tb_object_smart_clip_unset,
+ NULL,
NULL
};
_etk_tb_object_smart = evas_smart_class_new(&sc);
Index: etk/src/lib/etk_textblock2.c
===================================================================
--- etk/src/lib/etk_textblock2.c (revision 35583)
+++ etk/src/lib/etk_textblock2.c (working copy)
@@ -1582,6 +1582,7 @@
_etk_tb2_object_smart_color_set,
_etk_tb2_object_smart_clip_set,
_etk_tb2_object_smart_clip_unset,
+ NULL,
NULL
};
Index: ewl/src/lib/ewl_widget.c
===================================================================
--- ewl/src/lib/ewl_widget.c (revision 35583)
+++ ewl/src/lib/ewl_widget.c (working copy)
@@ -2451,7 +2451,7 @@
"Ewl Widget Smart Object",
EVAS_SMART_CLASS_VERSION,
NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL
+ NULL, NULL, NULL, NULL, NULL,
NULL
};
widget_smart = evas_smart_class_new(&sc);
}
Index: ewl/src/lib/ewl_embed.c
===================================================================
--- ewl/src/lib/ewl_embed.c (revision 35583)
+++ ewl/src/lib/ewl_embed.c (working copy)
@@ -232,6 +232,7 @@
NULL,
ewl_embed_smart_cb_clip_set,
ewl_embed_smart_cb_clip_unset,
+ NULL,
NULL
};
embedded_smart = evas_smart_class_new(&sc);
Index: PROTO/edvi/src/lib/esmart_dvi.c
===================================================================
--- PROTO/edvi/src/lib/esmart_dvi.c (revision 35583)
+++ PROTO/edvi/src/lib/esmart_dvi.c (working copy)
@@ -477,6 +477,7 @@
_smart_color_set,
_smart_clip_set,
_smart_clip_unset,
+ NULL,
NULL
};
smart = evas_smart_class_new(&sc);
Index: PROTO/epdf/src/lib/esmart_pdf.c
===================================================================
--- PROTO/epdf/src/lib/esmart_pdf.c (revision 35583)
+++ PROTO/epdf/src/lib/esmart_pdf.c (working copy)
@@ -471,6 +471,7 @@
_smart_color_set,
_smart_clip_set,
_smart_clip_unset,
+ NULL,
NULL
};
smart = evas_smart_class_new(&sc);
Index: emotion/src/lib/emotion_smart.c
===================================================================
--- emotion/src/lib/emotion_smart.c (revision 35583)
+++ emotion/src/lib/emotion_smart.c (working copy)
@@ -1164,6 +1164,7 @@
_smart_color_set,
_smart_clip_set,
_smart_clip_unset,
+ NULL,
NULL
};
smart = evas_smart_class_new(&sc);
Index: BINDINGS/python/python-evas/include/evas/c_evas.pxd
===================================================================
--- BINDINGS/python/python-evas/include/evas/c_evas.pxd (revision 35583)
+++ BINDINGS/python/python-evas/include/evas/c_evas.pxd (working copy)
@@ -155,6 +155,7 @@
void (*color_set)(Evas_Object *o, int r, int g, int b, int a)
void (*clip_set)(Evas_Object *o, Evas_Object *clip)
void (*clip_unset)(Evas_Object *o)
+ void (*calculate)(Evas_Object *o)
void *data
@@ -446,8 +447,13 @@
void evas_object_smart_callback_add(Evas_Object *obj, char *event, void
(*func) (void *data, Evas_Object *obj, void *event_info), void *data)
void *evas_object_smart_callback_del(Evas_Object *obj, char *event, void
(*func) (void *data, Evas_Object *obj, void *event_info))
void evas_object_smart_callback_call(Evas_Object *obj, char *event, void
*event_info)
+ void evas_object_smart_changed(Evas_Object *obj)
+ void evas_object_smart_need_recalculate_set(Evas_Object *obj, int value)
+ int evas_object_smart_need_recalculate_get(Evas_Object *obj)
+ void evas_object_smart_calculate(Evas_Object *obj)
+
####################################################################
# Rectangle Object
#
@@ -709,6 +715,7 @@
cdef object _m_color_set
cdef object _m_clip_set
cdef object _m_clip_unset
+ cdef object _m_calculate
cdef public class Rectangle(Object) [object PyEvasRectangle,
Index: BINDINGS/python/python-evas/evas/evas.c_evas_object_smart.pxi
===================================================================
--- BINDINGS/python/python-evas/evas/evas.c_evas_object_smart.pxi
(revision 35583)
+++ BINDINGS/python/python-evas/evas/evas.c_evas_object_smart.pxi
(working copy)
@@ -63,6 +63,10 @@
del obj.clip_unset
except AttributeError, e:
pass
+ try:
+ del obj.calculate
+ except AttributeError, e:
+ pass
obj._smart_callbacks = None
obj._m_delete = None
@@ -73,6 +77,7 @@
obj._m_color_set = None
obj._m_clip_set = None
obj._m_clip_unset = None
+ obj._m_calculate = None
cdef void _smart_object_move(Evas_Object *o,
@@ -150,6 +155,16 @@
traceback.print_exc()
+cdef void _smart_object_calculate(Evas_Object *o) with gil:
+ cdef SmartObject obj
+ obj = <SmartObject>evas_object_data_get(o, "python-evas")
+ if obj._m_calculate is not None:
+ try:
+ obj._m_calculate(obj)
+ except Exception, e:
+ traceback.print_exc()
+
+
cdef void _smart_callback(void *data,
Evas_Object *o, void *event_info) with gil:
cdef SmartObject obj
@@ -189,6 +204,7 @@
cls_def.color_set = _smart_object_color_set
cls_def.clip_set = _smart_object_clip_set
cls_def.clip_unset = _smart_object_clip_unset
+ cls_def.calculate = _smart_object_calculate
cls_def.data = NULL
cls = evas_smart_class_new(cls_def);
@@ -218,6 +234,16 @@
return meth
+cdef object _smart_class_get_impl_method_cls(object cls, object parent_cls,
+ char *name):
+ meth = getattr(cls, name)
+ orig = getattr(parent_cls, name)
+ if meth is orig:
+ return None
+ else:
+ return meth
+
+
cdef public class SmartObject(Object) [object PyEvasSmartObject,
type PyEvasSmartObject_Type]:
"""Smart Evas Objects.
@@ -256,6 +282,9 @@
I{No default implementation.}
- L{clip_unset()}: called in order to unlimit object's visible area.
I{No default implementation.}
+ - L{calculate()}: called before object is used for rendering and it is
+ marked as dirty/changed with L{changed()}. I{Default implementation
+ does nothing.}
@note: You should never instantiate the SmartObject base class directly,
but inherit and implement methods, then instantiate this new subclass.
@@ -272,7 +301,7 @@
members
@group Factories: Rectangle, Line, Image, FilledImage, Gradient,
Polygon, Text
- @group Default implementations: delete, move
+ @group Default implementations: delete, move, calculate
@group Missing implementations: resize, show, hide, color_set,
clip_set, clip_unset
@group Event system: callback_add, callback_del, callback_call
@@ -306,6 +335,11 @@
self._m_clip_unset = _smart_class_get_impl_method(cls, "clip_unset")
if self._m_clip_unset is not None:
self.clip_unset = python.PyMethod_New(Object.clip_unset, self, cls)
+ self._m_calculate = _smart_class_get_impl_method_cls(
+ cls, SmartObject, "calculate")
+ if self._m_calculate is not None:
+ self.calculate = python.PyMethod_New(
+ SmartObject.calculate, self, cls)
def __dealloc__(self):
self._smart_callbacks = None
@@ -489,7 +523,59 @@
"Virtual method clip_unset() of SmartObject"
print "%s.clip_unset() not implemented." % self.__class__.__name__
+ def calculate(self):
+ "Request object to recalculate it's internal state."
+ evas_object_smart_calculate(self.obj)
+ def changed(self):
+ """Mark object as changed, so it's L{calculate()} will be called.
+
+ If an object is changed and it provides a calculate() method,
+ it will be called from L{Evas.render()}, what we call pre-render
+ calculate.
+
+ This can be used to postpone heavy calculations until you need to
+ display the object, example: layout calculations.
+ """
+ evas_object_smart_changed(self.obj)
+
+ def need_recalculate_set(self, unsigned int value):
+ """Set need_recalculate flag.
+
+ Set the need_recalculate flag of given smart object.
+
+ If this flag is set then calculate() callback (method) of the
+ given smart object will be called, if one is provided, during
+ render phase usually evas_render(). After this step, this flag
+ will be automatically unset.
+
+ If no calculate() is provided, this flag will be left unchanged.
+
+ @note just setting this flag will not make scene dirty and
+ evas_render() will have no effect. To do that, use
+ evas_object_smart_changed(), that will automatically call this
+ function with 1 as parameter.
+
+ """
+ evas_object_smart_need_recalculate_set(self.obj, value)
+
+ def need_recalculate_get(self):
+ """Get the current value of need_recalculate flag.
+
+ @note this flag will be unset during the render phase, after
+ calculate() is called if one is provided. If no calculate()
+ is provided, then the flag will be left unchanged after render
+ phase.
+ """
+ return evas_object_smart_need_recalculate_get(self.obj)
+
+ property need_recalculate:
+ def __set__(self, value):
+ self.need_recalculate_set(value)
+
+ def __get__(self):
+ self.need_recalculate_get()
+
# Factory
def Rectangle(self, **kargs):
"""Factory of children L{evas.Rectangle}.
@@ -571,7 +657,7 @@
@group Children manipulation: member_add, member_del
@group Default implementations: delete, move, show, hide, color_set,
- clip_set, clip_unset
+ clip_set, clip_unset, calculate
@ivar clipper: the internal object used for clipping. You shouldn't
mess with it.
"""
Index: evas/src/lib/include/evas_private.h
===================================================================
--- evas/src/lib/include/evas_private.h (revision 35583)
+++ evas/src/lib/include/evas_private.h (working copy)
@@ -283,6 +283,7 @@
Evas_Array pending_objects;
Evas_Array obscuring_objects;
Evas_Array temporary_objects;
+ Evas_Array calculate_objects;
int delete_grabs;
int walking_grabs;
@@ -681,6 +682,7 @@
void evas_object_smart_member_stack_above(Evas_Object *member, Evas_Object
*other);
void evas_object_smart_member_stack_below(Evas_Object *member, Evas_Object
*other);
const Evas_Object_List *evas_object_smart_members_get_direct(const Evas_Object
*obj);
+void evas_call_smarts_calculate(Evas *e);
void *evas_mem_calloc(int size);
void evas_object_event_callback_all_del(Evas_Object *obj);
void evas_object_event_callback_cleanup(Evas_Object *obj);
Index: evas/src/lib/Evas.h
===================================================================
--- evas/src/lib/Evas.h (revision 35583)
+++ evas/src/lib/Evas.h (working copy)
@@ -129,7 +129,7 @@
} Evas_Aspect_Control;
-#define EVAS_SMART_CLASS_VERSION 1 /** the version you have to put into the
version field in the smart class struct */
+#define EVAS_SMART_CLASS_VERSION 2 /** the version you have to put into the
version field in the smart class struct */
struct _Evas_Smart_Class /** a smart object class */
{
const char *name; /** the string name of the class */
@@ -145,6 +145,7 @@
void (*color_set) (Evas_Object *o, int r, int g, int b, int a); //
FIXME: DELETE ME
void (*clip_set) (Evas_Object *o, Evas_Object *clip); // FIXME: DELETE
ME
void (*clip_unset) (Evas_Object *o); // FIXME: DELETE ME
+ void (*calculate) (Evas_Object *o);
const void *data;
};
@@ -738,6 +739,9 @@
EAPI void evas_object_smart_callback_add (Evas_Object *obj,
const char *event, void (*func) (void *data, Evas_Object *obj, void
*event_info), const void *data);
EAPI void *evas_object_smart_callback_del (Evas_Object *obj,
const char *event, void (*func) (void *data, Evas_Object *obj, void
*event_info));
EAPI void evas_object_smart_callback_call (Evas_Object *obj,
const char *event, void *event_info);
+ EAPI void evas_object_smart_changed (Evas_Object *obj);
+ EAPI void evas_object_smart_need_recalculate_set(Evas_Object
*obj, Evas_Bool value);
+ EAPI Evas_Bool evas_object_smart_need_recalculate_get(Evas_Object
*obj);
/* events */
EAPI void evas_event_freeze (Evas *e);
Index: evas/src/lib/canvas/evas_main.c
===================================================================
--- evas/src/lib/canvas/evas_main.c (revision 35583)
+++ evas/src/lib/canvas/evas_main.c (working copy)
@@ -70,6 +70,7 @@
evas_array_setup(&e->pending_objects, 16);
evas_array_setup(&e->obscuring_objects, 16);
evas_array_setup(&e->temporary_objects, 16);
+ evas_array_setup(&e->calculate_objects, 16);
return e;
}
Index: evas/src/lib/canvas/evas_object_smart.c
===================================================================
--- evas/src/lib/canvas/evas_object_smart.c (revision 35583)
+++ evas/src/lib/canvas/evas_object_smart.c (working copy)
@@ -13,6 +13,7 @@
Evas_Object_List *contained;
int walking_list;
Evas_Bool deletions_waiting : 1;
+ Evas_Bool need_recalculate : 1;
};
struct _Evas_Smart_Callback
@@ -429,6 +430,138 @@
evas_object_smart_callbacks_clear(obj);
}
+/**
+ * Set the need_recalculate flag of given smart object.
+ *
+ * If this flag is set then calculate() callback (method) of the given
+ * smart object will be called, if one is provided, during render phase
+ * usually evas_render(). After this step, this flag will be automatically
+ * unset.
+ *
+ * If no calculate() is provided, this flag will be left unchanged.
+ *
+ * @note just setting this flag will not make scene dirty and evas_render()
+ * will have no effect. To do that, use evas_object_smart_changed(),
+ * that will automatically call this function with 1 as parameter.
+ *
+ * @param obj the smart object
+ * @param value if one want to set or unset the need_recalculate flag.
+ *
+ * @ingroup Evas_Smart_Object_Group
+ */
+EAPI void
+evas_object_smart_need_recalculate_set(Evas_Object *obj, Evas_Bool value)
+{
+ Evas_Object_Smart *o;
+ MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
+ return;
+ MAGIC_CHECK_END();
+ o = obj->object_data;
+ MAGIC_CHECK(o, Evas_Object_Smart, MAGIC_OBJ_SMART);
+ return;
+ MAGIC_CHECK_END();
+
+ value = !!value;
+ if (o->need_recalculate == value)
+ return;
+ o->need_recalculate = value;
+
+ if (!obj->smart.smart->smart_class->calculate)
+ return;
+
+ /* XXX: objects can be present multiple times in calculate_objects()
+ * XXX: after a set-unset-set cycle, but it's not a problem since
+ * XXX: on _evas_render_call_smart_calculate() will check for the flag
+ * XXX: and it will be unset after the first.
+ */
+ if (o->need_recalculate)
+ {
+ Evas *e;
+ e = obj->layer->evas;
+ _evas_array_append(&e->calculate_objects, obj);
+ }
+ /* TODO: else, remove from array */
+}
+
+/**
+ * Get the current value of need_recalculate flag.
+ *
+ * @note this flag will be unset during the render phase, after calculate()
+ * is called if one is provided. If no calculate() is provided, then
+ * the flag will be left unchanged after render phase.
+ *
+ * @param obj the smart object
+ * @return if flag is set or not.
+ *
+ * @ingroup Evas_Smart_Object_Group
+ */
+EAPI Evas_Bool
+evas_object_smart_need_recalculate_get(Evas_Object *obj)
+{
+ Evas_Object_Smart *o;
+ MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
+ return;
+ MAGIC_CHECK_END();
+ o = obj->object_data;
+ MAGIC_CHECK(o, Evas_Object_Smart, MAGIC_OBJ_SMART);
+ return;
+ MAGIC_CHECK_END();
+
+ return o->need_recalculate;
+}
+
+/**
+ * Call calculate() on all smart objects that need_recalculate.
+ *
+ * @internal
+ */
+void
+evas_call_smarts_calculate(Evas *e)
+{
+ Evas_Array *calculate;
+ unsigned int i;
+
+ calculate = &e->calculate_objects;
+ for (i = 0; i < calculate->count; ++i)
+ {
+ Evas_Object *obj;
+ Evas_Object_Smart *o;
+
+ obj = _evas_array_get(calculate, i);
+ if (obj->delete_me)
+ continue;
+
+ o = obj->object_data;
+ if (o->need_recalculate)
+ {
+ obj->smart.smart->smart_class->calculate(obj);
+ o->need_recalculate = 0;
+ }
+ }
+
+ evas_array_flush(calculate);
+}
+
+/**
+ * Mark smart object as changed, dirty.
+ *
+ * This will inform the scene that it changed and needs to be redraw, also
+ * setting need_recalculate on the given object.
+ *
+ * @see evas_object_smart_need_recalculate_set().
+ *
+ * @ingroup Evas_Smart_Object_Group
+ */
+EAPI void
+evas_object_smart_changed(Evas_Object *obj)
+{
+ MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
+ return;
+ MAGIC_CHECK_END();
+ evas_object_change(obj);
+ evas_object_smart_need_recalculate_set(obj, 1);
+}
+
/* internal calls */
static void
evas_object_smart_callbacks_clear(Evas_Object *obj)
Index: evas/src/lib/canvas/evas_render.c
===================================================================
--- evas/src/lib/canvas/evas_render.c (revision 35583)
+++ evas/src/lib/canvas/evas_render.c (working copy)
@@ -341,6 +341,8 @@
MAGIC_CHECK_END();
if (!e->changed) return NULL;
+ evas_call_smarts_calculate(e);
+
/* Check if the modified object mean recalculating every thing */
if (!e->invalidate)
_evas_render_check_pending_objects(&e->pending_objects, e);
-------------------------------------------------------------------------
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-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel