utc-Dali-Text-Shaping.cpp
utc-Dali-VisualModel.cpp
utc-Dali-Text-Layout.cpp
+ utc-Dali-Text-Controller.cpp
)
# Append list of test harness files (Won't get parsed for test cases)
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <iostream>
+
+#include <stdlib.h>
+#include <limits>
+
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/internal/text/text-controller.h>
+
+using namespace Dali;
+using namespace Toolkit;
+using namespace Text;
+
+namespace
+{
+
+const char* const OPTION_SELECT_WORD("option-select_word"); // "Select Word" popup option.
+const char* const OPTION_SELECT_ALL("option-select_all"); // "Select All" popup option.
+const char* const OPTION_CUT("optionCut"); // "Cut" popup option.
+const char* const OPTION_COPY("optionCopy"); // "Copy" popup option.
+const char* const OPTION_PASTE("optionPaste"); // "Paste" popup option.
+const char* const OPTION_CLIPBOARD("optionClipboard"); // "Clipboard" popup option.
+
+const Size CONTROL_SIZE( 300.f, 60.f );
+
+class ControlImpl : public ControlInterface
+{
+public:
+ ControlImpl()
+ : ControlInterface()
+ {}
+
+ virtual ~ControlImpl()
+ {}
+
+ virtual void AddDecoration( Actor& actor, bool needsClipping )
+ {}
+
+ virtual void RequestTextRelayout()
+ {}
+
+ virtual void TextChanged()
+ {}
+
+ virtual void MaxLengthReached()
+ {}
+
+ virtual void InputStyleChanged( InputStyle::Mask inputStyleMask )
+ {}
+};
+
+std::string gClipboardText;
+void ContentSelectedCallback( ClipboardEventNotifier& notifier )
+{
+ gClipboardText = notifier.GetContent();
+}
+
+} // namespace
+
+int UtcDaliTextController(void)
+{
+ tet_infoline(" UtcDaliTextController");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControlImpl controlImpl;
+ ControllerPtr controller = Controller::New( controlImpl );
+
+ DALI_TEST_CHECK( controller );
+
+ tet_result(TET_PASS);
+ END_TEST;
+}
+
+int UtcDaliTextControllerEnableCursorBlinking(void)
+{
+ tet_infoline(" UtcDaliTextControllerEnableCursorBlinking");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControlImpl controlImpl;
+ ControllerPtr controller = Controller::New( controlImpl );
+
+ DALI_TEST_CHECK( controller );
+
+ // There is no text input enabled.
+ DALI_TEST_CHECK( !controller->GetEnableCursorBlink() );
+
+ // Enable the text input.
+ // Creates a decorator.
+ Text::DecoratorPtr decorator = Text::Decorator::New( *controller,
+ *controller );
+
+ // Enables the text input.
+ controller->EnableTextInput( decorator );
+
+ // Enables the cursor blink.
+ controller->SetEnableCursorBlink( true );
+
+ DALI_TEST_CHECK( controller->GetEnableCursorBlink() );
+
+ // Disables the cursor blink.
+ controller->SetEnableCursorBlink( false );
+
+ DALI_TEST_CHECK( !controller->GetEnableCursorBlink() );
+
+ tet_result(TET_PASS);
+ END_TEST;
+}
+
+int UtcDaliTextControllerImfEvent(void)
+{
+ tet_infoline(" UtcDaliTextController");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControlImpl controlImpl;
+ ControllerPtr controller = Controller::New( controlImpl );
+
+ std::string text;
+ ImfManager::ImfEventData imfEvent;
+
+ DALI_TEST_CHECK( controller );
+
+ // Enable the text input.
+ // Creates a decorator.
+ Text::DecoratorPtr decorator = Text::Decorator::New( *controller,
+ *controller );
+
+ // Enables the text input.
+ controller->EnableTextInput( decorator );
+
+ // Creates an ImfManager.
+ ImfManager imfManager = ImfManager::Get();
+
+ // Send VOID event.
+ imfEvent = ImfManager::ImfEventData( ImfManager::VOID, "", 0, 0 );
+ controller->OnImfEvent( imfManager, imfEvent );
+
+ controller->GetText( text );
+ DALI_TEST_CHECK( text.empty() );
+
+ // Send COMMIT event.
+ imfEvent = ImfManager::ImfEventData( ImfManager::COMMIT, "Hello ", 0, 6 );
+ controller->OnImfEvent( imfManager, imfEvent );
+
+ // Force to update the model.
+ controller->GetNaturalSize();
+
+ controller->GetText( text );
+ DALI_TEST_EQUALS( "Hello ", text, TEST_LOCATION );
+
+ // Send PREEDIT event
+ imfEvent = ImfManager::ImfEventData( ImfManager::PREEDIT, "w", 6, 1 );
+ controller->OnImfEvent( imfManager, imfEvent );
+
+ // Force to update the model.
+ controller->GetNaturalSize();
+
+ controller->GetText( text );
+ DALI_TEST_EQUALS( "Hello w", text, TEST_LOCATION );
+
+ // Send DELETESURROUNDING event
+ imfEvent = ImfManager::ImfEventData( ImfManager::DELETESURROUNDING, "", -1, 1 );
+ controller->OnImfEvent( imfManager, imfEvent );
+
+ // Force to update the model.
+ controller->GetNaturalSize();
+
+ controller->GetText( text );
+ DALI_TEST_EQUALS( "Hello ", text, TEST_LOCATION );
+
+ // Send PREEDIT event
+ imfEvent = ImfManager::ImfEventData( ImfManager::PREEDIT, "wo", 6, 2 );
+ controller->OnImfEvent( imfManager, imfEvent );
+
+ // Force to update the model.
+ controller->GetNaturalSize();
+
+ controller->GetText( text );
+ DALI_TEST_EQUALS( "Hello wo", text, TEST_LOCATION );
+
+ // Send GETSURROUNDING event
+ imfEvent = ImfManager::ImfEventData( ImfManager::GETSURROUNDING, "", 0, 0 );
+ controller->OnImfEvent( imfManager, imfEvent );
+
+ controller->GetText( text );
+ DALI_TEST_EQUALS( "Hello wo", text, TEST_LOCATION );
+
+ tet_result(TET_PASS);
+ END_TEST;
+}
+
+int UtcDaliTextControllerTextPopupButtonTouched(void)
+{
+ tet_infoline(" UtcDaliTextControllerTextPopupButtonTouched");
+ ToolkitTestApplication application;
+
+ // Creates a text controller.
+ ControlImpl controlImpl;
+ ControllerPtr controller = Controller::New( controlImpl );
+
+ DALI_TEST_CHECK( controller );
+
+ std::string text;
+ PushButton button;
+ Property::Map attributes;
+
+ // Enable the text input.
+ // Creates a decorator.
+ Text::DecoratorPtr decorator = Text::Decorator::New( *controller,
+ *controller );
+
+ // Enables the text input.
+ controller->EnableTextInput( decorator );
+
+ // Creates the text's popup.
+ TextSelectionPopupCallbackInterface& callbackInterface = *controller;
+ TextSelectionPopup textPopup = TextSelectionPopup::New( &callbackInterface );
+
+ Toolkit::TextSelectionPopup::Buttons buttonsToEnable = static_cast<Toolkit::TextSelectionPopup::Buttons>( TextSelectionPopup::CUT |
+ TextSelectionPopup::COPY |
+ TextSelectionPopup::PASTE |
+ TextSelectionPopup::SELECT |
+ TextSelectionPopup::SELECT_ALL |
+ TextSelectionPopup::CLIPBOARD );
+
+ textPopup.EnableButtons( buttonsToEnable );
+ Stage::GetCurrent().Add( textPopup );
+ textPopup.ShowPopup();
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Sets some text.
+ controller->SetText( "Hello world" );
+
+ // Select the whole text.
+ button = PushButton::DownCast( textPopup.FindChildByName( OPTION_SELECT_ALL ) );
+ DALI_TEST_CHECK( button );
+
+ button.DoAction( "buttonClick", attributes );
+
+ // Call relayout to process the input events.
+ controller->Relayout( CONTROL_SIZE );
+
+ // Cut the text.
+ button = PushButton::DownCast( textPopup.FindChildByName( OPTION_CUT ) );
+ DALI_TEST_CHECK( button );
+
+ button.DoAction( "buttonClick", attributes );
+
+ // Force to update the model.
+ controller->GetNaturalSize();
+
+ controller->GetText( text );
+ DALI_TEST_CHECK( text.empty() );
+
+ // Set text again.
+ controller->SetText( "Hello world" );
+
+ // Select the whole text.
+ button = PushButton::DownCast( textPopup.FindChildByName( OPTION_SELECT_ALL ) );
+ DALI_TEST_CHECK( button );
+
+ button.DoAction( "buttonClick", attributes );
+
+ // Call relayout to process the input events.
+ controller->Relayout( CONTROL_SIZE );
+
+ // Copy to the clipboard.
+ button = PushButton::DownCast( textPopup.FindChildByName( OPTION_COPY ) );
+ DALI_TEST_CHECK( button );
+
+ button.DoAction( "buttonClick", attributes );
+
+ // Call relayout to process the input events.
+ controller->Relayout( CONTROL_SIZE );
+
+ // Cut the text.
+ button = PushButton::DownCast( textPopup.FindChildByName( OPTION_CUT ) );
+ DALI_TEST_CHECK( button );
+
+ button.DoAction( "buttonClick", attributes );
+
+ // Force to update the model.
+ controller->GetNaturalSize();
+
+ controller->GetText( text );
+ DALI_TEST_CHECK( text.empty() );
+
+ ClipboardEventNotifier clipboardEventNotifier = ClipboardEventNotifier::Get();
+ clipboardEventNotifier.ContentSelectedSignal().Connect( &ContentSelectedCallback );
+
+ // Paste the text.
+ button = PushButton::DownCast( textPopup.FindChildByName( OPTION_PASTE ) );
+ DALI_TEST_CHECK( button );
+
+ button.DoAction( "buttonClick", attributes );
+
+ // Call relayout to process the input events.
+ controller->Relayout( CONTROL_SIZE );
+
+ DALI_TEST_EQUALS( "Hello world", gClipboardText, TEST_LOCATION );
+
+ // Show the clipboard.
+ button = PushButton::DownCast( textPopup.FindChildByName( OPTION_CLIPBOARD ) );
+ DALI_TEST_CHECK( button );
+
+ button.DoAction( "buttonClick", attributes );
+
+ tet_result(TET_PASS);
+ END_TEST;
+}
#include <dali-test-suite-utils.h>
#include "toolkit-test-application.h"
#include "toolkit-application.h"
+#include "toolkit-imf-manager.h"
+#include "toolkit-clipboard-event-notifier.h"
#endif // __DALI_TOOLKIT_TEST_SUITE_UTILS_H__
static bool gObjectCreatedCallBackCalled;
static bool gOnLayoutActivatedCalled; ///< Whether the LayoutActivated signal was invoked.
+static bool gOnScrollUpdateCalled;
static void TestCallback(BaseHandle handle)
{
gOnLayoutActivatedCalled = true;
}
+static void OnScrollUpdate( const Vector2& position )
+{
+ gOnScrollUpdateCalled = true;
+}
+
// Generate a PanGestureEvent to send to Core
Integration::PanGestureEvent GeneratePan(
Gesture::State state,
END_TEST;
}
+
+int UtcDaliItemEnableDisableRefresh(void)
+{
+ ToolkitTestApplication application;
+ Dali::Stage stage = Dali::Stage::GetCurrent();
+
+ // Create the ItemView actor
+ TestItemFactory factory;
+ ItemView view = ItemView::New(factory);
+
+ // Create a grid layout and add it to ItemView
+ ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
+ view.AddLayout(*gridLayout);
+ stage.Add(view);
+
+ // Activate the grid layout so that the items will be created and added to ItemView
+ Vector3 stageSize(stage.GetSize());
+ view.ActivateLayout(0, stageSize, 0.5f);
+
+ //Connect to signal scroll updated
+ view.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
+
+ Property::Map attributes;
+ view.DoAction("enableRefresh", attributes );
+ gOnScrollUpdateCalled = true;
+ view.SetProperty( ItemView::Property::LAYOUT_POSITION, 100.0f );
+ application.SendNotification();
+ application.Render(1000);
+ DALI_TEST_EQUALS( gOnScrollUpdateCalled, true, TEST_LOCATION );
+
+
+ view.DoAction("disableRefresh", attributes );
+ gOnScrollUpdateCalled = false;
+ view.SetProperty( ItemView::Property::LAYOUT_POSITION, 100.0f );
+ application.SendNotification();
+ application.Render(1000);
+
+ DALI_TEST_EQUALS( gOnScrollUpdateCalled, false, TEST_LOCATION );
+
+ END_TEST;
+}
scrollView.ScrollTo( target2, 0.25f, Dali::Toolkit::DirectionBiasLeft, Dali::Toolkit::DirectionBiasLeft );
Wait(application, RENDER_DELAY_SCROLL);
- DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2::ZERO, TEST_LOCATION );
+ DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
scrollView.ScrollTo( target, 0.0f );
Wait(application, RENDER_DELAY_SCROLL);
scrollView.ScrollTo( target2, 0.25f, AlphaFunction::LINEAR, Dali::Toolkit::DirectionBiasLeft, Dali::Toolkit::DirectionBiasLeft );
Wait(application, RENDER_DELAY_SCROLL);
- DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2::ZERO, TEST_LOCATION );
+ DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
scrollView.ScrollTo( target, 0.0f );
Wait(application, RENDER_DELAY_SCROLL);
Property::Map propertyMap;
propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE );
- propertyMap.Insert( PrimitiveVisual::Property::COLOR, color );
+ propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, color );
propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
propertyMap.Insert( PrimitiveVisual::Property::STACKS, 20 );
propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f );
DALI_TEST_CHECK( value );
DALI_TEST_EQUALS( value->Get<int>(), (int)PrimitiveVisual::Shape::CUBE, TEST_LOCATION );
- value = resultMap.Find( PrimitiveVisual::Property::COLOR, Property::VECTOR4 );
+ value = resultMap.Find( PrimitiveVisual::Property::MIX_COLOR, Property::VECTOR4 );
DALI_TEST_CHECK( value );
DALI_TEST_CHECK( value->Get<Vector4>() == color );
DALI_TEST_EQUALS( value->Get<Vector4>(), color, Math::MACHINE_EPSILON_100, TEST_LOCATION );
DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
Renderer renderer = actor.GetRendererAt(0);
- Property::Index index = renderer.GetPropertyIndex( PrimitiveVisual::Property::COLOR );
+ Property::Index index = renderer.GetPropertyIndex( PrimitiveVisual::Property::MIX_COLOR );
// The property isn't registered on the renderer, it's instead registered on the shader.
DALI_TEST_EQUALS( index, Property::INVALID_INDEX, TEST_LOCATION );
Property::Map propertyMap;
propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE );
- propertyMap.Insert( PrimitiveVisual::Property::COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
+ propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
propertyMap.Insert( PrimitiveVisual::Property::STACKS, 20 );
propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f );
Property::Map propertyMap;
propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
- propertyMap.Insert( PrimitiveVisual::Property::COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
+ propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
propertyMap.Insert( PrimitiveVisual::Property::STACKS, 20 );
Property::Map propertyMap;
propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CONICAL_FRUSTRUM );
- propertyMap.Insert( PrimitiveVisual::Property::COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
+ propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f );
propertyMap.Insert( PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, 40.0f );
Property::Map propertyMap;
propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::BEVELLED_CUBE );
- propertyMap.Insert( PrimitiveVisual::Property::COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
+ propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, 0.7f );
//Test to see if shape loads correctly.
Property::Map propertyMap;
propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::OCTAHEDRON );
- propertyMap.Insert( PrimitiveVisual::Property::COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
+ propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
//Test to see if shape loads correctly.
TestPrimitiveVisualWithProperties( propertyMap, application );
Property::Map propertyMap;
propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CONE );
- propertyMap.Insert( PrimitiveVisual::Property::COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
+ propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f );
propertyMap.Insert( PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f );
Property::Map propertyMap;
propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
- propertyMap.Insert( PrimitiveVisual::Property::COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
+ propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3( 0.0, 1.0, 2.0 ) );
//Test to see if shape loads correctly.
END_TEST;
}
+//Test if primitive shape loads correctly when told to use too many slices.
+int UtcDaliVisualFactoryGetPrimitiveVisual9(void)
+{
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
+
+ tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual9: Request primitive visual with above-cap slices." );
+
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
+ propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
+ propertyMap.Insert( PrimitiveVisual::Property::SLICES, Property::Value( 1000000 ) );
+
+ //Test to see if shape loads correctly.
+ TestPrimitiveVisualWithProperties( propertyMap, application );
+
+ END_TEST;
+}
+
+//Test if primitive shape loads correctly when told to use too few slices. (2 slices or less.)
+int UtcDaliVisualFactoryGetPrimitiveVisual10(void)
+{
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
+
+ tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual10: Request primitive visual with too few slices." );
+
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
+ propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
+ propertyMap.Insert( PrimitiveVisual::Property::SLICES, Property::Value( 2 ) );
+
+ //Test to see if shape loads correctly.
+ TestPrimitiveVisualWithProperties( propertyMap, application );
+
+ END_TEST;
+}
+
+//Test if primitive shape loads correctly when told to use too many stacks.
+int UtcDaliVisualFactoryGetPrimitiveVisual11(void)
+{
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
+
+ tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual11: Request primitive visual with too many stacks." );
+
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
+ propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
+ propertyMap.Insert( PrimitiveVisual::Property::STACKS, Property::Value( 1000000 ) );
+
+ //Test to see if shape loads correctly.
+ TestPrimitiveVisualWithProperties( propertyMap, application );
+
+ END_TEST;
+}
+
+//Test if primitive shape loads correctly when told to use too few stacks. (1 stack or less.)
+int UtcDaliVisualFactoryGetPrimitiveVisual12(void)
+{
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
+
+ tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual12: Request primitive visual with too few stacks." );
+
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
+ propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
+ propertyMap.Insert( PrimitiveVisual::Property::STACKS, Property::Value( 1 ) );
+
+ //Test to see if shape loads correctly.
+ TestPrimitiveVisualWithProperties( propertyMap, application );
+
+ END_TEST;
+}
+
+//Test if primitive shape loads correctly when told to use invalid (zero or negative) dimensions.
+int UtcDaliVisualFactoryGetPrimitiveVisual13(void)
+{
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
+
+ tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual13: Request primitive visual with invalid scale dimensions." );
+
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
+ propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
+ propertyMap.Insert( PrimitiveVisual::Property::SCALE_DIMENSIONS, Vector3::ZERO );
+
+ //Test to see if shape loads correctly.
+ TestPrimitiveVisualWithProperties( propertyMap, application );
+
+ END_TEST;
+}
+
+//Test if primitive shape loads correctly when told to use too low a bevel percentage.
+int UtcDaliVisualFactoryGetPrimitiveVisual14(void)
+{
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
+
+ tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual14: Request primitive visual with too low a bevel percentage." );
+
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
+ propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
+ propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, Property::Value( -1.0f ) );
+
+ //Test to see if shape loads correctly.
+ TestPrimitiveVisualWithProperties( propertyMap, application );
+
+ END_TEST;
+}
+
+//Test if primitive shape loads correctly when told to use too high a bevel percentage.
+int UtcDaliVisualFactoryGetPrimitiveVisual15(void)
+{
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
+
+ tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual15: Request primitive visual with too high a bevel percentage." );
+
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
+ propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
+ propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, Property::Value( 2.0f ) );
+
+ //Test to see if shape loads correctly.
+ TestPrimitiveVisualWithProperties( propertyMap, application );
+
+ END_TEST;
+}
+
+//Test if primitive shape loads correctly when told to use too low a bevel smoothness.
+int UtcDaliVisualFactoryGetPrimitiveVisual16(void)
+{
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
+
+ tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual16: Request primitive visual with too low a bevel smoothness." );
+
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
+ propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
+ propertyMap.Insert( PrimitiveVisual::Property::BEVEL_SMOOTHNESS, Property::Value( -1.0f ) );
+
+ //Test to see if shape loads correctly.
+ TestPrimitiveVisualWithProperties( propertyMap, application );
+
+ END_TEST;
+}
+
+//Test if primitive shape loads correctly when told to use too high a bevel smoothness.
+int UtcDaliVisualFactoryGetPrimitiveVisual17(void)
+{
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
+
+ tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual17: Request primitive visual with too high a bevel smoothness." );
+
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert( Visual::Property::TYPE, Visual::PRIMITIVE );
+ propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
+ propertyMap.Insert( PrimitiveVisual::Property::BEVEL_SMOOTHNESS, Property::Value( 2.0f ) );
+
+ //Test to see if shape loads correctly.
+ TestPrimitiveVisualWithProperties( propertyMap, application );
+
+ END_TEST;
+}
+
//Test if primitive shape visual handles the case of not being passed a specific shape to use.
int UtcDaliVisualFactoryGetPrimitiveVisualN1(void)
{
ALIASES += SINCE_1_1="@since 1.1"
ALIASES += SINCE_1_2="@since 1.2"
+# Extra tags for Tizen 3.0
+ALIASES += SINCE_1_2_2="@since 1.2.2"
+ALIASES += SINCE_1_2_4="@since 1.2.4"
+
ALIASES += DEPRECATED_1_0="@deprecated Deprecated since 1.0"
ALIASES += DEPRECATED_1_1="@deprecated Deprecated since 1.1"
ALIASES += DEPRECATED_1_2="@deprecated Deprecated since 1.2"
ALIASES += PLATFORM=""
ALIASES += PRIVLEVEL_PLATFORM=""
+ALIASES += PRIVLEVEL_PUBLIC=""
ALIASES += PRIVILEGE_KEYGRAB=""
+ALIASES += PRIVILEGE_DISPLAY=""
+ALIASES += REMARK_INTERNET=""
############################################
## For Tizen Native API Reference
#ALIASES += SINCE_1_0="\par Since:\n 2.4, DALi version 1.0"
#ALIASES += SINCE_1_1="\par Since:\n 3.0, DALi version 1.1"
+#ALIASES += SINCE_1_2="\par Since:\n 4.0, DALi version 1.2"
+
+## Extra tags for Tizen 3.0
+#ALIASES += SINCE_1_2_2="\par Since:\n 3.0, DALi version 1.2.2"
+#ALIASES += SINCE_1_2_4="\par Since:\n 3.0, DALi version 1.2.4"
## DALi has no deprecated API in Tizen 2.4 because it's DALi's first release.
## Thus deprecated APIs in DALi 1.0.xx will be deprecated in Tizen 3.0.
#ALIASES += DEPRECATED_1_0="@deprecated Deprecated since 3.0, DALi version 1.0"
#ALIASES += DEPRECATED_1_1="@deprecated Deprecated since 3.0, DALi version 1.1"
+#ALIASES += DEPRECATED_1_2="@deprecated Deprecated since 4.0, DALi version 1.2"
#ALIASES += PLATFORM="@platform"
#ALIASES += PRIVLEVEL_PLATFORM="\par Privilege Level:\n platform"
+#ALIASES += PRIVLEVEL_PUBLIC="\par Privilege Level:\n public"
#ALIASES += PRIVILEGE_KEYGRAB="\par Privilege:\n http://tizen.org/privilege/keygrab"
+#ALIASES += PRIVILEGE_DISPLAY="\par Privilege:\n http://tizen.org/privilege/display"
+#ALIASES += REMARK_INTERNET="@remarks %http://tizen.org/privilege/internet is needed if @a url is a http or https address."
# This tag can be used to specify a number of word-keyword mappings (TCL only).
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// EXTERNAL INCLUDES
#include <cstring>
+#include <algorithm>
// INTERNAL INCLUDES
#include "dali-toolkit/devel-api/builder/tree-node.h"
#include "dali-toolkit/internal/builder/tree-node-manipulator.h"
+namespace
+{
+
+bool CaseInsensitiveCharacterCompare( unsigned char a, unsigned char b )
+{
+ // Converts to lower case in the current locale.
+ return std::tolower( a ) == std::tolower( b );
+}
+
+/**
+ * return true if the lower cased ASCII strings are equal.
+ */
+bool CaseInsensitiveStringCompare( const std::string& a, const std::string& b )
+{
+ bool result = false;
+ if( a.length() == b.length() )
+ {
+ result = std::equal( a.begin(), a.end(), b.begin(), CaseInsensitiveCharacterCompare );
+ }
+ return result;
+}
+
+} // anonymous namespace
+
+
namespace Dali
{
return mIntValue == 1 ? true : false;
}
-
size_t TreeNode::Size() const
{
size_t c = 0;
return NULL;
}
+
+const TreeNode* TreeNode::GetChildIgnoreCase(const std::string& childName) const
+{
+ const TreeNode* p = mFirstChild;
+ while(p)
+ {
+ if(p->mName)
+ {
+ std::string nodeName(p->mName);
+ if( CaseInsensitiveStringCompare( nodeName, childName) )
+ {
+ return p;
+ }
+ }
+ p = p->mNextSibling;
+ }
+ return NULL;
+}
+
const TreeNode* TreeNode::Find(const std::string& childName) const
{
if(mName && std::string(mName) == childName)
#define __DALI_SCRIPT_TREE_NODE_H__
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
bool HasSubstitution() const;
/*
- * Gets a child of the node
- * @param name The name of the child
+ * Gets a child of the node (using case sensitive matching)
+ * @param name The name of the child.
* @return The child if found, else NULL
*/
const TreeNode* GetChild(const std::string& name) const;
/*
+ * Gets a child of the node (using case insensitive matching)
+ * @param name The name of the child in lower case
+ * @return The child if found, else NULL
+ */
+ const TreeNode* GetChildIgnoreCase(const std::string& name) const;
+
+ /*
* Recursively search for a child of the node
* @param name The name of the child
* @return The child if found, else NULL
#define __DALI_TOOLKIT_INTERNAL_BUILDER_GET_IS_INL__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
}
+inline OptionalChild IsChildIgnoreCase(const TreeNode* node, const std::string& childName)
+{
+ if( node )
+ {
+ const TreeNode* c = node->GetChildIgnoreCase(childName);
+ if( NULL != c )
+ {
+ return OptionalChild( *c );
+ }
+ else
+ {
+ return OptionalChild();
+ }
+ }
+ else
+ {
+ return OptionalChild();
+ }
+}
+
inline OptionalChild IsChild(const TreeNode& node, const std::string& childName)
{
return IsChild(&node, childName);
}
+inline OptionalChild IsChildIgnoreCase(const TreeNode& node, const std::string& childName)
+{
+ return IsChildIgnoreCase(&node, childName);
+}
+
inline OptionalString IsString(const OptionalChild& node)
{
if( node && (*node).GetType() == TreeNode::STRING )
{
if( OptionalString styleName = IsString( (*iter).second ) )
{
- if( OptionalChild node = IsChild( stylesCollection, *styleName) )
+ if( OptionalChild node = IsChildIgnoreCase( stylesCollection, *styleName) )
{
styleList.push_back( &(*node) );
DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Builder script not loaded");
OptionalChild styles = IsChild( *mParser.GetRoot(), KEYNAME_STYLES );
- OptionalChild style = IsChild( *styles, styleName );
+
+ std::string styleNameLower(styleName);
+ OptionalChild style = IsChildIgnoreCase( *styles, styleNameLower );
if( styles && style )
{
DALI_ACTION_REGISTRATION( Toolkit, ItemView, "stopScrolling", ACTION_STOP_SCROLLING )
+DALI_ACTION_REGISTRATION( Toolkit, ItemView, "enableRefresh", ACTION_ENABLE_REFRESH )
+DALI_ACTION_REGISTRATION( Toolkit, ItemView, "disableRefresh", ACTION_DISABLE_REFRESH )
+
DALI_TYPE_REGISTRATION_END()
bool FindById( const ItemContainer& items, ItemId id )
mIsFlicking(false),
mAddingItems(false),
mRefreshEnabled(true),
+ mRefreshNotificationEnabled(true),
mInAnimation(false)
{
}
void ItemView::OnRefreshNotification(PropertyNotification& source)
{
- // Cancel scroll animation to prevent any fighting of setting the scroll position property by scroll bar during fast scroll.
- if(!mRefreshEnabled && mScrollAnimation)
+ if( mRefreshNotificationEnabled )
{
- RemoveAnimation(mScrollAnimation);
- }
+ // Cancel scroll animation to prevent any fighting of setting the scroll position property by scroll bar during fast scroll.
+ if(!mRefreshEnabled && mScrollAnimation)
+ {
+ RemoveAnimation(mScrollAnimation);
+ }
- // Only cache extra items when it is not a fast scroll
- DoRefresh(GetCurrentLayoutPosition(0), mRefreshEnabled || mScrollAnimation);
+ // Only cache extra items when it is not a fast scroll
+ DoRefresh(GetCurrentLayoutPosition(0), mRefreshEnabled || mScrollAnimation);
+ }
}
void ItemView::Refresh()
{
GetImpl( itemView ).DoStopScrolling();
}
+ else if ( 0 == strcmp( actionName.c_str(), ACTION_ENABLE_REFRESH ) )
+ {
+ GetImpl( itemView ).SetRefreshNotificationEnabled( true );
+ }
+ else if ( 0 == strcmp( actionName.c_str(), ACTION_DISABLE_REFRESH ) )
+ {
+ GetImpl( itemView ).SetRefreshNotificationEnabled( false );
+ }
return true;
}
}
}
+void ItemView::SetRefreshNotificationEnabled( bool enabled )
+{
+ mRefreshNotificationEnabled = enabled;
+}
+
} // namespace Internal
} // namespace Toolkit
*/
void DoStopScrolling();
+ /**
+ * Helper for DoAction( ACTION_ENABLE/DISABLE_REFRESH_NOTIFICATIONS ).
+ * @param[in] enabled Whether to disable refresh notifications or not.
+ */
+ void SetRefreshNotificationEnabled( bool enabled );
+
private:
/**
bool mIsFlicking : 1;
bool mAddingItems : 1;
bool mRefreshEnabled : 1; ///< Whether to refresh the cache automatically
+ bool mRefreshNotificationEnabled : 1; ///< Whether to disable refresh notifications or not.
bool mInAnimation : 1; ///< Keeps track of whether an animation is controlling the overshoot property.
};
// Position Delta ///////////////////////////////////////////////////////
if(positionChanged)
{
+ UpdateMainInternalConstraint();
if(mWrapMode && findShortcuts)
{
// In Wrap Mode, the shortest distance is a little less intuitive...
const std::string text = value.Get< std::string >();
DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT %s\n", impl.mController.Get(), text.c_str() );
- impl.mController->SetPlaceholderText( PLACEHOLDER_TYPE_INACTIVE, text );
+ impl.mController->SetPlaceholderText( Controller::PLACEHOLDER_TYPE_INACTIVE, text );
}
break;
}
const std::string text = value.Get< std::string >();
DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p PLACEHOLDER_TEXT_FOCUSED %s\n", impl.mController.Get(), text.c_str() );
- impl.mController->SetPlaceholderText( PLACEHOLDER_TYPE_ACTIVE, text );
+ impl.mController->SetPlaceholderText( Controller::PLACEHOLDER_TYPE_ACTIVE, text );
}
break;
}
if( impl.mController )
{
std::string text;
- impl.mController->GetPlaceholderText( PLACEHOLDER_TYPE_INACTIVE, text );
+ impl.mController->GetPlaceholderText( Controller::PLACEHOLDER_TYPE_INACTIVE, text );
value = text;
}
break;
if( impl.mController )
{
std::string text;
- impl.mController->GetPlaceholderText( PLACEHOLDER_TYPE_ACTIVE, text );
+ impl.mController->GetPlaceholderText( Controller::PLACEHOLDER_TYPE_ACTIVE, text );
value = text;
}
break;
// todo Move this to adaptor??
#define GET_LOCALE_TEXT(string) dgettext("dali-toolkit", string)
-const std::string TEXT_SELECTION_POPUP_BUTTON_STYLE_NAME( "textselectionpopupbutton" );
+const std::string TEXT_SELECTION_POPUP_BUTTON_STYLE_NAME( "TextSelectionPopupButton" );
const Dali::Vector4 DEFAULT_OPTION_PRESSED_COLOR( Dali::Vector4( 0.24f, 0.72f, 0.8f, 1.0f ) );
#if defined(DEBUG_ENABLED)
} // namespace Toolkit
} // namespace Dali
-
-
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
const char* LANDSCAPE_QUALIFIER = "landscape";
const char* PORTRAIT_QUALIFIER = "portrait";
-const char* FONT_SIZE_QUALIFIER = "FontSize";
+const char* FONT_SIZE_QUALIFIER = "fontsize";
const char* DEFAULT_THEME = DALI_STYLE_DIR "dali-toolkit-default-theme.json";
if( styleName.empty() )
{
- // Convert control name to lower case
styleName = control.GetTypeName();
- std::transform( styleName.begin(), styleName.end(), styleName.begin(), ::tolower );
}
// Apply the style after choosing the correct actual style (e.g. landscape or portrait)
return fontDescriptionRun;
}
+// public : Constructor.
+
ControllerPtr Controller::New( ControlInterface& controlInterface )
{
return ControllerPtr( new Controller( controlInterface ) );
}
+// public : Configure the text controller.
+
void Controller::EnableTextInput( DecoratorPtr decorator )
{
if( NULL == mImpl->mEventData )
return false;
}
+void Controller::SetMaximumNumberOfCharacters( Length maxCharacters )
+{
+ mImpl->mMaximumNumberOfCharacters = maxCharacters;
+}
+
+int Controller::GetMaximumNumberOfCharacters()
+{
+ return mImpl->mMaximumNumberOfCharacters;
+}
+
+void Controller::SetEnableCursorBlink( bool enable )
+{
+ DALI_ASSERT_DEBUG( NULL != mImpl->mEventData && "TextInput disabled" );
+
+ if( NULL != mImpl->mEventData )
+ {
+ mImpl->mEventData->mCursorBlinkEnabled = enable;
+
+ if( !enable &&
+ mImpl->mEventData->mDecorator )
+ {
+ mImpl->mEventData->mDecorator->StopCursorBlink();
+ }
+ }
+}
+
+bool Controller::GetEnableCursorBlink() const
+{
+ if( NULL != mImpl->mEventData )
+ {
+ return mImpl->mEventData->mCursorBlinkEnabled;
+ }
+
+ return false;
+}
+
+void Controller::SetMultiLineEnabled( bool enable )
+{
+ const LayoutEngine::Layout layout = enable ? LayoutEngine::MULTI_LINE_BOX : LayoutEngine::SINGLE_LINE_BOX;
+
+ if( layout != mImpl->mLayoutEngine.GetLayout() )
+ {
+ // Set the layout type.
+ mImpl->mLayoutEngine.SetLayout( layout );
+
+ // Set the flags to redo the layout operations
+ const OperationsMask layoutOperations = static_cast<OperationsMask>( LAYOUT |
+ UPDATE_LAYOUT_SIZE |
+ ALIGN |
+ REORDER );
+
+ mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | layoutOperations );
+
+ mImpl->RequestRelayout();
+ }
+}
+
+bool Controller::IsMultiLineEnabled() const
+{
+ return LayoutEngine::MULTI_LINE_BOX == mImpl->mLayoutEngine.GetLayout();
+}
+
+void Controller::SetHorizontalAlignment( LayoutEngine::HorizontalAlignment alignment )
+{
+ if( alignment != mImpl->mLayoutEngine.GetHorizontalAlignment() )
+ {
+ // Set the alignment.
+ mImpl->mLayoutEngine.SetHorizontalAlignment( alignment );
+
+ // Set the flag to redo the alignment operation.
+ mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | ALIGN );
+
+ mImpl->RequestRelayout();
+ }
+}
+
+LayoutEngine::HorizontalAlignment Controller::GetHorizontalAlignment() const
+{
+ return mImpl->mLayoutEngine.GetHorizontalAlignment();
+}
+
+void Controller::SetVerticalAlignment( LayoutEngine::VerticalAlignment alignment )
+{
+ if( alignment != mImpl->mLayoutEngine.GetVerticalAlignment() )
+ {
+ // Set the alignment.
+ mImpl->mLayoutEngine.SetVerticalAlignment( alignment );
+
+ mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | ALIGN );
+
+ mImpl->RequestRelayout();
+ }
+}
+
+LayoutEngine::VerticalAlignment Controller::GetVerticalAlignment() const
+{
+ return mImpl->mLayoutEngine.GetVerticalAlignment();
+}
+
+// public : Update
+
void Controller::SetText( const std::string& text )
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::SetText\n" );
}
}
-void Controller::SetMaximumNumberOfCharacters( Length maxCharacters )
+void Controller::UpdateAfterFontChange( const std::string& newDefaultFont )
{
- mImpl->mMaximumNumberOfCharacters = maxCharacters;
-}
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::UpdateAfterFontChange\n");
-int Controller::GetMaximumNumberOfCharacters()
-{
- return mImpl->mMaximumNumberOfCharacters;
+ if( !mImpl->mFontDefaults->familyDefined ) // If user defined font then should not update when system font changes
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::Concise, "Controller::UpdateAfterFontChange newDefaultFont(%s)\n", newDefaultFont.c_str() );
+ mImpl->mFontDefaults->mFontDescription.family = newDefaultFont;
+
+ ClearFontData();
+
+ mImpl->RequestRelayout();
+ }
}
+// public : Default style & Input style
+
void Controller::SetDefaultFontFamily( const std::string& defaultFontFamily )
{
if( NULL == mImpl->mFontDefaults )
return 0.0f;
}
-void Controller::UpdateAfterFontChange( const std::string& newDefaultFont )
-{
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::UpdateAfterFontChange\n");
-
- if( !mImpl->mFontDefaults->familyDefined ) // If user defined font then should not update when system font changes
- {
- DALI_LOG_INFO( gLogFilter, Debug::Concise, "Controller::UpdateAfterFontChange newDefaultFont(%s)\n", newDefaultFont.c_str() );
- mImpl->mFontDefaults->mFontDescription.family = newDefaultFont;
-
- ClearFontData();
-
- mImpl->RequestRelayout();
- }
-}
-
void Controller::SetTextColor( const Vector4& textColor )
{
mImpl->mTextColor = textColor;
return mImpl->mTextColor;
}
-bool Controller::RemoveText( int cursorOffset,
- int numberOfCharacters,
- UpdateInputStyleType type )
-{
- bool removed = false;
-
- if( NULL == mImpl->mEventData )
- {
- return removed;
- }
-
- DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::RemoveText %p mText.Count() %d cursor %d cursorOffset %d numberOfCharacters %d\n",
- this, mImpl->mLogicalModel->mText.Count(), mImpl->mEventData->mPrimaryCursorPosition, cursorOffset, numberOfCharacters );
-
- if( !mImpl->IsShowingPlaceholderText() )
- {
- // Delete at current cursor position
- Vector<Character>& currentText = mImpl->mLogicalModel->mText;
- CharacterIndex& oldCursorIndex = mImpl->mEventData->mPrimaryCursorPosition;
-
- CharacterIndex cursorIndex = oldCursorIndex;
-
- // Validate the cursor position & number of characters
- if( static_cast< CharacterIndex >( std::abs( cursorOffset ) ) <= cursorIndex )
- {
- cursorIndex = oldCursorIndex + cursorOffset;
- }
-
- if( ( cursorIndex + numberOfCharacters ) > currentText.Count() )
- {
- numberOfCharacters = currentText.Count() - cursorIndex;
- }
-
- if( ( cursorIndex + numberOfCharacters ) <= mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters )
- {
- // Mark the paragraphs to be updated.
- mImpl->mTextUpdateInfo.mCharacterIndex = std::min( cursorIndex, mImpl->mTextUpdateInfo.mCharacterIndex );
- mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove += numberOfCharacters;
-
- // Update the input style and remove the text's style before removing the text.
-
- if( UPDATE_INPUT_STYLE == type )
- {
- // Keep a copy of the current input style.
- InputStyle currentInputStyle;
- currentInputStyle.Copy( mImpl->mEventData->mInputStyle );
-
- // Set first the default input style.
- mImpl->RetrieveDefaultInputStyle( mImpl->mEventData->mInputStyle );
-
- // Update the input style.
- mImpl->mLogicalModel->RetrieveStyle( cursorIndex, mImpl->mEventData->mInputStyle );
-
- // Compare if the input style has changed.
- const bool hasInputStyleChanged = !currentInputStyle.Equal( mImpl->mEventData->mInputStyle );
-
- if( hasInputStyleChanged )
- {
- const InputStyle::Mask styleChangedMask = currentInputStyle.GetInputStyleChangeMask( mImpl->mEventData->mInputStyle );
- // Queue the input style changed signal.
- mImpl->mEventData->mInputStyleChangedQueue.PushBack( styleChangedMask );
- }
- }
-
- // Updates the text style runs by removing characters. Runs with no characters are removed.
- mImpl->mLogicalModel->UpdateTextStyleRuns( cursorIndex, -numberOfCharacters );
-
- // Remove the characters.
- Vector<Character>::Iterator first = currentText.Begin() + cursorIndex;
- Vector<Character>::Iterator last = first + numberOfCharacters;
-
- currentText.Erase( first, last );
-
- // Cursor position retreat
- oldCursorIndex = cursorIndex;
-
- mImpl->mEventData->mScrollAfterDelete = true;
-
- DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::RemoveText %p removed %d\n", this, numberOfCharacters );
- removed = true;
- }
- }
-
- return removed;
-}
-
void Controller::SetPlaceholderTextColor( const Vector4& textColor )
{
if( NULL != mImpl->mEventData )
return GetDefaultOutlineProperties();
}
-void Controller::SetEnableCursorBlink( bool enable )
-{
- DALI_ASSERT_DEBUG( NULL != mImpl->mEventData && "TextInput disabled" );
-
- if( NULL != mImpl->mEventData )
- {
- mImpl->mEventData->mCursorBlinkEnabled = enable;
+// public : Queries & retrieves.
- if( !enable &&
- mImpl->mEventData->mDecorator )
- {
- mImpl->mEventData->mDecorator->StopCursorBlink();
- }
- }
+LayoutEngine& Controller::GetLayoutEngine()
+{
+ return mImpl->mLayoutEngine;
}
-bool Controller::GetEnableCursorBlink() const
+View& Controller::GetView()
{
- if( NULL != mImpl->mEventData )
- {
- return mImpl->mEventData->mCursorBlinkEnabled;
- }
-
- return false;
+ return mImpl->mView;
}
const Vector2& Controller::GetScrollPosition() const
return layoutSize.height;
}
+// public : Relayout.
+
Controller::UpdateTextType Controller::Relayout( const Size& size )
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::Relayout %p size %f,%f, autoScroll[%s]\n", this, size.width, size.height, (mImpl->mAutoScrollEnabled)?"true":"false" );
return updateTextType;
}
-void Controller::ProcessModifyEvents()
+// public : Input style change signals.
+
+bool Controller::IsInputStyleChangedSignalsQueueEmpty()
{
- Vector<ModifyEvent>& events = mImpl->mModifyEvents;
-
- if( 0u == events.Count() )
- {
- // Nothing to do.
- return;
- }
-
- for( Vector<ModifyEvent>::ConstIterator it = events.Begin(),
- endIt = events.End();
- it != endIt;
- ++it )
- {
- const ModifyEvent& event = *it;
-
- if( ModifyEvent::TEXT_REPLACED == event.type )
- {
- // A (single) replace event should come first, otherwise we wasted time processing NOOP events
- DALI_ASSERT_DEBUG( it == events.Begin() && "Unexpected TEXT_REPLACED event" );
-
- TextReplacedEvent();
- }
- else if( ModifyEvent::TEXT_INSERTED == event.type )
- {
- TextInsertedEvent();
- }
- else if( ModifyEvent::TEXT_DELETED == event.type )
- {
- // Placeholder-text cannot be deleted
- if( !mImpl->IsShowingPlaceholderText() )
- {
- TextDeletedEvent();
- }
- }
- }
-
- if( NULL != mImpl->mEventData )
- {
- // When the text is being modified, delay cursor blinking
- mImpl->mEventData->mDecorator->DelayCursorBlink();
- }
-
- // Discard temporary text
- events.Clear();
-}
-
-bool Controller::IsInputStyleChangedSignalsQueueEmpty()
-{
- return ( NULL == mImpl->mEventData ) || ( 0u == mImpl->mEventData->mInputStyleChangedQueue.Count() );
-}
+ return ( NULL == mImpl->mEventData ) || ( 0u == mImpl->mEventData->mInputStyleChangedQueue.Count() );
+}
void Controller::ProcessInputStyleChangedSignals()
{
mImpl->mEventData->mInputStyleChangedQueue.Clear();
}
-void Controller::ResetText()
-{
- // Reset buffers.
- mImpl->mLogicalModel->mText.Clear();
-
- // We have cleared everything including the placeholder-text
- mImpl->PlaceholderCleared();
-
- mImpl->mTextUpdateInfo.mCharacterIndex = 0u;
- mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
- mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = 0u;
-
- // Clear any previous text.
- mImpl->mTextUpdateInfo.mClearAll = true;
-
- // The natural size needs to be re-calculated.
- mImpl->mRecalculateNaturalSize = true;
-
- // Apply modifications to the model
- mImpl->mOperationsPending = ALL_OPERATIONS;
-}
+// public : Text-input Event Queuing.
-void Controller::ResetCursorPosition( CharacterIndex cursorIndex )
+void Controller::KeyboardFocusGainEvent()
{
- // Reset the cursor position
+ DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected KeyboardFocusGainEvent" );
+
if( NULL != mImpl->mEventData )
{
- mImpl->mEventData->mPrimaryCursorPosition = cursorIndex;
-
- // Update the cursor if it's in editing mode.
- if( EventData::IsEditingState( mImpl->mEventData->mState ) )
+ if( ( EventData::INACTIVE == mImpl->mEventData->mState ) ||
+ ( EventData::INTERRUPTED == mImpl->mEventData->mState ) )
{
- mImpl->mEventData->mUpdateCursorPosition = true;
+ mImpl->ChangeState( EventData::EDITING );
+ mImpl->mEventData->mUpdateCursorPosition = true; //If editing started without tap event, cursor update must be triggered.
+ }
+ mImpl->NotifyImfMultiLineStatus();
+ if( mImpl->IsShowingPlaceholderText() )
+ {
+ // Show alternative placeholder-text when editing
+ ShowPlaceholderText();
}
+
+ mImpl->RequestRelayout();
}
}
-void Controller::ResetScrollPosition()
+void Controller::KeyboardFocusLostEvent()
{
+ DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected KeyboardFocusLostEvent" );
+
if( NULL != mImpl->mEventData )
{
- // Reset the scroll position.
- mImpl->mScrollPosition = Vector2::ZERO;
- mImpl->mEventData->mScrollAfterUpdatePosition = true;
+ if( EventData::INTERRUPTED != mImpl->mEventData->mState )
+ {
+ mImpl->ChangeState( EventData::INACTIVE );
+
+ if( !mImpl->IsShowingRealText() )
+ {
+ // Revert to regular placeholder-text when not editing
+ ShowPlaceholderText();
+ }
+ }
}
+ mImpl->RequestRelayout();
}
-void Controller::TextReplacedEvent()
+bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent )
{
- // The natural size needs to be re-calculated.
- mImpl->mRecalculateNaturalSize = true;
-
- // Apply modifications to the model
- mImpl->mOperationsPending = ALL_OPERATIONS;
-}
+ DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected KeyEvent" );
-void Controller::TextInsertedEvent()
-{
- DALI_ASSERT_DEBUG( NULL != mImpl->mEventData && "Unexpected TextInsertedEvent" );
+ bool textChanged( false );
- if( NULL == mImpl->mEventData )
+ if( ( NULL != mImpl->mEventData ) &&
+ ( keyEvent.state == KeyEvent::Down ) )
{
- return;
- }
+ int keyCode = keyEvent.keyCode;
+ const std::string& keyString = keyEvent.keyPressed;
- // The natural size needs to be re-calculated.
- mImpl->mRecalculateNaturalSize = true;
+ // Pre-process to separate modifying events from non-modifying input events.
+ if( Dali::DALI_KEY_ESCAPE == keyCode )
+ {
+ // Escape key is a special case which causes focus loss
+ KeyboardFocusLostEvent();
+ }
+ else if( ( Dali::DALI_KEY_CURSOR_LEFT == keyCode ) ||
+ ( Dali::DALI_KEY_CURSOR_RIGHT == keyCode ) ||
+ ( Dali::DALI_KEY_CURSOR_UP == keyCode ) ||
+ ( Dali::DALI_KEY_CURSOR_DOWN == keyCode ) )
+ {
+ Event event( Event::CURSOR_KEY_EVENT );
+ event.p1.mInt = keyCode;
+ mImpl->mEventData->mEventQueue.push_back( event );
+ }
+ else if( Dali::DALI_KEY_BACKSPACE == keyCode )
+ {
+ textChanged = BackspaceKeyEvent();
+ }
+ else if( IsKey( keyEvent, Dali::DALI_KEY_POWER ) )
+ {
+ mImpl->ChangeState( EventData::INTERRUPTED ); // State is not INACTIVE as expect to return to edit mode.
+ // Avoids calling the InsertText() method which can delete selected text
+ }
+ else if( IsKey( keyEvent, Dali::DALI_KEY_MENU ) ||
+ IsKey( keyEvent, Dali::DALI_KEY_HOME ) )
+ {
+ mImpl->ChangeState( EventData::INACTIVE );
+ // Menu/Home key behaviour does not allow edit mode to resume like Power key
+ // Avoids calling the InsertText() method which can delete selected text
+ }
+ else if( Dali::DALI_KEY_SHIFT_LEFT == keyCode )
+ {
+ // DALI_KEY_SHIFT_LEFT is the key code for the Left Shift. It's sent (by the imf?) when the predictive text is enabled
+ // and a character is typed after the type of a upper case latin character.
- // Apply modifications to the model; TODO - Optimize this
- mImpl->mOperationsPending = ALL_OPERATIONS;
-}
+ // Do nothing.
+ }
+ else
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::KeyEvent %p keyString %s\n", this, keyString.c_str() );
-void Controller::TextDeletedEvent()
-{
- DALI_ASSERT_DEBUG( NULL != mImpl->mEventData && "Unexpected TextDeletedEvent" );
+ // IMF manager is no longer handling key-events
+ mImpl->ClearPreEditFlag();
- if( NULL == mImpl->mEventData )
- {
- return;
+ InsertText( keyString, COMMIT );
+ textChanged = true;
+ }
+
+ if ( ( mImpl->mEventData->mState != EventData::INTERRUPTED ) &&
+ ( mImpl->mEventData->mState != EventData::INACTIVE ) &&
+ ( Dali::DALI_KEY_SHIFT_LEFT != keyCode ) )
+ {
+ // Should not change the state if the key is the shift send by the imf manager.
+ // Otherwise, when the state is SELECTING the text controller can't send the right
+ // surrounding info to the imf.
+ mImpl->ChangeState( EventData::EDITING );
+ }
+
+ mImpl->RequestRelayout();
}
- // The natural size needs to be re-calculated.
- mImpl->mRecalculateNaturalSize = true;
+ if( textChanged )
+ {
+ // Do this last since it provides callbacks into application code
+ mImpl->mControlInterface.TextChanged();
+ }
- // Apply modifications to the model; TODO - Optimize this
- mImpl->mOperationsPending = ALL_OPERATIONS;
+ return true;
}
-bool Controller::DoRelayout( const Size& size,
- OperationsMask operationsRequired,
- Size& layoutSize )
+void Controller::TapEvent( unsigned int tapCount, float x, float y )
{
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::DoRelayout %p size %f,%f\n", this, size.width, size.height );
- bool viewUpdated( false );
-
- // Calculate the operations to be done.
- const OperationsMask operations = static_cast<OperationsMask>( mImpl->mOperationsPending & operationsRequired );
-
- const CharacterIndex startIndex = mImpl->mTextUpdateInfo.mParagraphCharacterIndex;
- const Length requestedNumberOfCharacters = mImpl->mTextUpdateInfo.mRequestedNumberOfCharacters;
-
- // Get the current layout size.
- layoutSize = mImpl->mVisualModel->GetLayoutSize();
+ DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected TapEvent" );
- if( NO_OPERATION != ( LAYOUT & operations ) )
+ if( NULL != mImpl->mEventData )
{
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::DoRelayout LAYOUT & operations\n");
-
- // Some vectors with data needed to layout and reorder may be void
- // after the first time the text has been laid out.
- // Fill the vectors again.
-
- // Calculate the number of glyphs to layout.
- const Vector<GlyphIndex>& charactersToGlyph = mImpl->mVisualModel->mCharactersToGlyph;
- const Vector<Length>& glyphsPerCharacter = mImpl->mVisualModel->mGlyphsPerCharacter;
- const GlyphIndex* const charactersToGlyphBuffer = charactersToGlyph.Begin();
- const Length* const glyphsPerCharacterBuffer = glyphsPerCharacter.Begin();
-
- const CharacterIndex lastIndex = startIndex + ( ( requestedNumberOfCharacters > 0u ) ? requestedNumberOfCharacters - 1u : 0u );
- const GlyphIndex startGlyphIndex = mImpl->mTextUpdateInfo.mStartGlyphIndex;
- const Length numberOfGlyphs = ( requestedNumberOfCharacters > 0u ) ? *( charactersToGlyphBuffer + lastIndex ) + *( glyphsPerCharacterBuffer + lastIndex ) - startGlyphIndex : 0u;
- const Length totalNumberOfGlyphs = mImpl->mVisualModel->mGlyphs.Count();
+ DALI_LOG_INFO( gLogFilter, Debug::Concise, "TapEvent state:%d \n", mImpl->mEventData->mState );
+ EventData::State state( mImpl->mEventData->mState );
+ bool relayoutNeeded( false ); // to avoid unnecessary relayouts when tapping an empty text-field
- if( 0u == totalNumberOfGlyphs )
+ if( mImpl->IsClipboardVisible() )
{
- if( NO_OPERATION != ( UPDATE_LAYOUT_SIZE & operations ) )
+ if( EventData::INACTIVE == state || EventData::EDITING == state)
{
- mImpl->mVisualModel->SetLayoutSize( Size::ZERO );
+ mImpl->ChangeState( EventData::EDITING_WITH_GRAB_HANDLE );
}
-
- // Nothing else to do if there is no glyphs.
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::DoRelayout no glyphs, view updated true\n" );
- return true;
+ relayoutNeeded = true;
}
-
- const Vector<LineBreakInfo>& lineBreakInfo = mImpl->mLogicalModel->mLineBreakInfo;
- const Vector<WordBreakInfo>& wordBreakInfo = mImpl->mLogicalModel->mWordBreakInfo;
- const Vector<CharacterDirection>& characterDirection = mImpl->mLogicalModel->mCharacterDirections;
- const Vector<GlyphInfo>& glyphs = mImpl->mVisualModel->mGlyphs;
- const Vector<CharacterIndex>& glyphsToCharactersMap = mImpl->mVisualModel->mGlyphsToCharacters;
- const Vector<Length>& charactersPerGlyph = mImpl->mVisualModel->mCharactersPerGlyph;
- const Character* const textBuffer = mImpl->mLogicalModel->mText.Begin();
-
- // Set the layout parameters.
- LayoutParameters layoutParameters( size,
- textBuffer,
- lineBreakInfo.Begin(),
- wordBreakInfo.Begin(),
- ( 0u != characterDirection.Count() ) ? characterDirection.Begin() : NULL,
- glyphs.Begin(),
- glyphsToCharactersMap.Begin(),
- charactersPerGlyph.Begin(),
- charactersToGlyphBuffer,
- glyphsPerCharacterBuffer,
- totalNumberOfGlyphs );
-
- // Resize the vector of positions to have the same size than the vector of glyphs.
- Vector<Vector2>& glyphPositions = mImpl->mVisualModel->mGlyphPositions;
- glyphPositions.Resize( totalNumberOfGlyphs );
-
- // Whether the last character is a new paragraph character.
- mImpl->mTextUpdateInfo.mIsLastCharacterNewParagraph = TextAbstraction::IsNewParagraph( *( textBuffer + ( mImpl->mLogicalModel->mText.Count() - 1u ) ) );
- layoutParameters.isLastNewParagraph = mImpl->mTextUpdateInfo.mIsLastCharacterNewParagraph;
-
- // The initial glyph and the number of glyphs to layout.
- layoutParameters.startGlyphIndex = startGlyphIndex;
- layoutParameters.numberOfGlyphs = numberOfGlyphs;
- layoutParameters.startLineIndex = mImpl->mTextUpdateInfo.mStartLineIndex;
- layoutParameters.estimatedNumberOfLines = mImpl->mTextUpdateInfo.mEstimatedNumberOfLines;
-
- // Update the visual model.
- Size newLayoutSize;
- viewUpdated = mImpl->mLayoutEngine.LayoutText( layoutParameters,
- glyphPositions,
- mImpl->mVisualModel->mLines,
- newLayoutSize );
-
- viewUpdated = viewUpdated || ( newLayoutSize != layoutSize );
-
- if( viewUpdated )
+ else if( 1u == tapCount )
{
- layoutSize = newLayoutSize;
-
- if ( NO_OPERATION != ( UPDATE_DIRECTION & operations ) )
+ if( EventData::EDITING_WITH_POPUP == state || EventData::EDITING_WITH_PASTE_POPUP == state )
{
- mImpl->mAutoScrollDirectionRTL = false;
+ mImpl->ChangeState( EventData::EDITING_WITH_GRAB_HANDLE ); // If Popup shown hide it here so can be shown again if required.
}
- // Reorder the lines
- if( NO_OPERATION != ( REORDER & operations ) )
+ if( mImpl->IsShowingRealText() && ( EventData::INACTIVE != state ) )
{
- Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo = mImpl->mLogicalModel->mBidirectionalParagraphInfo;
- Vector<BidirectionalLineInfoRun>& bidirectionalLineInfo = mImpl->mLogicalModel->mBidirectionalLineInfo;
-
- // Check first if there are paragraphs with bidirectional info.
- if( 0u != bidirectionalInfo.Count() )
+ mImpl->ChangeState( EventData::EDITING_WITH_GRAB_HANDLE );
+ relayoutNeeded = true;
+ }
+ else
+ {
+ if( mImpl->IsShowingPlaceholderText() && !mImpl->IsFocusedPlaceholderAvailable() )
{
- // Get the lines
- const Length numberOfLines = mImpl->mVisualModel->mLines.Count();
-
- // Reorder the lines.
- bidirectionalLineInfo.Reserve( numberOfLines ); // Reserve because is not known yet how many lines have right to left characters.
- ReorderLines( bidirectionalInfo,
- startIndex,
- requestedNumberOfCharacters,
- mImpl->mVisualModel->mLines,
- bidirectionalLineInfo );
-
- // Set the bidirectional info per line into the layout parameters.
- layoutParameters.lineBidirectionalInfoRunsBuffer = bidirectionalLineInfo.Begin();
- layoutParameters.numberOfBidirectionalInfoRuns = bidirectionalLineInfo.Count();
-
- // Re-layout the text. Reorder those lines with right to left characters.
- mImpl->mLayoutEngine.ReLayoutRightToLeftLines( layoutParameters,
- startIndex,
- requestedNumberOfCharacters,
- glyphPositions );
-
- if ( ( NO_OPERATION != ( UPDATE_DIRECTION & operations ) ) && ( numberOfLines > 0 ) )
- {
- const LineRun* const firstline = mImpl->mVisualModel->mLines.Begin();
- if ( firstline )
- {
- mImpl->mAutoScrollDirectionRTL = firstline->direction;
- }
- }
+ // Hide placeholder text
+ ResetText();
}
- } // REORDER
- // Sets the layout size.
- if( NO_OPERATION != ( UPDATE_LAYOUT_SIZE & operations ) )
+ if( EventData::INACTIVE == state )
+ {
+ mImpl->ChangeState( EventData::EDITING );
+ }
+ else if( !mImpl->IsClipboardEmpty() )
+ {
+ mImpl->ChangeState( EventData::EDITING_WITH_POPUP );
+ }
+ relayoutNeeded = true;
+ }
+ }
+ else if( 2u == tapCount )
+ {
+ if( mImpl->mEventData->mSelectionEnabled &&
+ mImpl->IsShowingRealText() )
{
- mImpl->mVisualModel->SetLayoutSize( layoutSize );
+ SelectEvent( x, y, false );
}
- } // view updated
+ }
+ // Handles & cursors must be repositioned after Relayout() i.e. after the Model has been updated
+ if( relayoutNeeded )
+ {
+ Event event( Event::TAP_EVENT );
+ event.p1.mUint = tapCount;
+ event.p2.mFloat = x;
+ event.p3.mFloat = y;
+ mImpl->mEventData->mEventQueue.push_back( event );
- // Store the size used to layout the text.
- mImpl->mVisualModel->mControlSize = size;
+ mImpl->RequestRelayout();
+ }
}
- if( NO_OPERATION != ( ALIGN & operations ) )
- {
- // The laid-out lines.
- Vector<LineRun>& lines = mImpl->mVisualModel->mLines;
-
- mImpl->mLayoutEngine.Align( size,
- startIndex,
- requestedNumberOfCharacters,
- lines );
-
- viewUpdated = true;
- }
-#if defined(DEBUG_ENABLED)
- std::string currentText;
- GetText( currentText );
- DALI_LOG_INFO( gLogFilter, Debug::Concise, "Controller::DoRelayout [%p] mImpl->mAutoScrollDirectionRTL[%s] [%s]\n", this, (mImpl->mAutoScrollDirectionRTL)?"true":"false", currentText.c_str() );
-#endif
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::DoRelayout, view updated %s\n", ( viewUpdated ? "true" : "false" ) );
- return viewUpdated;
+ // Reset keyboard as tap event has occurred.
+ mImpl->ResetImfManager();
}
-void Controller::SetMultiLineEnabled( bool enable )
+void Controller::PanEvent( Gesture::State state, const Vector2& displacement )
{
- const LayoutEngine::Layout layout = enable ? LayoutEngine::MULTI_LINE_BOX : LayoutEngine::SINGLE_LINE_BOX;
+ DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected PanEvent" );
- if( layout != mImpl->mLayoutEngine.GetLayout() )
+ if( NULL != mImpl->mEventData )
{
- // Set the layout type.
- mImpl->mLayoutEngine.SetLayout( layout );
-
- // Set the flags to redo the layout operations
- const OperationsMask layoutOperations = static_cast<OperationsMask>( LAYOUT |
- UPDATE_LAYOUT_SIZE |
- ALIGN |
- REORDER );
-
- mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | layoutOperations );
+ Event event( Event::PAN_EVENT );
+ event.p1.mInt = state;
+ event.p2.mFloat = displacement.x;
+ event.p3.mFloat = displacement.y;
+ mImpl->mEventData->mEventQueue.push_back( event );
mImpl->RequestRelayout();
}
}
-bool Controller::IsMultiLineEnabled() const
+void Controller::LongPressEvent( Gesture::State state, float x, float y )
{
- return LayoutEngine::MULTI_LINE_BOX == mImpl->mLayoutEngine.GetLayout();
-}
+ DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected LongPressEvent" );
-void Controller::SetHorizontalAlignment( LayoutEngine::HorizontalAlignment alignment )
-{
- if( alignment != mImpl->mLayoutEngine.GetHorizontalAlignment() )
+ if( ( state == Gesture::Started ) &&
+ ( NULL != mImpl->mEventData ) )
{
- // Set the alignment.
- mImpl->mLayoutEngine.SetHorizontalAlignment( alignment );
-
- // Set the flag to redo the alignment operation.
- mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | ALIGN );
-
- mImpl->RequestRelayout();
- }
-}
-
-LayoutEngine::HorizontalAlignment Controller::GetHorizontalAlignment() const
-{
- return mImpl->mLayoutEngine.GetHorizontalAlignment();
-}
+ if( !mImpl->IsShowingRealText() )
+ {
+ Event event( Event::LONG_PRESS_EVENT );
+ event.p1.mInt = state;
+ mImpl->mEventData->mEventQueue.push_back( event );
+ mImpl->RequestRelayout();
+ }
+ else
+ {
+ // The 1st long-press on inactive text-field is treated as tap
+ if( EventData::INACTIVE == mImpl->mEventData->mState )
+ {
+ mImpl->ChangeState( EventData::EDITING );
-void Controller::SetVerticalAlignment( LayoutEngine::VerticalAlignment alignment )
-{
- if( alignment != mImpl->mLayoutEngine.GetVerticalAlignment() )
- {
- // Set the alignment.
- mImpl->mLayoutEngine.SetVerticalAlignment( alignment );
+ Event event( Event::TAP_EVENT );
+ event.p1.mUint = 1;
+ event.p2.mFloat = x;
+ event.p3.mFloat = y;
+ mImpl->mEventData->mEventQueue.push_back( event );
- mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | ALIGN );
+ mImpl->RequestRelayout();
+ }
+ else if( !mImpl->IsClipboardVisible() )
+ {
+ // Reset the imf manger to commit the pre-edit before selecting the text.
+ mImpl->ResetImfManager();
- mImpl->RequestRelayout();
+ SelectEvent( x, y, false );
+ }
+ }
}
}
-LayoutEngine::VerticalAlignment Controller::GetVerticalAlignment() const
-{
- return mImpl->mLayoutEngine.GetVerticalAlignment();
-}
-
-void Controller::CalculateVerticalOffset( const Size& controlSize )
+ImfManager::ImfCallbackData Controller::OnImfEvent( ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent )
{
- Size layoutSize = mImpl->mVisualModel->GetLayoutSize();
+ // Whether the text needs to be relaid-out.
+ bool requestRelayout = false;
- if( fabsf( layoutSize.height ) < Math::MACHINE_EPSILON_1000 )
- {
- // Get the line height of the default font.
- layoutSize.height = mImpl->GetDefaultFontLineHeight();
- }
+ // Whether to retrieve the text and cursor position to be sent to the IMF manager.
+ bool retrieveText = false;
+ bool retrieveCursor = false;
- switch( mImpl->mLayoutEngine.GetVerticalAlignment() )
+ switch( imfEvent.eventName )
{
- case LayoutEngine::VERTICAL_ALIGN_TOP:
+ case ImfManager::COMMIT:
{
- mImpl->mScrollPosition.y = 0.f;
+ InsertText( imfEvent.predictiveString, Text::Controller::COMMIT );
+ requestRelayout = true;
+ retrieveCursor = true;
break;
}
- case LayoutEngine::VERTICAL_ALIGN_CENTER:
+ case ImfManager::PREEDIT:
{
- mImpl->mScrollPosition.y = floorf( 0.5f * ( controlSize.height - layoutSize.height ) ); // try to avoid pixel alignment.
+ InsertText( imfEvent.predictiveString, Text::Controller::PRE_EDIT );
+ requestRelayout = true;
+ retrieveCursor = true;
break;
}
- case LayoutEngine::VERTICAL_ALIGN_BOTTOM:
+ case ImfManager::DELETESURROUNDING:
{
- mImpl->mScrollPosition.y = controlSize.height - layoutSize.height;
+ const bool textDeleted = RemoveText( imfEvent.cursorOffset,
+ imfEvent.numberOfChars,
+ DONT_UPDATE_INPUT_STYLE );
+
+ if( textDeleted )
+ {
+ if( ( 0u != mImpl->mLogicalModel->mText.Count() ) ||
+ !mImpl->IsPlaceholderAvailable() )
+ {
+ mImpl->QueueModifyEvent( ModifyEvent::TEXT_DELETED );
+ }
+ else
+ {
+ ShowPlaceholderText();
+ }
+ mImpl->mEventData->mUpdateCursorPosition = true;
+ mImpl->mEventData->mScrollAfterDelete = true;
+
+ requestRelayout = true;
+ }
+ break;
+ }
+ case ImfManager::GETSURROUNDING:
+ {
+ retrieveText = true;
+ retrieveCursor = true;
+ break;
+ }
+ case ImfManager::VOID:
+ {
+ // do nothing
break;
}
+ } // end switch
+
+ if( requestRelayout )
+ {
+ mImpl->mOperationsPending = ALL_OPERATIONS;
+ mImpl->RequestRelayout();
+ }
+
+ std::string text;
+ CharacterIndex cursorPosition = 0u;
+ Length numberOfWhiteSpaces = 0u;
+
+ if( retrieveCursor )
+ {
+ numberOfWhiteSpaces = mImpl->GetNumberOfWhiteSpaces( 0u );
+
+ cursorPosition = mImpl->GetLogicalCursorPosition();
+
+ if( cursorPosition < numberOfWhiteSpaces )
+ {
+ cursorPosition = 0u;
+ }
+ else
+ {
+ cursorPosition -= numberOfWhiteSpaces;
+ }
+ }
+
+ if( retrieveText )
+ {
+ mImpl->GetText( numberOfWhiteSpaces, text );
+ }
+
+ ImfManager::ImfCallbackData callbackData( ( retrieveText || retrieveCursor ), cursorPosition, text, false );
+
+ if( requestRelayout )
+ {
+ // Do this last since it provides callbacks into application code
+ mImpl->mControlInterface.TextChanged();
}
+
+ return callbackData;
}
-LayoutEngine& Controller::GetLayoutEngine()
+void Controller::PasteClipboardItemEvent()
{
- return mImpl->mLayoutEngine;
+ // Retrieve the clipboard contents first
+ ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() );
+ std::string stringToPaste( notifier.GetContent() );
+
+ // Commit the current pre-edit text; the contents of the clipboard should be appended
+ mImpl->ResetImfManager();
+
+ // Temporary disable hiding clipboard
+ mImpl->SetClipboardHideEnable( false );
+
+ // Paste
+ PasteText( stringToPaste );
+
+ mImpl->SetClipboardHideEnable( true );
}
-View& Controller::GetView()
+// protected : Inherit from Text::Decorator::ControllerInterface.
+
+void Controller::GetTargetSize( Vector2& targetSize )
{
- return mImpl->mView;
+ targetSize = mImpl->mVisualModel->mControlSize;
}
-void Controller::KeyboardFocusGainEvent()
+void Controller::AddDecoration( Actor& actor, bool needsClipping )
{
- DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected KeyboardFocusGainEvent" );
+ mImpl->mControlInterface.AddDecoration( actor, needsClipping );
+}
+
+void Controller::DecorationEvent( HandleType handleType, HandleState state, float x, float y )
+{
+ DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected DecorationEvent" );
if( NULL != mImpl->mEventData )
{
- if( ( EventData::INACTIVE == mImpl->mEventData->mState ) ||
- ( EventData::INTERRUPTED == mImpl->mEventData->mState ) )
- {
- mImpl->ChangeState( EventData::EDITING );
- mImpl->mEventData->mUpdateCursorPosition = true; //If editing started without tap event, cursor update must be triggered.
- }
- mImpl->NotifyImfMultiLineStatus();
- if( mImpl->IsShowingPlaceholderText() )
+ switch( handleType )
{
- // Show alternative placeholder-text when editing
- ShowPlaceholderText();
+ case GRAB_HANDLE:
+ {
+ Event event( Event::GRAB_HANDLE_EVENT );
+ event.p1.mUint = state;
+ event.p2.mFloat = x;
+ event.p3.mFloat = y;
+
+ mImpl->mEventData->mEventQueue.push_back( event );
+ break;
+ }
+ case LEFT_SELECTION_HANDLE:
+ {
+ Event event( Event::LEFT_SELECTION_HANDLE_EVENT );
+ event.p1.mUint = state;
+ event.p2.mFloat = x;
+ event.p3.mFloat = y;
+
+ mImpl->mEventData->mEventQueue.push_back( event );
+ break;
+ }
+ case RIGHT_SELECTION_HANDLE:
+ {
+ Event event( Event::RIGHT_SELECTION_HANDLE_EVENT );
+ event.p1.mUint = state;
+ event.p2.mFloat = x;
+ event.p3.mFloat = y;
+
+ mImpl->mEventData->mEventQueue.push_back( event );
+ break;
+ }
+ case LEFT_SELECTION_HANDLE_MARKER:
+ case RIGHT_SELECTION_HANDLE_MARKER:
+ {
+ // Markers do not move the handles.
+ break;
+ }
+ case HANDLE_TYPE_COUNT:
+ {
+ DALI_ASSERT_DEBUG( !"Controller::HandleEvent. Unexpected handle type" );
+ }
}
mImpl->RequestRelayout();
}
}
-void Controller::KeyboardFocusLostEvent()
+// protected : Inherit from TextSelectionPopup::TextPopupButtonCallbackInterface.
+
+void Controller::TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Buttons button )
{
- DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected KeyboardFocusLostEvent" );
+ if( NULL == mImpl->mEventData )
+ {
+ return;
+ }
- if( NULL != mImpl->mEventData )
+ switch( button )
{
- if( EventData::INTERRUPTED != mImpl->mEventData->mState )
+ case Toolkit::TextSelectionPopup::CUT:
{
- mImpl->ChangeState( EventData::INACTIVE );
+ mImpl->SendSelectionToClipboard( true ); // Synchronous call to modify text
+ mImpl->mOperationsPending = ALL_OPERATIONS;
- if( !mImpl->IsShowingRealText() )
+ if( ( 0u != mImpl->mLogicalModel->mText.Count() ) ||
+ !mImpl->IsPlaceholderAvailable() )
+ {
+ mImpl->QueueModifyEvent( ModifyEvent::TEXT_DELETED );
+ }
+ else
{
- // Revert to regular placeholder-text when not editing
ShowPlaceholderText();
}
- }
- }
- mImpl->RequestRelayout();
-}
-bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent )
-{
- DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected KeyEvent" );
+ mImpl->mEventData->mUpdateCursorPosition = true;
+ mImpl->mEventData->mScrollAfterDelete = true;
- bool textChanged( false );
+ mImpl->RequestRelayout();
+ mImpl->mControlInterface.TextChanged();
+ break;
+ }
+ case Toolkit::TextSelectionPopup::COPY:
+ {
+ mImpl->SendSelectionToClipboard( false ); // Text not modified
- if( ( NULL != mImpl->mEventData ) &&
- ( keyEvent.state == KeyEvent::Down ) )
- {
- int keyCode = keyEvent.keyCode;
- const std::string& keyString = keyEvent.keyPressed;
+ mImpl->mEventData->mUpdateCursorPosition = true;
- // Pre-process to separate modifying events from non-modifying input events.
- if( Dali::DALI_KEY_ESCAPE == keyCode )
- {
- // Escape key is a special case which causes focus loss
- KeyboardFocusLostEvent();
+ mImpl->RequestRelayout(); // Cursor, Handles, Selection Highlight, Popup
+ break;
}
- else if( ( Dali::DALI_KEY_CURSOR_LEFT == keyCode ) ||
- ( Dali::DALI_KEY_CURSOR_RIGHT == keyCode ) ||
- ( Dali::DALI_KEY_CURSOR_UP == keyCode ) ||
- ( Dali::DALI_KEY_CURSOR_DOWN == keyCode ) )
+ case Toolkit::TextSelectionPopup::PASTE:
{
- Event event( Event::CURSOR_KEY_EVENT );
- event.p1.mInt = keyCode;
- mImpl->mEventData->mEventQueue.push_back( event );
+ mImpl->RequestGetTextFromClipboard(); // Request clipboard service to retrieve an item
+ break;
}
- else if( Dali::DALI_KEY_BACKSPACE == keyCode )
+ case Toolkit::TextSelectionPopup::SELECT:
{
- textChanged = BackspaceKeyEvent();
+ const Vector2& currentCursorPosition = mImpl->mEventData->mDecorator->GetPosition( PRIMARY_CURSOR );
+
+ if( mImpl->mEventData->mSelectionEnabled )
+ {
+ // Creates a SELECT event.
+ SelectEvent( currentCursorPosition.x, currentCursorPosition.y, false );
+ }
+ break;
}
- else if( IsKey( keyEvent, Dali::DALI_KEY_POWER ) )
+ case Toolkit::TextSelectionPopup::SELECT_ALL:
{
- mImpl->ChangeState( EventData::INTERRUPTED ); // State is not INACTIVE as expect to return to edit mode.
- // Avoids calling the InsertText() method which can delete selected text
+ // Creates a SELECT_ALL event
+ SelectEvent( 0.f, 0.f, true );
+ break;
}
- else if( IsKey( keyEvent, Dali::DALI_KEY_MENU ) ||
- IsKey( keyEvent, Dali::DALI_KEY_HOME ) )
+ case Toolkit::TextSelectionPopup::CLIPBOARD:
{
- mImpl->ChangeState( EventData::INACTIVE );
- // Menu/Home key behaviour does not allow edit mode to resume like Power key
- // Avoids calling the InsertText() method which can delete selected text
+ mImpl->ShowClipboard();
+ break;
}
- else if( Dali::DALI_KEY_SHIFT_LEFT == keyCode )
+ case Toolkit::TextSelectionPopup::NONE:
{
- // DALI_KEY_SHIFT_LEFT is the key code for the Left Shift. It's sent (by the imf?) when the predictive text is enabled
- // and a character is typed after the type of a upper case latin character.
-
- // Do nothing.
- }
- else
- {
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::KeyEvent %p keyString %s\n", this, keyString.c_str() );
-
- // IMF manager is no longer handling key-events
- mImpl->ClearPreEditFlag();
-
- InsertText( keyString, COMMIT );
- textChanged = true;
- }
-
- if ( ( mImpl->mEventData->mState != EventData::INTERRUPTED ) &&
- ( mImpl->mEventData->mState != EventData::INACTIVE ) &&
- ( Dali::DALI_KEY_SHIFT_LEFT != keyCode ) )
- {
- // Should not change the state if the key is the shift send by the imf manager.
- // Otherwise, when the state is SELECTING the text controller can't send the right
- // surrounding info to the imf.
- mImpl->ChangeState( EventData::EDITING );
+ // Nothing to do.
+ break;
}
-
- mImpl->RequestRelayout();
- }
-
- if( textChanged )
- {
- // Do this last since it provides callbacks into application code
- mImpl->mControlInterface.TextChanged();
}
-
- return true;
}
+// private : Update.
+
void Controller::InsertText( const std::string& text, Controller::InsertType type )
{
bool removedPrevious( false );
}
}
-bool Controller::RemoveSelectedText()
+void Controller::PasteText( const std::string& stringToPaste )
{
- bool textRemoved( false );
-
- if( EventData::SELECTING == mImpl->mEventData->mState )
- {
- std::string removedString;
- mImpl->RetrieveSelection( removedString, true );
-
- if( !removedString.empty() )
- {
- textRemoved = true;
- mImpl->ChangeState( EventData::EDITING );
- }
- }
+ InsertText( stringToPaste, Text::Controller::COMMIT );
+ mImpl->ChangeState( EventData::EDITING );
+ mImpl->RequestRelayout();
- return textRemoved;
+ // Do this last since it provides callbacks into application code
+ mImpl->mControlInterface.TextChanged();
}
-void Controller::TapEvent( unsigned int tapCount, float x, float y )
+bool Controller::RemoveText( int cursorOffset,
+ int numberOfCharacters,
+ UpdateInputStyleType type )
{
- DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected TapEvent" );
+ bool removed = false;
- if( NULL != mImpl->mEventData )
+ if( NULL == mImpl->mEventData )
{
- DALI_LOG_INFO( gLogFilter, Debug::Concise, "TapEvent state:%d \n", mImpl->mEventData->mState );
- EventData::State state( mImpl->mEventData->mState );
- bool relayoutNeeded( false ); // to avoid unnecessary relayouts when tapping an empty text-field
+ return removed;
+ }
- if( mImpl->IsClipboardVisible() )
- {
- if( EventData::INACTIVE == state || EventData::EDITING == state)
- {
- mImpl->ChangeState( EventData::EDITING_WITH_GRAB_HANDLE );
- }
- relayoutNeeded = true;
- }
- else if( 1u == tapCount )
- {
- if( EventData::EDITING_WITH_POPUP == state || EventData::EDITING_WITH_PASTE_POPUP == state )
- {
- mImpl->ChangeState( EventData::EDITING_WITH_GRAB_HANDLE ); // If Popup shown hide it here so can be shown again if required.
- }
+ DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::RemoveText %p mText.Count() %d cursor %d cursorOffset %d numberOfCharacters %d\n",
+ this, mImpl->mLogicalModel->mText.Count(), mImpl->mEventData->mPrimaryCursorPosition, cursorOffset, numberOfCharacters );
- if( mImpl->IsShowingRealText() && ( EventData::INACTIVE != state ) )
- {
- mImpl->ChangeState( EventData::EDITING_WITH_GRAB_HANDLE );
- relayoutNeeded = true;
- }
- else
- {
- if( mImpl->IsShowingPlaceholderText() && !mImpl->IsFocusedPlaceholderAvailable() )
- {
- // Hide placeholder text
- ResetText();
- }
+ if( !mImpl->IsShowingPlaceholderText() )
+ {
+ // Delete at current cursor position
+ Vector<Character>& currentText = mImpl->mLogicalModel->mText;
+ CharacterIndex& oldCursorIndex = mImpl->mEventData->mPrimaryCursorPosition;
- if( EventData::INACTIVE == state )
- {
- mImpl->ChangeState( EventData::EDITING );
- }
- else if( !mImpl->IsClipboardEmpty() )
- {
- mImpl->ChangeState( EventData::EDITING_WITH_POPUP );
- }
- relayoutNeeded = true;
- }
+ CharacterIndex cursorIndex = oldCursorIndex;
+
+ // Validate the cursor position & number of characters
+ if( static_cast< CharacterIndex >( std::abs( cursorOffset ) ) <= cursorIndex )
+ {
+ cursorIndex = oldCursorIndex + cursorOffset;
}
- else if( 2u == tapCount )
+
+ if( ( cursorIndex + numberOfCharacters ) > currentText.Count() )
{
- if( mImpl->mEventData->mSelectionEnabled &&
- mImpl->IsShowingRealText() )
- {
- SelectEvent( x, y, false );
- }
+ numberOfCharacters = currentText.Count() - cursorIndex;
}
- // Handles & cursors must be repositioned after Relayout() i.e. after the Model has been updated
- if( relayoutNeeded )
+
+ if( ( cursorIndex + numberOfCharacters ) <= mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters )
{
- Event event( Event::TAP_EVENT );
- event.p1.mUint = tapCount;
- event.p2.mFloat = x;
- event.p3.mFloat = y;
- mImpl->mEventData->mEventQueue.push_back( event );
+ // Mark the paragraphs to be updated.
+ mImpl->mTextUpdateInfo.mCharacterIndex = std::min( cursorIndex, mImpl->mTextUpdateInfo.mCharacterIndex );
+ mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove += numberOfCharacters;
- mImpl->RequestRelayout();
- }
- }
+ // Update the input style and remove the text's style before removing the text.
- // Reset keyboard as tap event has occurred.
- mImpl->ResetImfManager();
-}
+ if( UPDATE_INPUT_STYLE == type )
+ {
+ // Keep a copy of the current input style.
+ InputStyle currentInputStyle;
+ currentInputStyle.Copy( mImpl->mEventData->mInputStyle );
-void Controller::PanEvent( Gesture::State state, const Vector2& displacement )
-{
- DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected PanEvent" );
+ // Set first the default input style.
+ mImpl->RetrieveDefaultInputStyle( mImpl->mEventData->mInputStyle );
- if( NULL != mImpl->mEventData )
- {
- Event event( Event::PAN_EVENT );
- event.p1.mInt = state;
- event.p2.mFloat = displacement.x;
- event.p3.mFloat = displacement.y;
- mImpl->mEventData->mEventQueue.push_back( event );
+ // Update the input style.
+ mImpl->mLogicalModel->RetrieveStyle( cursorIndex, mImpl->mEventData->mInputStyle );
- mImpl->RequestRelayout();
- }
-}
+ // Compare if the input style has changed.
+ const bool hasInputStyleChanged = !currentInputStyle.Equal( mImpl->mEventData->mInputStyle );
-void Controller::LongPressEvent( Gesture::State state, float x, float y )
-{
- DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected LongPressEvent" );
+ if( hasInputStyleChanged )
+ {
+ const InputStyle::Mask styleChangedMask = currentInputStyle.GetInputStyleChangeMask( mImpl->mEventData->mInputStyle );
+ // Queue the input style changed signal.
+ mImpl->mEventData->mInputStyleChangedQueue.PushBack( styleChangedMask );
+ }
+ }
- if( ( state == Gesture::Started ) &&
- ( NULL != mImpl->mEventData ) )
- {
- if( !mImpl->IsShowingRealText() )
- {
- Event event( Event::LONG_PRESS_EVENT );
- event.p1.mInt = state;
- mImpl->mEventData->mEventQueue.push_back( event );
- mImpl->RequestRelayout();
- }
- else
- {
- // The 1st long-press on inactive text-field is treated as tap
- if( EventData::INACTIVE == mImpl->mEventData->mState )
- {
- mImpl->ChangeState( EventData::EDITING );
+ // Updates the text style runs by removing characters. Runs with no characters are removed.
+ mImpl->mLogicalModel->UpdateTextStyleRuns( cursorIndex, -numberOfCharacters );
- Event event( Event::TAP_EVENT );
- event.p1.mUint = 1;
- event.p2.mFloat = x;
- event.p3.mFloat = y;
- mImpl->mEventData->mEventQueue.push_back( event );
+ // Remove the characters.
+ Vector<Character>::Iterator first = currentText.Begin() + cursorIndex;
+ Vector<Character>::Iterator last = first + numberOfCharacters;
- mImpl->RequestRelayout();
- }
- else if( !mImpl->IsClipboardVisible() )
- {
- // Reset the imf manger to commit the pre-edit before selecting the text.
- mImpl->ResetImfManager();
+ currentText.Erase( first, last );
- SelectEvent( x, y, false );
- }
+ // Cursor position retreat
+ oldCursorIndex = cursorIndex;
+
+ mImpl->mEventData->mScrollAfterDelete = true;
+
+ DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::RemoveText %p removed %d\n", this, numberOfCharacters );
+ removed = true;
}
}
+
+ return removed;
}
-void Controller::SelectEvent( float x, float y, bool selectAll )
+bool Controller::RemoveSelectedText()
{
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::SelectEvent\n" );
+ bool textRemoved( false );
- if( NULL != mImpl->mEventData )
+ if( EventData::SELECTING == mImpl->mEventData->mState )
{
- if( selectAll )
- {
- Event event( Event::SELECT_ALL );
- mImpl->mEventData->mEventQueue.push_back( event );
- }
- else
+ std::string removedString;
+ mImpl->RetrieveSelection( removedString, true );
+
+ if( !removedString.empty() )
{
- Event event( Event::SELECT );
- event.p2.mFloat = x;
- event.p3.mFloat = y;
- mImpl->mEventData->mEventQueue.push_back( event );
+ textRemoved = true;
+ mImpl->ChangeState( EventData::EDITING );
}
-
- mImpl->RequestRelayout();
}
-}
-void Controller::GetTargetSize( Vector2& targetSize )
-{
- targetSize = mImpl->mVisualModel->mControlSize;
+ return textRemoved;
}
-void Controller::AddDecoration( Actor& actor, bool needsClipping )
-{
- mImpl->mControlInterface.AddDecoration( actor, needsClipping );
-}
+// private : Relayout.
-void Controller::DecorationEvent( HandleType handleType, HandleState state, float x, float y )
+bool Controller::DoRelayout( const Size& size,
+ OperationsMask operationsRequired,
+ Size& layoutSize )
{
- DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected DecorationEvent" );
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::DoRelayout %p size %f,%f\n", this, size.width, size.height );
+ bool viewUpdated( false );
- if( NULL != mImpl->mEventData )
+ // Calculate the operations to be done.
+ const OperationsMask operations = static_cast<OperationsMask>( mImpl->mOperationsPending & operationsRequired );
+
+ const CharacterIndex startIndex = mImpl->mTextUpdateInfo.mParagraphCharacterIndex;
+ const Length requestedNumberOfCharacters = mImpl->mTextUpdateInfo.mRequestedNumberOfCharacters;
+
+ // Get the current layout size.
+ layoutSize = mImpl->mVisualModel->GetLayoutSize();
+
+ if( NO_OPERATION != ( LAYOUT & operations ) )
{
- switch( handleType )
- {
- case GRAB_HANDLE:
- {
- Event event( Event::GRAB_HANDLE_EVENT );
- event.p1.mUint = state;
- event.p2.mFloat = x;
- event.p3.mFloat = y;
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->Controller::DoRelayout LAYOUT & operations\n");
- mImpl->mEventData->mEventQueue.push_back( event );
- break;
- }
- case LEFT_SELECTION_HANDLE:
- {
- Event event( Event::LEFT_SELECTION_HANDLE_EVENT );
- event.p1.mUint = state;
- event.p2.mFloat = x;
- event.p3.mFloat = y;
+ // Some vectors with data needed to layout and reorder may be void
+ // after the first time the text has been laid out.
+ // Fill the vectors again.
- mImpl->mEventData->mEventQueue.push_back( event );
- break;
- }
- case RIGHT_SELECTION_HANDLE:
- {
- Event event( Event::RIGHT_SELECTION_HANDLE_EVENT );
- event.p1.mUint = state;
- event.p2.mFloat = x;
- event.p3.mFloat = y;
+ // Calculate the number of glyphs to layout.
+ const Vector<GlyphIndex>& charactersToGlyph = mImpl->mVisualModel->mCharactersToGlyph;
+ const Vector<Length>& glyphsPerCharacter = mImpl->mVisualModel->mGlyphsPerCharacter;
+ const GlyphIndex* const charactersToGlyphBuffer = charactersToGlyph.Begin();
+ const Length* const glyphsPerCharacterBuffer = glyphsPerCharacter.Begin();
- mImpl->mEventData->mEventQueue.push_back( event );
- break;
- }
- case LEFT_SELECTION_HANDLE_MARKER:
- case RIGHT_SELECTION_HANDLE_MARKER:
- {
- // Markers do not move the handles.
- break;
- }
- case HANDLE_TYPE_COUNT:
+ const CharacterIndex lastIndex = startIndex + ( ( requestedNumberOfCharacters > 0u ) ? requestedNumberOfCharacters - 1u : 0u );
+ const GlyphIndex startGlyphIndex = mImpl->mTextUpdateInfo.mStartGlyphIndex;
+ const Length numberOfGlyphs = ( requestedNumberOfCharacters > 0u ) ? *( charactersToGlyphBuffer + lastIndex ) + *( glyphsPerCharacterBuffer + lastIndex ) - startGlyphIndex : 0u;
+ const Length totalNumberOfGlyphs = mImpl->mVisualModel->mGlyphs.Count();
+
+ if( 0u == totalNumberOfGlyphs )
+ {
+ if( NO_OPERATION != ( UPDATE_LAYOUT_SIZE & operations ) )
{
- DALI_ASSERT_DEBUG( !"Controller::HandleEvent. Unexpected handle type" );
+ mImpl->mVisualModel->SetLayoutSize( Size::ZERO );
}
- }
- mImpl->RequestRelayout();
- }
-}
-
-void Controller::PasteText( const std::string& stringToPaste )
-{
- InsertText( stringToPaste, Text::Controller::COMMIT );
- mImpl->ChangeState( EventData::EDITING );
- mImpl->RequestRelayout();
+ // Nothing else to do if there is no glyphs.
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::DoRelayout no glyphs, view updated true\n" );
+ return true;
+ }
- // Do this last since it provides callbacks into application code
- mImpl->mControlInterface.TextChanged();
-}
+ const Vector<LineBreakInfo>& lineBreakInfo = mImpl->mLogicalModel->mLineBreakInfo;
+ const Vector<WordBreakInfo>& wordBreakInfo = mImpl->mLogicalModel->mWordBreakInfo;
+ const Vector<CharacterDirection>& characterDirection = mImpl->mLogicalModel->mCharacterDirections;
+ const Vector<GlyphInfo>& glyphs = mImpl->mVisualModel->mGlyphs;
+ const Vector<CharacterIndex>& glyphsToCharactersMap = mImpl->mVisualModel->mGlyphsToCharacters;
+ const Vector<Length>& charactersPerGlyph = mImpl->mVisualModel->mCharactersPerGlyph;
+ const Character* const textBuffer = mImpl->mLogicalModel->mText.Begin();
-void Controller::PasteClipboardItemEvent()
-{
- // Retrieve the clipboard contents first
- ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() );
- std::string stringToPaste( notifier.GetContent() );
+ // Set the layout parameters.
+ LayoutParameters layoutParameters( size,
+ textBuffer,
+ lineBreakInfo.Begin(),
+ wordBreakInfo.Begin(),
+ ( 0u != characterDirection.Count() ) ? characterDirection.Begin() : NULL,
+ glyphs.Begin(),
+ glyphsToCharactersMap.Begin(),
+ charactersPerGlyph.Begin(),
+ charactersToGlyphBuffer,
+ glyphsPerCharacterBuffer,
+ totalNumberOfGlyphs );
- // Commit the current pre-edit text; the contents of the clipboard should be appended
- mImpl->ResetImfManager();
+ // Resize the vector of positions to have the same size than the vector of glyphs.
+ Vector<Vector2>& glyphPositions = mImpl->mVisualModel->mGlyphPositions;
+ glyphPositions.Resize( totalNumberOfGlyphs );
- // Temporary disable hiding clipboard
- mImpl->SetClipboardHideEnable( false );
+ // Whether the last character is a new paragraph character.
+ mImpl->mTextUpdateInfo.mIsLastCharacterNewParagraph = TextAbstraction::IsNewParagraph( *( textBuffer + ( mImpl->mLogicalModel->mText.Count() - 1u ) ) );
+ layoutParameters.isLastNewParagraph = mImpl->mTextUpdateInfo.mIsLastCharacterNewParagraph;
- // Paste
- PasteText( stringToPaste );
+ // The initial glyph and the number of glyphs to layout.
+ layoutParameters.startGlyphIndex = startGlyphIndex;
+ layoutParameters.numberOfGlyphs = numberOfGlyphs;
+ layoutParameters.startLineIndex = mImpl->mTextUpdateInfo.mStartLineIndex;
+ layoutParameters.estimatedNumberOfLines = mImpl->mTextUpdateInfo.mEstimatedNumberOfLines;
- mImpl->SetClipboardHideEnable( true );
-}
+ // Update the visual model.
+ Size newLayoutSize;
+ viewUpdated = mImpl->mLayoutEngine.LayoutText( layoutParameters,
+ glyphPositions,
+ mImpl->mVisualModel->mLines,
+ newLayoutSize );
-void Controller::TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Buttons button )
-{
- if( NULL == mImpl->mEventData )
- {
- return;
- }
+ viewUpdated = viewUpdated || ( newLayoutSize != layoutSize );
- switch( button )
- {
- case Toolkit::TextSelectionPopup::CUT:
+ if( viewUpdated )
{
- mImpl->SendSelectionToClipboard( true ); // Synchronous call to modify text
- mImpl->mOperationsPending = ALL_OPERATIONS;
+ layoutSize = newLayoutSize;
- if( ( 0u != mImpl->mLogicalModel->mText.Count() ) ||
- !mImpl->IsPlaceholderAvailable() )
+ if ( NO_OPERATION != ( UPDATE_DIRECTION & operations ) )
{
- mImpl->QueueModifyEvent( ModifyEvent::TEXT_DELETED );
+ mImpl->mAutoScrollDirectionRTL = false;
}
- else
+
+ // Reorder the lines
+ if( NO_OPERATION != ( REORDER & operations ) )
{
- ShowPlaceholderText();
+ Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo = mImpl->mLogicalModel->mBidirectionalParagraphInfo;
+ Vector<BidirectionalLineInfoRun>& bidirectionalLineInfo = mImpl->mLogicalModel->mBidirectionalLineInfo;
+
+ // Check first if there are paragraphs with bidirectional info.
+ if( 0u != bidirectionalInfo.Count() )
+ {
+ // Get the lines
+ const Length numberOfLines = mImpl->mVisualModel->mLines.Count();
+
+ // Reorder the lines.
+ bidirectionalLineInfo.Reserve( numberOfLines ); // Reserve because is not known yet how many lines have right to left characters.
+ ReorderLines( bidirectionalInfo,
+ startIndex,
+ requestedNumberOfCharacters,
+ mImpl->mVisualModel->mLines,
+ bidirectionalLineInfo );
+
+ // Set the bidirectional info per line into the layout parameters.
+ layoutParameters.lineBidirectionalInfoRunsBuffer = bidirectionalLineInfo.Begin();
+ layoutParameters.numberOfBidirectionalInfoRuns = bidirectionalLineInfo.Count();
+
+ // Re-layout the text. Reorder those lines with right to left characters.
+ mImpl->mLayoutEngine.ReLayoutRightToLeftLines( layoutParameters,
+ startIndex,
+ requestedNumberOfCharacters,
+ glyphPositions );
+
+ if ( ( NO_OPERATION != ( UPDATE_DIRECTION & operations ) ) && ( numberOfLines > 0 ) )
+ {
+ const LineRun* const firstline = mImpl->mVisualModel->mLines.Begin();
+ if ( firstline )
+ {
+ mImpl->mAutoScrollDirectionRTL = firstline->direction;
+ }
+ }
+ }
+ } // REORDER
+
+ // Sets the layout size.
+ if( NO_OPERATION != ( UPDATE_LAYOUT_SIZE & operations ) )
+ {
+ mImpl->mVisualModel->SetLayoutSize( layoutSize );
}
+ } // view updated
- mImpl->mEventData->mUpdateCursorPosition = true;
- mImpl->mEventData->mScrollAfterDelete = true;
+ // Store the size used to layout the text.
+ mImpl->mVisualModel->mControlSize = size;
+ }
- mImpl->RequestRelayout();
- mImpl->mControlInterface.TextChanged();
- break;
- }
- case Toolkit::TextSelectionPopup::COPY:
- {
- mImpl->SendSelectionToClipboard( false ); // Text not modified
+ if( NO_OPERATION != ( ALIGN & operations ) )
+ {
+ // The laid-out lines.
+ Vector<LineRun>& lines = mImpl->mVisualModel->mLines;
+
+ mImpl->mLayoutEngine.Align( size,
+ startIndex,
+ requestedNumberOfCharacters,
+ lines );
+
+ viewUpdated = true;
+ }
+#if defined(DEBUG_ENABLED)
+ std::string currentText;
+ GetText( currentText );
+ DALI_LOG_INFO( gLogFilter, Debug::Concise, "Controller::DoRelayout [%p] mImpl->mAutoScrollDirectionRTL[%s] [%s]\n", this, (mImpl->mAutoScrollDirectionRTL)?"true":"false", currentText.c_str() );
+#endif
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::DoRelayout, view updated %s\n", ( viewUpdated ? "true" : "false" ) );
+ return viewUpdated;
+}
- mImpl->mEventData->mUpdateCursorPosition = true;
+void Controller::CalculateVerticalOffset( const Size& controlSize )
+{
+ Size layoutSize = mImpl->mVisualModel->GetLayoutSize();
- mImpl->RequestRelayout(); // Cursor, Handles, Selection Highlight, Popup
- break;
- }
- case Toolkit::TextSelectionPopup::PASTE:
- {
- mImpl->RequestGetTextFromClipboard(); // Request clipboard service to retrieve an item
- break;
- }
- case Toolkit::TextSelectionPopup::SELECT:
- {
- const Vector2& currentCursorPosition = mImpl->mEventData->mDecorator->GetPosition( PRIMARY_CURSOR );
+ if( fabsf( layoutSize.height ) < Math::MACHINE_EPSILON_1000 )
+ {
+ // Get the line height of the default font.
+ layoutSize.height = mImpl->GetDefaultFontLineHeight();
+ }
- if( mImpl->mEventData->mSelectionEnabled )
- {
- // Creates a SELECT event.
- SelectEvent( currentCursorPosition.x, currentCursorPosition.y, false );
- }
- break;
- }
- case Toolkit::TextSelectionPopup::SELECT_ALL:
+ switch( mImpl->mLayoutEngine.GetVerticalAlignment() )
+ {
+ case LayoutEngine::VERTICAL_ALIGN_TOP:
{
- // Creates a SELECT_ALL event
- SelectEvent( 0.f, 0.f, true );
+ mImpl->mScrollPosition.y = 0.f;
break;
}
- case Toolkit::TextSelectionPopup::CLIPBOARD:
+ case LayoutEngine::VERTICAL_ALIGN_CENTER:
{
- mImpl->ShowClipboard();
+ mImpl->mScrollPosition.y = floorf( 0.5f * ( controlSize.height - layoutSize.height ) ); // try to avoid pixel alignment.
break;
}
- case Toolkit::TextSelectionPopup::NONE:
+ case LayoutEngine::VERTICAL_ALIGN_BOTTOM:
{
- // Nothing to do.
+ mImpl->mScrollPosition.y = controlSize.height - layoutSize.height;
break;
}
}
}
-ImfManager::ImfCallbackData Controller::OnImfEvent( ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent )
+// private : Events.
+
+void Controller::ProcessModifyEvents()
{
- // Whether the text needs to be relaid-out.
- bool requestRelayout = false;
+ Vector<ModifyEvent>& events = mImpl->mModifyEvents;
- // Whether to retrieve the text and cursor position to be sent to the IMF manager.
- bool retrieveText = false;
- bool retrieveCursor = false;
+ if( 0u == events.Count() )
+ {
+ // Nothing to do.
+ return;
+ }
- switch( imfEvent.eventName )
+ for( Vector<ModifyEvent>::ConstIterator it = events.Begin(),
+ endIt = events.End();
+ it != endIt;
+ ++it )
{
- case ImfManager::COMMIT:
+ const ModifyEvent& event = *it;
+
+ if( ModifyEvent::TEXT_REPLACED == event.type )
{
- InsertText( imfEvent.predictiveString, Text::Controller::COMMIT );
- requestRelayout = true;
- retrieveCursor = true;
- break;
+ // A (single) replace event should come first, otherwise we wasted time processing NOOP events
+ DALI_ASSERT_DEBUG( it == events.Begin() && "Unexpected TEXT_REPLACED event" );
+
+ TextReplacedEvent();
}
- case ImfManager::PREEDIT:
+ else if( ModifyEvent::TEXT_INSERTED == event.type )
{
- InsertText( imfEvent.predictiveString, Text::Controller::PRE_EDIT );
- requestRelayout = true;
- retrieveCursor = true;
- break;
+ TextInsertedEvent();
}
- case ImfManager::DELETESURROUNDING:
+ else if( ModifyEvent::TEXT_DELETED == event.type )
{
- const bool textDeleted = RemoveText( imfEvent.cursorOffset,
- imfEvent.numberOfChars,
- DONT_UPDATE_INPUT_STYLE );
-
- if( textDeleted )
+ // Placeholder-text cannot be deleted
+ if( !mImpl->IsShowingPlaceholderText() )
{
- if( ( 0u != mImpl->mLogicalModel->mText.Count() ) ||
- !mImpl->IsPlaceholderAvailable() )
- {
- mImpl->QueueModifyEvent( ModifyEvent::TEXT_DELETED );
- }
- else
- {
- ShowPlaceholderText();
- }
- mImpl->mEventData->mUpdateCursorPosition = true;
- mImpl->mEventData->mScrollAfterDelete = true;
-
- requestRelayout = true;
+ TextDeletedEvent();
}
- break;
- }
- case ImfManager::GETSURROUNDING:
- {
- retrieveText = true;
- retrieveCursor = true;
- break;
- }
- case ImfManager::VOID:
- {
- // do nothing
- break;
}
- } // end switch
+ }
- if( requestRelayout )
+ if( NULL != mImpl->mEventData )
{
- mImpl->mOperationsPending = ALL_OPERATIONS;
- mImpl->RequestRelayout();
+ // When the text is being modified, delay cursor blinking
+ mImpl->mEventData->mDecorator->DelayCursorBlink();
}
- std::string text;
- CharacterIndex cursorPosition = 0u;
- Length numberOfWhiteSpaces = 0u;
+ // Discard temporary text
+ events.Clear();
+}
- if( retrieveCursor )
- {
- numberOfWhiteSpaces = mImpl->GetNumberOfWhiteSpaces( 0u );
+void Controller::TextReplacedEvent()
+{
+ // The natural size needs to be re-calculated.
+ mImpl->mRecalculateNaturalSize = true;
- cursorPosition = mImpl->GetLogicalCursorPosition();
+ // Apply modifications to the model
+ mImpl->mOperationsPending = ALL_OPERATIONS;
+}
- if( cursorPosition < numberOfWhiteSpaces )
- {
- cursorPosition = 0u;
- }
- else
- {
- cursorPosition -= numberOfWhiteSpaces;
- }
- }
+void Controller::TextInsertedEvent()
+{
+ DALI_ASSERT_DEBUG( NULL != mImpl->mEventData && "Unexpected TextInsertedEvent" );
- if( retrieveText )
+ if( NULL == mImpl->mEventData )
{
- mImpl->GetText( numberOfWhiteSpaces, text );
+ return;
}
- ImfManager::ImfCallbackData callbackData( ( retrieveText || retrieveCursor ), cursorPosition, text, false );
+ // The natural size needs to be re-calculated.
+ mImpl->mRecalculateNaturalSize = true;
- if( requestRelayout )
+ // Apply modifications to the model; TODO - Optimize this
+ mImpl->mOperationsPending = ALL_OPERATIONS;
+}
+
+void Controller::TextDeletedEvent()
+{
+ DALI_ASSERT_DEBUG( NULL != mImpl->mEventData && "Unexpected TextDeletedEvent" );
+
+ if( NULL == mImpl->mEventData )
{
- // Do this last since it provides callbacks into application code
- mImpl->mControlInterface.TextChanged();
+ return;
}
- return callbackData;
+ // The natural size needs to be re-calculated.
+ mImpl->mRecalculateNaturalSize = true;
+
+ // Apply modifications to the model; TODO - Optimize this
+ mImpl->mOperationsPending = ALL_OPERATIONS;
}
-Controller::~Controller()
+void Controller::SelectEvent( float x, float y, bool selectAll )
{
- delete mImpl;
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::SelectEvent\n" );
+
+ if( NULL != mImpl->mEventData )
+ {
+ if( selectAll )
+ {
+ Event event( Event::SELECT_ALL );
+ mImpl->mEventData->mEventQueue.push_back( event );
+ }
+ else
+ {
+ Event event( Event::SELECT );
+ event.p2.mFloat = x;
+ event.p3.mFloat = y;
+ mImpl->mEventData->mEventQueue.push_back( event );
+ }
+
+ mImpl->RequestRelayout();
+ }
}
bool Controller::BackspaceKeyEvent()
return removed;
}
+// private : Helpers.
+
+void Controller::ResetText()
+{
+ // Reset buffers.
+ mImpl->mLogicalModel->mText.Clear();
+
+ // We have cleared everything including the placeholder-text
+ mImpl->PlaceholderCleared();
+
+ mImpl->mTextUpdateInfo.mCharacterIndex = 0u;
+ mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters;
+ mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = 0u;
+
+ // Clear any previous text.
+ mImpl->mTextUpdateInfo.mClearAll = true;
+
+ // The natural size needs to be re-calculated.
+ mImpl->mRecalculateNaturalSize = true;
+
+ // Apply modifications to the model
+ mImpl->mOperationsPending = ALL_OPERATIONS;
+}
+
void Controller::ShowPlaceholderText()
{
if( mImpl->IsPlaceholderAvailable() )
mImpl->mLogicalModel->ClearFontDescriptionRuns();
}
+void Controller::ResetCursorPosition( CharacterIndex cursorIndex )
+{
+ // Reset the cursor position
+ if( NULL != mImpl->mEventData )
+ {
+ mImpl->mEventData->mPrimaryCursorPosition = cursorIndex;
+
+ // Update the cursor if it's in editing mode.
+ if( EventData::IsEditingState( mImpl->mEventData->mState ) )
+ {
+ mImpl->mEventData->mUpdateCursorPosition = true;
+ }
+ }
+}
+
+void Controller::ResetScrollPosition()
+{
+ if( NULL != mImpl->mEventData )
+ {
+ // Reset the scroll position.
+ mImpl->mScrollPosition = Vector2::ZERO;
+ mImpl->mEventData->mScrollAfterUpdatePosition = true;
+ }
+}
+
+// private : Private contructors & copy operator.
+
Controller::Controller( ControlInterface& controlInterface )
: mImpl( NULL )
{
mImpl = new Controller::Impl( controlInterface );
}
+// The copy constructor and operator are left unimplemented.
+
+// protected : Destructor.
+
+Controller::~Controller()
+{
+ delete mImpl;
+}
+
} // namespace Text
} // namespace Toolkit
typedef Dali::Toolkit::Text::ControlInterface ControlInterface;
/**
- * @brief Different placeholder-text can be shown when the control is active/inactive.
- */
-enum PlaceholderType
-{
- PLACEHOLDER_TYPE_ACTIVE,
- PLACEHOLDER_TYPE_INACTIVE,
-};
-
-/**
* @brief A Text Controller is used by UI Controls which display text.
*
* It manipulates the Logical & Visual text models on behalf of the UI Controls.
*/
class Controller : public RefObject, public Decorator::ControllerInterface, public TextSelectionPopupCallbackInterface
{
-public:
+public: // Enumerated types.
/**
* @brief Text related operations to be done in the relayout process.
DONT_UPDATE_INPUT_STYLE
};
+ /**
+ * @brief Used to specify what has been updated after the Relayout() method has been called.
+ */
enum UpdateTextType
{
- NONE_UPDATED = 0x0,
- MODEL_UPDATED = 0x1,
- DECORATOR_UPDATED = 0x2
+ NONE_UPDATED = 0x0, ///< Nothing has been updated.
+ MODEL_UPDATED = 0x1, ///< The text's model has been updated.
+ DECORATOR_UPDATED = 0x2 ///< The decoration has been updated.
};
/**
+ * @brief Different placeholder-text can be shown when the control is active/inactive.
+ */
+ enum PlaceholderType
+ {
+ PLACEHOLDER_TYPE_ACTIVE,
+ PLACEHOLDER_TYPE_INACTIVE,
+ };
+
+public: // Constructor.
+
+ /**
* @brief Create a new instance of a Controller.
*
* @param[in] controlInterface An interface used to request a text relayout.
*/
static ControllerPtr New( ControlInterface& controlInterface );
+public: // Configure the text controller.
+
/**
* @brief Called to enable text input.
*
bool IsSmoothHandlePanEnabled() const;
/**
+ * @brief Sets the maximum number of characters that can be inserted into the TextModel
+ *
+ * @param[in] maxCharacters maximum number of characters to be accepted
+ */
+ void SetMaximumNumberOfCharacters( Length maxCharacters );
+
+ /**
+ * @brief Sets the maximum number of characters that can be inserted into the TextModel
+ *
+ * @param[in] maxCharacters maximum number of characters to be accepted
+ */
+ int GetMaximumNumberOfCharacters();
+
+ /**
+ * @brief Called to enable/disable cursor blink.
+ *
+ * @note Only editable controls should calls this.
+ * @param[in] enabled Whether the cursor should blink or not.
+ */
+ void SetEnableCursorBlink( bool enable );
+
+ /**
+ * @brief Query whether cursor blink is enabled.
+ *
+ * @return Whether the cursor should blink or not.
+ */
+ bool GetEnableCursorBlink() const;
+
+ /**
+ * @brief Whether to enable the multi-line layout.
+ *
+ * @param[in] enable \e true enables the multi-line (by default)
+ */
+ void SetMultiLineEnabled( bool enable );
+
+ /**
+ * @return Whether the multi-line layout is enabled.
+ */
+ bool IsMultiLineEnabled() const;
+
+ /**
+ * @copydoc Dali::Toolkit::Text::LayoutEngine::SetHorizontalAlignment()
+ */
+ void SetHorizontalAlignment( LayoutEngine::HorizontalAlignment alignment );
+
+ /**
+ * @copydoc Dali::Toolkit::Text::LayoutEngine::GetHorizontalAlignment()
+ */
+ LayoutEngine::HorizontalAlignment GetHorizontalAlignment() const;
+
+ /**
+ * @copydoc Dali::Toolkit::Text::LayoutEngine::SetVerticalAlignment()
+ */
+ void SetVerticalAlignment( LayoutEngine::VerticalAlignment alignment );
+
+ /**
+ * @copydoc Dali::Toolkit::Text::LayoutEngine::GetVerticalAlignment()
+ */
+ LayoutEngine::VerticalAlignment GetVerticalAlignment() const;
+
+public: // Update.
+
+ /**
* @brief Replaces any text previously set.
*
* @note This will be converted into UTF-32 when stored in the text model.
void GetText( std::string& text ) const;
/**
- * @brief Remove a given number of characters
- *
- * When predictve text is used the pre-edit text is removed and inserted again with the new characters.
- * The UpdateInputStyleType @type parameter if set to DONT_UPDATE_INPUT_STYLE avoids to update the input
- * style when pre-edit text is removed.
- *
- * @param[in] cursorOffset Start position from the current cursor position to start deleting characters.
- * @param[in] numberOfCharacters The number of characters to delete from the cursorOffset.
- * @param[in] type Whether to update the input style.
- * @return True if the remove was successful.
- */
- bool RemoveText( int cursorOffset,
- int numberOfCharacters,
- UpdateInputStyleType type );
-
- /**
* @brief Replaces any placeholder text previously set.
*
* @param[in] type Different placeholder-text can be shown when the control is active/inactive.
void GetPlaceholderText( PlaceholderType type, std::string& text ) const;
/**
- * @brief Sets the maximum number of characters that can be inserted into the TextModel
- *
- * @param[in] maxCharacters maximum number of characters to be accepted
+ * @ brief Update the text after a font change
+ * @param[in] newDefaultFont The new font to change to
*/
- void SetMaximumNumberOfCharacters( Length maxCharacters );
+ void UpdateAfterFontChange( const std::string& newDefaultFont );
- /**
- * @brief Sets the maximum number of characters that can be inserted into the TextModel
- *
- * @param[in] maxCharacters maximum number of characters to be accepted
- */
- int GetMaximumNumberOfCharacters();
+public: // Default style & Input style
/**
* @brief Set the default font family.
float GetDefaultPointSize() const;
/**
- * @ brief Update the text after a font change
- * @param[in] newDefaultFont The new font to change to
- */
- void UpdateAfterFontChange( const std::string& newDefaultFont );
-
- /**
* @brief Set the text color
*
* @param textColor The text color
*/
const std::string& GetInputOutlineProperties() const;
+public: // Queries & retrieves.
+
/**
- * @brief Called to enable/disable cursor blink.
+ * @brief Return the layout engine.
*
- * @note Only editable controls should calls this.
- * @param[in] enabled Whether the cursor should blink or not.
+ * @return A reference to the layout engine.
*/
- void SetEnableCursorBlink( bool enable );
+ LayoutEngine& GetLayoutEngine();
/**
- * @brief Query whether cursor blink is enabled.
+ * @brief Return a view of the text.
*
- * @return Whether the cursor should blink or not.
+ * @return A reference to the view.
*/
- bool GetEnableCursorBlink() const;
+ View& GetView();
/**
* @brief Query the current scroll position; the UI control is responsible for moving actors to this position.
*/
float GetHeightForWidth( float width );
+public: // Relayout.
+
/**
* @brief Triggers a relayout which updates View (if necessary).
*
*/
UpdateTextType Relayout( const Size& size );
- /**
- * @brief Process queued events which modify the model.
- */
- void ProcessModifyEvents();
+public: // Input style change signals.
/**
* @return Whether the queue of input style changed signals is empty.
*/
void ProcessInputStyleChangedSignals();
- /**
- * @brief Used to remove placeholder text.
- */
- void ResetText();
+public: // Text-input Event Queuing.
/**
- * @brief Used to reset the cursor position after setting a new text.
- *
- * @param[in] cursorIndex Where to place the cursor.
+ * @brief Called by editable UI controls when keyboard focus is gained.
*/
- void ResetCursorPosition( CharacterIndex cursorIndex );
+ void KeyboardFocusGainEvent();
/**
- * @brief Used to reset the scroll position after setting a new text.
+ * @brief Called by editable UI controls when focus is lost.
*/
- void ResetScrollPosition();
+ void KeyboardFocusLostEvent();
/**
- * @brief Used to process an event queued from SetText()
+ * @brief Called by editable UI controls when key events are received.
+ *
+ * @param[in] event The key event.
+ * @param[in] type Used to distinguish between regular key events and IMF events.
*/
- void TextReplacedEvent();
+ bool KeyEvent( const Dali::KeyEvent& event );
/**
- * @brief Used to process an event queued from key events etc.
+ * @brief Called by editable UI controls when a tap gesture occurs.
+ * @param[in] tapCount The number of taps.
+ * @param[in] x The x position relative to the top-left of the parent control.
+ * @param[in] y The y position relative to the top-left of the parent control.
*/
- void TextInsertedEvent();
+ void TapEvent( unsigned int tapCount, float x, float y );
/**
- * @brief Used to process an event queued from backspace key etc.
+ * @brief Called by editable UI controls when a pan gesture occurs.
+ *
+ * @param[in] state The state of the gesture.
+ * @param[in] displacement This distance panned since the last pan gesture.
*/
- void TextDeletedEvent();
+ void PanEvent( Gesture::State state, const Vector2& displacement );
/**
- * @brief Lays-out the text.
- *
- * GetNaturalSize(), GetHeightForWidth() and Relayout() calls this method.
+ * @brief Called by editable UI controls when a long press gesture occurs.
*
- * @param[in] size A the size of a bounding box to layout text within.
- * @param[in] operations The layout operations which need to be done.
- * @param[out] layoutSize The size of the laid-out text.
+ * @param[in] state The state of the gesture.
+ * @param[in] x The x position relative to the top-left of the parent control.
+ * @param[in] y The y position relative to the top-left of the parent control.
*/
- bool DoRelayout( const Size& size,
- OperationsMask operations,
- Size& layoutSize );
+ void LongPressEvent( Gesture::State state, float x, float y );
/**
- * @brief Whether to enable the multi-line layout.
+ * @brief Event received from IMF manager
*
- * @param[in] enable \e true enables the multi-line (by default)
+ * @param[in] imfManager The IMF manager.
+ * @param[in] imfEvent The event received.
+ * @return A data struture indicating if update is needed, cursor position and current text.
*/
- void SetMultiLineEnabled( bool enable );
+ ImfManager::ImfCallbackData OnImfEvent( ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent );
/**
- * @return Whether the multi-line layout is enabled.
+ * @brief Event from Clipboard notifying an Item has been selected for pasting
*/
- bool IsMultiLineEnabled() const;
+ void PasteClipboardItemEvent();
+
+protected: // Inherit from Text::Decorator::ControllerInterface.
/**
- * @copydoc Dali::Toolkit::Text::LayoutEngine::SetHorizontalAlignment()
+ * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::GetTargetSize()
*/
- void SetHorizontalAlignment( LayoutEngine::HorizontalAlignment alignment );
+ virtual void GetTargetSize( Vector2& targetSize );
/**
- * @copydoc Dali::Toolkit::Text::LayoutEngine::GetHorizontalAlignment()
+ * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::AddDecoration()
*/
- LayoutEngine::HorizontalAlignment GetHorizontalAlignment() const;
+ virtual void AddDecoration( Actor& actor, bool needsClipping );
/**
- * @copydoc Dali::Toolkit::Text::LayoutEngine::SetVerticalAlignment()
+ * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::DecorationEvent()
*/
- void SetVerticalAlignment( LayoutEngine::VerticalAlignment alignment );
+ virtual void DecorationEvent( HandleType handle, HandleState state, float x, float y );
+
+protected: // Inherit from TextSelectionPopup::TextPopupButtonCallbackInterface.
/**
- * @copydoc Dali::Toolkit::Text::LayoutEngine::GetVerticalAlignment()
+ * @copydoc Dali::Toolkit::TextSelectionPopup::TextPopupButtonCallbackInterface::TextPopupButtonTouched()
*/
- LayoutEngine::VerticalAlignment GetVerticalAlignment() const;
+ virtual void TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Buttons button );
+
+private: // Update.
/**
- * @brief Calulates the vertical offset to align the text inside the bounding box.
+ * @brief Called by editable UI controls when key events are received.
*
- * @param[in] size The size of the bounding box.
+ * @param[in] text The text to insert.
+ * @param[in] type Used to distinguish between regular key events and IMF events.
*/
- void CalculateVerticalOffset( const Size& size );
+ void InsertText( const std::string& text, InsertType type );
/**
- * @brief Return the layout engine.
- *
- * @return A reference to the layout engine.
+ * @brief Paste given string into Text model
+ * @param[in] stringToPaste this string will be inserted into the text model
*/
- LayoutEngine& GetLayoutEngine();
+ void PasteText( const std::string& stringToPaste );
/**
- * @brief Return a view of the text.
+ * @brief Remove a given number of characters
*
- * @return A reference to the view.
+ * When predictve text is used the pre-edit text is removed and inserted again with the new characters.
+ * The UpdateInputStyleType @type parameter if set to DONT_UPDATE_INPUT_STYLE avoids to update the input
+ * style when pre-edit text is removed.
+ *
+ * @param[in] cursorOffset Start position from the current cursor position to start deleting characters.
+ * @param[in] numberOfCharacters The number of characters to delete from the cursorOffset.
+ * @param[in] type Whether to update the input style.
+ * @return True if the remove was successful.
*/
- View& GetView();
-
- // Text-input Event Queuing
+ bool RemoveText( int cursorOffset,
+ int numberOfCharacters,
+ UpdateInputStyleType type );
/**
- * @brief Called by editable UI controls when keyboard focus is gained.
+ * @brief Checks if text is selected and if so removes it.
+ * @return true if text was removed
*/
- void KeyboardFocusGainEvent();
+ bool RemoveSelectedText();
- /**
- * @brief Called by editable UI controls when focus is lost.
- */
- void KeyboardFocusLostEvent();
+private: // Relayout.
/**
- * @brief Called by editable UI controls when key events are received.
+ * @brief Lays-out the text.
*
- * @param[in] event The key event.
- * @param[in] type Used to distinguish between regular key events and IMF events.
+ * GetNaturalSize(), GetHeightForWidth() and Relayout() calls this method.
+ *
+ * @param[in] size A the size of a bounding box to layout text within.
+ * @param[in] operations The layout operations which need to be done.
+ * @param[out] layoutSize The size of the laid-out text.
*/
- bool KeyEvent( const Dali::KeyEvent& event );
+ bool DoRelayout( const Size& size,
+ OperationsMask operations,
+ Size& layoutSize );
/**
- * @brief Called by editable UI controls when key events are received.
+ * @brief Calulates the vertical offset to align the text inside the bounding box.
*
- * @param[in] text The text to insert.
- * @param[in] type Used to distinguish between regular key events and IMF events.
+ * @param[in] size The size of the bounding box.
*/
- void InsertText( const std::string& text, InsertType type );
+ void CalculateVerticalOffset( const Size& size );
+
+private: // Events.
/**
- * @brief Checks if text is selected and if so removes it.
- * @return true if text was removed
+ * @brief Process queued events which modify the model.
*/
- bool RemoveSelectedText();
+ void ProcessModifyEvents();
/**
- * @brief Called by editable UI controls when a tap gesture occurs.
- * @param[in] tapCount The number of taps.
- * @param[in] x The x position relative to the top-left of the parent control.
- * @param[in] y The y position relative to the top-left of the parent control.
+ * @brief Used to process an event queued from SetText()
*/
- void TapEvent( unsigned int tapCount, float x, float y );
+ void TextReplacedEvent();
/**
- * @brief Called by editable UI controls when a pan gesture occurs.
- *
- * @param[in] state The state of the gesture.
- * @param[in] displacement This distance panned since the last pan gesture.
+ * @brief Used to process an event queued from key events etc.
*/
- void PanEvent( Gesture::State state, const Vector2& displacement );
+ void TextInsertedEvent();
/**
- * @brief Called by editable UI controls when a long press gesture occurs.
- *
- * @param[in] state The state of the gesture.
- * @param[in] x The x position relative to the top-left of the parent control.
- * @param[in] y The y position relative to the top-left of the parent control.
+ * @brief Used to process an event queued from backspace key etc.
*/
- void LongPressEvent( Gesture::State state, float x, float y );
+ void TextDeletedEvent();
/**
* @brief Creates a selection event.
void SelectEvent( float x, float y, bool selectAll );
/**
- * @brief Event received from IMF manager
+ * @brief Helper to KeyEvent() to handle the backspace case.
*
- * @param[in] imfManager The IMF manager.
- * @param[in] imfEvent The event received.
- * @return A data struture indicating if update is needed, cursor position and current text.
- */
- ImfManager::ImfCallbackData OnImfEvent( ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent );
-
- /**
- * @brief Paste given string into Text model
- * @param[in] stringToPaste this string will be inserted into the text model
- */
- void PasteText( const std::string& stringToPaste );
-
- /**
- * @brief Event from Clipboard notifying an Item has been selected for pasting
+ * @return True if a character was deleted.
*/
- void PasteClipboardItemEvent();
+ bool BackspaceKeyEvent();
- /**
- * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::GetTargetSize()
- */
- virtual void GetTargetSize( Vector2& targetSize );
+private: // Helpers.
/**
- * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::AddDecoration()
+ * @brief Used to remove the text included the placeholder text.
*/
- virtual void AddDecoration( Actor& actor, bool needsClipping );
+ void ResetText();
/**
- * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::DecorationEvent()
+ * @brief Helper to show the place holder text..
*/
- virtual void DecorationEvent( HandleType handle, HandleState state, float x, float y );
+ void ShowPlaceholderText();
/**
- * @copydoc Dali::Toolkit::TextSelectionPopup::TextPopupButtonCallbackInterface::TextPopupButtonTouched()
+ * @brief Helper to clear font-specific data (only).
*/
- virtual void TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Buttons button );
-
-protected:
+ void ClearFontData();
/**
- * @brief A reference counted object may only be deleted by calling Unreference().
+ * @brief Helper to clear text's style data.
*/
- virtual ~Controller();
-
-private:
+ void ClearStyleData();
/**
- * @brief Helper to KeyEvent() to handle the backspace case.
+ * @brief Used to reset the cursor position after setting a new text.
*
- * @return True if a character was deleted.
- */
- bool BackspaceKeyEvent();
-
- /**
- * @brief Helper to clear font-specific data.
+ * @param[in] cursorIndex Where to place the cursor.
*/
- void ShowPlaceholderText();
+ void ResetCursorPosition( CharacterIndex cursorIndex );
/**
- * @brief Helper to clear font-specific data (only).
+ * @brief Used to reset the scroll position after setting a new text.
*/
- void ClearFontData();
+ void ResetScrollPosition();
- /**
- * @brief Helper to clear text's style data.
- */
- void ClearStyleData();
+private: // Private contructors & copy operator.
/**
* @brief Private constructor.
// Undefined
Controller& operator=( const Controller& handle );
+protected: // Destructor.
+
+ /**
+ * @brief A reference counted object may only be deleted by calling Unreference().
+ */
+ virtual ~Controller();
+
private:
struct Impl;
//Property names
const char * const PRIMITIVE_SHAPE( "shape" );
-const char * const SHAPE_COLOR( "shapeColor" );
+const char * const SHAPE_COLOR( "mixColor" );
const char * const SLICES( "slices" );
const char * const STACKS( "stacks" );
const char * const SCALE_TOP_RADIUS( "scaleTopRadius" );
const Vector4 DEFAULT_COLOR = Vector4( 0.5, 0.5, 0.5, 0.0 ); ///< Grey, for all.
//Property limits
-const int MIN_SLICES = 1; ///< Minimum number of slices for spheres and conics
-const int MIN_STACKS = 1; ///< Minimum number of stacks for spheres and conics
+const int MIN_SLICES = 3; ///< Minimum number of slices for spheres and conics
+const int MIN_STACKS = 2; ///< Minimum number of stacks for spheres and conics
const int MAX_PARTITIONS = 255; ///< Maximum number of slices or stacks for spheres and conics
const float MIN_BEVEL_PERCENTAGE = 0.0; ///< Minimum bevel percentage for bevelled cubes
const float MAX_BEVEL_PERCENTAGE = 1.0; ///< Maximum bevel percentage for bevelled cubes
//Read in other potential properties.
- Property::Value* color = propertyMap.Find( Toolkit::PrimitiveVisual::Property::COLOR, SHAPE_COLOR );
+ Property::Value* color = propertyMap.Find( Toolkit::PrimitiveVisual::Property::MIX_COLOR, SHAPE_COLOR );
if( color && !color->Get( mColor ) )
{
DALI_LOG_ERROR( "Invalid type for color in PrimitiveVisual.\n" );
if( mSlices > MAX_PARTITIONS )
{
mSlices = MAX_PARTITIONS;
+ DALI_LOG_WARNING( "Value for slices clamped.\n" );
}
else if ( mSlices < MIN_SLICES )
{
mSlices = MIN_SLICES;
+ DALI_LOG_WARNING( "Value for slices clamped.\n" );
}
}
else
if( mStacks > MAX_PARTITIONS )
{
mStacks = MAX_PARTITIONS;
+ DALI_LOG_WARNING( "Value for stacks clamped.\n" );
}
else if ( mStacks < MIN_STACKS )
{
mStacks = MIN_STACKS;
+ DALI_LOG_WARNING( "Value for stacks clamped.\n" );
}
}
else
if( mScaleDimensions.x <= 0.0 )
{
mScaleDimensions.x = 1.0;
+ DALI_LOG_WARNING( "Value for scale dimensions clamped. Must be greater than zero.\n" );
}
if( mScaleDimensions.y <= 0.0 )
{
mScaleDimensions.y = 1.0;
+ DALI_LOG_WARNING( "Value for scale dimensions clamped. Must be greater than zero.\n" );
}
if( mScaleDimensions.z <= 0.0 )
{
mScaleDimensions.z = 1.0;
+ DALI_LOG_WARNING( "Value for scale dimensions clamped. Must be greater than zero.\n" );
}
}
else
if( mBevelPercentage < MIN_BEVEL_PERCENTAGE )
{
mBevelPercentage = MIN_BEVEL_PERCENTAGE;
+ DALI_LOG_WARNING( "Value for bevel percentage clamped.\n" );
}
else if( mBevelPercentage > MAX_BEVEL_PERCENTAGE )
{
mBevelPercentage = MAX_BEVEL_PERCENTAGE;
+ DALI_LOG_WARNING( "Value for bevel percentage clamped.\n" );
}
}
else
if( mBevelSmoothness < MIN_SMOOTHNESS )
{
mBevelSmoothness = MIN_SMOOTHNESS;
+ DALI_LOG_WARNING( "Value for bevel smoothness clamped.\n" );
}
else if( mBevelSmoothness > MAX_SMOOTHNESS )
{
mBevelSmoothness = MAX_SMOOTHNESS;
+ DALI_LOG_WARNING( "Value for bevel smoothness clamped.\n" );
}
}
else
map.Clear();
map.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::PRIMITIVE );
map.Insert( Toolkit::PrimitiveVisual::Property::SHAPE, mPrimitiveType );
- map.Insert( Toolkit::PrimitiveVisual::Property::COLOR, mColor );
+ map.Insert( Toolkit::PrimitiveVisual::Property::MIX_COLOR, mColor );
map.Insert( Toolkit::PrimitiveVisual::Property::SLICES, mSlices );
map.Insert( Toolkit::PrimitiveVisual::Property::STACKS, mStacks );
map.Insert( Toolkit::PrimitiveVisual::Property::SCALE_TOP_RADIUS, mScaleTopRadius );
mShader.RegisterProperty( STAGE_OFFSET_UNIFORM_NAME, Vector2( width, height ) / 2.0f );
mShader.RegisterProperty( LIGHT_POSITION_UNIFORM_NAME, mLightPosition );
mShader.RegisterProperty( OBJECT_MATRIX_UNIFORM_NAME, scaleMatrix );
- mShader.RegisterProperty( Toolkit::PrimitiveVisual::Property::COLOR, COLOR_UNIFORM_NAME, mColor );
+ mShader.RegisterProperty( Toolkit::PrimitiveVisual::Property::MIX_COLOR, COLOR_UNIFORM_NAME, mColor );
mShader.RegisterProperty( OBJECT_DIMENSIONS_UNIFORM_NAME, mObjectDimensions );
}
int normalIndex = 0; //Track progress through normals, as vertices are calculated per face.
float minDimension = std::min( std::min( dimensions.x, dimensions.y ), dimensions.z );
- float bevelScale = 1.0 - bevelPercentage;
- float bevelAmount = 0.5 * bevelScale * minDimension;
+ float bevelAmount = 0.5 * std::min( bevelPercentage, minDimension ); //Cap bevel amount if necessary.
+ //Distances from centre to outer edge points.
float outerX = 0.5 * dimensions.x;
float outerY = 0.5 * dimensions.y;
float outerZ = 0.5 * dimensions.z;
- float bevelX = outerX - ( 0.5 * minDimension - bevelAmount );
- float bevelY = outerY - ( 0.5 * minDimension - bevelAmount );
- float bevelZ = outerZ - ( 0.5 * minDimension - bevelAmount );
+ //Distances from centre to bevelled points.
+ float bevelX = outerX - bevelAmount;
+ float bevelY = outerY - bevelAmount;
+ float bevelZ = outerZ - bevelAmount;
Vector<Vector3> positions; //Holds object points, to be shared between vertexes.
positions.Resize( numPositions );
* | %Signal Name | Method | |
* |----------------------|--------------------------------|--------------------|
* | textChanged | @ref TextChangedSignal() | @SINCE_1_1.37 |
- * | inputStyleChanged | @ref InputStyleChangedSignal() | @SINCE_1_2.2 |
+ * | inputStyleChanged | @ref InputStyleChangedSignal() | @SINCE_1_2_2 |
*
*/
class DALI_IMPORT_API TextEditor : public Control
/**
* @brief Mask used by the signal InputStyleChangedSignal(). Notifies which parameters of the input style have changed.
*
- * @SINCE_1_2.2
+ * @SINCE_1_2_2
*/
struct InputStyle
{
enum Mask
{
- NONE = 0x0000, ///< @SINCE_1_2.2
- COLOR = 0x0001, ///< @SINCE_1_2.2
- FONT_FAMILY = 0x0002, ///< @SINCE_1_2.2
- POINT_SIZE = 0x0004, ///< @SINCE_1_2.2
- FONT_STYLE = 0x0008, ///< @SINCE_1_2.2
- LINE_SPACING = 0x0010, ///< @SINCE_1_2.2
- UNDERLINE = 0x0020, ///< @SINCE_1_2.2
- SHADOW = 0x0040, ///< @SINCE_1_2.2
- EMBOSS = 0x0080, ///< @SINCE_1_2.2
- OUTLINE = 0x0100 ///< @SINCE_1_2.2
+ NONE = 0x0000, ///< @SINCE_1_2_2
+ COLOR = 0x0001, ///< @SINCE_1_2_2
+ FONT_FAMILY = 0x0002, ///< @SINCE_1_2_2
+ POINT_SIZE = 0x0004, ///< @SINCE_1_2_2
+ FONT_STYLE = 0x0008, ///< @SINCE_1_2_2
+ LINE_SPACING = 0x0010, ///< @SINCE_1_2_2
+ UNDERLINE = 0x0020, ///< @SINCE_1_2_2
+ SHADOW = 0x0040, ///< @SINCE_1_2_2
+ EMBOSS = 0x0080, ///< @SINCE_1_2_2
+ OUTLINE = 0x0100 ///< @SINCE_1_2_2
};
};
/**
* @brief Input Style changed signal type.
- * @SINCE_1_2.2
+ * @SINCE_1_2_2
*/
typedef Signal<void ( TextEditor, InputStyle::Mask ) > InputStyleChangedSignalType;
* void YourCallbackName( TextEditor textEditor, TextEditor::InputStyle::Mask mask );
* @endcode
*
- * @SINCE_1_2.2
+ * @SINCE_1_2_2
* @return The signal to connect to.
*/
InputStyleChangedSignalType& InputStyleChangedSignal();
* |----------------------|--------------------------------|--------------------|
* | textChanged | @ref TextChangedSignal() | @SINCE_1_0.0 |
* | maxLengthReached | @ref MaxLengthReachedSignal() | @SINCE_1_0.0 |
- * | inputStyleChanged | @ref InputStyleChangedSignal() | @SINCE_1_2.2 |
+ * | inputStyleChanged | @ref InputStyleChangedSignal() | @SINCE_1_2_2 |
*/
class DALI_IMPORT_API TextField : public Control
{
/**
* @brief Mask used by the signal InputStyleChangedSignal(). Notifies which parameters of the input style have changed.
*
- * @SINCE_1_2.2
+ * @SINCE_1_2_2
*/
struct InputStyle
{
enum Mask
{
- NONE = 0x0000, ///< @SINCE_1_2.2
- COLOR = 0x0001, ///< @SINCE_1_2.2
- FONT_FAMILY = 0x0002, ///< @SINCE_1_2.2
- POINT_SIZE = 0x0004, ///< @SINCE_1_2.2
- FONT_STYLE = 0x0008, ///< @SINCE_1_2.2
- UNDERLINE = 0x0010, ///< @SINCE_1_2.2
- SHADOW = 0x0020, ///< @SINCE_1_2.2
- EMBOSS = 0x0040, ///< @SINCE_1_2.2
- OUTLINE = 0x0080 ///< @SINCE_1_2.2
+ NONE = 0x0000, ///< @SINCE_1_2_2
+ COLOR = 0x0001, ///< @SINCE_1_2_2
+ FONT_FAMILY = 0x0002, ///< @SINCE_1_2_2
+ POINT_SIZE = 0x0004, ///< @SINCE_1_2_2
+ FONT_STYLE = 0x0008, ///< @SINCE_1_2_2
+ UNDERLINE = 0x0010, ///< @SINCE_1_2_2
+ SHADOW = 0x0020, ///< @SINCE_1_2_2
+ EMBOSS = 0x0040, ///< @SINCE_1_2_2
+ OUTLINE = 0x0080 ///< @SINCE_1_2_2
};
};
/**
* @brief Input Style changed signal type.
- * @SINCE_1_2.2
+ * @SINCE_1_2_2
*/
typedef Signal<void ( TextField, InputStyle::Mask ) > InputStyleChangedSignalType;
* void YourCallbackName( TextField textField, TextField::InputStyle::Mask mask );
* @endcode
*
- * @SINCE_1_2.2
+ * @SINCE_1_2_2
* @return The signal to connect to.
*/
InputStyleChangedSignalType& InputStyleChangedSignal();
const unsigned int TOOLKIT_MAJOR_VERSION = 1;
const unsigned int TOOLKIT_MINOR_VERSION = 2;
-const unsigned int TOOLKIT_MICRO_VERSION = 3;
+const unsigned int TOOLKIT_MICRO_VERSION = 4;
const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
/**
* @brief The color of the shape.
- * @details Name "shapeColor", type Property::VECTOR4.
- * @SINCE_1_1.45
+ * @details Name "mixColor", type Property::VECTOR4.
+ * @SINCE_1_2_4
* @note Optional. If not specified, the default is Vector4(0.5, 0.5, 0.5, 1.0).
* @note Applies to ALL shapes.
*/
- COLOR,
+ MIX_COLOR,
/**
* @brief The number of slices as you go around the shape.
IMAGE, ///< Renders an image into the control's quad. @SINCE_1_1.45
MESH, ///< Renders a mesh using an "obj" file, optionally with textures provided by an "mtl" file. @SINCE_1_1.45
PRIMITIVE, ///< Renders a simple 3D shape, such as a cube or sphere. @SINCE_1_1.45
- WIREFRAME, ///< Renders a simple wire-frame outlining a quad. @SINCE_1_2.2
+ WIREFRAME, ///< Renders a simple wire-frame outlining a quad. @SINCE_1_2_2
};
namespace Property
{
"styles":
{
- "textlabel":
+ "TextLabel":
{
"pointSize":108,
"enableAutoScroll":false,
"autoScrollSpeed":80
},
- "textlabelFontSize0":
+ "TextLabelFontSize0":
{
"pointSize":84
},
- "textlabelFontSize1":
+ "TextLabelFontSize1":
{
"pointSize":96
},
- "textlabelFontSize2":
+ "TextLabelFontSize2":
{
"pointSize":108
},
- "textlabelFontSize3":
+ "TextLabelFontSize3":
{
"pointSize":120
},
- "textlabelFontSize4":
+ "TextLabelFontSize4":
{
"pointSize":132
},
- "textfield":
+ "TextField":
{
"pointSize":120,
"primaryCursorColor":[0.0,0.72,0.9,1.0],
"selectionHandleImageRight": {"filename":"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_right.png" }
},
- "textfieldFontSize0":
+ "TextFieldFontSize0":
{
"pointSize":120
},
- "textfieldFontSize1":
+ "TextFieldFontSize1":
{
"pointSize":120
},
- "textfieldFontSize2":
+ "TextFieldFontSize2":
{
"pointSize":120
},
- "textfieldFontSize3":
+ "TextFieldFontSize3":
{
"pointSize":120
},
- "textfieldFontSize4":
+ "TextFieldFontSize4":
{
"pointSize":120
},
- "textselectionpopup":
+ "TextSelectionPopup":
{
"popupMaxSize":[1700,100],
"optionDividerSize":[2,0],
"popupFadeInDuration":0.25,
"popupFadeOutDuration":0.25
},
- "textselectionpopupbutton":
+ "TextSelectionPopupButton":
{
"label":
{
"fontStyle":"{\"weight\":\"light\"}"
}
},
- "textselectiontoolbar":
+ "TextSelectionToolbar":
{
"enableOvershoot":true,
"scrollView":
"overshootSize":[1920.0,130.0]
}
},
- "scrollview":
+ "ScrollView":
{
"overshootEffectColor":"B018",
"overshootAnimationSpeed":960.0,
"overshootSize":[1920.0,130.0]
},
- "itemview":
+ "ItemView":
{
"overshootEffectColor":"B018",
"overshootAnimationSpeed":960.0,
"overshootSize":[1920.0,130.0]
},
- "texteditor":
+ "TextEditor":
{
"pointSize":120,
"primaryCursorColor":[0.0,0.72,0.9,1.0],
{
"styles":
{
- "textlabel":
+ "TextLabel":
{
"pointSize":18,
"enableAutoScroll":false,
"autoScrollSpeed":80
},
- "textlabelFontSize0":
+ "TextLabelFontSize0":
{
"pointSize":8
},
- "textlabelFontSize1":
+ "TextLabelFontSize1":
{
"pointSize":10
},
- "textlabelFontSize2":
+ "TextLabelFontSize2":
{
"pointSize":15
},
- "textlabelFontSize3":
+ "TextLabelFontSize3":
{
"pointSize":19
},
- "textlabelFontSize4":
+ "TextLabelFontSize4":
{
"pointSize":25
},
- "radiobutton":
+ "RadioButton":
{
"unselectedStateImage":"{DALI_IMAGE_DIR}radio-button-unselected.png",
"selectedStateImage":"{DALI_IMAGE_DIR}radio-button-selected.png",
"disabledSelectedStateImage":"{DALI_IMAGE_DIR}radio-button-selected-disabled.png"
},
- "textfield":
+ "TextField":
{
"pointSize":18,
"primaryCursorColor":[0.0,0.72,0.9,1.0],
"selectionHandleImageRight": {"filename":"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_right.png" }
},
- "textfieldFontSize0":
+ "TextFieldFontSize0":
{
"pointSize":10
},
- "textfieldFontSize1":
+ "TextFieldFontSize1":
{
"pointSize":10
},
- "textfieldFontSize2":
+ "TextFieldFontSize2":
{
"pointSize":10
},
- "textfieldFontSize3":
+ "TextFieldFontSize3":
{
"pointSize":10
},
- "textfieldFontSize4":
+ "TextFieldFontSize4":
{
"pointSize":10
},
- "textselectionpopup":
+ "TextSelectionPopup":
{
"popupMaxSize":[400,100],
"optionDividerSize":[2,0],
"popupFadeInDuration":0.25,
"popupFadeOutDuration":0.25
},
- "textselectionpopupbutton":
+ "TextSelectionPopupButton":
{
"label":
{
"fontStyle":"{\"weight\":\"light\"}"
}
},
- "textselectiontoolbar":
+ "TextSelectionToolbar":
{
"enableOvershoot":true,
"scrollView":
"overshootSize":[480.0,42.0]
}
},
- "scrollview":
+ "ScrollView":
{
"overshootEffectColor":"B018",
"overshootAnimationSpeed":120.0,
"overshootSize":[480.0,42.0]
},
- "itemview":
+ "ItemView":
{
"overshootEffectColor":"B018",
"overshootAnimationSpeed":120.0,
"overshootSize":[480.0,42.0]
},
- "texteditor":
+ "TextEditor":
{
"pointSize":18,
"primaryCursorColor":[0.0,0.72,0.9,1.0],
"selectionHandleImageLeft" : {"filename":"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_left.png" },
"selectionHandleImageRight": {"filename":"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_right.png" }
},
- "popup":
+ "Popup":
{
"popupBackgroundImage":"{DALI_IMAGE_DIR}00_popup_bg.9.png"
},
- "confirmationpopup":
+ "ConfirmationPopup":
{
"popupBackgroundImage":"{DALI_IMAGE_DIR}00_popup_bg.9.png"
},
- "slider":
+ "Slider":
{
"showPopup": true,
"showValue": true,
{
"styles":
{
- "textlabel":
+ "TextLabel":
{
"pointSize":18,
"enableAutoScroll":false,
"autoScrollSpeed":80
},
- "textlabelFontSize0":
+ "TextLabelFontSize0":
{
"pointSize":8
},
- "textlabelFontSize1":
+ "TextLabelFontSize1":
{
"pointSize":10
},
- "textlabelFontSize2":
+ "TextLabelFontSize2":
{
"pointSize":15
},
- "textlabelFontSize3":
+ "TextLabelFontSize3":
{
"pointSize":19
},
- "textlabelFontSize4":
+ "TextLabelFontSize4":
{
"pointSize":25
},
- "radiobutton":
+ "RadioButton":
{
"unselectedStateImage":"{DALI_IMAGE_DIR}radio-button-unselected.png",
"selectedStateImage":"{DALI_IMAGE_DIR}radio-button-selected.png",
"disabledSelectedStateImage":"{DALI_IMAGE_DIR}radio-button-selected-disabled.png"
},
- "textfield":
+ "TextField":
{
"pointSize":18,
"primaryCursorColor":[0.0,0.72,0.9,1.0],
"selectionHandleImageRight": {"filename":"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_right.png" }
},
- "textfieldFontSize0":
+ "TextFieldFontSize0":
{
"pointSize":10
},
- "textfieldFontSize1":
+ "TextFieldFontSize1":
{
"pointSize":10
},
- "textfieldFontSize2":
+ "TextFieldFontSize2":
{
"pointSize":10
},
- "textfieldFontSize3":
+ "TextFieldFontSize3":
{
"pointSize":10
},
- "textfieldFontSize4":
+ "TextFieldFontSize4":
{
"pointSize":10
},
- "textselectionpopup":
+ "TextSelectionPopup":
{
"popupMaxSize":[656,72],
"optionDividerSize":[2,0],
"popupFadeInDuration":0.25,
"popupFadeOutDuration":0.25
},
- "textselectionpopupbutton":
+ "TextSelectionPopupButton":
{
"label":
{
"fontStyle":"{\"weight\":\"light\"}"
}
},
- "textselectiontoolbar":
+ "TextSelectionToolbar":
{
"enableOvershoot":true,
"scrollView":
"overshootSize":[720.0,130.0]
}
},
- "scrollview":
+ "ScrollView":
{
"overshootEffectColor":"B018",
"overshootAnimationSpeed":360.0,
"overshootSize":[720.0,130.0]
},
- "itemview":
+ "ItemView":
{
"overshootEffectColor":"B018",
"overshootAnimationSpeed":360.0,
"overshootSize":[720.0,130.0]
},
- "texteditor":
+ "TextEditor":
{
"pointSize":18,
"primaryCursorColor":[0.0,0.72,0.9,1.0],
"selectionHandleImageLeft" : {"filename":"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_left.png" },
"selectionHandleImageRight": {"filename":"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_right.png" }
},
- "popup":
+ "Popup":
{
"popupBackgroundImage":"{DALI_IMAGE_DIR}00_popup_bg.9.png"
},
- "confirmationpopup":
+ "ConfirmationPopup":
{
"popupBackgroundImage":"{DALI_IMAGE_DIR}00_popup_bg.9.png"
},
- "slider":
+ "Slider":
{
"showPopup": true,
"showValue": true,
| Property | String | Type | Description | Default Value | Range |
|---------------------------------------------------------------|-------------------|:------------------:|-----------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------:|:------------------------------:|
| Dali::Toolkit::PrimitiveVisual::Property::SHAPE | shape | INTEGER or STRING | The specific shape to render. [More info](@ref shape-details) | Dali::Toolkit::PrimitiveVisual::Shape::SPHERE, "SPHERE" | [See list](@ref shape-details) |
-| Dali::Toolkit::PrimitiveVisual::Property::COLOR | shapeColor | VECTOR4 | The color of the shape. | (0.5, 0.5, 0.5, 1.0) | 0.0 - 1.0 for each |
+| Dali::Toolkit::PrimitiveVisual::Property::MIX_COLOR | mixColor | VECTOR4 | The color of the shape. | (0.5, 0.5, 0.5, 1.0) | 0.0 - 1.0 for each |
| Dali::Toolkit::PrimitiveVisual::Property::SLICES | slices | INTEGER | The number of slices as you go around the shape. [More info](@ref slices-details) | 128 | 1 - 255 |
| Dali::Toolkit::PrimitiveVisual::Property::STACKS | stacks | INTEGER | The number of stacks as you go down the shape. [More info](@ref stacks-details) | 128 | 1 - 255 |
| Dali::Toolkit::PrimitiveVisual::Property::SCALE_TOP_RADIUS | scaleTopRadius | FLOAT | The scale of the radius of the top circle of a conical frustrum. | 1.0 | ≥ 0.0 |
map[ Visual::Property::TYPE ] = Dali::Toolkit::Visual::PRIMITIVE;
map[ PrimitiveVisual::Property::SHAPE ] = PrimitiveVisual::Shape::SPHERE;
-map[ PrimitiveVisual::Property::COLOR ] = Vector4( 1.0, 0.5, 0.0, 1.0 );
+map[ PrimitiveVisual::Property::MIX_COLOR ] = Vector4( 1.0, 0.5, 0.0, 1.0 );
control.SetProperty( Control::Property::BACKGROUND, map );
~~~
map[ Visual::Property::TYPE ] = Dali::Toolkit::Visual::PRIMITIVE;
map[ PrimitiveVisual::Property::SHAPE ] = PrimitiveVisual::Shape::CONICAL_FRUSTRUM;
-map[ PrimitiveVisual::Property::COLOR ] = Vector4( 1.0, 0.5, 0.0, 1.0 );
+map[ PrimitiveVisual::Property::MIX_COLOR ] = Vector4( 1.0, 0.5, 0.0, 1.0 );
map[ PrimitiveVisual::Property::SCALE_TOP_RADIUS ] = 1.0f;
map[ PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS ] = 1.5f;
map[ PrimitiveVisual::Property::SCALE_HEIGHT ] = 3.0f;
map[ Visual::Property::TYPE ] = Dali::Toolkit::Visual::PRIMITIVE;
map[ PrimitiveVisual::Property::SHAPE ] = PrimitiveVisual::Shape::BEVELLED_CUBE;
-map[ PrimitiveVisual::Property::COLOR ] = Vector4( 1.0, 0.5, 0.0, 1.0 );
+map[ PrimitiveVisual::Property::MIX_COLOR ] = Vector4( 1.0, 0.5, 0.0, 1.0 );
map[ PrimitiveVisual::Property::BEVEL_PERCENTAGE ] = 0.4f;
control.SetProperty( Control::Property::BACKGROUND, map );
Name: dali-addon
Summary: DALi module for Node.JS
-Version: 1.2.3
+Version: 1.2.4
Release: 1
Group: Development/Libraries
License: Apache License, Version 2.0
Name: dali-toolkit
Summary: The OpenGLES Canvas Core Library Toolkit
-Version: 1.2.3
+Version: 1.2.4
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-2-Clause and MIT