forked from enlightenment/efl
Ui text: implement non-editable beahvior
Non-editable behavior resembles a label. It doesn't allow changing the text in any interactive form. The blinking cursor is also hidden. Selection, however, it allowed. Among the changes, I added a test which you can run using: "elementary_test -to "efl ui text label".
This commit is contained in:
parent
4f9ef4989c
commit
a8cea307dc
|
@ -839,6 +839,7 @@ bin/elementary/test_win_state.c \
|
|||
bin/elementary/test_win_wm_rotation.c \
|
||||
bin/elementary/test_win_dialog.c \
|
||||
bin/elementary/test_win_modal.c \
|
||||
bin/elementary/test_efl_ui_text.c \
|
||||
bin/elementary/test.h
|
||||
|
||||
bin_elementary_elementary_test_LDADD = @USE_ELEMENTARY_LIBS@
|
||||
|
|
|
@ -136,7 +136,6 @@ test_win_plug.c \
|
|||
test_win_state.c \
|
||||
test_win_wm_rotation.c \
|
||||
test_win_dialog.c \
|
||||
test_efl_ui_text.c \
|
||||
test.h
|
||||
|
||||
elementary_test_LDADD = $(top_builddir)/src/lib/libelementary.la \
|
||||
|
|
|
@ -295,7 +295,9 @@ void test_code_mirror(void *data, Evas_Object *obj, void *event_info);
|
|||
void test_code_log(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_code_diff(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_code_diff_inline(void *data, Evas_Object *obj, void *event_info);
|
||||
|
||||
void test_efl_ui_text(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_efl_ui_text_label(void *data, Evas_Object *obj, void *event_info);
|
||||
|
||||
Evas_Object *win, *tbx; // TODO: refactoring
|
||||
void *tt;
|
||||
|
@ -711,6 +713,7 @@ add_tests:
|
|||
ADD_TEST(NULL, "Entries", "Entry Emoticon", test_entry_emoticon);
|
||||
ADD_TEST(NULL, "Entries", "Entry Password", test_entry_password);
|
||||
ADD_TEST(NULL, "Entries", "Efl UI Text", test_efl_ui_text);
|
||||
ADD_TEST(NULL, "Entries", "Efl UI Text Label", test_efl_ui_text_label);
|
||||
|
||||
//------------------------------//
|
||||
ADD_TEST(NULL, "Advanced Entries", "Code Entry Markup", test_code_welcome);
|
||||
|
|
|
@ -4,3 +4,64 @@
|
|||
#define EO_BETA_API
|
||||
#include <Elementary.h>
|
||||
|
||||
static void
|
||||
_apply_style(Eo *obj, size_t start_pos, size_t end_pos, const char *style)
|
||||
{
|
||||
Efl_Canvas_Text_Cursor *start, *end;
|
||||
|
||||
start = efl_canvas_text_cursor_get(obj);
|
||||
end = efl_ui_text_cursor_new(obj);
|
||||
|
||||
efl_canvas_text_cursor_position_set(start, start_pos);
|
||||
efl_canvas_text_cursor_position_set(end, end_pos);
|
||||
|
||||
efl_canvas_text_annotation_insert(obj, start, end, style);
|
||||
}
|
||||
|
||||
static Eo *
|
||||
_create_label(Eo *win, Eo *bx)
|
||||
{
|
||||
Eo *en;
|
||||
en = efl_add(EFL_UI_TEXT_CLASS, win);
|
||||
printf("Added Efl.Ui.Text object\n");
|
||||
efl_ui_text_interactive_editable_set(en, EINA_FALSE);
|
||||
efl_canvas_text_style_set(en, NULL, "DEFAULT='align=center font=Sans font_size=10 color=#fff wrap=word'");
|
||||
|
||||
evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_show(en);
|
||||
elm_box_pack_end(bx, en);
|
||||
return en;
|
||||
}
|
||||
|
||||
void
|
||||
test_efl_ui_text_label(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *win, *bx;
|
||||
Eo *en;
|
||||
|
||||
win = elm_win_util_standard_add("label", "Label");
|
||||
elm_win_autodel_set(win, EINA_TRUE);
|
||||
|
||||
bx = elm_box_add(win);
|
||||
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
elm_win_resize_object_add(win, bx);
|
||||
evas_object_show(bx);
|
||||
|
||||
en = _create_label(win, bx);
|
||||
efl_text_set(en, "This is a small label");
|
||||
// 012345678901234567890
|
||||
_apply_style(en, 0, 21, "font_size=12 font_weight=bold");
|
||||
|
||||
en = _create_label(win, bx);
|
||||
efl_text_set(en, "This is a text. Is also has\n"
|
||||
"newlines. There are several styles applied.");
|
||||
_apply_style(en, 40, 45, "font_weight=bold color=#ff0");
|
||||
_apply_style(en, 52, 58, "font_weight=italic color=#f00");
|
||||
efl_canvas_text_style_set(en, NULL, "DEFAULT='align=center font=Sans font_size=12 color=#fff wrap=word'");
|
||||
|
||||
// elm_object_focus_set(en, EINA_TRUE);
|
||||
|
||||
evas_object_resize(win, 480, 320);
|
||||
evas_object_show(win);
|
||||
}
|
||||
|
|
|
@ -254,7 +254,7 @@ struct _Mod_Api
|
|||
static void _create_selection_handlers(Evas_Object *obj, Efl_Ui_Text_Data *sd, const char *file);
|
||||
static void _magnifier_move(void *data);
|
||||
static void _update_decorations(Eo *obj);
|
||||
static void _create_text_cursors(Efl_Ui_Text_Data *sd);
|
||||
static void _create_text_cursors(Eo *obj, Efl_Ui_Text_Data *sd);
|
||||
static void _efl_ui_text_changed_cb(void *data EINA_UNUSED, const Efl_Event *event);
|
||||
static void _efl_ui_text_selection_changed_cb(void *data EINA_UNUSED, const Efl_Event *event);
|
||||
static void _efl_ui_text_cursor_changed_cb(void *data EINA_UNUSED, const Efl_Event *event);
|
||||
|
@ -2210,7 +2210,13 @@ _entry_cursor_changed_signal_cb(void *data,
|
|||
(sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN);
|
||||
sd->cur_changed = EINA_TRUE;
|
||||
if (elm_widget_focus_get(data))
|
||||
edje_object_signal_emit(sd->entry_edje, "elm,action,show,cursor", "elm");
|
||||
{
|
||||
edje_object_signal_emit(sd->entry_edje, "elm,action,show,cursor", "elm");
|
||||
}
|
||||
else
|
||||
{
|
||||
edje_object_signal_emit(sd->entry_edje, "elm,action,hide,cursor", "elm");
|
||||
}
|
||||
_cursor_geometry_recalc(data);
|
||||
if (_elm_config->atspi_mode)
|
||||
elm_interface_atspi_accessible_event_emit(ELM_INTERFACE_ATSPI_ACCESSIBLE_MIXIN, data, ELM_INTERFACE_ATSPI_TEXT_EVENT_ACCESS_TEXT_CARET_MOVED, NULL);
|
||||
|
@ -3408,7 +3414,7 @@ _efl_ui_text_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Text_Data *priv)
|
|||
if (_elm_config->desktop_entry)
|
||||
priv->sel_handler_disabled = EINA_TRUE;
|
||||
|
||||
_create_text_cursors(priv);
|
||||
_create_text_cursors(obj, priv);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -3732,6 +3738,16 @@ _efl_ui_text_efl_ui_text_interactive_editable_set(Eo *obj, Efl_Ui_Text_Data *sd,
|
|||
_dnd_leave_cb, NULL,
|
||||
_dnd_pos_cb, NULL,
|
||||
_dnd_drop_cb, NULL);
|
||||
if (sd->cursor)
|
||||
{
|
||||
evas_object_show(sd->cursor);
|
||||
evas_object_show(sd->cursor_bidi);
|
||||
}
|
||||
}
|
||||
if (!editable && sd->cursor)
|
||||
{
|
||||
evas_object_hide(sd->cursor);
|
||||
evas_object_hide(sd->cursor_bidi);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4916,16 +4932,20 @@ _decoration_create(Efl_Ui_Text_Data *sd, const char *file,
|
|||
*/
|
||||
|
||||
static void
|
||||
_create_text_cursors(Efl_Ui_Text_Data *sd)
|
||||
_create_text_cursors(Eo *obj, Efl_Ui_Text_Data *sd)
|
||||
{
|
||||
const char *file;
|
||||
efl_file_get(sd->entry_edje, &file, NULL);
|
||||
sd->cursor = _decoration_create(sd, file, "elm/entry/cursor/default", EINA_TRUE);
|
||||
sd->cursor_bidi = _decoration_create(sd, file, "elm/entry/cursor/default", EINA_TRUE);
|
||||
evas_object_show(sd->cursor);
|
||||
evas_object_show(sd->cursor_bidi);
|
||||
edje_object_signal_emit(sd->cursor, "elm,action,focus", "elm");
|
||||
edje_object_signal_emit(sd->cursor_bidi, "elm,action,focus", "elm");
|
||||
|
||||
if (!efl_ui_text_interactive_editable_get(obj))
|
||||
{
|
||||
evas_object_hide(sd->cursor);
|
||||
evas_object_hide(sd->cursor_bidi);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in New Issue