X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Fdevel-api%2Ffocus-manager%2Ffocus-finder.cpp;h=2fdf28552bc6fbb697a7f2ab79260a57ae9f0ed3;hb=a5167c61104580ae0ab724f904537a3a01ea3061;hp=313fee9850ee2f3d55bcf16637201172667d1315;hpb=5415aaa17c1f7e9c083957d8c705c8450a8ad84c;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/devel-api/focus-manager/focus-finder.cpp b/dali-toolkit/devel-api/focus-manager/focus-finder.cpp index 313fee9..2fdf285 100644 --- a/dali-toolkit/devel-api/focus-manager/focus-finder.cpp +++ b/dali-toolkit/devel-api/focus-manager/focus-finder.cpp @@ -129,17 +129,15 @@ static int MinorAxisDistance(Dali::Toolkit::Control::KeyboardFocus::Direction di case Dali::Toolkit::Control::KeyboardFocus::RIGHT: { // the distance between the center verticals - return std::abs( - (((source.top + source.bottom) * 0.5f) - - (((dest.top + dest.bottom) * 0.5f)))); + return std::abs((source.top + (source.bottom - source.top) * 0.5f) - + (dest.top + (dest.bottom - dest.top) * 0.5f)); } case Dali::Toolkit::Control::KeyboardFocus::UP: case Dali::Toolkit::Control::KeyboardFocus::DOWN: { // the distance between the center horizontals - return std::abs( - (((source.left + source.right) * 0.5f) - - (((dest.left + dest.right) * 0.5f)))); + return std::abs((source.left + (source.right - source.left) * 0.5f) - + (dest.left + (dest.right - dest.left) * 0.5f)); } default: { @@ -345,21 +343,21 @@ bool IsBetterCandidate(Toolkit::Control::KeyboardFocus::Direction direction, Rec bool IsFocusable(Actor& actor) { return (actor.GetProperty(Actor::Property::KEYBOARD_FOCUSABLE) && + actor.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED) && actor.GetProperty(Actor::Property::VISIBLE) && - actor.GetProperty(Actor::Property::SENSITIVE) && actor.GetProperty(Actor::Property::WORLD_COLOR).a > FULLY_TRANSPARENT); } Actor FindNextFocus(Actor& actor, Actor& focusedActor, Rect& focusedRect, Rect& bestCandidateRect, Toolkit::Control::KeyboardFocus::Direction direction) { Actor nearestActor; - if(actor) + if(actor && actor.GetProperty(Actor::Property::VISIBLE) && actor.GetProperty(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN)) { // Recursively children const auto childCount = actor.GetChildCount(); - for(auto i = 0u; i < childCount; ++i) + for(auto i = childCount; i > 0u; --i) { - Dali::Actor child = actor.GetChildAt(i); + Dali::Actor child = actor.GetChildAt(i-1); if(child && child != focusedActor && IsFocusable(child)) { Rect candidateRect = DevelActor::CalculateScreenExtents(child); @@ -385,15 +383,26 @@ Actor FindNextFocus(Actor& actor, Actor& focusedActor, Rect& focusedRect, } // unnamed namespace -Actor GetNearestFocusableActor(Actor focusedActor, Toolkit::Control::KeyboardFocus::Direction direction) +Actor GetNearestFocusableActor(Actor rootActor, Actor focusedActor, Toolkit::Control::KeyboardFocus::Direction direction) { Actor nearestActor; - if(!focusedActor) + if(!rootActor) { return nearestActor; } - Rect focusedRect = DevelActor::CalculateScreenExtents(focusedActor); + Rect focusedRect; + if (!focusedActor) + { + // If there is no currently focused actor, it is searched based on the upper left corner of the current window. + Rect rootRect = DevelActor::CalculateScreenExtents(rootActor); + focusedRect = Rect(rootRect.x, rootRect.y, 0.f, 0.f); + } + else + { + focusedRect = DevelActor::CalculateScreenExtents(focusedActor); + } + // initialize the best candidate to something impossible // (so the first plausible actor will become the best choice) @@ -429,13 +438,7 @@ Actor GetNearestFocusableActor(Actor focusedActor, Toolkit::Control::KeyboardFoc ConvertCoordinate(bestCandidateRect); ConvertCoordinate(focusedRect); - - Integration::SceneHolder window = Integration::SceneHolder::Get(focusedActor); - if(window) - { - Actor rootActor = window.GetRootLayer(); - nearestActor = FindNextFocus(rootActor, focusedActor, focusedRect, bestCandidateRect, direction); - } + nearestActor = FindNextFocus(rootActor, focusedActor, focusedRect, bestCandidateRect, direction); return nearestActor; }