From: Adeel Kazmi Date: Tue, 15 Dec 2015 15:31:55 +0000 (-0800) Subject: Merge "Stop using ImageActor in GaussianBlur, Bloom & SuperBlur" into devel/master X-Git-Tag: dali_1.1.15~5 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=0d8064d02fc1c0a8c343b5a201b91098984ceb88;hp=397218b6cdd85915f5fe00fa9d3615dfa3867422 Merge "Stop using ImageActor in GaussianBlur, Bloom & SuperBlur" into devel/master --- diff --git a/dali-toolkit/internal/controls/popup/popup-impl.cpp b/dali-toolkit/internal/controls/popup/popup-impl.cpp index 66eeca1..4862b1d 100755 --- a/dali-toolkit/internal/controls/popup/popup-impl.cpp +++ b/dali-toolkit/internal/controls/popup/popup-impl.cpp @@ -326,8 +326,6 @@ void Popup::OnInitialize() // Any content after this point which is added to Self() will be re-parented to mContent. mAlterAddedChild = true; - // Make self keyboard focusable and a focus group. - self.SetKeyboardFocusable( true ); SetAsKeyboardFocusGroup( true ); } @@ -719,7 +717,6 @@ void Popup::SetDisplayState( Toolkit::Popup::DisplayState displayState ) // Allow the popup to catch events. mPopupLayout.SetSensitive( true ); - SetKeyInputFocus(); // Handle the keyboard focus when popup is shown. Dali::Toolkit::KeyboardFocusManager keyboardFocusManager = Dali::Toolkit::KeyboardFocusManager::Get(); @@ -727,14 +724,30 @@ void Popup::SetDisplayState( Toolkit::Popup::DisplayState displayState ) { mPreviousFocusedActor = keyboardFocusManager.GetCurrentFocusActor(); - if( mContent && mContent.IsKeyboardFocusable() ) + if( Self().IsKeyboardFocusable() ) { - // If content is focusable, move the focus to content. - keyboardFocusManager.SetCurrentFocusActor( mContent ); - } - else - { - DALI_LOG_WARNING( "There is no focusable in popup\n" ); + // Setup the actgor to start focus from. + Actor focusActor; + if( mContent && mContent.IsKeyboardFocusable() ) + { + // If the content is focusable, move the focus to the content. + focusActor = mContent; + } + else if( mFooter && mFooter.IsKeyboardFocusable() ) + { + // If the footer is focusable, move the focus to the footer. + focusActor = mFooter; + } + else + { + DALI_LOG_WARNING( "There is no focusable in popup\n" ); + } + + if( focusActor ) + { + SetKeyInputFocus(); + keyboardFocusManager.SetCurrentFocusActor( focusActor ); + } } } } @@ -1732,114 +1745,145 @@ bool Popup::OnKeyEvent( const KeyEvent& event ) return consumed; } +void Popup::AddFocusableChildrenRecursive( Actor parent, std::vector< Actor >& focusableActors ) +{ + if( parent ) + { + Toolkit::Control control = Toolkit::Control::DownCast( parent ); + bool layoutControl = control && GetImplementation( control ).IsKeyboardNavigationSupported(); + + if( parent.IsKeyboardFocusable() || layoutControl ) + { + focusableActors.push_back( parent ); + + if( !layoutControl ) + { + for( unsigned int i = 0, numberChildren = parent.GetChildCount(); i < numberChildren; ++i ) + { + Actor child( parent.GetChildAt( i ) ); + AddFocusableChildrenRecursive( child, focusableActors ); + } + } + } + } +} + +void Popup::AddFocusableChildren( Actor parent, std::vector< Actor >& focusableActors ) +{ + if( parent ) + { + Toolkit::Control control = Toolkit::Control::DownCast( parent ); + if( !GetImplementation( control ).IsKeyboardNavigationSupported() ) + { + for( unsigned int i = 0, numberChildren = parent.GetChildCount(); i < numberChildren; ++i ) + { + Actor child( parent.GetChildAt( i ) ); + AddFocusableChildrenRecursive( child, focusableActors ); + } + } + else + { + focusableActors.push_back( parent ); + } + } +} + Actor Popup::GetNextKeyboardFocusableActor( Actor currentFocusedActor, Toolkit::Control::KeyboardFocus::Direction direction, bool loopEnabled ) { + std::string currentStr; + if( currentFocusedActor ) + { + currentStr = currentFocusedActor.GetName(); + } + Actor nextFocusableActor( currentFocusedActor ); + Actor currentFocusGroup; + if( currentFocusedActor ) + { + currentFocusGroup = KeyboardFocusManager::Get().GetFocusGroup( currentFocusedActor ); + } // TODO: Needs to be optimised - if( !currentFocusedActor || ( currentFocusedActor && KeyboardFocusManager::Get().GetFocusGroup( currentFocusedActor ) != Self() ) ) + // The following statement checks that if we have a current focused actor, then the current focus group is not the popup content or footer. + // This is to detect if the focus is currently outside the popup, and if so, move it inside. + if( !currentFocusedActor || + ( currentFocusedActor && ( ( !mContent || ( currentFocusGroup != mContent ) ) && ( !mFooter || ( currentFocusGroup != mFooter ) ) ) ) ) { - // The current focused actor is not within popup + // The current focused actor is not within popup. if( mContent && mContent.IsKeyboardFocusable() ) { - // If content is focusable, move the focus to content + // If the content is focusable, move the focus to the content. nextFocusableActor = mContent; } + else if( mFooter && mFooter.IsKeyboardFocusable() ) + { + // If the footer is focusable, move the focus to the footer. + nextFocusableActor = mFooter; + } } else { // Rebuild the focus chain because controls or content can be added or removed dynamically std::vector< Actor > focusableActors; - if( mContent && mContent.IsKeyboardFocusable() ) + + AddFocusableChildren( mContent, focusableActors ); + AddFocusableChildren( mFooter, focusableActors ); + + std::vector< Actor >::iterator endIterator = focusableActors.end(); + std::vector< Actor >::iterator currentIterator = focusableActors.begin(); + for( std::vector< Actor >::iterator iterator = focusableActors.begin(); iterator != endIterator; ++iterator ) { - focusableActors.push_back( mContent ); + if( currentFocusedActor == *iterator ) + { + currentIterator = iterator; + } } - for( std::vector< Actor >::iterator iter = focusableActors.begin(), end = focusableActors.end(); iter != end; ++iter ) + if( currentIterator != endIterator ) { - if( currentFocusedActor == *iter ) + switch( direction ) { - switch( direction ) + case Toolkit::Control::KeyboardFocus::LEFT: { - case Toolkit::Control::KeyboardFocus::LEFT: + if( currentIterator == focusableActors.begin() ) { - if( iter == focusableActors.begin() ) - { - nextFocusableActor = *( focusableActors.end() - 1 ); - } - else - { - nextFocusableActor = *( iter - 1 ); - } - break; + nextFocusableActor = *( endIterator - 1 ); } - case Toolkit::Control::KeyboardFocus::RIGHT: + else { - if( iter == focusableActors.end() - 1 ) - { - nextFocusableActor = *( focusableActors.begin() ); - } - else - { - nextFocusableActor = *( iter + 1 ); - } - break; + nextFocusableActor = *( currentIterator - 1 ); } - - case Toolkit::Control::KeyboardFocus::UP: + break; + } + case Toolkit::Control::KeyboardFocus::RIGHT: + { + if( currentIterator == endIterator - 1 ) { - if( mContent && *iter == mContent ) - { - nextFocusableActor = *( focusableActors.end() - 1 ); - } - else - { - if( mContent && mContent.IsKeyboardFocusable() ) - { - nextFocusableActor = mContent; - } - else - { - if ( iter == focusableActors.begin() ) - { - nextFocusableActor = *( focusableActors.end() - 1 ); - } - else - { - nextFocusableActor = *( iter - 1 ); - } - } - } - break; + nextFocusableActor = *( focusableActors.begin() ); } - - case Toolkit::Control::KeyboardFocus::DOWN: + else { - if( mContent && mContent.IsKeyboardFocusable() ) - { - nextFocusableActor = mContent; - } - else - { - if( iter == focusableActors.end() - 1 ) - { - nextFocusableActor = *( focusableActors.begin() ); - } - else - { - nextFocusableActor = *( iter + 1 ); - } - } - break; + nextFocusableActor = *( currentIterator + 1 ); } + break; } - if( !nextFocusableActor ) + case Toolkit::Control::KeyboardFocus::UP: { - DALI_LOG_WARNING( "Can not decide next focusable actor\n" ); + nextFocusableActor = *( focusableActors.begin() ); + break; } - break; + case Toolkit::Control::KeyboardFocus::DOWN: + { + nextFocusableActor = *( endIterator - 1 ); + break; + } + } + + if( !nextFocusableActor ) + { + DALI_LOG_WARNING( "Can not decide next focusable actor\n" ); } } } @@ -1847,6 +1891,7 @@ Actor Popup::GetNextKeyboardFocusableActor( Actor currentFocusedActor, Toolkit:: return nextFocusableActor; } + } // namespace Internal } // namespace Toolkit diff --git a/dali-toolkit/internal/controls/popup/popup-impl.h b/dali-toolkit/internal/controls/popup/popup-impl.h index 884cab3..f01d498 100755 --- a/dali-toolkit/internal/controls/popup/popup-impl.h +++ b/dali-toolkit/internal/controls/popup/popup-impl.h @@ -478,6 +478,25 @@ private: private: + /** + * Recursively add any focusable actors or layout containers to the provided vector. + * Include the top level actor if it is a layout container. + * + * @param[in] parent The actor to start from + * @param[in/out] focusableActors The vector to add focusable actors to + */ + void AddFocusableChildren( Actor parent, std::vector< Actor >& focusableActors ); + + /** + * Recursively add any focusable actors or layout containers to the provided vector. + * + * @param[in] parent The actor to start from + * @param[in/out] focusableActors The vector to add focusable actors to + */ + void AddFocusableChildrenRecursive( Actor parent, std::vector< Actor >& focusableActors ); + +private: + // Undefined. Popup(const Popup&); diff --git a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp index d6ff3ab..96d9554 100644 --- a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp +++ b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp @@ -128,7 +128,7 @@ KeyboardFocusManager::~KeyboardFocusManager() { } -bool KeyboardFocusManager::SetCurrentFocusActor(Actor actor) +bool KeyboardFocusManager::SetCurrentFocusActor( Actor actor ) { DALI_ASSERT_DEBUG( !mIsWaitingKeyboardFocusChangeCommit && "Calling this function in the PreFocusChangeSignal callback?" ); @@ -140,41 +140,42 @@ bool KeyboardFocusManager::SetCurrentFocusActor(Actor actor) return false; } -bool KeyboardFocusManager::DoSetCurrentFocusActor(const unsigned int actorID) +bool KeyboardFocusManager::DoSetCurrentFocusActor( const unsigned int actorID ) { Actor rootActor = Stage::GetCurrent().GetRootLayer(); - Actor actor = rootActor.FindChildById(actorID); + Actor actor = rootActor.FindChildById( actorID ); + bool success = false; - // Check whether the actor is in the stage - if(actor) + // Check whether the actor is in the stage and is keyboard focusable. + if( actor && actor.IsKeyboardFocusable() ) { - // Set the focus only when the actor is keyboard focusable - if(actor.IsKeyboardFocusable()) + mIsFocusIndicatorEnabled = true; + // Draw the focus indicator upon the focused actor + if( mFocusIndicatorActor ) { - // Draw the focus indicator upon the focused actor - if(mIsFocusIndicatorEnabled && mFocusIndicatorActor) - { - actor.Add(mFocusIndicatorActor); - } + actor.Add( mFocusIndicatorActor ); + } - // Send notification for the change of focus actor - if( !mFocusChangedSignal.Empty() ) - { - mFocusChangedSignal.Emit(GetCurrentFocusActor(), actor); - } + // Send notification for the change of focus actor + if( !mFocusChangedSignal.Empty() ) + { + mFocusChangedSignal.Emit(GetCurrentFocusActor(), actor); + } - DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] Focus Changed\n", __FUNCTION__, __LINE__); + DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] Focus Changed\n", __FUNCTION__, __LINE__); - // Save the current focused actor - mCurrentFocusActor = actorID; + // Save the current focused actor + mCurrentFocusActor = actorID; - DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] SUCCEED\n", __FUNCTION__, __LINE__); - return true; - } + DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] SUCCEED\n", __FUNCTION__, __LINE__); + success = true; + } + else + { + DALI_LOG_WARNING("[%s:%d] FAILED\n", __FUNCTION__, __LINE__); } - DALI_LOG_WARNING("[%s:%d] FAILED\n", __FUNCTION__, __LINE__); - return false; + return success; } Actor KeyboardFocusManager::GetCurrentFocusActor()