forked from enlightenment/efl
Ui text scroller: add usage of a guide
This commit is contained in:
parent
acee09f585
commit
3e5616b346
|
@ -29,7 +29,8 @@
|
||||||
|
|
||||||
typedef struct _Efl_Ui_Internal_Text_Scroller_Data
|
typedef struct _Efl_Ui_Internal_Text_Scroller_Data
|
||||||
{
|
{
|
||||||
Efl_Canvas_Text *content;
|
Efl_Canvas_Text *text_obj;
|
||||||
|
Efl_Ui_Table *text_table;
|
||||||
Eo *smanager;
|
Eo *smanager;
|
||||||
|
|
||||||
Efl_Ui_Text_Scroller_Mode mode;
|
Efl_Ui_Text_Scroller_Mode mode;
|
||||||
|
@ -75,9 +76,9 @@ _efl_ui_internal_text_scroller_elm_layout_sizing_eval(Eo *obj,
|
||||||
|
|
||||||
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
||||||
|
|
||||||
if (sd->content)
|
if (sd->text_obj)
|
||||||
{
|
{
|
||||||
efl_gfx_size_hint_weight_get(sd->content, &xw, &yw);
|
efl_gfx_size_hint_weight_get(sd->text_table, &xw, &yw);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (psd->smanager)
|
if (psd->smanager)
|
||||||
|
@ -87,17 +88,21 @@ _efl_ui_internal_text_scroller_elm_layout_sizing_eval(Eo *obj,
|
||||||
|
|
||||||
edje_object_size_min_calc(wd->resize_obj, &vmw, &vmh);
|
edje_object_size_min_calc(wd->resize_obj, &vmw, &vmh);
|
||||||
|
|
||||||
if (sd->content)
|
if (sd->text_obj)
|
||||||
{
|
{
|
||||||
Eina_Size2D fsz = EINA_SIZE2D(0, 0);
|
Eina_Size2D fsz = EINA_SIZE2D(0, 0);
|
||||||
Eina_Size2D sz = EINA_SIZE2D(0, 0);
|
Eina_Size2D sz = EINA_SIZE2D(0, 0);
|
||||||
|
|
||||||
sz = efl_gfx_entity_size_get(sd->content);
|
sz = efl_gfx_entity_size_get(sd->text_table);
|
||||||
efl_event_freeze(sd->content);
|
efl_event_freeze(sd->text_table);
|
||||||
efl_gfx_entity_size_set(sd->content, view.size);
|
efl_event_freeze(sd->text_obj);
|
||||||
efl_canvas_text_size_formatted_get(sd->content, &fsz.w, &fsz.h);
|
efl_gfx_entity_size_set(sd->text_table, view.size);
|
||||||
efl_gfx_entity_size_set(sd->content, sz);
|
efl_gfx_entity_size_set(sd->text_obj, view.size);
|
||||||
efl_event_thaw(sd->content);
|
efl_canvas_text_size_formatted_get(sd->text_obj, &fsz.w, &fsz.h);
|
||||||
|
efl_gfx_entity_size_set(sd->text_table, sz);
|
||||||
|
efl_gfx_entity_size_set(sd->text_obj, sz);
|
||||||
|
efl_event_thaw(sd->text_obj);
|
||||||
|
efl_event_thaw(sd->text_table);
|
||||||
|
|
||||||
|
|
||||||
if (sd->mode == EFL_UI_TEXT_SCROLLER_MODE_SINGLELINE)
|
if (sd->mode == EFL_UI_TEXT_SCROLLER_MODE_SINGLELINE)
|
||||||
|
@ -118,7 +123,7 @@ _efl_ui_internal_text_scroller_elm_layout_sizing_eval(Eo *obj,
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: should be restricted_min?
|
// FIXME: should be restricted_min?
|
||||||
efl_gfx_entity_size_set(sd->content, fsz);
|
efl_gfx_entity_size_set(sd->text_table, fsz);
|
||||||
efl_gfx_size_hint_min_set(obj, size);
|
efl_gfx_size_hint_min_set(obj, size);
|
||||||
efl_gfx_size_hint_max_set(obj, EINA_SIZE2D(-1, size.h));
|
efl_gfx_size_hint_max_set(obj, EINA_SIZE2D(-1, size.h));
|
||||||
}
|
}
|
||||||
|
@ -131,6 +136,7 @@ _efl_ui_internal_text_scroller_efl_object_finalize(Eo *obj,
|
||||||
obj = efl_finalize(efl_super(obj, MY_CLASS));
|
obj = efl_finalize(efl_super(obj, MY_CLASS));
|
||||||
efl_ui_scrollbar_bar_mode_set(obj,
|
efl_ui_scrollbar_bar_mode_set(obj,
|
||||||
EFL_UI_SCROLLBAR_MODE_OFF, EFL_UI_SCROLLBAR_MODE_OFF);
|
EFL_UI_SCROLLBAR_MODE_OFF, EFL_UI_SCROLLBAR_MODE_OFF);
|
||||||
|
efl_content_set(obj, sd->text_table);
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
@ -143,12 +149,19 @@ _efl_ui_internal_text_scroller_efl_object_destructor(Eo *obj,
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN static void
|
EOLIAN static void
|
||||||
_efl_ui_internal_text_scroller_text_object_set(Eo *obj,
|
_efl_ui_internal_text_scroller_initialize(Eo *obj,
|
||||||
Efl_Ui_Internal_Text_Scroller_Data *sd,
|
Efl_Ui_Internal_Text_Scroller_Data *sd,
|
||||||
Efl_Canvas_Text *text_obj)
|
Efl_Canvas_Text *text_obj,
|
||||||
|
Efl_Ui_Table *text_table)
|
||||||
{
|
{
|
||||||
sd->content = text_obj;
|
if (efl_finalized_get(obj))
|
||||||
efl_content_set(obj, text_obj);
|
{
|
||||||
|
ERR("Can only be called on construction");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sd->text_obj = text_obj;
|
||||||
|
sd->text_table = text_table;
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN static void
|
EOLIAN static void
|
||||||
|
|
|
@ -7,17 +7,14 @@ enum Efl.Ui.Text_Scroller_Mode
|
||||||
|
|
||||||
class Efl.Ui.Internal_Text_Scroller (Efl.Ui.Scroller)
|
class Efl.Ui.Internal_Text_Scroller (Efl.Ui.Scroller)
|
||||||
{
|
{
|
||||||
[[Efl ui text scroller class]]
|
[[Internal-usage text scroller class.
|
||||||
|
|
||||||
|
This class is a special scroller that evaluates its size based on the
|
||||||
|
$Efl.Canvas.Text object it holds. On initialization the object is meant
|
||||||
|
to be passed along a container (so that other objects such as
|
||||||
|
a "guide hint" text object are store in such container.
|
||||||
|
]]
|
||||||
methods {
|
methods {
|
||||||
@property text_object {
|
|
||||||
[[The Efl.Canvas.Text content of this scroller]]
|
|
||||||
set {
|
|
||||||
[[Sets the given text object as the content of this scroller]]
|
|
||||||
}
|
|
||||||
values {
|
|
||||||
text_obj: Efl.Canvas.Text @nullable;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@property scroller_mode {
|
@property scroller_mode {
|
||||||
[[Mode of operation for the scroller]]
|
[[Mode of operation for the scroller]]
|
||||||
set {
|
set {
|
||||||
|
@ -36,6 +33,16 @@ class Efl.Ui.Internal_Text_Scroller (Efl.Ui.Scroller)
|
||||||
clip: Efl.Object;
|
clip: Efl.Object;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
initialize {
|
||||||
|
[[The Efl.Canvas.Text content of this scroller.
|
||||||
|
This should be called upon constructing the object.
|
||||||
|
]]
|
||||||
|
params {
|
||||||
|
text_obj: Efl.Canvas.Text @nullable; [[The text object to query]]
|
||||||
|
text_table: Efl.Ui.Table @nullable; [[The table container of
|
||||||
|
the $text_obj]]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
implements {
|
implements {
|
||||||
Efl.Object.constructor;
|
Efl.Object.constructor;
|
||||||
|
|
|
@ -33,6 +33,8 @@ struct _Efl_Ui_Text_Data
|
||||||
Evas_Object *mgf_clip;
|
Evas_Object *mgf_clip;
|
||||||
Evas_Object *mgf_proxy;
|
Evas_Object *mgf_proxy;
|
||||||
Eo *text_obj;
|
Eo *text_obj;
|
||||||
|
Eo *text_guide_obj;
|
||||||
|
Eo *text_table;
|
||||||
Eo *pan;
|
Eo *pan;
|
||||||
Eo *scroller;
|
Eo *scroller;
|
||||||
Eo *manager;
|
Eo *manager;
|
||||||
|
@ -831,10 +833,9 @@ _cursor_geometry_recalc(Evas_Object *obj)
|
||||||
edje_object_size_min_restricted_calc(sd->cursor, &cw, NULL, cw, 0);
|
edje_object_size_min_restricted_calc(sd->cursor, &cw, NULL, cw, 0);
|
||||||
evas_object_geometry_get(sd->entry_edje, &x, &y, &w, &h);
|
evas_object_geometry_get(sd->entry_edje, &x, &y, &w, &h);
|
||||||
evas_object_geometry_get(
|
evas_object_geometry_get(
|
||||||
edje_object_part_swallow_get(sd->entry_edje, "efl.text"),
|
sd->text_obj,
|
||||||
&x2, &y2, &w2, &h2);
|
&x2, &y2, &w2, &h2);
|
||||||
cx = cx + x - x2;
|
|
||||||
cy = cy + y - y2;
|
|
||||||
efl_ui_scrollable_scroll(sd->scroller, EINA_RECT(cx, cy, cw, ch), EINA_FALSE);
|
efl_ui_scrollable_scroll(sd->scroller, EINA_RECT(cx, cy, cw, ch), EINA_FALSE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -946,7 +947,7 @@ _efl_ui_text_efl_ui_focus_object_on_focus_update(Eo *obj, Efl_Ui_Text_Data *sd)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Eo *sw = edje_object_part_swallow_get(sd->entry_edje, "efl.text");
|
Eo *sw = sd->text_obj;
|
||||||
|
|
||||||
_edje_signal_emit(sd, "efl,action,unfocus", "efl");
|
_edje_signal_emit(sd, "efl,action,unfocus", "efl");
|
||||||
if (sd->scroll)
|
if (sd->scroll)
|
||||||
|
@ -1970,6 +1971,20 @@ _cb_deleted(void *data EINA_UNUSED, const Efl_Event *ev)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_update_guide_text(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd)
|
||||||
|
{
|
||||||
|
const char *txt;
|
||||||
|
Eina_Bool show_guide;
|
||||||
|
|
||||||
|
txt = efl_text_get(sd->text_obj);
|
||||||
|
|
||||||
|
show_guide = (!txt || (txt[0] == '\0'));
|
||||||
|
|
||||||
|
efl_gfx_entity_visible_set(sd->text_guide_obj, show_guide);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
EOLIAN static Eo *
|
EOLIAN static Eo *
|
||||||
_efl_ui_text_efl_object_constructor(Eo *obj, Efl_Ui_Text_Data *sd)
|
_efl_ui_text_efl_object_constructor(Eo *obj, Efl_Ui_Text_Data *sd)
|
||||||
{
|
{
|
||||||
|
@ -1985,6 +2000,8 @@ _efl_ui_text_efl_object_constructor(Eo *obj, Efl_Ui_Text_Data *sd)
|
||||||
|
|
||||||
text_obj = efl_add(EFL_UI_INTERNAL_TEXT_INTERACTIVE_CLASS, obj);
|
text_obj = efl_add(EFL_UI_INTERNAL_TEXT_INTERACTIVE_CLASS, obj);
|
||||||
sd->text_obj = text_obj;
|
sd->text_obj = text_obj;
|
||||||
|
sd->text_guide_obj = efl_add(EFL_CANVAS_TEXT_CLASS, obj);
|
||||||
|
sd->text_table = efl_add(EFL_UI_TABLE_CLASS, obj);
|
||||||
efl_composite_attach(obj, text_obj);
|
efl_composite_attach(obj, text_obj);
|
||||||
|
|
||||||
sd->entry_edje = wd->resize_obj;
|
sd->entry_edje = wd->resize_obj;
|
||||||
|
@ -2032,9 +2049,17 @@ _efl_ui_text_efl_object_finalize(Eo *obj,
|
||||||
efl_text_normal_color_set(sd->text_obj, 255, 255, 255, 255);
|
efl_text_normal_color_set(sd->text_obj, 255, 255, 255, 255);
|
||||||
sd->single_line = !efl_text_multiline_get(sd->text_obj);
|
sd->single_line = !efl_text_multiline_get(sd->text_obj);
|
||||||
|
|
||||||
sd->item_fallback_factory = efl_add(EFL_UI_TEXT_FACTORY_FALLBACK_CLASS, obj);
|
efl_text_set(sd->text_obj, "");
|
||||||
|
efl_pack_table(sd->text_table, sd->text_obj, 0, 0, 1, 1);
|
||||||
|
efl_pack_table(sd->text_table, sd->text_guide_obj, 0, 0, 1, 1);
|
||||||
|
|
||||||
edje_object_part_swallow(sd->entry_edje, "efl.text", sd->text_obj);
|
//edje_object_part_swallow(sd->entry_edje, "efl.text", sd->text_obj);
|
||||||
|
//edje_object_part_swallow(sd->entry_edje, "efl.text_guide", sd->text_guide_obj);
|
||||||
|
edje_object_part_swallow(sd->entry_edje, "efl.text", sd->text_table);
|
||||||
|
|
||||||
|
_update_guide_text(obj, sd);
|
||||||
|
|
||||||
|
sd->item_fallback_factory = efl_add(EFL_UI_TEXT_FACTORY_FALLBACK_CLASS, obj);
|
||||||
|
|
||||||
evas_object_size_hint_weight_set
|
evas_object_size_hint_weight_set
|
||||||
(sd->entry_edje, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
(sd->entry_edje, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
|
@ -2441,14 +2466,12 @@ _efl_ui_text_scrollable_set(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd, Eina_Bool
|
||||||
|
|
||||||
if (scroll)
|
if (scroll)
|
||||||
{
|
{
|
||||||
efl_ref(sd->text_obj);
|
|
||||||
sd->scroller = efl_add(EFL_UI_INTERNAL_TEXT_SCROLLER_CLASS, obj);
|
|
||||||
efl_ui_scrollbar_bar_mode_set(sd->scroller, EFL_UI_SCROLLBAR_MODE_AUTO, EFL_UI_SCROLLBAR_MODE_AUTO);
|
|
||||||
efl_content_set(sd->scroller, sd->text_obj);
|
|
||||||
|
|
||||||
edje_object_part_swallow(sd->entry_edje, "efl.text", NULL);
|
edje_object_part_swallow(sd->entry_edje, "efl.text", NULL);
|
||||||
|
sd->scroller = efl_add(EFL_UI_INTERNAL_TEXT_SCROLLER_CLASS, obj,
|
||||||
|
efl_ui_internal_text_scroller_initialize(efl_added,
|
||||||
|
sd->text_obj, sd->text_table));
|
||||||
|
efl_ui_scrollbar_bar_mode_set(sd->scroller, EFL_UI_SCROLLBAR_MODE_AUTO, EFL_UI_SCROLLBAR_MODE_AUTO);
|
||||||
edje_object_part_swallow(sd->entry_edje, "efl.text", sd->scroller);
|
edje_object_part_swallow(sd->entry_edje, "efl.text", sd->scroller);
|
||||||
efl_ui_internal_text_scroller_text_object_set(sd->scroller, sd->text_obj);
|
|
||||||
evas_object_clip_set(sd->cursor,
|
evas_object_clip_set(sd->cursor,
|
||||||
efl_ui_internal_text_scroller_viewport_clip_get(sd->scroller));
|
efl_ui_internal_text_scroller_viewport_clip_get(sd->scroller));
|
||||||
efl_event_callback_add(sd->scroller, EFL_GFX_ENTITY_EVENT_RESIZE,
|
efl_event_callback_add(sd->scroller, EFL_GFX_ENTITY_EVENT_RESIZE,
|
||||||
|
@ -2457,8 +2480,7 @@ _efl_ui_text_scrollable_set(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd, Eina_Bool
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
efl_content_set(sd->scroller, NULL);
|
efl_content_set(sd->scroller, NULL);
|
||||||
edje_object_part_swallow(sd->entry_edje, "efl.text", sd->text_obj);
|
edje_object_part_swallow(sd->entry_edje, "efl.text", sd->text_table);
|
||||||
efl_unref(sd->text_obj);
|
|
||||||
efl_del(sd->scroller);
|
efl_del(sd->scroller);
|
||||||
sd->scroller = NULL;
|
sd->scroller = NULL;
|
||||||
}
|
}
|
||||||
|
@ -3258,7 +3280,7 @@ _decoration_create(Eo *obj, Efl_Ui_Text_Data *sd,
|
||||||
evas_object_smart_member_add(ret, sd->entry_edje);
|
evas_object_smart_member_add(ret, sd->entry_edje);
|
||||||
if (above)
|
if (above)
|
||||||
{
|
{
|
||||||
evas_object_stack_above(ret, sd->text_obj);
|
evas_object_stack_above(ret, sd->text_table);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3758,6 +3780,7 @@ _efl_ui_text_changed_cb(void *data, const Efl_Event *event EINA_UNUSED)
|
||||||
EFL_UI_TEXT_DATA_GET(data, sd);
|
EFL_UI_TEXT_DATA_GET(data, sd);
|
||||||
sd->text_changed = EINA_TRUE;
|
sd->text_changed = EINA_TRUE;
|
||||||
sd->cursor_update = EINA_TRUE;
|
sd->cursor_update = EINA_TRUE;
|
||||||
|
_update_guide_text(data, sd);
|
||||||
elm_layout_sizing_eval(data);
|
elm_layout_sizing_eval(data);
|
||||||
_decoration_defer(data);
|
_decoration_defer(data);
|
||||||
}
|
}
|
||||||
|
@ -3770,6 +3793,7 @@ _efl_ui_text_changed_user_cb(void *data, const Efl_Event *event)
|
||||||
if (efl_invalidated_get(event->object)) return;
|
if (efl_invalidated_get(event->object)) return;
|
||||||
EFL_UI_TEXT_DATA_GET(obj, sd);
|
EFL_UI_TEXT_DATA_GET(obj, sd);
|
||||||
sd->text_changed = EINA_TRUE;
|
sd->text_changed = EINA_TRUE;
|
||||||
|
_update_guide_text(data, sd);
|
||||||
elm_layout_sizing_eval(obj);
|
elm_layout_sizing_eval(obj);
|
||||||
_decoration_defer_all(obj);
|
_decoration_defer_all(obj);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue