summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Hirt <hirt.danny@gmail.com>2018-11-12 15:09:56 +0200
committerDaniel Hirt <hirt.danny@gmail.com>2018-11-15 10:59:41 +0200
commit56f2e1e2283d6c579b32a8604350c37bca0dd582 (patch)
tree9146231a3d71691d4989f633d7fb22497f5690af
parent09da85807a6447d6e9c04fc72fdb485a78192d82 (diff)
downloadefl-56f2e1e2283d6c579b32a8604350c37bca0dd582.tar.gz
Ui text scroller: add usage of a guide
-rw-r--r--src/lib/elementary/efl_ui_internal_text_scroller.c43
-rw-r--r--src/lib/elementary/efl_ui_internal_text_scroller.eo27
-rw-r--r--src/lib/elementary/efl_ui_text.c52
3 files changed, 82 insertions, 40 deletions
diff --git a/src/lib/elementary/efl_ui_internal_text_scroller.c b/src/lib/elementary/efl_ui_internal_text_scroller.c
index bda295a2ec..fa63a9d6ba 100644
--- a/src/lib/elementary/efl_ui_internal_text_scroller.c
+++ b/src/lib/elementary/efl_ui_internal_text_scroller.c
@@ -29,7 +29,8 @@
typedef struct _Efl_Ui_Internal_Text_Scroller_Data
{
- Efl_Canvas_Text *content;
+ Efl_Canvas_Text *text_obj;
+ Efl_Ui_Table *text_table;
Eo *smanager;
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);
- 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)
@@ -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);
- if (sd->content)
+ if (sd->text_obj)
{
Eina_Size2D fsz = EINA_SIZE2D(0, 0);
Eina_Size2D sz = EINA_SIZE2D(0, 0);
- sz = efl_gfx_entity_size_get(sd->content);
- efl_event_freeze(sd->content);
- efl_gfx_entity_size_set(sd->content, view.size);
- efl_canvas_text_size_formatted_get(sd->content, &fsz.w, &fsz.h);
- efl_gfx_entity_size_set(sd->content, sz);
- efl_event_thaw(sd->content);
+ sz = efl_gfx_entity_size_get(sd->text_table);
+ efl_event_freeze(sd->text_table);
+ efl_event_freeze(sd->text_obj);
+ efl_gfx_entity_size_set(sd->text_table, view.size);
+ efl_gfx_entity_size_set(sd->text_obj, view.size);
+ 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)
@@ -118,7 +123,7 @@ _efl_ui_internal_text_scroller_elm_layout_sizing_eval(Eo *obj,
}
// 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_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));
efl_ui_scrollbar_bar_mode_set(obj,
EFL_UI_SCROLLBAR_MODE_OFF, EFL_UI_SCROLLBAR_MODE_OFF);
+ efl_content_set(obj, sd->text_table);
return obj;
}
@@ -143,12 +149,19 @@ _efl_ui_internal_text_scroller_efl_object_destructor(Eo *obj,
}
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_Canvas_Text *text_obj)
+ Efl_Canvas_Text *text_obj,
+ Efl_Ui_Table *text_table)
{
- sd->content = text_obj;
- efl_content_set(obj, text_obj);
+ if (efl_finalized_get(obj))
+ {
+ ERR("Can only be called on construction");
+ return;
+ }
+
+ sd->text_obj = text_obj;
+ sd->text_table = text_table;
}
EOLIAN static void
diff --git a/src/lib/elementary/efl_ui_internal_text_scroller.eo b/src/lib/elementary/efl_ui_internal_text_scroller.eo
index 70586260fa..47624e44b3 100644
--- a/src/lib/elementary/efl_ui_internal_text_scroller.eo
+++ b/src/lib/elementary/efl_ui_internal_text_scroller.eo
@@ -7,17 +7,14 @@ enum Efl.Ui.Text_Scroller_Mode
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 {
- @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 {
[[Mode of operation for the scroller]]
set {
@@ -36,6 +33,16 @@ class Efl.Ui.Internal_Text_Scroller (Efl.Ui.Scroller)
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 {
Efl.Object.constructor;
diff --git a/src/lib/elementary/efl_ui_text.c b/src/lib/elementary/efl_ui_text.c
index 9825e98eb6..b664ca4fa1 100644
--- a/src/lib/elementary/efl_ui_text.c
+++ b/src/lib/elementary/efl_ui_text.c
@@ -33,6 +33,8 @@ struct _Efl_Ui_Text_Data
Evas_Object *mgf_clip;
Evas_Object *mgf_proxy;
Eo *text_obj;
+ Eo *text_guide_obj;
+ Eo *text_table;
Eo *pan;
Eo *scroller;
Eo *manager;
@@ -831,10 +833,9 @@ _cursor_geometry_recalc(Evas_Object *obj)
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(
- edje_object_part_swallow_get(sd->entry_edje, "efl.text"),
+ sd->text_obj,
&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);
}
@@ -946,7 +947,7 @@ _efl_ui_text_efl_ui_focus_object_on_focus_update(Eo *obj, Efl_Ui_Text_Data *sd)
}
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");
if (sd->scroll)
@@ -1971,6 +1972,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 *
_efl_ui_text_efl_object_constructor(Eo *obj, Efl_Ui_Text_Data *sd)
{
@@ -1986,6 +2001,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);
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);
sd->entry_edje = wd->resize_obj;
@@ -2033,10 +2050,16 @@ _efl_ui_text_efl_object_finalize(Eo *obj,
efl_text_normal_color_set(sd->text_obj, 255, 255, 255, 255);
sd->single_line = !efl_text_multiline_get(sd->text_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);
- sd->item_fallback_factory = efl_add(EFL_UI_TEXT_FACTORY_FALLBACK_CLASS, 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);
- edje_object_part_swallow(sd->entry_edje, "efl.text", sd->text_obj);
+ sd->item_fallback_factory = efl_add(EFL_UI_TEXT_FACTORY_FALLBACK_CLASS, obj);
evas_object_size_hint_weight_set
(sd->entry_edje, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
@@ -2440,14 +2463,12 @@ _efl_ui_text_scrollable_set(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd, Eina_Bool
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);
+ 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);
- efl_ui_internal_text_scroller_text_object_set(sd->scroller, sd->text_obj);
evas_object_clip_set(sd->cursor,
efl_ui_internal_text_scroller_viewport_clip_get(sd->scroller));
efl_event_callback_add(sd->scroller, EFL_GFX_ENTITY_EVENT_RESIZE,
@@ -2456,8 +2477,7 @@ _efl_ui_text_scrollable_set(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd, Eina_Bool
else
{
efl_content_set(sd->scroller, NULL);
- edje_object_part_swallow(sd->entry_edje, "efl.text", sd->text_obj);
- efl_unref(sd->text_obj);
+ edje_object_part_swallow(sd->entry_edje, "efl.text", sd->text_table);
efl_del(sd->scroller);
sd->scroller = NULL;
}
@@ -3257,7 +3277,7 @@ _decoration_create(Eo *obj, Efl_Ui_Text_Data *sd,
evas_object_smart_member_add(ret, sd->entry_edje);
if (above)
{
- evas_object_stack_above(ret, sd->text_obj);
+ evas_object_stack_above(ret, sd->text_table);
}
else
{
@@ -3754,6 +3774,7 @@ _efl_ui_text_changed_cb(void *data, const Efl_Event *event EINA_UNUSED)
EFL_UI_TEXT_DATA_GET(data, sd);
sd->text_changed = EINA_TRUE;
sd->cursor_update = EINA_TRUE;
+ _update_guide_text(data, sd);
elm_layout_sizing_eval(data);
_decoration_defer(data);
}
@@ -3766,6 +3787,7 @@ _efl_ui_text_changed_user_cb(void *data, const Efl_Event *event)
if (efl_invalidated_get(event->object)) return;
EFL_UI_TEXT_DATA_GET(obj, sd);
sd->text_changed = EINA_TRUE;
+ _update_guide_text(data, sd);
elm_layout_sizing_eval(obj);
_decoration_defer_all(obj);
}