utc-Dali-ProgressBar.cpp
utc-Dali-PushButton.cpp
utc-Dali-RadioButton.cpp
+ utc-Dali-ToggleButton.cpp
utc-Dali-ScrollViewEffect.cpp
utc-Dali-SuperBlurView.cpp
utc-Dali-Toolkit.cpp
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <iostream>
+#include <stdlib.h>
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+#include <dali/integration-api/events/touch-event-integ.h>
+#include <dali-toolkit/devel-api/controls/buttons/toggle-button.h>
+
+
+using namespace Dali;
+using namespace Dali::Toolkit;
+
+void dali_toggle_button_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+
+void dali_toggle_button_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+namespace
+{
+static const char* TEST_IMAGE_ONE = TEST_RESOURCE_DIR "/icon-delete.png";
+static const char* TEST_IMAGE_TWO = TEST_RESOURCE_DIR "/icon-edit.png";
+static const char* TEST_IMAGE_THREE = TEST_RESOURCE_DIR "/popup_tail_down.png";
+static const char* TEST_IMAGE_FOUR = TEST_RESOURCE_DIR "/popup_tail_up.png";
+
+static const Vector2 INSIDE_TOUCH_POINT_POSITON = Vector2( 240, 400 );
+static const Vector3 BUTTON_POSITON_TO_GET_INSIDE_TOUCH_EVENTS = Vector3( 200, 360, 0 );
+static const Size BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS = Size( 100, 100 );
+
+static bool gObjectCreatedCallBackCalled;
+
+static void TestCallback(BaseHandle handle)
+{
+ gObjectCreatedCallBackCalled = true;
+}
+
+Dali::Integration::Point GetPointDownInside()
+{
+ Dali::Integration::Point point;
+ point.SetState( PointState::DOWN );
+ point.SetScreenPosition( INSIDE_TOUCH_POINT_POSITON );
+ return point;
+}
+
+Dali::Integration::Point GetPointUpInside()
+{
+ Dali::Integration::Point point;
+ point.SetState( PointState::UP );
+ point.SetScreenPosition( INSIDE_TOUCH_POINT_POSITON );
+ return point;
+}
+
+}
+
+int UtcDaliToggleButtonConstructorP(void)
+{
+ TestApplication application;
+ tet_infoline(" UtcDaliToggleButtonConstructorP");
+
+ ToggleButton button;
+ DALI_TEST_CHECK( !button );
+ END_TEST;
+}
+
+int UtcDaliToggleButtonCopyConstructorP(void)
+{
+ TestApplication application;
+ tet_infoline(" UtcDaliToggleButtonCopyConstructorP");
+
+ // Initialize an object, ref count == 1
+ ToggleButton button = ToggleButton::New();
+
+ ToggleButton copy( button );
+ DALI_TEST_CHECK( copy );
+ END_TEST;
+}
+
+int UtcDaliToggleButtonAssignmentOperatorP(void)
+{
+ TestApplication application;
+ tet_infoline(" UtcDaliToggleButtonAssignmentOperatorP");
+
+ ToggleButton button = ToggleButton::New();
+
+ ToggleButton copy( button );
+ DALI_TEST_CHECK( copy );
+
+ DALI_TEST_CHECK( button == copy );
+ END_TEST;
+}
+
+int UtcDaliToggleButtonNewP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToggleButtonNewP");
+
+ // Create the Slider actor
+ ToggleButton toggleButton;
+
+ DALI_TEST_CHECK( !toggleButton );
+
+ toggleButton = ToggleButton::New();
+
+ DALI_TEST_CHECK( toggleButton );
+
+ ToggleButton toggleButton2(toggleButton);
+
+ DALI_TEST_CHECK( toggleButton2 == toggleButton );
+
+ //Additional check to ensure object is created by checking if it's registered
+ ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
+ DALI_TEST_CHECK( registry );
+
+ gObjectCreatedCallBackCalled = false;
+ registry.ObjectCreatedSignal().Connect( &TestCallback );
+ {
+ ToggleButton toggleButton = ToggleButton::New();
+ }
+ DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
+ END_TEST;
+}
+
+int UtcDaliToggleButtonDestructorP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliToggleButtonDestructorP");
+
+ ToggleButton* toggleButton = new ToggleButton();
+ delete toggleButton;
+
+ DALI_TEST_CHECK( true );
+ END_TEST;
+}
+
+int UtcDaliToggleButtonDownCast(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliToggleButtonDownCast");
+
+ Handle handle = ToggleButton::New();
+ ToggleButton toggleButton = ToggleButton::DownCast( handle );
+
+ DALI_TEST_CHECK( toggleButton == handle );
+ END_TEST;
+}
+
+int UtcDaliToggleButtonToggleStatesProperty(void)
+{
+ ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
+ tet_infoline(" UtcDaliToggleButtonToggleStatesProperty");
+
+ // Create the ToggleButton actor
+ ToggleButton toggleButton = ToggleButton::New();
+ Stage::GetCurrent().Add( toggleButton );
+ toggleButton.SetParentOrigin(ParentOrigin::TOP_LEFT);
+ toggleButton.SetAnchorPoint(ParentOrigin::TOP_LEFT);
+ toggleButton.SetPosition( 0.0f, 0.0f );
+
+ {// Check empty array
+ Property::Array toggleIcons;
+ toggleButton.SetProperty( Toolkit::ToggleButton::Property::STATE_VISUALS, toggleIcons );
+
+ application.SendNotification();
+ application.Render();
+
+ Property::Array resultIcons;
+ resultIcons = toggleButton.GetProperty( Toolkit::ToggleButton::Property::STATE_VISUALS ).Get<Property::Array>();
+ DALI_TEST_CHECK( resultIcons.Count() == 0 );
+ }
+
+ {// Check non-empty Array
+ Property::Array toggleIcons;
+ toggleIcons.PushBack( TEST_IMAGE_ONE ); //Icons path
+ toggleIcons.PushBack( TEST_IMAGE_TWO );
+ toggleIcons.PushBack( TEST_IMAGE_THREE );
+ toggleIcons.PushBack( TEST_IMAGE_FOUR );
+ toggleButton.SetProperty( Toolkit::ToggleButton::Property::STATE_VISUALS, toggleIcons );
+
+ application.SendNotification();
+ application.Render();
+
+ Property::Array resultIcons;
+ resultIcons = toggleButton.GetProperty( Toolkit::ToggleButton::Property::STATE_VISUALS ).Get<Property::Array>();
+
+ // Check that the result is the same as
+ DALI_TEST_EQUALS( toggleIcons.Count(), resultIcons.Count(), TEST_LOCATION );
+ DALI_TEST_CHECK( toggleIcons[0].Get<std::string>() == resultIcons[0].Get<std::string>() );
+ DALI_TEST_CHECK( toggleIcons[1].Get<std::string>() == resultIcons[1].Get<std::string>() );
+ DALI_TEST_CHECK( toggleIcons[2].Get<std::string>() == resultIcons[2].Get<std::string>() );
+ DALI_TEST_CHECK( toggleIcons[3].Get<std::string>() == resultIcons[3].Get<std::string>() );
+ }
+
+ {// Check property::map
+ Property::Map propertyMap1;
+ Vector4 testColor1( 1.f, 0.5f, 0.3f, 0.2f );
+ propertyMap1.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
+ propertyMap1.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, testColor1);
+
+ Property::Map propertyMap2;
+ Vector4 testColor2( 0.5f, 1.f, 0.3f, 0.2f );
+ propertyMap2.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
+ propertyMap2.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, testColor2);
+
+ Property::Map propertyMap3;
+ Vector4 testColor3( 1.f, 0.5f, 1.f, 0.2f );
+ propertyMap3.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
+ propertyMap3.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, testColor3);
+
+ Property::Array toggleMaps;
+ toggleMaps.Add( propertyMap1 );
+ toggleMaps.Add( propertyMap2 );
+ toggleMaps.Add( propertyMap3 );
+ toggleButton.SetProperty( Toolkit::ToggleButton::Property::STATE_VISUALS, toggleMaps );
+
+ application.SendNotification();
+ application.Render();
+
+ Property::Array resultMaps;
+ resultMaps = toggleButton.GetProperty( Toolkit::ToggleButton::Property::STATE_VISUALS ).Get<Property::Array>();
+
+ // Check that the result
+ DALI_TEST_EQUALS( toggleMaps.Count(), resultMaps.Count(), TEST_LOCATION );
+ }
+
+ END_TEST;
+}
+
+int UtcDaliToggleButtonToggleTipsProperty( void )
+{
+ ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
+ tet_infoline(" UtcDaliToggleButtonToggleTipsProperty");
+
+ // Create the ToggleButton actor
+ ToggleButton toggleButton = ToggleButton::New();
+ Stage::GetCurrent().Add( toggleButton );
+ toggleButton.SetParentOrigin(ParentOrigin::TOP_LEFT);
+ toggleButton.SetAnchorPoint(ParentOrigin::TOP_LEFT);
+ toggleButton.SetPosition( 0.0f, 0.0f );
+
+ { // Check empty tip array
+ Property::Array toggleIcons;
+ toggleIcons.PushBack( TEST_IMAGE_ONE ); //Icons path
+ toggleIcons.PushBack( TEST_IMAGE_TWO );
+ toggleIcons.PushBack( TEST_IMAGE_THREE );
+ toggleButton.SetProperty( Toolkit::ToggleButton::Property::STATE_VISUALS, toggleIcons );
+
+ Property::Array toggleTips;
+ toggleButton.SetProperty( Toolkit::ToggleButton::Property::TOOLTIPS, toggleTips );
+
+ application.SendNotification();
+ application.Render();
+
+ Property::Array resultTips;
+ resultTips = toggleButton.GetProperty( Toolkit::ToggleButton::Property::TOOLTIPS ).Get<Property::Array>();
+ DALI_TEST_CHECK( resultTips.Count() == 0 );
+ }
+
+ { // Check non-empty tip array
+ Property::Array toggleIcons;
+ toggleIcons.PushBack( TEST_IMAGE_ONE ); //Icons path
+ toggleIcons.PushBack( TEST_IMAGE_TWO );
+ toggleIcons.PushBack( TEST_IMAGE_THREE );
+ toggleButton.SetProperty( Toolkit::ToggleButton::Property::STATE_VISUALS, toggleIcons );
+
+ Property::Array toggleTips;
+ toggleTips.PushBack( "Button State A" ); //Tooltip string
+ toggleTips.PushBack( "Button State B" );
+ toggleTips.PushBack( "Button State C" );
+ toggleButton.SetProperty( Toolkit::ToggleButton::Property::TOOLTIPS, toggleTips );
+
+ application.SendNotification();
+ application.Render();
+
+ Property::Array resultTips;
+ resultTips = toggleButton.GetProperty( Toolkit::ToggleButton::Property::TOOLTIPS ).Get<Property::Array>();
+
+ //Check that the result is the same as
+ DALI_TEST_EQUALS( toggleTips.Count(), resultTips.Count(), TEST_LOCATION );
+ DALI_TEST_CHECK( toggleTips[0].Get<std::string>() == resultTips[0].Get<std::string>() );
+ DALI_TEST_CHECK( toggleTips[1].Get<std::string>() == resultTips[1].Get<std::string>() );
+ DALI_TEST_CHECK( toggleTips[2].Get<std::string>() == resultTips[2].Get<std::string>() );
+ DALI_TEST_CHECK( toggleTips[3].Get<std::string>() == resultTips[3].Get<std::string>() );
+ }
+ END_TEST;
+}
+
+int UtcDaliToggleButtonStateChange(void)
+{
+ ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
+ tet_infoline(" UtcDaliToggleButtonStateChange");
+
+ // Create the ToggleButton actor
+ ToggleButton toggleButton = ToggleButton::New();
+ Stage::GetCurrent().Add( toggleButton );
+ toggleButton.SetParentOrigin(ParentOrigin::TOP_LEFT);
+ toggleButton.SetAnchorPoint(ParentOrigin::TOP_LEFT);
+ toggleButton.SetPosition( BUTTON_POSITON_TO_GET_INSIDE_TOUCH_EVENTS );
+ toggleButton.SetSize( BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS );
+
+ Property::Array toggleIcons;
+ toggleIcons.PushBack( TEST_IMAGE_ONE ); //Icons path
+ toggleIcons.PushBack( TEST_IMAGE_TWO );
+ toggleIcons.PushBack( TEST_IMAGE_THREE );
+ toggleButton.SetProperty( Toolkit::ToggleButton::Property::STATE_VISUALS, toggleIcons );
+
+ Property::Array toggleTips;
+ toggleTips.PushBack( "Button State A" ); //Tooltip string
+ toggleTips.PushBack( "Button State B" );
+ toggleTips.PushBack( "Button State C" );
+ toggleButton.SetProperty( Toolkit::ToggleButton::Property::TOOLTIPS, toggleTips );
+
+ application.SendNotification();
+ application.Render();
+
+ Property::Array resultIcons;
+ resultIcons = toggleButton.GetProperty( Toolkit::ToggleButton::Property::STATE_VISUALS ).Get<Property::Array>();
+ DALI_TEST_EQUALS( toggleIcons.Count(), resultIcons.Count(), TEST_LOCATION );
+
+ Property::Array resultTips;
+ resultTips = toggleButton.GetProperty( Toolkit::ToggleButton::Property::TOOLTIPS ).Get<Property::Array>();
+ DALI_TEST_EQUALS( toggleTips.Count(), resultTips.Count(), TEST_LOCATION );
+
+ int index;
+ DALI_TEST_CHECK( toggleButton.GetProperty( Toolkit::ToggleButton::Property::CURRENT_STATE_INDEX ).Get( index ) );
+ DALI_TEST_EQUALS( index, 0, TEST_LOCATION );
+
+ Dali::Integration::TouchEvent event;
+
+ // Touch point down and up inside the button 3 times.
+ event = Dali::Integration::TouchEvent();
+ event.AddPoint( GetPointDownInside() );
+ application.ProcessEvent( event );
+
+ event = Dali::Integration::TouchEvent();
+ event.AddPoint( GetPointUpInside() );
+ application.ProcessEvent( event );
+
+ DALI_TEST_CHECK( toggleButton.GetProperty( Toolkit::ToggleButton::Property::CURRENT_STATE_INDEX ).Get( index ) );
+ DALI_TEST_EQUALS( index, 1, TEST_LOCATION );
+
+ event = Dali::Integration::TouchEvent();
+ event.AddPoint( GetPointDownInside() );
+ application.ProcessEvent( event );
+
+ event = Dali::Integration::TouchEvent();
+ event.AddPoint( GetPointUpInside() );
+ application.ProcessEvent( event );
+
+ DALI_TEST_CHECK( toggleButton.GetProperty( Toolkit::ToggleButton::Property::CURRENT_STATE_INDEX ).Get( index ) );
+ DALI_TEST_EQUALS( index, 2, TEST_LOCATION );
+
+ event = Dali::Integration::TouchEvent();
+ event.AddPoint( GetPointDownInside() );
+ application.ProcessEvent( event );
+
+ event = Dali::Integration::TouchEvent();
+ event.AddPoint( GetPointUpInside() );
+ application.ProcessEvent( event );
+
+ DALI_TEST_CHECK( toggleButton.GetProperty( Toolkit::ToggleButton::Property::CURRENT_STATE_INDEX ).Get( index ) );
+ DALI_TEST_EQUALS( index, 0, TEST_LOCATION );
+
+ END_TEST;
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2017 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 <dali-toolkit/devel-api/controls/buttons/toggle-button.h>
+
+// INTERNAL INCLUDES
+
+#include <dali-toolkit/internal/controls/buttons/toggle-button-impl.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+ToggleButton::ToggleButton()
+: Button()
+{
+}
+
+ToggleButton::ToggleButton( Internal::ToggleButton& implementation )
+: Button( implementation )
+{
+}
+
+ToggleButton::ToggleButton( const ToggleButton& toggleButton )
+: Button( toggleButton )
+{
+}
+
+ToggleButton& ToggleButton::operator=( const ToggleButton& toggleButton )
+{
+ if( &toggleButton != this )
+ {
+ Button::operator=( toggleButton );
+ }
+ return *this;
+}
+
+ToggleButton::ToggleButton( Dali::Internal::CustomActor* internal )
+: Button( internal )
+{
+ VerifyCustomActorPointer<Internal::ToggleButton>(internal);
+}
+
+ToggleButton::~ToggleButton()
+{
+}
+
+ToggleButton ToggleButton::New()
+{
+ return Internal::ToggleButton::New();
+}
+
+ToggleButton ToggleButton::DownCast( BaseHandle handle )
+{
+ return Control::DownCast<ToggleButton, Internal::ToggleButton>(handle);
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_TOOLKIT_TOGGLE_BUTTON_H__
+#define __DALI_TOOLKIT_TOGGLE_BUTTON_H__
+
+/*
+ * Copyright (c) 2017 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 <dali-toolkit/public-api/controls/buttons/button.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+// Forward declarations
+
+namespace Internal DALI_INTERNAL
+{
+// Forward declarations
+
+class ToggleButton;
+}
+/**
+ * @addtogroup dali_toolkit_controls_buttons
+ * @{
+ */
+
+/**
+ * @brief A ToggleButton allows the user to change a setting between two or more states.
+ *
+ * By default a ToggleButton emits a Button::StateChangedSignal() signal when it's clicked.
+ *
+ * Usage example: -
+ *
+ * @code
+ *
+ * void ToggleButtonExample::Create( Application& application )
+ * {
+ * ToggleButton button = ToggleButton::New();
+ * button.SetProperty( Toolkit::ToggleButton::Property::STATE_VISUALS, Property::Array()
+ * .Add( "A.png" )
+ * .Add( "B.png" )
+ * .Add( "C.png" ));
+ * or
+ *
+ * Property::Map propertyMap1;
+ * Vector4 testColor1( 1.f, 0.5f, 0.3f, 0.2f );
+ * propertyMap1.Insert(Visual::Property::TYPE, Visual::COLOR);
+ * propertyMap1.Insert(ColorVisual::Property::MIX_COLOR, testColor1);
+ *
+ * Property::Map propertyMap2;
+ * Vector4 testColor2( 0.5f, 1.f, 0.3f, 0.2f );
+ * propertyMap2.Insert(Visual::Property::TYPE, Visual::COLOR);
+ * propertyMap2.Insert(ColorVisual::Property::MIX_COLOR, testColor2);
+ *
+ * Property::Map propertyMap3;
+ * Vector4 testColor3( 1.f, 0.5f, 1.f, 0.2f );
+ * propertyMap3.Insert(Visual::Property::TYPE, Visual::COLOR);
+ * propertyMap3.Insert(ColorVisual::Property::MIX_COLOR, testColor3);
+ *
+ * button.SetProperty( Toolkit::ToggleButton::Property::STATE_VISUALS, Property::Array()
+ * .Add( propertyMap1 )
+ * .Add( propertyMap2 )
+ * .Add( propertyMap3 ));
+ *
+ * button.SetProperty( Toolkit::ToggleButton::Property::TOOLTIPS, Property::Array()
+ * .Add( "STATE A" )
+ * .Add( "STATE B" )
+ * .Add( "STATE C" ));
+ *
+ * Stage::GetCurrent().Add( button );
+ *
+ * // Connect to button signals emitted by the button
+ * button.ClickedSignal().Connect( this, &ToggleButtonExample::OnButtonClicked );
+ * }
+ *
+ * bool ToggleButtonExample::OnButtonClicked( Button button )
+ * {
+ * // Do something when the button is clicked
+ * return true;
+ * }
+ * @endcode
+ *
+ * See Button for more detail on signals and modifying states via properties.
+ */
+class DALI_IMPORT_API ToggleButton : public Button
+{
+public:
+ /**
+ * @brief The start and end property ranges for this control.
+ */
+ enum PropertyRange
+ {
+ PROPERTY_START_INDEX = Button::PROPERTY_END_INDEX + 1, ///< Toggle button start index
+ PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000 ///< Reserving 1000 property indices
+ };
+
+ /**
+ * @brief An enumeration of properties belonging to the ToggleButton class.
+ */
+ struct Property
+ {
+ enum
+ {
+ /**
+ * @brief The state visual array of toggle button.
+ * @details Name "stateVisuals", type Property::Array.
+ * It's a property array of property-maps or a property array of strings,
+ * property map expects a description of visual and
+ * string represents an image url.
+ * @note Mandatory
+ */
+ STATE_VISUALS = PROPERTY_START_INDEX,
+
+ /**
+ * @brief The tooltips of toggle button.
+ * @details Name "tooltips", type Property::Array.
+ * It's an array of toggle state tooltip strings.
+ * Each tooltip string should match a toggle state strictly.
+ * @note Mandatory
+ */
+ TOOLTIPS,
+
+ /**
+ * @brief The current state index of toggle button.
+ * @details Name "currentStateIndex", type integer.
+ * It just provides a property to get current state index.
+ * @note Optional
+ * @note The index is automatically changed when toggle button is clicked.
+ */
+ CURRENT_STATE_INDEX
+ };
+ };
+
+public:
+
+ /**
+ * @brief Create an uninitialized ToggleButton; this can be initialized with ToggleButton::New().
+ *
+ * Calling member functions with an uninitialized Dali::Object is not allowed.
+ */
+ ToggleButton();
+
+ /**
+ * @brief Copy constructor.
+ * @param[in] toggleButton Handle to an object
+ */
+ ToggleButton( const ToggleButton& toggleButton );
+
+ /**
+ * @brief Assignment operator.
+ * @param[in] toggleButton Handle to an object
+ * @return A reference to this
+ */
+ ToggleButton& operator=( const ToggleButton& toggleButton );
+
+ /**
+ * @brief Destructor
+ *
+ * This is non-virtual since derived Handle types must not contain data or virtual methods.
+ */
+ ~ToggleButton();
+
+ /**
+ * @brief Create an initialized ToggleButton.
+ *
+ * @return A handle to a newly allocated Dali resource.
+ */
+ static ToggleButton New();
+
+ /**
+ * @brief Downcast a handle to ToggleButton handle.
+ *
+ * If handle points to a ToggleButton the downcast produces valid
+ * handle. If not the returned handle is left uninitialized.
+ *
+ * @param[in] handle Handle to an object
+ * @return handle to a ToggleButton or an uninitialized handle
+ */
+ static ToggleButton DownCast( BaseHandle handle );
+
+public: // Not intended for application developers
+
+ /// @cond internal
+ /**
+ * @brief Creates a handle using the Toolkit::Internal implementation.
+ *
+ * @param[in] implementation The Control implementation.
+ */
+ DALI_INTERNAL ToggleButton( Internal::ToggleButton& implementation );
+
+ /**
+ * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
+ *
+ * @param[in] internal A pointer to the internal CustomActor.
+ */
+ DALI_INTERNAL ToggleButton( Dali::Internal::CustomActor* internal );
+ /// @endcond
+};
+
+/**
+ * @}
+ */
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_TOOLKIT_TOGGLE_BUTTON_H__
$(devel_api_src_dir)/controls/control-wrapper-impl.cpp \
$(devel_api_src_dir)/controls/bloom-view/bloom-view.cpp \
$(devel_api_src_dir)/controls/bubble-effect/bubble-emitter.cpp \
+ $(devel_api_src_dir)/controls/buttons/toggle-button.cpp \
$(devel_api_src_dir)/controls/effects-view/effects-view.cpp \
$(devel_api_src_dir)/controls/magnifier/magnifier.cpp \
$(devel_api_src_dir)/controls/navigation-view/navigation-view.cpp \
$(devel_api_src_dir)/controls/bubble-effect/bubble-emitter.h
devel_api_buttons_header_files = \
- $(devel_api_src_dir)/controls/buttons/button-devel.h
+ $(devel_api_src_dir)/controls/buttons/button-devel.h \
+ $(devel_api_src_dir)/controls/buttons/toggle-button.h
devel_api_builder_header_files = \
$(devel_api_src_dir)/builder/builder.h \
{
bool groupMyChildren = false;
- if( TreeNode::ARRAY == value->GetType() &&
+ if( TreeNode::ARRAY == value->GetType() && value->mFirstChild &&
( TreeNode::INTEGER == value->mFirstChild->GetType() ||
TreeNode::FLOAT == value->mFirstChild->GetType() ) )
{
--- /dev/null
+/*
+ * Copyright (c) 2017 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 "toggle-button-impl.h"
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/type-registry.h>
+#include <dali/public-api/object/type-registry-helper.h>
+#include <dali/public-api/images/resource-image.h>
+#include <dali/devel-api/scripting/scripting.h>
+#include <dali/public-api/object/property-array.h>
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/image-view/image-view.h>
+#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
+#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
+#include <dali-toolkit/devel-api/align-enums.h>
+#include <dali-toolkit/devel-api/controls/tooltip/tooltip-properties.h>
+#include <dali-toolkit/devel-api/visuals/text-visual-properties.h>
+#include <dali-toolkit/devel-api/controls/control-devel.h>
+
+#if defined(DEBUG_ENABLED)
+ extern Debug::Filter* gLogButtonFilter;
+#endif
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+namespace
+{
+
+BaseHandle Create()
+{
+ return Toolkit::ToggleButton::New();
+}
+
+// Properties
+DALI_TYPE_REGISTRATION_BEGIN( Toolkit::ToggleButton, Toolkit::Button, Create )
+
+DALI_PROPERTY_REGISTRATION( Toolkit, ToggleButton, "stateVisuals", ARRAY, STATE_VISUALS )
+DALI_PROPERTY_REGISTRATION( Toolkit, ToggleButton, "tooltips", ARRAY, TOOLTIPS )
+DALI_PROPERTY_REGISTRATION( Toolkit, ToggleButton, "currentStateIndex", INTEGER, CURRENT_STATE_INDEX )
+
+DALI_TYPE_REGISTRATION_END()
+
+} // unnamed namespace
+
+Dali::Toolkit::ToggleButton ToggleButton::New()
+{
+ DALI_LOG_INFO( gLogButtonFilter, Debug::General, "ToggleButton::New\n" );
+ // Create the implementation, temporarily owned on stack
+ IntrusivePtr< ToggleButton > internalToggleButton = new ToggleButton();
+
+ // Pass ownership to CustomActor
+ Dali::Toolkit::ToggleButton toggleButton( *internalToggleButton );
+
+ // Second-phase init of the implementation
+ // This can only be done after the CustomActor connection has been made...
+ internalToggleButton->Initialize();
+
+ return toggleButton;
+}
+
+ToggleButton::ToggleButton()
+: Button(),
+ mToggleStates(),
+ mToggleVisuals(),
+ mToggleSelectedVisuals(),
+ mToggleDisabledVisuals(),
+ mToggleDisabledSelectedVisuals(),
+ mToggleTooltips(),
+ mCurrentToggleIndex(0)
+{
+ DALI_LOG_INFO( gLogButtonFilter, Debug::General, "ToggleButton::Constructor\n" );
+ SetTogglableButton( false );
+}
+
+ToggleButton::~ToggleButton()
+{
+}
+
+void ToggleButton::OnInitialize()
+{
+ DALI_LOG_INFO( gLogButtonFilter, Debug::General, "ToggleButton::OnInitialize\n" );
+ Button::OnInitialize();
+
+ // Toggle button requires the Leave event.
+ Actor self = Self();
+ self.SetLeaveRequired( true );
+}
+
+void ToggleButton::SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value )
+{
+ Toolkit::ToggleButton toggleButton = Toolkit::ToggleButton::DownCast( Dali::BaseHandle( object ) );
+
+ DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "ToggleButton::SetProperty index[%d]\n", propertyIndex );
+
+ if ( toggleButton )
+ {
+ ToggleButton& toggleButtonImpl( GetImplementation( toggleButton ) );
+
+ switch ( propertyIndex )
+ {
+ case Toolkit::ToggleButton::Property::STATE_VISUALS:
+ {
+ Property::Array stateArray;
+ if( value.Get( stateArray ) )
+ {
+ toggleButtonImpl.SetToggleStates( stateArray );
+ }
+
+ break;
+ }
+ case Toolkit::ToggleButton::Property::TOOLTIPS:
+ {
+ Property::Array* tipArray = value.GetArray();
+ if( tipArray )
+ {
+ std::vector<std::string> tips;
+ size_t tipsCount = tipArray->Count();
+ tips.resize( tipsCount );
+ for( size_t i = 0; i != tipsCount; ++i )
+ {
+ tipArray->GetElementAt( i ).Get( tips[i] );
+ }
+ toggleButtonImpl.SetToggleTooltips(tips);
+ }
+ break;
+ }
+ default :
+ {
+ break;
+ }
+ } // end of switch
+ }
+}
+
+Property::Value ToggleButton::GetProperty( BaseObject* object, Property::Index propertyIndex )
+{
+ Property::Value value;
+
+ Toolkit::ToggleButton toggleButton = Toolkit::ToggleButton::DownCast( Dali::BaseHandle( object ) );
+
+ DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "ToggleButton::GetProperty index[%d]\n", propertyIndex );
+
+ if ( toggleButton )
+ {
+ ToggleButton& toggleButtonImpl( GetImplementation( toggleButton ) );
+
+ switch ( propertyIndex )
+ {
+ case Toolkit::ToggleButton::Property::STATE_VISUALS:
+ {
+ Property::Array array = toggleButtonImpl.GetToggleStates();
+ value = Property::Value( array );
+ break;
+ }
+ case Toolkit::ToggleButton::Property::TOOLTIPS:
+ {
+ Property::Value value1( Property::ARRAY );
+ Property::Array* tipArray = value1.GetArray();
+
+ if( tipArray )
+ {
+ std::vector<std::string> tips = toggleButtonImpl.GetToggleTooltips();
+ size_t tipsCount( tips.size() );
+ for( size_t i( 0 ); i != tipsCount; ++i )
+ {
+ tipArray->PushBack( tips[i] );
+ }
+ }
+ value = value1;
+ break;
+ }
+ case Toolkit::ToggleButton::Property::CURRENT_STATE_INDEX:
+ {
+ value = static_cast<int>(toggleButtonImpl.mCurrentToggleIndex);
+ break;
+ }
+ } // end of switch
+ }
+
+ return value;
+}
+
+void ToggleButton::CreateVisualsForAllStates( const Property::Array& states, std::vector<Toolkit::Visual::Base>& visuals )
+{
+ DALI_LOG_INFO( gLogButtonFilter, Debug::General, "ToggleButton::CreateVisualsForAllStates\n" );
+
+ visuals.clear();
+
+ for ( unsigned int i = 0; i < states.Count(); i++ )
+ {
+ Property::Value value( states[i] );
+
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base stateVisual;
+
+ if ( value.GetType() == Property::MAP )
+ {
+ Property::Map *map = value.GetMap();
+ if( map && !map->Empty() ) // Empty map results in current visual removal.
+ {
+ DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "ToggleButton::CreateVisuals Using Map\n" );
+ stateVisual = visualFactory.CreateVisual( *map );
+ }
+ }
+ else if ( value.GetType() == Property::STRING )
+ {
+ std::string imageUrl = value.Get<std::string>();
+ DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "ToggleButton::CreateVisuals Using image URL\n" );
+ if ( !imageUrl.empty() )
+ {
+ stateVisual = visualFactory.CreateVisual( imageUrl, ImageDimensions() );
+ }
+ }
+
+ if ( stateVisual )
+ {
+ stateVisual.SetDepthIndex( DepthIndex::CONTENT );
+ visuals.push_back( stateVisual );
+ }
+ } // end of for
+ DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "ToggleButton::CreateVisuals mToggleVisuals:%d\n", mToggleVisuals.size() );
+}
+
+void ToggleButton::SetToggleStates( const Property::Array& states )
+{ //this should really be generalized to be either string or maps so that any visual can be created.
+ DALI_LOG_INFO( gLogButtonFilter, Debug::General, "ToggleButton::SetToggleStates\n" );
+ if ( !states.Empty() )
+ {
+ mToggleStates.Clear();
+ mToggleStates = states;
+ /* New toggle button index from 0. */
+ mCurrentToggleIndex = 0;
+
+ // Create all visuals, save to mToggleVisuals.
+ CreateVisualsForAllStates( states, mToggleVisuals );
+ CreateVisualsForAllStates( states, mToggleSelectedVisuals );
+ CreateVisualsForAllStates( states, mToggleDisabledVisuals );
+ CreateVisualsForAllStates( states, mToggleDisabledSelectedVisuals );
+
+ DALI_LOG_INFO( gLogButtonFilter, Debug::General, "ToggleButton::Began to register visual.\n" );
+
+ PrepareVisual( Toolkit::DevelButton::Property::UNSELECTED_VISUAL, mToggleVisuals[mCurrentToggleIndex] );
+ PrepareVisual( Toolkit::DevelButton::Property::SELECTED_VISUAL, mToggleSelectedVisuals[mCurrentToggleIndex] );
+ PrepareVisual( Toolkit::DevelButton::Property::DISABLED_UNSELECTED_VISUAL, mToggleDisabledVisuals[mCurrentToggleIndex] );
+ PrepareVisual( Toolkit::DevelButton::Property::DISABLED_SELECTED_VISUAL, mToggleDisabledSelectedVisuals[mCurrentToggleIndex] );
+
+ RelayoutRequest();
+ }
+}
+
+Property::Array ToggleButton::GetToggleStates() const
+{
+ return mToggleStates;
+}
+
+void ToggleButton::SetToggleTooltips( std::vector<std::string>& tips )
+{
+ DALI_LOG_INFO( gLogButtonFilter, Debug::General, "ToggleButton::SetToggleTooltips\n" );
+ if ( !tips.empty() )
+ {
+ mToggleTooltips.clear();
+ mToggleTooltips.swap( tips );
+ }
+
+ if ( !mToggleTooltips.empty() && ( mCurrentToggleIndex < mToggleTooltips.size() ) )
+ {
+ Self().SetProperty( Toolkit::DevelControl::Property::TOOLTIP, mToggleTooltips[mCurrentToggleIndex] );
+ }
+
+ RelayoutRequest();
+}
+
+const std::vector<std::string>& ToggleButton::GetToggleTooltips() const
+{
+ return mToggleTooltips;
+}
+
+void ToggleButton::PrepareVisual(Property::Index index, Toolkit::Visual::Base& visual)
+{
+ RegisterVisual( index, visual, true );
+ EnableVisual( index, false );
+}
+
+void ToggleButton::RelayoutVisual( Property::Index index, const Vector2& size )
+{
+ Toolkit::Visual::Base visual = GetVisual( index );
+ if ( visual )
+ {
+ Size visualSize = Size::ZERO;
+ Vector2 visualPosition = Vector2::ZERO;
+
+ visual.GetNaturalSize( visualSize );
+
+ DALI_LOG_INFO( gLogButtonFilter, Debug::General, "ToggleButton::OnRelayout Setting visual size to(%f,%f)\n", visualSize.width, visualSize.height );
+ DALI_LOG_INFO( gLogButtonFilter, Debug::General, "ToggleButton::OnRelayout Setting visual position to(%f,%f)\n", visualPosition.x, visualPosition.y );
+
+ Property::Map visualTransform;
+ visualTransform.Add( Toolkit::DevelVisual::Transform::Property::SIZE, visualSize )
+ .Add( Toolkit::DevelVisual::Transform::Property::OFFSET, visualPosition )
+ .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) ) // Use absolute size
+ .Add( Toolkit::DevelVisual::Transform::Property::ORIGIN, Toolkit::Align::CENTER )
+ .Add( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER );
+
+ visual.SetTransformAndSize( visualTransform, size );
+ }
+}
+
+void ToggleButton::OnRelayout( const Vector2& size, RelayoutContainer& container )
+{
+ DALI_LOG_INFO( gLogButtonFilter, Debug::General, "ToggleButton::OnRelayout targetSize(%f,%f) ptr(%p)\n", size.width, size.height, this );
+
+ RelayoutVisual( Toolkit::DevelButton::Property::UNSELECTED_VISUAL, size );
+ RelayoutVisual( Toolkit::DevelButton::Property::SELECTED_VISUAL, size );
+ RelayoutVisual( Toolkit::DevelButton::Property::DISABLED_UNSELECTED_VISUAL, size );
+ RelayoutVisual( Toolkit::DevelButton::Property::DISABLED_SELECTED_VISUAL, size );
+}
+
+void ToggleButton::OnPressed()
+{
+ DALI_LOG_INFO( gLogButtonFilter, Debug::General, "ToggleButton::OnPressed\n" );
+ // State index will add 1 only when button is pressed.
+ mCurrentToggleIndex = ( mCurrentToggleIndex + 1 ) % mToggleVisuals.size();
+
+ // Both create SelectedVisual and UnselectedVisual
+ PrepareVisual( Toolkit::DevelButton::Property::UNSELECTED_VISUAL, mToggleVisuals[mCurrentToggleIndex] );
+ PrepareVisual( Toolkit::DevelButton::Property::SELECTED_VISUAL, mToggleSelectedVisuals[mCurrentToggleIndex] );
+ PrepareVisual( Toolkit::DevelButton::Property::DISABLED_UNSELECTED_VISUAL, mToggleDisabledVisuals[mCurrentToggleIndex] );
+ PrepareVisual( Toolkit::DevelButton::Property::DISABLED_SELECTED_VISUAL, mToggleDisabledSelectedVisuals[mCurrentToggleIndex] );
+
+ //Need to check mCurrentToggleIndex, it must less than the size of mToggleTooltips.
+ if ( !mToggleTooltips.empty() && ( mCurrentToggleIndex < mToggleTooltips.size() ) )
+ {
+ Self().SetProperty( Toolkit::DevelControl::Property::TOOLTIP, mToggleTooltips[mCurrentToggleIndex] );
+ }
+
+ RelayoutRequest();
+}
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_TOOLKIT_INTERNAL_TOGGLE_BUTTON_H__
+#define __DALI_TOOLKIT_INTERNAL_TOGGLE_BUTTON_H__
+
+/*
+ * Copyright (c) 2017 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 <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/object/property-value.h>
+#include <dali/public-api/object/property-array.h>
+
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/controls/buttons/toggle-button.h>
+#include "button-impl.h"
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+/**
+ * ToggleButton implementation class.
+ *
+ * \sa Dali::Toolkit::ToggleButton
+ */
+class ToggleButton : public Button
+{
+public:
+
+ /**
+ * Create a new ToggleButton.
+ * @return A smart-pointer to the newly allocated ToggleButton.
+ */
+ static Dali::Toolkit::ToggleButton New();
+
+protected:
+
+ /**
+ * Construct a new ToggleButton.
+ */
+ ToggleButton();
+
+ /**
+ * A reference counted object may only be deleted by calling Unreference()
+ */
+ virtual ~ToggleButton();
+
+public:
+
+ /**
+ * Called when a property of an object of this type is set.
+ * @param[in] object The object whose property is set.
+ * @param[in] index The property index.
+ * @param[in] value The new property value.
+ */
+ static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
+
+ /**
+ * Called to retrieve a property of an object of this type.
+ * @param[in] object The object whose property is to be retrieved.
+ * @param[in] index The property index.
+ * @return The current value of the property.
+ */
+ static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
+
+private:
+
+ /**
+ * Called to create all toggle visuals and save them to mToggleVisuals.
+ * @param[in] states The array store toggle states.
+ * @param[out] visuals The created state visual vector.
+ */
+ void CreateVisualsForAllStates( const Property::Array& states, std::vector<Toolkit::Visual::Base>& visuals );
+
+ /**
+ * Called to set toggle states when TOGGLE_STATES is set in SetProperty function.
+ * @param[in] states The array store toggle states.
+ */
+ void SetToggleStates( const Property::Array& states );
+
+ /**
+ * Called to retrieve toggle states.
+ * @return The toggle states array.
+ */
+ Property::Array GetToggleStates() const;
+
+ /**
+ * Called to set toggle tooltips when TOGGLE_TIPS is set in SetProperty function.
+ * @param[in] tips The array store toggle tips.
+ */
+ void SetToggleTooltips( std::vector<std::string>& tips );
+
+ /**
+ * Called to retrieve toggle tips.
+ * @return The toggle tips array.
+ */
+ const std::vector<std::string>& GetToggleTooltips() const;
+
+ /**
+ * Called to prepare visual for next state.
+ * @param[in] index The property index to set.
+ * @param[in] visual The visual to set.
+ */
+ void PrepareVisual(Property::Index index, Toolkit::Visual::Base& visual);
+
+ /**
+ * Called to relayout visual.
+ * @param[in] index The index of visual to relayout.
+ * @param[in] size The size of control.
+ */
+ void RelayoutVisual( Property::Index index, const Vector2& size );
+
+private: // From Button
+
+ /**
+ * @copydoc Toolkit::Internal::Button::OnInitialize
+ */
+ virtual void OnInitialize();
+
+ /**
+ * @copydoc Toolkit::Internal::Button::OnRelayout
+ */
+ virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
+
+ /**
+ * This method is called when the button is pressed.
+ */
+ virtual void OnPressed();
+
+private:
+
+ // Undefined
+ ToggleButton( const ToggleButton& );
+
+ // Undefined
+ ToggleButton& operator=( const ToggleButton& );
+
+private:
+
+ Property::Array mToggleStates; ///< Toggle states, string or map.
+ std::vector<Toolkit::Visual::Base> mToggleVisuals; ///< Save all unselected visuals.
+ std::vector<Toolkit::Visual::Base> mToggleSelectedVisuals; ///< Save all selected visuals.
+ std::vector<Toolkit::Visual::Base> mToggleDisabledVisuals; ///< Save all disabled unselected visuals.
+ std::vector<Toolkit::Visual::Base> mToggleDisabledSelectedVisuals; ///< Save all disabled selected visuals.
+ std::vector<std::string> mToggleTooltips; ///< Toggle tooltips.
+ unsigned int mCurrentToggleIndex; ///< The index of state.
+};
+
+} // namespace Internal
+
+// Helpers for public-api forwarding methods
+
+inline Toolkit::Internal::ToggleButton& GetImplementation( Toolkit::ToggleButton& button )
+{
+ DALI_ASSERT_ALWAYS( button );
+
+ Dali::RefObject& handle = button.GetImplementation();
+
+ return static_cast<Toolkit::Internal::ToggleButton&>( handle );
+}
+
+inline const Toolkit::Internal::ToggleButton& GetImplementation( const Toolkit::ToggleButton& button )
+{
+ DALI_ASSERT_ALWAYS( button );
+
+ const Dali::RefObject& handle = button.GetImplementation();
+
+ return static_cast<const Toolkit::Internal::ToggleButton&>( handle );
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_TOOLKIT_INTERNAL_TOGGLE_BUTTON_H__
TableView::TableView( unsigned int initialRows, unsigned int initialColumns )
: Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
mCellData( initialRows, initialColumns ),
+ mPreviousFocusedActor(),
mLayoutingChild( false ),
mRowDirty( true ), // Force recalculation first time
mColumnDirty( true )
{
- mCurrentColumn = 0;
- mCurrentRow = 0;
SetKeyboardNavigationSupport( true );
ResizeContainers( initialRows, initialColumns );
}
// Move the focus if we haven't lost it.
if(!focusLost)
{
- // Save the new focus cell positions of TableView.
- mCurrentColumn = currentColumn;
- mCurrentRow = currentRow;
-
nextFocusableActor = GetChildAt(Toolkit::TableView::CellPosition(currentRow, currentColumn));
+
+ // Save the focused actor in the TableView.
+ mPreviousFocusedActor = nextFocusableActor;
}
}
else
{
- // The current focused actor is not within TableView.
- // This means that the TableView has gained the Focus again.
+ // The current focused actor is not within this TableView.
unsigned int numberOfColumns = GetColumns();
unsigned int numberOfRows = GetRows();
- if( (mCurrentRow != 0 && mCurrentColumn != 0) && // Last saved cell was not the first cell
- (mCurrentRow != numberOfRows - 1 && mCurrentColumn != numberOfColumns - 1) ) // Last saved cell was not the last cell
+ // Check whether the previous focused actor is a focus group (i.e. a layout container)
+ bool wasFocusedOnLayoutContainer = false;
+ Actor previousFocusedActor = mPreviousFocusedActor.GetHandle();
+ if( previousFocusedActor )
{
- // This condition handles the cases when parent TableView gained the focus again after the child layout
- // container (i.e. TableView) has no more items (i.e. actors) to be focused on in a given direction.
+ Toolkit::Control control = Toolkit::Control::DownCast( previousFocusedActor );
+ if( control )
+ {
+ Internal::Control& controlImpl = static_cast<Internal::Control&>(control.GetImplementation());
+ wasFocusedOnLayoutContainer = controlImpl.IsKeyboardFocusGroup();
+ }
+ }
- // Move the focus to next cell towards the given direction in a TableView if the last saved cell was not the first or last cell.
- nextFocusableActor = GetNextKeyboardFocusableActor(GetChildAt(Toolkit::TableView::CellPosition(mCurrentRow, mCurrentColumn)), direction, loopEnabled);
+ // Check whether the previous focused actor is a layout container and also a child of this TableView
+ Toolkit::TableView::CellPosition position;
+ if( wasFocusedOnLayoutContainer && FindChildPosition( previousFocusedActor, position ) )
+ {
+ nextFocusableActor = GetNextKeyboardFocusableActor(previousFocusedActor, direction, loopEnabled);
}
else
{
*
*/
+// EXTERNAL INCLUDES
+#include <dali/devel-api/object/weak-handle.h>
+
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/control-impl.h>
#include <dali-toolkit/public-api/controls/table-view/table-view.h>
Size mFixedTotals; ///< Accumulated totals for fixed width and height
Size mPadding; ///< Padding to apply to each cell
- unsigned int mCurrentRow; ///< Last / current focused row
- unsigned int mCurrentColumn; ///< Last / current focused column
+
+ WeakHandle<Actor> mPreviousFocusedActor; ///< Perviously focused actor
bool mLayoutingChild; ///< Can't be a bitfield due to Relayouting lock
bool mRowDirty : 1; ///< Flag to indicate the row data is dirty
bool mColumnDirty : 1; ///< Flag to indicate the column data is dirty
$(toolkit_src_dir)/controls/buttons/check-box-button-impl.cpp \
$(toolkit_src_dir)/controls/buttons/push-button-impl.cpp \
$(toolkit_src_dir)/controls/buttons/radio-button-impl.cpp \
+ $(toolkit_src_dir)/controls/buttons/toggle-button-impl.cpp \
$(toolkit_src_dir)/controls/effects-view/effects-view-impl.cpp \
$(toolkit_src_dir)/controls/flex-container/flex-container-impl.cpp \
$(toolkit_src_dir)/controls/gaussian-blur-view/gaussian-blur-view-impl.cpp \
const unsigned int TOOLKIT_MAJOR_VERSION = 1;
const unsigned int TOOLKIT_MINOR_VERSION = 2;
-const unsigned int TOOLKIT_MICRO_VERSION = 23;
+const unsigned int TOOLKIT_MICRO_VERSION = 24;
const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
Name: dali-addon
Summary: DALi module for Node.JS
-Version: 1.2.23
+Version: 1.2.24
Release: 1
Group: Development/Libraries
License: Apache License, Version 2.0
Name: dali-toolkit
Summary: The OpenGLES Canvas Core Library Toolkit
-Version: 1.2.23
+Version: 1.2.24
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-2-Clause and MIT
%template(LongPressGestureDetectedSignal) Dali::Signal<void (Dali::Actor, const Dali::LongPressGesture&)>;
//%template(ActorTouchEventSignal) Dali::Signal<bool (Dali::Actor, const Dali::TouchEvent&)>;
%template(ActorTouchDataSignal) Dali::Signal<bool (Dali::Actor, const Dali::TouchData&)>;
-%template(ActorHoverEventSignal) Dali::Signal<bool (Dali::Actor, const Dali::HoverEvent&)>;
+%template(ActorHoverSignal) Dali::Signal<bool (Dali::Actor, const Dali::HoverEvent&)>;
%template(ActorWheelEventSignal) Dali::Signal<bool (Dali::Actor, const Dali::WheelEvent&)>;
%template(ActorSignal) Dali::Signal<void (Dali::Actor)>;
%template(KeyEventSignal) Dali::Signal<void (const Dali::KeyEvent&)>;
DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, KeyEvent );
DALI_CREATE_CUSTOM_DISPOSE_FUNCTION( Dali, KeyEvent );
-DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, HoverEvent );
-DALI_CREATE_CUSTOM_DISPOSE_FUNCTION( Dali, HoverEvent );
DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, TouchEvent );
DALI_CREATE_CUSTOM_DISPOSE_FUNCTION( Dali, TouchEvent );
DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, WheelEvent );
%include dali-operator.i
%include devel-properties.i
+%include gestures/hover.i
+
+
%include dali-core.i
%include dali-adaptor.i
%include dali-toolkit.i
* @brief Event arguments that passed via Hover signal
*
*/
- public class HoverEventArgs : EventArgs
+ public class HoverArgs : EventArgs
{
private View _view;
- private HoverEvent _hoverEvent;
+ private Hover _hover;
/**
* @brief View - is the view that is being hovered
}
/**
- * @brief HoverEvent - contains touch points that represent the points
+ * @brief Hover - contains touch points that represent the points
* that are currently being hovered or the points where a hover has stopped
*
*/
- public HoverEvent HoverEvent
+ public Hover Hover
{
get
{
- return _hoverEvent;
+ return _hover;
}
set
{
- _hoverEvent = value;
+ _hover = value;
}
}
}
private TouchCallbackDelegate _viewTouchDataCallbackDelegate;
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
- private delegate bool HoverEventCallbackDelegate(IntPtr view, IntPtr hoverEvent);
- private DaliEventHandlerWithReturnType<object,HoverEventArgs,bool> _viewHoverEventHandler;
- private HoverEventCallbackDelegate _viewHoverEventCallbackDelegate;
+ private delegate bool HoverCallbackDelegate(IntPtr view, IntPtr hover);
+ private DaliEventHandlerWithReturnType<object,HoverArgs,bool> _viewHoverHandler;
+ private HoverCallbackDelegate _viewHoverCallbackDelegate;
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate bool WheelEventCallbackDelegate(IntPtr view, IntPtr wheelEvent);
/**
* @brief Event for KeyInputFocusGained signal which can be used to subscribe/unsubscribe the event handler
- * (in the type of KeyInputFocusGainedEventHandler-DaliEventHandler<object,KeyInputFocusGainedEventArgs>)
+ * (in the type of KeyInputFocusGainedEventHandler-DaliEventHandler<object,KeyInputFocusGainedEventArgs>)
* provided by the user. KeyInputFocusGained signal is emitted when the control gets Key Input Focus.
*/
public event DaliEventHandler<object,KeyInputFocusGainedEventArgs> KeyInputFocusGained
/**
* @brief Event for Hovered signal which can be used to subscribe/unsubscribe the event handler
- * (in the type of HoverEventHandler-DaliEventHandlerWithReturnType<object,HoverEventArgs,bool>)
+ * (in the type of HoverHandler-DaliEventHandlerWithReturnType<object,HoverArgs,bool>)
* provided by the user. Hovered signal is emitted when hover input is received.
*/
- public event DaliEventHandlerWithReturnType<object,HoverEventArgs,bool> Hovered
+ public event DaliEventHandlerWithReturnType<object,HoverArgs,bool> Hovered
{
add
{
lock(this)
{
// Restricted to only one listener
- if (_viewHoverEventHandler == null)
+ if (_viewHoverHandler == null)
{
- _viewHoverEventHandler += value;
+ _viewHoverHandler += value;
- _viewHoverEventCallbackDelegate = new HoverEventCallbackDelegate(OnHoverEvent);
- this.HoveredSignal().Connect(_viewHoverEventCallbackDelegate);
+ _viewHoverCallbackDelegate = new HoverCallbackDelegate(OnHover);
+ this.HoveredSignal().Connect(_viewHoverCallbackDelegate);
}
}
}
{
lock(this)
{
- if (_viewHoverEventHandler != null)
+ if (_viewHoverHandler != null)
{
- this.HoveredSignal().Disconnect(_viewHoverEventCallbackDelegate);
+ this.HoveredSignal().Disconnect(_viewHoverCallbackDelegate);
}
- _viewHoverEventHandler -= value;
+ _viewHoverHandler -= value;
}
}
}
// Callback for View Hover signal
- private bool OnHoverEvent(IntPtr view, IntPtr hoverEvent)
+ private bool OnHover(IntPtr view, IntPtr hover)
{
- HoverEventArgs e = new HoverEventArgs();
+ HoverArgs e = new HoverArgs();
- // Populate all members of "e" (HoverEventArgs) with real data
+ // Populate all members of "e" (HoverArgs) with real data
e.View = View.GetViewFromPtr(view);
- e.HoverEvent = Dali.HoverEvent.GetHoverEventFromPtr(hoverEvent);
+ e.Hover = Dali.Hover.GetHoverFromPtr(hover);
- if (_viewHoverEventHandler != null)
+ if (_viewHoverHandler != null)
{
//here we send all data to user event handlers
- return _viewHoverEventHandler(this, e);
+ return _viewHoverHandler(this, e);
}
return false;
--- /dev/null
+%rename(Hover) Dali::HoverEvent;
+
+%csmethodmodifiers Dali::HoverEvent::points "private";
+%csmethodmodifiers Dali::HoverEvent::time "private";
+
+%typemap(cscode) Dali::HoverEvent %{
+ public static Hover GetHoverFromPtr(global::System.IntPtr cPtr) {
+ Hover ret = new Hover(cPtr, false);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return ret;
+ }
+
+ public uint GetTime() {
+ return time;
+ }
+
+ public int GetDeviceId(uint point) {
+ if( point < points.Count )
+ {
+ return points[(int)point].deviceId;
+ }
+ return -1;
+ }
+
+ public PointStateType GetState(uint point) {
+ if( point < points.Count )
+ {
+ return (Dali.PointStateType)(points[(int)point].state);
+ }
+ return PointStateType.FINISHED;
+ }
+
+ public Actor GetHitActor(uint point) {
+ if( point < points.Count )
+ {
+ return points[(int)point].hitActor;
+ }
+ else
+ {
+ // Return a native empty handle
+ Actor actor = new Actor();
+ actor.Reset();
+ return actor;
+ }
+ }
+
+ public Vector2 GetLocalPosition(uint point) {
+ if( point < points.Count )
+ {
+ return points[(int)point].local;
+ }
+ return new Vector2(0.0f, 0.0f);
+ }
+
+ public Vector2 GetScreenPosition(uint point) {
+ if( point < points.Count )
+ {
+ return points[(int)point].screen;
+ }
+ return new Vector2(0.0f, 0.0f);
+ }
+%}
\ No newline at end of file
DALI_CREATE_C_PTR_TO_CSHARP_FUNCTION( Dali, Animation );
DALI_CREATE_C_PTR_TO_CSHARP_FUNCTION( Dali, TouchEvent );
DALI_CREATE_C_PTR_TO_CSHARP_FUNCTION( Dali, TouchData );
-DALI_CREATE_C_PTR_TO_CSHARP_FUNCTION( Dali, HoverEvent );
DALI_CREATE_C_PTR_TO_CSHARP_FUNCTION( Dali, WheelEvent );
DALI_CREATE_C_PTR_TO_CSHARP_FUNCTION( Dali, KeyEvent );
DALI_CREATE_C_PTR_TO_CSHARP_FUNCTION( Dali, LongPressGesture );
viewWrapperImpl.OnSizeSet = new ViewWrapperImpl.OnSizeSetDelegate(OnSizeSet);
viewWrapperImpl.OnSizeAnimation = new ViewWrapperImpl.OnSizeAnimationDelegate(OnSizeAnimation);
viewWrapperImpl.OnTouchEvent = new ViewWrapperImpl.OnTouchEventDelegate(OnTouchEvent);
- viewWrapperImpl.OnHoverEvent = new ViewWrapperImpl.OnHoverEventDelegate(OnHoverEvent);
+ viewWrapperImpl.OnHover = new ViewWrapperImpl.OnHoverDelegate(OnHover);
viewWrapperImpl.OnKeyEvent = new ViewWrapperImpl.OnKeyEventDelegate(OnKeyEvent);
viewWrapperImpl.OnWheelEvent = new ViewWrapperImpl.OnWheelEventDelegate(OnWheelEvent);
viewWrapperImpl.OnRelayout = new ViewWrapperImpl.OnRelayoutDelegate(OnRelayout);
/**
* @brief Called after a hover-event is received by the owning actor.
*
- * @param[in] event The hover event
- * @return True if the event should be consumed.
+ * @param[in] hover The hover event
+ * @return True if the hover event should be consumed.
* @note CustomViewBehaviour.REQUIRES_HOVER_EVENTS must be enabled during construction. See CustomView(ViewWrapperImpl.CustomViewBehaviour behaviour).
*/
- public virtual bool OnHoverEvent(HoverEvent hoverEvent)
+ public virtual bool OnHover(Hover hover)
{
return false; // Do not consume
}
public delegate void OnSizeSetDelegate(Vector3 targetSize);
public delegate void OnSizeAnimationDelegate(Animation animation, Vector3 targetSize);
public delegate bool OnTouchEventDelegate(TouchEvent touchEvent);
- public delegate bool OnHoverEventDelegate(HoverEvent hoverEvent);
+ public delegate bool OnHoverDelegate(Hover hover);
public delegate bool OnKeyEventDelegate(KeyEvent keyEvent);
public delegate bool OnWheelEventDelegate(WheelEvent wheelEvent);
public delegate void OnRelayoutDelegate(Vector2 size, RelayoutContainer container);
public OnSizeSetDelegate OnSizeSet;
public OnSizeAnimationDelegate OnSizeAnimation;
public OnTouchEventDelegate OnTouchEvent;
- public OnHoverEventDelegate OnHoverEvent;
+ public OnHoverDelegate OnHover;
public OnKeyEventDelegate OnKeyEvent;
public OnWheelEventDelegate OnWheelEvent;
public OnRelayoutDelegate OnRelayout;
Delegate5 = new DelegateViewWrapperImpl_5(DirectorOnSizeSet);
Delegate6 = new DelegateViewWrapperImpl_6(DirectorOnSizeAnimation);
Delegate7 = new DelegateViewWrapperImpl_7(DirectorOnTouchEvent);
- Delegate8 = new DelegateViewWrapperImpl_8(DirectorOnHoverEvent);
+ Delegate8 = new DelegateViewWrapperImpl_8(DirectorOnHover);
Delegate9 = new DelegateViewWrapperImpl_9(DirectorOnKeyEvent);
Delegate10 = new DelegateViewWrapperImpl_10(DirectorOnWheelEvent);
Delegate11 = new DelegateViewWrapperImpl_11(DirectorOnRelayout);
return OnTouchEvent(new TouchEvent(arg0, false));
}
- private bool DirectorOnHoverEvent(global::System.IntPtr arg0)
+ private bool DirectorOnHover(global::System.IntPtr arg0)
{
- return OnHoverEvent(new HoverEvent(arg0, false));
+ return OnHover(new Hover(arg0, false));
}
private bool DirectorOnKeyEvent(global::System.IntPtr arg0)