Fix candidate cursor highlight for TV 16/159316/8
authorliuxd <xd123.liu@samsung.com>
Wed, 8 Nov 2017 07:10:01 +0000 (02:10 -0500)
committerliuxd <xd123.liu@samsung.com>
Mon, 20 Nov 2017 16:16:33 +0000 (00:16 +0800)
Signed-off-by: liuxd <xd123.liu@samsung.com>
Change-Id: I51d7f169003befcf6eb1ec2cd6196c72c7ba1915

data/edc/candidate-multiline/candidate.edc
src/candidate/efl/candidate-efl.h
src/candidate/efl/candidate-multiline-efl.cpp
src/candidate/efl/candidate-multiline-efl.h
src/candidate/include/candidate.h
src/ise.cpp

index a01eb55..2076104 100755 (executable)
@@ -174,6 +174,20 @@ collections {
                 //source, "button_release";
                 action: SIGNAL_EMIT "candidate,action,clicked" "";
             }
+            program { name: "high_light";
+                signal: "highlight";
+                source: "bg";
+                action: STATE_SET "pressed" 0.0;
+                target: "bg";
+                target: "candidate";
+            }
+            program { name: "unhigh_light";
+                signal: "unhighlight";
+                source: "bg";
+                action: STATE_SET "default" 0.0;
+                target: "bg";
+                target: "candidate";
+            }
         }
     }
     group { name: "more_button";
index 45e3d71..933fd91 100644 (file)
@@ -37,6 +37,10 @@ class EflCandidate: public Candidate
         void item_pressed(Evas_Object *item);
         void item_released(Evas_Object *item);
         void item_moved(Evas_Object *item);
+#ifdef _TV
+        sclu32 soft_candidate_handle_key_event(const char *key_name){return false;}
+        bool soft_candidate_flag(){return false;}
+#endif
     private:
         Evas_Object *create_item();
         Evas_Object *create_seperate_line();
index 25cbb7a..163542c 100644 (file)
 #include <string>
 #include <assert.h>
 #include <algorithm>
-
 #define LOG_TAG "ISE_DEFAULT"
 #include <dlog.h>
-
+#include <inputmethod_internal.h>
 using namespace std;
 
 #define CANDIDATE_EDJ_FILE_PATH       RESDIR"/edje/candidate-multiline.edj"
@@ -46,7 +45,9 @@ using namespace std;
 #endif
 
 static bool               _item_click                         = true;
+
 extern CONFIG_VALUES g_config_values;
+extern CSCLUI *g_ui;
 
 static void
 _mouse_down(void *data, Evas *e,
@@ -76,6 +77,12 @@ _mouse_move(void *data, Evas *e,
 void
 EflMultiLineCandidate::item_pressed(Evas_Object *item)
 {
+#ifdef _TV
+    m_candidates_item.clear();
+    g_ui->enable_highlight_ui(TRUE);
+    m_highlight_mode = false;
+#endif
+
     const char *str = edje_object_part_text_get(
         item, "candidate");
 
@@ -198,7 +205,6 @@ EflMultiLineCandidate::show_more_view()
     evas_object_show(m_candidateMoreScrollerBg);
     evas_object_show(m_candidateMoreScroller);
     evas_object_show(m_candidateMoreTable);
-
     MultiEventDesc desc;
     desc.type = MultiEventDesc::CANDIDATE_MORE_VIEW_SHOW;
 
@@ -415,6 +421,10 @@ EflMultiLineCandidate::EflMultiLineCandidate(Evas_Object *window)
     m_candidateFontSize = 37*m_screenRatio;
     m_stringWidthCalObj = evas_object_text_add(m_window);
     evas_object_text_font_set(m_stringWidthCalObj, m_candidateFontName.c_str(), m_candidateFontSize);
+#ifdef _TV
+    m_focused_candidate_index = 0;
+    m_highlight_mode = false;
+#endif
 }
 
 EflMultiLineCandidate::~EflMultiLineCandidate()
@@ -485,6 +495,10 @@ void
 EflMultiLineCandidate::update(const vector<string> &vec_str)
 {
     cur_candidates = vec_str;
+#ifdef _TV
+    m_focused_candidate_index = 0;
+    m_candidates_item.clear();
+#endif
     hide_more_view();
     evas_object_hide(m_candidateMoreBtn);
     evas_object_hide(m_candidateCloseBtn);
@@ -517,6 +531,9 @@ EflMultiLineCandidate::update(const vector<string> &vec_str)
             elm_table_pack(m_candidateTable, item, cur_item_sum, y_start,
                            item_text_size.width, item_text_size.height);
             cur_item_sum += item_text_size.width;
+#ifdef _TV
+            m_candidates_item.push_back(item);
+#endif
         } else if (!multiline) {
             multiline = true;
             cur_item_sum = 0;
@@ -528,6 +545,9 @@ EflMultiLineCandidate::update(const vector<string> &vec_str)
                 y_start = (CANDIDATE_WINDOW_HEIGHT*m_screenRatio - item_text_size.height)/2;
                 elm_table_pack(m_candidateTable, item, cur_item_sum, y_start,
                                item_text_size.width, item_text_size.height);
+#ifdef _TV
+                m_candidates_item.push_back(item);
+#endif
                 continue;
             }
         }
@@ -562,6 +582,9 @@ EflMultiLineCandidate::update(const vector<string> &vec_str)
             elm_table_pack(m_candidateMoreTable, item, cur_item_sum, lineCount*CANDIDATE_WINDOW_HEIGHT*m_screenRatio+y_start,
                            item_text_size.width, item_text_size.height);
             cur_item_sum += item_text_size.width;
+#ifdef _TV
+            m_candidates_item.push_back(item);
+#endif
         }
     }
 
