[dali_1.2.25] Merge branch 'devel/master' 18/113018/1
authorUmar <m.umar@partner.samsung.com>
Fri, 3 Feb 2017 15:38:27 +0000 (15:38 +0000)
committerUmar <m.umar@partner.samsung.com>
Fri, 3 Feb 2017 15:38:27 +0000 (15:38 +0000)
Change-Id: I86f3f01af8119a79e5fa52be58875822f90780c9

23 files changed:
automated-tests/src/dali-toolkit/CMakeLists.txt [changed mode: 0644->0755]
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-actor-utils.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-actor-utils.h
automated-tests/src/dali-toolkit/utc-Dali-ScrollBar.cpp
automated-tests/src/dali-toolkit/utc-Dali-ToggleButton.cpp [new file with mode: 0755]
dali-toolkit/devel-api/controls/buttons/toggle-button.cpp [new file with mode: 0644]
dali-toolkit/devel-api/controls/buttons/toggle-button.h [new file with mode: 0644]
dali-toolkit/devel-api/file.list [changed mode: 0644->0755]
dali-toolkit/internal/builder/tree-node-manipulator.cpp
dali-toolkit/internal/controls/buttons/toggle-button-impl.cpp [new file with mode: 0755]
dali-toolkit/internal/controls/buttons/toggle-button-impl.h [new file with mode: 0644]
dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp
dali-toolkit/internal/controls/table-view/table-view-impl.cpp
dali-toolkit/internal/controls/table-view/table-view-impl.h
dali-toolkit/internal/file.list [changed mode: 0644->0755]
dali-toolkit/public-api/dali-toolkit-version.cpp
docs/content/shared-javascript-and-cpp-documentation/creating-custom-controls.md
packaging/dali-addon.spec
packaging/dali-toolkit.spec
plugins/dali-swig/SWIG/dali-toolkit.i
plugins/dali-swig/SWIG/dali.i
plugins/dali-swig/examples/control-dashboard.cs
plugins/dali-swig/examples/images/star-mod.png [new file with mode: 0644]

old mode 100644 (file)
new mode 100755 (executable)
index 1297575..97975d1
@@ -48,6 +48,7 @@ SET(TC_SOURCES
    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
index 6e2e204..38eb0b2 100644 (file)
@@ -94,23 +94,4 @@ Actor CreateRenderableActor( Image texture, const std::string& vertexShader, con
   return actor;
 }
 
-Image GetTexture( Actor actor )
-{
-  Image image;
-  if( actor && actor.GetRendererCount() )
-  {
-    Renderer renderer = actor.GetRendererAt( 0u );
-    if( renderer )
-    {
-      TextureSet textureSet = renderer.GetTextures();
-      if( textureSet && textureSet.GetTextureCount() )
-      {
-        image = TextureGetImage( textureSet, 0u );
-      }
-    }
-  }
-
-  return image;
-}
-
 } // namespace Dali
index 28953cb..a62dcca 100644 (file)
@@ -49,13 +49,6 @@ Actor CreateRenderableActor( Image texture );
  */
 Actor CreateRenderableActor( Image texture, const std::string& vertexShader, const std::string& fragmentShader );
 
-/**
- * @brief Retrieves the texture used in a renderable actor (if available).
- * @return The texture used by the actor.
- * @note Assumes the actor only has one renderer, and that renderer only has one texture.
- */
-Image GetTexture( Actor actor );
-
 } // namespace Dali
 
 #endif // DALI_TEST_ACTOR_UTILS_H
index ea50a30..ded233f 100644 (file)
@@ -470,6 +470,11 @@ int UtcDaliToolkitScrollBarSetScrollIndicatorP(void)
   DALI_TEST_CHECK( indicator != scrollBar.GetScrollIndicator() );
   DALI_TEST_CHECK( newIndicator == scrollBar.GetScrollIndicator() );
 
+  // Check that the new control indicator is successfully set
+  Control controlIndicator = Control::New();
+  scrollBar.SetScrollIndicator(controlIndicator);
+
+  DALI_TEST_CHECK( controlIndicator == Control::DownCast( scrollBar.GetScrollIndicator() ) );
   END_TEST;
 }
 
diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ToggleButton.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ToggleButton.cpp
new file mode 100755 (executable)
index 0000000..2f75b37
--- /dev/null
@@ -0,0 +1,384 @@
+/*
+ * 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
diff --git a/dali-toolkit/devel-api/controls/buttons/toggle-button.cpp b/dali-toolkit/devel-api/controls/buttons/toggle-button.cpp
new file mode 100644 (file)
index 0000000..39f1845
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * 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
diff --git a/dali-toolkit/devel-api/controls/buttons/toggle-button.h b/dali-toolkit/devel-api/controls/buttons/toggle-button.h
new file mode 100644 (file)
index 0000000..2e61901
--- /dev/null
@@ -0,0 +1,223 @@
+#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__
old mode 100644 (file)
new mode 100755 (executable)
index a67e25b..c8e9f29
@@ -8,6 +8,7 @@ devel_api_src_files = \
   $(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 \
@@ -53,7 +54,8 @@ devel_api_bubble_emitter_header_files = \
   $(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 \
index 4357cb8..9567306 100644 (file)
@@ -398,7 +398,7 @@ void TreeNodeManipulator::DoWrite(const TreeNode *value, std::ostream& output, i
     {
       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() ) )
       {
diff --git a/dali-toolkit/internal/controls/buttons/toggle-button-impl.cpp b/dali-toolkit/internal/controls/buttons/toggle-button-impl.cpp
new file mode 100755 (executable)
index 0000000..555cb7b
--- /dev/null
@@ -0,0 +1,370 @@
+/*
+ * 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
diff --git a/dali-toolkit/internal/controls/buttons/toggle-button-impl.h b/dali-toolkit/internal/controls/buttons/toggle-button-impl.h
new file mode 100644 (file)
index 0000000..8c76eb4
--- /dev/null
@@ -0,0 +1,194 @@
+#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__
index 6e301cb..ddf5738 100755 (executable)
@@ -234,7 +234,7 @@ void ScrollBar::CreateDefaultIndicatorActor()
   Toolkit::ImageView indicator = Toolkit::ImageView::New( DEFAULT_INDICATOR_IMAGE_PATH );
   indicator.SetParentOrigin( ParentOrigin::TOP_LEFT );
   indicator.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-
+  indicator.SetStyleName( "ScrollBarIndicator" );
   SetScrollIndicator(indicator);
 }
 
@@ -249,6 +249,13 @@ void ScrollBar::SetScrollIndicator( Actor indicator )
       Self().Remove( mIndicator );
     }
     mIndicator = indicator;
+
+    Toolkit::Control control = Toolkit::Control::DownCast( mIndicator );
+    if( control )
+    {
+      control.SetStyleName( "ScrollBarIndicator" );
+    }
+
     mIndicatorFirstShow = true;
     Self().Add( mIndicator );
 
index a674abb..b683987 100644 (file)
@@ -1078,12 +1078,11 @@ void TableView::OnChildRemove( Actor& child )
 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 );
 }
@@ -1405,29 +1404,37 @@ Actor TableView::GetNextKeyboardFocusableActor(Actor currentFocusedActor, Toolki
       // 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
       {
index be1f702..a8e8456 100644 (file)
@@ -18,6 +18,9 @@
  *
  */
 
+// 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>
@@ -497,8 +500,8 @@ private: // Data
   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
