ui.text: Use proper EO type for cnp mode

It's not working. Just "fixing" the API for consistency.
Also, we're lacking a proper hint for "markup without images".

So I think EFL_SELECTION_FORMAT_MARKUP should be without images, while
EFL_SELECTION_FORMAT_MARKUP | EFL_SELECTION_FORMAT_IMAGE would allow
markup with images.

Ping @thiep.ha

Ref T5329
This commit is contained in:
Jean-Philippe Andre 2018-01-18 16:19:01 +09:00
parent 4e055db429
commit 15d32fd4cc
4 changed files with 26 additions and 13 deletions

View File

@ -279,6 +279,7 @@ typedef Eo Efl_Ui_Focus_Manager;
#include <elm_win.h>
#ifdef EFL_EO_API_SUPPORT
# include <efl_selection_types.eot.h>
# include <efl_ui_list_segarray.h>
# include <efl_config_global.eo.h>
# include <efl_ui_widget.eo.h>
@ -325,7 +326,6 @@ typedef Eo Efl_Ui_Focus_Manager;
# include <efl_ui_list_pan.eo.h>
# include <efl_ui_scroll_manager.eo.h>
# include <efl_ui_scroller.eo.h>
# include <efl_selection_types.eot.h>
# include <efl_ui_dnd_types.eot.h>
# include <efl_ui_pan.eo.h>
# include <efl_selection.eo.h>

View File

@ -1445,7 +1445,7 @@ _view_init(Evas_Object *obj, Efl_Ui_Multibuttonentry_Data *sd)
sd->entry = efl_add(EFL_UI_TEXT_CLASS, sd->box,
efl_text_multiline_set(efl_added, EINA_FALSE),
efl_text_set(efl_added, ""),
efl_ui_text_cnp_mode_set(efl_added, EINA_FALSE),
efl_ui_text_cnp_mode_set(efl_added, EFL_SELECTION_FORMAT_MARKUP),
efl_ui_text_input_panel_enabled_set(efl_added, EINA_FALSE),
efl_ui_text_interactive_editable_set(efl_added, EINA_TRUE),
efl_composite_attach(obj, efl_added));

View File

@ -3606,24 +3606,36 @@ _efl_ui_text_efl_file_file_get(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd, const
}
EOLIAN static void
_efl_ui_text_cnp_mode_set(Eo *obj, Efl_Ui_Text_Data *sd, Elm_Cnp_Mode cnp_mode)
_efl_ui_text_cnp_mode_set(Eo *obj, Efl_Ui_Text_Data *sd, Efl_Selection_Format cnp_mode)
{
Elm_Sel_Format format = ELM_SEL_FORMAT_MARKUP;
/* FIXME: CnP format handling really odd... */
Elm_Sel_Format dnd_format = ELM_SEL_FORMAT_MARKUP;
Elm_Sel_Format cnp_format = cnp_mode;
if (sd->cnp_mode == cnp_mode) return;
sd->cnp_mode = cnp_mode;
if (sd->cnp_mode == ELM_CNP_MODE_PLAINTEXT)
format = ELM_SEL_FORMAT_TEXT;
else if (cnp_mode == ELM_CNP_MODE_MARKUP)
format |= ELM_SEL_FORMAT_IMAGE;
if (cnp_mode != EFL_SELECTION_FORMAT_TARGETS)
{
if (cnp_mode & EFL_SELECTION_FORMAT_VCARD)
ERR("VCARD format not supported for copy & paste!");
else if (cnp_mode & EFL_SELECTION_FORMAT_HTML)
ERR("HTML format not supported for copy & paste!");
cnp_mode &= ~EFL_SELECTION_FORMAT_VCARD;
cnp_mode &= ~EFL_SELECTION_FORMAT_HTML;
}
if (sd->cnp_mode == cnp_format) return;
sd->cnp_mode = cnp_format;
if (sd->cnp_mode == EFL_SELECTION_FORMAT_TEXT)
dnd_format = ELM_SEL_FORMAT_TEXT;
else if (cnp_mode == EFL_SELECTION_FORMAT_IMAGE)
dnd_format |= ELM_SEL_FORMAT_IMAGE;
elm_drop_target_del(obj, sd->drop_format,
_dnd_enter_cb, NULL,
_dnd_leave_cb, NULL,
_dnd_pos_cb, NULL,
_dnd_drop_cb, NULL);
sd->drop_format = format;
sd->drop_format = dnd_format;
elm_drop_target_add(obj, sd->drop_format,
_dnd_enter_cb, NULL,
_dnd_leave_cb, NULL,
@ -3631,7 +3643,7 @@ _efl_ui_text_cnp_mode_set(Eo *obj, Efl_Ui_Text_Data *sd, Elm_Cnp_Mode cnp_mode)
_dnd_drop_cb, NULL);
}
EOLIAN static Elm_Cnp_Mode
EOLIAN static Efl_Selection_Format
_efl_ui_text_cnp_mode_get(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd)
{
return sd->cnp_mode;

View File

@ -59,6 +59,7 @@ class Efl.Ui.Text (Efl.Ui.Layout, Elm.Interface_Scrollable, Efl.Ui.Clickable,
}
}
@property cnp_mode {
/* FIXME: Efl.Selection.Format does not allow markup without images! */
set {
[[Control pasting of text and images for the widget.
@ -77,7 +78,7 @@ class Efl.Ui.Text (Efl.Ui.Layout, Elm.Interface_Scrollable, Efl.Ui.Clickable,
]]
}
values {
cnp_mode: Elm.Cnp_Mode; [[One of #Elm_Cnp_Mode: #ELM_CNP_MODE_MARKUP, #ELM_CNP_MODE_NO_IMAGE, #ELM_CNP_MODE_PLAINTEXT.]]
format: Efl.Selection.Format; [[Format for copy & paste.]]
}
}
@property input_panel_language {