Adapt to latest Text changes

This commit is contained in:
Xavi Artigas 2019-12-05 12:58:02 +01:00
parent 868ed77548
commit aeaba83065
3 changed files with 23 additions and 12 deletions

View File

@ -57,12 +57,14 @@ _button_pressed_cb(void *data, const Efl_Event *event EINA_UNUSED)
efl_text_set(_screen, "");
_must_overwrite = EINA_FALSE;
}
Efl_Text_Cursor_Cursor *cursor = efl_text_cursor_get(_screen, EFL_TEXT_CURSOR_GET_TYPE_MAIN);
efl_text_cursor_text_insert(_screen, cursor, str);
Efl_Text_Cursor *cursor = efl_text_interactive_main_cursor_get(_screen);
efl_text_cursor_text_insert(cursor, str);
}
else
{
char str[32] = "";
// No need to sanitize these values, so do not emit "text changed" events
efl_event_freeze(_screen);
switch (button)
{
case 'C':
@ -89,11 +91,12 @@ _button_pressed_cb(void *data, const Efl_Event *event EINA_UNUSED)
default:
break;
}
efl_event_thaw(_screen);
}
}
// Called every time the content of the screen changes
// We use it to sanitize input (remove heading zeros, for example)
// We use it to sanitize input (remove leading zeros, for example)
// This makes more sense when the Text widget is editable, since the user
// is free to type anything.
static void
@ -113,7 +116,11 @@ _screen_changed_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
}
if (strncmp(_text, str, sizeof(_text)))
{
// Avoid infinite recursion when setting the text from the
// "text changed" callback
efl_event_freeze(_screen);
efl_text_set(_screen, _text);
efl_event_thaw(_screen);
}
}
@ -134,11 +141,12 @@ _button_add(Efl_Ui_Table *table, const char *text, const char *command, int posx
Efl_Ui_Text *label =
efl_add(EFL_UI_TEXT_CLASS, button,
efl_text_interactive_editable_set(efl_added, EINA_FALSE),
efl_text_halign_set(efl_added, 0.5),
efl_text_valign_set(efl_added, 0.5),
efl_text_horizontal_align_set(efl_added, 0.5),
efl_text_vertical_align_set(efl_added, 0.5),
efl_gfx_color_set(efl_added, r, g, b, 255),
efl_text_set(efl_added, text));
efl_text_font_set(label, "Sans", 36);
efl_text_font_family_set(label, "Sans");
efl_text_font_size_set(label, 36);
efl_content_set(button, label);
}
@ -188,13 +196,14 @@ _gui_setup()
efl_text_interactive_editable_set(efl_added, EINA_FALSE),
efl_text_interactive_selection_allowed_set(efl_added, EINA_FALSE),
efl_pack_table(table, efl_added, 0, 0, 4, 1),
efl_text_halign_set(efl_added, 0.9),
efl_text_valign_set(efl_added, 0.5),
efl_text_horizontal_align_set(efl_added, 0.9),
efl_text_vertical_align_set(efl_added, 0.5),
efl_text_effect_type_set(efl_added, EFL_TEXT_STYLE_EFFECT_TYPE_GLOW),
efl_text_glow_color_set(efl_added, 128, 128, 128, 128),
efl_event_callback_add(efl_added, EFL_UI_TEXT_EVENT_CHANGED,
_screen_changed_cb, NULL));
efl_text_font_set(_screen, "Sans", 48);
efl_text_font_family_set(_screen, "Sans");
efl_text_font_size_set(_screen, 48);
}
EAPI_MAIN void

View File

@ -82,7 +82,7 @@ _gui_toolbar_refresh(void)
EFL_CALLBACKS_ARRAY_DEFINE(_editor_callbacks,
{ EFL_UI_TEXT_EVENT_CHANGED, _editor_changed_cb },
{ EFL_UI_TEXT_EVENT_CHANGED_USER, _editor_changed_cb });
{ EFL_TEXT_INTERACTIVE_EVENT_CHANGED_USER, _editor_changed_cb });
static void
_gui_setup()
@ -104,12 +104,13 @@ _gui_setup()
_gui_toolbar_setup(box);
_editor = efl_add(EFL_UI_TEXT_CLASS, box,
efl_text_font_set(efl_added, "Mono", 14),
efl_text_multiline_set(efl_added, EINA_TRUE),
efl_text_interactive_editable_set(efl_added, EINA_TRUE),
efl_event_callback_array_add(efl_added, _editor_callbacks(), NULL),
efl_pack(box, efl_added));
efl_ui_text_scrollable_set(_editor, EINA_TRUE);
efl_text_font_family_set(_editor, "Mono");
efl_text_font_size_set(_editor, 14);
}
EAPI_MAIN void

View File

@ -168,7 +168,8 @@ public class TextEditor : Efl.Csharp.Application
// Create the main text entry
editorTextBox = new Efl.Ui.Text(box);
editorTextBox.SetFont("Mono", 14);
editorTextBox.FontFamily = "Mono";
editorTextBox.FontSize = 14;
editorTextBox.Multiline = true;
editorTextBox.Editable = true;
editorTextBox.Scrollable = true;