From: Seungho BAEK Date: Fri, 29 Apr 2022 06:48:30 +0000 (+0000) Subject: Merge changes I7b63ee17,I61bd1ed2 into devel/master X-Git-Tag: dali_2.1.21~10 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=bee78157f19fa54ae961081782a2f6537cc8dd5a;hp=3699bd6bb292750152ea1a19f702a641f50c9867 Merge changes I7b63ee17,I61bd1ed2 into devel/master * changes: Use default PBR shader to the scene-loader Fix Scene3d-View light issue --- diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-input-method-context.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-input-method-context.h index d53e02a..deb9a2d 100755 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-input-method-context.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-input-method-context.h @@ -60,12 +60,13 @@ public: */ enum EventType { - VOID, ///< No event - PRE_EDIT, ///< Pre-Edit changed - COMMIT, ///< Commit recieved - DELETE_SURROUNDING, ///< Event to delete a range of characters from the string - GET_SURROUNDING, ///< Event to query string and cursor position - PRIVATE_COMMAND ///< Private command sent from the input panel + VOID, ///< No event + PRE_EDIT, ///< Pre-Edit changed + COMMIT, ///< Commit recieved + DELETE_SURROUNDING, ///< Event to delete a range of characters from the string + GET_SURROUNDING, ///< Event to query string and cursor position + PRIVATE_COMMAND, ///< Private command sent from the input panel + SELECTION_SET ///< input method needs to set the selection }; /** @@ -141,7 +142,9 @@ public: : predictiveString(), eventName( VOID ), cursorOffset( 0 ), - numberOfChars ( 0 ) + numberOfChars ( 0 ), + startIndex ( 0 ), + endIndex ( 0 ) { }; @@ -157,15 +160,36 @@ public: : predictiveString( aPredictiveString ), eventName( aEventName ), cursorOffset( aCursorOffset ), - numberOfChars( aNumberOfChars ) + numberOfChars( aNumberOfChars ), + startIndex ( 0 ), + endIndex ( 0 ) + { + } + + /** + * @brief Constructor + * + * @param[in] aEventName The name of the event from the InputMethodContext. + * @param[in] aStartIndex The start index of selection. + * @param[in] aEndIndex The end index of selection. + */ + EventData(EventType aEventName, int aStartIndex, int aEndIndex) + : predictiveString(), + eventName(aEventName), + cursorOffset(0), + numberOfChars(0), + startIndex(aStartIndex), + endIndex(aEndIndex) { } // Data std::string predictiveString; ///< The pre-edit or commit string. - EventType eventName; ///< The name of the event from the input method context. + EventType eventName; ///< The name of the event from the input method context. int cursorOffset; ///< Start position from the current cursor position to start deleting characters. int numberOfChars; ///< number of characters to delete from the cursorOffset. + int startIndex; ///< The start index of selection. + int endIndex; ///< The end index of selection. }; /** diff --git a/automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp b/automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp index d0bb94b..05ae1c4 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp @@ -2307,4 +2307,47 @@ int UtcDaliKeyboardFocusManagerWithHide(void) END_TEST; +} + +int UtcDaliKeyboardFocusManagerWithVisible(void) +{ + ToolkitTestApplication application; + + tet_infoline(" UtcDaliKeyboardFocusManagerWithVisible"); + + KeyboardFocusManager manager = KeyboardFocusManager::Get(); + DALI_TEST_CHECK(manager); + + // Create the first actor and add it to the stage + Actor first = Actor::New(); + first.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true); + application.GetScene().Add(first); + + // Create the second actor and add it to the first actor. + Actor second = Actor::New(); + second.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true); + first.Add(second); + + // Check that no actor is being focused yet. + DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor()); + + // Check that the focus is set on the first actor + DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true); + DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first); + + // Set visible false. + first.SetProperty(Actor::Property::VISIBLE, false); + + // Check that it will fail to set focus on the second actor as it's not focusable + DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == false); + DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first); + + // Set visible true. + first.SetProperty(Actor::Property::VISIBLE, true); + + // Check that the focus is set on the second actor + DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true); + DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second); + + END_TEST; } \ No newline at end of file diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp index b86f96b..3e8b0de 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp @@ -1599,6 +1599,83 @@ int utcDaliTextFieldTextChangedWithInputMethodContext(void) END_TEST; } +int utcDaliTextFieldSelectionWithInputMethodContext(void) +{ + ToolkitTestApplication application; + tet_infoline(" utcDaliTextFieldSelectionWithInputMethodContext"); + TextField field = TextField::New(); + DALI_TEST_CHECK(field); + + field.SetProperty(TextField::Property::TEXT, "Hello world"); + + application.GetScene().Add(field); + + // connect to the selection changed signal. + ConnectionTracker* testTracker = new ConnectionTracker(); + DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback); + bool selectionChangedSignal = false; + field.ConnectSignal(testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal)); + + // get InputMethodContext + std::string text; + InputMethodContext::EventData imfEvent; + InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field); + + field.SetKeyInputFocus(); + field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true); + + // input text + gSelectionChangedCallbackCalled = false; + imfEvent = InputMethodContext::EventData(InputMethodContext::SELECTION_SET, 1, 4); + inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent); + application.SendNotification(); + application.Render(); + DALI_TEST_CHECK(gSelectionChangedCallbackCalled); + + DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::SELECTED_TEXT_START).Get(), 1, TEST_LOCATION); + DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::SELECTED_TEXT_END).Get(), 4, TEST_LOCATION); + + END_TEST; +} + +int utcDaliTextFieldPositionWithInputMethodContext(void) +{ + ToolkitTestApplication application; + tet_infoline(" utcDaliTextFieldPositionWithInputMethodContext"); + TextField field = TextField::New(); + DALI_TEST_CHECK(field); + + field.SetProperty(TextField::Property::TEXT, "Hello world"); + + application.GetScene().Add(field); + + // connect to the selection changed signal. + ConnectionTracker* testTracker = new ConnectionTracker(); + DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback); + bool cursorPositionChangedSignal = false; + field.ConnectSignal(testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal)); + + // get InputMethodContext + std::string text; + InputMethodContext::EventData imfEvent; + InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field); + + field.SetKeyInputFocus(); + field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true); + + // input text + gCursorPositionChangedCallbackCalled = false; + imfEvent = InputMethodContext::EventData(InputMethodContext::SELECTION_SET, 2, 2); + inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent); + application.SendNotification(); + application.Render(); + DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled); + + DALI_TEST_EQUALS(field.GetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION).Get(), 2, TEST_LOCATION); + + END_TEST; +} + // Negative test for the textChanged signal. int utcDaliTextFieldTextChangedN(void) { 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 a64690e..d0daa9f 100644 --- a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp +++ b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp @@ -205,53 +205,44 @@ bool KeyboardFocusManager::DoSetCurrentFocusActor(Actor actor) { bool success = false; - // If the parent's KEYBOARD_FOCUSABLE_CHILDREN is false, it cannot have focus. - if(actor) + // Check whether the actor is in the stage and is keyboard focusable. + if(actor && + actor.GetProperty(Actor::Property::KEYBOARD_FOCUSABLE) && + actor.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED) && + actor.GetProperty(Actor::Property::CONNECTED_TO_SCENE) && + actor.GetProperty(Actor::Property::VISIBLE)) { + // If the parent's KEYBOARD_FOCUSABLE_CHILDREN is false or VISIBLE is false, it cannot have focus. Actor parent = actor.GetParent(); while(parent) { - if(!parent.GetProperty(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN)) + if(!parent.GetProperty(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN) || !parent.GetProperty(Actor::Property::VISIBLE)) { - DALI_LOG_INFO(gLogFilter, Debug::General, "[%s:%d] Parent Actor has KEYBOARD_FOCUSABLE_CHILDREN false,\n", __FUNCTION__, __LINE__); + DALI_LOG_INFO(gLogFilter, Debug::General, "[%s:%d] Parent Actor has KEYBOARD_FOCUSABLE_CHILDREN false or VISIBLE false,\n", __FUNCTION__, __LINE__); return false; } parent = parent.GetParent(); } - } - if(actor && actor.GetProperty(Actor::Property::KEYBOARD_FOCUSABLE) && actor.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED) && actor.GetProperty(Actor::Property::CONNECTED_TO_SCENE)) - { - Integration::SceneHolder currentWindow = Integration::SceneHolder::Get(actor); + // If developer set focus on same actor, doing nothing + Actor currentFocusedActor = GetCurrentFocusActor(); + if(actor == currentFocusedActor) + { + return true; + } + Integration::SceneHolder currentWindow = Integration::SceneHolder::Get(actor); if(currentWindow.GetRootLayer() != mCurrentFocusedWindow.GetHandle()) { Layer rootLayer = currentWindow.GetRootLayer(); mCurrentFocusedWindow = rootLayer; } - } - - Actor currentFocusedActor = GetCurrentFocusActor(); - - // If developer set focus on same actor, doing nothing - if(actor == currentFocusedActor) - { - if(!actor) - { - return false; - } - return true; - } - // Check whether the actor is in the stage and is keyboard focusable. - if(actor && actor.GetProperty(Actor::Property::KEYBOARD_FOCUSABLE) && actor.GetProperty(DevelActor::Property::USER_INTERACTION_ENABLED) && actor.GetProperty(Actor::Property::CONNECTED_TO_SCENE)) - { if((mIsFocusIndicatorShown == SHOW) && (mEnableFocusIndicator == ENABLE)) { actor.Add(GetFocusIndicatorActor()); } - Toolkit::Control currentlyFocusedControl = Toolkit::Control::DownCast(currentFocusedActor); if(currentlyFocusedControl) { diff --git a/dali-toolkit/internal/text/text-controller-event-handler.cpp b/dali-toolkit/internal/text/text-controller-event-handler.cpp index d5c41a1..1d4be23 100644 --- a/dali-toolkit/internal/text/text-controller-event-handler.cpp +++ b/dali-toolkit/internal/text/text-controller-event-handler.cpp @@ -809,6 +809,21 @@ InputMethodContext::CallbackData Controller::EventHandler::OnInputMethodContextE retrieveCursor = true; break; } + case InputMethodContext::SELECTION_SET: + { + uint32_t start = static_cast(inputMethodContextEvent.startIndex); + uint32_t end = static_cast(inputMethodContextEvent.endIndex); + if(start == end) + { + controller.SetPrimaryCursorPosition(start, true); + } + else + { + controller.SelectText(start, end); + } + + break; + } case InputMethodContext::VOID: { // do nothing