forked from enlightenment/efl
elm_entry: use layout text/content aliases when text_set/get content_set/get/unset
Summary: - elm_entry has elm.guide text part and it can be set by "guide". - However when using text_aliases_get, this cannot be found. - Add elm_obj_elm_layout_part_aliasing_eval() internal APIs to make entry use proper aliases. Test Plan: 1. Run elementary test 2. Observe search entry has guide text with "guide" part. 3. Run Entry 8. 4. Observe "elm.guide" part also works. 5. Observe "icon" and "end" part works. Reviewers: id213sin, herdsman, jpeg Reviewed By: jpeg Subscribers: conr2d, cedric, jpeg Differential Revision: https://phab.enlightenment.org/D4962
This commit is contained in:
parent
9452a4ac49
commit
82a955be90
|
@ -74,6 +74,13 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
|
|||
};
|
||||
#undef ELM_PRIV_ENTRY_SIGNALS
|
||||
|
||||
static const Elm_Layout_Part_Alias_Description _text_aliases[] =
|
||||
{
|
||||
{"default", "elm.text"},
|
||||
{"guide", "elm.guide"},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
static const Elm_Layout_Part_Alias_Description _content_aliases[] =
|
||||
{
|
||||
{"icon", "elm.swallow.icon"},
|
||||
|
@ -3116,7 +3123,7 @@ _elm_entry_content_set(Eo *obj, Elm_Entry_Data *_pd EINA_UNUSED, const char *par
|
|||
if (!part || !strcmp(part, "icon") || !strcmp(part, "elm.swallow.icon"))
|
||||
elm_entry_icon_visible_set(obj, EINA_TRUE);
|
||||
|
||||
if (!part || !strcmp(part, "end") || !strcmp(part, "elm.swallow.end"))
|
||||
if (part && (!strcmp(part, "end") || !strcmp(part, "elm.swallow.end")))
|
||||
elm_entry_end_visible_set(obj, EINA_TRUE);
|
||||
|
||||
return EINA_TRUE;
|
||||
|
@ -3134,7 +3141,7 @@ _elm_entry_content_unset(Eo *obj, Elm_Entry_Data *_pd EINA_UNUSED, const char *p
|
|||
if (!part || !strcmp(part, "icon") || !strcmp(part, "elm.swallow.icon"))
|
||||
elm_entry_icon_visible_set(obj, EINA_FALSE);
|
||||
|
||||
if (!part || !strcmp(part, "end") || !strcmp(part, "elm.swallow.end"))
|
||||
if (part && (!strcmp(part, "end") || !strcmp(part, "elm.swallow.end")))
|
||||
elm_entry_end_visible_set(obj, EINA_FALSE);
|
||||
|
||||
return ret;
|
||||
|
@ -3200,12 +3207,12 @@ _elm_entry_text_set(Eo *obj, Elm_Entry_Data *sd, const char *part, const char *e
|
|||
int len = 0;
|
||||
|
||||
if (!entry) entry = "";
|
||||
if (part && strcmp(part, "elm.text"))
|
||||
if (!_elm_layout_part_aliasing_eval(obj, &part, EINA_TRUE))
|
||||
return EINA_FALSE;
|
||||
|
||||
if (strcmp(part, "elm.text"))
|
||||
{
|
||||
if (!strcmp(part, "guide"))
|
||||
edje_object_part_text_set(sd->entry_edje, "elm.guide", entry);
|
||||
else
|
||||
edje_object_part_text_set(sd->entry_edje, part, entry);
|
||||
edje_object_part_text_set(sd->entry_edje, part, entry);
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
@ -3250,20 +3257,11 @@ _elm_entry_text_get(Eo *obj, Elm_Entry_Data *sd, const char *item)
|
|||
{
|
||||
const char *text;
|
||||
|
||||
if (item)
|
||||
{
|
||||
if (!strcmp(item, "default") || strcmp(item, "elm.text")) goto proceed;
|
||||
else if (!strcmp(item, "guide"))
|
||||
{
|
||||
return edje_object_part_text_get(sd->entry_edje, "elm.guide");
|
||||
}
|
||||
else
|
||||
{
|
||||
return edje_object_part_text_get(sd->entry_edje, item);
|
||||
}
|
||||
}
|
||||
if (!_elm_layout_part_aliasing_eval(obj, &item, EINA_TRUE))
|
||||
return NULL;
|
||||
|
||||
proceed:
|
||||
if (strcmp(item, "elm.text"))
|
||||
return edje_object_part_text_get(sd->entry_edje, item);
|
||||
|
||||
text = edje_object_part_text_get(sd->entry_edje, "elm.text");
|
||||
if (!text)
|
||||
|
@ -3990,6 +3988,12 @@ _elm_entry_efl_canvas_group_group_member_add(Eo *obj, Elm_Entry_Data *sd, Evas_O
|
|||
evas_object_raise(sd->hit_rect);
|
||||
}
|
||||
|
||||
EOLIAN static const Elm_Layout_Part_Alias_Description*
|
||||
_elm_entry_elm_layout_text_aliases_get(Eo *obj EINA_UNUSED, Elm_Entry_Data *_sd EINA_UNUSED)
|
||||
{
|
||||
return _text_aliases;
|
||||
}
|
||||
|
||||
EOLIAN static const Elm_Layout_Part_Alias_Description *
|
||||
_elm_entry_elm_layout_content_aliases_get(Eo *obj EINA_UNUSED, Elm_Entry_Data *sd EINA_UNUSED)
|
||||
{
|
||||
|
|
|
@ -967,6 +967,7 @@ class Elm.Entry (Elm.Layout, Elm.Interface_Scrollable, Efl.Ui.Clickable,
|
|||
Elm.Layout.signal_callback_add;
|
||||
Elm.Layout.signal_callback_del;
|
||||
Elm.Layout.signal_emit;
|
||||
Elm.Layout.text_aliases { get; }
|
||||
Elm.Layout.content_aliases { get; }
|
||||
Elm.Interface_Scrollable.policy { set; }
|
||||
Elm.Interface_Scrollable.bounce_allow { set; }
|
||||
|
|
|
@ -618,18 +618,17 @@ _elm_layout_theme_enable(Eo *obj EINA_UNUSED, Elm_Layout_Smart_Data *_pd EINA_UN
|
|||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_elm_layout_part_aliasing_eval(const Evas_Object *obj EINA_UNUSED,
|
||||
Elm_Layout_Smart_Data *sd,
|
||||
EAPI Eina_Bool
|
||||
_elm_layout_part_aliasing_eval(const Evas_Object *obj,
|
||||
const char **part,
|
||||
Eina_Bool is_text)
|
||||
{
|
||||
const Elm_Layout_Part_Alias_Description *aliases = NULL;
|
||||
|
||||
if (is_text)
|
||||
aliases = elm_obj_layout_text_aliases_get(sd->obj);
|
||||
aliases = elm_obj_layout_text_aliases_get(obj);
|
||||
else
|
||||
aliases = elm_obj_layout_content_aliases_get(sd->obj);
|
||||
aliases = elm_obj_layout_content_aliases_get(obj);
|
||||
|
||||
while (aliases && aliases->alias && aliases->real_part)
|
||||
{
|
||||
|
@ -646,7 +645,7 @@ _elm_layout_part_aliasing_eval(const Evas_Object *obj EINA_UNUSED,
|
|||
if (!*part)
|
||||
{
|
||||
ERR("no default content part set for object %p -- "
|
||||
"part must not be NULL", sd->obj);
|
||||
"part must not be NULL", obj);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
|
@ -1025,7 +1024,7 @@ _elm_layout_content_set(Eo *obj, Elm_Layout_Smart_Data *sd, const char *part, Ev
|
|||
|
||||
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
|
||||
|
||||
if (!_elm_layout_part_aliasing_eval(obj, sd, &part, EINA_FALSE))
|
||||
if (!_elm_layout_part_aliasing_eval(obj, &part, EINA_FALSE))
|
||||
return EINA_FALSE;
|
||||
|
||||
EINA_LIST_FOREACH(sd->subs, l, sub_d)
|
||||
|
@ -1100,7 +1099,7 @@ _elm_layout_content_get(Eo *obj, Elm_Layout_Smart_Data *sd, const char *part)
|
|||
const Eina_List *l;
|
||||
Elm_Layout_Sub_Object_Data *sub_d;
|
||||
|
||||
if (!_elm_layout_part_aliasing_eval(obj, sd, &part, EINA_FALSE))
|
||||
if (!_elm_layout_part_aliasing_eval(obj, &part, EINA_FALSE))
|
||||
return NULL;
|
||||
|
||||
EINA_LIST_FOREACH(sd->subs, l, sub_d)
|
||||
|
@ -1132,7 +1131,7 @@ _elm_layout_content_unset(Eo *obj, Elm_Layout_Smart_Data *sd, const char *part)
|
|||
|
||||
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL);
|
||||
|
||||
if (!_elm_layout_part_aliasing_eval(obj, sd, &part, EINA_FALSE))
|
||||
if (!_elm_layout_part_aliasing_eval(obj, &part, EINA_FALSE))
|
||||
return NULL;
|
||||
|
||||
EINA_LIST_FOREACH(sd->subs, l, sub_d)
|
||||
|
@ -1281,7 +1280,7 @@ _elm_layout_text_set(Eo *obj, Elm_Layout_Smart_Data *sd, const char *part, const
|
|||
Eina_List *l;
|
||||
Elm_Layout_Sub_Object_Data *sub_d = NULL;
|
||||
|
||||
if (!_elm_layout_part_aliasing_eval(obj, sd, &part, EINA_TRUE))
|
||||
if (!_elm_layout_part_aliasing_eval(obj, &part, EINA_TRUE))
|
||||
return EINA_FALSE;
|
||||
|
||||
EINA_LIST_FOREACH(sd->subs, l, sub_d)
|
||||
|
@ -1344,11 +1343,11 @@ _elm_layout_text_set(Eo *obj, Elm_Layout_Smart_Data *sd, const char *part, const
|
|||
}
|
||||
|
||||
EOLIAN static const char*
|
||||
_elm_layout_text_get(Eo *obj, Elm_Layout_Smart_Data *sd, const char *part)
|
||||
_elm_layout_text_get(Eo *obj, Elm_Layout_Smart_Data *sd EINA_UNUSED, const char *part)
|
||||
{
|
||||
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL);
|
||||
|
||||
if (!_elm_layout_part_aliasing_eval(obj, sd, &part, EINA_TRUE))
|
||||
if (!_elm_layout_part_aliasing_eval(obj, &part, EINA_TRUE))
|
||||
return NULL;
|
||||
|
||||
return edje_object_part_text_get(wd->resize_obj, part);
|
||||
|
@ -2144,7 +2143,7 @@ _elm_layout_efl_ui_model_connect_connect(Eo *obj EINA_UNUSED, Elm_Layout_Smart_D
|
|||
return;
|
||||
}
|
||||
|
||||
if (!_elm_layout_part_aliasing_eval(obj, pd, &name, EINA_TRUE))
|
||||
if (!_elm_layout_part_aliasing_eval(obj, &name, EINA_TRUE))
|
||||
return;
|
||||
|
||||
ss_name = eina_stringshare_add(name);
|
||||
|
@ -2182,7 +2181,7 @@ _elm_layout_efl_ui_model_factory_connect_connect(Eo *obj EINA_UNUSED, Elm_Layout
|
|||
Efl_Ui_Factory *old_factory;
|
||||
Evas_Object *new_ev, *old_ev;
|
||||
|
||||
if (!_elm_layout_part_aliasing_eval(obj, pd, &name, EINA_TRUE))
|
||||
if (!_elm_layout_part_aliasing_eval(obj, &name, EINA_TRUE))
|
||||
return;
|
||||
|
||||
ss_name = eina_stringshare_add(name);
|
||||
|
@ -2343,14 +2342,14 @@ elm_layout_text_get(const Elm_Layout *obj, const char *part)
|
|||
/* Efl.Part implementation */
|
||||
|
||||
static EOLIAN Efl_Object *
|
||||
_elm_layout_efl_part_part(const Eo *obj, Elm_Layout_Smart_Data *sd,
|
||||
_elm_layout_efl_part_part(const Eo *obj, Elm_Layout_Smart_Data *sd EINA_UNUSED,
|
||||
const char *part)
|
||||
{
|
||||
Edje_Part_Type type;
|
||||
Elm_Part_Data *pd;
|
||||
Eo *proxy;
|
||||
|
||||
if (!_elm_layout_part_aliasing_eval(obj, sd, &part, EINA_FALSE))
|
||||
if (!_elm_layout_part_aliasing_eval(obj, &part, EINA_FALSE))
|
||||
return NULL;
|
||||
|
||||
ELM_WIDGET_DATA_GET_OR_RETURN((Eo *) obj, wd, NULL);
|
||||
|
|
|
@ -862,6 +862,11 @@ _elm_widget_sub_object_redirect_to_top(Evas_Object *obj, Evas_Object *sobj)
|
|||
|
||||
EAPI Eina_Bool elm_selection_selection_has_owner(Evas_Object *obj);
|
||||
|
||||
EAPI Eina_Bool _elm_layout_part_aliasing_eval(const Evas_Object *obj,
|
||||
const char **part,
|
||||
Eina_Bool is_text);
|
||||
|
||||
|
||||
#define ELM_WIDGET_ITEM_PROTECTED
|
||||
#include "elm_widget_item.eo.h"
|
||||
|
||||
|
|
Loading…
Reference in New Issue