From c0cd7d4632a5ec5460bcbb1158bc9969e9666af9 Mon Sep 17 00:00:00 2001 From: Haifeng Deng Date: Sat, 7 Sep 2013 15:15:18 +0800 Subject: [PATCH] Add soft candidate interface Change-Id: I52ab632e6a2719eea44b0807487a499a254c635e --- ism/data/pixmaps/isf_candidate.edc | 81 ++++++++++++++++++++ ism/extras/efl_panel/isf_panel_efl.cpp | 53 ++++++++++++- ism/src/scim_helper.cpp | 82 +++++++++++++++++++++ ism/src/scim_helper.h | 38 ++++++++++ ism/src/scim_panel_agent.cpp | 131 +++++++++++++++++++++++++++++++++ ism/src/scim_panel_agent.h | 25 +++++++ ism/src/scim_trans_commands.h | 4 + ism/src/scim_utility.h | 1 + 8 files changed, 414 insertions(+), 1 deletion(-) diff --git a/ism/data/pixmaps/isf_candidate.edc b/ism/data/pixmaps/isf_candidate.edc index a0235de..fe9d5bd 100755 --- a/ism/data/pixmaps/isf_candidate.edc +++ b/ism/data/pixmaps/isf_candidate.edc @@ -218,6 +218,87 @@ collections { } } + group { name: "soft_candidate"; + images { + image: BUTTON_NORMAL_BG COMP; + image: BUTTON_PRESS_BG COMP; + } + + parts { + part { name: "bg"; + type: RECT; + mouse_events: 1; + description { state: "default" 0.0; + rel1.relative: 0.0 0.0; + rel2.relative: 1.0 1.0; + color_class: "rect_color"; + } + description { state: "pressed" 0.0; + rel1.relative: 0.0 0.0; + rel2.relative: 1.0 1.0; + color: COLOR_PRESS_BUTTON; + } + } + + part { name: "candidate"; + type: TEXT; + mouse_events: 0; + //effect: SHADOW; + description { state: "default" 0.0; + color: COLOR_NORMAL_TEXT; + color_class: "text_color"; + text { + text_class: "candidate_text_class"; + text: "Test"; + font: FONT_NAME; + size: FONT_SIZE; + align: 0.5 0.5; + } + rel1.to: "bg"; + rel1.relative: 0.0 0.0; + rel1.offset: 11 0; + rel2.to: "bg"; + rel2.relative: 1.0 1.0; + rel2.offset: -11 0; + } + description { state: "pressed" 0.0; + inherit: "default" 0.0; + color: COLOR_PRESS_TEXT; + } + } + } + programs { + program { name: "button_click"; + signal: "mouse,clicked,1"; + source: "bg"; + action: SIGNAL_EMIT "candidate,action,clicked" ""; + } + + program { name, "button_press"; + signal, "mouse,down,1"; + source, "bg"; + action, STATE_SET "pressed" 0.0; + target, "bg"; + target, "candidate"; + } + + program { name, "button_release"; + signal, "mouse,up,1"; + source, "bg"; + action, STATE_SET "default" 0.0; + target, "bg"; + target, "candidate"; + //after, "do_me"; + } + + program { name, "do_me"; + //signal, "*"; + //source, "button_release"; + action, SIGNAL_EMIT "candidate,action,clicked" ""; + } + } + } + group { name: "more_button"; images { diff --git a/ism/extras/efl_panel/isf_panel_efl.cpp b/ism/extras/efl_panel/isf_panel_efl.cpp index b7e2bbc..c7aff21 100644 --- a/ism/extras/efl_panel/isf_panel_efl.cpp +++ b/ism/extras/efl_panel/isf_panel_efl.cpp @@ -157,6 +157,7 @@ static void slot_update_preedit_string (const String &str, const static void slot_update_preedit_caret (int caret); static void slot_update_aux_string (const String &str, const AttributeList &attrs); static void slot_update_candidate_table (const LookupTable &table); +static void slot_select_candidate (int index); static void slot_set_active_ise (const String &uuid, bool changeDefault); static bool slot_get_ise_list (std::vector &list); static bool slot_get_ise_information (String uuid, String &name, String &language, int &type, int &option); @@ -2386,6 +2387,7 @@ static bool initialize_panel_agent (const String &config, const String &display, _panel_agent->signal_connect_update_preedit_caret (slot (slot_update_preedit_caret)); _panel_agent->signal_connect_update_aux_string (slot (slot_update_aux_string)); _panel_agent->signal_connect_update_lookup_table (slot (slot_update_candidate_table)); + _panel_agent->signal_connect_select_candidate (slot (slot_select_candidate)); _panel_agent->signal_connect_get_candidate_geometry (slot (slot_get_candidate_geometry)); _panel_agent->signal_connect_get_input_panel_geometry (slot (slot_get_input_panel_geometry)); _panel_agent->signal_connect_set_active_ise_by_uuid (slot (slot_set_active_ise)); @@ -2454,6 +2456,8 @@ static void slot_focus_out (void) static void slot_expand_candidate (void) { SCIM_DEBUG_MAIN (3) << __FUNCTION__ << "...\n"; + if (_candidate_mode == SOFT_CANDIDATE_WINDOW) + return; if (_candidate_area_2 && !evas_object_visible_get (_candidate_area_2)) ui_candidate_window_more_button_cb (NULL, NULL, NULL, NULL); @@ -2466,6 +2470,9 @@ static void slot_contract_candidate (void) { SCIM_DEBUG_MAIN (3) << __FUNCTION__ << "...\n"; + if (_candidate_mode == SOFT_CANDIDATE_WINDOW) + return; + ui_candidate_window_close_button_cb (NULL, NULL, NULL, NULL); } @@ -2481,6 +2488,14 @@ static void slot_set_candidate_style (int portrait_line, int mode) if ((portrait_line != _candidate_port_line) || (mode != _candidate_mode)) { _candidate_mode = (ISF_CANDIDATE_MODE_T)mode; _candidate_port_line = (ISF_CANDIDATE_PORTRAIT_LINE_T)portrait_line; + + if (_candidate_mode == SOFT_CANDIDATE_WINDOW) { + if (_candidate_window) + ui_destroy_candidate_window (); + + return; + } + if (_candidate_window) ui_create_candidate_window (); } @@ -2642,9 +2657,14 @@ static void slot_show_aux_string (void) */ static void slot_show_candidate_table (void) { - SCIM_DEBUG_MAIN (3) << __FUNCTION__ << "...\n"; int feedback_result = 0; + if (_candidate_mode == SOFT_CANDIDATE_WINDOW) { + _panel_agent->helper_candidate_show (); + return; + } + + SCIM_DEBUG_MAIN (3) << __FUNCTION__ << "...\n"; if (_candidate_window == NULL) ui_create_candidate_window (); @@ -2711,6 +2731,11 @@ static void slot_hide_candidate_table (void) int feedback_result = 0; + if (_candidate_mode == SOFT_CANDIDATE_WINDOW) { + _panel_agent->helper_candidate_hide (); + return; + } + if (!_candidate_area_1) return; @@ -3218,6 +3243,12 @@ static void update_table (int table_type, const LookupTable &table) static void slot_update_candidate_table (const LookupTable &table) { SCIM_DEBUG_MAIN (3) << __FUNCTION__ << "...\n"; + + if (_candidate_mode == SOFT_CANDIDATE_WINDOW){ + _panel_agent->update_helper_lookup_table (table); + return ; + } + if (_candidate_window == NULL) ui_create_candidate_window (); @@ -3228,6 +3259,17 @@ static void slot_update_candidate_table (const LookupTable &table) } /** + * @brief Send selected candidate index. + * + * @param selected candidate string index number. + */ +static void slot_select_candidate (int index) +{ + SCIM_DEBUG_MAIN (3) << __FUNCTION__ << "...\n"; + _panel_agent->select_candidate (index); +} + +/** * @brief Get candidate geometry slot function for PanelAgent. * * @param info The data is used to store candidate position and size. @@ -3238,6 +3280,15 @@ static void slot_get_candidate_geometry (struct rectinfo &info) int y = 0; int width = 0; int height = 0; + + if (_candidate_mode == SOFT_CANDIDATE_WINDOW) { + info.pos_x = x; + info.pos_y = y; + info.width = width; + info.height = height; + return; + } + if (!_candidate_will_hide) { if (_candidate_window && evas_object_visible_get (_candidate_window)) { /* Get candidate window position */ diff --git a/ism/src/scim_helper.cpp b/ism/src/scim_helper.cpp index 075f039..6419ab0 100644 --- a/ism/src/scim_helper.cpp +++ b/ism/src/scim_helper.cpp @@ -50,6 +50,8 @@ #include "scim_private.h" #include "scim.h" +EAPI scim::CommonLookupTable g_helper_candidate_table; + namespace scim { typedef Signal3 @@ -100,6 +102,9 @@ typedef Signal3 typedef Signal2 &> HelperAgentSignalUintVector; +typedef Signal2 + HelperAgentSignalLookupTable; + class HelperAgent::HelperAgentImpl { public: @@ -126,6 +131,8 @@ public: HelperAgentSignalVoid signal_focus_in; HelperAgentSignalIntRawVoid signal_ise_show; HelperAgentSignalVoid signal_ise_hide; + HelperAgentSignalVoid signal_candidate_show; + HelperAgentSignalVoid signal_candidate_hide; HelperAgentSignalSize signal_get_geometry; HelperAgentSignalUintVoid signal_set_mode; HelperAgentSignalUintVoid signal_set_language; @@ -146,6 +153,7 @@ public: HelperAgentSignalStringVector signal_update_keyboard_ise_list; HelperAgentSignalVoid signal_candidate_more_window_show; HelperAgentSignalVoid signal_candidate_more_window_hide; + HelperAgentSignalLookupTable signal_update_lookup_table; HelperAgentSignalInt signal_select_aux; HelperAgentSignalInt signal_select_candidate; HelperAgentSignalVoid signal_candidate_table_page_up; @@ -714,6 +722,22 @@ HelperAgent::filter_event () m_impl->signal_update_candidate_table_page_size (this, ic, ic_uuid, size); break; } + case ISM_TRANS_CMD_CANDIDATE_SHOW: + { + m_impl->signal_candidate_show (this, ic, ic_uuid); + break; + } + case ISM_TRANS_CMD_CANDIDATE_HIDE: + { + m_impl->signal_candidate_hide (this, ic, ic_uuid); + break; + } + case ISM_TRANS_CMD_UPDATE_LOOKUP_TABLE: + { + if (m_impl->recv.get_data (g_helper_candidate_table)) + m_impl->signal_update_lookup_table (this, g_helper_candidate_table); + break; + } case ISM_TRANS_CMD_UPDATE_CANDIDATE_ITEM_LAYOUT: { std::vector row_items; @@ -1461,6 +1485,22 @@ HelperAgent::contract_candidate (void) const } /** + * @brief Send selected candidate string index number. + */ +void +HelperAgent::select_candidate (int index) const +{ + if (m_impl->socket_active.is_connected ()) { + m_impl->send.clear (); + m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST); + m_impl->send.put_data (m_impl->magic_active); + m_impl->send.put_command (ISM_TRANS_CMD_SELECT_CANDIDATE); + m_impl->send.put_data (index); + m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active); + } +} + +/** * @brief Update our ISE is exiting. */ void @@ -1983,6 +2023,48 @@ HelperAgent::signal_connect_candidate_more_window_hide (HelperAgentSlotVoid *slo } /** + * @brief Connect a slot to Helper candidate show signal. + * + * This signal is used to do candidate show. + * + * The prototype of the slot is: + * void candidate_show (const HelperAgent *agent, int ic, const String &uuid); + */ +Connection +HelperAgent::signal_connect_candidate_show (HelperAgentSlotVoid *slot) +{ + return m_impl->signal_candidate_show.connect (slot); +} + +/** + * @brief Connect a slot to Helper candidate hide signal. + * + * This signal is used to do candidate hide. + * + * The prototype of the slot is: + * void candidate_hide (const HelperAgent *agent, int ic, const String &uuid); + */ +Connection +HelperAgent::signal_connect_candidate_hide (HelperAgentSlotVoid *slot) +{ + return m_impl->signal_candidate_hide.connect (slot); +} + +/** + * @brief Connect a slot to Helper update lookup table signal. + * + * This signal is used to do someting when update lookup table. + * + * The prototype of the slot is: + * void update_lookup_table (const HelperAgent *agent, int ic, const String &uuid ,LookupTable &table); + */ +Connection +HelperAgent::signal_connect_update_lookup_table (HelperAgentSlotLookupTable *slot) +{ + return m_impl->signal_update_lookup_table.connect (slot); +} + +/** * @brief Connect a slot to Helper select aux signal. * * This signal is used to do something when aux is selected. diff --git a/ism/src/scim_helper.h b/ism/src/scim_helper.h index 81d82b7..156d4b1 100644 --- a/ism/src/scim_helper.h +++ b/ism/src/scim_helper.h @@ -199,6 +199,9 @@ typedef Slot3 typedef Slot2 &> HelperAgentSlotUintVector; +typedef Slot2 + HelperAgentSlotLookupTable; + /** * @brief The accessory class to write a Helper object. * @@ -564,6 +567,11 @@ public: void contract_candidate (void) const; /** + * @brief Send selected candidate string index number. + */ + void select_candidate (int index) const; + + /** * @brief Update ise exit status */ void update_ise_exit (void) const; @@ -951,6 +959,36 @@ public: Connection signal_connect_candidate_more_window_hide (HelperAgentSlotVoid *slot); /** + * @brief Connect a slot to Helper candidate show signal. + * + * This signal is used to do candidate show. + * + * The prototype of the slot is: + * void candidate_show (const HelperAgent *agent, int ic, const String &uuid); + */ + Connection signal_connect_candidate_show (HelperAgentSlotVoid *slot); + + /** + * @brief Connect a slot to Helper candidate hide signal. + * + * This signal is used to do candidate hide. + * + * The prototype of the slot is: + * void candidate_hide (const HelperAgent *agent,int ic, const String &uuid); + */ + Connection signal_connect_candidate_hide (HelperAgentSlotVoid *slot); + + /** + * @brief Connect a slot to Helper update lookup table signal. + * + * This signal is used to do someting when update lookup table. + * + * The prototype of the slot is: + * void update_lookup_table (const HelperAgent *agent, int ic, const String &uuid, LookupTable &Table); + */ + Connection signal_connect_update_lookup_table (HelperAgentSlotLookupTable *slot); + + /** * @brief Connect a slot to Helper select aux signal. * * This signal is used to do something when aux is selected. diff --git a/ism/src/scim_panel_agent.cpp b/ism/src/scim_panel_agent.cpp index 58d5896..2dc8fc3 100644 --- a/ism/src/scim_panel_agent.cpp +++ b/ism/src/scim_panel_agent.cpp @@ -337,6 +337,7 @@ class PanelAgent::PanelAgentImpl PanelAgentSignalVoid m_signal_focus_out; PanelAgentSignalVoid m_signal_expand_candidate; PanelAgentSignalVoid m_signal_contract_candidate; + PanelAgentSignalInt m_signal_select_candidate; PanelAgentSignalBoolStringVector m_signal_get_ise_list; PanelAgentSignalBoolString3int2 m_signal_get_ise_information; PanelAgentSignalBoolStringVector m_signal_get_keyboard_ise_list; @@ -695,6 +696,66 @@ public: return client >= 0; } + bool helper_candidate_show (void) + { + SCIM_DEBUG_MAIN(4) << __FUNCTION__ << "...\n"; + + int client; + uint32 context; + + get_focused_context (client, context); + + if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode) { + HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid); + + if (it != m_helper_client_index.end ()) { + Socket client_socket (it->second.id); + uint32 ctx = get_helper_ic (client, context); + + m_send_trans.clear (); + m_send_trans.put_command (SCIM_TRANS_CMD_REPLY); + m_send_trans.put_data (ctx); + m_send_trans.put_data (m_current_helper_uuid); + m_send_trans.put_command (ISM_TRANS_CMD_CANDIDATE_SHOW); + m_send_trans.write_to_socket (client_socket); + + return true; + } + } + + return false; + } + + bool helper_candidate_hide (void) + { + SCIM_DEBUG_MAIN(4) << __FUNCTION__ << "...\n"; + + int client; + uint32 context; + + get_focused_context (client, context); + + if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode) { + HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid); + + if (it != m_helper_client_index.end ()) { + Socket client_socket (it->second.id); + uint32 ctx = get_helper_ic (client, context); + + m_send_trans.clear (); + m_send_trans.put_command (SCIM_TRANS_CMD_REPLY); + m_send_trans.put_data (ctx); + m_send_trans.put_data (m_current_helper_uuid); + m_send_trans.put_command (ISM_TRANS_CMD_CANDIDATE_HIDE); + m_send_trans.write_to_socket (client_socket); + + return true; + } + } + + return false; + } + bool candidate_more_window_show (void) { SCIM_DEBUG_MAIN(4) << __FUNCTION__ << "...\n"; @@ -777,6 +838,36 @@ public: return false; } + bool update_helper_lookup_table (const LookupTable &table) + { + int client; + uint32 context; + + if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode) { + HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid); + + if (it != m_helper_client_index.end ()) { + Socket client_socket (it->second.id); + uint32 ctx; + + get_focused_context (client, context); + ctx = get_helper_ic (client, context); + + m_send_trans.clear (); + m_send_trans.put_command (SCIM_TRANS_CMD_REPLY); + m_send_trans.put_data (ctx); + m_send_trans.put_data (m_current_helper_uuid); + m_send_trans.put_command (ISM_TRANS_CMD_UPDATE_LOOKUP_TABLE); + m_send_trans.put_data (table); + m_send_trans.write_to_socket (client_socket); + + return true; + } + } + + return false; + } + bool select_aux (uint32 item) { SCIM_DEBUG_MAIN(1) << "PanelAgent::select_aux (" << item << ")\n"; @@ -2771,6 +2862,11 @@ public: return m_signal_contract_candidate.connect (slot); } + Connection signal_connect_select_candidate (PanelAgentSlotInt *slot) + { + return m_signal_select_candidate.connect (slot); + } + Connection signal_connect_get_ise_list (PanelAgentSlotBoolStringVector *slot) { return m_signal_get_ise_list.connect (slot); @@ -3346,6 +3442,8 @@ private: socket_helper_expand_candidate (client_id); } else if (cmd == ISM_TRANS_CMD_CONTRACT_CANDIDATE) { socket_helper_contract_candidate (client_id); + } else if (cmd == ISM_TRANS_CMD_SELECT_CANDIDATE) { + socket_helper_select_candidate (); } else if (cmd == SCIM_TRANS_CMD_GET_SURROUNDING_TEXT) { socket_helper_get_surrounding_text (client_id); } else if (cmd == SCIM_TRANS_CMD_DELETE_SURROUNDING_TEXT) { @@ -4066,6 +4164,15 @@ private: m_signal_set_keyboard_ise (uuid); } + void socket_helper_select_candidate (void) + { + SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_set_keyboard_ise ()\n"; + + uint32 index; + if (m_recv_trans.get_data (index)) + m_signal_select_candidate (index); + } + void socket_helper_update_ise_geometry (int client) { SCIM_DEBUG_MAIN(4) << __func__ << "\n"; @@ -5460,6 +5567,18 @@ PanelAgent::change_factory (const String &uuid) } bool +PanelAgent::helper_candidate_show (void) +{ + return m_impl->helper_candidate_show (); +} + +bool +PanelAgent::helper_candidate_hide (void) +{ + return m_impl->helper_candidate_hide (); +} + +bool PanelAgent::candidate_more_window_show (void) { return m_impl->candidate_more_window_show (); @@ -5472,6 +5591,12 @@ PanelAgent::candidate_more_window_hide (void) } bool +PanelAgent::update_helper_lookup_table (const LookupTable &table) +{ + return m_impl->update_helper_lookup_table (table); +} + +bool PanelAgent::select_aux (uint32 item) { return m_impl->select_aux (item); @@ -5905,6 +6030,12 @@ PanelAgent::signal_connect_contract_candidate (PanelAgentSlotVoid } Connection +PanelAgent::signal_connect_select_candidate (PanelAgentSlotInt *slot) +{ + return m_impl->signal_connect_select_candidate (slot); +} + +Connection PanelAgent::signal_connect_get_ise_list (PanelAgentSlotBoolStringVector *slot) { return m_impl->signal_connect_get_ise_list (slot); diff --git a/ism/src/scim_panel_agent.h b/ism/src/scim_panel_agent.h index 25cda96..fd1b6f0 100644 --- a/ism/src/scim_panel_agent.h +++ b/ism/src/scim_panel_agent.h @@ -476,6 +476,24 @@ public: bool candidate_more_window_hide (void); /** + * @brief Notice Helper ISE that show candidate. + * @return true if the command was sent correctly. + */ + bool helper_candidate_show (void); + + /** + * @brief Notice Helper ISE that hide candidate. + * @return true if the command was sent correctly. + */ + bool helper_candidate_hide (void); + + /** + * @brief Update helper lookup table. + * @return true if the command was sent correctly. + */ + bool update_helper_lookup_table (const LookupTable &table); + + /** * @brief Let the focused IMEngineInstance object * select a aux in current aux string. * @@ -992,6 +1010,13 @@ public: Connection signal_connect_contract_candidate (PanelAgentSlotVoid *slot); /** + * @brief Signal: Select candidate string index. + * + * slot prototype: void select_candidate (int index); + */ + Connection signal_connect_select_candidate (PanelAgentSlotInt *slot); + + /** * @brief Signal: Get the list of ise name. * * slot prototype: bool get_ise_list (std::vector &); diff --git a/ism/src/scim_trans_commands.h b/ism/src/scim_trans_commands.h index c484c8c..34f3a1c 100644 --- a/ism/src/scim_trans_commands.h +++ b/ism/src/scim_trans_commands.h @@ -665,12 +665,16 @@ const int ISM_TRANS_CMD_UPDATE_ISE_GEOMETRY = 1213; const int ISM_TRANS_CMD_EXPAND_CANDIDATE = 1214; const int ISM_TRANS_CMD_CONTRACT_CANDIDATE = 1215; const int ISM_TRANS_CMD_UPDATE_ISE_EXIT = 1216; +const int ISM_TRANS_CMD_SELECT_CANDIDATE = 1217; /* Panel to ISE */ const int ISM_TRANS_CMD_CANDIDATE_MORE_WINDOW_SHOW = 1251; const int ISM_TRANS_CMD_CANDIDATE_MORE_WINDOW_HIDE = 1252; const int ISM_TRANS_CMD_UPDATE_DISPLAYED_CANDIDATE = 1253; const int ISM_TRANS_CMD_LONGPRESS_CANDIDATE = 1254; +const int ISM_TRANS_CMD_UPDATE_LOOKUP_TABLE = 1255; +const int ISM_TRANS_CMD_CANDIDATE_SHOW = 1256; +const int ISM_TRANS_CMD_CANDIDATE_HIDE = 1257; const int ISM_TRANS_CMD_TURN_ON_LOG = 1301; diff --git a/ism/src/scim_utility.h b/ism/src/scim_utility.h index d42610b..a6296a4 100644 --- a/ism/src/scim_utility.h +++ b/ism/src/scim_utility.h @@ -503,6 +503,7 @@ typedef enum { FIXED_CANDIDATE_WINDOW = 0, FLOATING_CANDIDATE_WINDOW, + SOFT_CANDIDATE_WINDOW } ISF_CANDIDATE_MODE_T; typedef enum -- 2.7.4