Add a logic to check startpos equality first on focus navigation 56/130456/1
authorJi-hoon Lee <dalton.lee@samsung.com>
Mon, 22 May 2017 09:53:59 +0000 (18:53 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Mon, 22 May 2017 09:54:33 +0000 (18:54 +0900)
The previous logic for checking next-button-to-be-highlighted
when a direction key is pressed, put more emphasis on the length
of overlapping height (in horizontal movement case) when looking
for a possible candidate.
But when an adjacent button has smaller overlapping height value
but has identical ypos, it would be much suitable to choose it
as next highlighted item, than to an item whose overlapping
height is bigger but is in farther location.
So, changed code not to reset candidate_distance_x when the
ypos of current possible candidate is identical to that of
currently highlighted button.

Change-Id: I0d763f42334b76b3ff109cb89c170f9fb62aa1ab

scl/sclkeyfocushandler.cpp

index 405a0b4..c6e842e 100644 (file)
@@ -253,6 +253,7 @@ CSCLKeyFocusHandler::get_next_candidate_key(SCLHighlightNavigationDirection dire
     int candidate = NOT_USED;
     int candidate_distance_x = INT_MAX;
     int candidate_distance_y = INT_MAX;
+    int startpos_identical = FALSE;
 
     int otherside_candidate = NOT_USED;
 
@@ -274,6 +275,7 @@ CSCLKeyFocusHandler::get_next_candidate_key(SCLHighlightNavigationDirection dire
             layout = context->get_popup_layout(window);
         }
     }
+
     if (windows && cache && context &&
         sclres_layout_key_coordinate_pointer_frame && scl_check_arrindex(layout, MAX_SCL_LAYOUT)) {
         for (sclint loop = 0;loop < MAX_KEY; loop++) {
@@ -307,7 +309,10 @@ CSCLKeyFocusHandler::get_next_candidate_key(SCLHighlightNavigationDirection dire
                         if (temp_distance_y <= candidate_distance_y && temp_distance_y < 0) {
                             /* If the button is closer in Y axis, consider this to be the closer regardless of X */
                             if (temp_distance_y < candidate_distance_y) {
-                                candidate_distance_x = INT_MAX;
+                                /* Only if the ypos were not the same */
+                                if (!startpos_identical) {
+                                    candidate_distance_x = INT_MAX;
+                                }
                             }
                             /* Save for otherside */
                             otherside_candidate = loop;
@@ -317,6 +322,7 @@ CSCLKeyFocusHandler::get_next_candidate_key(SCLHighlightNavigationDirection dire
                                     candidate = loop;
                                     candidate_distance_x = temp_distance_x;
                                     candidate_distance_y = temp_distance_y;
+                                    startpos_identical = (btn.y == cur.y);
                                 }
                             }
                         }
@@ -327,7 +333,10 @@ CSCLKeyFocusHandler::get_next_candidate_key(SCLHighlightNavigationDirection dire
                         if (temp_distance_y <= candidate_distance_y && temp_distance_y < 0) {
                             /* If the button is closer in Y axis, consider this to be the closer regardless of X */
                             if (temp_distance_y < candidate_distance_y) {
-                                candidate_distance_x = INT_MAX;
+                                /* Only if the ypos were not the same */
+                                if (!startpos_identical) {
+                                    candidate_distance_x = INT_MAX;
+                                }
                             }
                             /* Save for otherside */
                             if (otherside_candidate == NOT_USED) {
@@ -339,6 +348,7 @@ CSCLKeyFocusHandler::get_next_candidate_key(SCLHighlightNavigationDirection dire
                                     candidate = loop;
                                     candidate_distance_x = temp_distance_x;
                                     candidate_distance_y = temp_distance_y;
+                                    startpos_identical = (btn.y == cur.y);
                                 }
                             }
                         }
@@ -348,7 +358,10 @@ CSCLKeyFocusHandler::get_next_candidate_key(SCLHighlightNavigationDirection dire
                         if (temp_distance_x <= candidate_distance_x) {
                             /* If the button is closer in X axis, consider this to be the closer regardless of Y */
                             if (temp_distance_x < candidate_distance_x) {
-                                candidate_distance_y = INT_MAX;
+                                /* Only if the xpos were not the same */
+                                if (!startpos_identical) {
+                                    candidate_distance_y = INT_MAX;
+                                }
                             }
                             temp_distance_y = calculate_distance(btn.y, btn.y + btn.height, cur.y, cur.y + cur.height);
                             if (temp_distance_y < candidate_distance_y) {
@@ -356,6 +369,7 @@ CSCLKeyFocusHandler::get_next_candidate_key(SCLHighlightNavigationDirection dire
                                     candidate = loop;
                                     candidate_distance_x = temp_distance_x;
                                     candidate_distance_y = temp_distance_y;
+                                    startpos_identical = (btn.x == cur.x);
                                 }
                             }
                         }
@@ -365,7 +379,10 @@ CSCLKeyFocusHandler::get_next_candidate_key(SCLHighlightNavigationDirection dire
                         if (temp_distance_x <= candidate_distance_x) {
                             /* If the button is closer in X axis, consider this to be the closer regardless of Y */
                             if (temp_distance_x < candidate_distance_x) {
-                                candidate_distance_y = INT_MAX;
+                                /* Only if the xpos were not the same */
+                                if (!startpos_identical) {
+                                    candidate_distance_y = INT_MAX;
+                                }
                             }
                             temp_distance_y = calculate_distance(btn.y, btn.y + btn.height, cur.y, cur.y + cur.height);
                             if (temp_distance_y < candidate_distance_y) {
@@ -373,6 +390,7 @@ CSCLKeyFocusHandler::get_next_candidate_key(SCLHighlightNavigationDirection dire
                                     candidate = loop;
                                     candidate_distance_x = temp_distance_x;
                                     candidate_distance_y = temp_distance_y;
+                                    startpos_identical = (btn.x == cur.x);
                                 }
                             }
                         }