From: Adeel Kazmi Date: Tue, 26 May 2015 18:27:42 +0000 (-0700) Subject: Merge "Empty Implementation for INPUT_METHOD_SETTINGS property" into tizen X-Git-Tag: accepted/tizen/common/20150529.134100~3 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=7c5cd5665d3b4648fed0a8b0a67522cdb48885cf;hp=6f556d60d4e7d21da0ee48c0a015e570db15ad60 Merge "Empty Implementation for INPUT_METHOD_SETTINGS property" into tizen --- diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp index 47a13ec..3223daa 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp @@ -204,17 +204,16 @@ int UtcDaliControlKeyInputFocus(void) END_TEST; } -int UtcDaliControlGetImplementation(void) +int UtcDaliControlGetImplementationN(void) { ToolkitTestApplication application; - DummyControl control; // Get Empty { try { - Toolkit::Internal::Control& controlImpl = control.GetImplementation(); + Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( control ); (void)controlImpl; // Avoid unused warning tet_result(TET_FAIL); } @@ -223,13 +222,20 @@ int UtcDaliControlGetImplementation(void) tet_result(TET_PASS); } } + END_TEST; +} + +int UtcDaliControlGetImplementationConstN(void) +{ + ToolkitTestApplication application; + DummyControl control; // Get Const Empty { try { const DummyControl constControl(control); - const Toolkit::Internal::Control& controlImpl = constControl.GetImplementation(); + const Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( constControl ); (void)controlImpl; // Avoid unused warning tet_result(TET_FAIL); } @@ -238,14 +244,19 @@ int UtcDaliControlGetImplementation(void) tet_result(TET_PASS); } } + END_TEST; +} - control = DummyControl::New(); +int UtcDaliControlGetImplementationP(void) +{ + ToolkitTestApplication application; + DummyControl control = DummyControl::New(); // Get { try { - Toolkit::Internal::Control& controlImpl = control.GetImplementation(); + Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( control ); (void)controlImpl; // Avoid unused warning tet_result(TET_PASS); } @@ -254,13 +265,19 @@ int UtcDaliControlGetImplementation(void) tet_result(TET_FAIL); } } + END_TEST; +} +int UtcDaliControlGetImplementationConstP(void) +{ + ToolkitTestApplication application; + DummyControl control = DummyControl::New(); // Get Const { try { const DummyControl constControl(control); - const Toolkit::Internal::Control& controlImpl = constControl.GetImplementation(); + const Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( constControl ); (void)controlImpl; // Avoid unused warning tet_result(TET_PASS); } @@ -281,7 +298,7 @@ int UtcDaliControlSignalConnectDisconnect(void) Actor actor = Actor::New(); DALI_TEST_EQUALS( actor.OnStageSignal().GetConnectionCount(), 0u, TEST_LOCATION ); - Toolkit::Internal::Control& control = dummy.GetImplementation(); + Toolkit::Internal::Control& control = Toolkit::Internal::GetImplementation( dummy ); DummyControlImpl* dummyImpl = dynamic_cast(&control); DALI_TEST_CHECK( dummyImpl ); @@ -310,7 +327,7 @@ int UtcDaliControlSignalAutomaticDisconnect(void) { DummyControl dummy = DummyControlImpl::New(); - Toolkit::Internal::Control& control = dummy.GetImplementation(); + Toolkit::Internal::Control& control = Toolkit::Internal::GetImplementation( dummy ); DummyControlImpl* dummyImpl = dynamic_cast(&control); DALI_TEST_CHECK( dummyImpl ); @@ -362,11 +379,9 @@ int UtcDaliControlBackgroundColor(void) ToolkitTestApplication application; Control control = Control::New(); - DALI_TEST_CHECK( !control.GetBackgroundActor() ); DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::TRANSPARENT, TEST_LOCATION ); control.SetBackgroundColor( Color::RED ); - DALI_TEST_CHECK( control.GetBackgroundActor() ); DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::RED, TEST_LOCATION ); END_TEST; @@ -377,24 +392,20 @@ int UtcDaliControlBackgroundImage(void) ToolkitTestApplication application; Control control = Control::New(); - DALI_TEST_CHECK( !control.GetBackgroundActor() ); DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::TRANSPARENT, TEST_LOCATION ); Image image = ResourceImage::New("TestImage"); control.SetBackgroundImage( image ); - DALI_TEST_CHECK( control.GetBackgroundActor() ); DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::WHITE, TEST_LOCATION ); control.SetBackgroundColor( Color::GREEN ); DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::GREEN, TEST_LOCATION ); control.ClearBackground(); - DALI_TEST_CHECK( !control.GetBackgroundActor() ); DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::TRANSPARENT, TEST_LOCATION ); control.SetBackgroundColor( Color::YELLOW ); control.SetBackgroundImage( image ); - DALI_TEST_CHECK( control.GetBackgroundActor() ); DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::YELLOW, TEST_LOCATION ); END_TEST; @@ -405,13 +416,13 @@ int UtcDaliControlBackgroundProperties(void) ToolkitTestApplication application; Control control = Control::New(); - DALI_TEST_CHECK( !control.GetBackgroundActor() ); + DALI_TEST_CHECK( control.GetChildCount() == 0 ); DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::TRANSPARENT, TEST_LOCATION ); DALI_TEST_EQUALS( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >(), Color::TRANSPARENT, TEST_LOCATION ); DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND_IMAGE ).Get< Property::Map >().Empty() ); control.SetProperty( Control::Property::BACKGROUND_COLOR, Color::RED ); - DALI_TEST_CHECK( control.GetBackgroundActor() ); + DALI_TEST_CHECK( control.GetChildCount() > 0 ); DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::RED, TEST_LOCATION ); DALI_TEST_EQUALS( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >(), Color::RED, TEST_LOCATION ); @@ -420,7 +431,7 @@ int UtcDaliControlBackgroundProperties(void) Property::Map map; map[ "image" ] = imageMap; control.SetProperty( Control::Property::BACKGROUND_IMAGE, map ); - DALI_TEST_CHECK( control.GetBackgroundActor() ); + DALI_TEST_CHECK( control.GetChildCount() > 0 ); DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::RED, TEST_LOCATION ); DALI_TEST_EQUALS( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >(), Color::RED, TEST_LOCATION ); @@ -431,7 +442,7 @@ int UtcDaliControlBackgroundProperties(void) Property::Map emptyMap; control.SetProperty( Control::Property::BACKGROUND_IMAGE, emptyMap ); - DALI_TEST_CHECK( !control.GetBackgroundActor() ); + DALI_TEST_CHECK( control.GetChildCount() == 0 ); DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::TRANSPARENT, TEST_LOCATION ); DALI_TEST_EQUALS( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >(), Color::TRANSPARENT, TEST_LOCATION ); DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND_IMAGE ).Get< Property::Map >().Empty() ); @@ -531,3 +542,15 @@ int UtcDaliControlImplKeyInputFocusLostSignal(void) END_TEST; } + +int UtcDaliControlImplGetControlExtensionP(void) +{ + ToolkitTestApplication application; + Control control = Control::New(); + + Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( control ); + + DALI_TEST_CHECK( NULL == controlImpl.GetControlExtension() ); + + END_TEST; +} diff --git a/automated-tests/src/dali-toolkit/utc-Dali-FocusManager.cpp b/automated-tests/src/dali-toolkit/utc-Dali-FocusManager.cpp index ae74364..b26edb0 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-FocusManager.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-FocusManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2015 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. @@ -114,6 +114,20 @@ public: Toolkit::FocusManager::FocusOvershotDirection mFocusOvershotDirection; }; +// Functor to test whether focused actor activated signal is emitted. +class FocusedActorActivatedCallback : public Dali::ConnectionTracker +{ +public: + FocusedActorActivatedCallback() + { + } + + void Callback(Actor activatedActor) + { + tet_infoline("Verifying FocusedActorActivatedCallback()"); + } +}; + } // namespace @@ -1051,3 +1065,19 @@ int UtcDaliFocusManagerSignalFocusOvershot(void) DALI_TEST_CHECK(signalVerified); END_TEST; } + +int UtcDaliFocusManagerSignalFocusedActorActivated(void) +{ + ToolkitTestApplication application; + + tet_infoline(" UtcDaliFocusManagerSignalFocusedActorActivated"); + + FocusManager manager = FocusManager::Get(); + DALI_TEST_CHECK(manager); + + FocusedActorActivatedCallback callback; + manager.FocusedActorActivatedSignal().Connect(&callback, &FocusedActorActivatedCallback::Callback); + DALI_TEST_CHECK(true); + + END_TEST; +} diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ItemLayout.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ItemLayout.cpp index d9e52fd..8dd9e24 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ItemLayout.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ItemLayout.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2015 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. @@ -47,6 +47,13 @@ public: { } + /** + * Virtual destructor. + */ + virtual ~TestItemFactory() + { + } + public: // From ItemFactory /** @@ -72,6 +79,186 @@ public: // From ItemFactory return actor; } }; + +class TestItemLayout; + +typedef IntrusivePtr TestItemLayoutPtr; + +// Implementation of ItemLayout +class TestItemLayout : public ItemLayout +{ +public: + + /** + * Constructor + */ + TestItemLayout() + { + } + + /** + * Virtual destructor. + */ + virtual ~TestItemLayout() + { + } + + /** + * Create a new grid layout. + */ + static TestItemLayoutPtr New() + { + return TestItemLayoutPtr(new TestItemLayout()); + } + +public: // From ItemLayout + + /** + * Query the minimum valid layout position; this is a negative value. + * + * When scrolling, the first item will move within the range 0 to GetMinimumLayoutPosition(). + * @param[in] numberOfItems The current number of items in the layout. + * @param[in] layoutSize The size of the layout area. + * @return The minimum layout position. + */ + virtual float GetMinimumLayoutPosition(unsigned int numberOfItems, Vector3 layoutSize) const + { + return 0.0f; + } + + /** + * Query the closest anchor position for the given layout position. + * + * This anchor position is the position where all the items in the layout are aligned to + * their rounded layout positions in integer. + * @param[in] layoutPosition The layout position. + * @return The closest anchor position for the given layout position. + */ + virtual float GetClosestAnchorPosition(float layoutPosition) const + { + return 0.0f; + } + + /** + * Query the layout position for the first item in the layout to move to when the layout + * needs to scroll to a particular item. + * + * @param[in] itemId The ID of an item in the layout. + * @return The layout position for the first item in the layout to move to. + */ + virtual float GetItemScrollToPosition(unsigned int itemId) const + { + return 0.0f; + } + + /** + * Query the items within a given layout-area. + * + * @param[in] firstItemPosition The layout-position of the first item in the layout. + * @param[in] layoutSize The size of the layout area. + * @return The ID of the first & last visible item. + */ + virtual ItemRange GetItemsWithinArea(float firstItemPosition, Vector3 layoutSize) const + { + return ItemRange(0, 10); + } + + /** + * Query the number of items that should be reserved, for scrolling purposes. + * + * @param[in] layoutSize The size of the layout area. + * @return The number of extra items. + */ + virtual unsigned int GetReserveItemCount(Vector3 layoutSize) const + { + return 0; + } + + /** + * Retrieve the default size of an item in the layout. + * + * @param[in] itemId The ID of an item in the layout. + * @param[in] layoutSize The layout size + * @param[out] itemSize The target size of an item. + */ + virtual void GetDefaultItemSize( unsigned int itemId, const Vector3& layoutSize, Vector3& itemSize ) const + { + } + + /** + * Retrieve the resize animation in the layout. + * + * @param[in] animation The resize animation, not owned by the layout + * @param[in] actor The actor to animate + * @param [in] size The target size. + * @param [in] durationSeconds The duration of the resizing. + */ + virtual void GetResizeAnimation(Animation& animation, Actor actor, Vector3 size, float durationSeconds) const + { + } + + /** + * @brief Query the scroll direction of the layout. + * @return The scroll direction in degrees. + */ + virtual Degree GetScrollDirection() const + { + return Degree( 0.0f ); + } + + /** + * @brief Query the scroll speed factor of the layout while dragging. + * @return The scroll speed factor of the layout. + */ + virtual float GetScrollSpeedFactor() const + { + return 0; + } + + /** + * @brief Query the maximum swipe speed in pixels per second. + * @return speed The maximum swipe speed. + */ + virtual float GetMaximumSwipeSpeed() const + { + return 0; + } + + /** + * @brief Get the duration of the flick animation in second. + * @return The duration of the flick animation. + */ + virtual float GetItemFlickAnimationDuration() const + { + return 0; + } + + /* + * @brief Applies constraints defined by the layout to an actor. + * + * @param[in] actor The actor to constrain. + * @param[in] itemId The ID of the item represented by the actor. + * @param[in] layoutSize the current size of the item view instance. + * @param[in] itemViewActor The item view instance which requests the application of constraints. + */ + virtual void ApplyConstraints( Actor& actor, const int itemId, const Vector3& layoutSize, const Actor& itemViewActor ) + { + } + + /** + * @brief Gets the position of a given item + * + * @param[in] itemID id of the item we want to get its position + * @param[in] currentLayoutPosition the current layout position of the item view instance + * @param[in] layoutSize the current size of the item view instance + * @return The item position (x,y,z) + */ + virtual Vector3 GetItemPosition(int itemID, float currentLayoutPosition, const Vector3& layoutSize) const + { + return Vector3::ZERO; + } +}; + } // namespace int UtcDaliItemLayoutSetAndGetOrientation(void) @@ -135,3 +322,39 @@ int UtcDaliItemLayoutSetAndGetOrientation(void) DALI_TEST_CHECK(spiralLayout == layout); END_TEST; } + +int UtcDaliItemLayoutGetExtension(void) +{ + ToolkitTestApplication application; + + ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID ); + DALI_TEST_CHECK( gridLayout ); + DALI_TEST_CHECK( !gridLayout->GetExtension() ); + + END_TEST; +} + +int UtcDaliItemLayoutGetClosestOnScreenLayoutPosition(void) +{ + ToolkitTestApplication application; + + TestItemLayoutPtr layout = TestItemLayout::New(); + DALI_TEST_CHECK( layout ); + DALI_TEST_EQUALS(layout->GetClosestOnScreenLayoutPosition(0, 0.0f, Vector3::ZERO), 0.0f, TEST_LOCATION ); + DALI_TEST_EQUALS(layout->GetClosestOnScreenLayoutPosition(0, 0.0f, Vector3(-800.0f, -1200.0f, 0.0f)), 0.0f, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliItemLayoutGetNextFocusItemID(void) +{ + ToolkitTestApplication application; + + TestItemLayoutPtr layout = TestItemLayout::New(); + DALI_TEST_CHECK( layout ); + DALI_TEST_EQUALS(layout->GetNextFocusItemID(0, 100, Control::Left, true), 99, TEST_LOCATION ); + DALI_TEST_EQUALS(layout->GetNextFocusItemID(110, 100, Control::Right, true), 0, TEST_LOCATION ); + + END_TEST; +} + diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp index fd01efe..6d38d5e 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp @@ -685,6 +685,9 @@ int UtcDaliToolkitScrollViewSetWrapModeP(void) ScrollView scrollView = ScrollView::New(); Stage::GetCurrent().Add( scrollView ); + Actor actor = Actor::New(); + scrollView.Add( actor ); + // Position rulers. 4x4 grid. RulerPtr rulerX = new FixedRuler(50.0f); RulerPtr rulerY = new FixedRuler(50.0f); @@ -697,7 +700,10 @@ int UtcDaliToolkitScrollViewSetWrapModeP(void) scrollView.ScrollTo(Vector2(225.0f, 125.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped) Wait(application); DALI_TEST_EQUALS( static_cast(scrollView.GetCurrentPage()), 17, TEST_LOCATION ); + scrollView.SetWrapMode(true); + scrollView.ScrollTo(Vector2(230.0f, 130.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped) + Wait(application); DALI_TEST_EQUALS( static_cast(scrollView.GetCurrentPage()), 13, TEST_LOCATION ); END_TEST; } @@ -2006,6 +2012,18 @@ int UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP(void) position = rulerNormal->GetPositionFromPage(2, volume, true); DALI_TEST_EQUALS( position, 60.0f, TEST_LOCATION ); DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION ); + + // Disable the ruler + rulerNormal->Disable(); + + position = rulerNormal->GetPositionFromPage(1, volume, true); + DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( volume, 1u, TEST_LOCATION ); + + position = rulerNormal->GetPositionFromPage(2, volume, true); + DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( volume, 2u, TEST_LOCATION ); + END_TEST; } @@ -2103,6 +2121,21 @@ int UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP(void) DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION); DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION); + // Set domain size to be smaller than the ruler space + fixedRuler->SetDomain( RulerDomain(0.0f, 50.0f, true) ); + + fixedRuler->Enable(); + DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION); + + fixedRuler->Disable(); + DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 0u, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION); + DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION); + END_TEST; } diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TableView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TableView.cpp index 30f0cda..8e6bffa 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TableView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TableView.cpp @@ -438,6 +438,10 @@ int UtcDaliTableViewCells(void) tableView.AddChild(actor1, TableView::CellPosition(110, 110, 5, 5)); DALI_TEST_CHECK( tableView.GetRows() == 115 && tableView.GetColumns() == 115 ); + // Set the alignment of the cell + tableView.SetCellAlignment( TableView::CellPosition(100, 100, 1, 1), HorizontalAlignment::CENTER, VerticalAlignment::CENTER ); + tableView.SetCellAlignment( TableView::CellPosition(110, 110, 5, 5), HorizontalAlignment::LEFT, VerticalAlignment::TOP ); + DALI_TEST_CHECK( true ); END_TEST; } diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextSelectionPopup.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextSelectionPopup.cpp index d4914f5..b248e01 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextSelectionPopup.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextSelectionPopup.cpp @@ -19,6 +19,7 @@ #include #include #include +#include using namespace Dali; using namespace Toolkit; diff --git a/build/tizen/dali-toolkit/Makefile.am b/build/tizen/dali-toolkit/Makefile.am index 2165644..0614d96 100644 --- a/build/tizen/dali-toolkit/Makefile.am +++ b/build/tizen/dali-toolkit/Makefile.am @@ -126,7 +126,6 @@ publicapialignmentdir = $(publicapicontrolsdir)/alignment publicapibuttonsdir = $(publicapicontrolsdir)/buttons publicapidefaultcontrolsdir = $(publicapicontrolsdir)/default-controls publicapigaussianblurviewdir = $(publicapicontrolsdir)/gaussian-blur-view -publicapiimageviewdir = $(publicapicontrolsdir)/image-view publicapiscrollbardir = $(publicapicontrolsdir)/scroll-bar publicapiscrollabledir = $(publicapicontrolsdir)/scrollable publicapiscrollviewdir = $(publicapicontrolsdir)/scrollable/scroll-view @@ -143,7 +142,6 @@ publicapialignment_HEADERS = $(public_api_alignment_header_files) publicapibuttons_HEADERS = $(public_api_buttons_header_files) publicapidefaultcontrols_HEADERS = $(public_api_default_controls_header_files) publicapigaussianblurview_HEADERS = $(public_api_gaussian_blur_view_header_files) -publicapiimageview_HEADERS = $(public_api_image_view_header_files) publicapiitemview_HEADERS = $(public_api_item_view_header_files) publicapiscrollbar_HEADERS = $(public_api_scroll_bar_header_files) publicapiscrollable_HEADERS = $(public_api_scrollable_header_files) diff --git a/dali-toolkit/dali-toolkit.h b/dali-toolkit/dali-toolkit.h index eeeaa44..5fc233b 100644 --- a/dali-toolkit/dali-toolkit.h +++ b/dali-toolkit/dali-toolkit.h @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -44,7 +43,6 @@ #include #include #include -#include #include #include #include diff --git a/dali-toolkit/public-api/controls/text-controls/text-selection-popup.cpp b/dali-toolkit/devel-api/controls/text-controls/text-selection-popup.cpp similarity index 95% rename from dali-toolkit/public-api/controls/text-controls/text-selection-popup.cpp rename to dali-toolkit/devel-api/controls/text-controls/text-selection-popup.cpp index 4c55375..f41f667 100644 --- a/dali-toolkit/public-api/controls/text-controls/text-selection-popup.cpp +++ b/dali-toolkit/devel-api/controls/text-controls/text-selection-popup.cpp @@ -16,7 +16,7 @@ */ // CLASS HEADER -#include +#include // INTERNAL INCLUDES #include diff --git a/dali-toolkit/public-api/controls/text-controls/text-selection-popup.h b/dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h similarity index 100% rename from dali-toolkit/public-api/controls/text-controls/text-selection-popup.h rename to dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h diff --git a/dali-toolkit/devel-api/file.list b/dali-toolkit/devel-api/file.list index 5e0a8ff..7a940c1 100755 --- a/dali-toolkit/devel-api/file.list +++ b/dali-toolkit/devel-api/file.list @@ -16,6 +16,7 @@ devel_api_src_files = \ $(devel_api_src_dir)/controls/shadow-view/shadow-view.cpp \ $(devel_api_src_dir)/controls/slider/slider.cpp \ $(devel_api_src_dir)/controls/super-blur-view/super-blur-view.cpp \ + $(devel_api_src_dir)/controls/text-controls/text-selection-popup.cpp \ $(devel_api_src_dir)/controls/tool-bar/tool-bar.cpp \ $(devel_api_src_dir)/styling/style-manager.cpp \ $(devel_api_src_dir)/scripting/script.cpp \ @@ -132,6 +133,9 @@ devel_api_shader_effects_header_files = \ devel_api_super_blur_view_header_files = \ $(devel_api_src_dir)/controls/super-blur-view/super-blur-view.h +devel_api_text_selection_popup_header_files = \ + $(devel_api_src_dir)/controls/text-controls/text-selection-popup.h + devel_api_tool_bar_header_files = \ $(devel_api_src_dir)/controls/tool-bar/tool-bar.h diff --git a/dali-toolkit/internal/controls/image-view/masked-image-view-impl.cpp b/dali-toolkit/internal/controls/image-view/masked-image-view-impl.cpp deleted file mode 100644 index 97c4053..0000000 --- a/dali-toolkit/internal/controls/image-view/masked-image-view-impl.cpp +++ /dev/null @@ -1,651 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// CLASS HEADER -#include - -// EXTERNAL INCLUDES -#include -#include -#include -#include -#include -#include - -namespace Dali -{ - -namespace Toolkit -{ - -namespace Internal -{ - -namespace // unnamed namespace -{ - -const char* CUSTOM_PROPERTY_NAMES[ Dali::Toolkit::MaskedImageView::CUSTOM_PROPERTY_COUNT ] = -{ - "background-color", - "source-size", - "source-offset", - "mask-size", - "mask-offset" -}; - -const char* const MASKED_IMAGE_VIEW_VERTEX_SOURCE = - "precision mediump float; \n" - "uniform vec2 uTargetSize; \n" - "uniform vec2 uSourceSize; \n" - "uniform vec2 uSourceOffset; \n" - "uniform vec2 uMaskSize; \n" - "uniform vec2 uMaskOffset; \n" - "varying vec2 vMaskTexCoord; \n" - "void main() \n" - "{ \n" - " float x = uSourceSize.x*aPosition.x + uSourceOffset.x; \n" - " float y = uSourceSize.y*aPosition.y + uSourceOffset.y; \n" - " \n" - " gl_Position = vec4( x/(uTargetSize.x*0.5), y/(uTargetSize.y*0.5), 0.0, 1.0 ); \n" - " \n" - " vMaskTexCoord.x = (uMaskSize.x*0.5 + x - uMaskOffset.x) / uMaskSize.x; \n" - " vMaskTexCoord.y = (uMaskSize.y*0.5 + y - uMaskOffset.y) / uMaskSize.y; \n"; - -const char* const MASKED_IMAGE_VIEW_VERTEX_SOURCE_ROTATE0 = - " \n" - " vTexCoord = aTexCoord; \n" - "}"; - -const char* const MASKED_IMAGE_VIEW_VERTEX_SOURCE_ROTATE90 = - " \n" - " vTexCoord.x = aTexCoord.y; \n" - " vTexCoord.y = 1.0 - aTexCoord.x; \n" - "}"; - -const char* const MASKED_IMAGE_VIEW_VERTEX_SOURCE_ROTATE180 = - " \n" - " vTexCoord.x = 1.0 - aTexCoord.x; \n" - " vTexCoord.y = 1.0 - aTexCoord.y; \n" - "}"; - -const char* const MASKED_IMAGE_VIEW_VERTEX_SOURCE_ROTATE270 = - " \n" - " vTexCoord.x = 1.0 - aTexCoord.y; \n" - " vTexCoord.y = aTexCoord.x; \n" - "}"; - -const char* const MASKED_IMAGE_VIEW_FRAGMENT_SOURCE = - "precision mediump float; \n" - "varying vec2 vMaskTexCoord; \n" - "void main() \n" - "{ \n" - " highp vec4 mask = texture2D(sEffect, vMaskTexCoord); \n" - " gl_FragColor = texture2D(sTexture, vTexCoord) * vec4(1,1,1,mask.a); \n" - "}"; - -Vector2 GetSizeForAspectRatio( const Vector2& targetSize, float aspectRatio ) -{ - Vector2 sizeToKeepAspectRatio( targetSize ); - - float targetAspectRatio( targetSize.width / targetSize.height ); - - if( aspectRatio > targetAspectRatio ) - { - sizeToKeepAspectRatio.width = sizeToKeepAspectRatio.height * aspectRatio; - } - else if ( aspectRatio < targetAspectRatio ) - { - sizeToKeepAspectRatio.height = sizeToKeepAspectRatio.width / aspectRatio; - } - - return sizeToKeepAspectRatio; -} - -Vector2 ClampSourceSize( const Vector2& sourceSize, const Vector2& targetSize, float widthOverHeight, float maxSourceScale ) -{ - Vector2 clampedSize( sourceSize ); - - Vector2 minSize( targetSize ); - if ( widthOverHeight > 0.0f ) - { - minSize = GetSizeForAspectRatio( targetSize, widthOverHeight ); - } - - if ( clampedSize.width < minSize.width || - clampedSize.height < minSize.height ) - { - clampedSize = minSize; - } - else if ( clampedSize.width > minSize.width *maxSourceScale || - clampedSize.height > minSize.height*maxSourceScale ) - { - clampedSize = minSize * maxSourceScale; - } - - return clampedSize; -} - -Vector2 ClampSourceOffset( const Vector2& sourceOffset, const Vector2& targetSize, const Vector2& sourceSize ) -{ - Vector2 min, max; - - if ( sourceSize.width > targetSize.width ) - { - float offset = (sourceSize.width - targetSize.width) * 0.5f; - min.x = -offset; - max.x = offset; - } - - if ( sourceSize.height > targetSize.height ) - { - float offset = (sourceSize.height - targetSize.height) * 0.5f; - min.y = -offset; - max.y = offset; - } - - return Vector2( Clamp(sourceOffset.x, min.x, max.x), Clamp(sourceOffset.y, min.y, max.y) ); -} - -} // unnamed namespace - -Dali::Toolkit::MaskedImageView MaskedImageView::New( unsigned int targetWidth, - unsigned int targetHeight, - Image sourceImage, - Image maskImage ) -{ - // Create the implementation - MaskedImageView* maskedImageView = new MaskedImageView(); - - // Pass ownership to CustomActor via derived handle - Dali::Toolkit::MaskedImageView handle(*maskedImageView); - - // Second-phase init of the implementation - // This can only be done after the CustomActor connection has been made... - maskedImageView->Initialize( targetWidth, targetHeight, sourceImage, maskImage ); - - return handle; -} - -void MaskedImageView::SetSourceImage( Image sourceImage ) -{ - mSourceImageActor.SetImage( sourceImage ); -} - -Image MaskedImageView::GetSourceImage() -{ - return mSourceImageActor.GetImage(); -} - -void MaskedImageView::SetMaskImage( Image maskImage ) -{ - mMaskImage = maskImage; - mSourceImageActor.GetShaderEffect().SetEffectImage( maskImage ); -} - -Image MaskedImageView::GetMaskImage() -{ - return mMaskImage; -} - -Property::Index MaskedImageView::GetPropertyIndex( Dali::Toolkit::MaskedImageView::CustomProperty customProperty ) const -{ - Property::Index index = Property::INVALID_INDEX; - - switch ( customProperty ) - { - case Dali::Toolkit::MaskedImageView::BACKGROUND_COLOR: - { - index = mCustomProperties[ Dali::Toolkit::MaskedImageView::BACKGROUND_COLOR ]; - break; - } - - case Dali::Toolkit::MaskedImageView::SOURCE_SIZE: - { - index = mCustomProperties[ Dali::Toolkit::MaskedImageView::SOURCE_SIZE ]; - break; - } - - case Dali::Toolkit::MaskedImageView::SOURCE_OFFSET: - { - index = mCustomProperties[ Dali::Toolkit::MaskedImageView::SOURCE_OFFSET ]; - break; - } - - case Dali::Toolkit::MaskedImageView::MASK_SIZE: - { - index = mCustomProperties[ Dali::Toolkit::MaskedImageView::MASK_SIZE ]; - break; - } - - case Dali::Toolkit::MaskedImageView::MASK_OFFSET: - { - index = mCustomProperties[ Dali::Toolkit::MaskedImageView::MASK_OFFSET ]; - break; - } - - default: - break; - } - - return index; -} - -void MaskedImageView::Pause() -{ - if ( mRenderTask ) - { - mRenderTask.SetRefreshRate( RenderTask::REFRESH_ONCE ); - } -} - -void MaskedImageView::Resume() -{ - if ( mRenderTask ) - { - mRenderTask.SetRefreshRate( RenderTask::REFRESH_ALWAYS ); - } -} - -bool MaskedImageView::IsPaused() const -{ - if( mRenderTask.GetRefreshRate() ) // REFRESH_ALWAYS - { - return false; - } - else // REFRESH_ONCE - { - return true; - } -} - -void MaskedImageView::SetEditMode( Dali::Toolkit::MaskedImageView::EditMode editMode ) -{ - Actor self = Self(); - - mEditMode = editMode; - - if ( Dali::Toolkit::MaskedImageView::EDIT_DISABLED == editMode ) - { - if ( mPanGestureDetector ) - { - mPanGestureDetector.DetachAll(); - mPanGestureDetector.Reset(); - } - - if ( mPinchDetector ) - { - mPinchDetector.DetachAll(); - mPinchDetector.Reset(); - } - } - else - { - if ( !mPanGestureDetector ) - { - mPanGestureDetector = PanGestureDetector::New(); - mPanGestureDetector.Attach( self ); - mPanGestureDetector.DetectedSignal().Connect(this, &MaskedImageView::OnPan); - } - - if ( !mPinchDetector ) - { - mPinchDetector = PinchGestureDetector::New(); - mPinchDetector.Attach( self ); - mPinchDetector.DetectedSignal().Connect(this, &MaskedImageView::OnPinch); - } - - if( Dali::Toolkit::MaskedImageView::EDIT_SOURCE == editMode ) - { - // Re-clamp values to preserve image aspect-ratio etc. - ClampSourceSizeAndOffset(); - } - } -} - -Dali::Toolkit::MaskedImageView::EditMode MaskedImageView::GetEditMode() const -{ - return mEditMode; -} - -void MaskedImageView::OnPropertySet( Property::Index index, Property::Value propertyValue ) -{ - // Ignore OnPropertySet if MaskedImageView is setting the properties - if( !mSelfPropertySetting ) - { - // Synchronize with user-supplied property values... - if( mCustomProperties[ Dali::Toolkit::MaskedImageView::SOURCE_SIZE ] == index ) - { - // Note that clamping will take effect when edit-mode is used later - mSourcePosition.mStartPinchSize = propertyValue.Get(); - mSourcePosition.mCurrentPinchSize = propertyValue.Get(); - } - else if( mCustomProperties[ Dali::Toolkit::MaskedImageView::SOURCE_OFFSET ] == index ) - { - // Note that clamping will take effect when edit-mode is used later - mSourcePosition.mPanOffset = propertyValue.Get(); - } - else if( mCustomProperties[ Dali::Toolkit::MaskedImageView::MASK_SIZE ] == index ) - { - mMaskPosition.mStartPinchSize = propertyValue.Get(); - mMaskPosition.mCurrentPinchSize = propertyValue.Get(); - } - else if( mCustomProperties[ Dali::Toolkit::MaskedImageView::MASK_OFFSET ] == index ) - { - mMaskPosition.mPanOffset = propertyValue.Get(); - } - // else it's fine to do nothing here - } -} - -void MaskedImageView::OnPan(Actor source, const PanGesture& gesture) -{ - // Used to flag whether edit mode is setting properties - mSelfPropertySetting = true; - - Actor self = Self(); - - if ( Dali::Toolkit::MaskedImageView::EDIT_SOURCE == mEditMode ) - { - mSourcePosition.mPanOffset += gesture.displacement; - mSourcePosition.mPanOffset = ClampSourceOffset( mSourcePosition.mPanOffset, mTargetSize, mSourcePosition.mCurrentPinchSize ); - - self.SetProperty( GetPropertyIndex( Dali::Toolkit::MaskedImageView::SOURCE_OFFSET ), mSourcePosition.mPanOffset ); - } - else // Edit mask - { - mMaskPosition.mPanOffset += gesture.displacement; - - self.SetProperty( GetPropertyIndex( Dali::Toolkit::MaskedImageView::MASK_OFFSET ), mMaskPosition.mPanOffset ); - } - - // Used to flag whether edit mode is setting properties - mSelfPropertySetting = false; -} - -void MaskedImageView::OnPinch(Actor actor, const PinchGesture& pinch) -{ - // Used to flag whether edit mode is setting properties - mSelfPropertySetting = true; - - Actor self = Self(); - - if ( Dali::Toolkit::MaskedImageView::EDIT_SOURCE == mEditMode ) - { - if ( pinch.state == Gesture::Started ) - { - mSourcePosition.mStartPinchSize = mSourcePosition.mCurrentPinchSize; - } - - mSourcePosition.mCurrentPinchSize = mSourcePosition.mStartPinchSize * pinch.scale; - - ClampSourceSizeAndOffset(); - } - else // Edit mask - { - if ( pinch.state == Gesture::Started ) - { - mMaskPosition.mStartPinchSize = mMaskPosition.mCurrentPinchSize; - } - - mMaskPosition.mCurrentPinchSize = mMaskPosition.mStartPinchSize * pinch.scale; - - self.SetProperty( GetPropertyIndex( Dali::Toolkit::MaskedImageView::MASK_SIZE ), mMaskPosition.mCurrentPinchSize ); - } - - // Used to flag whether edit mode is setting properties - mSelfPropertySetting = false; -} - -void MaskedImageView::SetSourceAspectRatio( float widthOverHeight ) -{ - Actor self = Self(); - - if ( widthOverHeight > 0.0f ) - { - mWidthOverHeight = widthOverHeight; - - ClampSourceSizeAndOffset(); - } - else - { - mWidthOverHeight = 0.0f; // ignore aspect-ratio - } -} - -float MaskedImageView::GetSourceAspectRatio() const -{ - return mWidthOverHeight; -} - -void MaskedImageView::SetMaximumSourceScale( float scale ) -{ - mMaximumSourceScale = scale; -} - -float MaskedImageView::GetMaximumSourceScale() const -{ - return mMaximumSourceScale; -} - -void MaskedImageView::SetSourceRotation( MaskedImageView::ImageRotation newRotation ) -{ - if( mSourceRotation != newRotation ) - { - bool oldLandscape( Dali::Toolkit::MaskedImageView::ROTATE_90 == mSourceRotation || Dali::Toolkit::MaskedImageView::ROTATE_270 == mSourceRotation ); - bool newLandscape( Dali::Toolkit::MaskedImageView::ROTATE_90 == newRotation || Dali::Toolkit::MaskedImageView::ROTATE_270 == newRotation ); - - if ( oldLandscape != newLandscape ) - { - // Changing between landscape & portraint, swap width & height - float temp = mSourcePosition.mCurrentPinchSize.width; - mSourcePosition.mCurrentPinchSize.width = mSourcePosition.mCurrentPinchSize.height; - mSourcePosition.mCurrentPinchSize.height = temp; - } - - mSourceRotation = newRotation; - - ApplyMaskedImageShader( newRotation ); - - ClampSourceSizeAndOffset(); - } -} - -MaskedImageView::ImageRotation MaskedImageView::GetSourceRotation() const -{ - return mSourceRotation; -} - -Dali::Toolkit::MaskedImageView::MaskedImageViewSignal& MaskedImageView::MaskFinishedSignal() -{ - return mMaskFinishedSignal; -} - -MaskedImageView::MaskedImageView() -: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ), - mEditMode( Dali::Toolkit::MaskedImageView::EDIT_DISABLED ), - mSelfPropertySetting( false ), - mSourceRotation( Dali::Toolkit::MaskedImageView::ROTATE_0 ), - mWidthOverHeight( 0.0f ), - mMaximumSourceScale( Dali::Toolkit::MaskedImageView::DEFAULT_MAXIMUM_SOURCE_SCALE ) -{ -} - -void MaskedImageView::Initialize( unsigned int targetWidth, - unsigned int targetHeight, - Image sourceImage, - Image maskImage ) -{ - Actor self = Self(); - - // Register custom properties - - mTargetSize = Vector2( static_cast(targetWidth), static_cast(targetHeight) ); - - mCustomProperties[ Dali::Toolkit::MaskedImageView::BACKGROUND_COLOR ] - = self.RegisterProperty( CUSTOM_PROPERTY_NAMES[ Dali::Toolkit::MaskedImageView::BACKGROUND_COLOR ], Color::BLACK ); - - mCustomProperties[ Dali::Toolkit::MaskedImageView::SOURCE_SIZE ] - = self.RegisterProperty( CUSTOM_PROPERTY_NAMES[ Dali::Toolkit::MaskedImageView::SOURCE_SIZE ], mTargetSize ); - - mCustomProperties[ Dali::Toolkit::MaskedImageView::SOURCE_OFFSET ] - = self.RegisterProperty( CUSTOM_PROPERTY_NAMES[ Dali::Toolkit::MaskedImageView::SOURCE_OFFSET ], Vector2::ZERO ); - - mCustomProperties[ Dali::Toolkit::MaskedImageView::MASK_SIZE ] - = self.RegisterProperty( CUSTOM_PROPERTY_NAMES[ Dali::Toolkit::MaskedImageView::MASK_SIZE ], mTargetSize ); - - mCustomProperties[ Dali::Toolkit::MaskedImageView::MASK_OFFSET ] - = self.RegisterProperty( CUSTOM_PROPERTY_NAMES[ Dali::Toolkit::MaskedImageView::MASK_OFFSET ], Vector2::ZERO ); - - // Create destination image (FBO) - mDestinationImage = FrameBufferImage::New( targetWidth, targetHeight, Pixel::RGBA8888 ); - - // Create source actor for off-screen image processing - mSourceImageActor = ImageActor::New( sourceImage ); - self.Add( mSourceImageActor ); - mSourceImageActor.SetParentOrigin( ParentOrigin::CENTER ); - mSourceImageActor.SetPositionInheritanceMode( DONT_INHERIT_POSITION ); - mSourceImageActor.SetInheritOrientation( false ); - mSourceImageActor.SetInheritScale( false ); - mSourceImageActor.SetColorMode( USE_OWN_COLOR ); - mSourceImageActor.SetSize( Vector3::ONE ); - - // Apply masking effect to source actor - mMaskImage = maskImage; - ApplyMaskedImageShader( Dali::Toolkit::MaskedImageView::ROTATE_0 ); - - // Create actor to display result of off-screen rendering - mDestinationImageActor = ImageActor::New( mDestinationImage ); - self.Add( mDestinationImageActor ); - mDestinationImageActor.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION ); - - // Start the masking operation - mRenderTask = Stage::GetCurrent().GetRenderTaskList().CreateTask(); - mRenderTask.SetSourceActor( mSourceImageActor ); - mRenderTask.SetTargetFrameBuffer( mDestinationImage ); - mRenderTask.SetInputEnabled( false ); - mRenderTask.SetExclusive( true ); - mRenderTask.SetClearEnabled( true ); - - Constraint clearColorConstraint = Constraint::New( mRenderTask, RenderTask::Property::CLEAR_COLOR, EqualToConstraint() ); - clearColorConstraint.AddSource( Source( self, mCustomProperties[ Dali::Toolkit::MaskedImageView::BACKGROUND_COLOR ] ) ); - clearColorConstraint.Apply(); - mRenderTask.FinishedSignal().Connect( this, &MaskedImageView::OnRenderTaskFinished ); - - // Edit mode initialization - mSourcePosition.mCurrentPinchSize = Vector2( targetWidth, targetHeight ); - mMaskPosition.mCurrentPinchSize = mSourcePosition.mCurrentPinchSize; -} - -void MaskedImageView::ApplyMaskedImageShader( ImageRotation rotation ) -{ - Actor self = Self(); - - // Vertex shader has different postfix for each rotation - std::stringstream vertexSource; - vertexSource << MASKED_IMAGE_VIEW_VERTEX_SOURCE; - if( Dali::Toolkit::MaskedImageView::ROTATE_90 == rotation ) - { - vertexSource << MASKED_IMAGE_VIEW_VERTEX_SOURCE_ROTATE90; - } - else if( Dali::Toolkit::MaskedImageView::ROTATE_180 == rotation ) - { - vertexSource << MASKED_IMAGE_VIEW_VERTEX_SOURCE_ROTATE180; - } - else if( Dali::Toolkit::MaskedImageView::ROTATE_270 == rotation ) - { - vertexSource << MASKED_IMAGE_VIEW_VERTEX_SOURCE_ROTATE270; - } - else // Default to Dali::Toolkit::MaskedImageView::ROTATE_0 - { - vertexSource << MASKED_IMAGE_VIEW_VERTEX_SOURCE_ROTATE0; - } - - ShaderEffect shader = ShaderEffect::New( vertexSource.str(), - MASKED_IMAGE_VIEW_FRAGMENT_SOURCE, - GeometryType( GEOMETRY_TYPE_IMAGE ), - ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING ) ); - - shader.SetUniform( "uTargetSize", mTargetSize ); - - shader.SetUniform( "uSourceSize", mTargetSize ); - Constraint sourceSizeConstraint = Constraint::New( shader, shader.GetPropertyIndex( "uSourceSize" ), EqualToConstraint() ); - sourceSizeConstraint.AddSource( Source( self, mCustomProperties[ Dali::Toolkit::MaskedImageView::SOURCE_SIZE ] ) ); - sourceSizeConstraint.Apply(); - - shader.SetUniform( "uSourceOffset", Vector2::ZERO ); - Constraint sourceOffsetConstraint = Constraint::New( shader, shader.GetPropertyIndex( "uSourceOffset" ), EqualToConstraint() ); - sourceOffsetConstraint.AddSource( Source( self, mCustomProperties[ Dali::Toolkit::MaskedImageView::SOURCE_OFFSET ] ) ); - sourceOffsetConstraint.Apply(); - - shader.SetUniform( "uMaskSize", mTargetSize ); - Constraint maskSizeConstraint = Constraint::New( shader, shader.GetPropertyIndex( "uMaskSize" ), EqualToConstraint() ); - maskSizeConstraint.AddSource( Source( self, mCustomProperties[ Dali::Toolkit::MaskedImageView::MASK_SIZE ] ) ); - maskSizeConstraint.Apply(); - - shader.SetUniform( "uMaskOffset", mTargetSize ); - Constraint maskOffsetConstraint = Constraint::New( shader, shader.GetPropertyIndex( "uMaskOffset" ), EqualToConstraint() ); - maskOffsetConstraint.AddSource( Source( self, mCustomProperties[ Dali::Toolkit::MaskedImageView::MASK_OFFSET ] ) ); - maskOffsetConstraint.Apply(); - - shader.SetEffectImage( mMaskImage ); - mSourceImageActor.SetShaderEffect( shader ); -} - -void MaskedImageView::ClampSourceSizeAndOffset() -{ - float rotatedAspectRatio( mWidthOverHeight ); - if( mWidthOverHeight > 0.0f && - ( Dali::Toolkit::MaskedImageView::ROTATE_90 == mSourceRotation || - Dali::Toolkit::MaskedImageView::ROTATE_270 == mSourceRotation ) ) - { - rotatedAspectRatio = 1.0f / mWidthOverHeight; - } - - Actor self = Self(); - - mSourcePosition.mCurrentPinchSize = ClampSourceSize( mSourcePosition.mCurrentPinchSize, mTargetSize, rotatedAspectRatio, mMaximumSourceScale ); - self.SetProperty( GetPropertyIndex( Dali::Toolkit::MaskedImageView::SOURCE_SIZE ), mSourcePosition.mCurrentPinchSize ); - - mSourcePosition.mPanOffset = ClampSourceOffset( mSourcePosition.mPanOffset, mTargetSize, mSourcePosition.mCurrentPinchSize ); - self.SetProperty( GetPropertyIndex( Dali::Toolkit::MaskedImageView::SOURCE_OFFSET ), mSourcePosition.mPanOffset ); -} - -MaskedImageView::~MaskedImageView() -{ - // Guard to allow handle destruction after Core has been destroyed - if( Stage::IsInstalled() ) - { - Stage::GetCurrent().GetRenderTaskList().RemoveTask( mRenderTask ); - } -} - -void MaskedImageView::OnControlSizeSet( const Vector3& targetSize ) -{ - mDestinationImageActor.SetSize(targetSize); -} - -void MaskedImageView::OnRenderTaskFinished( Dali::RenderTask& renderTask ) -{ - Toolkit::MaskedImageView handle( GetOwner() ); - mMaskFinishedSignal.Emit( handle ); -} - -} // namespace Internal - -} // namespace Toolkit - -} // namespace Dali diff --git a/dali-toolkit/internal/controls/image-view/masked-image-view-impl.h b/dali-toolkit/internal/controls/image-view/masked-image-view-impl.h deleted file mode 100644 index a1c8285..0000000 --- a/dali-toolkit/internal/controls/image-view/masked-image-view-impl.h +++ /dev/null @@ -1,275 +0,0 @@ -#ifndef __DALI_TOOLKIT_INTERNAL_MASKED_IMAGE_VIEW_H__ -#define __DALI_TOOLKIT_INTERNAL_MASKED_IMAGE_VIEW_H__ - -/* - * Copyright (c) 2014 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. - * - */ - -// EXTERNAL INCLUDES -#include -#include -#include - -// INTERNAL INCLUDES -#include -#include - -namespace Dali -{ - -namespace Toolkit -{ - -namespace Internal -{ - -/** - * @copydoc Dali::Toolkit::MaskedImageView - */ -class MaskedImageView : public Control -{ -public: - - typedef Dali::Toolkit::MaskedImageView::ImageRotation ImageRotation; - - /** - * Create a new MaskedImageView. - * @return A public handle to the newly allocated MaskedImageView. - */ - static Dali::Toolkit::MaskedImageView New( unsigned int targetWidth, - unsigned int targetHeight, - Image sourceImage, - Image maskImage ); - - /** - * @copydoc Dali::Toolkit::MaskedImageView::SetSourceImage() - */ - void SetSourceImage( Image sourceImage ); - - /** - * @copydoc Dali::Toolkit::MaskedImageView::GetSourceImage() - */ - Image GetSourceImage(); - - /** - * @copydoc Dali::Toolkit::MaskedImageView::SetMaskImage() - */ - void SetMaskImage( Image maskImage ); - - /** - * @copydoc Dali::Toolkit::MaskedImageView::GetMaskImage() - */ - Image GetMaskImage(); - - /** - * @copydoc Dali::Toolkit::MaskedImageView::GetPropertyIndex() - */ - Property::Index GetPropertyIndex( Dali::Toolkit::MaskedImageView::CustomProperty customProperty ) const; - - /** - * @copydoc Dali::Toolkit::MaskedImageView::Pause() - */ - void Pause(); - - /** - * @copydoc Dali::Toolkit::MaskedImageView::Resume() - */ - void Resume(); - - /** - * @copydoc Dali::Toolkit::MaskedImageView::IsPaused() - */ - bool IsPaused() const; - - /** - * @copydoc Dali::Toolkit::MaskedImageView::SetEditMode() - */ - void SetEditMode( Dali::Toolkit::MaskedImageView::EditMode editMode ); - - /** - * @copydoc Dali::Toolkit::MaskedImageView::GetEditMode() - */ - Dali::Toolkit::MaskedImageView::EditMode GetEditMode() const; - - /** - * @copydoc Dali::Toolkit::MaskedImageView::SetSourceAspectRatio() - */ - void SetSourceAspectRatio( float widthOverHeight ); - - /** - * @copydoc Dali::Toolkit::MaskedImageView::GetSourceAspectRatio() - */ - float GetSourceAspectRatio() const; - - /** - * @copydoc Dali::Toolkit::MaskedImageView::SetMaximumSourceScale() - */ - void SetMaximumSourceScale( float scale ); - - /** - * @copydoc Dali::Toolkit::MaskedImageView::GetMaximumSourceScale() - */ - float GetMaximumSourceScale() const; - - /** - * @copydoc Dali::Toolkit::MaskedImageView::SetSourceRotation() - */ - void SetSourceRotation( ImageRotation rotation ); - - /** - * @copydoc Dali::Toolkit::MaskedImageView::GetSourceRotation() - */ - ImageRotation GetSourceRotation() const; - - /** - * @copydoc Dali::Toolkit::MaskedImageView::MaskFinishedSignal - */ - Dali::Toolkit::MaskedImageView::MaskedImageViewSignal& MaskFinishedSignal(); - -protected: - - /** - * @copydoc Dali::CustomActorImpl::OnPropertySet() - */ - void OnPropertySet( Property::Index index, Property::Value propertyValue ); - - /** - * Helper for edit mode. - */ - void OnPan( Actor source, const PanGesture& gesture ); - - /** - * Helper for edit mode. - */ - void OnPinch( Actor actor, const PinchGesture& pinch ); - - /** - * Construct a new MaskedImageView. - */ - MaskedImageView(); - - /** - * 2nd-phase initialization. - */ - void Initialize( unsigned int targetWidth, - unsigned int targetHeight, - Image sourceImage, - Image maskImage ); - - /** - * Helper to apply the desired shader-effect for a given rotation. - * @param[in] rotation The rotation to apply to the source image. - */ - void ApplyMaskedImageShader( ImageRotation rotation ); - - /** - * Helper to clamp the source image properties (only in edit mode). - */ - void ClampSourceSizeAndOffset(); - - /** - * A reference counted object may only be deleted by calling Unreference() - */ - virtual ~MaskedImageView(); - - /** - * - * @copydoc Toolkit::Control::OnControlSizeSet( const Vector3& targetSize ) - */ - virtual void OnControlSizeSet( const Vector3& targetSize ); - -private: - - // Undefined - MaskedImageView(const MaskedImageView&); - - // Undefined - MaskedImageView& operator=(const MaskedImageView& rhs); - - /** - * Emit MaskFinishedSignal when the render task finished rendering - * @param[in] renderTask the off-screen render task - */ - void OnRenderTaskFinished( Dali::RenderTask& renderTask ); - -private: - - Vector2 mTargetSize; - - Property::Index mCustomProperties[ Dali::Toolkit::MaskedImageView::CUSTOM_PROPERTY_COUNT ]; - - // Used for off-screen rendering - RenderTask mRenderTask; - ImageActor mSourceImageActor; - FrameBufferImage mDestinationImage; - - // Create actor to display result of off-screen rendering - ImageActor mDestinationImageActor; - - // Because ShaderEffect doesn't have a GetEffectImage() - Image mMaskImage; - - // For edit mode - Dali::Toolkit::MaskedImageView::EditMode mEditMode; - PanGestureDetector mPanGestureDetector; - PinchGestureDetector mPinchDetector; - bool mSelfPropertySetting; - - struct ImagePosition - { - Vector2 mPanOffset; - Vector2 mStartPinchSize; - Vector2 mCurrentPinchSize; - }; - ImagePosition mSourcePosition; - ImagePosition mMaskPosition; - - ImageRotation mSourceRotation; - - // Limits for edit mode - float mWidthOverHeight; - float mMaximumSourceScale; - - Dali::Toolkit::MaskedImageView::MaskedImageViewSignal mMaskFinishedSignal; -}; - -} // namespace Internal - -// Helpers for public-api forwarding methods - -inline Toolkit::Internal::MaskedImageView& GetImpl(Toolkit::MaskedImageView& pub) -{ - DALI_ASSERT_ALWAYS(pub); - - Dali::RefObject& handle = pub.GetImplementation(); - - return static_cast(handle); -} - -inline const Toolkit::Internal::MaskedImageView& GetImpl(const Toolkit::MaskedImageView& pub) -{ - DALI_ASSERT_ALWAYS(pub); - - const Dali::RefObject& handle = pub.GetImplementation(); - - return static_cast(handle); -} - -} // namespace Toolkit - -} // namespace Dali - -#endif // __DALI_TOOLKIT_INTERNAL_MASKED_IMAGE_VIEW_H__ diff --git a/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.h b/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.h index 0753579..892c563 100644 --- a/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.h +++ b/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.h @@ -21,7 +21,7 @@ // INTERNAL INCLUDES #include #include -#include +#include // EXTERNAL INCLUDES #include diff --git a/dali-toolkit/internal/file.list b/dali-toolkit/internal/file.list index b39bf81..c748177 100644 --- a/dali-toolkit/internal/file.list +++ b/dali-toolkit/internal/file.list @@ -21,7 +21,6 @@ toolkit_src_files = \ $(toolkit_src_dir)/controls/buttons/radio-button-impl.cpp \ $(toolkit_src_dir)/controls/effects-view/effects-view-impl.cpp \ $(toolkit_src_dir)/controls/gaussian-blur-view/gaussian-blur-view-impl.cpp \ - $(toolkit_src_dir)/controls/image-view/masked-image-view-impl.cpp \ $(toolkit_src_dir)/controls/magnifier/magnifier-impl.cpp \ $(toolkit_src_dir)/controls/popup/popup-impl.cpp \ $(toolkit_src_dir)/controls/popup/popup-style-impl.cpp \ diff --git a/dali-toolkit/internal/focus-manager/focus-manager-impl.cpp b/dali-toolkit/internal/focus-manager/focus-manager-impl.cpp index f1dab7e..b832eff 100644 --- a/dali-toolkit/internal/focus-manager/focus-manager-impl.cpp +++ b/dali-toolkit/internal/focus-manager/focus-manager-impl.cpp @@ -467,7 +467,7 @@ void FocusManager::DoActivate(Actor actor) if(control) { // Notify the control that it is activated - control.GetImplementation().Activate(); + GetImplementation( control ).Activate(); } // Send notification for the activation of focused actor @@ -815,7 +815,7 @@ bool FocusManager::AccessibilityActionUp() if(control) { // Notify the control that it is activated - ret = control.GetImplementation().OnAccessibilityValueChange(true); + ret = GetImplementation( control ).OnAccessibilityValueChange(true); } } } @@ -836,7 +836,7 @@ bool FocusManager::AccessibilityActionDown() if(control) { // Notify the control that it is activated - ret = control.GetImplementation().OnAccessibilityValueChange(false); + ret = GetImplementation( control ).OnAccessibilityValueChange(false); } } } @@ -873,7 +873,7 @@ bool FocusManager::AccessibilityActionTouch(const TouchEvent& touchEvent) Dali::Toolkit::Control control = Dali::Toolkit::Control::DownCast(GetCurrentFocusActor()); if(control) { - handled = control.GetImplementation().OnAccessibilityTouch(touchEvent); + handled = GetImplementation( control ).OnAccessibilityTouch(touchEvent); } return handled; @@ -933,7 +933,7 @@ bool FocusManager::HandlePanGesture(const Integration::PanGestureEvent& panEvent pan.velocity.x = pan.displacement.x / panEvent.timeDelta; pan.velocity.y = pan.displacement.y / panEvent.timeDelta; - handled = control.GetImplementation().OnAccessibilityPan(pan); + handled = GetImplementation( control ).OnAccessibilityPan(pan); } // If the gesture is not handled by the control, check its parent diff --git a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp index facff71..cfe7287 100644 --- a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp +++ b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp @@ -195,7 +195,7 @@ Actor KeyboardFocusManager::GetCurrentFocusGroup() bool KeyboardFocusManager::IsLayoutControl(Actor actor) const { Toolkit::Control control = Toolkit::Control::DownCast(actor); - return control && control.GetImplementation().IsKeyboardNavigationSupported(); + return control && GetImplementation( control ).IsKeyboardNavigationSupported(); } Toolkit::Control KeyboardFocusManager::GetParentLayoutControl(Actor actor) const @@ -260,7 +260,7 @@ bool KeyboardFocusManager::MoveFocus(Toolkit::Control::KeyboardFocusNavigationDi bool KeyboardFocusManager::DoMoveFocusWithinLayoutControl(Toolkit::Control control, Actor actor, Toolkit::Control::KeyboardFocusNavigationDirection direction) { // Ask the control for the next actor to focus - Actor nextFocusableActor = control.GetImplementation().GetNextKeyboardFocusableActor(actor, direction, mFocusGroupLoopEnabled); + Actor nextFocusableActor = GetImplementation( control ).GetNextKeyboardFocusableActor(actor, direction, mFocusGroupLoopEnabled); if(nextFocusableActor) { if(!nextFocusableActor.IsKeyboardFocusable()) @@ -299,7 +299,7 @@ bool KeyboardFocusManager::DoMoveFocusWithinLayoutControl(Toolkit::Control contr // If the application hasn't changed our proposed actor, we informs the layout control we will // move the focus to what the control returns. The control might wish to perform some actions // before the focus is actually moved. - control.GetImplementation().OnKeyboardFocusChangeCommitted(committedFocusActor); + GetImplementation( control ).OnKeyboardFocusChangeCommitted( committedFocusActor ); } return SetCurrentFocusActor(committedFocusActor); @@ -351,7 +351,7 @@ void KeyboardFocusManager::DoActivate(Actor actor) if(control) { // Notify the control that it is activated - control.GetImplementation().Activate(); + GetImplementation( control ).Activate(); } // Send notification for the activation of focused actor diff --git a/dali-toolkit/internal/focus-manager/keyinput-focus-manager-impl.cpp b/dali-toolkit/internal/focus-manager/keyinput-focus-manager-impl.cpp index 9fee428..48f0ebf 100644 --- a/dali-toolkit/internal/focus-manager/keyinput-focus-manager-impl.cpp +++ b/dali-toolkit/internal/focus-manager/keyinput-focus-manager-impl.cpp @@ -88,13 +88,13 @@ void KeyInputFocusManager::SetFocus( Toolkit::Control control ) if( previousFocusControl ) { // Notify the control that it has lost key input focus - previousFocusControl.GetImplementation().OnKeyInputFocusLost(); + GetImplementation( previousFocusControl ).OnKeyInputFocusLost(); } mFocusStack.PushBack( &control.GetBaseObject() ); // Tell the new actor that it has gained focus. - control.GetImplementation().OnKeyInputFocusGained(); + GetImplementation( control ).OnKeyInputFocusGained(); // Emit the signal to inform focus change to the application. if ( !mKeyInputFocusChangedSignal.Empty() ) @@ -113,7 +113,7 @@ void KeyInputFocusManager::RemoveFocus( Toolkit::Control control ) control.OffStageSignal().Disconnect( mSlotDelegate, &KeyInputFocusManager::OnFocusControlStageDisconnection ); // Notify the control that it has lost key input focus - control.GetImplementation().OnKeyInputFocusLost(); + GetImplementation( control ).OnKeyInputFocusLost(); // If this is the top-most actor, pop it and change focus to the previous control if( pos == mFocusStack.End() - 1 ) @@ -124,7 +124,7 @@ void KeyInputFocusManager::RemoveFocus( Toolkit::Control control ) if( previouslyFocusedControl ) { // Tell the control that it has gained focus. - previouslyFocusedControl.GetImplementation().OnKeyInputFocusGained(); + GetImplementation( previouslyFocusedControl ).OnKeyInputFocusGained(); } } else @@ -194,7 +194,7 @@ void KeyInputFocusManager::OnKeyEvent( const KeyEvent& event ) if( control ) { // Notify the control about the key event - consumed = control.GetImplementation().EmitKeyEventSignal( event ); + consumed = GetImplementation( control ).EmitKeyEventSignal( event ); } } } diff --git a/dali-toolkit/internal/text/decorator/text-decorator.cpp b/dali-toolkit/internal/text/decorator/text-decorator.cpp index 7329790..f529f70 100644 --- a/dali-toolkit/internal/text/decorator/text-decorator.cpp +++ b/dali-toolkit/internal/text/decorator/text-decorator.cpp @@ -47,7 +47,7 @@ #include #include #include -#include +#include #ifdef DEBUG_ENABLED #define DECORATOR_DEBUG diff --git a/dali-toolkit/public-api/controls/control-impl.cpp b/dali-toolkit/public-api/controls/control-impl.cpp index cd4301d..d655a3b 100644 --- a/dali-toolkit/public-api/controls/control-impl.cpp +++ b/dali-toolkit/public-api/controls/control-impl.cpp @@ -180,8 +180,7 @@ public: mLongPressGestureDetector(), mFlags( Control::ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ), mIsKeyboardNavigationSupported( false ), - mIsKeyboardFocusGroup( false ), - mInitialized( false ) + mIsKeyboardFocusGroup( false ) { } @@ -243,7 +242,7 @@ public: if ( control ) { - Control& controlImpl( control.GetImplementation() ); + Control& controlImpl( GetImplementation( control ) ); switch ( index ) { @@ -309,7 +308,7 @@ public: if ( control ) { - Control& controlImpl( control.GetImplementation() ); + Control& controlImpl( GetImplementation( control ) ); switch ( index ) { @@ -329,10 +328,10 @@ public: { Property::Map map; - Actor actor = controlImpl.GetBackgroundActor(); - if ( actor ) + Background* back = controlImpl.mImpl->mBackground; + if( back ) { - ImageActor imageActor = ImageActor::DownCast( actor ); + ImageActor imageActor = ImageActor::DownCast( back->actor ); if ( imageActor ) { Image image = imageActor.GetImage(); @@ -376,7 +375,6 @@ public: ControlBehaviour mFlags :CONTROL_BEHAVIOUR_FLAG_COUNT; ///< Flags passed in from constructor. bool mIsKeyboardNavigationSupported :1; ///< Stores whether keyboard navigation is supported by the control. bool mIsKeyboardFocusGroup :1; ///< Stores whether the control is a focus group. - bool mInitialized :1; // Properties - these need to be members of Internal::Control::Impl as they need to function within this class. static PropertyRegistration PROPERTY_1; @@ -411,45 +409,6 @@ Control::~Control() delete mImpl; } -Vector3 Control::GetNaturalSize() -{ - if( mImpl->mBackground ) - { - Actor actor = mImpl->mBackground->actor; - if( actor ) - { - return actor.GetNaturalSize(); - } - } - return Vector3(); -} - -float Control::GetHeightForWidth( float width ) -{ - if( mImpl->mBackground ) - { - Actor actor = mImpl->mBackground->actor; - if( actor ) - { - return actor.GetHeightForWidth( width ); - } - } - return GetHeightForWidthBase( width ); -} - -float Control::GetWidthForHeight( float height ) -{ - if( mImpl->mBackground ) - { - Actor actor = mImpl->mBackground->actor; - if( actor ) - { - return actor.GetWidthForHeight( height ); - } - } - return GetWidthForHeightBase( height ); -} - void Control::SetKeyInputFocus() { if( Self().OnStage() ) @@ -577,16 +536,6 @@ void Control::ClearBackground() } } -Actor Control::GetBackgroundActor() const -{ - if ( mImpl->mBackground ) - { - return mImpl->mBackground->actor; - } - - return Actor(); -} - void Control::SetKeyboardNavigationSupport(bool isSupported) { mImpl->mIsKeyboardNavigationSupported = isSupported; @@ -600,7 +549,11 @@ bool Control::IsKeyboardNavigationSupported() void Control::Activate() { // Inform deriving classes - OnActivated(); + OnAccessibilityActivated(); +} + +void Control::OnAccessibilityActivated() +{ } bool Control::OnAccessibilityPan(PanGesture gesture) @@ -650,7 +603,7 @@ bool Control::DoAction(BaseObject* object, const std::string& actionName, const if( control ) { // if cast succeeds there is an implementation so no need to check - control.GetImplementation().OnActivated(); + GetImplementation( control ).OnAccessibilityActivated(); } } @@ -665,7 +618,7 @@ bool Control::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* t Toolkit::Control control = Toolkit::Control::DownCast( handle ); if ( control ) { - Control& controlImpl( control.GetImplementation() ); + Control& controlImpl( GetImplementation( control ) ); connected = true; if ( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_EVENT ) ) @@ -755,9 +708,6 @@ Control::Control( ControlBehaviour behaviourFlags ) void Control::Initialize() { - // Calling deriving classes - OnInitialize(); - if( mImpl->mFlags & REQUIRES_STYLE_CHANGE_SIGNALS ) { Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get(); @@ -774,7 +724,8 @@ void Control::Initialize() SetKeyboardNavigationSupport( true ); } - mImpl->mInitialized = true; + // Calling deriving classes + OnInitialize(); } void Control::EnableGestureDetection(Gesture::Type type) @@ -839,7 +790,19 @@ void Control::OnInitialize() { } -void Control::OnActivated() +void Control::OnControlStageConnection() +{ +} + +void Control::OnControlStageDisconnection() +{ +} + +void Control::OnControlChildAdd( Actor& child ) +{ +} + +void Control::OnControlChildRemove( Actor& child ) { } @@ -880,56 +843,10 @@ void Control::OnLongPress( const LongPressGesture& longPress ) { } -void Control::OnControlStageConnection() -{ -} - -void Control::OnControlStageDisconnection() -{ -} - -void Control::OnControlChildAdd( Actor& child ) -{ -} - -void Control::OnControlChildRemove( Actor& child ) -{ -} - void Control::OnControlSizeSet( const Vector3& size ) { } -void Control::OnCalculateRelayoutSize( Dimension::Type dimension ) -{ -} - -void Control::OnLayoutNegotiated( float size, Dimension::Type dimension ) -{ -} - -void Control::OnRelayout( const Vector2& size, RelayoutContainer& container ) -{ - for( unsigned int i = 0, numChildren = Self().GetChildCount(); i < numChildren; ++i ) - { - container.Add( Self().GetChildAt( i ), size ); - } -} - -void Control::OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension ) -{ -} - -float Control::CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension ) -{ - return CalculateChildSizeBase( child, dimension ); -} - -bool Control::RelayoutDependentOnChildren( Dimension::Type dimension ) -{ - return RelayoutDependentOnChildrenBase( dimension ); -} - void Control::EmitKeyInputFocusSignal( bool focusGained ) { Dali::Toolkit::Control handle( GetOwner() ); @@ -962,9 +879,53 @@ void Control::OnKeyInputFocusLost() EmitKeyInputFocusSignal( false ); } +void Control::OnStageConnection() +{ + // Notify derived classes. + OnControlStageConnection(); +} + +void Control::OnStageDisconnection() +{ + // Notify derived classes + OnControlStageDisconnection(); +} + +void Control::OnChildAdd(Actor& child) +{ + // If this is the background actor, then we do not want to relayout or inform deriving classes + if ( mImpl->mBackground && ( child == mImpl->mBackground->actor ) ) + { + return; + } + + // Notify derived classes. + OnControlChildAdd( child ); +} + +void Control::OnChildRemove(Actor& child) +{ + // If this is the background actor, then we do not want to relayout or inform deriving classes + if ( mImpl->mBackground && ( child == mImpl->mBackground->actor ) ) + { + return; + } + + // Notify derived classes. + OnControlChildRemove( child ); +} + +void Control::OnSizeSet(const Vector3& targetSize) +{ + // Background is resized through size negotiation + + // Notify derived classes. + OnControlSizeSet( targetSize ); +} + void Control::OnSizeAnimation(Animation& animation, const Vector3& targetSize) { - // @todo consider animating negotiated child sizes to target size + // @todo size negotiate background to new size, animate as well? } bool Control::OnTouchEvent(const TouchEvent& event) @@ -987,48 +948,73 @@ bool Control::OnMouseWheelEvent(const MouseWheelEvent& event) return false; // Do not consume } -void Control::OnStageConnection() +void Control::OnRelayout( const Vector2& size, RelayoutContainer& container ) { - // Notify derived classes. - OnControlStageConnection(); + for( unsigned int i = 0, numChildren = Self().GetChildCount(); i < numChildren; ++i ) + { + container.Add( Self().GetChildAt( i ), size ); + } } -void Control::OnStageDisconnection() +void Control::OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension ) { - // Notify derived classes - OnControlStageDisconnection(); } -void Control::OnChildAdd(Actor& child) +Vector3 Control::GetNaturalSize() { - // If this is the background actor, then we do not want to relayout or inform deriving classes - if ( mImpl->mBackground && ( child == mImpl->mBackground->actor ) ) + if( mImpl->mBackground ) { - return; + Actor actor = mImpl->mBackground->actor; + if( actor ) + { + return actor.GetNaturalSize(); + } } + return Vector3(); +} - // Notify derived classes. - OnControlChildAdd( child ); +float Control::CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension ) +{ + return CalculateChildSizeBase( child, dimension ); } -void Control::OnChildRemove(Actor& child) +float Control::GetHeightForWidth( float width ) { - // If this is the background actor, then we do not want to relayout or inform deriving classes - if ( mImpl->mBackground && ( child == mImpl->mBackground->actor ) ) + if( mImpl->mBackground ) { - return; + Actor actor = mImpl->mBackground->actor; + if( actor ) + { + return actor.GetHeightForWidth( width ); + } } + return GetHeightForWidthBase( width ); +} - // Notify derived classes. - OnControlChildRemove( child ); +float Control::GetWidthForHeight( float height ) +{ + if( mImpl->mBackground ) + { + Actor actor = mImpl->mBackground->actor; + if( actor ) + { + return actor.GetWidthForHeight( height ); + } + } + return GetWidthForHeightBase( height ); } -void Control::OnSizeSet(const Vector3& targetSize) +bool Control::RelayoutDependentOnChildren( Dimension::Type dimension ) { - // Background is resized through size negotiation + return RelayoutDependentOnChildrenBase( dimension ); +} - // Notify derived classes. - OnControlSizeSet( targetSize ); +void Control::OnCalculateRelayoutSize( Dimension::Type dimension ) +{ +} + +void Control::OnLayoutNegotiated( float size, Dimension::Type dimension ) +{ } void Control::SignalConnected( SlotObserver* slotObserver, CallbackBase* callback ) @@ -1041,6 +1027,22 @@ void Control::SignalDisconnected( SlotObserver* slotObserver, CallbackBase* call mImpl->SignalDisconnected( slotObserver, callback ); } +Control& GetImplementation( Dali::Toolkit::Control& handle ) +{ + CustomActorImpl& customInterface = handle.GetImplementation(); + // downcast to control + Control& impl = dynamic_cast< Internal::Control& >( customInterface ); + return impl; +} + +const Control& GetImplementation( const Dali::Toolkit::Control& handle ) +{ + const CustomActorImpl& customInterface = handle.GetImplementation(); + // downcast to control + const Control& impl = dynamic_cast< const Internal::Control& >( customInterface ); + return impl; +} + } // namespace Internal } // namespace Toolkit diff --git a/dali-toolkit/public-api/controls/control-impl.h b/dali-toolkit/public-api/controls/control-impl.h index 68a9c4b..a7e2c91 100644 --- a/dali-toolkit/public-api/controls/control-impl.h +++ b/dali-toolkit/public-api/controls/control-impl.h @@ -35,16 +35,13 @@ namespace Dali namespace Toolkit { - class StyleManager; -namespace Internal DALI_INTERNAL -{ -class KeyInputFocusManager; -} - namespace Internal { +class FocusManager; +class KeyboardFocusManager; +class KeyInputFocusManager; /** * @brief This is the internal base class for all controls. @@ -74,23 +71,6 @@ public: */ virtual ~Control(); - // Size negotiation - - /** - * @copydoc Dali::CustomActorImpl::GetHeightForWidth() - */ - virtual float GetHeightForWidth( float width ); - - /** - * @copydoc Dali::CustomActorImpl::GetWidthForHeight() - */ - virtual float GetWidthForHeight( float height ); - - /** - * @copydoc Toolkit::CustomActorImpl::GetNaturalSize() - */ - virtual Vector3 GetNaturalSize(); - // Key Input /** @@ -154,7 +134,7 @@ public: */ LongPressGestureDetector GetLongPressGestureDetector() const; - // Background + // Styling /** * @copydoc Dali::Toolkit::Control::SetStyleName @@ -166,6 +146,8 @@ public: */ const std::string& GetStyleName() const; + // Background + /** * @copydoc Dali::Toolkit::Control::SetBackgroundColor */ @@ -186,11 +168,6 @@ public: */ void ClearBackground(); - /** - * @copydoc Dali::Toolkit::Control::GetBackgroundActor - */ - Actor GetBackgroundActor() const; - // Keyboard Navigation /** @@ -217,33 +194,6 @@ public: */ DALI_INTERNAL void Activate(); - /** - * @brief This method should be overridden by deriving classes when they wish to respond the accessibility - * pan gesture. - * - * @param[in] gesture The pan gesture. - * @return true if the pan gesture has been consumed by this control - */ - virtual bool OnAccessibilityPan(PanGesture gesture); - - /** - * @brief This method should be overridden by deriving classes when they wish to respond the accessibility - * touch event. - * - * @param[in] touchEvent The touch event. - * @return true if the touch event has been consumed by this control - */ - virtual bool OnAccessibilityTouch(const TouchEvent& touchEvent); - - /** - * @brief This method should be overridden by deriving classes when they wish to respond - * the accessibility up and down action (i.e. value change of slider control). - * - * @param[in] isIncrease Whether the value should be increased or decreased - * @return true if the value changed action has been consumed by this control - */ - virtual bool OnAccessibilityValueChange(bool isIncrease); - // Keyboard Focus /** @@ -263,27 +213,6 @@ public: bool IsKeyboardFocusGroup(); /** - * @brief Gets the next keyboard focusable actor in this control towards the given direction. - * - * A control needs to override this function in order to support two dimensional keyboard navigation. - * @param[in] currentFocusedActor The current focused actor. - * @param[in] direction The direction to move the focus towards. - * @param[in] loopEnabled Whether the focus movement should be looped within the control. - * @return the next keyboard focusable actor in this control or an empty handle if no actor can be focused. - */ - virtual Actor GetNextKeyboardFocusableActor(Actor currentFocusedActor, Toolkit::Control::KeyboardFocusNavigationDirection direction, bool loopEnabled); - - /** - * @brief Informs this control that its chosen focusable actor will be focused. - * - * This allows the application to preform any actions if wishes - * before the focus is actually moved to the chosen actor. - * - * @param[in] commitedFocusableActor The commited focusable actor. - */ - virtual void OnKeyboardFocusChangeCommitted(Actor commitedFocusableActor); - - /** * @brief Emits KeyInputFocusGained signal if true else emits KeyInputFocusLost signal * * Should be called last by the control after it acts on the Input Focus change. @@ -338,7 +267,104 @@ public: */ DALI_INTERNAL bool EmitKeyEventSignal(const KeyEvent& event); -protected: +protected: // From CustomActorImpl, not to be used by application developers + + /** + * @copydoc CustomActorImpl::OnStageConnection() + */ + virtual void OnStageConnection(); + + /** + * @copydoc CustomActorImpl::OnStageDisconnection() + */ + virtual void OnStageDisconnection(); + + /** + * @copydoc CustomActorImpl::OnChildAdd() + */ + virtual void OnChildAdd(Actor& child); + + /** + * @copydoc CustomActorImpl::OnChildRemove() + */ + virtual void OnChildRemove(Actor& child); + + /** + * @copydoc CustomActorImpl::OnSizeSet() + */ + virtual void OnSizeSet(const Vector3& targetSize); + + /** + * @copydoc CustomActorImpl::OnSizeAnimation() + */ + virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize); + + /** + * @copydoc CustomActorImpl::OnTouchEvent() + */ + virtual bool OnTouchEvent(const TouchEvent& event); + + /** + * @copydoc CustomActorImpl::OnHoverEvent() + */ + virtual bool OnHoverEvent(const HoverEvent& event); + + /** + * @copydoc CustomActorImpl::OnKeyEvent() + */ + virtual bool OnKeyEvent(const KeyEvent& event); + + /** + * @copydoc CustomActorImpl::OnMouseWheelEvent() + */ + virtual bool OnMouseWheelEvent(const MouseWheelEvent& event); + + /** + * @copydoc CustomActorImpl::OnRelayout() + */ + virtual void OnRelayout( const Vector2& size, RelayoutContainer& container ); + + /** + * @copydoc CustomActorImpl::OnSetResizePolicy() + */ + virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension ); + + /** + * @copydoc CustomActorImpl::GetNaturalSize() + */ + virtual Vector3 GetNaturalSize(); + + /** + * @copydoc CustomActorImpl::CalculateChildSize() + */ + virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension ); + + /** + * @copydoc CustomActorImpl::GetHeightForWidth() + */ + virtual float GetHeightForWidth( float width ); + + /** + * @copydoc CustomActorImpl::GetWidthForHeight() + */ + virtual float GetWidthForHeight( float height ); + + /** + * @copydoc CustomActorImpl::RelayoutDependentOnChildren() + */ + virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ); + + /** + * @copydoc CustomActorImpl::OnCalculateRelayoutSize() + */ + virtual void OnCalculateRelayoutSize( Dimension::Type dimension ); + + /** + * @copydoc CustomActorImpl::OnLayoutNegotiated() + */ + virtual void OnLayoutNegotiated( float size, Dimension::Type dimension ); + +protected: // Helpers for deriving classes // Construction @@ -354,11 +380,11 @@ protected: static const int CONTROL_BEHAVIOUR_FLAG_COUNT = Log< LAST_CONTROL_BEHAVIOUR_FLAG - 1 >::value + 1; ///< Total count of flags /** - * @brief Create a Control. + * @brief Control constructor * * @param[in] behaviourFlags Behavioural flags from ControlBehaviour enum */ - Control(ControlBehaviour behaviourFlags); + Control( ControlBehaviour behaviourFlags ); /** * @brief Second phase initialization. @@ -376,7 +402,7 @@ protected: * @endcode * @param[in] type The gesture type(s) to enable. */ - void EnableGestureDetection(Gesture::Type type); + void EnableGestureDetection( Gesture::Type type ); /** * @brief Allows deriving classes to disable any of the gesture detectors. @@ -385,16 +411,11 @@ protected: * @param[in] type The gesture type(s) to disable. * @see EnableGetureDetection */ - void DisableGestureDetection(Gesture::Type type); + void DisableGestureDetection( Gesture::Type type ); - /** - * @copydoc Dali::CustomActorImpl::RelayoutDependentOnChildren() - */ - virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ); +public: // API for derived classes to override -private: - - // For derived classes to override + // Lifecycle /** * @brief This method is called after the Control has been initialized. @@ -404,74 +425,6 @@ private: virtual void OnInitialize(); /** - * @brief This method is called when the control is activated. - * - * Derived classes should override this if they wish to be notified when they are activated. - */ - virtual void OnActivated(); - - /** - * @brief This method should be overridden by deriving classes requiring notifications when the style changes. - * - * @param[in] styleManager The StyleManager object. - * @param[in] change Information denoting what has changed. - */ - virtual void OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change ); - - /** - * @brief Called whenever a pinch gesture is detected on this control. - * - * This can be overridden by deriving classes when pinch detection - * is enabled. The default behaviour is to scale the control by the - * pinch scale. - * - * @note If overridden, then the default behaviour will not occur. - * @note Pinch detection should be enabled via EnableGestureDetection(). - * @param[in] pinch The pinch gesture. - * @see EnableGestureDetection - */ - virtual void OnPinch(const PinchGesture& pinch); - - /** - * @brief Called whenever a pan gesture is detected on this control. - * - * This should be overridden by deriving classes when pan detection - * is enabled. - * - * @note There is no default behaviour with panning. - * @note Pan detection should be enabled via EnableGestureDetection(). - * @param[in] pan The pan gesture. - * @see EnableGestureDetection - */ - virtual void OnPan( const PanGesture& pan ); - - /** - * @brief Called whenever a tap gesture is detected on this control. - * - * This should be overridden by deriving classes when tap detection - * is enabled. - * - * @note There is no default behaviour with a tap. - * @note Tap detection should be enabled via EnableGestureDetection(). - * @param[in] tap The tap gesture. - * @see EnableGestureDetection - */ - virtual void OnTap( const TapGesture& tap ); - - /** - * @brief Called whenever a long press gesture is detected on this control. - * - * This should be overridden by deriving classes when long press - * detection is enabled. - * - * @note There is no default behaviour associated with a long press. - * @note Long press detection should be enabled via EnableGestureDetection(). - * @param[in] longPress The long press gesture. - * @see EnableGestureDetection - */ - virtual void OnLongPress( const LongPressGesture& longPress ); - - /** * @brief Called whenever the control is added to the stage. * * Could be overridden by derived classes. @@ -503,114 +456,152 @@ private: */ virtual void OnControlChildRemove( Actor& child ); - /** - * @brief Called whenever the Control's size is set. - * - * Could be overridden by derived classes. - * - * @param[in] size The new size. - */ - virtual void OnControlSizeSet( const Vector3& size ); + // Styling /** - * @brief Called when the control gains key input focus. + * @brief This method should be overridden by deriving classes requiring notifications when the style changes. * - * Should be overridden by derived classes if they need to customize what happens when focus is gained. + * @param[in] styleManager The StyleManager object. + * @param[in] change Information denoting what has changed. */ - virtual void OnKeyInputFocusGained(); + virtual void OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change ); + + // Size negotiation /** - * @brief Called when the control loses key input focus. + * @brief Called whenever the Control's size is set. * - * Should be overridden by derived classes if they need to customize what happens when focus is lost. + * @param[in] size The new size. */ - virtual void OnKeyInputFocusLost(); - - // From CustomActorImpl, derived classes can override these. + virtual void OnControlSizeSet( const Vector3& size ); - /** - * @copydoc Dali::CustomActorImpl::OnSizeAnimation(Animation&, const Vector3&) - */ - virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize); + // Accessibility /** - * @copydoc Dali::CustomActorImpl::OnTouchEvent(const TouchEvent&) + * @brief This method is called when the control is accessibility activated. + * + * Derived classes should override this to perform custom accessibility activation. */ - virtual bool OnTouchEvent(const TouchEvent& event); + virtual void OnAccessibilityActivated(); /** - * @copydoc Dali::CustomActorImpl::OnHoverEvent(const HoverEvent&) + * @brief This method should be overridden by deriving classes when they wish to respond the accessibility + * pan gesture. + * + * @param[in] gesture The pan gesture. + * @return true if the pan gesture has been consumed by this control */ - virtual bool OnHoverEvent(const HoverEvent& event); + virtual bool OnAccessibilityPan(PanGesture gesture); /** - * @copydoc Dali::CustomActorImpl::OnKeyEvent(const KeyEvent&) + * @brief This method should be overridden by deriving classes when they wish to respond the accessibility + * touch event. + * + * @param[in] touchEvent The touch event. + * @return true if the touch event has been consumed by this control */ - virtual bool OnKeyEvent(const KeyEvent& event); + virtual bool OnAccessibilityTouch(const TouchEvent& touchEvent); /** - * @copydoc Dali::CustomActorImpl::OnMouseWheelEvent(const MouseWheelEvent&) + * @brief This method should be overridden by deriving classes when they wish to respond + * the accessibility up and down action (i.e. value change of slider control). + * + * @param[in] isIncrease Whether the value should be increased or decreased + * @return true if the value changed action has been consumed by this control */ - virtual bool OnMouseWheelEvent(const MouseWheelEvent& event); + virtual bool OnAccessibilityValueChange(bool isIncrease); - /** - * @copydoc Dali::CustomActorImpl::OnCalculateRelayoutSize() - */ - virtual void OnCalculateRelayoutSize( Dimension::Type dimension ); + // Keyboard focus /** - * @copydoc Dali::CustomActorImpl::OnLayoutNegotiated() + * @brief Called when the control gains key input focus. + * + * Should be overridden by derived classes if they need to customize what happens when focus is gained. */ - virtual void OnLayoutNegotiated( float size, Dimension::Type dimension ); + virtual void OnKeyInputFocusGained(); /** - * @copydoc Dali::CustomActorImpl::OnRelayout() + * @brief Called when the control loses key input focus. + * + * Should be overridden by derived classes if they need to customize what happens when focus is lost. */ - virtual void OnRelayout( const Vector2& size, RelayoutContainer& container ); + virtual void OnKeyInputFocusLost(); /** - * @copydoc Dali::CustomActorImpl::OnSetResizePolicy() + * @brief Gets the next keyboard focusable actor in this control towards the given direction. + * + * A control needs to override this function in order to support two dimensional keyboard navigation. + * @param[in] currentFocusedActor The current focused actor. + * @param[in] direction The direction to move the focus towards. + * @param[in] loopEnabled Whether the focus movement should be looped within the control. + * @return the next keyboard focusable actor in this control or an empty handle if no actor can be focused. */ - virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension ); + virtual Actor GetNextKeyboardFocusableActor(Actor currentFocusedActor, Toolkit::Control::KeyboardFocusNavigationDirection direction, bool loopEnabled); /** - * @copydoc Dali::CustomActorImpl::CalculateChildSize() + * @brief Informs this control that its chosen focusable actor will be focused. + * + * This allows the application to preform any actions if wishes + * before the focus is actually moved to the chosen actor. + * + * @param[in] commitedFocusableActor The commited focusable actor. */ - virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension ); + virtual void OnKeyboardFocusChangeCommitted(Actor commitedFocusableActor); - // From CustomActorImpl, derived classes should NOT override these. + // Gestures /** - * @brief Sends a request to relayout this control. - * - * The control will be relaid out after the - * Dali::Stage::SignalMessageQueueFlushed() signal is emitted. + * @brief Called whenever a pinch gesture is detected on this control. * - * It calls OnControlStageConnection() to notify derived classes. + * This can be overridden by deriving classes when pinch detection + * is enabled. The default behaviour is to scale the control by the + * pinch scale. * - * @see Dali::CustomActorImpl::OnStageConnection() - */ - virtual void OnStageConnection(); - - /** - * @copydoc Dali::CustomActorImpl::OnStageDisconnection() + * @note If overridden, then the default behaviour will not occur. + * @note Pinch detection should be enabled via EnableGestureDetection(). + * @param[in] pinch The pinch gesture. + * @see EnableGestureDetection */ - virtual void OnStageDisconnection(); + virtual void OnPinch(const PinchGesture& pinch); /** - * @copydoc Dali::CustomActorImpl::OnChildAdd(Actor&) + * @brief Called whenever a pan gesture is detected on this control. + * + * This should be overridden by deriving classes when pan detection + * is enabled. + * + * @note There is no default behaviour with panning. + * @note Pan detection should be enabled via EnableGestureDetection(). + * @param[in] pan The pan gesture. + * @see EnableGestureDetection */ - virtual void OnChildAdd(Actor& child); + virtual void OnPan( const PanGesture& pan ); /** - * @copydoc Dali::CustomActorImpl::OnChildRemove(Actor&) + * @brief Called whenever a tap gesture is detected on this control. + * + * This should be overridden by deriving classes when tap detection + * is enabled. + * + * @note There is no default behaviour with a tap. + * @note Tap detection should be enabled via EnableGestureDetection(). + * @param[in] tap The tap gesture. + * @see EnableGestureDetection */ - virtual void OnChildRemove(Actor& child); + virtual void OnTap( const TapGesture& tap ); /** - * @copydoc Dali::CustomActorImpl::OnSizeSet(const Vector3&) + * @brief Called whenever a long press gesture is detected on this control. + * + * This should be overridden by deriving classes when long press + * detection is enabled. + * + * @note There is no default behaviour associated with a long press. + * @note Long press detection should be enabled via EnableGestureDetection(). + * @param[in] longPress The long press gesture. + * @see EnableGestureDetection */ - virtual void OnSizeSet(const Vector3& targetSize); + virtual void OnLongPress( const LongPressGesture& longPress ); // From ConnectionTrackerInterface @@ -629,7 +620,7 @@ private: * * @return The extension if available, NULL otherwise */ - virtual Extension* GetExtension() + virtual Extension* GetControlExtension() { return NULL; } @@ -643,9 +634,26 @@ private: class Impl; Impl* mImpl; - friend class Internal::KeyInputFocusManager; ///< KeyInputFocusManager needs to call several methods which are private. // TODO: Remove }; +/** + * @brief Get implementation from the handle + * + * @pre handle is initialized and points to a control + * @param handle + * @return implementation + */ +Internal::Control& GetImplementation( Dali::Toolkit::Control& handle ); + +/** + * @brief Get implementation from the handle + * + * @pre handle is initialized and points to a control + * @param handle + * @return implementation + */ +const Internal::Control& GetImplementation( const Dali::Toolkit::Control& handle ); + } // namespace Internal } // namespace Toolkit diff --git a/dali-toolkit/public-api/controls/control.cpp b/dali-toolkit/public-api/controls/control.cpp index 5bbc4e7..18eaeeb 100644 --- a/dali-toolkit/public-api/controls/control.cpp +++ b/dali-toolkit/public-api/controls/control.cpp @@ -36,8 +36,8 @@ Control::Control() { } -Control::Control(const Control& uiControl) -: CustomActor( uiControl ? static_cast< const Internal::Control& >( uiControl.GetImplementation() ).GetOwner() : NULL) +Control::Control( const Control& uiControl ) +: CustomActor( uiControl ) { } @@ -59,99 +59,84 @@ Control Control::DownCast( BaseHandle handle ) return DownCast< Control, Internal::Control >(handle); } -Internal::Control& Control::GetImplementation() -{ - return static_cast(CustomActor::GetImplementation()); -} - -const Internal::Control& Control::GetImplementation() const -{ - return static_cast(CustomActor::GetImplementation()); -} - void Control::SetKeyInputFocus() { - GetImplementation().SetKeyInputFocus(); + Internal::GetImplementation(*this).SetKeyInputFocus(); } bool Control::HasKeyInputFocus() { - return GetImplementation().HasKeyInputFocus(); + return Internal::GetImplementation(*this).HasKeyInputFocus(); } void Control::ClearKeyInputFocus() { - GetImplementation().ClearKeyInputFocus(); + Internal::GetImplementation(*this).ClearKeyInputFocus(); } PinchGestureDetector Control::GetPinchGestureDetector() const { - return GetImplementation().GetPinchGestureDetector(); + return Internal::GetImplementation(*this).GetPinchGestureDetector(); } PanGestureDetector Control::GetPanGestureDetector() const { - return GetImplementation().GetPanGestureDetector(); + return Internal::GetImplementation(*this).GetPanGestureDetector(); } TapGestureDetector Control::GetTapGestureDetector() const { - return GetImplementation().GetTapGestureDetector(); + return Internal::GetImplementation(*this).GetTapGestureDetector(); } LongPressGestureDetector Control::GetLongPressGestureDetector() const { - return GetImplementation().GetLongPressGestureDetector(); + return Internal::GetImplementation(*this).GetLongPressGestureDetector(); } void Control::SetStyleName( const std::string& styleName ) { - GetImplementation().SetStyleName( styleName ); + Internal::GetImplementation(*this).SetStyleName( styleName ); } const std::string& Control::GetStyleName() const { - return GetImplementation().GetStyleName(); + return Internal::GetImplementation(*this).GetStyleName(); } void Control::SetBackgroundColor( const Vector4& color ) { - GetImplementation().SetBackgroundColor( color ); + Internal::GetImplementation(*this).SetBackgroundColor( color ); } Vector4 Control::GetBackgroundColor() const { - return GetImplementation().GetBackgroundColor(); + return Internal::GetImplementation(*this).GetBackgroundColor(); } void Control::SetBackgroundImage( Image image ) { - GetImplementation().SetBackgroundImage( image ); + Internal::GetImplementation(*this).SetBackgroundImage( image ); } void Control::ClearBackground() { - GetImplementation().ClearBackground(); -} - -Actor Control::GetBackgroundActor() const -{ - return GetImplementation().GetBackgroundActor(); + Internal::GetImplementation(*this).ClearBackground(); } Control::KeyEventSignalType& Control::KeyEventSignal() { - return GetImplementation().KeyEventSignal(); + return Internal::GetImplementation(*this).KeyEventSignal(); } Control::KeyInputFocusSignalType& Control::KeyInputFocusGainedSignal() { - return GetImplementation().KeyInputFocusGainedSignal(); + return Internal::GetImplementation(*this).KeyInputFocusGainedSignal(); } Control::KeyInputFocusSignalType& Control::KeyInputFocusLostSignal() { - return GetImplementation().KeyInputFocusLostSignal(); + return Internal::GetImplementation(*this).KeyInputFocusLostSignal(); } Control::Control(Internal::Control& implementation) diff --git a/dali-toolkit/public-api/controls/control.h b/dali-toolkit/public-api/controls/control.h index 7e4e693..7742bb7 100644 --- a/dali-toolkit/public-api/controls/control.h +++ b/dali-toolkit/public-api/controls/control.h @@ -166,20 +166,6 @@ public: */ static Control DownCast( BaseHandle handle ); - /** - * @brief Retrieve the Control implementation. - * - * @return The implementation. - */ - Internal::Control& GetImplementation(); - - /** - * @brief Retrieve the Control implementation. - * - * @return The implementation. - */ - const Internal::Control& GetImplementation() const; - // Key Input /** @@ -248,7 +234,7 @@ public: */ LongPressGestureDetector GetLongPressGestureDetector() const; - // Background + // Styling /** * @brief Sets the name of the style to be applied to the control. @@ -296,13 +282,6 @@ public: */ void ClearBackground(); - /** - * @brief Retrieves the actor used as the background for this control. - * - * @return The actor that used as the background for this control. - */ - Actor GetBackgroundActor() const; - // Signals /** diff --git a/dali-toolkit/public-api/controls/image-view/masked-image-view.cpp b/dali-toolkit/public-api/controls/image-view/masked-image-view.cpp deleted file mode 100644 index 1b7bd37..0000000 --- a/dali-toolkit/public-api/controls/image-view/masked-image-view.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2015 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. - * - */ - -// INTERNAL INCLUDES -#include -#include - -namespace Dali -{ - -namespace Toolkit -{ - -const float MaskedImageView::DEFAULT_MAXIMUM_SOURCE_SCALE(3.0f); - -MaskedImageView::MaskedImageView() -{ -} - -MaskedImageView::MaskedImageView( const MaskedImageView& handle ) -: Control( handle ) -{ -} - -MaskedImageView& MaskedImageView::operator=( const MaskedImageView& handle ) -{ - if( &handle != this ) - { - Control::operator=( handle ); - } - return *this; -} - -MaskedImageView::~MaskedImageView() -{ -} - -MaskedImageView MaskedImageView::New( unsigned int targetWidth, - unsigned int targetHeight, - Image sourceImage, - Image maskImage ) -{ - return Internal::MaskedImageView::New( targetWidth, targetHeight, sourceImage, maskImage ); -} - -MaskedImageView MaskedImageView::DownCast( BaseHandle handle ) -{ - return Control::DownCast( handle ); -} - -void MaskedImageView::SetSourceImage( Image sourceImage ) -{ - GetImpl(*this).SetSourceImage( sourceImage ); -} - -Image MaskedImageView::GetSourceImage() -{ - return GetImpl(*this).GetSourceImage(); -} - -void MaskedImageView::SetMaskImage( Image sourceImage ) -{ - GetImpl(*this).SetMaskImage( sourceImage ); -} - -Image MaskedImageView::GetMaskImage() -{ - return GetImpl(*this).GetMaskImage(); -} - -Property::Index MaskedImageView::GetPropertyIndex( MaskedImageView::CustomProperty customProperty ) const -{ - return GetImpl(*this).GetPropertyIndex( customProperty ); -} - -void MaskedImageView::Pause() -{ - GetImpl(*this).Pause(); -} - -void MaskedImageView::Resume() -{ - GetImpl(*this).Resume(); -} - -bool MaskedImageView::IsPaused() const -{ - return GetImpl(*this).IsPaused(); -} - -void MaskedImageView::SetEditMode( MaskedImageView::EditMode editMode ) -{ - GetImpl(*this).SetEditMode( editMode ); -} - -MaskedImageView::EditMode MaskedImageView::GetEditMode() const -{ - return GetImpl(*this).GetEditMode(); -} - -void MaskedImageView::SetSourceAspectRatio( float widthOverHeight ) -{ - GetImpl(*this).SetSourceAspectRatio( widthOverHeight ); -} - -float MaskedImageView::GetSourceAspectRatio() const -{ - return GetImpl(*this).GetSourceAspectRatio(); -} - -void MaskedImageView::SetMaximumSourceScale( float scale ) -{ - GetImpl(*this).SetMaximumSourceScale( scale ); -} - -float MaskedImageView::GetMaximumSourceScale() const -{ - return GetImpl(*this).GetMaximumSourceScale(); -} - -void MaskedImageView::SetSourceRotation( MaskedImageView::ImageRotation rotation ) -{ - GetImpl(*this).SetSourceRotation( rotation ); -} - -MaskedImageView::ImageRotation MaskedImageView::GetSourceRotation() const -{ - return GetImpl(*this).GetSourceRotation(); -} - -MaskedImageView::MaskedImageViewSignal& MaskedImageView::MaskFinishedSignal() -{ - return GetImpl(*this).MaskFinishedSignal(); -} - -MaskedImageView::MaskedImageView(Internal::MaskedImageView& implementation) -: Control(implementation) -{ -} - -MaskedImageView::MaskedImageView( Dali::Internal::CustomActor* internal ) -: Control( internal ) -{ - VerifyCustomActorPointer(internal); -} - -} // namespace Toolkit - -} // namespace Dali diff --git a/dali-toolkit/public-api/controls/image-view/masked-image-view.h b/dali-toolkit/public-api/controls/image-view/masked-image-view.h deleted file mode 100644 index b4e6208..0000000 --- a/dali-toolkit/public-api/controls/image-view/masked-image-view.h +++ /dev/null @@ -1,301 +0,0 @@ -#ifndef __DALI_TOOLKIT_MASKED_IMAGE_VIEW_H__ -#define __DALI_TOOLKIT_MASKED_IMAGE_VIEW_H__ - -/* - * Copyright (c) 2015 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. - * - */ - -// INTERNAL INCLUDES -#include - -namespace Dali -{ - -namespace Toolkit -{ - -namespace Internal DALI_INTERNAL -{ -class MaskedImageView; -} - -/** - * @brief MaskedImageView displays the result of an image created from a masking operation. - * - * Masking operations: - * - Firstly a target image size is chosen. The MaskedImageView handles the creation of this image internally. Initially the - * target image will be filled according to the BACKGROUND_COLOR property. - * - A source image is provided and positioned with the target image area. The position of the source image (in pixels), can - * be controlled using the SOURCE_OFFSET and SOURCE_SIZE properties. By default the source image is centered within the target - * image, and stretched to fill. Note that by default, no attempt is made to maintain the aspect ratio of the source image. - * - A mask image is provided and positioned in the same way as the source image, using the MASK_OFFSET and MASK_SIZE properties. - * - Conceptually the source image is then painted using the mask image as a stencil. Areas of the source which overlap with opaque - * areas of the mask, will be painted into the target image. However where the mask is transparent, the source will be faded away. - * Note that the edge of the mask image will be stretched to cover the entire target area. - * - * Initially MaskedImageView will perform the masking operation on a per-frame basis. This can impact performance, and may be - * avoided by calling Pause() e.g. when the source & mask positions are not being modified. The Resume() method can then be called - * to continue the masking operation when required. - */ -class DALI_IMPORT_API MaskedImageView : public Control -{ -public: - - /** - * @brief The custom properties installed by this control. - */ - enum CustomProperty - { - BACKGROUND_COLOR, ///< Name "background-color", type Vector4 - SOURCE_SIZE, ///< Name "source-size", type Vector2 - SOURCE_OFFSET, ///< Name "source-offset", type Vector2 - MASK_SIZE, ///< Name "mask-size", type Vector2 - MASK_OFFSET, ///< Name "mask-offset", type Vector2 - - CUSTOM_PROPERTY_COUNT - }; - - /** - * @brief Edit mode for this control. - * - * @see SetEditMode() - */ - enum EditMode - { - EDIT_DISABLED, ///< Editting is disabled - EDIT_SOURCE, ///< Editting affects the source image - EDIT_MASK ///< Editting affects the mask - }; - - /** - * @brief The rotation of the image. - * - * @see SetSourceRotation() - */ - enum ImageRotation - { - ROTATE_0, ///< No rotation - ROTATE_90, ///< Image is rotated clockwise by 90 degrees - ROTATE_180, ///< Image is rotated clockwise by 180 degrees - ROTATE_270 ///< Image is rotated clockwise by 270 degrees - }; - - static const float DEFAULT_MAXIMUM_SOURCE_SCALE; ///< Default SetMaximumSourceScale() value - - /** - * @brief Creates an empty MaskedImageView handle. - */ - MaskedImageView(); - - /** - * @brief Copy constructor. - * - * Creates another handle that points to the same real object - * @param handle to copy from - */ - MaskedImageView( const MaskedImageView& handle ); - - /** - * @brief Assignment operator. - * - * Changes this handle to point to another real object - * @param[in] handle the handle of the object to re-assign this to - * @return a reference to this - */ - MaskedImageView& operator=( const MaskedImageView& handle ); - - /** - * @brief Destructor - * - * This is non-virtual since derived Handle types must not contain data or virtual methods. - */ - ~MaskedImageView(); - - /** - * @brief Create the MaskedImageView control. - * - * @param[in] targetWidth The width of the target image - * @param[in] targetHeight The height of the target image - * @param[in] sourceImage The source image - * @param[in] maskImage The mask image - * @return A handle to the MaskedImageView control. - */ - static MaskedImageView New( unsigned int targetWidth, - unsigned int targetHeight, - Image sourceImage, - Image maskImage ); - - /** - * @brief Downcast an Object handle to MaskedImageView. - * - * If handle points to an MaskedImageView the downcast produces - * valid handle. If not the returned handle is left uninitialized. - * - * @param[in] handle Handle to an object - * @return handle to a MaskedImageView or an uninitialized handle - */ - static MaskedImageView DownCast( BaseHandle handle ); - - /** - * @brief Set the image used as a source in the masking operation. - * - * @param[in] sourceImage The source image - */ - void SetSourceImage( Image sourceImage ); - - /** - * @brief Retrieve the image used as a source in the masking operation. - * - * @return sourceImage The source image - */ - Image GetSourceImage(); - - /** - * @brief Set the image used as a mask in the masking operation. - * - * @param[in] maskImage The mask image - */ - void SetMaskImage( Image maskImage ); - - /** - * @brief Retrieve the image used as a mask in the masking operation. - * - * @return sourceImage The mask image - */ - Image GetMaskImage(); - - /** - * @brief Get the property index for a custom MaskedImageView property. - * - * @param[in] customProperty A custom property enum defined in this class. - * @return The property index e.g. for use with Animation::AnimateTo() - */ - Dali::Property::Index GetPropertyIndex( CustomProperty customProperty ) const; - - /** - * @brief Pause the masking operation to improve performance. - * - * Call this when the source & mask positions etc. are not being modified. - */ - void Pause(); - - /** - * @brief Resume the masking operation. - * - */ - void Resume(); - - /** - * @brief Query whether the masking operation has been paused. - * - * @return True if the masking operation has been paused. - */ - bool IsPaused() const; - - /** - * @brief Enable or disable an edit mode. - * - * The default is EDIT_DISABLED. - * @param[in] editMode The edit mode required. - */ - void SetEditMode( EditMode editMode ); - - /** - * @brief Query which edit mode is enabled. - */ - EditMode GetEditMode() const; - - /** - * @brief Set the aspect ratio to be preserved when editing the source image. - * - * @param[in] widthOverHeight The aspect ratio i.e. width divided by height. If a value - * of zero or less is set, then the aspect ratio of the source image will be ignored. - */ - void SetSourceAspectRatio( float widthOverHeight ); - - /** - * @brief Query the aspect ratio preserved when editing the source image. - * - * @return The aspect ratio (width divided by height) or zero if no aspect ratio is set. - */ - float GetSourceAspectRatio() const; - - /** - * @brief Set the maximum scale applied when editing the source image. - * - * The minimum scale is implied by the target width/height i.e. the source image will - * always fill that area when edit mode is enabled. - * @param[in] scale The maximum scale. - */ - void SetMaximumSourceScale( float scale ); - - /** - * @brief Query the maximum scale applied when editing the source image. - * - * @return The maximum scale. - */ - float GetMaximumSourceScale() const; - - /** - * @brief Set the rotation applied to the source image. - * - * @param[in] rotation The new rotation; by default the source image is not rotated (ROTATE_0). - */ - void SetSourceRotation( ImageRotation rotation ); - - /** - * @brief Query the rotation applied to the source image. - * - * @return The current rotation. - */ - ImageRotation GetSourceRotation() const; - -public: /* Signals */ - - /// @brief Finished signal type. - typedef Signal< void (MaskedImageView& source) > MaskedImageViewSignal; - - /** - * @brief Signal emitted when the render task which targets the - * frame buffer of the masked image has finished. - * - * This signal carries information of the control handle to the callback function. - * @return the signal - */ - MaskedImageViewSignal& MaskFinishedSignal(); - -public: // Not intended for application developers - - /** - * @brief Creates a handle using the Toolkit::Internal implementation. - * - * @param[in] implementation The Control implementation. - */ - DALI_INTERNAL MaskedImageView(Internal::MaskedImageView& implementation); - - /** - * @brief Allows the creation of this Control from an Internal::CustomActor pointer. - * - * @param[in] internal A pointer to the internal CustomActor. - */ - explicit DALI_INTERNAL MaskedImageView(Dali::Internal::CustomActor* internal); -}; - -} // namespace Toolkit - -} // namespace Dali - -#endif // __DALI_TOOLKIT_MASKED_IMAGE_VIEW_H__ diff --git a/dali-toolkit/public-api/file.list b/dali-toolkit/public-api/file.list index 3607815..d64c5d2 100755 --- a/dali-toolkit/public-api/file.list +++ b/dali-toolkit/public-api/file.list @@ -22,9 +22,7 @@ public_api_src_files = \ $(public_api_src_dir)/controls/table-view/table-view.cpp \ $(public_api_src_dir)/controls/text-controls/text-label.cpp \ $(public_api_src_dir)/controls/text-controls/text-field.cpp \ - $(public_api_src_dir)/controls/text-controls/text-selection-popup.cpp \ $(public_api_src_dir)/controls/gaussian-blur-view/gaussian-blur-view.cpp \ - $(public_api_src_dir)/controls/image-view/masked-image-view.cpp \ $(public_api_src_dir)/focus-manager/focus-manager.cpp \ $(public_api_src_dir)/focus-manager/keyboard-focus-manager.cpp \ $(public_api_src_dir)/focus-manager/keyinput-focus-manager.cpp \ @@ -56,9 +54,6 @@ public_api_default_controls_header_files = \ public_api_gaussian_blur_view_header_files = \ $(public_api_src_dir)/controls/gaussian-blur-view/gaussian-blur-view.h -public_api_image_view_header_files = \ - $(public_api_src_dir)/controls/image-view/masked-image-view.h - public_api_item_view_header_files = \ $(public_api_src_dir)/controls/scrollable/item-view/default-item-layout.h \ $(public_api_src_dir)/controls/scrollable/item-view/item-factory.h \ @@ -83,8 +78,7 @@ public_api_table_view_header_files = \ public_api_text_controls_header_files = \ $(public_api_src_dir)/controls/text-controls/text-label.h \ - $(public_api_src_dir)/controls/text-controls/text-field.h \ - $(public_api_src_dir)/controls/text-controls/text-selection-popup.h + $(public_api_src_dir)/controls/text-controls/text-field.h public_api_focus_manager_header_files = \ $(public_api_src_dir)/focus-manager/focus-manager.h \