2012-03-11 Cedric Bail
* Propagate scale factor to GROUP's part.
+
+2012-03-12 Cedric Bail
+
+ * Make it possible for edje to update size hint automatically.
+ * Add min: SOURCE to GROUP's part.
* EDJE_ASPECT_PREFER_SOURCE.
* edje.version() Lua function.
* minmul edc property.
- * add min: SOURCE and max: SOURCE.
+ * add min: SOURCE and max: SOURCE to IMAGE and GROUP parts.
* add edje_object_markup_filter_callback_add/del/delfull().
* add broadcast_signal: bool.
* add edje_object_part_text_imf_context_get()
+ * add edje_object_update_hints_set() and edje_object_update_hints_get()
Improvements:
* speedup load time of Edje file.
When min is defined to SOURCE, it will look at the original
image size and enforce it minimal size to match at least the
- original one. The part must be an IMAGE part.
+ original one. The part must be an IMAGE or a GROUP part.
@endproperty
*/
static void
current_desc->min.w = parse_float_range(0, 0, 0x7fffffff);
current_desc->min.h = parse_float_range(1, 0, 0x7fffffff);
} else {
- Edje_Part_Description_Image *desc;
char *tmp;
tmp = parse_str(0);
- if (current_part->type != EDJE_PART_TYPE_IMAGE ||
+ if ((current_part->type != EDJE_PART_TYPE_IMAGE && current_part->type != EDJE_PART_TYPE_GROUP) ||
!tmp || strcmp(tmp, "SOURCE") != 0)
{
ERR("%s: Error. parse error %s:%i. "
- "Only IMAGE part can have a min: SOURCE; defined",
+ "Only IMAGE and GROUP part can have a min: SOURCE; defined",
progname, file_in, line - 1);
exit(-1);
}
- desc = (Edje_Part_Description_Image *) current_desc;
- desc->image.min.limit = EINA_TRUE;
+ current_desc->min.limit = EINA_TRUE;
}
}
current_desc->max.w = parse_float_range(0, -1.0, 0x7fffffff);
current_desc->max.h = parse_float_range(1, -1.0, 0x7fffffff);
} else {
- Edje_Part_Description_Image *desc;
char *tmp;
tmp = parse_str(0);
exit(-1);
}
- desc = (Edje_Part_Description_Image *) current_desc;
- desc->image.max.limit = EINA_TRUE;
+ current_desc->max.limit = EINA_TRUE;
}
}
EAPI void edje_object_size_min_get (const Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh);
/**
+ * @brief Edje will automatically update the size hints on itself.
+ *
+ * @param obj A handle to an Edje object.
+ * @param update Wether or not update the size hints.
+ *
+ * By default edje doesn't set size hints on itself. With this function
+ * call, it will do so if update is true. Be carefull, it cost a lot to
+ * trigger this feature as it will recalc the object every time it make
+ * sense to be sure that's its minimal size hint is always accurate.
+ */
+EAPI void edje_object_update_hints_set(Evas_Object *obj, Eina_Bool update);
+
+/**
+ * @brief Wether or not Edje will update size hints on itself.
+ *
+ * @param obj A handle to an Edje object.
+ * @return @c true if does, @c false if it doesn't.
+ */
+EAPI Eina_Bool edje_object_update_hints_get(Evas_Object *obj);
+
+/**
* @brief Get the maximum size specified -- as an EDC property -- for a
* given Edje object
*
npos = fp_pos;
break;
}
-#endif
+#endif
if (npos == ep->description_pos) return;
ep->description_pos = npos;
ep->part->type == EDJE_PART_TYPE_EXTERNAL)
_edje_external_recalc_apply(ed, ep, NULL, chosen_desc);
+ ed->recalc_hints = 1;
ed->dirty = 1;
ed->recalc_call = 1;
#ifdef EDJE_CALC_CACHE
else
evas_object_smart_need_recalculate_set(ed->obj, need_calc);
ed->recalc_call = 0;
+
+ if (ed->update_hints && ed->recalc_hints && !ed->calc_only)
+ {
+ Evas_Coord w, h;
+
+ ed->recalc_hints = 0;
+
+ edje_object_size_min_calc(ed->obj, &w, &h);
+ evas_object_size_hint_min_set(ed->obj, w, h);
+ }
}
void
}
}
else if ((ep->part->type == EDJE_PART_TYPE_IMAGE) &&
- ((((Edje_Part_Description_Image *)chosen_desc)->image.min.limit) ||
- (((Edje_Part_Description_Image *)chosen_desc)->image.max.limit)))
+ (chosen_desc->min.limit || chosen_desc->max.limit))
{
Evas_Coord w, h;
_edje_real_part_image_set(ed, ep, pos);
evas_object_image_size_get(ep->object, &w, &h);
- if (((Edje_Part_Description_Image *)chosen_desc)->image.min.limit)
+ if (chosen_desc->min.limit)
{
if (w > minw) minw = w;
if (h > minh) minh = h;
}
- if (((Edje_Part_Description_Image *)chosen_desc)->image.max.limit)
+ if (chosen_desc->max.limit)
{
if ((maxw <= 0) || (w < maxw)) maxw = w;
if ((maxh <= 0) || (h < maxh)) maxh = h;
if (ep->part->scale &&
ep->part->type == EDJE_PART_TYPE_GROUP &&
ep->swallowed_object)
- edje_object_scale_set(ep->swallowed_object, TO_DOUBLE(ed->scale));
+ {
+ edje_object_scale_set(ep->swallowed_object, TO_DOUBLE(ed->scale));
+
+ if (ep->description_pos > FROM_DOUBLE(0.5) && ep->param2)
+ {
+ edje_object_update_hints_set(ep->swallowed_object, ep->param2->description->min.limit);
+ }
+ else
+ {
+ edje_object_update_hints_set(ep->swallowed_object, ep->param1.description->min.limit);
+ }
+ }
#ifdef EDJE_CALC_CACHE
if (ep->state == ed->state && !state)
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "minmul.h", minmul.h, EDJE_T_FLOAT); \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "min.w", min.w, EET_T_INT); \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "min.h", min.h, EET_T_INT); \
+ EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "min.limit", min.limit, EET_T_UCHAR); \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "max.w", max.w, EET_T_INT); \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "max.h", max.h, EET_T_INT); \
+ EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "max.limit", max.limit, EET_T_UCHAR); \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "step.x", step.x, EET_T_INT); \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "step.y", step.y, EET_T_INT); \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "aspect.min", aspect.min, EDJE_T_FLOAT); \
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.id", image.id, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.set", image.set, EET_T_UCHAR);
- EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.min.limit", image.min.limit, EET_T_UCHAR);
- EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.max.limit", image.max.limit, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.border.l", image.border.l, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.border.r", image.border.r, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.border.t", image.border.t, EET_T_INT);
struct _Edje_Size
{
int w, h;
+ Eina_Bool limit; /* should we limit ourself to the size of the source */
};
struct _Edje_Rectangle
int id; /* the image id to use */
int scale_hint; /* evas scale hint */
Eina_Bool set; /* if image condition it's content */
- struct {
- Eina_Bool limit; /* should we limit ourself to the size of the image */
- } min, max;
Edje_Part_Description_Spec_Border border;
};
#endif
unsigned int have_mapped_part : 1;
unsigned int recalc_call : 1;
+ unsigned int update_hints : 1;
+ unsigned int recalc_hints : 1;
};
struct _Edje_Calc_Params
if (text) rp->text.text = eina_stringshare_add(text);
rp->edje->dirty = 1;
rp->edje->recalc_call = 1;
+ rp->edje->recalc_hints = 1;
#ifdef EDJE_CALC_CACHE
rp->invalidate = 1;
#endif
evas_textblock_style_set(ts, style);
evas_object_textblock_style_user_push(rp->object, ts);
evas_textblock_style_free(ts);
+ ed->recalc_hints = 1;
}
EAPI void
if (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) return;
evas_object_textblock_style_user_pop(rp->object);
+ ed->recalc_hints = 1;
}
EAPI const char *
_edje_entry_text_markup_insert(rp, text);
rp->edje->dirty = 1;
rp->edje->recalc_call = 1;
+ rp->edje->recalc_hints = 1;
#ifdef EDJE_CALC_CACHE
rp->invalidate = 1;
#endif
_edje_object_part_text_raw_append(obj, rp, part, text);
rp->edje->dirty = 1;
rp->edje->recalc_call = 1;
+ rp->edje->recalc_hints = 1;
#ifdef EDJE_CALC_CACHE
rp->invalidate = 1;
#endif
maxh = 0;
}
pep = NULL;
+ has_non_fixed_tb = EINA_FALSE;
for (i = 0; i < ed->table_parts_size; i++)
{
Edje_Real_Part *ep;
return EINA_TRUE;
}
+EAPI void
+edje_object_update_hints_set(Evas_Object *obj, Eina_Bool update)
+{
+ Edje *ed;
+
+ ed = _edje_fetch(obj);
+ if (!ed) return ;
+ if (ed->update_hints == !!update) return ;
+
+ ed->update_hints = !!update;
+ if (update) ed->recalc_hints = 1;
+}
+
+EAPI Eina_Bool
+edje_object_update_hints_get(Evas_Object *obj)
+{
+ Edje *ed;
+
+ ed = _edje_fetch(obj);
+ if (!ed) return EINA_FALSE;
+
+ return ed->update_hints;
+}
+
Eina_Bool
_edje_real_part_table_pack(Edje_Real_Part *rp, Evas_Object *child_obj, unsigned short col, unsigned short row, unsigned short colspan, unsigned short rowspan)
{
_edje_real_part_swallow_hints_update(rp);
rp->edje->dirty = 1;
rp->edje->recalc_call = 1;
+ rp->edje->recalc_hints = 1;
_edje_recalc(rp->edje);
return;
}
rp->edje->dirty = 1;
rp->edje->recalc_call = 1;
+ rp->edje->recalc_hints = 1;
_edje_recalc(rp->edje);
}