old mode 100644 (file)
new mode 100755 (executable)
index f003ce2..7f39ff6
@@ -42,6 +42,7 @@ toolkit_src_files = \
    $(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 \
index ee84e5a..91895c0 100644 (file)
@@ -31,7 +31,7 @@ namespace Toolkit
 
 const unsigned int TOOLKIT_MAJOR_VERSION = 1;
 const unsigned int TOOLKIT_MINOR_VERSION = 2;
-const unsigned int TOOLKIT_MICRO_VERSION = 24;
+const unsigned int TOOLKIT_MICRO_VERSION = 25;
 const char * const TOOLKIT_BUILD_DATE    = __DATE__ " " __TIME__;
 
 #ifdef DEBUG_ENABLED
index 54a0220..c5d3a7c 100644 (file)
@@ -17,8 +17,8 @@ Namespaces are important
 + The handle & body classes should have the same name but in different namespaces
 + TypeRegistry relies on this convention
 + Here our custom control requires
-  + MyControl
-  + Internal::MyControl
+  + MyUIControl
+  + Internal::MyUIControl
  
 ### General Guidelines:
 + Try to avoid adding C++ APIs as they become difficult to maintain.
@@ -46,7 +46,34 @@ Currently, this is devel-api though, so is subject to change.
  
 ![ ](../assets/img/creating-custom-controls/rendering.png)
 ![ ](creating-custom-controls/rendering.png)
+
+To add a visual to a control, first create a Property for the visual of type MAP, and ensure the name has a suffix of "_VISUAL". Then the visual is normally defined in the stylesheet, and the definition sent via SetProperty(), where you would then create the visual:
+
+~~~{.cpp}
+// C++
+void Internal::MyUIControl::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
+{
+  MyUIControl control = MyUIControl::DownCast( Dali::BaseHandle( object ) );
+  switch( index )
+  {
+    case MyUIControl::Property::MY_VISUAL:
+    {
+      Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+      const Property::Map *map = value.GetMap();
+      if( map && !map->Empty() )
+      {
+        Toolkit::Visual::Base visual = visualFactory.CreateVisual( *map );
+        GetImplementation( control ).RegisterVisual( index, visual );
+      }
+      break;
+    }
+    //...
+  }
+}
+~~~
+
+The [Visuals](@ref visuals) section describes the property maps that can be used for each visual type.
+
 ___________________________________________________________________________________________________
 
 ## Ensuring Control is Stylable {#creating-controls-stylable}
@@ -118,10 +145,10 @@ It is recommended to do provide a New() method in the custom control implementat
 
 ~~~{.cpp}
 // C++
-MyUIControl MyUIControlImpl::New()
+MyUIControl Internal::MyUIControl::New()
 {
   // Create the implementation, temporarily owned on stack
-  IntrusivePtr< MyUIControlImpl > controlImpl = new MyUIControlImpl;
+  IntrusivePtr< Internal::MyUIControl > controlImpl = new Internal::MyUIControl;
 
   // Pass ownership to handle
   MyUIControl handle( *controlImpl );
@@ -138,7 +165,7 @@ This will trigger the Dali::Toolkit::Internal::Control Initialize() method which
 This should be overridden by the custom ui control.
 ~~~{.cpp}
 // C++
-void MyUIControlImpl::OnInitialize()
+void Internal::MyUIControl::OnInitialize()
 {
   // Create visuals using the VisualFactory, register events etc.
   // Register any created visuals with Control base class
@@ -169,7 +196,7 @@ ________________________________________________________________________________
 If the control needs to utilize hover and wheel events, then the correct behaviour flag should be used when constructing the control and then the appropriate method should be overridden.
 ~~~{.cpp}
 // C++
-bool MyUIControlImpl::OnHoverEvent( const HoverEvent& event )
+bool Internal::MyUIControl::OnHoverEvent( const HoverEvent& event )
 {
   bool consumed = false;
 
@@ -181,7 +208,7 @@ bool MyUIControlImpl::OnHoverEvent( const HoverEvent& event )
 ~~~
 ~~~{.cpp}
 // C++
-bool MyUIControlImpl::OnWheelEvent( const WheelEvent& event )
+bool Internal::MyUIControl::OnWheelEvent( const WheelEvent& event )
 {
   bool consumed = false;
 
@@ -210,7 +237,7 @@ If any of these detectors are required then this can be specified in the OnIniti
  
 ~~~{.cpp}
 // C++
-void MyUIControlImpl::OnInitialize()
+void Internal::MyUIControl::OnInitialize()
 {
   // Only enable pan gesture detection
   EnableGestureDetection( Gesture::Pan );
@@ -232,28 +259,28 @@ panGestureDetector.AddDirection( PanGestureDetector::DIRECTION_VERTICAL );
 Finally, the appropriate method should be overridden:
 ~~~{.cpp}
 // C++
-void MyUIControlImpl::OnPan( const PanGesture& pan )
+void Internal::MyUIControl::OnPan( const PanGesture& pan )
 {
   // Handle pan-gesture
 }
 ~~~
 ~~~{.cpp}
 // C++
-void MyUIControlImpl::OnPinch( const PinchGesture& pinch )
+void Internal::MyUIControl::OnPinch( const PinchGesture& pinch )
 {
   // Handle pinch-event
 }
 ~~~
 ~~~{.cpp}
 // C++
-void MyUIControlImpl::OnTap( const TapGesture& tap )
+void Internal::MyUIControl::OnTap( const TapGesture& tap )
 {
   // Handle tap-gesture
 }
 ~~~
 ~~~{.cpp}
 // C++
-void MyUIControlImpl::OnLongPress( const LongPressGesture& longPress )
+void Internal::MyUIControl::OnLongPress( const LongPressGesture& longPress )
 {
   // Handle long-press-gesture
 }
@@ -339,7 +366,7 @@ An up call to the Control class is necessary if these methods are overridden.
  
 ~~~{.cpp}
 // C++
-void MyUIControlImpl::OnChildAdd( Actor& child );
+void Internal::MyUIControl::OnChildAdd( Actor& child );
 {
   // Do any other operations required upon child addition
 
@@ -349,7 +376,7 @@ void MyUIControlImpl::OnChildAdd( Actor& child );
 ~~~
 ~~~{.cpp}
 // C++
-void MyUIControlImpl::OnChildRemove( Actor& child );
+void Internal::MyUIControl::OnChildRemove( Actor& child );
 {
   // Do any other operations required upon child removal
 
@@ -369,7 +396,7 @@ An up call to the Control class is necessary if these methods are overridden.
  
 ~~~{.cpp}
 // C++
-void MyUIControlImpl::OnStageConnection( int depth )
+void Internal::MyUIControl::OnStageConnection( int depth )
 {
   // Do any other operations required upon stage connection
 
@@ -379,7 +406,7 @@ void MyUIControlImpl::OnStageConnection( int depth )
 ~~~
 ~~~{.cpp}
 // C++
-void MyUIControlImpl::OnStageDisconnection()
+void Internal::MyUIControl::OnStageDisconnection()
 {
   // Do any other operations required upon stage disconnection
 
@@ -396,7 +423,7 @@ The following methods must be overridden for size negotiation to work correctly
  
 ~~~{.cpp}
 // C++
-Vector3 MyUIControlImpl::GetNaturalSize()
+Vector3 Internal::MyUIControl::GetNaturalSize()
 {
   // Return the natural size of the control
   // This depends on our layout
@@ -411,7 +438,7 @@ Vector3 MyUIControlImpl::GetNaturalSize()
 ~~~
 ~~~{.cpp}
 // C++
-float MyUIControlImpl::GetHeightForWidth( float width )
+float Internal::MyUIControl::GetHeightForWidth( float width )
 {
   // Called by the size negotiation algorithm if we have a fixed width
   // We should calculate the height we would like our control to be for that width
@@ -423,7 +450,7 @@ float MyUIControlImpl::GetHeightForWidth( float width )
 ~~~
 ~~~{.cpp}
 // C++
-float MyUIControlImpl::GetWidthForHeight( float height )
+float Internal::MyUIControl::GetWidthForHeight( float height )
 {
   // Called by the size negotiation algorithm if we have a fixed height
   // We should calculate the width we would like our control to be for that height
@@ -434,7 +461,7 @@ float MyUIControlImpl::GetWidthForHeight( float height )
 ~~~
 ~~~{.cpp}
 // C++
-void MyUIControlImpl::OnRelayout( const Vector2& size, RelayoutContainer& container )
+void Internal::MyUIControl::OnRelayout( const Vector2& size, RelayoutContainer& container )
 {
   // The size is what we have been given and what our control needs to fit into
   // Here, we need to set the position and the size of our visuals
@@ -452,9 +479,10 @@ ________________________________________________________________________________
 ### Clipping Support {#creating-controls-clipping}
 
 When an Actor is set to clip its children, the renderers have to be added manually in order to specify what its children need to clip to.
-The Control base class automates the creation of the renderers/visuals when it is set to clip its children.
+The Control base class automates the creation of the visuals when it is set to clip its children.
  
-This is only done if the application or custom control writer has not added any renderers to the Control or registered any visuals
+This is only done if the application or custom control writer has not
+added any Renderers to the Control or registered any visuals
 (regardless of whether these visuals are enabled or not).
  
 If custom control writers want to define the clipping visuals themselves, then they should register all required visuals before the control is staged.
index 4120bd8..94e7756 100644 (file)
@@ -1,6 +1,6 @@
 Name:       dali-addon
 Summary:    DALi module for Node.JS
-Version:    1.2.24
+Version:    1.2.25
 Release:    1
 Group:      Development/Libraries
 License:    Apache License, Version 2.0
index e06ed88..4183bd4 100644 (file)
@@ -1,6 +1,6 @@
 Name:       dali-toolkit
 Summary:    The OpenGLES Canvas Core Library Toolkit
-Version:    1.2.24
+Version:    1.2.25
 Release:    1
 Group:      System/Libraries
 License:    Apache-2.0 and BSD-2-Clause and MIT
index 68b9ad9..3e7a512 100755 (executable)
@@ -75,6 +75,8 @@
 %ignore *::Base(Dali::Internal::Visual::Base*);
 %ignore *::GetExtension();
 %ignore *::GetControlExtension();
+%ignore *::ToggleButton(Internal::ToggleButton&);
+%ignore *::ToggleButton(Dali::Internal::CustomActor*);
 
 %ignore *::Button::SetAnimationTime(float animationTime);
 %ignore *::Button::SetAutoRepeating(bool);
@@ -280,6 +282,7 @@ typedef Dali::IntrusivePtr<Dali::Toolkit::Ruler> RulerPtr;
 %include <dali-toolkit/devel-api/controls/page-turn-view/page-turn-view.h>
 %include <dali-toolkit/devel-api/controls/page-turn-view/page-turn-landscape-view.h>
 %include <dali-toolkit/devel-api/controls/page-turn-view/page-turn-portrait-view.h>
+%include <dali-toolkit/devel-api/controls/buttons/toggle-button.h>
 
 %include <dali-toolkit/devel-api/visual-factory/visual-base.h>
 %include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
index 824ed85..20558f4 100755 (executable)
@@ -75,6 +75,7 @@
 #include <dali-toolkit/devel-api/controls/page-turn-view/page-turn-view.h>
 #include <dali-toolkit/devel-api/controls/page-turn-view/page-turn-landscape-view.h>
 #include <dali-toolkit/devel-api/controls/page-turn-view/page-turn-portrait-view.h>
+#include <dali-toolkit/devel-api/controls/buttons/toggle-button.h>
 
 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
index 756f651..6c9fc64 100755 (executable)
@@ -45,7 +45,7 @@ namespace MyCSharpExample
 
         // List of items
         private Item[] mViewList = {
-            new Item("PushButton", true),  new Item("DropDown", false),    new Item("Toggle", false),
+            new Item("PushButton", true),  new Item("DropDown", false),    new Item("Toggle", true),
             new Item("InputField", false),  new Item("AnimateGif", false),  new Item("Loading", false),
             new Item("ProgressBar", false), new Item("CheckBox", false),    new Item("RadioButton", true),
             new Item("Tooltip", true),     new Item("Popup", true),       new Item("Toast", true),
@@ -154,7 +154,28 @@ namespace MyCSharpExample
                 }
                 if (item.name.CompareTo("Toggle") == 0)
                 {
+                    ToggleButton toggleButton = new ToggleButton();
+                    Dali.Property.Array array = new Dali.Property.Array();
+                    array.Add( new Dali.Property.Value("./images/star-highlight.png") );
+                    array.Add( new Dali.Property.Value("./images/star-mod.png") );
+                    array.Add( new Dali.Property.Value("./images/star-dim.png") );
+                    toggleButton.StateVisuals = array;
+
+                    Dali.Property.Array tooltips = new Dali.Property.Array();
+                    tooltips.Add( new Dali.Property.Value("State A") );
+                    tooltips.Add( new Dali.Property.Value("State B") );
+                    tooltips.Add( new Dali.Property.Value("State C") );
+                    toggleButton.Tooltips = tooltips;
+
+                    toggleButton.WidthResizePolicy  = "FILL_TO_PARENT";
+                    toggleButton.HeightResizePolicy = "FILL_TO_PARENT";
+                    toggleButton.Clicked += (obj, e) =>
+                    {
+                        Console.WriteLine("Toggle button state changed.");
+                        return true;
+                    };
 
+                    _contentContainer.AddChild(toggleButton, new TableView.CellPosition(((uint)idx / 5) * 2 + 1, (uint)idx % 5));
                 }
                 if (item.name.CompareTo("InputField") == 0)
                 {
diff --git a/plugins/dali-swig/examples/images/star-mod.png b/plugins/dali-swig/examples/images/star-mod.png
new file mode 100644 (file)
index 0000000..2e3212e
Binary files /dev/null and b/plugins/dali-swig/examples/images/star-mod.png differ