forked from enlightenment/efl
Edje_Edit: support new edje top block "text classes" with edje_edit API
Plenty of new API: edje_edit_text_classes_list_get - to return total list of text_classes inside of loaded collection of groups edje_edit_text_class_add - add new text class into loaded collection edje_edit_text_class_del - deleting edje_edit_text_class_name_set - renaming existing text class into something new edje_edit_text_class_font_{get|set} - get/set font name edje_edit_text_class_size_{get|set} - get/set font size
This commit is contained in:
parent
499e66ac78
commit
559cf1e73c
|
@ -728,6 +728,120 @@ EAPI Eina_Bool edje_edit_group_data_value_set(Evas_Object *obj, const char *item
|
|||
EAPI Eina_Bool edje_edit_group_data_name_set(Evas_Object *obj, const char *itemname, const char *newname);
|
||||
|
||||
|
||||
//@}
|
||||
/*****************************************************************************/
|
||||
/*********************** TEXT CLASSES API ********************************/
|
||||
/*****************************************************************************/
|
||||
/** @name Text Classes API
|
||||
* Functions to deal with Text Classes (see @ref edcref).
|
||||
*/ //@{
|
||||
|
||||
/** Get the list of all the Text Classes in the given edje object.
|
||||
*
|
||||
* @param obj Object being edited.
|
||||
*
|
||||
* @return List of strings, each being one text class.
|
||||
* The return value should be freed with edje_edit_string_list_free().
|
||||
*
|
||||
* @see edje_edit_string_list_free()
|
||||
*
|
||||
* @since 1.18
|
||||
*/
|
||||
EAPI Eina_List *
|
||||
edje_edit_text_classes_list_get(Evas_Object *obj);
|
||||
|
||||
/** Create a new text class object in the given edje.
|
||||
*
|
||||
* If class is already exist then nothing is created and EINA_FALSE returned.
|
||||
*
|
||||
* @param obj Object being edited.
|
||||
* @param name Name for the new text class.
|
||||
*
|
||||
* @return @c EINA_TRUE in case of success, @c EINA_FALSE otherwise.
|
||||
*
|
||||
* @since 1.18
|
||||
*/
|
||||
EAPI Eina_Bool
|
||||
edje_edit_text_class_add(Evas_Object *obj, const char *name);
|
||||
|
||||
/** Delete text class object from edje.
|
||||
*
|
||||
* @param obj Object being edited.
|
||||
* @param name Text class to delete.
|
||||
*
|
||||
* @return @c EINA_TRUE in case of success, @c EINA_FALSE otherwise.
|
||||
*
|
||||
* @since 1.18
|
||||
*/
|
||||
EAPI Eina_Bool
|
||||
edje_edit_text_class_del(Evas_Object *obj, const char *name);
|
||||
|
||||
/** Change name of a text class.
|
||||
*
|
||||
* @param obj Object being edited.
|
||||
* @param name Text class to rename.
|
||||
* @param newname New name for the text class.
|
||||
*
|
||||
* @return @c EINA_TRUE in case of success, @c EINA_FALSE otherwise.
|
||||
*
|
||||
* @since 1.18
|
||||
*/
|
||||
EAPI Eina_Bool
|
||||
edje_edit_text_class_name_set(Evas_Object *obj, const char *name, const char *newname);
|
||||
|
||||
/** Return font name of specified text class.
|
||||
*
|
||||
* @param obj Object being edited.
|
||||
* @param class_name Text class to fetch values.
|
||||
*
|
||||
* @return font name in case of success, NULL otherwise.
|
||||
*
|
||||
* @since 1.18
|
||||
*/
|
||||
EAPI Eina_Stringshare *
|
||||
edje_edit_text_class_font_get(Evas_Object *obj, const char *class_name);
|
||||
|
||||
/** Set font for the given text class.
|
||||
*
|
||||
* NULL is possible value.
|
||||
*
|
||||
* @param obj Object being edited.
|
||||
* @param class_name Text class to set values.
|
||||
* @param font Name of font.
|
||||
*
|
||||
* @return @c EINA_TRUE in case of success, @c EINA_FALSE otherwise.
|
||||
*
|
||||
* @since 1.18
|
||||
*/
|
||||
EAPI Eina_Bool
|
||||
edje_edit_text_class_font_set(Evas_Object *obj, const char *class_name, const char *font);
|
||||
|
||||
/** Return font size of specified text class.
|
||||
*
|
||||
* @param obj Object being edited.
|
||||
* @param class_name Text class to fetch values.
|
||||
*
|
||||
* @return @c Evas_Font_Size.
|
||||
*
|
||||
* @since 1.18
|
||||
*/
|
||||
EAPI Evas_Font_Size
|
||||
edje_edit_text_class_size_get(Evas_Object *obj, const char *class_name);
|
||||
|
||||
/** Set font size for specified text class
|
||||
*
|
||||
* @param obj Object being edited.
|
||||
* @param class_name Text class to set values.
|
||||
* @param size Font size which is greater or equal than zero (0).
|
||||
*
|
||||
* @return @c EINA_TRUE in case of success, @c EINA_FALSE otherwise.
|
||||
*
|
||||
* @since 1.18
|
||||
*/
|
||||
EAPI Eina_Bool
|
||||
edje_edit_text_class_size_set(Evas_Object *obj, const char *class_name, Evas_Font_Size size);
|
||||
|
||||
|
||||
//@}
|
||||
/******************************************************************************/
|
||||
/*********************** COLOR CLASSES API ********************************/
|
||||
|
|
|
@ -7373,6 +7373,175 @@ edje_edit_state_map_on_set(Evas_Object *obj, const char *part, const char *state
|
|||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
/*********************/
|
||||
/* TEXT CLASSES API */
|
||||
/*********************/
|
||||
|
||||
EAPI Eina_List *
|
||||
edje_edit_text_classes_list_get(Evas_Object *obj)
|
||||
{
|
||||
Eina_List *classes = NULL;
|
||||
Eina_List *l;
|
||||
Edje_Text_Class *tc;
|
||||
|
||||
GET_ED_OR_RETURN(NULL);
|
||||
|
||||
if (!ed->file || !ed->file->text_classes)
|
||||
return NULL;
|
||||
EINA_LIST_FOREACH(ed->file->text_classes, l, tc)
|
||||
classes = eina_list_append(classes, eina_stringshare_add(tc->name));
|
||||
|
||||
return classes;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
edje_edit_text_class_add(Evas_Object *obj, const char *name)
|
||||
{
|
||||
Eina_List *l;
|
||||
Edje_Text_Class *tc, *t;
|
||||
|
||||
GET_ED_OR_RETURN(EINA_FALSE);
|
||||
|
||||
if (!name || !ed->file)
|
||||
return EINA_FALSE;
|
||||
|
||||
EINA_LIST_FOREACH(ed->file->text_classes, l, tc)
|
||||
if (strcmp(tc->name, name) == 0)
|
||||
return EINA_FALSE;
|
||||
|
||||
t = _alloc(sizeof(Edje_Text_Class));
|
||||
if (!t) return EINA_FALSE;
|
||||
|
||||
t->name = eina_stringshare_add(name);
|
||||
|
||||
ed->file->text_classes = eina_list_append(ed->file->text_classes, t);
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
edje_edit_text_class_del(Evas_Object *obj, const char *name)
|
||||
{
|
||||
Eina_List *l;
|
||||
Edje_Text_Class *tc;
|
||||
|
||||
GET_ED_OR_RETURN(EINA_FALSE);
|
||||
|
||||
if (!name || !ed->file || !ed->file->text_classes)
|
||||
return EINA_FALSE;
|
||||
|
||||
EINA_LIST_FOREACH(ed->file->text_classes, l, tc)
|
||||
if (strcmp(tc->name, name) == 0)
|
||||
{
|
||||
_edje_if_string_free(ed, &tc->name);
|
||||
_edje_if_string_free(ed, &tc->font);
|
||||
ed->file->text_classes = eina_list_remove(ed->file->text_classes, tc);
|
||||
free(tc);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
edje_edit_text_class_name_set(Evas_Object *obj, const char *name, const char *newname)
|
||||
{
|
||||
Eina_List *l;
|
||||
Edje_Text_Class *tc;
|
||||
|
||||
GET_ED_OR_RETURN(EINA_FALSE);
|
||||
|
||||
if (!ed->file || !ed->file->text_classes)
|
||||
return EINA_FALSE;
|
||||
|
||||
EINA_LIST_FOREACH(ed->file->text_classes, l, tc)
|
||||
if (!strcmp(tc->name, name))
|
||||
{
|
||||
_edje_if_string_replace(ed, &tc->name, newname);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
EAPI Eina_Stringshare *
|
||||
edje_edit_text_class_font_get(Evas_Object *obj, const char *class_name)
|
||||
{
|
||||
Eina_List *l;
|
||||
Edje_Text_Class *tc;
|
||||
|
||||
GET_ED_OR_RETURN(EINA_FALSE);
|
||||
|
||||
if (!ed->file || !ed->file->text_classes)
|
||||
return EINA_FALSE;
|
||||
|
||||
EINA_LIST_FOREACH(ed->file->text_classes, l, tc)
|
||||
if (!strcmp(tc->name, class_name))
|
||||
return eina_stringshare_add(tc->font);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
edje_edit_text_class_font_set(Evas_Object *obj, const char *class_name, const char *font)
|
||||
{
|
||||
Eina_List *l;
|
||||
Edje_Text_Class *tc;
|
||||
|
||||
GET_ED_OR_RETURN(EINA_FALSE);
|
||||
|
||||
if (!ed->file || !ed->file->text_classes || !class_name)
|
||||
return EINA_FALSE;
|
||||
|
||||
EINA_LIST_FOREACH(ed->file->text_classes, l, tc)
|
||||
if (!strcmp(tc->name, class_name))
|
||||
{
|
||||
_edje_if_string_replace(ed, &tc->font, font);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
EAPI Evas_Font_Size
|
||||
edje_edit_text_class_size_get(Evas_Object *obj, const char *class_name)
|
||||
{
|
||||
Eina_List *l;
|
||||
Edje_Text_Class *tc;
|
||||
|
||||
GET_ED_OR_RETURN(EINA_FALSE);
|
||||
|
||||
if (!ed->file || !ed->file->text_classes)
|
||||
return EINA_FALSE;
|
||||
|
||||
EINA_LIST_FOREACH(ed->file->text_classes, l, tc)
|
||||
if (!strcmp(tc->name, class_name))
|
||||
return tc->size;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
edje_edit_text_class_size_set(Evas_Object *obj, const char *class_name, Evas_Font_Size size)
|
||||
{
|
||||
Eina_List *l;
|
||||
Edje_Text_Class *tc;
|
||||
|
||||
GET_ED_OR_RETURN(EINA_FALSE);
|
||||
|
||||
if (!ed->file || !ed->file->text_classes || !class_name)
|
||||
return EINA_FALSE;
|
||||
if (size < 0)
|
||||
return EINA_FALSE;
|
||||
|
||||
EINA_LIST_FOREACH(ed->file->text_classes, l, tc)
|
||||
if (!strcmp(tc->name, class_name))
|
||||
{
|
||||
tc->size = size;
|
||||
return EINA_TRUE;
|
||||
}
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**************/
|
||||
/* TEXT API */
|
||||
/**************/
|
||||
|
|
Loading…
Reference in New Issue