@@ -639,3 +662,74 @@ EflMultiLineCandidate::get_floating_mode()
 {
     return m_floating_mode;
 }
+
+#ifdef _TV
+sclu32 EflMultiLineCandidate::soft_candidate_handle_key_event(const char *keyname)
+{
+    int count = (cur_candidates.size() > 20 ? 20 : cur_candidates.size());//for fixing lagging issue of glm temporarily
+    int index = 0;
+    if (strcmp(keyname, "Right") == 0) {
+        if (m_highlight_mode) {
+            index = (m_focused_candidate_index + 1) %count;
+            Evas_Object *item = m_candidates_item[m_focused_candidate_index];
+            edje_object_signal_emit(item, "unhighlight", "bg");
+            item = m_candidates_item[index];
+            edje_object_signal_emit(item, "highlight", "bg");
+            m_focused_candidate_index = index;
+            return true;
+        } else {
+            return false;
+        }
+    } else if (strcmp(keyname, "Left") == 0) {
+        if (m_highlight_mode) {
+            index = (m_focused_candidate_index + count - 1) % count;
+            Evas_Object *item = m_candidates_item[m_focused_candidate_index];
+            edje_object_signal_emit(item, "unhighlight", "bg");
+            item = m_candidates_item[index];
+            edje_object_signal_emit(item, "highlight", "bg");
+            m_focused_candidate_index = index;
+            return true;
+        } else {
+            return false;
+        }
+    } else if (strcmp(keyname, "Up") == 0) {
+        int item_num = m_candidates_item.size();
+        if (item_num > 0) {
+            more_btn_clicked();
+            g_ui->enable_highlight_ui(FALSE);
+            Evas_Object *item = m_candidates_item[m_focused_candidate_index];
+            edje_object_signal_emit(item, "highlight", "bg");
+            m_highlight_mode = true;
+        }
+            return true;
+    } else if (strcmp(keyname, "Down") == 0) {
+        if (m_highlight_mode) {
+            int item_num = m_candidates_item.size();
+            if (item_num > 0) {
+                Evas_Object *item = m_candidates_item[m_focused_candidate_index];
+                edje_object_signal_emit(item, "unhighlight", "bg");
+                close_btn_clicked();
+                g_ui->enable_highlight_ui(TRUE);
+                m_highlight_mode = false;
+                return TRUE;
+            } else {
+                return false;
+            }
+        } else {
+            return false;
+        }
+    } else if ((strcmp(keyname, "Return") == 0) || (strcmp(keyname, "Enter") == 0)) {
+        if (m_highlight_mode) {
+            ime_select_candidate(m_focused_candidate_index);
+            m_candidates_item.clear();
+            g_ui->enable_highlight_ui(TRUE);
+            m_highlight_mode = false;
+            return true;
+        } else {
+            return false;
+        }
+    } else {
+        return false;
+    }
+}
+#endif
index 11cff39..70f1374 100644 (file)
@@ -46,6 +46,10 @@ class EflMultiLineCandidate: public Candidate
         void item_pressed(Evas_Object *);
         void item_released(Evas_Object *);
         void item_moved(Evas_Object *);
+#ifdef _TV
+        sclu32 soft_candidate_handle_key_event(const char *key_name);
+        bool soft_candidate_flag(){return m_highlight_mode;}
+#endif
     private:
         void make_view();
         void make_more_view();
@@ -78,5 +82,10 @@ class EflMultiLineCandidate: public Candidate
         Evas_Object * m_candidateMoreScrollerBg;
         Evas_Object * m_candidateMoreScroller;
         Evas_Object * m_candidateMoreTable;
+#ifdef _TV
+        int  m_focused_candidate_index;
+        bool m_highlight_mode;
+        std::vector<Evas_Object *> m_candidates_item;
+#endif
 };
 #endif
index f28aca7..84dd1aa 100644 (file)
@@ -20,6 +20,8 @@
 #include <vector>
 #include <string>
 #include "ise-floating-mode.h"
+#include "scltypes.h"
+#include "ise.h"
 
 class EventDesc
 {
@@ -76,6 +78,10 @@ class Candidate
         virtual bool get_visible() { return m_visible; }
         virtual bool get_floating_mode() { return false; }
         void add_event_listener(EventListener *l);
+#ifdef _TV
+        virtual sclu32 soft_candidate_handle_key_event(const char *key_name) = 0;
+        virtual bool soft_candidate_flag() = 0;
+#endif
     protected:
         void notify_listeners(const EventDesc &desc);
         std::vector<EventListener*> listeners;
index 5697669..5b58e27 100644 (file)
@@ -1997,12 +1997,34 @@ void ise_process_key_event(scim::KeyEvent& key, sclu32 &ret)
     }
 
     ret = 0;
+#ifdef _TV
+    if (g_candidate) {
+        if (!g_candidate->soft_candidate_flag()) {
+            if (g_ui) {
+                if (key.dev_name.compare("ime") != 0) {
+                    ret = (sclu32)g_ui->process_key_event(key.get_key_string().c_str());
+                }
+            }
+        }
+        if (!ret) {
+            ret = g_candidate->soft_candidate_handle_key_event(key.get_key_string().c_str());
+        }
+    } else {
+        if (g_ui) {
+            /* Process this key event if it was not generated by ime */
+            if (key.dev_name.compare("ime") != 0) {
+                ret = (sclu32)g_ui->process_key_event(key.get_key_string().c_str());
+            }
+        }
+    }
+#else
     if (g_ui) {
         /* Process this key event if it was not generated by ime */
         if (key.dev_name.compare("ime") != 0) {
             ret = (sclu32)g_ui->process_key_event(key.get_key_string().c_str());
         }
     }
+#endif
 }
 
 static void init_recent_used_punctuation()