# List of test case sources (Only these get parsed for test cases)
SET(TC_SOURCES
- utc-Dali-PushButton.cpp
utc-Dali-Text-CharacterSetConversion.cpp
utc-Dali-Text-Cursor.cpp
utc-Dali-Text-Segmentation.cpp
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <iostream>
-
-#include <stdlib.h>
-#include <dali-toolkit/internal/controls/buttons/push-button-impl.h>
-#include <dali-toolkit-test-suite-utils.h>
-#include <dali-toolkit/dali-toolkit.h>
-#include <dali/integration-api/events/touch-event-integ.h>
-
-
-using namespace Dali;
-using namespace Toolkit;
-
-namespace
-{
-
-static bool gPushButtonSelectedState = false;
-bool PushButtonSelected( Button button, bool selected )
-{
- gPushButtonSelectedState = selected && ( selected == static_cast<PushButton&>( button ).IsSelected() );
- return true;
-}
-
-
-Dali::Integration::Point GetPointDownInside()
-{
- Dali::Integration::Point point;
- point.SetState( PointState::DOWN );
- point.SetScreenPosition( Vector2( 240, 400 ) );
- return point;
-}
-
-Dali::Integration::Point GetPointUpInside()
-{
- Dali::Integration::Point point;
- point.SetState( PointState::UP );
- point.SetScreenPosition( Vector2( 240, 400 ) );
- return point;
-}
-
-Dali::Integration::Point GetPointMotionOut()
-{
- Dali::Integration::Point point;
- point.SetState( PointState::MOTION );
- point.SetScreenPosition( Vector2( 10, 10 ) );
- return point;
-}
-
-Dali::Integration::Point GetPointUpOutside()
-{
- Dali::Integration::Point point;
- point.SetState( PointState::UP );
- point.SetScreenPosition( Vector2( 10, 10 ) );
- return point;
-}
-
-} // namespace
-
-
-//////////////////////////////////////////////////////////
-
-namespace
-{
-static bool gOnTouchPointInterrupted = false;
-} //namespace
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-class TETButton;
-}
-
-/**
- * Creates a PushButton to test if interrupt events are handled correctly.
- */
-class TETButton : public PushButton
-{
-public:
- // PushButton Pressed
- typedef Signal< bool ( PushButton ) > ButtonSignalType;
-
- ButtonSignalType& PressedSignal();
-
- /**
- * Default constructor.
- */
- TETButton();
-
- /**
- * Copy constructor.
- */
- TETButton( const PushButton& button );
-
- /**
- * Assignment operator.
- */
- TETButton& operator=( const TETButton& button );
-
- /**
- * Creates and initializes a new button.
- */
- static TETButton New();
-
- /**
- * Down cast to TETButton.
- */
- static TETButton DownCast( BaseHandle handle );
-
- /**
- * Creates a handle using the Toolkit::Internal implementation.
- * @param[in] implementation The Control implementation.
- */
- TETButton( Internal::TETButton& implementation );
-
- /**
- * Allows the creation of this Control from an Internal::CustomActor pointer.
- * @param[in] internal A pointer to the internal CustomActor.
- */
- TETButton( Dali::Internal::CustomActor* internal );
-};
-
-namespace Internal
-{
-
-/**
- * Internal implementation
- */
-class TETButton : public PushButton
-{
-public:
- /**
- * Construct a new Button.
- */
- TETButton();
-
- /**
- * A reference counted object may only be deleted by calling Unreference()
- */
- virtual ~TETButton();
-
- /**
- * Creates an internal button.
- */
- static Toolkit::TETButton New();
-
- /**
- * @return the pressed signal.
- */
- Toolkit::TETButton::ButtonSignalType& PressedSignal();
-
- /**
- * Callback called when an interrupt events is received.
- */
- void OnTouchPointInterrupted();
-
- /**
- * Callback received when a down event is received.
- */
- void OnButtonDown();
-
- Toolkit::TETButton::ButtonSignalType mPressedSignal; ///< Signal emitted when the button is pressed.
-};
-
-} // namespace Internal
-
-TETButton::TETButton()
-{
-}
-
-TETButton::TETButton( const PushButton& button )
-: PushButton( button )
-{
-}
-
-TETButton& TETButton::operator=( const TETButton& button )
-{
- if( &button != this )
- {
- PushButton::operator=( button );
- }
- return *this;
-}
-
-TETButton TETButton::New()
-{
- return Internal::TETButton::New();
-}
-
-TETButton TETButton::DownCast( BaseHandle handle )
-{
- return Control::DownCast<TETButton, Internal::TETButton>(handle);
-}
-
-TETButton::ButtonSignalType& TETButton::PressedSignal()
-{
- TETButton button( *this );
- DALI_ASSERT_ALWAYS( button );
-
- Dali::RefObject& handle = button.GetImplementation();
-
- return static_cast<Toolkit::Internal::TETButton&>( handle ).PressedSignal();
-}
-
-TETButton::TETButton( Internal::TETButton& implementation )
-: PushButton( implementation )
-{}
-
-TETButton::TETButton( Dali::Internal::CustomActor* internal )
-: PushButton( internal )
-{
- VerifyCustomActorPointer<Internal::TETButton>(internal);
-}
-
-namespace Internal
-{
-
-TETButton::TETButton()
-: PushButton(),
- mPressedSignal()
-{
-}
-
-TETButton::~TETButton()
-{
-}
-
-Toolkit::TETButton TETButton::New()
-{
- // Create the implementation, temporarily owned on stack
- IntrusivePtr< TETButton > internalTETButton = new TETButton();
-
- // Pass ownership to CustomActor
- Dali::Toolkit::TETButton tetButton( *internalTETButton );
-
- // Second-phase init of the implementation
- // This can only be done after the CustomActor connection has been made...
- internalTETButton->Initialize();
-
- return tetButton;
-}
-
-Toolkit::TETButton::ButtonSignalType& TETButton::PressedSignal()
-{
- return mPressedSignal;
-}
-
-void TETButton::OnButtonDown()
-{
- Toolkit::TETButton handle( GetOwner() );
-
- //Emit signal.
- mPressedSignal.Emit( handle );
-}
-
-void TETButton::OnTouchPointInterrupted()
-{
- gOnTouchPointInterrupted = true;
-}
-
-} // namespace Internal
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-namespace
-{
-
-class TETButtonPressed : public Dali::ConnectionTracker
-{
-public:
- enum Test
- {
- SENSITIVENESS,
- VISIBILITY
- };
-
- TETButtonPressed( Actor actor, Test test )
- : mActor( actor ),
- mTest( test )
- {
- }
-
- bool Callback( PushButton button )
- {
- switch( mTest )
- {
- case SENSITIVENESS:
- {
- mActor.SetSensitive( false );
- break;
- }
- case VISIBILITY:
- {
- std::cout <<"VISIBILITY false" << std::endl;
- mActor.SetVisible( false );
- break;
- }
- default:
- {
- break;
- }
- }
- return true;
- }
-
- Actor mActor;
- Test mTest;
-};
-
-static bool TestCallback(Actor actor, const TouchData& event)
-{
- return true;
-}
-
-} // namespace
-
-//////////////////////////////////////////////////////////
-
-int UtcDaliPushButtonDownCast(void)
-{
- ToolkitTestApplication application;
- tet_infoline(" UtcDaliPushButtonDownCast");
-
- TETButton tetButton= Toolkit::TETButton::New();
-
- BaseHandle object(tetButton);
-
- TETButton tetButton2 = TETButton::DownCast( object );
- DALI_TEST_CHECK(tetButton2);
-
- TETButton tetButton3 = DownCast< TETButton >(object);
- DALI_TEST_CHECK(tetButton3);
- END_TEST;
-}
-
-int UtcDaliPushButtonInterruptEventWhenInsensitive(void)
-{
- ToolkitTestApplication application;
- tet_infoline(" UtcDaliPushButtonInterruptEventWhenInsensitive");
-
- // * Creates an actor which contains a button.
- // * The size of the actor is bigger than the button.
- // * The button's boundary is contained in the actor's one.
- Actor actor = Actor::New();
- TETButton tetButton= Toolkit::TETButton::New();
-
- actor.SetName( "Actor" );
- tetButton.SetName( "TETButton" );
-
- actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
- actor.SetPosition( 0, 0 );
- actor.SetSize( 400, 800 );
-
- tetButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- tetButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
- tetButton.SetPosition( 240, 400 );
- tetButton.SetSize( 100, 100 );
-
- actor.Add( tetButton );
- Stage::GetCurrent().Add( actor );
-
- // * Actor's touch event is connected to a callback function
- // and this callback function consumes the event.
- actor.TouchSignal().Connect( &TestCallback );
-
- // * Button's pressed signal is connected to a callback function
- // which also consumes the event.
- // * Changes the sensitiveness of the button to false.
- TETButtonPressed tetButtonPressed( actor, TETButtonPressed::SENSITIVENESS );
- tetButton.PressedSignal().Connect( &tetButtonPressed, &TETButtonPressed::Callback );
-
- // Initializes TET state.
- gOnTouchPointInterrupted = false;
- tetButton.SetSensitive( true );
-
- Dali::Integration::TouchEvent event;
-
- // TET starts.
-
- // Test a down point inside the button which is also consumed by the actor, and an up point
- // consumed only by the actor. gOnTouchPointInterrupted should be true (Button receives an
- // interrupt event.
-
- application.SendNotification();
- application.Render();
-
- // A down event is sent inside the button's boundary.
-
- event = Dali::Integration::TouchEvent();
- event.AddPoint( GetPointDownInside() );
-
- // flush the queue and render once
- application.SendNotification();
- application.Render();
- application.ProcessEvent( event );
-
- // An up event is sent outside the button's boundary but inside the actor's one.
-
- event = Dali::Integration::TouchEvent();
- event.AddPoint( GetPointUpOutside() );
-
- // flush the queue and render once
- application.SendNotification();
- application.Render();
- application.ProcessEvent( event );
-
- DALI_TEST_CHECK( gOnTouchPointInterrupted );
-
- // Test a down point inside the button which is also consumed by the actor, and a motion point
- // consumed only by the actor. gOnTouchPointInterrupted should be true (Button receives an
- // interrupt event.
-
- // Initializes TET state.
- gOnTouchPointInterrupted = false;
- actor.SetSensitive( true );
- tetButton.SetSensitive( true );
-
- application.SendNotification();
- application.Render();
-
- // A down event is sent inside the button's boundary.
-
- event = Dali::Integration::TouchEvent();
- event.AddPoint( GetPointDownInside() );
-
- // flush the queue and render once
- application.SendNotification();
- application.Render();
- application.ProcessEvent( event );
-
- // A motion event is sent outside the button's boundary but inside the actor's one.
-
- event = Dali::Integration::TouchEvent();
- event.AddPoint( GetPointMotionOut() );
-
- // flush the queue and render once
- application.SendNotification();
- application.Render();
- application.ProcessEvent( event );
-
- DALI_TEST_CHECK( gOnTouchPointInterrupted );
-
- // Test a down point inside the button which is also consumed by the actor, and an up point
- // also inside the button and consumed by the actor. gOnTouchPointInterrupted should be false.
-
- // Initializes TET state.
- gOnTouchPointInterrupted = false;
- actor.SetSensitive( true );
- tetButton.SetSensitive( true );
-
- // A down event is sent inside the button's boundary.
-
- event = Dali::Integration::TouchEvent();
- event.AddPoint( GetPointDownInside() );
-
- // flush the queue and render once
- application.SendNotification();
- application.Render();
- application.ProcessEvent( event );
-
- actor.SetSensitive( true );
- // An up event is sent inside the button's boundary.
-
- event = Dali::Integration::TouchEvent();
- event.AddPoint( GetPointUpInside() );
-
- // flush the queue and render once
- application.SendNotification();
- application.Render();
- application.ProcessEvent( event );
-
- DALI_TEST_CHECK( !gOnTouchPointInterrupted );
- END_TEST;
-}
-
-int UtcDaliPushButtonInterruptEventWhenNonVisible(void)
-{
- ToolkitTestApplication application;
- tet_infoline(" UtcDaliPushButtonInterruptEventWhenNonVisible");
-
- // Does same test as above but changing the visibility instead the sensitiveness.
-
- // * Creates an actor which contains a button.
- // * The size of the actor is bigger than the button.
- // * The button's boundary is contained in the actor's one.
- Actor actor = Actor::New();
- TETButton tetButton = Toolkit::TETButton::New();
-
- actor.SetName( "Actor" );
- tetButton.SetName( "TETButton" );
-
- actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
- actor.SetPosition( 0, 0 );
- actor.SetSize( 400, 800 );
-
- tetButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- tetButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
- tetButton.SetPosition( 240, 400 );
- tetButton.SetSize( 100, 100 );
-
- actor.Add( tetButton );
- Stage::GetCurrent().Add( actor );
-
- // * Actor's touch event is connected to a callback function
- // and this callback function consumes the event.
- actor.TouchSignal().Connect( &TestCallback );
-
- // * Button's pressed signal is connected to a callback function
- // which also consumes the event.
- // * Changes the visibility of the button to false.
- TETButtonPressed tetButtonPressed( tetButton, TETButtonPressed::VISIBILITY );
- tetButton.PressedSignal().Connect( &tetButtonPressed, &TETButtonPressed::Callback );
-
- // Initializes TET state.
- gOnTouchPointInterrupted = false;
- tetButton.SetVisible( true );
-
- Dali::Integration::TouchEvent event;
-
- // TET starts.
-
- // Test a down point inside the button which is also consumed by the actor, and an up point
- // consumed only by the actor. gOnTouchPointInterrupted should be true (Button receives an
- // interrupt event.
-
- application.SendNotification();
- application.Render();
-
- // A down event is sent inside the button's boundary.
-
- event = Dali::Integration::TouchEvent();
- event.AddPoint( GetPointDownInside() );
-
- // flush the queue and render once
- application.SendNotification();
- application.Render();
- application.ProcessEvent( event );
-
- // More renders are needed in order to allow the node of the actor to become invisible.
- application.SendNotification();
- application.Render();
- application.SendNotification();
- application.Render();
- application.SendNotification();
- application.Render();
-
- // An up event is sent outside the button's boundary but inside the actor's one.
-
- event = Dali::Integration::TouchEvent();
- event.AddPoint( GetPointUpOutside() );
-
- // flush the queue and render once
- application.SendNotification();
- application.Render();
- application.ProcessEvent( event );
-
- DALI_TEST_CHECK( gOnTouchPointInterrupted );
-
- // Test a down point inside the button which is also consumed by the actor, and a motion point
- // consumed only by the actor. gOnTouchPointInterrupted should be true (Button receives an
- // interrupt event.
-
- // Initializes TET state.
- gOnTouchPointInterrupted = false;
- tetButton.SetVisible( true );
-
- application.SendNotification();
- application.Render();
- application.SendNotification();
- application.Render();
- application.SendNotification();
- application.Render();
-
- // A down event is sent inside the button's boundary.
-
- event = Dali::Integration::TouchEvent();
- event.AddPoint( GetPointDownInside() );
-
- // flush the queue and render once
- application.SendNotification();
- application.Render();
- application.ProcessEvent( event );
-
- // More renders are needed in order to allow the node of the actor to become invisible.
- application.SendNotification();
- application.Render();
- application.SendNotification();
- application.Render();
- application.SendNotification();
- application.Render();
-
- // A motion event is sent outside the button's boundary but inside the actor's one.
-
- event = Dali::Integration::TouchEvent();
- event.AddPoint( GetPointMotionOut() );
-
- // flush the queue and render once
- application.SendNotification();
- application.Render();
- application.ProcessEvent( event );
-
- DALI_TEST_CHECK( gOnTouchPointInterrupted );
-
- // Test a down point inside the button which is also consumed by the actor, and an up point
- // also inside the button and consumed by the actor. gOnTouchPointInterrupted should be false.
-
- // Initializes TET state.
- gOnTouchPointInterrupted = false;
- tetButton.SetVisible( true );
-
- application.SendNotification();
- application.Render();
- application.SendNotification();
- application.Render();
- application.SendNotification();
- application.Render();
-
- // A down event is sent inside the button's boundary.
-
- event = Dali::Integration::TouchEvent();
- event.AddPoint( GetPointDownInside() );
-
- // flush the queue and render once
- application.SendNotification();
- application.Render();
- application.ProcessEvent( event );
-
- tetButton.SetVisible( true );
-
- application.SendNotification();
- application.Render();
- application.SendNotification();
- application.Render();
- application.SendNotification();
- application.Render();
-
- // An up event is sent inside the button's boundary.
-
- event = Dali::Integration::TouchEvent();
- event.AddPoint( GetPointUpInside() );
-
- // flush the queue and render once
- application.SendNotification();
- application.Render();
- application.ProcessEvent( event );
-
- DALI_TEST_CHECK( !gOnTouchPointInterrupted );
- END_TEST;
-}
-
-int UtcDaliPushButtonProperties(void)
-{
- ToolkitTestApplication application;
-
- PushButton button = PushButton::New();
- Stage::GetCurrent().Add( button );
-
- // Button::PROPERTY_AUTO_REPEATING
- button.SetAutoRepeating( false );
- DALI_TEST_CHECK( ! button.GetProperty< bool >( Button::Property::AUTO_REPEATING ) );
- button.SetProperty( Button::Property::AUTO_REPEATING, true );
- DALI_TEST_CHECK( button.IsAutoRepeating() ) ;
- DALI_TEST_CHECK( button.GetProperty< bool >( Button::Property::AUTO_REPEATING ) );
-
- // Button::PROPERTY_INITIAL_AUTO_REPEATING_DELAY
- button.SetInitialAutoRepeatingDelay( 10.0f );
- DALI_TEST_EQUALS( 10.0f, button.GetProperty< float >( Button::Property::INITIAL_AUTO_REPEATING_DELAY ), TEST_LOCATION );
- button.SetProperty( Button::Property::INITIAL_AUTO_REPEATING_DELAY, 25.0f );
- DALI_TEST_EQUALS( 25.0f, button.GetInitialAutoRepeatingDelay(), TEST_LOCATION );
- DALI_TEST_EQUALS( 25.0f, button.GetProperty< float >( Button::Property::INITIAL_AUTO_REPEATING_DELAY ), TEST_LOCATION );
-
- // Button::PROPERTY_NEXT_AUTO_REPEATING_DELAY
- button.SetNextAutoRepeatingDelay( 3.0f );
- DALI_TEST_EQUALS( 3.0f, button.GetProperty< float >( Button::Property::NEXT_AUTO_REPEATING_DELAY ), TEST_LOCATION );
- button.SetProperty( Button::Property::NEXT_AUTO_REPEATING_DELAY, 4.0f );
- DALI_TEST_EQUALS( 4.0f, button.GetNextAutoRepeatingDelay(), TEST_LOCATION );
- DALI_TEST_EQUALS( 4.0f, button.GetProperty< float >( Button::Property::NEXT_AUTO_REPEATING_DELAY ), TEST_LOCATION );
-
- // Button::PROPERTY_TOGGLABLE
- button.SetTogglableButton( false );
- DALI_TEST_CHECK( ! button.GetProperty< bool >( Button::Property::TOGGLABLE ) );
- button.SetProperty( Button::Property::TOGGLABLE, true );
- DALI_TEST_CHECK( button.IsTogglableButton() ) ;
- DALI_TEST_CHECK( button.GetProperty< bool >( Button::Property::TOGGLABLE ) );
-
- // Button::PROPERTY_SELECTED
- button.SetSelected( false );
- DALI_TEST_CHECK( ! button.GetProperty< bool >( Button::Property::SELECTED ) );
- button.SetProperty( Button::Property::SELECTED, true );
- DALI_TEST_CHECK( button.IsSelected() ) ;
- DALI_TEST_CHECK( button.GetProperty< bool >( Button::Property::SELECTED ) );
-
- END_TEST;
-}
DALI_TYPE_REGISTRATION_BEGIN( Toolkit::DummyControl, Toolkit::Control, Create );
DALI_TYPE_REGISTRATION_END()
+
+Dali::PropertyRegistration dummyControlVisualProperty(
+ typeRegistration, "testVisual", Dali::Toolkit::DummyControl::Property::TEST_VISUAL, Dali::Property::MAP, &Dali::Toolkit::DummyControlImpl::SetProperty, &Dali::Toolkit::DummyControlImpl::GetProperty );
+
}
DummyControl DummyControlImpl::New()
return Control::CreateTransition( transition );
}
+void DummyControlImpl::SetProperty( BaseObject* object, Dali::Property::Index index, const Dali::Property::Value& value )
+{
+}
+
+Property::Value DummyControlImpl::GetProperty( BaseObject* object, Dali::Property::Index propertyIndex )
+{
+ Dali::Property::Value value;
+ return value;
+}
+
+
+
DummyControl DummyControlImplOverride::New()
{
IntrusivePtr< DummyControlImplOverride > impl = new DummyControlImplOverride;
{
class DummyControlImpl;
-class ControlRenderer;
+
/**
* Control does not have a New method so use this dummy class for the handle.
*/
class DummyControl : public Control
{
public:
+ enum PropertyRange
+ {
+ PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1, ///< @SINCE_1_0.0
+ PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000 ///< Reserve property index
+ };
+
+ struct Property
+ {
+ enum Type
+ {
+ TEST_VISUAL = PROPERTY_START_INDEX
+ };
+ };
DummyControl();
DummyControl(const DummyControl& control);
Toolkit::Visual::Base GetVisual( Property::Index index );
Animation CreateTransition( const Toolkit::TransitionData& transition );
+ static void SetProperty( BaseObject* object, Dali::Property::Index index, const Dali::Property::Value& value );
+
+ static Property::Value GetProperty( BaseObject* object, Dali::Property::Index propertyIndex );
+
// Used to test signal connections
void CustomSlot1( Actor actor );
mCore->ContextCreated();
}
+unsigned int TestApplication::Wait( unsigned int durationToWait )
+{
+ int time = 0;
+
+ for(unsigned int i = 0; i <= ( durationToWait / RENDER_FRAME_INTERVAL); i++)
+ {
+ SendNotification();
+ Render(RENDER_FRAME_INTERVAL);
+ time += RENDER_FRAME_INTERVAL;
+ }
+ return time;
+}
} // Namespace dali
static const unsigned int DEFAULT_RENDER_INTERVAL = 1;
+ static const unsigned int RENDER_FRAME_INTERVAL = 16;
+
TestApplication( size_t surfaceWidth = DEFAULT_SURFACE_WIDTH,
size_t surfaceHeight = DEFAULT_SURFACE_HEIGHT,
float horizontalDpi = DEFAULT_HORIZONTAL_DPI,
bool RenderOnly( );
void ResetContext();
bool GetRenderNeedsUpdate();
+ unsigned int Wait( unsigned int durationToWait );
private:
void DoUpdate( unsigned int intervalMilliseconds, const char* location=NULL );
// Need to override adaptor classes for toolkit test harness, so include
// test harness headers before dali headers.
#include <dali-toolkit-test-suite-utils.h>
+#include "dali-toolkit-test-utils/toolkit-timer.h"
#include <dali.h>
#include <dali-toolkit/dali-toolkit.h>
#include <dali/integration-api/events/touch-event-integ.h>
+#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
+#include <dali-toolkit/devel-api/visuals/text-visual-properties.h>
+
using namespace Dali;
using namespace Toolkit;
namespace
{
+static const char* TEST_IMAGE_ONE = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
+
static bool gIsCalledButtonCallback = false;
+const int RENDER_FRAME_INTERVAL = 16;
+
static bool ButtonCallback( Button button )
{
gIsCalledButtonCallback = true;
return point;
}
-
static float ANIMATION_TIME( 0.5f );
+
} // namespace
int UtcDaliButtonConstructorP(void)
END_TEST;
}
+int UtcDaliButtonSetDisabledWithDifferentStates01P(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline("UtcDaliButtonSetDisabledWithDifferentStates01P\n");
+
+ Button button = PushButton::New();
+
+ bool SELECTED = true;
+
+ button.SetProperty( Button::Property::TOGGLABLE, true);
+ button.SetProperty( Button::Property::SELECTED, SELECTED );
+
+ button.SetProperty( Button::Property::DISABLED, true);
+
+ tet_infoline("Set button to SELECTED = false whilst disabled, should not change to false\n");
+ button.SetProperty( Button::Property::SELECTED, !SELECTED );
+
+ bool isSelected = button.GetProperty<bool>( Button::Property::SELECTED ) ;
+
+ DALI_TEST_EQUALS( isSelected, SELECTED , TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliButtonSetDisabledWithDifferentStates02P(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline("UtcDaliButtonSetDisabledWithDifferentStates02\n");
+
+ Button button = PushButton::New();
+
+ bool SELECTED = true;
+
+ button.SetProperty( Button::Property::TOGGLABLE, true );
+ button.SetProperty( Button::Property::SELECTED, SELECTED );
+ button.SetProperty( Button::Property::DISABLED, true );
+
+ bool isSelected = button.GetProperty<bool>( Button::Property::SELECTED );
+ DALI_TEST_EQUALS( isSelected, SELECTED , TEST_LOCATION );
+ tet_infoline("Set button to DISABLED = false whilst disabled and then set to unselected\n");
+
+ button.SetProperty( Button::Property::DISABLED, false );
+ button.SetProperty( Button::Property::SELECTED, !SELECTED );
+
+ isSelected = button.GetProperty<bool>( Button::Property::SELECTED );
+ DALI_TEST_EQUALS( isSelected, !SELECTED , TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliButtonPropertyGetLabelAlignment(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliPushButtonPropertyGetLabelAlignment\n");
+
+ Button button = PushButton::New();
+ button.SetProperty( Toolkit::DevelButton::Property::LABEL_RELATIVE_ALIGNMENT, "END" );
+ DALI_TEST_EQUALS( button.GetProperty<std::string>( Toolkit::DevelButton::Property::LABEL_RELATIVE_ALIGNMENT ), "END", TEST_LOCATION );
+
+ END_TEST;
+}
+
int UtcDaliButtonIsDisabledP(void)
{
ToolkitTestApplication application;
END_TEST;
}
+int UtcDaliButtonAutoRepeatingP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliButtonPressedSignalP Setup Autorepeating and check multiple clicked signals received\n");
+
+ const float AUTO_REPEATING_DELAY = 0.15f;
+
+ Button button = PushButton::New();
+ button.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ button.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ button.SetPosition( 240, 400 );
+ button.SetSize( 100, 100 );
+ Stage::GetCurrent().Add( button );
+
+ application.SendNotification();
+ application.Render();
+
+ button.SetProperty( Toolkit::Button::Property::AUTO_REPEATING, true );
+ button.SetProperty( Toolkit::Button::Property::INITIAL_AUTO_REPEATING_DELAY, AUTO_REPEATING_DELAY );
+ // connect to its touch signal
+ ConnectionTracker* testTracker = new ConnectionTracker();
+ button.PressedSignal().Connect( &ButtonCallback );
+ button.ClickedSignal().Connect( &ButtonCallback );
+ bool clickedSignal = false;
+ bool pressedSignal = false;
+ button.ConnectSignal( testTracker, "pressed", CallbackFunctor(&pressedSignal) );
+ button.ConnectSignal( testTracker, "clicked", CallbackFunctor(&clickedSignal) );
+
+ Dali::Integration::TouchEvent event;
+
+ // Touch point down and up inside the button.
+
+ gIsCalledButtonCallback = false;
+ event = Dali::Integration::TouchEvent();
+ event.AddPoint( GetPointDownInside() );
+ application.ProcessEvent( event );
+
+ DALI_TEST_EQUALS( gIsCalledButtonCallback, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( pressedSignal, true, TEST_LOCATION );
+ tet_infoline("Consume first clicked signal then wait\n");
+
+ gIsCalledButtonCallback = false;
+ Dali::Timer timer = Timer::New( AUTO_REPEATING_DELAY );
+ timer.MockEmitSignal();
+ application.Wait( AUTO_REPEATING_DELAY*2 );
+ DALI_TEST_EQUALS( clickedSignal, true, TEST_LOCATION );
+ tet_infoline("Check gIsCalledButtonCallback was called again after last consumption of it.\n");
+
+ DALI_TEST_EQUALS( gIsCalledButtonCallback, true, TEST_LOCATION );
+
+ gIsCalledButtonCallback = false;
+ event = Dali::Integration::TouchEvent();
+ event.AddPoint( GetPointUpInside() );
+ application.ProcessEvent( event );
+
+ DALI_TEST_EQUALS( gIsCalledButtonCallback, true, TEST_LOCATION );
+
+ END_TEST;
+}
+
int UtcDaliButtonSetInitialAutoRepeatingDelayP(void)
{
ToolkitTestApplication application;
DALI_TEST_EQUALS( button.GetNextAutoRepeatingDelay(), 0.5f, TEST_LOCATION );
- button.SetNextAutoRepeatingDelay( 0.2f );
+ button.SetProperty( Button::Property::NEXT_AUTO_REPEATING_DELAY, 0.2f );
DALI_TEST_EQUALS( button.GetNextAutoRepeatingDelay(), 0.2f, TEST_LOCATION );
END_TEST;
ToolkitTestApplication application;
Button button = PushButton::New();
+ button.SetProperty( Toolkit::Button::Property::LABEL,
+ Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT )
+ .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f )
+ );
button.SetLabelText( "Button Label" );
END_TEST;
}
-int UtcDaliButtonSetLabelActorP(void)
+int UtcDaliButtonSetLabelPropertyP(void)
{
ToolkitTestApplication application;
+ const std::string TEST_LABEL1 = "test label one";
+ const std::string TEST_LABEL2 = "test label two";
+
Button button = PushButton::New();
- button.SetLabelText( "Button Label" );
+ button.SetProperty( Toolkit::Button::Property::LABEL,
+ Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT )
+ .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f )
+ );
+
+ button.SetProperty( Button::Property::LABEL_TEXT, TEST_LABEL1 );
+
+ std::string labelText = button.GetProperty<std::string>( Button::Property::LABEL_TEXT );
+
+ DALI_TEST_EQUALS( labelText, TEST_LABEL1, TEST_LOCATION );
+
+ Property::Map propertyMap;
+ propertyMap.Insert( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT );
+ propertyMap.Insert( Toolkit::TextVisual::Property::TEXT, TEST_LABEL2 );
+ propertyMap.Insert( Toolkit::TextVisual::Property::TEXT_COLOR, Color::BLUE );
+ propertyMap.Insert( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f );
+ button.SetProperty( Button::Property::LABEL, propertyMap );
+
+ labelText = button.GetProperty<std::string>( Button::Property::LABEL_TEXT );
+
+ DALI_TEST_EQUALS( labelText, TEST_LABEL2, TEST_LOCATION );
- DALI_TEST_EQUALS( button.GetLabelText(), "Button Label", TEST_LOCATION );
END_TEST;
}
application.SendNotification();
application.Render();
- pushButton.SetSize( Vector2( 20.0f, 20.0f ) );
pushButton.SetUnselectedImage( "Image.jpg" );
application.SendNotification();
application.Render();
- Vector3 size = pushButton.GetCurrentSize();
-
- DALI_TEST_EQUALS( size.width, 20.f, TEST_LOCATION );
- DALI_TEST_EQUALS( size.height, 20.f, TEST_LOCATION );
+ DALI_TEST_CHECK( pushButton );
END_TEST;
}
application.SendNotification();
application.Render();
- pushButton.SetSize( Vector2( 20.0f, 20.0f ) );
pushButton.SetSelectedImage( "Image.jpg" );
application.SendNotification();
application.Render();
- Vector3 size = pushButton.GetCurrentSize();
-
- DALI_TEST_EQUALS( size.width, 20.f, TEST_LOCATION );
- DALI_TEST_EQUALS( size.height, 20.f, TEST_LOCATION );
+ DALI_TEST_CHECK( pushButton );
END_TEST;
}
END_TEST;
}
-int UtcDaliButtonSetLabelP(void)
+int UtcDaliButtonSetLabeActorlP(void)
{
ToolkitTestApplication application;
try
{
- button.SetButtonImage( CreateBufferImage( 10, 10, Color::WHITE ) );
- DALI_TEST_CHECK( ImageView::DownCast( button.GetButtonImage() ) );
+ ResourceImage image1 = ResourceImage::New( TEST_IMAGE_ONE );
+ button.SetButtonImage( image1 );
+
+ Property::Value value = button.GetProperty(Button::Property::UNSELECTED_STATE_IMAGE );
+ DALI_TEST_CHECK( value.Get<std::string>() == TEST_IMAGE_ONE );
}
catch(...)
{
DALI_TEST_CHECK( false );
}
+ std::string imageUrl;
+
+ Dali::Actor actor = button.GetButtonImage();
+
+ Toolkit::ImageView imageView = Toolkit::ImageView ::DownCast( actor );
+
+ tet_infoline(" UtcDaliButtonSetButtonImageP Ensure an ImageView is returned\n");
+ DALI_TEST_CHECK ( imageView )
+
END_TEST;
}
try
{
- button.SetButtonImage( CreateBufferImage( 10, 10, Color::WHITE ) );
+ ResourceImage image1 = ResourceImage::New( TEST_IMAGE_ONE );
+ button.SetButtonImage( image1 );
+
DALI_TEST_CHECK( false );
}
catch(...)
PushButton button = PushButton::New();
Stage::GetCurrent().Add( button );
+ ResourceImage image1 = ResourceImage::New( TEST_IMAGE_ONE );
try
{
- button.SetSelectedImage( CreateBufferImage( 10, 10, Color::WHITE ) );
- DALI_TEST_CHECK( ImageView::DownCast( button.GetSelectedImage() ) );
+ button.SetSelectedImage( image1 );
+ Property::Value value = button.GetProperty( Button::Property::SELECTED_STATE_IMAGE );
+ DALI_TEST_CHECK( value.Get<std::string>() == TEST_IMAGE_ONE );
}
catch(...)
{
DALI_TEST_CHECK( false );
}
+ std::string imageUrl;
+
+ Dali::Actor actor = button.GetSelectedImage();
+
+ Toolkit::ImageView imageView = Toolkit::ImageView::DownCast( actor );
+
+ tet_infoline(" UtcDaliButtonSetSelectedImageWithImageP Ensure an ImageView is returned\n");
+
END_TEST;
}
END_TEST;
}
+
+int UtcDaliButtonSetImagesWithDeprecatedProperties(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliButtonSetImagesWithDeprecatedProperties");
+
+ PushButton pushButton = PushButton::New();
+
+ Stage::GetCurrent().Add( pushButton );
+
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
+ propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
+
+ DALI_TEST_EQUALS( pushButton.GetRendererCount(), 0, TEST_LOCATION );
+
+ pushButton.SetProperty( Toolkit::Button::Property::UNSELECTED_STATE_IMAGE, propertyMap );
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_EQUALS( pushButton.GetRendererCount(), 1, TEST_LOCATION );
+
+ tet_infoline(" Set state to selected and provide SELECTED visual");
+ pushButton.SetProperty( Toolkit::Button::Property::SELECTED_STATE_IMAGE, propertyMap );
+ pushButton.SetProperty( Toolkit::Button::Property::SELECTED, true );
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_EQUALS( pushButton.GetRendererCount(), 1, TEST_LOCATION );
+
+ tet_infoline(" Set state to selected, disabled and provide DISABLED_STATE_IMAGE visual");
+ pushButton.SetProperty( Toolkit::Button::Property::SELECTED, false );
+ pushButton.SetProperty( Toolkit::Button::Property::DISABLED, true );
+ pushButton.SetProperty( Toolkit::Button::Property::DISABLED_STATE_IMAGE, propertyMap );
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_EQUALS( pushButton.GetRendererCount(), 1, TEST_LOCATION );
+
+END_TEST;
+}
+
+int UtcDaliButtonSetGetDepreciatedPropertiesWithURL(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliButtonSetGetDepreciatedPropertiesWithURL");
+
+ PushButton button = PushButton::New();
+ Stage::GetCurrent().Add( button );
+
+ tet_infoline(" Set state to selected, disabled and provide DISABLED_STATE_IMAGE visual");
+ button.SetProperty( Toolkit::Button::Property::DISABLED, true );
+ button.SetProperty( Toolkit::Button::Property::DISABLED_STATE_IMAGE, TEST_IMAGE_ONE );
+
+ Property::Value value = button.GetProperty(Button::Property::DISABLED_STATE_IMAGE );
+ DALI_TEST_EQUALS( value.Get<std::string>(), TEST_IMAGE_ONE, TEST_LOCATION );
+
+END_TEST;
+}
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
+#include <dali-toolkit/devel-api/visuals/text-visual-properties.h>
+
+
using namespace Dali;
using namespace Toolkit;
return true;
}
+static const char* TEST_IMAGE_ONE = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
+const Vector2 TEST_IMAGE_SIZE = Vector2( 66.0f, 66.0f );
+
+
} // namespace
void checkbox_button_startup(void)
CheckBoxButton checkBox = CheckBoxButton::New();
Property::Map propertyMap;
- propertyMap.Insert("text", "activate");
+
+ propertyMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT )
+ .Add( Toolkit::TextVisual::Property::TEXT, "activate" )
+ .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f );
+
checkBox.SetProperty( checkBox.GetPropertyIndex("label"), propertyMap );
DALI_TEST_EQUALS( checkBox.GetLabelText(), "activate", TEST_LOCATION ); // Change to use GerProperty once that code is implemented
-
END_TEST;
}
application.Render();
Property::Map propertyMap;
- propertyMap.Insert("text", "activate");
- checkBox.SetProperty(checkBox.GetPropertyIndex("disabled"), true);
+ propertyMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT )
+ .Add( Toolkit::TextVisual::Property::TEXT, "activate" )
+ .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f );
+
+ checkBox.SetProperty(checkBox.GetPropertyIndex("disabled"), true);
checkBox.SetProperty( checkBox.GetPropertyIndex("label"), propertyMap );
DALI_TEST_CHECK( checkBox.GetProperty<bool>(checkBox.GetPropertyIndex("disabled")) );
- DALI_TEST_EQUALS( checkBox.GetLabelText(), "activate", TEST_LOCATION ); // Change to use GerProperty once that code is implemented
+ DALI_TEST_EQUALS( checkBox.GetLabelText(), "activate", TEST_LOCATION ); // Change to use GetProperty once that code is implemented
END_TEST;
}
END_TEST;
}
+
+int UtcDaliCheckBoxSetLabelPadding(void)
+{
+ tet_infoline("UtcDaliCheckBoxSetLabelPadding\n");
+
+ ToolkitTestApplication application;
+
+ CheckBoxButton checkBox = CheckBoxButton::New();
+
+ Property::Map propertyMap;
+
+ propertyMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT )
+ .Add( Toolkit::TextVisual::Property::TEXT, "activate" )
+ .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f );
+
+ checkBox.SetProperty( Toolkit::DevelButton::Property::LABEL, propertyMap );
+
+ application.SendNotification();
+ application.Render();
+
+ Vector3 orginalSize = checkBox.GetNaturalSize();
+
+ checkBox.SetProperty( Toolkit::DevelButton::Property::LABEL_PADDING, Vector4( 10.0f, 10.0f, 10.0f, 10.0f ) );
+
+ application.SendNotification();
+ application.Render();
+
+ Vector3 paddingAddedSize = checkBox.GetNaturalSize();
+
+ DALI_TEST_EQUALS( checkBox.GetProperty<Vector4>( Toolkit::DevelButton::Property::LABEL_PADDING ), Vector4( 10.0f, 10.0f, 10.0f, 10.0f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ tet_infoline("Comparing original size of button with just text and button size with text and padding\n");
+
+ DALI_TEST_EQUALS( orginalSize.width +10.0f + 10.0f , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( orginalSize.height +10.0f + 10.0f , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliCheckBoxSetForegroundPadding(void)
+{
+ tet_infoline("UtcDaliCheckBoxSetForegroundPadding\n");
+
+ ToolkitTestApplication application;
+
+ CheckBoxButton checkBox = CheckBoxButton::New();
+
+ Property::Map propertyMap;
+
+ propertyMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT )
+ .Add( Toolkit::TextVisual::Property::TEXT, "activate" )
+ .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f );
+
+ checkBox.SetProperty( Toolkit::DevelButton::Property::LABEL, propertyMap );
+ checkBox.SetProperty( Toolkit::DevelButton::Property::LABEL_PADDING, Vector4( 5.0f, 5.0f, 5.0f, 5.0f ) );
+
+ application.SendNotification();
+ application.Render();
+
+ tet_printf( "Button RelayoutSize with text(%f,%f)\n", checkBox.GetNaturalSize().width, checkBox.GetNaturalSize().height );
+
+ TestPlatformAbstraction& platform = application.GetPlatform();
+ platform.SetClosestImageSize( TEST_IMAGE_SIZE );
+
+ checkBox.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_VISUAL, TEST_IMAGE_ONE );
+ checkBox.SetProperty( Toolkit::DevelButton::Property::SELECTED_VISUAL, TEST_IMAGE_ONE );
+
+
+ application.SendNotification();
+ application.Render();
+
+ Vector3 preVisualPaddingSize = checkBox.GetNaturalSize();
+
+ tet_printf( "Button RelayoutSize with text and icon (%f,%f)\n", checkBox.GetNaturalSize().width, checkBox.GetNaturalSize().height );
+
+ checkBox.SetProperty( Toolkit::DevelButton::Property::VISUAL_PADDING, Vector4( 25.0f, 25.0f, 25.0f, 25.0f ) );
+
+ application.SendNotification();
+ application.Render();
+
+ Vector3 paddingAddedSize = checkBox.GetNaturalSize();
+
+ tet_printf( "Button RelayoutSize with text, icon and padding (%f,%f)\n", checkBox.GetNaturalSize().width, checkBox.GetNaturalSize().height );
+
+ DALI_TEST_EQUALS( checkBox.GetProperty<Vector4>( Toolkit::DevelButton::Property::VISUAL_PADDING ), Vector4( 25.0f, 25.0f, 25.0f, 25.0f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ tet_infoline("Comparing original size of button before adding padding to visual foreground\n");
+
+ DALI_TEST_GREATER( paddingAddedSize.width, preVisualPaddingSize.width , TEST_LOCATION );
+
+ tet_infoline("Text and Visual are side by side, visual height and padding must be greater than text height and padding for this test\n");
+
+ DALI_TEST_GREATER( paddingAddedSize.height, preVisualPaddingSize.height , TEST_LOCATION );
+
+ END_TEST;
+}
END_TEST;
}
+
+int UtcDaliKeyboardFocusManagerMoveFocusBackward(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliKeyboardFocusManagerMoveFocusBackward");
+
+ KeyboardFocusManager manager = KeyboardFocusManager::Get();
+ DALI_TEST_CHECK(manager);
+
+ // Make history stack full
+ for(int i = 0 ; i < 31 ; i ++)
+ {
+ Actor actor = Actor::New();
+ actor.SetKeyboardFocusable(true);
+ Stage::GetCurrent().Add(actor);
+ manager.SetCurrentFocusActor(actor);
+ }
+
+ // Create the first actor and add it to the stage
+ Actor first = Actor::New();
+ first.SetKeyboardFocusable(true);
+ Stage::GetCurrent().Add(first);
+
+ // Create the second actor and add it to the stage
+ Actor second = Actor::New();
+ second.SetKeyboardFocusable(true);
+ Stage::GetCurrent().Add(second);
+
+ // Create the second actor and add it to the stage
+ Actor third = Actor::New();
+ third.SetKeyboardFocusable(true);
+ Stage::GetCurrent().Add(third);
+
+ // Check that the focus is set on the second actor
+ DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
+
+ // Check that the focus is set on the second actor
+ DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
+
+ // Check that the focus is set on the third actor
+ DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
+
+ // Move the focus backward
+ manager.MoveFocusBackward();
+
+ // Check that it current focused actor is second actor
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
+
+ // Check that the focus is set on the third actor
+ DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
+
+ // Remove the second actor on stage
+ second.Unparent();
+
+ // Move the focus backward
+ manager.MoveFocusBackward();
+
+ // Check that it current focused actor is first actor
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
+
+ END_TEST;
+}
#include <dali/integration-api/events/touch-event-integ.h>
#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
+#include <dali-toolkit/devel-api/visuals/text-visual-properties.h>
+
using namespace Dali;
using namespace Toolkit;
namespace
{
+static const char* TEST_IMAGE_ONE = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
+
+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 gPushButtonSelectedState = false;
bool PushButtonSelected( Button button )
return true;
}
+static bool gPushButtonClicked = false;
+
+static bool PushButtonClicked( Button button )
+{
+ gPushButtonClicked = true;
+ return gPushButtonClicked;
+}
+
Dali::Integration::Point GetPointDownInside()
{
Dali::Integration::Point point;
point.SetState( PointState::DOWN );
- point.SetScreenPosition( Vector2( 240, 400 ) );
+ point.SetScreenPosition( INSIDE_TOUCH_POINT_POSITON );
return point;
}
{
Dali::Integration::Point point;
point.SetState( PointState::UP );
- point.SetScreenPosition( Vector2( 240, 400 ) );
+ point.SetScreenPosition( INSIDE_TOUCH_POINT_POSITON );
return point;
}
{
Dali::Integration::Point point;
point.SetState( PointState::LEAVE );
- point.SetScreenPosition( Vector2( 240, 400 ) );
+ point.SetScreenPosition( INSIDE_TOUCH_POINT_POSITON );
return point;
}
{
Dali::Integration::Point point;
point.SetState( PointState::MOTION );
- point.SetScreenPosition( Vector2( 240, 400 ) );
+ point.SetScreenPosition( INSIDE_TOUCH_POINT_POSITON );
return point;
}
return point;
}
+// Set up the position of the button for the default test events
+void SetupButtonForTestTouchEvents( ToolkitTestApplication& application, Button& button, bool useDefaultImages )
+{
+ button.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ button.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ button.SetPosition( BUTTON_POSITON_TO_GET_INSIDE_TOUCH_EVENTS );
+ if ( useDefaultImages )
+ {
+ const Vector2 TEST_IMAGE_SIZE = Vector2( BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS );
+ TestPlatformAbstraction& platform = application.GetPlatform();
+ platform.SetClosestImageSize( TEST_IMAGE_SIZE );
+ button.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, TEST_IMAGE_ONE );
+ button.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, TEST_IMAGE_ONE );
+ }
+}
+
} //namespace
int UtcDaliPushButtonConstructorP(void)
END_TEST;
}
+int UtcDaliPushButtonSetAutoRepeating(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliPushButtonSetAutoRepeating\n");
+ tet_infoline("Ensure setting AutoRepeating on a SELECTED Toggle button switches off Toggle\n");
+ PushButton pushButton = PushButton::New();
+
+ const bool INITIAL_TOGGLE_VALUE = true;
+ const bool INITIAL_SELECTED_VALUE = true;
+
+ pushButton.SetProperty( Button::Property::TOGGLABLE, INITIAL_TOGGLE_VALUE);
+ pushButton.SetProperty( Button::Property::SELECTED, INITIAL_SELECTED_VALUE );
+
+ DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::TOGGLABLE ), INITIAL_TOGGLE_VALUE , TEST_LOCATION );
+ DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED ), INITIAL_SELECTED_VALUE , TEST_LOCATION );
+
+ pushButton.SetProperty( Button::Property::AUTO_REPEATING, true );
+
+ DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::TOGGLABLE ), !INITIAL_TOGGLE_VALUE , TEST_LOCATION );
+
+ END_TEST;
+}
+
int UtcDaliPushButtonSetGetTogglableButton(void)
{
ToolkitTestApplication application;
PushButton pushButton = PushButton::New();
+ pushButton.SetProperty( Toolkit::Button::Property::LABEL,
+ Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT )
+ .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f )
+ );
+
application.SendNotification();
application.Render();
PushButton pushButton = PushButton::New();
pushButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
pushButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
- pushButton.SetPosition( 240, 400 );
- pushButton.SetSize( 100, 100 );
+ pushButton.SetPosition( BUTTON_POSITON_TO_GET_INSIDE_TOUCH_EVENTS );
+ pushButton.SetSize( BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS );
Stage::GetCurrent().Add( pushButton );
PushButton pushButton = PushButton::New();
pushButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
pushButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
- pushButton.SetPosition( 240, 400 );
- pushButton.SetSize( 100, 100 );
+ pushButton.SetPosition( BUTTON_POSITON_TO_GET_INSIDE_TOUCH_EVENTS );
+ pushButton.SetSize( BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS );
Stage::GetCurrent().Add( pushButton );
PushButton pushButton = PushButton::New();
pushButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
pushButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
- pushButton.SetPosition( 240, 400 );
- pushButton.SetSize( 100, 100 );
+ pushButton.SetPosition( BUTTON_POSITON_TO_GET_INSIDE_TOUCH_EVENTS );
+ pushButton.SetSize( BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS );
Stage::GetCurrent().Add( pushButton );
DALI_TEST_CHECK( !gPushButtonSelectedState );
// Test4. Touch point down inside and up outside the button.
-
+ // State changes on Button down
gPushButtonSelectedState = false;
event = Dali::Integration::TouchEvent();
event.AddPoint( GetPointDownInside() );
event.AddPoint( GetPointUpOutside() );
application.ProcessEvent( event );
- DALI_TEST_CHECK( !gPushButtonSelectedState );
+ DALI_TEST_CHECK( gPushButtonSelectedState );
// Test5. Touch point down outside and up inside the button.
+ // Start in unselected state
+ pushButton.SetProperty( Button::Property::SELECTED, false );
+ DALI_TEST_CHECK( !pushButton.IsSelected());
gPushButtonSelectedState = false;
event = Dali::Integration::TouchEvent();
// The icon and label are each enabled and disabled to confirm the correct padding is used.
PushButton pushButton = PushButton::New();
- pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, Vector4( 10.0f, 10.0f, 10.0f, 10.0f ) );
- pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, Vector4( 20.0f, 20.0f, 20.0f, 20.0f ) );
+ const Vector4 TEST_ICON_PADDING( 20.0f, 20.0f, 20.0f, 20.0f );
+ const Vector4 TEST_LABEL_PADDING( 10.0f, 10.0f, 10.0f ,10.0f );
+ const Vector2 TEST_IMAGE_SIZE = Vector2( 5.0f, 5.0f);
pushButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
pushButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
Vector2 size( Vector2::ZERO );
size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+ tet_printf( "Button Natural Size(%f,%f)\n", pushButton.GetNaturalSize().width, pushButton.GetNaturalSize().height );
DALI_TEST_EQUALS( size, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- // Check label only padding.
+ // Check label only padding
pushButton.SetLabelText( "Label" );
application.SendNotification();
application.Render();
- size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
- size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+ Vector2 sizeWithLabelWithoutPadding( Vector2::ZERO );
+ sizeWithLabelWithoutPadding.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
+ sizeWithLabelWithoutPadding.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+
+ tet_printf( "Button RelayoutSize label without padding (%f,%f)\n", sizeWithLabelWithoutPadding.width, sizeWithLabelWithoutPadding.height );
+
+ // Add label padding to label
+ pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, TEST_LABEL_PADDING );
+ application.SendNotification();
+ application.Render();
- // We should not test against the exact label size, we just make sure it is larger than our label padding so we know the padding has been applied.
- DALI_TEST_GREATER( size.width, 20.0f, TEST_LOCATION );
- DALI_TEST_GREATER( size.height, 20.0f, TEST_LOCATION );
+ Vector2 sizeLabelAndPadding( Vector2::ZERO );
+ sizeLabelAndPadding.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
+ sizeLabelAndPadding.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+ tet_printf( "Button RelayoutSize after label padding(%f,%f)\n", sizeLabelAndPadding.width, sizeLabelAndPadding.height );
+
+ // If control size has increased beyond size of just label then padding has been applied
+ DALI_TEST_GREATER( sizeLabelAndPadding.width, sizeWithLabelWithoutPadding.width+TEST_LABEL_PADDING.x, TEST_LOCATION );
+ DALI_TEST_GREATER( sizeLabelAndPadding.height, sizeWithLabelWithoutPadding.height+TEST_LABEL_PADDING.w, TEST_LOCATION );
// Re-initialise the button so we can setup icon-only padding.
pushButton.Unparent();
pushButton = PushButton::New();
- pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, Vector4( 10.0f, 10.0f, 10.0f, 10.0f ) );
- pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, Vector4( 20.0f, 20.0f, 20.0f, 20.0f ) );
-
pushButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
pushButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
pushButton.SetPosition( 0.0f, 0.0f );
Stage::GetCurrent().Add( pushButton );
- const char* INVALID_IMAGE_FILE_NAME = "invalid-image.jpg";
+ TestPlatformAbstraction& platform = application.GetPlatform();
+ platform.SetClosestImageSize( TEST_IMAGE_SIZE );
+
pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "RIGHT" );
- pushButton.SetProperty( Toolkit::PushButton::Property::UNSELECTED_ICON, INVALID_IMAGE_FILE_NAME );
- pushButton.SetProperty( Toolkit::PushButton::Property::SELECTED_ICON, INVALID_IMAGE_FILE_NAME );
+ pushButton.SetProperty( Toolkit::PushButton::Property::UNSELECTED_ICON, TEST_IMAGE_ONE );
+ pushButton.SetProperty( Toolkit::PushButton::Property::SELECTED_ICON, TEST_IMAGE_ONE );
application.SendNotification();
application.Render();
+ // Size of button with just icon
size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+ tet_printf( "Button RelayoutSize with icon(%f,%f)\n", size.width, size.height );
+
+ pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, TEST_ICON_PADDING );
+
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_EQUALS( size, TEST_IMAGE_SIZE, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( size, Vector2( 40.0f, 40.0f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
+ size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+ tet_printf( "Button RelayoutSize after icon padding(%f,%f)\n", size.width, size.height );
+ const Vector2 expectedIconAndPaddingSize( TEST_ICON_PADDING.x+TEST_ICON_PADDING.y+TEST_IMAGE_SIZE.width, TEST_ICON_PADDING.w+TEST_ICON_PADDING.z +TEST_IMAGE_SIZE.height );
+ DALI_TEST_EQUALS( size, expectedIconAndPaddingSize, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
// Now test padding for both label and icon simultaneously.
pushButton.SetLabelText( "Label" );
+ application.SendNotification();
+ application.Render();
+
+ size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
+ size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+ tet_printf( "Button RelayoutSize after label added(%f,%f)\n", size.width, size.height );
+
+ pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, TEST_LABEL_PADDING );
application.SendNotification();
application.Render();
size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+ tet_printf( "Button RelayoutSize after icon and label padding(%f,%f)\n", size.width, size.height );
- // We should not test against the exact label size, we just make sure it is larger than our label padding so we know the padding has been applied.
- // Note we only test the width as we are horizontally aligned and the label my be less high than the icon.
- // Full directional alignment tests are done in UtcDaliPushButtonAlignmentLayout.
- DALI_TEST_GREATER( size.width, 60.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( size.width, sizeLabelAndPadding.width + expectedIconAndPaddingSize.width, TEST_LOCATION );
+ DALI_TEST_GREATER( size.height, expectedIconAndPaddingSize.width, TEST_LOCATION ); // Test height of control is greater than icon and padding. As Text set to larger values.
END_TEST;
}
* | | v +------------+ -
* +---------+ -
*/
- PushButton pushButton = PushButton::New();
- pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, Vector4( 30.0f, 30.0f, 30.0f, 30.0f ) );
- pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, Vector4( 75.0f, 75.0f, 75.0f, 75.0f ) );
+ const Vector4 TEST_ICON_PADDING( 70.0f, 70.0f, 70.0f, 70.0f );
+ const Vector4 TEST_LABEL_PADDING( 30.0f, 30.0f, 30.0f, 30.0f );
+ const Vector2 TEST_IMAGE_SIZE = Vector2( 10.0f, 10.0f);
+
+ PushButton pushButton = PushButton::New();
pushButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
pushButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
Stage::GetCurrent().Add( pushButton );
- const char* INVALID_IMAGE_FILE_NAME = "invalid-image.jpg";
- pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "RIGHT" );
- pushButton.SetProperty( Toolkit::PushButton::Property::UNSELECTED_ICON, INVALID_IMAGE_FILE_NAME );
- pushButton.SetProperty( Toolkit::PushButton::Property::SELECTED_ICON, INVALID_IMAGE_FILE_NAME );
+ // Add a label and get size of control
+ pushButton.SetLabelText( "Label" );
+ application.SendNotification();
+ application.Render();
+
+ // First get the size of control with just label
+ Vector2 justLabelSize( Vector2::ZERO );
+ justLabelSize.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
+ justLabelSize.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+ tet_printf( "Button RelayoutSize with just label and no padding(%f,%f)\n", justLabelSize.width, justLabelSize.height );
+ pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, TEST_LABEL_PADDING );
application.SendNotification();
application.Render();
- // First get the base size (without label).
- Vector2 baseSize( Vector2::ZERO );
- baseSize.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
- baseSize.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+ // Size of Label and Padding
+ Vector2 expectedLabelAndPaddingSize( Vector2::ZERO );
+ expectedLabelAndPaddingSize.width = justLabelSize.width + TEST_LABEL_PADDING.x + TEST_LABEL_PADDING.y;
+ expectedLabelAndPaddingSize.height = justLabelSize.height + TEST_LABEL_PADDING.w + TEST_LABEL_PADDING.z;
- DALI_TEST_EQUALS( baseSize, Vector2( 150.0f, 150.0f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ Vector2 labelAndPaddingSize( Vector2::ZERO );
+ labelAndPaddingSize.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
+ labelAndPaddingSize.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
- // Add a label to cause size to be modified in the direction of alignment.
- pushButton.SetLabelText( "Label" );
+ DALI_TEST_EQUALS( labelAndPaddingSize, expectedLabelAndPaddingSize , Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+ const Vector2 testImageWithPaddingSize = Vector2 ( ( TEST_IMAGE_SIZE.width + TEST_ICON_PADDING.x + TEST_ICON_PADDING.y ),
+ ( TEST_IMAGE_SIZE.height + TEST_ICON_PADDING.w + TEST_ICON_PADDING.z ) );
+
+ TestPlatformAbstraction& platform = application.GetPlatform();
+ platform.SetClosestImageSize( TEST_IMAGE_SIZE );
+
+ // Add Icon and set its alignment
+ pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "RIGHT" );
+ pushButton.SetProperty( Toolkit::PushButton::Property::UNSELECTED_ICON, TEST_IMAGE_ONE );
+ pushButton.SetProperty( Toolkit::PushButton::Property::SELECTED_ICON, TEST_IMAGE_ONE );
+ pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, TEST_ICON_PADDING );
application.SendNotification();
application.Render();
size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
-
/*
* Test Icon right alignment.
* Height grows to largest of Icon or Label (+ padding).
* |............+ |
* +------------+---------+
*/
- DALI_TEST_GREATER( size.width, 150.0f + 60.0f, TEST_LOCATION );
- DALI_TEST_EQUALS( size.height, 150.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( size.width, ( testImageWithPaddingSize.width + labelAndPaddingSize.width ) , TEST_LOCATION );
+ DALI_TEST_EQUALS( size.height, ( std::max( testImageWithPaddingSize.height, labelAndPaddingSize.height) ) , Math::MACHINE_EPSILON_1000, TEST_LOCATION );
// Now test left alignment matches right for size.
pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "LEFT" );
application.SendNotification();
application.Render();
- Vector2 compareSize( Vector2::ZERO );
- compareSize.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
- compareSize.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+ size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
+ size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
/*
* Test Icon left alignment.
* | +............|
* +---------+------------+
*/
- DALI_TEST_EQUALS( size, compareSize, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-
- // Test top alignment.
- pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "TOP" );
-
- application.SendNotification();
- application.Render();
-
- compareSize.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
- compareSize.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+ DALI_TEST_EQUALS( size.width, ( testImageWithPaddingSize.width + labelAndPaddingSize.width ) , TEST_LOCATION );
+ DALI_TEST_EQUALS( size.height, ( std::max( testImageWithPaddingSize.height, labelAndPaddingSize.height) ) , Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ tet_infoline(" Test Icon TOP alignment - Width grows to largest of Icon or label (plus padding)");
/*
- * Test Icon top alignment.
- * Width grows to largest of Icon or Label (+ padding).
*
* +---------+
* | |
* | |
* +---------+
*
- * Note: We subtract a small number as we want to do a >= test.
*/
- DALI_TEST_GREATER( size.width, 150.0f - Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_GREATER( compareSize.height, 150.0f + 60.0f, TEST_LOCATION );
- // Test bottom alignment.
- pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "BOTTOM" );
+ tet_infoline("SetProperty on ICON_ALIGNMENT should relayout the Button");
+ pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "TOP" );
application.SendNotification();
application.Render();
size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+ tet_printf("Natural width (%f)\n",pushButton.GetNaturalSize().width);
+ tet_printf("Natural height (%f)\n",pushButton.GetNaturalSize().height);
+
+ tet_printf(" UtcDaliPushButtonAlignmentLayout Top layout - Image and Padding size (%f,%f)\n", testImageWithPaddingSize.width, testImageWithPaddingSize.height );
+ tet_printf(" UtcDaliPushButtonAlignmentLayout Top layout - Text and Padding size (%f,%f)\n", labelAndPaddingSize.width, labelAndPaddingSize.height );
+
+ DALI_TEST_EQUALS( size.width, ( std::max( testImageWithPaddingSize.width, labelAndPaddingSize.width ) ) , TEST_LOCATION );
+
+ DALI_TEST_EQUALS( size.height,( testImageWithPaddingSize.height + labelAndPaddingSize.height ) , TEST_LOCATION );
+
/*
* Test Icon bottom alignment.
* Width grows to largest of Icon or Label (+ padding).
* | |
* +---------+
*/
- DALI_TEST_EQUALS( size, compareSize, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ tet_infoline(" Test Icon BOTTOM alignment - Width grows to largest of Icon or label (plus padding)");
+ pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "BOTTOM" );
+
+ application.SendNotification();
+ application.Render();
+
+ size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
+ size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+
+ DALI_TEST_EQUALS( size.width, ( std::max(testImageWithPaddingSize.width, labelAndPaddingSize.width )) , TEST_LOCATION );
+ DALI_TEST_EQUALS( size.height,( testImageWithPaddingSize.height + labelAndPaddingSize.height ) , TEST_LOCATION );
END_TEST;
}
-int UtcDaliPushButtonSetButtonImageP(void)
+int UtcDaliPushButtonSetUnSelectedVisual01P(void)
{
+ tet_infoline(" Test adding a visual for the UNSELECTED_VISUAL property, removing Button from stage and counting renderers\n");
ToolkitTestApplication application;
- PushButton button = PushButton::New();
- Stage::GetCurrent().Add( button );
+ PushButton pushButton = PushButton::New();
+ pushButton.SetSize( BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS );
- try
- {
- button.SetButtonImage( ImageView::New() );
- DALI_TEST_CHECK( true );
- }
- catch(...)
- {
- DALI_TEST_CHECK( false );
- }
+ Stage::GetCurrent().Add( pushButton );
- END_TEST;
-}
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
+ propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
-int UtcDaliPushButtonSetButtonImageN(void)
-{
- ToolkitTestApplication application;
+ pushButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, propertyMap );
- PushButton button;
+ tet_infoline(" UNSELECTED_VISUAL Added to button\n");
- try
- {
- button.SetSelectedImage( ImageView::New() );
- DALI_TEST_CHECK( false );
- }
- catch(...)
- {
- DALI_TEST_CHECK( true );
- }
+ application.SendNotification();
+ application.Render(0);
- END_TEST;
-}
+ unsigned int rendererCount = pushButton.GetRendererCount();
+ tet_printf("After adding UNSELECTED_BACKGROUND_VISUAL the renderer count is(%d)\n", rendererCount );
-int UtcDaliPushButtonSetBackgroundImageP(void)
-{
- ToolkitTestApplication application;
+ DALI_TEST_EQUALS( pushButton.GetRendererCount(), 1 , TEST_LOCATION );
- PushButton button = PushButton::New();
- Stage::GetCurrent().Add( button );
+ tet_printf("Remove button from stage\n" );
- try
- {
- button.SetBackgroundImage( ImageView::New() );
- DALI_TEST_CHECK( true );
- }
- catch(...)
- {
- DALI_TEST_CHECK( false );
- }
+ Stage::GetCurrent().Remove( pushButton );
+
+ rendererCount = pushButton.GetRendererCount();
+ tet_printf("After removing pushbutton from stage the renderer count is(%d)\n ", rendererCount );
+
+ DALI_TEST_EQUALS( pushButton.GetRendererCount(), 0, TEST_LOCATION );
+
+ tet_printf("After removing pushbutton from stage the renderer count is(%d)\n ", rendererCount );
+
+ Property::Map propertyMap2;
+ propertyMap2.Insert(Visual::Property::TYPE, Visual::COLOR);
+ propertyMap2.Insert(ColorVisual::Property::MIX_COLOR, Color::RED);
+ pushButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_VISUAL, propertyMap2 );
+
+ tet_printf("Added UNSELECTED_VISUAL and add button back to Stage\n");
+
+ Stage::GetCurrent().Add( pushButton );
+
+ tet_printf("With UNSELECTED_BACKGROUND_VISUAL and UNSELECTED_ICON the renderer count is(%d)\n", pushButton.GetRendererCount() );
+
+ DALI_TEST_EQUALS( pushButton.GetRendererCount(), 2, TEST_LOCATION );
END_TEST;
}
-int UtcDaliPushButtonSetBackgroundImageN(void)
+int UtcDaliPushButtonSetSelectedVisualN(void)
{
+ tet_infoline(" Test adding a broken visual for the UNSELECTED_VISUAL property");
+
ToolkitTestApplication application;
- PushButton button;
+ PushButton pushButton = PushButton::New();
- try
- {
- button.SetBackgroundImage( ImageView::New() );
- DALI_TEST_CHECK( false );
- }
- catch(...)
- {
- DALI_TEST_CHECK( true );
- }
+ pushButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ pushButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ pushButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
+
+ Stage::GetCurrent().Add( pushButton );
+ application.SendNotification();
+ application.Render(0);
+
+ unsigned int preRendererCount = pushButton.GetRendererCount();
+ tet_printf("RendererCount prior to adding visual(%d)\n",preRendererCount);
+ DALI_TEST_EQUALS( preRendererCount, 0, TEST_LOCATION );
+
+ Stage::GetCurrent().Remove( pushButton );
+ application.SendNotification();
+ application.Render(0);
+
+ Property::Map colorMap;
+ const int BROKEN_VISUAL_TYPE = 999999999;
+
+ colorMap.Insert(Visual::Property::TYPE, BROKEN_VISUAL_TYPE);
+ colorMap.Insert(BorderVisual::Property::COLOR, Color::BLUE);
+ colorMap.Insert(BorderVisual::Property::SIZE, 5.f);
+ pushButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_VISUAL, colorMap );
+
+ Stage::GetCurrent().Add( pushButton );
+ application.SendNotification();
+ application.Render(0);
+
+ unsigned int postRendererCount = pushButton.GetRendererCount();
+ tet_printf("RendererCount post broken visual (%d)\n", postRendererCount);
+ DALI_TEST_EQUALS( postRendererCount, 0, TEST_LOCATION );
END_TEST;
}
-int UtcDaliPushButtonSetSelectedImageP(void)
+int UtcDaliPushButtonSetButtonImageP(void)
{
ToolkitTestApplication application;
try
{
- button.SetSelectedImage( ImageView::New() );
+ button.SetButtonImage( ImageView::New() );
DALI_TEST_CHECK( true );
}
catch(...)
END_TEST;
}
-int UtcDaliPushButtonSetSelectedImageN(void)
+int UtcDaliPushButtonSetBackgroundImageP(void)
{
ToolkitTestApplication application;
- PushButton button;
+ PushButton button = PushButton::New();
+ Stage::GetCurrent().Add( button );
try
{
- button.SetSelectedImage( ImageView::New() );
- DALI_TEST_CHECK( false );
+ button.SetBackgroundImage( ImageView::New() );
+ DALI_TEST_CHECK( true );
}
catch(...)
{
- DALI_TEST_CHECK( true );
+ DALI_TEST_CHECK( false );
}
END_TEST;
}
-int UtcDaliPushButtonSetSelectedBackgroundImageP(void)
+int UtcDaliPushButtonSetSelectedImageP(void)
{
ToolkitTestApplication application;
try
{
- button.SetSelectedBackgroundImage( ImageView::New() );
+ button.SetSelectedImage( ImageView::New() );
DALI_TEST_CHECK( true );
}
catch(...)
END_TEST;
}
-int UtcDaliPushButtonSetSelectedBackgroundImageN(void)
+int UtcDaliPushButtonSetSelectedBackgroundImageP(void)
{
ToolkitTestApplication application;
- PushButton button;
+ PushButton button = PushButton::New();
+ Stage::GetCurrent().Add( button );
try
{
button.SetSelectedBackgroundImage( ImageView::New() );
- DALI_TEST_CHECK( false );
+ DALI_TEST_CHECK( true );
}
catch(...)
{
- DALI_TEST_CHECK( true );
+ DALI_TEST_CHECK( false );
}
END_TEST;
END_TEST;
}
-int UtcDaliPushButtonSetDisabledBackgroundImageN(void)
-{
- ToolkitTestApplication application;
-
- PushButton button;
-
- try
- {
- button.SetDisabledBackgroundImage( ImageView::New() );
- DALI_TEST_CHECK( false );
- }
- catch(...)
- {
- DALI_TEST_CHECK( true );
- }
-
- END_TEST;
-}
int UtcDaliPushButtonSetDisabledImageP(void)
{
END_TEST;
}
-int UtcDaliPushButtonSetDisabledImageN(void)
-{
- ToolkitTestApplication application;
-
- PushButton button;
-
- try
- {
- button.SetDisabledImage( ImageView::New() );
- DALI_TEST_CHECK( false );
- }
- catch(...)
- {
- DALI_TEST_CHECK( true );
- }
-
- END_TEST;
-}
-
int UtcDaliPushButtonSetDisabledSelectedImageP(void)
{
ToolkitTestApplication application;
END_TEST;
}
-int UtcDaliPushButtonSetDisabledSelectedImageN(void)
+int UtcDaliPushButtonToggleSignalP(void)
{
ToolkitTestApplication application;
+ tet_infoline(" UtcDaliButtonToggleSignalP Ensure Signals emitted");
- PushButton button;
+ PushButton button = PushButton::New();
+ button.SetProperty( Button::Property::TOGGLABLE, true);
- try
- {
- button.SetDisabledSelectedImage( ImageView::New() );
- DALI_TEST_CHECK( false );
- }
- catch(...)
- {
- DALI_TEST_CHECK( true );
- }
+ SetupButtonForTestTouchEvents( application, button, true );
+
+ Stage::GetCurrent().Add( button );
+
+ application.SendNotification();
+ application.Render();
+
+ // connect to its signal
+ button.ClickedSignal().Connect( &PushButtonClicked );
+ gPushButtonClicked = false;
+
+ tet_infoline(" Touch down and up within button");
+ Dali::Integration::TouchEvent event;
+ event = Dali::Integration::TouchEvent();
+ event.AddPoint( GetPointDownInside() );
+ application.ProcessEvent( event );
+
+ event = Dali::Integration::TouchEvent();
+ event.AddPoint( GetPointUpInside() );
+ application.ProcessEvent( event );
+
+ DALI_TEST_EQUALS( gPushButtonClicked, true, TEST_LOCATION );
END_TEST;
}
#include <dali-toolkit/dali-toolkit.h>
#include <dali/integration-api/events/touch-event-integ.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
+#include <dali-toolkit/devel-api/visuals/text-visual-properties.h>
using namespace Dali;
using namespace Dali::Toolkit;
std::string labelText = "test actor 1";
- RadioButton radioButton = RadioButton::New( labelText );
+ RadioButton radioButton = RadioButton::New();
+
+ radioButton.SetProperty( Toolkit::Button::Property::LABEL,
+ Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT )
+ .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f )
+ );
+
+ radioButton.SetLabelText( labelText );
+
DALI_TEST_EQUALS( radioButton.GetLabelText(), labelText, TEST_LOCATION );
std::string labelText2 = "test actor 2";
application.SendNotification();
application.Render();
- // Check there are the expected number of children ( offscreen root actor, and the offscreen image view
- DALI_TEST_EQUALS( editor.GetChildCount(), 2u, TEST_LOCATION );
+ // Check there are the expected number of children (the stencil).
+ DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
- Actor offscreenRoot = editor.GetChildAt( 0u );
- DALI_TEST_CHECK( offscreenRoot.IsLayer() );
- DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor.
-
- Actor offscreenImage = editor.GetChildAt( 1u );
- DALI_TEST_CHECK( offscreenImage );
+ Actor stencil = editor.GetChildAt( 0u );
// Create a tap event to touch the text editor.
application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
application.SendNotification();
application.Render();
- Actor layer = editor.GetChildAt( 2u );
+ Actor layer = editor.GetChildAt( 1u );
DALI_TEST_CHECK( layer.IsLayer() );
DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
- DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor.
+ DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
// Now the text editor has the focus, so it can handle the key events.
application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
// Checks the cursor and the renderer have been created.
DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
- DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 2u, TEST_LOCATION ); // The camera actor and the renderer
+ DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
DALI_TEST_CHECK( cursor );
- CameraActor camera = CameraActor::DownCast( offscreenRoot.GetChildAt( 0u ) );
- DALI_TEST_CHECK( camera );
-
- // The offscreen root actor has a container with all the actors which contain the text renderers.
- Actor container = offscreenRoot.GetChildAt( 1u );
+ // The stencil actor has a container with all the actors which contain the text renderers.
+ Actor container = stencil.GetChildAt( 0u );
for( unsigned int index = 0; index < container.GetChildCount(); ++index )
{
Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
// Should not be a renderer.
- DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor only.
+ DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
END_TEST;
}
application.SendNotification();
application.Render();
- // The offscreen root actor should have three actors: the camera, a renderer and the highlight actor.
- Actor offscreenRoot = editor.GetChildAt( 0u );
- DALI_TEST_CHECK( offscreenRoot.IsLayer() );
-
- CameraActor camera = CameraActor::DownCast( offscreenRoot.GetChildAt( 0u ) );
- DALI_TEST_CHECK( camera );
+ // The stencil actor should have two actors: the renderer and the highlight actor.
+ Actor stencil = editor.GetChildAt( 0u );
- // The offscreen root actor has a container with all the actors which contain the text renderers.
- Actor container = offscreenRoot.GetChildAt( 1u );
+ // The stencil actor has a container with all the actors which contain the text renderers.
+ Actor container = stencil.GetChildAt( 0u );
for( unsigned int index = 0; index < container.GetChildCount(); ++index )
{
Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
DALI_TEST_CHECK( renderer );
}
- Renderer highlight = offscreenRoot.GetChildAt( 2u ).GetRendererAt( 0u );
+ Renderer highlight = stencil.GetChildAt( 1u ).GetRendererAt( 0u );
DALI_TEST_CHECK( highlight );
END_TEST;
DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
// Check exceed policy
- // Set a different exceed policy is not implemented.
+ field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
+ DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
+ field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
+ DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
// Check that the Alignment properties can be correctly set
field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
application.SendNotification();
application.Render();
- // Check there are the expected number of children ( offscreen root actor, and the offscreen image view
- DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
+ // Check there are the expected number of children ( stencil ).
+ DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
- Actor offscreenRoot = field.GetChildAt( 0u );
- DALI_TEST_CHECK( offscreenRoot.IsLayer() );
- DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor.
-
- Actor offscreenImage = field.GetChildAt( 1u );
- DALI_TEST_CHECK( offscreenImage );
+ Actor stencil = field.GetChildAt( 0u );
+ DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
// Create a tap event to touch the text field.
application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
application.SendNotification();
application.Render();
- Actor layer = field.GetChildAt( 2u );
+ Actor layer = field.GetChildAt( 1u );
DALI_TEST_CHECK( layer.IsLayer() );
DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
- DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor.
+ DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
// Now the text field has the focus, so it can handle the key events.
application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
// Checks the cursor and the renderer have been created.
DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
- DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 2u, TEST_LOCATION ); // The camera actor and the renderer
+ DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
DALI_TEST_CHECK( cursor );
- CameraActor camera = CameraActor::DownCast( offscreenRoot.GetChildAt( 0u ) );
- DALI_TEST_CHECK( camera );
-
// The offscreen root actor has a container with all the actors which contain the text renderers.
- Actor container = offscreenRoot.GetChildAt( 1u );
+ Actor container = stencil.GetChildAt( 0u );
for( unsigned int index = 0; index < container.GetChildCount(); ++index )
{
Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
// Should not be a renderer.
- DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor only.
+ DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
END_TEST;
}
application.SendNotification();
application.Render();
- // The offscreen root actor should have three actors: the camera, a renderer and the highlight actor.
- Actor offscreenRoot = field.GetChildAt( 1u );
- DALI_TEST_CHECK( offscreenRoot.IsLayer() );
-
- CameraActor camera = CameraActor::DownCast( offscreenRoot.GetChildAt( 0u ) );
- DALI_TEST_CHECK( camera );
+ // The offscreen root actor should have two actors: the renderer and the highlight actor.
+ Actor stencil = field.GetChildAt( 0u );
// The offscreen root actor has a container with all the actors which contain the text renderers.
- Actor container = offscreenRoot.GetChildAt( 1u );
+ Actor container = stencil.GetChildAt( 0u );
for( unsigned int index = 0; index < container.GetChildCount(); ++index )
{
Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
DALI_TEST_CHECK( renderer );
}
- Renderer highlight = offscreenRoot.GetChildAt( 2u ).GetRendererAt( 0u );
+ Renderer highlight = stencil.GetChildAt( 1u ).GetRendererAt( 0u );
DALI_TEST_CHECK( highlight );
END_TEST;
SendPan(application, Gesture::Finished, pos);
Wait(application, RENDER_FRAME_INTERVAL);
- Actor offscreenRoot = field.GetChildAt( 1u );
+ Actor stencil = field.GetChildAt( 1u );
END_TEST;
}
END_TEST;
}
-
int UtcDaliTransitionDataMap3P(void)
{
TestApplication application;
- tet_printf("Testing animation of a visual's placement actor property\n");
+ tet_printf("Testing animation of an actor's position property using bezier curve\n");
Property::Map map;
- map["target"] = "visual1";
- map["property"] = "color";
- map["initialValue"] = Color::MAGENTA;
- map["targetValue"] = Color::RED;
+ map["target"] = "Actor1";
+ map["property"] = "position";
+ map["initialValue"] = Vector3(0, 0, 0);
+ map["targetValue"] = Vector3(100, 100, 0);
map["animator"] = Property::Map()
- .Add("alphaFunction", "EASE_IN_OUT")
+ .Add("alphaFunction", Vector4(0.71, -0.57, 0.42, 1.38) )
.Add("timePeriod", Property::Map()
- .Add("delay", 0.5f)
+ .Add("delay", 0.0f)
.Add("duration", 1.0f));
Dali::Toolkit::TransitionData transition = TransitionData::New( map );
DummyControl actor = DummyControl::New();
actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
actor.SetName("Actor1");
- actor.SetColor(Color::CYAN);
Stage::GetCurrent().Add(actor);
DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
-
- Property::Map visualMap;
- visualMap[Visual::Property::TYPE] = Visual::COLOR;
- visualMap[ColorVisual::Property::MIX_COLOR] = Color::MAGENTA;
- Visual::Base visual = VisualFactory::Get().CreateVisual( visualMap );
- visual.SetName( "visual1" );
-
- Property::Index visualIndex = Control::CONTROL_PROPERTY_END_INDEX + 1;
- dummyImpl.RegisterVisual( visualIndex, visual );
-
Animation anim = dummyImpl.CreateTransition( transition );
DALI_TEST_CHECK( anim );
application.SendNotification();
application.Render(0);
- DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::MAGENTA, TEST_LOCATION);
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(0,0,0), 0.001f, TEST_LOCATION);
anim.Play();
application.SendNotification();
application.Render(0);
- application.Render(500);
- application.Render(500); // Halfway thru map1 anim
+
+ application.Render(250); // 25%
application.SendNotification();
- DALI_TEST_EQUALS( actor.GetCurrentColor(), (Color::MAGENTA+Color::RED)*0.5f, TEST_LOCATION);
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(-10,-10,0), 1.0, TEST_LOCATION); // High epsilon as we don't have exact figure for bezier curve at 50%
- application.Render(500); // End of map1 anim
+ application.Render(250); // Halfway thru map1 anim
application.SendNotification();
- DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::RED, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(24,24,0), 1.0, TEST_LOCATION); // High epsilon as we don't have exact figure for bezier curve at 50%
+
+ application.Render(250); // End of map1 anim
+ application.SendNotification();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(100,100,0), 1.0, TEST_LOCATION); // High epsilon as we don't have exact figure for bezier curve
+
+ application.Render(250); // End of map1 anim
+ application.SendNotification();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(100,100,0), TEST_LOCATION );
END_TEST;
}
{
TestApplication application;
- tet_printf("Testing animation of a visual's placement actor property using bezier curve\n");
+ tet_printf("Testing animation of a visual's transform property using programmatic maps\n");
- Property::Map map;
- map["target"] = "Actor1";
- map["property"] = "position";
- map["initialValue"] = Vector3(0, 0, 0);
- map["targetValue"] = Vector3(100, 100, 0);
- map["animator"] = Property::Map()
- .Add("alphaFunction", Vector4(0.71, -0.57, 0.42, 1.38) )
+ Property::Map map1;
+ map1["target"] = "testVisual";
+ map1["property"] = "offset";
+ map1["initialValue"] = Vector2(0.0f, 0.0f);
+ map1["targetValue"] = Vector2(100.0f, 100.0f);
+ map1["animator"] = Property::Map()
+ .Add("alphaFunction", "LINEAR")
.Add("timePeriod", Property::Map()
- .Add("delay", 0.0f)
+ .Add("delay", 0.5f)
.Add("duration", 1.0f));
- Dali::Toolkit::TransitionData transition = TransitionData::New( map );
+ Property::Map map2;
+ map2["target"] = "testVisual";
+ map2["property"] = "size";
+ map2["initialValue"] = Vector2(10.0f, 10.0f);
+ map2["targetValue"] = Vector2(110.0f, 110.0f);
+ map2["animator"] = Property::Map()
+ .Add("alphaFunction", "LINEAR")
+ .Add("timePeriod", Property::Map()
+ .Add("delay", 0.5f)
+ .Add("duration", 1.0f));
+
+ Dali::Toolkit::TransitionData transition = TransitionData::New( Property::Array().Add(map1).Add(map2) );
DummyControl actor = DummyControl::New();
actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
Stage::GetCurrent().Add(actor);
DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+
+ Property::Map visualMap;
+ visualMap[Visual::Property::TYPE] = Visual::COLOR;
+ visualMap[ColorVisual::Property::MIX_COLOR] = Color::MAGENTA;
+ Visual::Base visual = VisualFactory::Get().CreateVisual( visualMap );
+
+ visual.SetName( "testVisual" );
+ dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
+
Animation anim = dummyImpl.CreateTransition( transition );
DALI_TEST_CHECK( anim );
+ Renderer renderer = actor.GetRendererAt(0);
+ Property::Index sizeIndex = renderer.GetPropertyIndex( "size" );
application.SendNotification();
application.Render(0);
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(0,0,0), 0.001f, TEST_LOCATION);
+
+ DALI_TEST_EQUALS( renderer.GetProperty<Vector2>(sizeIndex), Vector2(10.0f, 10.0f), TEST_LOCATION);
anim.Play();
application.SendNotification();
application.Render(0);
-
- application.Render(250); // 25%
- application.SendNotification();
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(-10,-10,0), 1.0, TEST_LOCATION); // High epsilon as we don't have exact figure for bezier curve at 50%
-
- application.Render(250); // Halfway thru map1 anim
+ application.Render(500); // Start animation
+ application.Render(500); // Halfway thru anim
application.SendNotification();
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(24,24,0), 1.0, TEST_LOCATION); // High epsilon as we don't have exact figure for bezier curve at 50%
+ DALI_TEST_EQUALS( renderer.GetProperty<Vector2>(sizeIndex), Vector2(60.0f, 60.0f), TEST_LOCATION);
- application.Render(250); // End of map1 anim
+ application.Render(500); // End of anim
application.SendNotification();
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(100,100,0), 1.0, TEST_LOCATION); // High epsilon as we don't have exact figure for bezier curve
+ DALI_TEST_EQUALS( renderer.GetProperty<Vector2>(sizeIndex), Vector2(110.0f, 110.0f), TEST_LOCATION );
- application.Render(250); // End of map1 anim
- application.SendNotification();
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(100,100,0), TEST_LOCATION );
END_TEST;
}
+
int UtcDaliTransitionDataMap1N(void)
{
TestApplication application;
Property::Map shader;
const std::string fragmentShader = "Foobar";
shader[Dali::Toolkit::Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
+
+ Property::Map transformMap;
+ transformMap["size"] = Vector2( 0.5f, 0.5f ) ;
+ transformMap["offset"] = Vector2( 20.0f, 0.0f ) ;
+ transformMap["offsetSizeMode"] = Vector4( 1.0f, 1.0f, 0.0f, 0.0f );
+ transformMap["anchorPoint"] = Align::CENTER;
+ transformMap["origin"] = Align::CENTER;
+ properties[DevelVisual::Property::TRANSFORM] = transformMap;
+
properties[Dali::Toolkit::Visual::Property::TYPE] = Dali::Toolkit::Visual::IMAGE;
properties[Dali::Toolkit::Visual::Property::SHADER]=shader;
properties[Dali::Toolkit::ImageVisual::Property::URL] = TEST_NPATCH_FILE_NAME;
dummy.SetSize(2000, 2000);
dummy.SetParentOrigin(ParentOrigin::CENTER);
Stage::GetCurrent().Add(dummy);
+ application.SendNotification();
Renderer renderer = dummy.GetRendererAt( 0 );
Shader shader2 = renderer.GetShader();
Property::Map* map = value.GetMap();
DALI_TEST_CHECK( map );
+ Property::Index index = renderer.GetPropertyIndex("size");
+ DALI_TEST_EQUALS( renderer.GetProperty( index ), Property::Value(Vector2(0.5, 0.5)), 0.001, TEST_LOCATION );
+
Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
// *map["vertex"]; is default here so not verifying it
DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 0, TEST_LOCATION );
dummyControl.SetSize(200.f, 200.f);
+ dummyControl.SetParentOrigin( ParentOrigin::CENTER );
Stage::GetCurrent().Add( dummyControl );
application.SendNotification();
propertyMap.Insert( TextVisual::Property::MULTI_LINE, true );
Property::Map transformMap;
- transformMap.Insert( DevelVisual::Transform::Property::SIZE, Vector2( 720.f, 640.f ) );
+ transformMap.Insert( "size", Vector2( 0.5f, 0.5f ) );
propertyMap.Insert( DevelVisual::Property::TRANSFORM, transformMap );
textVisual = factory.CreateVisual( propertyMap );
dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, textVisual );
dummyControl.SetSize( 720.f, 640.f );
- application.SendNotification();
+ application.SendNotification(); // force process events to ensure text visual
+ // adds renderer to the dummy control in OnRelayout
application.Render();
+ Renderer renderer = dummyControl.GetRendererAt(0u);
+ Property::Index index = renderer.GetPropertyIndex("size");
+
+ tet_infoline( "Test that the TextVisual overrides anything set by developer" );
+ DALI_TEST_EQUALS( renderer.GetProperty<Vector2>(index), Vector2( 1.0, 1.0 ), 0.001f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliVisualPremultipliedAlpha(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliVisualPremultipliedAlpha" );
+
+ VisualFactory factory = VisualFactory::Get();
+
+ // image visual, test default value ( false )
+ {
+ Visual::Base imageVisual = factory.CreateVisual(
+ Property::Map()
+ .Add( Visual::Property::TYPE, Visual::IMAGE )
+ .Add( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ) );
+
+ Dali::Property::Map visualMap;
+ imageVisual.CreatePropertyMap( visualMap );
+ Property::Value* value = visualMap.Find( DevelVisual::Property::PREMULTIPLIED_ALPHA );
+
+ // test values
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<bool>(), false, TEST_LOCATION );
+ }
+
+ // image visual, override premultiplied
+ {
+ Visual::Base imageVisual = factory.CreateVisual(
+ Property::Map()
+ .Add( Visual::Property::TYPE, Visual::IMAGE )
+ .Add( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME )
+ .Add( DevelVisual::Property::PREMULTIPLIED_ALPHA, true ) );
+
+ Dali::Property::Map visualMap;
+ imageVisual.CreatePropertyMap( visualMap );
+ Property::Value* value = visualMap.Find( DevelVisual::Property::PREMULTIPLIED_ALPHA );
+
+ // test values
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<bool>(), true, TEST_LOCATION);
+ }
+
+ // svg visual ( premultiplied alpha by default is true )
+ {
+ Visual::Base imageVisual = factory.CreateVisual(
+ Property::Map()
+ .Add( Visual::Property::TYPE, Visual::IMAGE )
+ .Add( ImageVisual::Property::URL, TEST_SVG_FILE_NAME ) );
+
+ Dali::Property::Map visualMap;
+ imageVisual.CreatePropertyMap( visualMap );
+ Property::Value* value = visualMap.Find( DevelVisual::Property::PREMULTIPLIED_ALPHA );
+
+ // test values
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<bool>(), true, TEST_LOCATION );
+ }
+
END_TEST;
}
develapicontrolsdir = $(develapidir)/controls
develapibloomviewdir = $(develapicontrolsdir)/bloom-view
develapibubbleemitterdir = $(develapicontrolsdir)/bubble-effect
+develapibuttonsdir = $(develapicontrolsdir)/buttons
develapieffectsviewdir = $(develapicontrolsdir)/effects-view
develapigaussianblurviewdir = $(develapicontrolsdir)/gaussian-blur-view
develapimagnifierdir = $(develapicontrolsdir)/magnifier
develapicontrols_HEADERS = $(devel_api_controls_header_files)
develapibloomview_HEADERS = $(devel_api_bloom_view_header_files)
develapibubbleemitter_HEADERS = $(devel_api_bubble_emitter_header_files)
+develapibuttons_HEADERS = $(devel_api_buttons_header_files)
develapibuilder_HEADERS = $(devel_api_builder_header_files)
develapieffectsview_HEADERS = $(devel_api_effects_view_header_files)
develapifocusmanager_HEADERS = $(devel_api_focus_manager_header_files)
ALIASES += DEPRECATED_1_0="@deprecated Deprecated since 1.0"
ALIASES += DEPRECATED_1_1="@deprecated Deprecated since 1.1"
+ALIASES += DEPRECATED_1_2_8="@deprecated Deprecated since 1.2.8"
ALIASES += DEPRECATED_1_2_10="@deprecated Deprecated since 1.2.10"
ALIASES += DEPRECATED_1_2="@deprecated Deprecated since 1.2"
## Thus deprecated APIs in DALi 1.0.xx will be deprecated in Tizen 3.0.
#ALIASES += DEPRECATED_1_0="@deprecated Deprecated since 3.0, DALi version 1.0"
#ALIASES += DEPRECATED_1_1="@deprecated Deprecated since 3.0, DALi version 1.1"
+#ALIASES += DEPRECATED_1_2_8="@deprecated Deprecated since 3.0, DALi version 1.2.8"
#ALIASES += DEPRECATED_1_2_10="@deprecated Deprecated since 3.0, DALi version 1.2.10"
#ALIASES += DEPRECATED_1_2="@deprecated Deprecated since 4.0, DALi version 1.2"
ALIASES += DEPRECATED_1_0="@deprecated Deprecated since 1.0"
ALIASES += DEPRECATED_1_1="@deprecated Deprecated since 1.1"
+ALIASES += DEPRECATED_1_2_8="@deprecated Deprecated since 1.2.8"
ALIASES += DEPRECATED_1_2_10="@deprecated Deprecated since 1.2.10"
ALIASES += DEPRECATED_1_2="@deprecated Deprecated since 1.2"
## Thus deprecated APIs in DALi 1.0.xx will be deprecated in Tizen 3.0.
#ALIASES += DEPRECATED_1_0="@deprecated Deprecated since 3.0, DALi version 1.0"
#ALIASES += DEPRECATED_1_1="@deprecated Deprecated since 3.0, DALi version 1.1"
+#ALIASES += DEPRECATED_1_2_8="@deprecated Deprecated since 3.0, DALi version 1.2.8"
#ALIASES += DEPRECATED_1_2_10="@deprecated Deprecated since 3.0, DALi version 1.2.10"
#ALIASES += DEPRECATED_1_2="@deprecated Deprecated since 4.0, DALi version 1.2"
--- /dev/null
+#ifndef __DALI_TOOLKIT_BUTTON_DEVEL_H__
+#define __DALI_TOOLKIT_BUTTON_DEVEL_H__
+
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/buttons/button.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace DevelButton
+{
+/**
+ *
+ * @section ButtonProperties Properties
+ * |%Property enum |String name |Type |Writable|Animatable|
+ * |-------------------------------------------------------|----------------------------------------|--------------|--------|----------|
+ * | Property::DISABLED | disabled | BOOLEAN | Y | N |
+ * | Property::AUTO_REPEATING | autoRepeating | BOOLEAN | Y | N |
+ * | Property::INITIAL_AUTO_REPEATING_DELAY | initialAutoRepeatingDelay | FLOAT | Y | N |
+ * | Property::NEXT_AUTO_REPEATING_DELAY | nextAutoRepeatingDelay | FLOAT | Y | N |
+ * | Property::TOGGLABLE | togglable | BOOLEAN | Y | N |
+ * | Property::SELECTED | selected | BOOLEAN | Y | N |
+ * | Property::LABEL | label | MAP | Y | N |
+ * | Property::UNSELECTED_STATE_VISUAL | unselectedVisual | MAP | Y | N |
+ * | Property::SELECTED_VISUAL | selectedVisual | MAP | Y | N |
+ * | Property::DISABLED_SELECTED_VISUAL | disabledSelectedVisual | MAP | Y | N |
+ * | Property::DISABLED_UNSELECTED_VISUAL | disabledUnselectedVisual | MAP | Y | N |
+ * | Property::UNSELECTED_BACKGROUND_VISUAL | unselectedBackgroundVisual | MAP | Y | N |
+ * | Property::SELECTED_BACKGROUND_VISUAL | selectedBackgroundVisual | MAP | Y | N |
+ * | Property::DISABLED_UNSELECTED_BACKGROUND_VISUAL | disabledUnselectedBackgroundVisual | MAP | Y | N |
+ * | Property::DISABLED_SELECTED_BACKGROUND_VISUAL | disabledSelectedBackgroundVisual | MAP | Y | N |
+ * | Property::LABEL_RELATIVE_ALIGNMENT | labelRelativeAlignment | STRING | Y | N |
+ * -------------------------------------------------------------------------------------------------------------------------------------
+ *
+ *
+ */
+
+ namespace Property
+ {
+ enum Type
+ {
+ DISABLED = Dali::Toolkit::Button::Property::DISABLED,
+ AUTO_REPEATING = Dali::Toolkit::Button::Property::AUTO_REPEATING,
+ INITIAL_AUTO_REPEATING_DELAY = Dali::Toolkit::Button::Property::INITIAL_AUTO_REPEATING_DELAY,
+ NEXT_AUTO_REPEATING_DELAY = Dali::Toolkit::Button::Property:: NEXT_AUTO_REPEATING_DELAY,
+ TOGGLABLE = Dali::Toolkit::Button::Property::TOGGLABLE,
+ SELECTED = Dali::Toolkit::Button::Property::SELECTED,
+ UNSELECTED_STATE_IMAGE = Dali::Toolkit::Button::Property::UNSELECTED_STATE_IMAGE,
+ SELECTED_STATE_IMAGE = Dali::Toolkit::Button::Property::SELECTED_STATE_IMAGE,
+ DISABLED_STATE_IMAGE = Dali::Toolkit::Button::Property::DISABLED_STATE_IMAGE,
+ UNSELECTED_COLOR = Dali::Toolkit::Button::Property::UNSELECTED_COLOR,
+ SELECTED_COLOR = Dali::Toolkit::Button::Property::SELECTED_COLOR,
+ LABEL = Dali::Toolkit::Button::Property::LABEL,
+ LABEL_TEXT = Dali::Toolkit::Button::Property::LABEL_TEXT,
+
+ /**
+ * @brief name "unselectedVisual", type string if it is a url, map otherwise
+ * @details Sets the unselected button foreground/icon visual
+ */
+ UNSELECTED_VISUAL = LABEL_TEXT + 1,
+
+ /**
+ * @brief name "selectedImage", type string if it is a url, map otherwise
+ * @details Sets the selected button foreground/icon visual
+ * @SINCE_1_2.18
+ */
+ SELECTED_VISUAL,
+
+ /**
+ * @brief name "disabledSelectedVisual", type string if it is a url, map otherwise
+ * @details Sets the disabled selected state foreground/icon button visual
+ */
+ DISABLED_SELECTED_VISUAL,
+
+ /**
+ * @brief name "disabledUnSelectedVisual", type string if it is a url, map otherwise
+ * @details Sets the disabled unselected state foreground/icon visual
+ */
+ DISABLED_UNSELECTED_VISUAL,
+
+ /**
+ * @brief name "unselectedBackgroundVisual", type string if it is a url, map otherwise
+ * @details Sets the disabled in the unselected state background, button visual
+ */
+ UNSELECTED_BACKGROUND_VISUAL,
+
+ /**
+ * @brief name "selectedBackgroundVisual", type string if it is a url, map otherwise
+ * @details Sets the selected background button visual
+ */
+ SELECTED_BACKGROUND_VISUAL,
+
+ /**
+ * @brief name "disabledUnselectedBackgroundVisual", type string if it is a url, map otherwise
+ * @details Sets the disabled while unselected background button visual
+ */
+ DISABLED_UNSELECTED_BACKGROUND_VISUAL,
+
+ /**
+ * @brief name "disabledSelectedBackgroundVisual", type string if it is a url, map otherwise
+ * @details Sets the disabled while selected background button visual
+ */
+ DISABLED_SELECTED_BACKGROUND_VISUAL,
+
+ /**
+ * @brief name "labelRelativeAlignment", type STRING
+ * @details Sets the position of the the label in relation to the foreground/icon if both present
+ */
+ LABEL_RELATIVE_ALIGNMENT,
+
+ /**
+ * @brief name "labelPadding", type Vector4
+ * @details Sets the padding around the text
+ */
+ LABEL_PADDING,
+
+ /**
+ * @brief name "visualPadding", type Vector4
+ * @details Sets the padding around the foreground visual
+ */
+ VISUAL_PADDING
+ };
+ } // namespace Property
+
+} // namespace DevelButton
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_TOOLKIT_BUTTON_DEVEL_H__
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_builder_header_files = \
$(devel_api_src_dir)/builder/builder.h \
$(devel_api_src_dir)/builder/json-parser.h \
GetImplementation( *this ).SetTransformAndSize( transform, controlSize );
}
-float Visual::Base::GetHeightForWidth( float width ) const
+float Visual::Base::GetHeightForWidth( float width )
{
return GetImplementation( *this ).GetHeightForWidth( width );
}
+float Visual::Base::GetWidthForHeight( float height )
+{
+ return GetImplementation( *this ).GetWidthForHeight( height );
+}
+
void Visual::Base::GetNaturalSize(Vector2& naturalSize )
{
GetImplementation( *this ).GetNaturalSize( naturalSize );
GetImplementation( *this ).CreatePropertyMap( map );
}
+
+
+
} // namespace Toolkit
} // namespace Dali
*
* @return The height based on the width.
*/
- float GetHeightForWidth( float width ) const;
+ float GetHeightForWidth( float width );
+
+ /**
+ * @brief Returns the width for a given height.
+ *
+ * @param[in] height Height to use.
+ *
+ * @return The width based on the height.
+ */
+ float GetWidthForHeight( float height );
/**
* @brief Return the natural size of the visual.
* @note Optional.
* @see DevelVisual::Transform::Property
*/
- TRANSFORM = SHADER+1//Dali::Toolkit::Visual::Property::SHADER+1
+ TRANSFORM = SHADER + 1, // Dali::Toolkit::Visual::Property::SHADER + 1
+
+ /**
+ * @brief Enables/disables premultiplied alpha.
+ * The premultiplied alpha is false by default unless this behaviour is modified
+ * by the derived Visual type.
+
+ * @details Name "premultipliedAlpha", type Property::Boolean.
+
+ * @note Optional.
+ */
+ PREMULTIPLIED_ALPHA = SHADER + 2, // Dali::Toolkit::Visual::Property::SHADER + 2
};
} //namespace Property
}
else
{
- DALI_SCRIPT_VERBOSE("SetProperty INVALID '%s' Index=:%d\n", key.c_str(), index);
+ DALI_LOG_ERROR("Key '%s' not found.\n", key.c_str());
}
// Add custom properties
// EXTERNAL INCLUDES
#include <cstring> // for strcmp
+#include <dali/devel-api/scripting/enum-helper.h>
+#include <dali/integration-api/debug.h>
#include <dali/public-api/events/touch-data.h>
#include <dali/public-api/images/resource-image.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/object/type-registry-helper.h>
+#include <dali/public-api/size-negotiation/relayout-container.h>
+#include <dali/devel-api/object/property-helper-devel.h>
#include <dali/devel-api/scripting/scripting.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
#include <dali-toolkit/public-api/controls/image-view/image-view.h>
#include <dali-toolkit/public-api/visuals/color-visual-properties.h>
-#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
+#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
+#include <dali-toolkit/devel-api/align-enums.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/text-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
-
-/**
- * Button states and contents
- * (3) mSelectedContent
- * (2) mUnselectedContent (2) mSelectedBackgroundContent
- * (1) mBackgroundContent (1) mBackgroundContent
- * < unselected > ----------------------- < selected >
- * | OnSelect() |
- * | OnDisabled() | OnDisabled()
- * | |
- * < disabled > < disabled-selected >
- * (2) mDisabledContent (2) mDisabledSelectedContent
- * (1) mDisabledBackgroundContent (1) mDisabledBackgroundContent
- *
- * The drawing order of child actors is as follows.
- *
- * Top mLabel
- * | mUnselectedContent / mSelectedContent / mDisabledContent / mDisabledSelectedContent
- * | mSelectedBackgroundContent
- * Bottom mBackgroundContent / mDisabledBackgroundContent
- *
- * Some of contents may be missed.
- * And 2 images - fade-in image and fade-out image - in the same layer can be shown during the transition animation. Fade-in image should be above fade-out image.
- */
+#if defined(DEBUG_ENABLED)
+ Debug::Filter* gLogButtonFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_BUTTON_CONTROL");
+#endif
namespace Dali
{
}
// Setup properties, signals and actions using the type-registry.
-DALI_TYPE_REGISTRATION_BEGIN( Toolkit::Button, Toolkit::Control, Create );
-
-DALI_PROPERTY_REGISTRATION( Toolkit, Button, "disabled", BOOLEAN, DISABLED )
-DALI_PROPERTY_REGISTRATION( Toolkit, Button, "autoRepeating", BOOLEAN, AUTO_REPEATING )
-DALI_PROPERTY_REGISTRATION( Toolkit, Button, "initialAutoRepeatingDelay", FLOAT, INITIAL_AUTO_REPEATING_DELAY )
-DALI_PROPERTY_REGISTRATION( Toolkit, Button, "nextAutoRepeatingDelay", FLOAT, NEXT_AUTO_REPEATING_DELAY )
-DALI_PROPERTY_REGISTRATION( Toolkit, Button, "togglable", BOOLEAN, TOGGLABLE )
-DALI_PROPERTY_REGISTRATION( Toolkit, Button, "selected", BOOLEAN, SELECTED )
-DALI_PROPERTY_REGISTRATION( Toolkit, Button, "unselectedStateImage", STRING, UNSELECTED_STATE_IMAGE )
-DALI_PROPERTY_REGISTRATION( Toolkit, Button, "selectedStateImage", STRING, SELECTED_STATE_IMAGE )
-DALI_PROPERTY_REGISTRATION( Toolkit, Button, "disabledStateImage", STRING, DISABLED_STATE_IMAGE )
-DALI_PROPERTY_REGISTRATION( Toolkit, Button, "unselectedColor", VECTOR4, UNSELECTED_COLOR )
-DALI_PROPERTY_REGISTRATION( Toolkit, Button, "selectedColor", VECTOR4, SELECTED_COLOR )
-DALI_PROPERTY_REGISTRATION( Toolkit, Button, "label", MAP, LABEL )
-
-// Deprecated properties:
-DALI_PROPERTY_REGISTRATION( Toolkit, Button, "labelText", STRING, LABEL_TEXT )
+DALI_TYPE_REGISTRATION_BEGIN( Toolkit::Button, Toolkit::Control, Create )
+
+DALI_PROPERTY_REGISTRATION( Toolkit, Button, "disabled", BOOLEAN, DISABLED )
+DALI_PROPERTY_REGISTRATION( Toolkit, Button, "autoRepeating", BOOLEAN, AUTO_REPEATING )
+DALI_PROPERTY_REGISTRATION( Toolkit, Button, "initialAutoRepeatingDelay", FLOAT, INITIAL_AUTO_REPEATING_DELAY )
+DALI_PROPERTY_REGISTRATION( Toolkit, Button, "nextAutoRepeatingDelay", FLOAT, NEXT_AUTO_REPEATING_DELAY )
+DALI_PROPERTY_REGISTRATION( Toolkit, Button, "togglable", BOOLEAN, TOGGLABLE )
+DALI_PROPERTY_REGISTRATION( Toolkit, Button, "selected", BOOLEAN, SELECTED )
+DALI_PROPERTY_REGISTRATION( Toolkit, Button, "unselectedStateImage", MAP, UNSELECTED_STATE_IMAGE ) // Deprecated property
+DALI_PROPERTY_REGISTRATION( Toolkit, Button, "selectedStateImage", MAP, SELECTED_STATE_IMAGE ) // Deprecated property
+DALI_PROPERTY_REGISTRATION( Toolkit, Button, "disabledStateImage", MAP, DISABLED_STATE_IMAGE ) // Deprecated property
+DALI_PROPERTY_REGISTRATION( Toolkit, Button, "unselectedColor", VECTOR4, UNSELECTED_COLOR ) // Deprecated property
+DALI_PROPERTY_REGISTRATION( Toolkit, Button, "selectedColor", VECTOR4, SELECTED_COLOR ) // Deprecated property
+DALI_PROPERTY_REGISTRATION( Toolkit, Button, "label", MAP, LABEL )
+DALI_PROPERTY_REGISTRATION( Toolkit, Button, "labelText", STRING, LABEL_TEXT ) // Deprecated property
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, Button, "unselectedVisual", MAP, UNSELECTED_VISUAL )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, Button, "selectedVisual", MAP, SELECTED_VISUAL )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, Button, "disabledSelectedVisual", MAP, DISABLED_SELECTED_VISUAL )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, Button, "disabledUnselectedVisual", MAP, DISABLED_UNSELECTED_VISUAL )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, Button, "unselectedBackgroundVisual", MAP, UNSELECTED_BACKGROUND_VISUAL )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, Button, "selectedBackgroundVisual", MAP, SELECTED_BACKGROUND_VISUAL )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, Button, "disabledUnselectedBackgroundVisual", MAP, DISABLED_UNSELECTED_BACKGROUND_VISUAL )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, Button, "disabledSelectedBackgroundVisual", MAP, DISABLED_SELECTED_BACKGROUND_VISUAL )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, Button, "labelRelativeAlignment", STRING, LABEL_RELATIVE_ALIGNMENT )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, Button, "labelPadding", VECTOR4, LABEL_PADDING )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, Button, "visualPadding", VECTOR4, VISUAL_PADDING )
// Signals:
DALI_SIGNAL_REGISTRATION( Toolkit, Button, "pressed", SIGNAL_PRESSED )
DALI_TYPE_REGISTRATION_END()
-const unsigned int INITIAL_AUTOREPEATING_DELAY( 0.15f );
-const unsigned int NEXT_AUTOREPEATING_DELAY( 0.05f );
+DALI_ENUM_TO_STRING_TABLE_BEGIN( ALIGNMENT )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::Internal::Button, BEGIN )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::Internal::Button, END )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::Internal::Button, TOP )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::Internal::Button, BOTTOM )
+DALI_ENUM_TO_STRING_TABLE_END( ALIGNMENT )
-} // unnamed namespace
-
-Button::Button()
-: Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
- mAutoRepeatingTimer(),
- mUnselectedColor( Color::WHITE ), // The natural colors of the specified images will be used by default.
- mSelectedColor( Color::WHITE ),
- mDisabled( false ),
- mAutoRepeating( false ),
- mTogglableButton( false ),
- mSelected( false ),
- mInitialAutoRepeatingDelay( INITIAL_AUTOREPEATING_DELAY ),
- mNextAutoRepeatingDelay( NEXT_AUTOREPEATING_DELAY ),
- mAnimationTime( 0.0f ),
- mClickActionPerforming( false ),
- mState( ButtonUp ),
- mPaintState( UnselectedState )
+const Scripting::StringEnum ALIGNMENT_STRING_TABLE[] =
{
-}
+ { "BEGIN", Button::BEGIN },
+ { "END", Button::END },
+ { "TOP", Button::TOP },
+ { "BOTTOM", Button::BOTTOM },
+};
-Button::~Button()
-{
-}
+const unsigned int ALIGNMENT_STRING_TABLE_COUNT = sizeof( ALIGNMENT_STRING_TABLE ) / sizeof( ALIGNMENT_STRING_TABLE[0] );
-void Button::SetDisabled( bool disabled )
+const Property::Index GET_VISUAL_INDEX_FOR_STATE[][Button::STATE_COUNT] =
{
- if( disabled == mDisabled )
- {
- return;
- }
+ { Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, Toolkit::DevelButton::Property::UNSELECTED_VISUAL },
+ { Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, Toolkit::DevelButton::Property::SELECTED_VISUAL },
+ { Toolkit::DevelButton::Property::DISABLED_UNSELECTED_BACKGROUND_VISUAL, Toolkit::DevelButton::Property::DISABLED_UNSELECTED_VISUAL },
+ { Toolkit::DevelButton::Property::DISABLED_SELECTED_BACKGROUND_VISUAL, Toolkit::DevelButton::Property::DISABLED_SELECTED_VISUAL }
+};
- StopTransitionAnimation();
-
- mDisabled = disabled;
-
- // Notifies the derived class the button has been disabled.
- OnDisabled();
-
- switch( mPaintState )
+/**
+ * Checks if given map contains a text string
+ */
+bool MapContainsTextString( Property::Map& map )
+{
+ bool result = false;
+ Property::Value* value = map.Find( Toolkit::TextVisual::Property::TEXT );
+ if ( value )
{
- case UnselectedState:
- {
- //Layer Order
- //(3) mDisabledContent (Inserted)
- //(4) mUnselectedContent
- //(2) mDisabledBackgroundContent (Inserted)
- //(1) mBackgroundContent
-
- AddButtonImage( mBackgroundContent );
- TransitionButtonImage( mDisabledBackgroundContent );
- AddButtonImage( mUnselectedContent );
- TransitionButtonImage( mDisabledContent );
-
- AddButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
- ReAddLabel();
-
- TransitionOut( mDecoration[ SELECTED_DECORATION ] );
- TransitionOut( mUnselectedContent );
- TransitionOut( mSelectedContent );
- TransitionOut( mBackgroundContent );
- TransitionOut( mSelectedBackgroundContent );
- TransitionOut( mDisabledSelectedContent );
-
- mPaintState = DisabledUnselectedState;
- break;
- }
- case SelectedState:
- {
- //Layer Order
- //(5) mDisabledSelectedContent (Inserted)
- //(4) mSelectedContent
- //(3) mDisabledBackgroundContent (Inserted)
- //(2) mSelectedBackgroundContent
- //(1) mBackgroundContent
-
- AddButtonImage( mBackgroundContent );
- AddButtonImage( mSelectedBackgroundContent );
- TransitionButtonImage( mDisabledBackgroundContent );
- AddButtonImage( mSelectedContent );
- TransitionButtonImage( mDisabledSelectedContent );
-
- AddButtonImage( mDecoration[ SELECTED_DECORATION ] );
- ReAddLabel();
-
- TransitionOut( mDecoration[ UNSELECTED_DECORATION ] );
- TransitionOut( mUnselectedContent );
- TransitionOut( mSelectedContent );
- TransitionOut( mBackgroundContent );
- TransitionOut( mSelectedBackgroundContent );
- TransitionOut( mDisabledContent );
-
- mPaintState = DisabledSelectedState;
- break;
- }
- case DisabledUnselectedState:
+ std::string textString;
+ value->Get( textString );
+ if ( !textString.empty() )
{
- //Layer Order
- //(3) mUnselectedContent (Inserted)
- //(4) mDisabledContent
- //(2) mBackgroundContent (Inserted)
- //(1) mDisabledBackgroundContent
-
- AddButtonImage( mDisabledBackgroundContent );
- TransitionButtonImage( mBackgroundContent );
- AddButtonImage( mDisabledContent );
- TransitionButtonImage( mUnselectedContent );
-
- AddButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
- ReAddLabel();
-
- TransitionOut( mDecoration[ SELECTED_DECORATION ] );
- TransitionOut( mSelectedContent );
- TransitionOut( mSelectedBackgroundContent );
- TransitionOut( mDisabledContent );
- TransitionOut( mDisabledSelectedContent );
- TransitionOut( mDisabledBackgroundContent );
-
- mPaintState = UnselectedState;
- break;
- }
- case DisabledSelectedState:
- {
- //Layer Order
- //(4) mSelectedContent (Inserted)
- //(5) mDisabledSelectedContent
- //(3) mSelectedBackgroundContent (Inserted)
- //(2) mBackgroundContent (Inserted)
- //(1) mDisabledBackgroundContent
-
- AddButtonImage( mDisabledBackgroundContent );
- TransitionButtonImage( mBackgroundContent );
- TransitionButtonImage( mSelectedBackgroundContent );
- AddButtonImage( mDisabledSelectedContent );
- TransitionButtonImage( mSelectedContent );
-
- AddButtonImage( mDecoration[ SELECTED_DECORATION ] );
- ReAddLabel();
-
- TransitionOut( mDecoration[ UNSELECTED_DECORATION ] );
- TransitionOut( mUnselectedContent );
- TransitionOut( mDisabledContent );
- TransitionOut( mDisabledSelectedContent );
- TransitionOut( mDisabledBackgroundContent );
-
- mPaintState = SelectedState;
- break;
+ result = true;
}
}
+ return result;
+}
+
+} // unnamed namespace
- StartTransitionAnimation();
+Button::Button()
+: Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
+ mAutoRepeatingTimer(),
+ mTextLabelAlignment( END ),
+ mAutoRepeating( false ),
+ mTogglableButton( false ),
+ mTextStringSetFlag( false ),
+ mInitialAutoRepeatingDelay( 0.0f ),
+ mNextAutoRepeatingDelay( 0.0f ),
+ mAnimationTime( 0.0f ),
+ mButtonPressedState( UNPRESSED ),
+ mButtonState( UNSELECTED_STATE ),
+ mPreviousButtonState( mButtonState ),
+ mClickActionPerforming( false )
+{
}
-bool Button::IsDisabled() const
+Button::~Button()
{
- return mDisabled;
}
void Button::SetAutoRepeating( bool autoRepeating )
{
mAutoRepeating = autoRepeating;
- // An autorepeating button can't be a togglable button.
+ // An autorepeating button can't be a toggle button.
if( autoRepeating )
{
- mTogglableButton = false;
-
- if( mSelected )
+ if( IsSelected() )
{
- // Emit a signal is not wanted, only change the appearance.
- SetSelected( false, false );
+ SetSelected( false ); // UnSelect before switching off Toggle feature.
}
+ mTogglableButton = false;
}
}
void Button::SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay )
{
- DALI_ASSERT_ALWAYS( initialAutoRepeatingDelay > 0.f );
+ DALI_ASSERT_DEBUG( initialAutoRepeatingDelay > 0.f );
mInitialAutoRepeatingDelay = initialAutoRepeatingDelay;
}
void Button::SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay )
{
- DALI_ASSERT_ALWAYS( nextAutoRepeatingDelay > 0.f );
+ DALI_ASSERT_DEBUG( nextAutoRepeatingDelay > 0.f );
mNextAutoRepeatingDelay = nextAutoRepeatingDelay;
}
{
mTogglableButton = togglable;
- // A togglable button can't be an autorepeating button.
+ // A toggle button can't be an autorepeating button.
if( togglable )
{
mAutoRepeating = false;
void Button::SetSelected( bool selected )
{
- if( !mDisabled && mTogglableButton && ( selected != mSelected ) )
+ if( mTogglableButton )
{
- SetSelected( selected, true );
+ DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::SetSelected (%s)\n", (selected?"true":"false") );
+
+ if ( selected && ( mButtonState != SELECTED_STATE ) )
+ {
+ ChangeState( SELECTED_STATE );
+ }
+ else if ( !selected && ( mButtonState != UNSELECTED_STATE ) )
+ {
+ ChangeState( UNSELECTED_STATE );
+ }
}
}
-void Button::SetSelected( bool selected, bool emitSignal )
+void Button::SetDisabled( bool disabled )
{
- StopTransitionAnimation();
-
- mSelected = selected;
+ DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::SetDisabled(%s) state(%d)\n", (disabled)?"disabled":"active", mButtonState );
- // Notifies the derived class the button has been selected.
- OnSelected();
-
- switch( mPaintState )
+ if ( disabled )
{
- case UnselectedState:
- {
- //Layer Order
- //(3) mSelectedContent (Inserted)
- //(4) mUnselectedContent
- //(2) mSelectedBackgroundContent (Inserted)
- //(1) mBackgroundContent
-
- AddButtonImage( mBackgroundContent );
- TransitionButtonImage( mSelectedBackgroundContent );
- AddButtonImage( mUnselectedContent );
- TransitionButtonImage( mSelectedContent );
-
- AddButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
- TransitionButtonImage( mDecoration[ SELECTED_DECORATION ] );
- ReAddLabel();
-
- TransitionOut( mDecoration[ UNSELECTED_DECORATION ] );
- TransitionOut( mUnselectedContent );
- TransitionOut( mDisabledContent );
- TransitionOut( mDisabledSelectedContent );
- TransitionOut( mDisabledBackgroundContent );
-
- mPaintState = SelectedState;
- break;
- }
- case SelectedState:
+ if ( mButtonState == SELECTED_STATE )
{
- //Layer Order
- //(3) mUnselectedContent (Inserted)
- //(2) mSelectedContent
- //(1) mBackgroundContent
-
- AddButtonImage( mBackgroundContent );
- AddButtonImage( mSelectedContent );
- TransitionButtonImage( mUnselectedContent );
-
- AddButtonImage( mDecoration[ SELECTED_DECORATION ] );
- TransitionButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
- ReAddLabel();
-
- TransitionOut( mDecoration[ SELECTED_DECORATION ] );
- TransitionOut( mSelectedContent );
- TransitionOut( mSelectedBackgroundContent );
- TransitionOut( mDisabledContent );
- TransitionOut( mDisabledSelectedContent );
- TransitionOut( mDisabledBackgroundContent );
-
- mPaintState = UnselectedState;
- break;
+ ChangeState( DISABLED_SELECTED_STATE );
}
- case DisabledUnselectedState:
- case DisabledSelectedState:
+ else if ( mButtonState == UNSELECTED_STATE )
{
- DALI_ASSERT_DEBUG( 0 && "Shouldn't be able to change paint state if the button is disabled." );
- break;
+ ChangeState( DISABLED_UNSELECTED_STATE );
}
}
-
- StartTransitionAnimation();
-
- if( emitSignal )
+ else
{
- Toolkit::Button handle( GetOwner() );
-
- // Emit signal.
- mStateChangedSignal.Emit( handle );
+ if ( mButtonState == DISABLED_SELECTED_STATE )
+ {
+ ChangeState( SELECTED_STATE );
+ }
+ else if ( mButtonState == DISABLED_UNSELECTED_STATE )
+ {
+ ChangeState( UNSELECTED_STATE );
+ }
}
-
- RelayoutRequest();
-}
-
-bool Button::IsSelected() const
-{
- return mTogglableButton && mSelected;
}
-void Button::SetAnimationTime( float animationTime )
+bool Button::IsDisabled() const
{
- mAnimationTime = animationTime;
+ return ( mButtonState == DISABLED_SELECTED_STATE || mButtonState == DISABLED_UNSELECTED_STATE ) ;
}
-float Button::GetAnimationTime() const
+bool Button::ValidateState( State requestedState )
{
- return mAnimationTime;
-}
+ /* Below tables shows allowed state transitions
+ * Match rows in first column to following columns, if true then transition allowed.
+ * eg UNSELECTED_STATE to DISABLED_UNSELECTED_STATE is true so state transition allowed.
+ *
+ to| UNSELECTED_STATE | SELECTED_STATE | DISABLED_UNSELECTED_STATE | DISABLED_SELECTED_STATE |*/
+ /* from*/
+ bool transitionTable[4][4] = { /* UNSELECTED_STATE*/ { false, true, true, false },
+ /* SELECTED_STATE*/ { true, false, false, true },
+ /* DISABLED_UNSELECTED_STATE*/{ true, true, false, false },
+ /* DISABLED_SELECTED_STATE*/ { false, true, false, false }
+ };
-void Button::SetLabelText( const std::string& label )
-{
- Property::Map labelProperty;
- labelProperty.Insert( "text", label );
- ModifyLabel( labelProperty );
-}
+ DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::ValidateState ReuestedState:%d, CurrentState:%d, result:%s\n",
+ requestedState, mButtonState, (transitionTable[mButtonState][requestedState])?"change-accepted":"change-denied");
-std::string Button::GetLabelText() const
-{
- Toolkit::TextLabel label = Dali::Toolkit::TextLabel::DownCast( mLabel );
- if( label )
- {
- return label.GetProperty<std::string>( Dali::Toolkit::TextLabel::Property::TEXT );
- }
- return std::string();
+ return transitionTable[mButtonState][requestedState];
}
-void Button::ModifyLabel( const Property::Map& properties )
+void Button::PerformFunctionOnVisualsInState( void(Button::*functionPtr)( Property::Index visualIndex), State state )
{
- // If we don't have a label yet, create one.
- if( !mLabel )
- {
- // If we don't have a label, create one and set it up.
- // Note: The label text is set from the passed in property map after creation.
- mLabel = Toolkit::TextLabel::New();
- mLabel.SetPosition( 0.0f, 0.0f );
- // label should be the top of the button
- Self().Add( mLabel );
- }
-
- // Set any properties specified for the label by iterating through all property key-value pairs.
- for( unsigned int i = 0, mapCount = properties.Count(); i < mapCount; ++i )
- {
- const StringValuePair& propertyPair( properties.GetPair( i ) );
-
- // Convert the property string to a property index.
- Property::Index setPropertyIndex = mLabel.GetPropertyIndex( propertyPair.first );
- if( setPropertyIndex != Property::INVALID_INDEX )
- {
- // If the conversion worked, we have a valid property index,
- // Set the property to the new value.
- mLabel.SetProperty( setPropertyIndex, propertyPair.second );
- }
- }
+ DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::PerformFunctionOnVisualsInState BACKROUND visual(%d) for state (%d)\n",
+ GET_VISUAL_INDEX_FOR_STATE[state][BACKGROUND], state );
+ DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::PerformFunctionOnVisualsInState FOREGROUND visuals(%d) for state (%d)\n",
+ GET_VISUAL_INDEX_FOR_STATE[state][FOREGROUND], state );
- // Notify derived button classes of the change.
- OnLabelSet( false );
+ (this->*functionPtr)( GET_VISUAL_INDEX_FOR_STATE[state][BACKGROUND] );
+ (this->*functionPtr)( GET_VISUAL_INDEX_FOR_STATE[state][FOREGROUND] );
RelayoutRequest();
}
-Actor& Button::GetLabelActor()
+void Button::ChangeState( State requestedState )
{
- return mLabel;
-}
+ DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::ChangeState ReuestedState(%d)\n", requestedState );
-void Button::SetDecoration( DecorationState state, Actor actor )
-{
- if( mDecoration[ state ] && mDecoration[ state ].GetParent() )
+ // Validate State before changing
+ if ( !ValidateState( requestedState ))
{
- mDecoration[ state ].Unparent();
+ DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::ChangeState ReuestedState(%d) not validated\n", requestedState );
+ return;
}
- mDecoration[ state ] = actor;
- mDecoration[ state ].SetColorMode( USE_OWN_COLOR );
-
- ResetImageLayers();
- RelayoutRequest();
-}
-
-Actor& Button::GetDecoration( DecorationState state )
-{
- return mDecoration[ state ];
-}
+ // If not on stage the button could have still been set to selected so update state
+ mPreviousButtonState = mButtonState; // Store previous state for visual removal (used when animations ended)
+ mButtonState = requestedState; // Update current state
-void Button::SetupContent( Actor& actorToModify, Actor newActor )
-{
- if( newActor )
+ if ( Self().OnStage() )
{
- StopTransitionAnimation();
-
- if( actorToModify && actorToModify.GetParent() )
- {
- actorToModify.Unparent();
- }
-
- actorToModify = newActor;
-
- if( actorToModify )
- {
- actorToModify.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- actorToModify.SetParentOrigin( ParentOrigin::TOP_LEFT );
- actorToModify.SetPosition( 0.f, 0.f );
- }
-
- ResetImageLayers();
+ OnStateChange( mButtonState ); // Notify derived buttons
+ PerformFunctionOnVisualsInState( &Button::SelectRequiredVisual, mButtonState );
+ // If animation supported then visual removal should be performed after any transition animation has completed.
+ // If Required Visual is not loaded before current visual is removed then a flickering will be evident.
+ PerformFunctionOnVisualsInState( &Button::OnButtonVisualRemoval, mPreviousButtonState ); // Derived button can override OnButtonVisualRemoval
}
-}
-const Vector4 Button::GetUnselectedColor() const
-{
- return mUnselectedColor;
+ Toolkit::Button handle( GetOwner() );
+ // Emit signal.
+ mStateChangedSignal.Emit( handle );
}
-void Button::SetColor( const Vector4& color, Button::PaintState selectedState )
+bool Button::IsSelected() const
{
- Actor* contentActor = NULL; // Using a pointer as SetupContent assigns the new Actor to this.
- bool imageFileExists = false;
- Property::Index visualIndex = Toolkit::Button::Property::SELECTED_STATE_IMAGE;
-
- if ( selectedState == SelectedState || selectedState == DisabledSelectedState )
- {
- mSelectedColor = color;
- contentActor = &mSelectedContent;
- imageFileExists = !GetSelectedImageFilename().empty();
- }
- else
- {
- mUnselectedColor = color;
- contentActor = &mUnselectedContent;
- imageFileExists = !GetUnselectedImageFilename().empty();
- visualIndex = Toolkit::Button::Property::UNSELECTED_STATE_IMAGE;
- }
-
- if ( contentActor )
- {
- if( imageFileExists )
- {
- // If there is existing unselected content, change the color on it directly.
- contentActor->SetColor( color );
- }
- else
- {
- // If there is no existing content, create a new actor to use for flat color.
- Actor placementActor = Actor::New();
- Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
- Toolkit::Visual::Base visual;
-
- Property::Map map;
- map[ Toolkit::DevelVisual::Property::TYPE ] = Toolkit::Visual::COLOR;
- map[ Toolkit::ColorVisual::Property::MIX_COLOR ] = color;
-
- visual = visualFactory.CreateVisual( map );
-
- RegisterVisual( visualIndex, visual );
-
- SetupContent( *contentActor, placementActor ); //
- contentActor->SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
- }
- }
+ bool selected = ( mButtonState == SELECTED_STATE ) || ( mButtonState == DISABLED_SELECTED_STATE );
+ return mTogglableButton && selected;
}
-const Vector4 Button::GetSelectedColor() const
+void Button::SetLabelText( const std::string& label )
{
- return mSelectedColor;
+ Property::Map labelProperty;
+ labelProperty.Add( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT)
+ .Add( Toolkit::TextVisual::Property::TEXT, label );
+
+ Self().SetProperty( Toolkit::Button::Property::LABEL, labelProperty );
}
-void Button::SetUnselectedImage( const std::string& filename )
+std::string Button::GetLabelText() const
{
- Toolkit::ImageView newContent;
- if( !filename.empty() )
- {
- newContent = Toolkit::ImageView::New( filename );
- }
- else
- {
- newContent = Toolkit::ImageView::New();
- }
+ Property::Value value = Self().GetProperty( Toolkit::Button::Property::LABEL );
- if( newContent )
- {
- SetupContent( mUnselectedContent, newContent );
+ Property::Map *labelProperty = value.GetMap();
- mUnselectedContent.SetColor( mUnselectedColor );
+ std::string textLabel;
- OnUnselectedImageSet();
- RelayoutRequest();
+ if ( labelProperty )
+ {
+ Property::Value* value = labelProperty->Find( Toolkit::TextVisual::Property::TEXT );
+ value->Get( textLabel );
}
-}
-Actor& Button::GetUnselectedImage()
-{
- return mUnselectedContent;
+ return textLabel;
}
-void Button::SetSelectedImage( const std::string& filename )
+void Button::MergeLabelProperties( const Property::Map& inMap, Property::Map& outMap )
{
- Toolkit::ImageView newContent;
- if( !filename.empty() )
- {
- newContent = Toolkit::ImageView::New( filename );
- }
- else
- {
- newContent = Toolkit::ImageView::New();
- }
+ DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "MergeLabelProperties with %d properties\n", inMap.Count() );
- if( newContent )
+ /**
+ * Properties for the Label visual could be from a style sheet but after being set the "TEXT" property could be set.
+ * Hence would need to create the Text Visual with the complete merged set of properties.
+ *
+ * 1) Find Label Visual
+ * 2) Retrieve current properties ( settings )
+ * 3) Merge with new properties ( settings )
+ * 4) Return new merged map
+ */
+ Toolkit::Visual::Base visual = GetVisual( Toolkit::Button::Property::LABEL );
+ if ( visual )
{
- SetupContent( mSelectedContent, newContent );
-
- mSelectedContent.SetColor( mSelectedColor );
-
- OnSelectedImageSet();
- RelayoutRequest();
+ DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "MergeLabelProperties Visual already exists, retrieving existing map\n");
+ visual.CreatePropertyMap( outMap );
+ DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "MergeLabelProperties retrieved %d properties\n", outMap.Count() );
}
-}
-
-Actor& Button::GetSelectedImage()
-{
- return mSelectedContent;
-}
-
-void Button::SetBackgroundImage( const std::string& filename )
-{
- SetupContent( mBackgroundContent, Toolkit::ImageView::New( filename ) );
-
- OnBackgroundImageSet();
- RelayoutRequest();
-}
-
-Actor& Button::GetBackgroundImage()
-{
- return mBackgroundContent;
-}
-
-void Button::SetSelectedBackgroundImage( const std::string& filename )
-{
- SetupContent( mSelectedBackgroundContent, Toolkit::ImageView::New( filename ) );
-
- OnSelectedBackgroundImageSet();
- RelayoutRequest();
-}
-Actor& Button::GetSelectedBackgroundImage()
-{
- return mSelectedBackgroundContent;
-}
+ outMap.Merge( inMap );
-void Button::SetDisabledImage( const std::string& filename )
-{
- SetupContent( mDisabledContent, Toolkit::ImageView::New( filename ) );
+ // Store if a text string has been supplied.
- OnDisabledImageSet();
- RelayoutRequest();
-}
+ mTextStringSetFlag = MapContainsTextString( outMap );
-Actor& Button::GetDisabledImage()
-{
- return mDisabledContent;
+ DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "MergeLabelProperties now has %d properties\n", outMap.Count() );
}
-void Button::SetDisabledSelectedImage( const std::string& filename )
+void Button::SetLabelAlignment( Button::Align labelAlignment)
{
- SetupContent( mDisabledSelectedContent, Toolkit::ImageView::New( filename ) );
-
- OnDisabledSelectedImageSet();
+ mTextLabelAlignment = labelAlignment;
RelayoutRequest();
}
-Actor& Button::GetDisabledSelectedImage()
+Button::Align Button::GetLabelAlignment()
{
- return mDisabledSelectedContent;
+ return mTextLabelAlignment;
}
-void Button::SetDisabledBackgroundImage( const std::string& filename )
-{
- SetupContent( mDisabledBackgroundContent, Toolkit::ImageView::New( filename ) );
-
- OnDisabledBackgroundImageSet();
- RelayoutRequest();
-}
+/**
+ * Create Visual for given index from a property map or url.
+ * 1) Check if value passed in is a url and create visual
+ * 2) Create visual from map if step (1) is false
+ * 3) Register visual with control with false for enable flag. Button will later enable visual when needed ( Button::SelectRequiredVisual )
+ * 4) Unregister visual if empty map was provided. This is the method to remove a visual
+ */
-Actor& Button::GetDisabledBackgroundImage()
+void Button::CreateVisualsForComponent( Property::Index index, const Property::Value& value, const float visualDepth )
{
- return mDisabledBackgroundContent;
-}
+ DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "CreateVisualsForComponent index(%d)\n", index );
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base buttonVisual;
-std::string Button::GetUnselectedImageFilename() const
-{
- if( mUnselectedContent )
+ std::string imageUrl;
+ if( value.Get( imageUrl ) )
{
- ResourceImage image = ResourceImage::DownCast( mUnselectedContent );
- if( image )
+ DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "CreateVisualsForComponent Using image URL(%d)\n", index );
+ if ( !imageUrl.empty() )
{
- return image.GetUrl();
+ DALI_ASSERT_DEBUG( index != Toolkit::Button::Property::LABEL && "Creating a Image Visual instead of Text Visual " );
+ buttonVisual = visualFactory.CreateVisual( imageUrl, ImageDimensions() );
}
}
- return std::string();
-}
-
-std::string Button::GetSelectedImageFilename() const
-{
- if( mSelectedContent )
+ else
{
- ResourceImage image = ResourceImage::DownCast( mSelectedContent );
- if( image )
+ // if its not a string then get a Property::Map from the property if possible.
+ Property::Map *map = value.GetMap();
+ if( map && !map->Empty() ) // Empty map results in current visual removal.
{
- return image.GetUrl();
+ DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "CreateVisualsForComponent Using Map(%d)\n", index );
+ buttonVisual = visualFactory.CreateVisual( *map );
}
}
- return std::string();
+
+ if ( buttonVisual )
+ {
+ DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "CreateVisualsForComponent RegisterVisual index(%d) enabled(%s)\n",
+ index, IsVisualEnabled( index )?"true":"false" );
+ buttonVisual.SetDepthIndex( visualDepth );
+ RegisterVisual( index, buttonVisual, IsVisualEnabled( index ) );
+ }
+ else
+ {
+ UnregisterVisual( index );
+ DALI_LOG_INFO( gLogButtonFilter, Debug::General, "CreateVisualsForComponent Visual not created or empty map (clearing visual).(%d)\n", index);
+ }
+ PerformFunctionOnVisualsInState( &Button::SelectRequiredVisual, mButtonState );
}
-std::string Button::GetDisabledImageFilename() const
+bool Button::GetPropertyMapForVisual( Property::Index visualIndex, Property::Map& retreivedMap ) const
{
- if( mDisabledContent )
+ DALI_LOG_INFO( gLogButtonFilter, Debug::General, "GetPropertyMapForVisual visual(%d)\n", visualIndex);
+ bool success = false;
+ Toolkit::Visual::Base visual = GetVisual( visualIndex );
+ if ( visual )
{
- ResourceImage image = ResourceImage::DownCast( mDisabledContent );
- if( image )
- {
- return image.GetUrl();
- }
+ visual.CreatePropertyMap( retreivedMap );
+ success = true;
}
- return std::string();
+ DALI_LOG_INFO( gLogButtonFilter, Debug::General, "GetPropertyMapForVisual %s\n", success?"Success":"Failure");
+ return success;
}
bool Button::DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes )
Toolkit::Button button = Toolkit::Button::DownCast( handle );
- DALI_ASSERT_ALWAYS( button );
+ DALI_ASSERT_DEBUG( button );
if( 0 == strcmp( actionName.c_str(), ACTION_BUTTON_CLICK ) )
{
if( !mClickActionPerforming )
{
mClickActionPerforming = true;
- OnButtonDown();
- mState = ButtonDown;
- OnButtonUp();
+ ButtonDown();
+ if ( !mTogglableButton )
+ {
+ mButtonPressedState = DEPRESSED;
+ }
+ ButtonUp();
mClickActionPerforming = false;
return true;
return false;
}
-void Button::OnButtonDown()
+void Button::ButtonDown()
{
- if( !mTogglableButton )
+ if( mTogglableButton )
+ {
+ if ( mButtonState != SELECTED_STATE )
+ {
+ SetSelected( true );
+ mButtonPressedState = TOGGLE_DEPRESSED;
+ }
+ else
+ {
+ mButtonPressedState = DEPRESSED;
+ }
+ }
+ else
{
Pressed();
-
+ mButtonPressedState = DEPRESSED;
if( mAutoRepeating )
{
- SetUpTimer( mInitialAutoRepeatingDelay );
+ SetUpTimer( mInitialAutoRepeatingDelay );
}
}
mPressedSignal.Emit( handle );
}
-void Button::OnButtonUp()
+void Button::ButtonUp()
{
- if( ButtonDown == mState )
+ bool emitSignalsForPressAndReleaseAction = false;
+
+ if( DEPRESSED == mButtonPressedState )
{
- if( mTogglableButton )
+ if( mTogglableButton ) // Button up will change state
{
- SetSelected( !mSelected );
+ emitSignalsForPressAndReleaseAction = OnToggleReleased(); // Derived toggle buttons can override this to provide custom behaviour
}
else
{
- Released();
-
+ Released(); // Button up will result in unselected state
if( mAutoRepeating )
{
mAutoRepeatingTimer.Reset();
}
+ emitSignalsForPressAndReleaseAction = true;
}
+ }
+ else if ( TOGGLE_DEPRESSED == mButtonPressedState )
+ {
+ emitSignalsForPressAndReleaseAction = true; // toggle released after being pressed, a click
+ }
+ if ( emitSignalsForPressAndReleaseAction )
+ {
// The clicked and released signals should be emitted regardless of toggle mode.
Toolkit::Button handle( GetOwner() );
mReleasedSignal.Emit( handle );
}
}
+bool Button::OnToggleReleased()
+{
+ SetSelected( !IsSelected() );
+ mButtonPressedState = UNPRESSED;
+ return true;
+}
+
+
void Button::OnTouchPointLeave()
{
- if( ButtonDown == mState )
+ if( DEPRESSED == mButtonPressedState )
{
if( !mTogglableButton )
{
}
}
+ mButtonPressedState = UNPRESSED;
+
// The released signal should be emitted regardless of toggle mode.
Toolkit::Button handle( GetOwner() );
mReleasedSignal.Emit( handle );
void Button::OnInitialize()
{
+ DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::OnInitialize\n" );
+
Actor self = Self();
mTapDetector = TapGestureDetector::New();
return OnKeyboardEnter();
}
-bool Button::OnKeyboardEnter()
+bool Button::OnTouch( Actor actor, const TouchData& touch )
{
- // When the enter key is pressed, or button is activated, the click action is performed.
- Property::Map attributes;
- bool ret = DoClickAction( attributes );
-
- return ret;
-}
-void Button::OnStageDisconnection()
-{
- if( ButtonDown == mState )
- {
- if( !mTogglableButton )
- {
- Released();
-
- if( mAutoRepeating )
- {
- mAutoRepeatingTimer.Reset();
- }
- }
- }
-
- mState = ButtonUp;
-
- Control::OnStageDisconnection();
-}
-
-bool Button::OnTouch( Actor actor, const TouchData& touch )
-{
// Only events are processed when the button is not disabled and the touch event has only
// one touch point.
- if( ( !mDisabled ) && ( 1 == touch.GetPointCount() ) )
+
+ if( !IsDisabled() && ( 1 == touch.GetPointCount() ) )
{
switch( touch.GetState( 0 ) )
{
case PointState::DOWN:
{
- OnButtonDown(); // Notification for derived classes.
-
- // Sets the button state to ButtonDown.
- mState = ButtonDown;
+ ButtonDown();
break;
}
case PointState::UP:
{
- OnButtonUp(); // Notification for derived classes.
-
- // Sets the button state to ButtonUp.
- mState = ButtonUp;
+ ButtonUp();
break;
}
case PointState::INTERRUPTED:
{
- OnTouchPointInterrupted(); // Notification for derived classes.
-
- // Sets the button state to the default (ButtonUp).
- mState = ButtonUp;
+ OnTouchPointInterrupted();
break;
}
case PointState::LEAVE:
{
- OnTouchPointLeave(); // Notification for derived classes.
-
- // Sets the button state to the default (ButtonUp).
- mState = ButtonUp;
+ OnTouchPointLeave();
break;
}
case PointState::MOTION:
{
OnTouchPointLeave(); // Notification for derived classes.
- // Sets the button state to the default (ButtonUp).
- mState = ButtonUp;
+ // Sets the button state to the default
+ mButtonPressedState = UNPRESSED;
}
return false;
}
-void Button::OnTap(Actor actor, const TapGesture& tap)
+bool Button::OnKeyboardEnter()
{
- // Do nothing.
-}
+ // When the enter key is pressed, or button is activated, the click action is performed.
+ Property::Map attributes;
+ bool ret = DoClickAction( attributes );
-void Button::SetUpTimer( float delay )
-{
- mAutoRepeatingTimer = Dali::Timer::New( static_cast<unsigned int>( 1000.f * delay ) );
- mAutoRepeatingTimer.TickSignal().Connect( this, &Button::AutoRepeatingSlot );
- mAutoRepeatingTimer.Start();
+ return ret;
}
-bool Button::AutoRepeatingSlot()
+void Button::OnStageDisconnection()
{
- bool consumed = false;
- if( !mDisabled )
+ if( DEPRESSED == mButtonPressedState )
{
- // Restart the autorepeat timer.
- SetUpTimer( mNextAutoRepeatingDelay );
-
- Pressed();
+ if( !mTogglableButton )
+ {
+ Released();
- Toolkit::Button handle( GetOwner() );
+ if( mAutoRepeating )
+ {
+ mAutoRepeatingTimer.Reset();
+ }
+ }
+ }
- //Emit signal.
- consumed = mReleasedSignal.Emit( handle );
- consumed |= mClickedSignal.Emit( handle );
- consumed |= mPressedSignal.Emit( handle );
- }
+ mButtonPressedState = UNPRESSED;
- return consumed;
+ Control::OnStageDisconnection(); // Visuals will be set off stage
}
-void Button::Pressed()
+void Button::OnStageConnection( int depth )
{
- if( mPaintState == UnselectedState )
- {
- StopTransitionAnimation();
-
- // Notifies the derived class the button has been pressed.
- OnPressed();
+ DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::OnStageConnection ptr(%p) \n", this );
+ PerformFunctionOnVisualsInState( &Button::OnButtonVisualRemoval, mPreviousButtonState );
+ SelectRequiredVisual( Toolkit::Button::Property::LABEL );
+ PerformFunctionOnVisualsInState( &Button::SelectRequiredVisual, mButtonState );
+ Control::OnStageConnection( depth ); // Enabled visuals will be put on stage
+}
- //Layer Order
- //(4) mSelectedContent (Inserted)
- //(3) mUnselectedContent
- //(2) mSelectedBackgroundContent (Inserted)
- //(1) mBackgroundContent
+Vector3 Button::GetNaturalSize()
+{
+ Vector3 size = Vector3::ZERO;
- AddButtonImage( mBackgroundContent );
- TransitionButtonImage( mSelectedBackgroundContent );
- AddButtonImage( mUnselectedContent );
- TransitionButtonImage( mSelectedContent );
+ bool horizontalAlignment = mTextLabelAlignment == BEGIN || mTextLabelAlignment == END; // label and visual side by side
- AddButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
- TransitionButtonImage( mDecoration[ SELECTED_DECORATION ] );
- ReAddLabel();
+ // Get natural size of foreground ( largest of the possible visuals )
+ Size largestProvidedVisual;
+ Size labelSize = Size::ZERO;
- TransitionOut( mDecoration[ UNSELECTED_DECORATION ] );
- TransitionOut( mUnselectedContent );
- TransitionOut( mDisabledContent );
- TransitionOut( mDisabledSelectedContent );
- TransitionOut( mDisabledBackgroundContent );
+ bool foreGroundVisualUsed = false;
- mPaintState = SelectedState;
+ for ( int state = Button::UNSELECTED_STATE; state < Button::STATE_COUNT; state++ )
+ {
+ Toolkit::Visual::Base visual = GetVisual( GET_VISUAL_INDEX_FOR_STATE[state][FOREGROUND] );
+ Size visualSize;
+ if ( visual )
+ {
+ visual.GetNaturalSize( visualSize );
+ largestProvidedVisual.width = std::max(largestProvidedVisual.width, visualSize.width );
+ largestProvidedVisual.height = std::max(largestProvidedVisual.height, visualSize.height );
+ foreGroundVisualUsed = true;
+ }
+ }
- StartTransitionAnimation();
+ if ( !foreGroundVisualUsed ) // If foreground visual not supplied then use the background visual to calculate Natural size
+ {
+ for ( int state = Button::UNSELECTED_STATE; state < Button::STATE_COUNT; state++ )
+ {
+ Toolkit::Visual::Base visual = GetVisual( GET_VISUAL_INDEX_FOR_STATE[state][BACKGROUND] );
+ Size visualSize;
+ if ( visual )
+ {
+ visual.GetNaturalSize( visualSize );
+ largestProvidedVisual.width = std::max(largestProvidedVisual.width, visualSize.width );
+ largestProvidedVisual.height = std::max(largestProvidedVisual.height, visualSize.height );
+ }
+ }
}
-}
-void Button::Released()
-{
- if( mPaintState == SelectedState )
+ // Get horizontal padding total
+ if ( largestProvidedVisual.width > 0 ) // if visual exists
{
- StopTransitionAnimation();
+ size.width += largestProvidedVisual.width + mForegroundPadding.left + mForegroundPadding.right;
+ }
+ // Get vertical padding total
+ if ( largestProvidedVisual.height > 0 )
+ {
+ size.height += largestProvidedVisual.height + mForegroundPadding.top + mForegroundPadding.bottom;
+ }
- // Notifies the derived class the button has been released.
- OnReleased();
+ DALI_LOG_INFO( gLogButtonFilter, Debug::General, "GetNaturalSize visual Size(%f,%f)\n",
+ largestProvidedVisual.width, largestProvidedVisual.height );
- //Layer Order
- //(3) mUnselectedContent (Inserted)
- //(2) mSelectedContent
- //(1) mBackgroundContent
+ // Get natural size of label if text has been set
+ if ( mTextStringSetFlag )
+ {
+ Toolkit::Visual::Base visual = GetVisual( Toolkit::Button::Property::LABEL );
- AddButtonImage( mBackgroundContent );
- AddButtonImage( mSelectedContent );
- TransitionButtonImage( mUnselectedContent );
+ if ( visual )
+ {
+ visual.GetNaturalSize( labelSize );
- AddButtonImage( mDecoration[ SELECTED_DECORATION ] );
- TransitionButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
- ReAddLabel();
+ DALI_LOG_INFO( gLogButtonFilter, Debug::General, "GetNaturalSize labelSize(%f,%f) padding(%f,%f)\n",
+ labelSize.width, labelSize.height, mLabelPadding.left + mLabelPadding.right, mLabelPadding.top + mLabelPadding.bottom);
- TransitionOut( mDecoration[ SELECTED_DECORATION ] );
- TransitionOut( mSelectedContent );
- TransitionOut( mSelectedBackgroundContent );
- TransitionOut( mDisabledContent );
- TransitionOut( mDisabledSelectedContent );
- TransitionOut( mDisabledBackgroundContent );
+ labelSize.width += mLabelPadding.left + mLabelPadding.right;
+ labelSize.height += mLabelPadding.top + mLabelPadding.bottom;
- mPaintState = UnselectedState;
+ // Add label size to height or width depending on alignment position
+ if ( horizontalAlignment )
+ {
+ size.width += labelSize.width;
+ size.height = std::max(size.height, labelSize.height );
+ }
+ else
+ {
+ size.height += labelSize.height;
+ size.width = std::max(size.width, labelSize.width );
+ }
+ }
+ }
- StartTransitionAnimation();
+ if( size.width < 1 && size.height < 1 )
+ {
+ // if no image or label then use Control's natural size
+ DALI_LOG_INFO( gLogButtonFilter, Debug::General, "GetNaturalSize Using control natural size\n");
+ size = Control::GetNaturalSize();
}
-}
-Button::ButtonState Button::GetState()
-{
- return mState;
-}
+ DALI_LOG_INFO( gLogButtonFilter, Debug::General, "Button GetNaturalSize (%f,%f)\n", size.width, size.height );
-Button::PaintState Button::GetPaintState()
-{
- return mPaintState;
+ return size;
}
-void Button::PrepareAddButtonImage( Actor& actor )
+void Button::OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
{
- if( actor )
- {
- Self().Add( actor );
- PrepareForTranstionOut( actor );
- }
+ DALI_LOG_INFO( gLogButtonFilter, Debug::General, "OnSetResizePolicy\n");
+ RelayoutRequest();
}
-void Button::TransitionButtonImage( Actor& actor )
+/**
+ * Visuals are sized and positioned in this function.
+ * Whilst the control has it's size negotiated it has to size it's visuals explicitly here.
+ */
+
+void Button::OnRelayout( const Vector2& size, RelayoutContainer& container )
{
- if( actor )
- {
- if( !actor.GetParent() )
- {
- Self().Add( actor );
- }
+ DALI_LOG_INFO( gLogButtonFilter, Debug::General, "OnRelayout targetSize(%f,%f) ptr(%p) state[%d]\n", size.width, size.height, this, mButtonState );
- OnTransitionIn( actor );
- }
-}
+ Toolkit::Visual::Base currentVisual = GetVisual( GET_VISUAL_INDEX_FOR_STATE[mButtonState][FOREGROUND] );
-void Button::AddButtonImage( Actor& actor )
-{
- if( actor )
- {
- Self().Add( actor );
- }
-}
+ Toolkit::Visual::Base currentBackGroundVisual = GetVisual( GET_VISUAL_INDEX_FOR_STATE[mButtonState][BACKGROUND] );
-void Button::ReAddLabel()
-{
- if( mLabel )
+ // Sizes and padding set to zero, if not present then values will no effect calculations.
+ Vector2 visualPosition = Vector2::ZERO;
+ Vector2 labelPosition = Vector2::ZERO;
+ Size visualSize = Size::ZERO;
+ Padding foregroundVisualPadding = Padding(0.0f, 0.0f, 0.0f, 0.0f );
+ Padding labelVisualPadding = Padding(0.0f, 0.0f, 0.0f, 0.0f );
+
+ if ( mTextStringSetFlag )
{
- mLabel.Unparent();
- Self().Add( mLabel );
+ DALI_LOG_INFO( gLogButtonFilter, Debug::General, "OnRelayout Label padding setting padding:%f,%f,%f,%f\n", mLabelPadding.y, mLabelPadding.x, mLabelPadding.width,mLabelPadding.height );
+ labelVisualPadding = mLabelPadding;
}
-}
-void Button::RemoveButtonImage( Actor& actor )
-{
- if( actor )
+ if ( currentVisual )
{
- if( actor.GetParent() )
- {
- Self().Remove( actor );
- }
- PrepareForTranstionIn( actor );
+ DALI_LOG_INFO( gLogButtonFilter, Debug::General, "OnRelayout Foreground Visual setting padding:%f,%f,%f,%f\n", mForegroundPadding.y, mForegroundPadding.x, mForegroundPadding.width,mForegroundPadding.height );
+ currentVisual.GetNaturalSize( visualSize );
+ foregroundVisualPadding = mForegroundPadding;
}
-}
-unsigned int Button::FindChildIndex( Actor& actor )
-{
- Actor self = Self();
- unsigned int childrenNum = self.GetChildCount();
+ Toolkit::Align::Type visualAnchorPoint = Toolkit::Align::TOP_BEGIN;
+
+ Vector2 visualAndPaddingSize = Vector2( ( foregroundVisualPadding.x + visualSize.width + foregroundVisualPadding.y ),
+ ( foregroundVisualPadding.width + visualSize.height + foregroundVisualPadding.height ));
+
+ DALI_LOG_INFO( gLogButtonFilter, Debug::General, "OnRelayout visualAndPaddingSize(%f,%f)\n", visualAndPaddingSize.width, visualAndPaddingSize.height);
+
+ // Text Visual should take all space available after foreground visual size and all padding is considered.
+ // Remaining Space priority, Foreground padding, foreground visual, Text padding then Text visual.
+ Size remainingSpaceForText = Size::ZERO;
- for( unsigned int i = 0; i < childrenNum; i++ )
+ switch ( mTextLabelAlignment )
{
- Actor child = self.GetChildAt( i );
- if( child == actor )
+ case BEGIN :
{
- return i;
- }
- }
+ visualAnchorPoint = Toolkit::Align::TOP_END;
+ visualPosition.x = foregroundVisualPadding.right;
+ visualPosition.y = foregroundVisualPadding.top;
- return childrenNum;
-}
+ labelPosition.x = labelVisualPadding.x;
+ labelPosition.y = labelVisualPadding.top;
-void Button::TransitionOut( Actor actor )
-{
- OnTransitionOut( actor );
-}
+ remainingSpaceForText.width = size.width - visualAndPaddingSize.width - labelVisualPadding.x - labelVisualPadding.y;
+ remainingSpaceForText.height = size.height - labelVisualPadding.top - labelVisualPadding.bottom;
+ break;
+ }
+ case END :
+ {
+ visualAnchorPoint = Toolkit::Align::TOP_BEGIN;
+ visualPosition.x = foregroundVisualPadding.left;
+ visualPosition.y = foregroundVisualPadding.top;
-void Button::ResetImageLayers()
-{
- // Ensure that all layers are in the correct order and state according to the paint state
+ labelPosition.x = visualAndPaddingSize.width + labelVisualPadding.x;
+ labelPosition.y = labelVisualPadding.top;
- switch( mPaintState )
- {
- case UnselectedState:
- {
- //Layer Order
- //(2) mUnselectedContent
- //(1) mBackgroundContent
-
- RemoveButtonImage( mDecoration[ SELECTED_DECORATION ] );
- RemoveButtonImage( mSelectedContent );
- RemoveButtonImage( mSelectedBackgroundContent );
- RemoveButtonImage( mDisabledContent );
- RemoveButtonImage( mDisabledSelectedContent );
- RemoveButtonImage( mDisabledBackgroundContent );
-
- PrepareAddButtonImage( mBackgroundContent );
- PrepareAddButtonImage( mUnselectedContent );
-
- PrepareAddButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
- ReAddLabel();
+ remainingSpaceForText.width = size.width - visualAndPaddingSize.width - labelVisualPadding.x - labelVisualPadding.y;
+ remainingSpaceForText.height = size.height - labelVisualPadding.top - labelVisualPadding.bottom;
break;
}
- case SelectedState:
+ case TOP :
{
- //Layer Order
- //(3) mSelectedContent
- //(2) mSelectedBackgroundContent
- //(1) mBackgroundContent
-
- RemoveButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
- RemoveButtonImage( mUnselectedContent );
- RemoveButtonImage( mDisabledContent );
- RemoveButtonImage( mDisabledSelectedContent );
- RemoveButtonImage( mDisabledBackgroundContent );
-
- PrepareAddButtonImage( mBackgroundContent );
- PrepareAddButtonImage( mSelectedBackgroundContent );
- PrepareAddButtonImage( mSelectedContent );
-
- PrepareAddButtonImage( mDecoration[ SELECTED_DECORATION ] );
- ReAddLabel();
+ visualAnchorPoint = Toolkit::Align::BOTTOM_END;
+ visualPosition.x = foregroundVisualPadding.left;
+ visualPosition.y = foregroundVisualPadding.bottom;
+
+ labelPosition.x = labelVisualPadding.left;
+ labelPosition.y = labelVisualPadding.top;
+
+ remainingSpaceForText.width = size.width - labelVisualPadding.x - labelVisualPadding.y;
+ remainingSpaceForText.height = size.height - visualAndPaddingSize.height - labelVisualPadding.top - labelVisualPadding.bottom;
+
break;
}
- case DisabledUnselectedState:
+ case BOTTOM :
{
- //Layer Order
- //(2) mDisabledContent
- //(1) mDisabledBackgroundContent
-
- RemoveButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
- RemoveButtonImage( mUnselectedContent );
- RemoveButtonImage( mBackgroundContent );
- RemoveButtonImage( mDecoration[ SELECTED_DECORATION ] );
- RemoveButtonImage( mSelectedContent );
- RemoveButtonImage( mDisabledSelectedContent );
- RemoveButtonImage( mSelectedBackgroundContent );
-
- PrepareAddButtonImage( mDisabledBackgroundContent ? mDisabledBackgroundContent : mBackgroundContent );
- PrepareAddButtonImage( mDisabledContent ? mDisabledContent : mUnselectedContent );
-
- PrepareAddButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
- ReAddLabel();
+ visualAnchorPoint = Toolkit::Align::TOP_END;
+ visualPosition.x = foregroundVisualPadding.left;
+ visualPosition.y = foregroundVisualPadding.top;
+
+ labelPosition.x = labelVisualPadding.left;
+ labelPosition.y = visualAndPaddingSize.height + labelVisualPadding.top;
+
+ remainingSpaceForText.width = size.width - labelVisualPadding.x - labelVisualPadding.y;
+ remainingSpaceForText.height = size.height - visualAndPaddingSize.height - labelVisualPadding.top - labelVisualPadding.bottom;
+
break;
}
- case DisabledSelectedState:
+ }
+
+ if ( currentBackGroundVisual )
+ {
+ DALI_LOG_INFO( gLogButtonFilter, Debug::General, "OnRelayout Setting visual background size to(%f,%f)\n", size.width, size.height);
+
+ Property::Map visualTransform;
+
+ visualTransform.Add( Toolkit::DevelVisual::Transform::Property::SIZE, size )
+ .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4( 0.0f, 0.0f, 1.0f, 1.0f) ); // Use relative size
+
+ currentBackGroundVisual.SetTransformAndSize( visualTransform, size );
+ }
+
+ if ( currentVisual )
+ {
+ DALI_LOG_INFO( gLogButtonFilter, Debug::General, "OnRelayout Setting visual size to(%f,%f)\n", visualSize.width, visualSize.height);
+
+ 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::TOP_BEGIN )
+ .Add( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT, visualAnchorPoint );
+
+ currentVisual.SetTransformAndSize( visualTransform, size );
+ }
+
+ if ( mTextStringSetFlag )
+ {
+ Toolkit::Visual::Base textVisual = GetVisual( Toolkit::Button::Property::LABEL ); // No need to search for Label visual if no text set.
+
+ if ( textVisual )
{
- //Layer Order
- // (2) mDisabledSelectedContent
- // (1) mDisabledBackgroundContent
-
- RemoveButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
- RemoveButtonImage( mUnselectedContent );
- RemoveButtonImage( mDecoration[ SELECTED_DECORATION ] );
- RemoveButtonImage( mSelectedContent );
- RemoveButtonImage( mBackgroundContent );
- RemoveButtonImage( mSelectedBackgroundContent );
- RemoveButtonImage( mDisabledContent );
-
- if( mDisabledBackgroundContent )
- {
- PrepareAddButtonImage( mDisabledBackgroundContent );
- }
- else
+ if ( !currentVisual )
{
- PrepareAddButtonImage( mBackgroundContent );
- PrepareAddButtonImage( mSelectedBackgroundContent );
+ DALI_LOG_INFO( gLogButtonFilter, Debug::General, "OnRelayout Only Text\n");
+ labelPosition.x = labelVisualPadding.left;
+ labelPosition.y = labelVisualPadding.height;
}
- PrepareAddButtonImage( mDisabledSelectedContent ? mDisabledSelectedContent : mSelectedContent );
+ Vector2 preSize = Vector2( static_cast< int >( remainingSpaceForText.x ), static_cast< int >( remainingSpaceForText.y ));
- PrepareAddButtonImage( mDecoration[ SELECTED_DECORATION ] );
- ReAddLabel();
- break;
+ DALI_LOG_INFO( gLogButtonFilter, Debug::General, "OnRelayout text Size(%f,%f) text Position(%f,%f) \n", remainingSpaceForText.width, remainingSpaceForText.height, labelPosition.x, labelPosition.y);
+
+ DALI_LOG_INFO( gLogButtonFilter, Debug::General, "OnRelayout text Size -- (%f,%f) text Position(%f,%f) \n", preSize.width, preSize.height, labelPosition.x, labelPosition.y);
+
+
+ Property::Map textVisualTransform;
+ textVisualTransform.Add( Toolkit::DevelVisual::Transform::Property::SIZE, preSize )
+ .Add( Toolkit::DevelVisual::Transform::Property::OFFSET, labelPosition )
+ .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::TOP_BEGIN )
+ .Add( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT, visualAnchorPoint );
+
+ textVisual.SetTransformAndSize( textVisualTransform, size );
}
}
+
+ DALI_LOG_INFO( gLogButtonFilter, Debug::General, "OnRelayout selected (%s) \n", IsSelected()?"yes":"no" );
+
+ DALI_LOG_INFO( gLogButtonFilter, Debug::General, "OnRelayout << \n");
}
-void Button::StartTransitionAnimation()
+void Button::OnTap(Actor actor, const TapGesture& tap)
+{
+ // Prevents Parent getting a tap event
+}
+
+void Button::SetUpTimer( float delay )
{
- if( mTransitionAnimation )
+ mAutoRepeatingTimer = Dali::Timer::New( static_cast<unsigned int>( 1000.f * delay ) );
+ mAutoRepeatingTimer.TickSignal().Connect( this, &Button::AutoRepeatingSlot );
+ mAutoRepeatingTimer.Start();
+}
+
+bool Button::AutoRepeatingSlot()
+{
+ bool consumed = false;
+ if( !IsDisabled() )
{
- mTransitionAnimation.Play();
- }
- else
+ // Restart the autorepeat timer.
+ SetUpTimer( mNextAutoRepeatingDelay );
+
+ Pressed();
+
+ Toolkit::Button handle( GetOwner() );
+
+ //Emit signal.
+ consumed = mReleasedSignal.Emit( handle );
+ consumed = mClickedSignal.Emit( handle );
+ consumed |= mPressedSignal.Emit( handle );
+ }
+
+ return consumed;
+}
+
+void Button::Pressed()
+{
+ DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::Pressed\n" );
+
+ if( mButtonState == UNSELECTED_STATE )
{
- ResetImageLayers();
+ ChangeState( SELECTED_STATE );
+ OnPressed(); // Notifies the derived class the button has been pressed.
}
}
-void Button::StopTransitionAnimation()
+void Button::Released()
{
- if( mTransitionAnimation )
+ DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::Released\n" );
+
+ if( mButtonState == SELECTED_STATE && !mTogglableButton )
{
- mTransitionAnimation.Clear();
- mTransitionAnimation.Reset();
+ ChangeState( UNSELECTED_STATE );
+ OnReleased(); // // Notifies the derived class the button has been released.
}
+ mButtonPressedState = UNPRESSED;
}
-Dali::Animation Button::GetTransitionAnimation()
+void Button::SelectRequiredVisual( Property::Index visualIndex )
{
- if( !mTransitionAnimation )
+ DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::SelectRequiredVisual index(%d) state(%d)\n", visualIndex, mButtonState );
+
+ EnableVisual( visualIndex, true );
+}
+
+void Button::RemoveVisual( Property::Index visualIndex )
+{
+ // Use OnButtonVisualRemoval if want button developer to have the option to override removal.
+ DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::RemoveVisual index(%d) state(%d)\n", visualIndex, mButtonState );
+
+ Toolkit::Visual::Base visual = GetVisual( visualIndex );
+
+ if( visual )
{
- mTransitionAnimation = Dali::Animation::New( GetAnimationTime() );
- mTransitionAnimation.FinishedSignal().Connect( this, &Button::TransitionAnimationFinished );
+ EnableVisual( visualIndex, false );
}
-
- return mTransitionAnimation;
}
-void Button::TransitionAnimationFinished( Dali::Animation& source )
+void Button::OnButtonVisualRemoval( Property::Index visualIndex )
{
- StopTransitionAnimation();
- ResetImageLayers();
+ // Derived Buttons can over ride this to prevent default removal.
+ DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::OnButtonVisualRemoval index(%d)\n", visualIndex );
+ RemoveVisual( visualIndex );
}
void Button::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
{
Toolkit::Button button = Toolkit::Button::DownCast( Dali::BaseHandle( object ) );
+ DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::SetProperty index[%d]\n", index );
+
if ( button )
{
switch ( index )
break;
}
- case Toolkit::Button::Property::UNSELECTED_STATE_IMAGE:
+ case Toolkit::Button::Property::UNSELECTED_STATE_IMAGE: // Legacy Tizen 3.0
{
- GetImplementation( button ).SetUnselectedImage( value.Get< std::string >() );
+ GetImplementation( button ).CreateVisualsForComponent( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, value, DepthIndex::BACKGROUND );
break;
}
-
- case Toolkit::Button::Property::SELECTED_STATE_IMAGE:
+ case Toolkit::Button::Property::DISABLED_STATE_IMAGE: // Legacy Tizen 3.0
+ {
+ GetImplementation( button ).CreateVisualsForComponent( Toolkit::DevelButton::Property::DISABLED_UNSELECTED_BACKGROUND_VISUAL, value, DepthIndex::BACKGROUND );
+ break;
+ }
+ case Toolkit::Button::Property::SELECTED_STATE_IMAGE: // Legacy Tizen 3.0
{
- GetImplementation( button ).SetSelectedImage( value.Get< std::string >() );
+ GetImplementation( button ).CreateVisualsForComponent( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, value, DepthIndex::BACKGROUND );
+ break;
+ }
+ case Toolkit::DevelButton::Property::UNSELECTED_VISUAL:
+ case Toolkit::DevelButton::Property::SELECTED_VISUAL:
+ case Toolkit::DevelButton::Property::DISABLED_SELECTED_VISUAL:
+ case Toolkit::DevelButton::Property::DISABLED_UNSELECTED_VISUAL:
+ {
+ GetImplementation( button ).CreateVisualsForComponent( index, value, DepthIndex::CONTENT );
break;
}
- case Toolkit::Button::Property::DISABLED_STATE_IMAGE:
+ case Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL:
+ case Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL:
+ case Toolkit::DevelButton::Property::DISABLED_SELECTED_BACKGROUND_VISUAL:
+ case Toolkit::DevelButton::Property::DISABLED_UNSELECTED_BACKGROUND_VISUAL:
{
- GetImplementation( button ).SetDisabledImage( value.Get< std::string >() );
+ GetImplementation( button ).CreateVisualsForComponent( index , value, DepthIndex::BACKGROUND);
break;
}
case Toolkit::Button::Property::UNSELECTED_COLOR:
{
- GetImplementation( button ).SetColor( value.Get< Vector4 >(), UnselectedState );
+ DALI_LOG_WARNING("[%s] Using deprecated Property Button::Property::UNSELECTED_COLOR instead use Button::Property::UNSELECTED_BACKGROUND_VISUAL\n", __FUNCTION__);
+ GetImplementation( button ).SetColor( value.Get< Vector4 >(), Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL );
break;
}
case Toolkit::Button::Property::SELECTED_COLOR:
{
- GetImplementation( button ).SetColor( value.Get< Vector4 >(), SelectedState );
+ DALI_LOG_WARNING("[%s] Using deprecated Property Button::Property::SELECTED_COLOR instead use Button::Property::SELECTED_BACKGROUND_VISUAL\n", __FUNCTION__);
+ GetImplementation( button ).SetColor( value.Get< Vector4 >(), Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL );
break;
}
case Toolkit::Button::Property::LABEL_TEXT:
{
- GetImplementation( button ).SetLabelText( value.Get< std::string >() );
+ DALI_LOG_WARNING("[%s] Using deprecated Property Button::Property::LABEL_TEXT instead use Button::Property::LABEL\n", __FUNCTION__);
+ GetImplementation( button ).SetLabelText(value.Get< std::string >() );
break;
}
case Toolkit::Button::Property::LABEL:
{
// Get a Property::Map from the property if possible.
- Property::Map setPropertyMap;
- if( value.Get( setPropertyMap ) )
+ Property::Map* setPropertyMap = value.GetMap();
+ if( setPropertyMap )
{
- GetImplementation( button ).ModifyLabel( setPropertyMap );
+ Property::Map textVisualProperties;
+ GetImplementation( button ).MergeLabelProperties( *setPropertyMap, textVisualProperties );
+ GetImplementation( button ).CreateVisualsForComponent( index, textVisualProperties, DepthIndex::CONTENT );
+ GetImplementation( button ).RelayoutRequest();
}
+ break;
+ }
+
+ case Toolkit::DevelButton::Property::LABEL_RELATIVE_ALIGNMENT:
+ {
+ Button::Align labelAlignment(END);
+ Scripting::GetEnumeration< Button::Align> ( value.Get< std::string >().c_str(),
+ ALIGNMENT_TABLE, ALIGNMENT_TABLE_COUNT,
+ labelAlignment );
+
+ GetImplementation( button ).SetLabelAlignment( labelAlignment );
+ GetImplementation( button ).RelayoutRequest();
+ break;
+ }
+
+ case Toolkit::DevelButton::Property::LABEL_PADDING:
+ {
+ Vector4 padding ( value.Get< Vector4 >() );
+ GetImplementation( button ).SetLabelPadding( Padding( padding.x, padding.y, padding.z, padding.w ) );
+ break;
+ }
+
+ case Toolkit::DevelButton::Property::VISUAL_PADDING:
+ {
+ Vector4 padding ( value.Get< Vector4 >() );
+ GetImplementation( button ).SetForegroundPadding( Padding( padding.x, padding.y, padding.z, padding.w ) );
+ GetImplementation( button ).RelayoutRequest();
+ break;
}
- break;
}
}
}
{
case Toolkit::Button::Property::DISABLED:
{
- value = GetImplementation( button ).mDisabled;
+ value = GetImplementation( button ).IsDisabled();
break;
}
case Toolkit::Button::Property::SELECTED:
{
- value = GetImplementation( button ).mSelected;
+ value = GetImplementation( button ).IsSelected();
break;
}
case Toolkit::Button::Property::UNSELECTED_STATE_IMAGE:
{
- value = GetImplementation( button ).GetUnselectedImageFilename();
+ value = GetImplementation( button ).GetUrlForImageVisual( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL );
break;
}
case Toolkit::Button::Property::SELECTED_STATE_IMAGE:
{
- value = GetImplementation( button ).GetSelectedImageFilename();
+ value = GetImplementation( button ).GetUrlForImageVisual( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL );
break;
}
case Toolkit::Button::Property::DISABLED_STATE_IMAGE:
{
- value = GetImplementation( button ).GetDisabledImageFilename();
+ value = GetImplementation( button ).GetUrlForImageVisual( Toolkit::DevelButton::Property::DISABLED_UNSELECTED_BACKGROUND_VISUAL );
+ break;
+ }
+
+ case Toolkit::DevelButton::Property::UNSELECTED_VISUAL:
+ case Toolkit::DevelButton::Property::SELECTED_VISUAL:
+ case Toolkit::DevelButton::Property::DISABLED_SELECTED_VISUAL:
+ case Toolkit::DevelButton::Property::DISABLED_UNSELECTED_VISUAL:
+ case Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL:
+ case Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL:
+ case Toolkit::DevelButton::Property::DISABLED_SELECTED_BACKGROUND_VISUAL:
+ case Toolkit::DevelButton::Property::DISABLED_UNSELECTED_BACKGROUND_VISUAL:
+ case Toolkit::Button::Property::LABEL:
+ {
+ Property::Map visualProperty;
+ if ( GetImplementation( button ).GetPropertyMapForVisual( propertyIndex, visualProperty ) )
+ {
+ value = visualProperty;
+ }
break;
}
break;
}
- case Toolkit::Button::Property::LABEL:
+ case Toolkit::DevelButton::Property::LABEL_RELATIVE_ALIGNMENT:
{
- Property::Map emptyMap;
- value = emptyMap;
+ const char* alignment = Scripting::GetEnumerationName< Button::Align >( GetImplementation( button ).GetLabelAlignment(),
+ ALIGNMENT_STRING_TABLE,
+ ALIGNMENT_STRING_TABLE_COUNT );
+ if( alignment )
+ {
+ value = std::string( alignment );
+ }
+
break;
}
+
+ case Toolkit::DevelButton::Property::LABEL_PADDING:
+ {
+ Padding padding = GetImplementation( button ).GetLabelPadding();
+ value = Vector4( padding.x, padding.y, padding.top, padding.bottom);
+ break;
+ }
+
+ case Toolkit::DevelButton::Property::VISUAL_PADDING:
+ {
+ Padding padding = GetImplementation( button ).GetForegroundPadding();
+ value = Vector4( padding.x, padding.y, padding.top, padding.bottom);
+ }
}
}
return value;
}
-// Deprecated API
+void Button::SetLabelPadding( const Padding& padding)
+{
+ DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::SetLabelPadding padding(%f,%f,%f,%f)\n", padding.left, padding.right, padding.bottom, padding.top );
+ mLabelPadding = Padding( padding.left, padding.right, padding.bottom, padding.top );
+ RelayoutRequest();
+}
-void Button::SetLabel( Actor label )
+Padding Button::GetLabelPadding()
{
- if( mLabel != label )
- {
- if( mLabel && mLabel.GetParent() )
- {
- mLabel.GetParent().Remove( mLabel );
- }
+ return mLabelPadding;
+}
- mLabel = label;
- mLabel.SetPosition( 0.0f, 0.0f );
+void Button::SetForegroundPadding( const Padding& padding)
+{
+ DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::SetForegroundPadding padding(%f,%f,%f,%f)\n", padding.left, padding.right, padding.bottom, padding.top );
+ mForegroundPadding = Padding( padding.left, padding.right, padding.bottom, padding.top );
+ RelayoutRequest();
+}
- // label should be the top of the button
- Self().Add( mLabel );
+Padding Button::GetForegroundPadding()
+{
+ return mForegroundPadding;
+}
- ResetImageLayers();
- OnLabelSet( true );
+////////////////////////////////////////////////////////////////////////
+// Legacy functions from Tizen 2.4 and 3.0
- RelayoutRequest();
+// Legacy code needed whilst Color can be set by direct Property setting ( deprecated ) instead of setting a Visual
+void Button::SetColor( const Vector4& color, Property::Index visualIndex )
+{
+ if ( visualIndex == Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL )
+ {
+ mSelectedColor = color;
}
+ else
+ {
+ mUnselectedColor = color;
+ }
+
+ Property::Map map;
+ map[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::COLOR;
+ map[ Toolkit::ColorVisual::Property::MIX_COLOR ] = color;
+
+ CreateVisualsForComponent( visualIndex, map, DepthIndex::BACKGROUND );
}
-void Button::SetButtonImage( Actor image )
+const Vector4 Button::GetUnselectedColor() const
{
- if( image )
- {
- StopTransitionAnimation();
+ return mUnselectedColor;
+}
- SetupContent( mUnselectedContent, image );
+const Vector4 Button::GetSelectedColor() const
+{
+ return mSelectedColor;
+}
- OnUnselectedImageSet();
- RelayoutRequest();
- }
+void Button::SetAnimationTime( float animationTime )
+{
+ // Used by deprecated API
+ mAnimationTime = animationTime;
}
-void Button::SetSelectedImage( Actor image )
+float Button::GetAnimationTime() const
{
- if( image )
- {
- StopTransitionAnimation();
+ // Used by deprecated API
+ return mAnimationTime;
+}
- SetupContent( mSelectedContent, image );
+void Button::SetLabel( Actor label )
+{
+ if ( label )
+ {
+ Property::Value value ="";
+ value = label.GetProperty(Toolkit::TextLabel::Property::TEXT);
- OnSelectedImageSet();
- RelayoutRequest();
+ SetLabelText( value.Get<std::string>() );
}
}
-void Button::SetBackgroundImage( Actor image )
+void Button::SetUnselectedImage( const std::string& filename )
{
- if( image )
+ SetBackgroundImage( filename );
+}
+
+void Button::SetBackgroundImage( const std::string& filename )
+{
+ if( !filename.empty() )
+ {
+ CreateVisualsForComponent( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, filename, DepthIndex::BACKGROUND );
+ }
+ else
{
- StopTransitionAnimation();
+ UnregisterVisual( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL );
+ }
+}
- SetupContent( mBackgroundContent, image );
+void Button::SetSelectedImage( const std::string& filename )
+{
+ SetSelectedBackgroundImage( filename );
+}
- OnBackgroundImageSet();
- RelayoutRequest();
+void Button::SetSelectedBackgroundImage( const std::string& filename )
+{
+ if( !filename.empty() )
+ {
+ CreateVisualsForComponent( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, filename, DepthIndex::BACKGROUND );
+ }
+ else
+ {
+ UnregisterVisual( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL );
}
}
-void Button::SetSelectedBackgroundImage( Actor image )
+void Button::SetDisabledBackgroundImage( const std::string& filename )
{
- if( image )
+ if( !filename.empty() )
{
- StopTransitionAnimation();
-
- SetupContent( mSelectedBackgroundContent, image );
-
- OnSelectedBackgroundImageSet();
- RelayoutRequest();
+ CreateVisualsForComponent( Toolkit::DevelButton::Property::DISABLED_UNSELECTED_BACKGROUND_VISUAL, filename, DepthIndex::BACKGROUND );
}
}
-void Button::SetDisabledImage( Actor image )
+void Button::SetDisabledImage( const std::string& filename )
{
- if( image )
+ if( !filename.empty() )
{
- StopTransitionAnimation();
-
- SetupContent( mDisabledContent, image );
-
- OnDisabledImageSet();
- RelayoutRequest();
+ CreateVisualsForComponent( Toolkit::DevelButton::Property::DISABLED_UNSELECTED_VISUAL, filename, DepthIndex::CONTENT );
}
}
-void Button::SetDisabledSelectedImage( Actor image )
+void Button::SetDisabledSelectedImage( const std::string& filename )
{
- if( image )
+ if( !filename.empty() )
{
- StopTransitionAnimation();
+ CreateVisualsForComponent( Toolkit::DevelButton::Property::DISABLED_SELECTED_VISUAL, filename, DepthIndex::CONTENT );
+ }
+}
- SetupContent( mDisabledSelectedContent, image );
+// Used by Deprecated Properties which don't use the Visual Property maps for setting and getting
+std::string Button::GetUrlForImageVisual( const Property::Index index ) const
+{
+ Toolkit::Visual::Base visual = GetVisual( index );
+ std::string result;
- OnDisabledSelectedImageSet();
- RelayoutRequest();
+ if ( visual )
+ {
+ Dali::Property::Map retreivedMap;
+ visual.CreatePropertyMap( retreivedMap );
+ Property::Value* value = retreivedMap.Find( Toolkit::ImageVisual::Property::URL, Property::STRING );
+ if ( value )
+ {
+ result = value->Get<std::string>();
+ }
}
+
+ return result;
}
-void Button::SetDisabledBackgroundImage( Actor image )
+// Below functions DEPRECATED_1_0.50 - Return empty Actors
+
+namespace
{
- if( image )
- {
- StopTransitionAnimation();
+std::string GetUrlFromImage( Image& image )
+{
+ ResourceImage resourceImage = ResourceImage::DownCast( image );
- SetupContent( mDisabledBackgroundContent, image );
+ std::string imageUrl;
- OnDisabledBackgroundImageSet();
- RelayoutRequest();
+ if ( resourceImage )
+ {
+ imageUrl = resourceImage.GetUrl();
}
+ return imageUrl;
+}
+
+} // namespace
+
+
+void Button::SetButtonImage( Image image )
+{
+ DALI_LOG_WARNING("Button::SetButtonImage @DEPRECATED_1_0.50\n");
+ SetUnselectedImage( GetUrlFromImage( image ) );
+}
+
+void Button::SetSelectedImage( Image image )
+{
+ DALI_LOG_WARNING("Button::SetSelectedImage @DEPRECATED_1_0.50\n");
+ SetSelectedImage( GetUrlFromImage( image ) );
}
Actor Button::GetButtonImage() const
{
- return mUnselectedContent;
+ DALI_LOG_WARNING("Button::GetButtonImage @DEPRECATED_1_0.50\n");
+ Actor imageView = Toolkit::ImageView::New( GetUrlForImageVisual( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL ) );
+
+ return imageView;
}
Actor Button::GetSelectedImage() const
{
- return mSelectedContent;
-}
+ DALI_LOG_WARNING("Button::GetSelectedImage @DEPRECATED_1_0.50\n");
+ Actor imageView = Toolkit::ImageView::New( GetUrlForImageVisual( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL ) );
+ return imageView;
+}
} // namespace Internal
-#ifndef __DALI_TOOLKIT_INTERNAL_BUTTON_H__
-#define __DALI_TOOLKIT_INTERNAL_BUTTON_H__
+#ifndef DALI_TOOLKIT_INTERNAL_BUTTON_H
+#define DALI_TOOLKIT_INTERNAL_BUTTON_H
/*
* Copyright (c) 2014 Samsung Electronics Co., Ltd.
#include <dali/public-api/animation/animation.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/buttons/button.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-base.h>
+#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
#include <dali-toolkit/public-api/controls/control-impl.h>
namespace Dali
{
/**
+ * @copydoc Toolkit::Button
+ *
* Button is the base class implementation for all buttons.
+ *
+ * @note
+ *
+ * All Foreground/Icon visuals expected to be the same size.
+ * Background visuals will take the size of the control.
+ * Padding and struts take size precedence over visuals when available space is limited.
+ * Icon/Foreground visuals take size precedence over Labels when available space is limited.
*/
class Button : public Control
{
public:
/**
+ * Enum describing the position the text label can be in relation to the control (and foreground/icon)
+ */
+ enum Align
+ {
+ BEGIN, // At the start of the control before the foreground/icon
+ END, // At the end of the control after the foreground/icon
+ TOP, // At the top of the control above the foreground/icon
+ BOTTOM // At the bottom of the control below the foreground/icon
+ };
+
+public:
+
+ /**
* @copydoc Dali::Toolkit::Button::SetDisabled
*/
void SetDisabled( bool disabled );
std::string GetLabelText() const;
/**
- * @copydoc Dali::Toolkit::PushButton::SetUnselectedImage
- */
- void SetUnselectedImage( const std::string& filename );
-
- /**
- * @copydoc Dali::Toolkit::PushButton::SetSelectedImage
- */
- void SetSelectedImage( const std::string& filename );
-
- /**
- * @copydoc Dali::Toolkit::PushButton::SetBackgroundImage
- */
- void SetBackgroundImage( const std::string& filename );
-
- /**
- * @copydoc Dali::Toolkit::PushButton::SetSelectedBackgroundImage
- */
- void SetSelectedBackgroundImage( const std::string& filename );
-
- /**
- * @copydoc Dali::Toolkit::PushButton::SetDisabledImage
- */
- void SetDisabledImage( const std::string& filename );
-
- /**
- * @copydoc Dali::Toolkit::CheckBoxButton::SetDisabledSelectedImage
- */
- void SetDisabledSelectedImage( const std::string& filename );
-
- /**
- * @copydoc Dali::Toolkit::PushButton::SetDisabledBackgroundImage
- */
- void SetDisabledBackgroundImage( const std::string& filename );
-
- /**
- * @return The filename used for the button image.
- */
- std::string GetUnselectedImageFilename() const;
-
- /**
- * @return The filename used for the selected image.
- */
- std::string GetSelectedImageFilename() const;
-
- /**
- * @return The filename used for the background image.
- */
- std::string GetBackgroundImageFilename() const;
-
- /**
- * @return The filename used for the selected background image.
- */
- std::string GetSelectedBackgroundImageFilename() const;
-
- /**
- * @return The filename used for the disabled button image.
- */
- std::string GetDisabledImageFilename() const;
-
- /**
- * @return The filename used for the disabled selected image.
- */
- std::string GetDisabledSelectedImageFilename() const;
-
- /**
- * @return The filename used for the disabled background image.
- */
- std::string GetDisabledBackgroundImageFilename() const;
-
- /**
- * @brief Sets the specified properties on the button label.
+ * @brief Produces a Property::Map of Text properties to create a Text Visual
* If the label does not exist yet, it is created.
* The derived buttons are notified if any properties are changed.
* @param[in] properties A Property::Map of key-value pairs of properties to set.
+ * @param[out] properties A Property::Map of text visual properties to set.
*/
- void ModifyLabel( const Property::Map& properties );
+ void MergeLabelProperties( const Property::Map& inMap, Property::Map& outMap );
/**
* Performs actions as requested using the action name.
void SetLabel( Actor label );
/**
- * @deprecated Sets the unselected image with an Actor.
+ * @deprecated Sets the unselected image with an url.
* @param[in] image The Actor to use.
*/
- void SetButtonImage( Actor image );
+ void SetUnselectedImage( const std::string& filename );
/**
- * @deprecated Sets the selected image with an Actor.
- * @param[in] image The Actor to use.
+ * @deprecated Sets the selected image with an url.
+ * @param[in] filename The url of the image to use to use.
*/
- void SetSelectedImage( Actor image );
+ void SetSelectedImage( const std::string& filename );
/**
- * @deprecated Sets the background image with an Actor.
- * @param[in] image The Actor to use.
+ * @deprecated Sets the selected background image with an url.
+ * @param[in] filename The url of the image to use to use.
*/
- void SetBackgroundImage( Actor image );
+ void SetSelectedBackgroundImage( const std::string& filename );
/**
- * @deprecated Sets the selected background image with an Actor.
- * @param[in] image The Actor to use.
+ * @deprecated Sets the background image with an url.
+ * @param[in] filename The url of the image to use to use.
*/
- void SetSelectedBackgroundImage( Actor image );
+ void SetBackgroundImage( const std::string& filename );
/**
- * @deprecated Sets the disabled image with an Actor.
- * @param[in] image The Actor to use.
+ * @deprecated Sets the disabled unselected background image with an url.
+ * @param[in] filename The url of the image to use to use.
*/
- void SetDisabledImage( Actor image );
+ void SetDisabledBackgroundImage( const std::string& filename );
/**
- * @deprecated Sets the disabled selected image with an Actor.
- * @param[in] image The Actor to use.
+ * @deprecated Sets the disabled unselected image with an url.
+ * @param[in] filename The url of the image to use to use.
*/
- void SetDisabledSelectedImage( Actor image );
+ void SetDisabledImage( const std::string& filename );
/**
- * @deprecated Sets the disabled background image with an Actor.
- * @param[in] image The Actor to use.
+ * @deprecated Sets the disabled selected image with an url.
+ * @param[in] filename The url of the image to use to use.
*/
- void SetDisabledBackgroundImage( Actor image );
+ void SetDisabledSelectedImage( const std::string& filename );
+
+ /**
+ * @deprecated Sets the unselected image with an Actor.
+ * @param[in] image The Image to use.
+ */
+ void SetButtonImage( Image image );
+
+ /**
+ * @deprecated Sets the selected image with an Actor.
+ * @param[in] image The Image to use.
+ */
+ void SetSelectedImage( Image image );
+
+ /**
+ * @Gets url of a image visual, used by GetProperty but for deprecated Properties
+ * @param[in] index Visual index of url required
+ * @return filename for the corresponding visual
+ */
+ std::string GetUrlForImageVisual( const Property::Index index ) const;
/**
* @copydoc Dali::Toolkit::Button::GetButtonImage
*/
Actor GetSelectedImage() const;
-protected:
+public:
+
+ /**
+ * Button's state
+ */
+ enum State
+ {
+ UNSELECTED_STATE, ///< The button is unselected.
+ SELECTED_STATE, ///< The button is selected.
+ DISABLED_UNSELECTED_STATE, ///< The button is disabled and unselected.
+ DISABLED_SELECTED_STATE, ///< The button is disabled and selected.
+ STATE_COUNT, ///< Number of States
+ };
- enum ButtonState
+ /**
+ * Enum to distinguish the different style-able components of the button
+ */
+ enum Visuals
{
- ButtonUp, ///< The button is up.
- ButtonDown, ///< The button is down.
+ UNSELECTED_FOREGROUND = 0,
+ SELECTED_FOREGROUND,
+ DISABLED_SELECTED_FOREGROUND,
+ DISABLED_UNSELECTED_FOREGROUND,
+ UNSELECTED_BACKGROUND,
+ SELECTED_BACKGROUND,
+ DISABLED_UNSELECTED_BACKGROUND,
+ DISABLED_SELECTED_BACKGROUND,
+ VISUALS_COUNT
};
/**
- * Button paint states.
+ * Enum to list types of visual a state can have.
*/
- enum PaintState
+ enum VisualState
{
- UnselectedState, ///< The button is unselected.
- SelectedState, ///< The button is selected.
- DisabledUnselectedState, ///< The button is disabled and unselected.
- DisabledSelectedState, ///< The button is disabled and selected.
+ BACKGROUND = 0,
+ FOREGROUND,
+ VISUAL_STATE_COUNT
};
+protected:
+
/**
- * Enum to specify which decoration when getting and setting decorations.
+ * Button press state which is not the same as the actual button's state.
+ * For example An UNSELECTED button can be DEPRESSED, but until released, the actual button state doesn't change to SELECTED
*/
- enum DecorationState
+ enum PressState
{
- UNSELECTED_DECORATION = 0,
- SELECTED_DECORATION,
- DECORATION_STATES
+ DEPRESSED, ///< The button is up.
+ UNPRESSED, ///< The button is down.
+ TOGGLE_DEPRESSED, ///< The button has been pressed down and will stay depressed when released.
};
/**
/**
* @return A reference to the unselected button image.
*/
- Actor& GetUnselectedImage();
+ Actor GetUnselectedImage();
/**
* @return A reference to the selected image.
*/
- Actor& GetSelectedImage();
-
- /**
- * @return A reference to the background image.
- */
- Actor& GetBackgroundImage();
-
- /**
- * @return A reference to the selected background image.
- */
- Actor& GetSelectedBackgroundImage();
-
- /**
- * @return A reference to the disabled button image.
- */
- Actor& GetDisabledImage();
-
- /**
- * @return A reference to the disabled selected image.
- */
- Actor& GetDisabledSelectedImage();
-
- /**
- * @return A reference to the disabled background image.
- */
- Actor& GetDisabledBackgroundImage();
+ Actor GetSelectedImage();
private:
bool DoClickAction( const Property::Map& attributes );
/**
- * This method is called when the label is set.
- * @param[in] noPadding Used to bypass padding if the label is to be treated generically.
- */
- virtual void OnLabelSet( bool noPadding ) {}
-
- /**
- * This method is called when the unselected button image is set
- */
- virtual void OnUnselectedImageSet() {}
-
- /**
- * This method is called when the selected image is set
- */
- virtual void OnSelectedImageSet() {}
-
- /**
- * This method is called when the background image is set
- */
- virtual void OnBackgroundImageSet() {}
-
- /**
- * This method is called when the selected background image is set
- */
- virtual void OnSelectedBackgroundImageSet() {}
-
- /**
- * This method is called when the disabled button image is set
- */
- virtual void OnDisabledImageSet() {}
-
- /**
- * This method is called when the disabled selected image is set
- */
- virtual void OnDisabledSelectedImageSet() {}
-
- /**
- * This method is called when the disabled background image is set
- */
- virtual void OnDisabledBackgroundImageSet() {}
-
- /**
- * This method is called the button is down.
- * Could be reimplemented in subclasses to provide specific behaviour.
- */
- virtual void OnButtonDown();
-
- /**
- * This method is called when the button is up.
+ * This method is called when the button is a Toggle button and released
* Could be reimplemented in subclasses to provide specific behaviour.
+ * @return bool returns true if state changed.
*/
- virtual void OnButtonUp();
+ virtual bool OnToggleReleased();
/**
* This method is called when touch leaves the boundary of the button or several touch points are received.
/**
* This method is called when the \e selected property is changed.
*/
- virtual void OnSelected() {}
+ virtual void OnStateChange( State newState ){}
/**
* This method is called when the \e disabled property is changed.
* @copydoc Toolkit::Control::OnStageDisconnection()
* @note If overridden by deriving button classes, then an up-call to Button::OnStageDisconnection MUST be made at the end.
*/
- void OnStageDisconnection();
+ virtual void OnStageDisconnection();
+ /**
+ * @copydoc Toolkit::Control::OnStageConnnection()
+ */
+ virtual void OnStageConnection( int depth );
+
+ /**
+ * @copydoc Toolkit::Control::GetNaturalSize
+ */
+ virtual Vector3 GetNaturalSize();
+
+ /**
+ * @copydoc Toolkit::Control::OnSetResizePolicy
+ */
+ virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension );
+
+ /**
+ * @copydoc Toolkit::Control::OnRelayout
+ */
+ virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
private:
void SetUpTimer( float delay );
/**
- * Slot called when Dali::Timer::SignalTick signal. Resets the autorepeating timer.
+ * Button has been pressed
*/
- bool AutoRepeatingSlot();
+ void Pressed();
/**
- * Sets the button as selected or unselected.
- * @param[in] selected \e selected property value.
- * @param[in] emitSignal Emit a signal if this value is \e true.
+ * This method is called the button is down.
*/
- void SetSelected( bool selected, bool emitSignal );
+ void ButtonDown();
/**
- * This method is called when the button is pressed.
+ * This method is called when the button is up.
*/
- void Pressed();
+ void ButtonUp();
/**
- * This method is called when the button is released.
+ * Slot called when Dali::Timer::SignalTick signal. Resets the autorepeating timer.
*/
- void Released();
+ bool AutoRepeatingSlot();
/**
- * Used to perform common setup applied to images within button.
- * This will replace the current image with the specifed one.
- * @param[in] actorToModify The image to replace.
- * @param[out] newActor The new image to use.
+ * Check the requested state is an allowed transition.
+ * Some states can not be transitioned to from certain states.
+ * @param[in] requestedState check if can transition to this state
+ * @return bool true if state change valid
*/
- void SetupContent( Actor& actorToModify, Actor newActor );
+ bool ValidateState( State requestedState );
/**
- * Gets the unselected content color.
- * @return The currently used unselected color.
+ * Perform the given function on the visuals in the given state. Can be used to add and remove visuals.
+ * @param[in] functionPtr pointer to the function to perform an action on a visual
+ * @param[in] state Visuals in this state will be the target
*/
- const Vector4 GetUnselectedColor() const;
+ void PerformFunctionOnVisualsInState( void(Button::*functionPtr)( Property::Index visualIndex), State state );
/**
- * Sets the color of button in selected or unselected state, if image also supplied this color will be appplied to it.
- * If no visual exists, it is created.
- * @param[in] color The color to use.
- * @param[in] selectedState The state to apply the color to, SelectedState or DisabledUnselectedState.
+ * Changes the button state when an action occurs on it
+ * @param[in] requestedState the state to change to
*/
- void SetColor( const Vector4& color, PaintState selectedState );
+ void ChangeState( State requestedState );
/**
- * Gets the selected content color.
- * @return The currently used selected color.
+ * @brief Get unselected button color
+ * @return color as vector4
*/
- const Vector4 GetSelectedColor() const;
-
-protected:
-
- ButtonState GetState();
- PaintState GetPaintState();
- void SetDecoration( DecorationState state, Actor actor );
- Actor& GetDecoration( DecorationState state );
-
+ const Vector4 GetUnselectedColor() const;
/**
- * Returns the animation to be used for transitioning creating the animation if needed.
- * @return The initialised transition animation.
+ * @brief Get selected button color
+ * @return color as vector4
*/
- Dali::Animation GetTransitionAnimation();
+ const Vector4 GetSelectedColor() const;
/**
- * Prepares the actor to be transitioned in.
- * @param[in] actor The actor that will be transitioned in.
+ * Sets the color of button in selected or unselected state, if image also supplied this color will be appplied to it.
+ * If no visual exists, it is created.
+ * @param[in] color The color to use.
+ * @param[in] visualIndex The Visual to apply the color
*/
- virtual void PrepareForTranstionIn( Actor actor ) {}
+ void SetColor( const Vector4& color, Property::Index visualIndex );
/**
- * Prepares the actor to be transitioned in.
- * @param[in] actor The actor that will be transitioned out.
+ * This method is called when the button is released.
*/
- virtual void PrepareForTranstionOut( Actor actor ) {}
+ void Released();
- /**
- * Transitions the actor in, allowing derived classes to configure
- * the GetTransitionAnimation() animation ready.
- * Button is in charge of calling Dali::Animation::Play and so derived classes
- * only need to add the animation.
- */
- virtual void OnTransitionIn( Actor actor ) {}
+protected:
/**
- * Transitions the actor out, allowing derived classes to configure
- * the GetTransitionAnimation() animation ready.
- * Button is in charge of calling Dali::Animation::Play and so derived classes
- * only need to add the animation.
+ * Set Text Label Padding
+ * @param[in] padding BEGIN END BOTTOM TOP
*/
- virtual void OnTransitionOut( Actor actor ) {}
-
-private:
+ void SetLabelPadding( const Padding& padding );
/**
- * Starts the transition animation.
- * Button::TransitionFinished is called when the animation finishes.
+ * Get Text Label padding
+ * @return Padding
*/
- void StartTransitionAnimation();
+ Padding GetLabelPadding();
/**
- * This method stops all transition animations
+ * Set Foreground/icon Padding
+ * @param[in] padding BEGIN END BOTTOM TOP
*/
- void StopTransitionAnimation();
+ void SetForegroundPadding( const Padding& padding);
/**
- * Called when the transition animation finishes.
+ * Get Foreground padding
+ * @ return Padding
*/
- void TransitionAnimationFinished( Dali::Animation& source );
+ Padding GetForegroundPadding();
/**
- * Resets the Button to the base state for the current paint state.
- * Any additionally inserted images needed for transitions that are
- * no longer needed and the removed.
+ * @brief Setup the button components for example foregrounds and background
+ * @param[in] index the index of the visual to set
+ * @param[in] value the value to set on the component
+ * @param[in] visualDepth the depth of the visual if overlapping another
*/
- void ResetImageLayers();
+ void CreateVisualsForComponent( Property::Index index ,const Property::Value& value, const float visualDepth );
/**
- * Transitions out the actor
+ * @brief Get the Property map for the given Visual
+ * @param[in] visualIndex visual index of the required visual
+ * @param[out] retreivedMap the property map used to construct the required visual
+ * @return bool success flag, true if visual found
*/
- void TransitionOut( Actor actor );
-
+ bool GetPropertyMapForVisual( Property::Index visualIndex, Property::Map& retreivedMap ) const;
/**
- * Removes the actor from the button and prepares it to be transitioned out
+ * Returns the animation to be used for transition, creating the animation if needed.
+ * @return The initialised transition animation.
*/
- void RemoveButtonImage( Actor& actor );
+ Dali::Animation GetTransitionAnimation();
/**
- * Finds the index of the actor.
- * If the actor doesn't exist, return the last index + 1.
+ * @brief Set the position of the label relative to foreground/icon, if both present
+ * @param[in] labelAlignment given alignment setting
*/
- unsigned int FindChildIndex( Actor& actor );
+ void SetLabelAlignment( Align labelAlignment);
/**
- * Adds an actor to the hierarchy and prepares it to be transitioned.
- * @param[in] actor The actor to add
+ * @brief Get set alignment of label in relation to foreground/icon
+ * @return Set alignment value
*/
- void PrepareAddButtonImage( Actor& actor );
+ Align GetLabelAlignment();
/**
- * Adds an actor to the hierarchy and marks it to be transitioned.
- * @param[in] actor The actor to add
+ * Removes the visual from the button (un-staged)
+ * If the derived button does not want the visual removed then use this virtual function to
+ * define the required behaviour.
+ * Can decide to only remove specified visuals via index
*/
- void TransitionButtonImage( Actor& actor );
+ virtual void OnButtonVisualRemoval( Property::Index visualIndex );
+
+
+private:
/**
- * Adds an actor to the hierarchy.
- * @param[in] actor The actor to add
+ * Removes the visual from the button and prepares it to be transitioned out
+ * @param[in] visualIndex the visual to remove
*/
- void AddButtonImage( Actor& actor );
+ void RemoveVisual( Property::Index visualIndex );
/**
- * (Re)Adds the label (if exists) to the hierarchy (so it is always on top).
+ * Adds the required visual to the button.
+ * @param[in] visualIndex The Property index of the visual required
*/
- void ReAddLabel();
+ void SelectRequiredVisual( Property::Index visualIndex );
// Undefined
Button( const Button& );
Toolkit::Button::ButtonSignalType mClickedSignal; ///< Signal emitted when the button is clicked.
Toolkit::Button::ButtonSignalType mStateChangedSignal; ///< Signal emitted when the button's state is changed.
- Timer mAutoRepeatingTimer; ///< Timer used to implement the autorepeating property.
+ Timer mAutoRepeatingTimer;
- Actor mLabel; ///< Stores the button label.
+ Actor mLabel; ///< Stores the button text label.
+ Padding mLabelPadding; ///< The padding around the label (if present).
+ Padding mForegroundPadding; ///< The padding around the foreground/icon visual (if present).
- Actor mDecoration[ DECORATION_STATES ]; ///< Stores the decorations for both selected and unselected states.
+ Align mTextLabelAlignment; ///< Position of text label in relation to foreground/icon when both are present.
- Actor mUnselectedContent; ///< Stores the unselected content.
- Actor mSelectedContent; ///< Stores the selected content.
- Actor mBackgroundContent; ///< Stores the background content.
- Actor mSelectedBackgroundContent; ///< Stores the selected background content.
- Actor mDisabledContent; ///< Stores the disabled content.
- Actor mDisabledSelectedContent; ///< Stores the disabled selected content.
- Actor mDisabledBackgroundContent; ///< Stores the disabled background content.
+ TapGestureDetector mTapDetector;
- Animation mTransitionAnimation; ///< Animation used in the state transitions.
+ Vector4 mUnselectedColor;
+ Vector4 mSelectedColor;
- TapGestureDetector mTapDetector;
+ bool mAutoRepeating; ///< Stores the autorepeating property.
+ bool mTogglableButton; ///< Stores the togglable property as a flag.
+ bool mTextStringSetFlag; ///< Stores if text has been set. Required in relayout but don't want to calculate there.
- Vector4 mUnselectedColor; ///< Color to use for unselected content.
- Vector4 mSelectedColor; ///< Color to use for selected content.
+ float mInitialAutoRepeatingDelay; ///< Stores the initial autorepeating delay in seconds.
+ float mNextAutoRepeatingDelay; ///< Stores the next autorepeating delay in seconds.
- bool mDisabled; ///< Stores the disabled property.
- bool mAutoRepeating; ///< Stores the autorepeating property.
- bool mTogglableButton; ///< Stores the togglable property.
- bool mSelected; ///< Stores the selected state.
- float mInitialAutoRepeatingDelay; ///< Stores the initial autorepeating delay in seconds.
- float mNextAutoRepeatingDelay; ///< Stores the next autorepeating delay in seconds.
+ float mAnimationTime;
- float mAnimationTime; ///< The animation time.
+ PressState mButtonPressedState; ///< In relation to the button being pressed/released
+ State mButtonState;
+ State mPreviousButtonState; ///< During a transition between two states, this stores the previous state so Visuals can be removed.
// Actions
- bool mClickActionPerforming;
-
- ButtonState mState; ///< Stores the button state.
- PaintState mPaintState; ///< Stores the paint state.
+ bool mClickActionPerforming; ///< Used to manage signal emissions during action
};
} // namespace Internal
} // namespace Dali
-#endif // __DALI_TOOLKIT_INTERNAL_BUTTON_H__
+#endif // DALI_TOOLKIT_INTERNAL_BUTTON_H
#include "check-box-button-impl.h"
// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/images/resource-image.h>
#include <dali-toolkit/devel-api/shader-effects/image-region-effect.h>
#include <dali-toolkit/devel-api/shader-effects/image-region-effect.h>
+#if defined(DEBUG_ENABLED)
+ extern Debug::Filter* gLogButtonFilter;
+#endif
+
namespace Dali
{
namespace
{
-const float DISTANCE_BETWEEN_IMAGE_AND_LABEL( 5.0f );
-const float ANIMATION_TIME( 0.26f ); // EFL checkbox tick time
-
BaseHandle Create()
{
return Toolkit::CheckBoxButton::New();
TypeRegistration mType( typeid(Toolkit::CheckBoxButton), typeid(Toolkit::Button), Create );
-const char* const UNSELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "checkbox-unselected.png";
-const char* const SELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "checkbox-selected.png";
-const char* const DISABLED_UNSELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "checkbox-unselected-disabled.png";
-const char* const DISABLED_SELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "checkbox-selected-diabled.png";
+
+
}
Dali::Toolkit::CheckBoxButton CheckBoxButton::New()
: Button()
{
SetTogglableButton( true );
-
- SetAnimationTime( ANIMATION_TIME );
}
CheckBoxButton::~CheckBoxButton()
{
}
-void CheckBoxButton::SetTickUVEffect()
-{
- Toolkit::ImageView imageView = Toolkit::ImageView::DownCast( mSelectedImage );
- if( imageView )
- {
- imageView.RegisterProperty( "uTextureRect", Vector4(0.f, 0.f, 1.f, 1.f ) );
- imageView.RegisterProperty( "uTopLeft", Vector2::ZERO );
-
- Property::Map shaderMap = CreateImageRegionEffect();
- imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, shaderMap );
-
- GetImpl( imageView ).SetDepthIndex( DepthIndex::DECORATION );
- }
-}
-
void CheckBoxButton::OnInitialize()
{
Button::OnInitialize();
-
- // Wrap around all children
- Self().SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
-
- SetUnselectedImage( UNSELECTED_BUTTON_IMAGE_DIR );
- SetSelectedImage( SELECTED_BUTTON_IMAGE_DIR );
- SetDisabledImage( DISABLED_UNSELECTED_BUTTON_IMAGE_DIR );
- SetDisabledSelectedImage( DISABLED_SELECTED_BUTTON_IMAGE_DIR );
-
- mSelectedImage = GetSelectedImage();
- SetTickUVEffect();
}
-void CheckBoxButton::OnLabelSet( bool noPadding )
-{
- Actor& label = GetLabelActor();
-
- if( label )
- {
- label.SetParentOrigin( ParentOrigin::CENTER_LEFT );
- label.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
-
- if( IsDisabled() && GetDisabledBackgroundImage() )
- {
- label.SetX( GetDisabledBackgroundImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
- }
- else if ( GetBackgroundImage() )
- {
- label.SetX( GetBackgroundImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
- }
- else if( IsSelected() && GetSelectedImage())
- {
- label.SetX( GetSelectedImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
- }
- else if( GetUnselectedImage() )
- {
- label.SetX( GetUnselectedImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
- }
- else
- {
- label.SetX( DISTANCE_BETWEEN_IMAGE_AND_LABEL );
- }
- }
-}
-
-void CheckBoxButton::OnDisabled()
-{
- Actor& backgroundImage = GetBackgroundImage();
- Actor& disabledBackgroundImage = GetDisabledBackgroundImage();
-
- Actor& label = GetLabelActor();
- if( label )
- {
- if( IsDisabled() && disabledBackgroundImage )
- {
- label.SetX( disabledBackgroundImage.GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
- }
- else if( backgroundImage )
- {
- label.SetX( backgroundImage.GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
- }
- else if( IsSelected() && GetSelectedImage())
- {
- label.SetX( GetSelectedImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
- }
- else if( GetUnselectedImage() )
- {
- label.SetX( GetUnselectedImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
- }
- else
- {
- label.SetX( DISTANCE_BETWEEN_IMAGE_AND_LABEL );
- }
- }
-}
-
-void CheckBoxButton::PrepareForTranstionIn( Actor actor )
-{
- Actor& selectedImage = GetSelectedImage();
- if( actor == selectedImage )
- {
- actor.SetScale( Vector3( 0.0f, 1.0f, 1.0f ) );
- actor.RegisterProperty( "uBottomRight", Vector2( 0.0f, 1.0f ) );
-
- if( mSelectedImage != selectedImage )
- {
- mSelectedImage = selectedImage;
- SetTickUVEffect();
- }
- }
-}
-
-void CheckBoxButton::PrepareForTranstionOut( Actor actor )
-{
- Actor& selectedImage = GetSelectedImage();
- if( actor == selectedImage )
- {
- actor.SetScale( Vector3::ONE );
- actor.RegisterProperty( "uBottomRight", Vector2::ONE );
-
- if( mSelectedImage != selectedImage )
- {
- mSelectedImage = selectedImage;
- SetTickUVEffect();
- }
- }
-}
-
-void CheckBoxButton::OnTransitionIn( Actor actor )
-{
- Actor& selectedImage = GetSelectedImage();
- if( actor && actor == selectedImage )
- {
- if( GetPaintState() == UnselectedState )
- {
- Dali::Animation transitionAnimation = GetTransitionAnimation();
- if( transitionAnimation )
- {
- // UV anim
- transitionAnimation.AnimateTo( Property( actor, "uBottomRight" ), Vector2::ONE );
-
- // Actor size anim
- transitionAnimation.AnimateTo( Property( actor, Actor::Property::SCALE_X ), 1.0f );
- }
- }
- else
- {
- //explicitly end the swipe animation
- actor.SetScale( Vector3::ONE );
- if( mSelectedImage == selectedImage )
- {
- actor.RegisterProperty( "uBottomRight", Vector2::ONE );
- }
- }
- }
-}
} // namespace Internal
*/
virtual ~CheckBoxButton();
- /**
- * Setup the ticking effect to the selected image.
- */
- void SetTickUVEffect();
-
private: // From Button
*/
virtual void OnInitialize();
- /**
- * @copydoc Toolkit::Internal::Button::OnLabelSet
- */
- virtual void OnLabelSet( bool noPadding );
-
- /**
- * @copydoc Toolkit::Internal::Button::OnDisabled
- */
- virtual void OnDisabled();
-
- /**
- * @copydoc Toolkit::Internal::Button::PrepareForTranstionIn( Actor actor )
- */
- virtual void PrepareForTranstionIn( Actor actor );
-
- /**
- * @copydoc Toolkit::Internal::Button::PrepareForTranstionOut( Actor actor )
- */
- virtual void PrepareForTranstionOut( Actor actor );
-
- /**
- * @copydoc Toolkit::Internal::Button::OnTransitionInImage( Actor actor )
- */
- virtual void OnTransitionIn( Actor actor );
-
private:
// Undefined
// Undefined
CheckBoxButton& operator=( const CheckBoxButton& );
-private:
- Actor mSelectedImage;
};
} // namespace Internal
#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/integration-api/debug.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/image-view/image-view.h>
#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
+#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
+#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
+
+#if defined(DEBUG_ENABLED)
+ extern Debug::Filter* gLogButtonFilter;
+#endif
namespace Dali
{
namespace
{
-const float ANIMATION_TIME( 0.2f );
-const Padding DEFAULT_LABEL_PADDING( 12.0f, 12.0f, 12.0f, 12.0f );
-const Padding DEFAULT_ICON_PADDING( 12.0f, 12.0f, 12.0f, 12.0f );
-
BaseHandle Create()
{
return Toolkit::PushButton::New();
{ "BOTTOM", Toolkit::Internal::PushButton::BOTTOM },
}; const unsigned int IconAlignmentTableCount = sizeof( IconAlignmentTable ) / sizeof( IconAlignmentTable[0] );
-const char* const UNSELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "button-up.9.png";
-const char* const SELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "button-down.9.png";
-const char* const DISABLED_UNSELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "button-disabled.9.png";
-const char* const DISABLED_SELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "button-down-disabled.9.png";
-
} // unnamed namespace
namespace
{
-/**
- * Get size of Actor if larger than given size
- * @param[in] root the actor to get the size of
- * @param[out] size the greater of the given size or the size of the Actor
- */
-void SizeOfActorIfLarger( Actor root, Vector3& size )
-{
- if ( root )
- {
- // RelayoutSize retreived for Actor to use any padding set to it.
- size.width = std::max( root.GetRelayoutSize( Dimension::WIDTH ), size.width );
- size.height = std::max( root.GetRelayoutSize( Dimension::HEIGHT ), size.height );
- }
-}
-
} // unnamed namespace
Dali::Toolkit::PushButton PushButton::New()
PushButton::PushButton()
: Button(),
- mLabelPadding( DEFAULT_LABEL_PADDING ),
- mIconPadding( DEFAULT_ICON_PADDING ),
- mIconAlignment( RIGHT ),
- mSize()
+ mIconAlignment( RIGHT )
{
- SetAnimationTime( ANIMATION_TIME );
}
PushButton::~PushButton()
// Push button requires the Leave event.
Actor self = Self();
self.SetLeaveRequired( true );
-
- // Set resize policy to natural size so that buttons will resize to background images
- self.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
-
- SetUnselectedImage( UNSELECTED_BUTTON_IMAGE_DIR );
- SetSelectedImage( SELECTED_BUTTON_IMAGE_DIR );
- SetDisabledImage( DISABLED_UNSELECTED_BUTTON_IMAGE_DIR );
- SetDisabledSelectedImage( DISABLED_SELECTED_BUTTON_IMAGE_DIR );
-}
-
-void PushButton::SetIcon( DecorationState state, const std::string iconFilename )
-{
- mIconName[ state ] = iconFilename;
- SetDecoration( state, Toolkit::ImageView::New( iconFilename ) );
- ConfigureSizeNegotiation();
-}
-
-std::string& PushButton::GetIcon( DecorationState state )
-{
- return mIconName[ state ];
}
void PushButton::SetIconAlignment( const PushButton::IconAlignment iconAlignment )
{
mIconAlignment = iconAlignment;
- ConfigureSizeNegotiation();
+ Button::Align labelAlignment;
+ switch ( iconAlignment )
+ {
+ case RIGHT:
+ {
+ labelAlignment = Button::BEGIN;
+ break;
+ }
+ case TOP:
+ {
+ labelAlignment = Button::BOTTOM;
+ break;
+ }
+ case BOTTOM:
+ {
+ labelAlignment = Button::TOP;
+ break;
+ }
+ case LEFT:
+ default:
+ labelAlignment = Button::END;
+ break;
+ }
+
+ Button::SetLabelAlignment( labelAlignment );
}
const PushButton::IconAlignment PushButton::GetIconAlignment() const
return mIconAlignment;
}
-void PushButton::SetLabelPadding( const Vector4& padding )
-{
- mLabelPadding = Padding( padding.x, padding.y, padding.z, padding.w );
- ConfigureSizeNegotiation();
-}
-
-Vector4 PushButton::GetLabelPadding()
-{
- return Vector4( mLabelPadding.left, mLabelPadding.right, mLabelPadding.top, mLabelPadding.bottom );
-}
-
-void PushButton::SetIconPadding( const Vector4& padding )
-{
- mIconPadding = Padding( padding.x, padding.y, padding.z, padding.w );
- ConfigureSizeNegotiation();
-}
-
-Vector4 PushButton::GetIconPadding()
-{
- return Vector4( mIconPadding.left, mIconPadding.right, mIconPadding.top, mIconPadding.bottom );
-}
-
void PushButton::SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value )
{
Toolkit::PushButton pushButton = Toolkit::PushButton::DownCast( Dali::BaseHandle( object ) );
{
PushButton& pushButtonImpl( GetImplementation( pushButton ) );
+ // Properties remain here for Tizen 3.0 legacy requirements. Are now in Button base class
+
switch ( propertyIndex )
{
case Toolkit::PushButton::Property::UNSELECTED_ICON:
{
- pushButtonImpl.SetIcon( UNSELECTED_DECORATION, value.Get< std::string >() );
+ pushButtonImpl.CreateVisualsForComponent( Toolkit::DevelButton::Property::UNSELECTED_VISUAL, value, DepthIndex::CONTENT );
break;
}
case Toolkit::PushButton::Property::SELECTED_ICON:
{
- pushButtonImpl.SetIcon( SELECTED_DECORATION, value.Get< std::string >() );
+ pushButtonImpl.CreateVisualsForComponent( Toolkit::DevelButton::Property::SELECTED_VISUAL, value, DepthIndex::CONTENT );
break;
}
case Toolkit::PushButton::Property::ICON_ALIGNMENT:
}
case Toolkit::PushButton::Property::LABEL_PADDING:
{
- pushButtonImpl.SetLabelPadding( value.Get< Vector4 >() );
+ Vector4 padding ( value.Get< Vector4 >() );
+ pushButtonImpl.Button::SetLabelPadding( Padding( padding.x, padding.y, padding.z, padding.w ) );
break;
}
case Toolkit::PushButton::Property::ICON_PADDING:
{
- pushButtonImpl.SetIconPadding( value.Get< Vector4 >() );
+ Vector4 padding ( value.Get< Vector4 >() );
+ pushButtonImpl.Button::SetForegroundPadding( Padding( padding.x, padding.y, padding.z, padding.w ) );
break;
}
}
{
case Toolkit::PushButton::Property::UNSELECTED_ICON:
{
- value = pushButtonImpl.GetIcon( UNSELECTED_DECORATION );
+ //value = pushButtonImpl.GetIcon( UNSELECTED_DECORATION );
break;
}
case Toolkit::PushButton::Property::SELECTED_ICON:
{
- value = pushButtonImpl.GetIcon( UNSELECTED_DECORATION );
+ //value = pushButtonImpl.GetIcon( UNSELECTED_DECORATION );
break;
}
case Toolkit::PushButton::Property::ICON_ALIGNMENT:
}
case Toolkit::PushButton::Property::LABEL_PADDING:
{
- value = pushButtonImpl.GetLabelPadding();
+ Padding padding = pushButtonImpl.Button::GetLabelPadding();
+ value = Vector4( padding.x, padding.y, padding.top, padding.bottom);
break;
}
case Toolkit::PushButton::Property::ICON_PADDING:
{
- value = pushButtonImpl.GetIconPadding();
+ Padding padding = pushButtonImpl.Button::GetForegroundPadding();
+ value = Vector4( padding.x, padding.y, padding.top, padding.bottom);
break;
}
}
return value;
}
-void PushButton::OnLabelSet( bool noPadding )
-{
- Actor& label = GetLabelActor();
-
- if( label )
- {
- if( noPadding )
- {
- mLabelPadding = Padding( 0.0f, 0.0f, 0.0f, 0.0f );
- }
-
- Toolkit::TextLabel textLabel = Toolkit::TextLabel::DownCast( label );
- if( textLabel )
- {
- textLabel.SetProperty( Toolkit::TextLabel::Property::MULTI_LINE, false );
- }
- }
- ConfigureSizeNegotiation();
-}
-
-void PushButton::OnButtonImageSet()
-{
- ConfigureSizeNegotiation();
-}
-
-void PushButton::OnSelectedImageSet()
-{
- ConfigureSizeNegotiation();
-}
-
-void PushButton::OnBackgroundImageSet()
-{
- ConfigureSizeNegotiation();
-}
-
-void PushButton::OnSelectedBackgroundImageSet()
-{
- ConfigureSizeNegotiation();
-}
-
-void PushButton::OnDisabledImageSet()
-{
- ConfigureSizeNegotiation();
-}
-
-void PushButton::OnDisabledSelectedImageSet()
-{
- ConfigureSizeNegotiation();
-}
-
-void PushButton::OnDisabledBackgroundImageSet()
-{
- ConfigureSizeNegotiation();
-}
-
-void PushButton::OnSizeSet( const Vector3& targetSize )
-{
- if( targetSize != mSize )
- {
- mSize = targetSize;
-
- Actor& label = GetLabelActor();
-
- if( label )
- {
- label.SetSize( mSize );
- }
- }
-}
-
-void PushButton::PrepareForTranstionIn( Actor actor )
-{
- actor.SetOpacity( 0.0f );
-}
-
-void PushButton::PrepareForTranstionOut( Actor actor )
-{
- actor.SetOpacity( 1.0f );
-}
-
-void PushButton::OnTransitionIn( Actor actor )
-{
- FadeImageTo( actor, 1.f );
-}
-
-void PushButton::OnTransitionOut( Actor actor )
-{
- FadeImageTo( actor, 0.0f );
-}
-
-void PushButton::FadeImageTo( Actor actor, float opacity )
-{
- if( actor )
- {
- Dali::Animation transitionAnimation = GetTransitionAnimation();
- DALI_ASSERT_DEBUG( transitionAnimation );
-
- if( transitionAnimation )
- {
- transitionAnimation.AnimateTo( Property( actor, Actor::Property::COLOR_ALPHA ), opacity );
- }
- }
-}
-
-Vector3 PushButton::GetNaturalSize()
-{
- Vector3 size;
-
- // If label, test against it's size
- Toolkit::TextLabel label = Toolkit::TextLabel::DownCast( GetLabelActor() );
-
- Actor icon = GetDecoration( UNSELECTED_DECORATION );
- if( label || icon )
- {
- Vector3 labelSize( Vector3::ZERO );
- Vector3 iconSize( Vector3::ZERO );
-
- if( label )
- {
- Vector3 labelNaturalSize = label.GetNaturalSize();
- labelSize.width = labelNaturalSize.width + mLabelPadding.left + mLabelPadding.right;
- labelSize.height = labelNaturalSize.height + mLabelPadding.top + mLabelPadding.bottom;
- }
-
- if( icon )
- {
- Vector3 iconNaturalSize = icon.GetNaturalSize();
- iconSize.width = iconNaturalSize.width + mIconPadding.left + mIconPadding.right;
- iconSize.height = iconNaturalSize.height + mIconPadding.top + mIconPadding.bottom;
-
- switch( mIconAlignment )
- {
- case LEFT:
- case RIGHT:
- {
- size.width = labelSize.width + iconSize.width;
- size.height = std::max( labelSize.height, iconSize.height );
- break;
- }
- case TOP:
- case BOTTOM:
- {
- size.width = std::max( labelSize.width, iconSize.width );
- size.height = labelSize.height + iconSize.height;
- break;
- }
- }
- }
- else
- {
- // No icon, so size is the same as label size.
- // (If there is no label this is zero).
- size = labelSize;
- }
- }
- else
- {
- // Check Image and Background image and use the largest size as the control's Natural size.
- SizeOfActorIfLarger( GetUnselectedImage(), size );
- SizeOfActorIfLarger( GetBackgroundImage(), size );
- }
-
- return size;
-}
-
-void PushButton::OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
-{
- ConfigureSizeNegotiation();
-}
-
-void PushButton::ConfigureSizeNegotiation()
-{
- std::vector< Actor > images;
- images.reserve( 7 );
-
- images.push_back( GetUnselectedImage() );
- images.push_back( GetSelectedImage() );
- images.push_back( GetSelectedBackgroundImage() );
- images.push_back( GetBackgroundImage() );
- images.push_back( GetDisabledImage() );
- images.push_back( GetDisabledSelectedImage() );
- images.push_back( GetDisabledBackgroundImage() );
-
- Actor label = GetLabelActor();
-
- for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i )
- {
- ConfigureSizeNegotiationDimension( static_cast< Dimension::Type >( 1 << i ), images, label );
- }
-
- // Add any vertical padding directly to the actors.
- Actor icon = GetDecoration( UNSELECTED_DECORATION );
- Actor selectedIcon = GetDecoration( SELECTED_DECORATION );
- bool iconExists = icon || selectedIcon;
-
- if( label )
- {
- label.SetPadding( mLabelPadding );
- }
- if( icon )
- {
- icon.SetPadding( mIconPadding );
- }
- if( selectedIcon )
- {
- selectedIcon.SetPadding( mIconPadding );
- }
-
- // Calculate and apply horizontal alignments and offsets
- // to text and icon (depending on existence).
- Vector3 iconPosition( Vector3::ZERO );
- Vector3 labelPosition( Vector3::ZERO );
- Vector3 iconAnchoring( AnchorPoint::CENTER );
- Vector3 labelAnchoring( AnchorPoint::CENTER );
- std::string horizontalLabelAlignment = "CENTER";
- std::string verticalLabelAlignment = "CENTER";
-
- if( iconExists && label )
- {
- // There is an icon and a label to lay out.
- switch( mIconAlignment )
- {
- case LEFT:
- {
- iconPosition.x = mIconPadding.left;
- labelPosition.x = -mLabelPadding.right;
- iconAnchoring = AnchorPoint::CENTER_LEFT;
- labelAnchoring = AnchorPoint::CENTER_RIGHT;
- horizontalLabelAlignment = "END";
- break;
- }
- case RIGHT:
- {
- iconPosition.x = -mIconPadding.right;
- labelPosition.x = mLabelPadding.left;
- iconAnchoring = AnchorPoint::CENTER_RIGHT;
- labelAnchoring = AnchorPoint::CENTER_LEFT;
- horizontalLabelAlignment = "BEGIN";
- break;
- }
- case TOP:
- {
- iconPosition.y = mIconPadding.top;
- labelPosition.y = -mLabelPadding.bottom;
- iconAnchoring = AnchorPoint::TOP_CENTER;
- labelAnchoring = AnchorPoint::BOTTOM_CENTER;
- verticalLabelAlignment = "BOTTOM";
- break;
- }
- case BOTTOM:
- {
- iconPosition.y = -mIconPadding.bottom;
- labelPosition.y = mLabelPadding.top;
- iconAnchoring = AnchorPoint::BOTTOM_CENTER;
- labelAnchoring = AnchorPoint::TOP_CENTER;
- verticalLabelAlignment = "TOP";
- break;
- }
- }
- }
-
- // Note: If there is only an icon, or only a label, the default values are now correct.
- // Setup the icon(s) with the precalculated values.
- if( icon )
- {
- icon.SetPosition( iconPosition );
- icon.SetParentOrigin( iconAnchoring );
- icon.SetAnchorPoint( iconAnchoring );
- }
- if( selectedIcon )
- {
- selectedIcon.SetPosition( iconPosition );
- selectedIcon.SetParentOrigin( iconAnchoring );
- selectedIcon.SetAnchorPoint( iconAnchoring );
- }
-
- // Setup the label.
- if( label )
- {
- label.SetPosition( labelPosition );
- label.SetParentOrigin( labelAnchoring );
- label.SetAnchorPoint( labelAnchoring );
- label.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, horizontalLabelAlignment );
- label.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, verticalLabelAlignment );
- }
-
- RelayoutRequest();
-}
-
-
-void PushButton::ConfigureSizeNegotiationDimension( Dimension::Type dimension, const std::vector< Actor >& images, Actor& label )
-{
- ResizePolicy::Type imageResizePolicy = ResizePolicy::FILL_TO_PARENT;
- ResizePolicy::Type labelResizePolicy = ResizePolicy::FILL_TO_PARENT;
-
- ResizePolicy::Type resizePolicy = Self().GetResizePolicy( dimension );
-
- if( resizePolicy == ResizePolicy::FIT_TO_CHILDREN || resizePolicy == ResizePolicy::USE_NATURAL_SIZE )
- {
- if( label )
- {
- labelResizePolicy = ResizePolicy::USE_NATURAL_SIZE;
- }
- else
- {
- imageResizePolicy = ResizePolicy::USE_NATURAL_SIZE;
- }
- }
-
- if( label )
- {
- label.SetResizePolicy( labelResizePolicy, dimension );
- }
-
- for( std::vector< Actor >::const_iterator it = images.begin(), itEnd = images.end(); it != itEnd; ++it )
- {
- Actor actor = *it;
- if( actor )
- {
- actor.SetResizePolicy( imageResizePolicy, dimension );
- }
- }
-}
-
-
} // namespace Internal
} // namespace Toolkit
*/
virtual void OnInitialize();
- /**
- * @copydoc Toolkit::Internal::Button::OnLabelSet
- */
- virtual void OnLabelSet( bool noPadding );
-
- /**
- * @copydoc Toolkit::Internal::Button::OnButtonImageSet
- */
- virtual void OnButtonImageSet();
-
- /**
- * @copydoc Toolkit::Internal::Button::OnSelectedImageSet
- */
- virtual void OnSelectedImageSet();
-
- /**
- * @copydoc Toolkit::Internal::Button::OnBackgroundImage
- */
- virtual void OnBackgroundImageSet();
-
- /**
- * @copydoc Toolkit::Internal::Button::OnSelectedBackgroundImageSet
- */
- virtual void OnSelectedBackgroundImageSet();
-
- /**
- * @copydoc Toolkit::Internal::Button::OnDisabledImageSet
- */
- virtual void OnDisabledImageSet();
-
- /**
- * @copydoc Toolkit::Internal::Button::OnDisabledSelectedImageSet
- */
- virtual void OnDisabledSelectedImageSet();
-
- /**
- * @copydoc Toolkit::Internal::Button::OnDisabledBackgroundImageSet
- */
- virtual void OnDisabledBackgroundImageSet();
-
- /**
- * @copydoc Toolkit::Internal::Button::PrepareForTranstionIn( Actor actor )
- */
- virtual void PrepareForTranstionIn( Actor actor );
-
- /**
- * @copydoc Toolkit::Internal::Button::PrepareForTranstionOut( Actor actor )
- */
- virtual void PrepareForTranstionOut( Actor actor );
-
- /**
- * @copydoc Toolkit::Internal::Button::OnTransitionIn( Actor actor )
- */
- virtual void OnTransitionIn( Actor actor );
-
- /**
- * @copydoc Toolkit::Internal::Button::OnTransitionOut( Actor actor )
- */
- virtual void OnTransitionOut( Actor actor );
-
-private: // From Control
-
- /**
- * @copydoc CustomActorImpl::OnSizeSet( const Vector3& targetSize )
- */
- virtual void OnSizeSet( const Vector3& targetSize );
-
- /**
- * @copydoc Toolkit::Control::GetNaturalSize
- */
- virtual Vector3 GetNaturalSize();
-
- /**
- * @copydoc Toolkit::Control::OnSetResizePolicy
- */
- virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension );
-
private:
/**
- * It adds the actor to the root actor and to the fade in animation.
- * @param[inout] actor The actor.
- * @param[in] opacity The opacity to fade to
- */
- void FadeImageTo( Actor actor, float opacity );
-
- /**
- * @brief Custom configuration for size negotiation
- */
- void ConfigureSizeNegotiation();
-
- /**
- * @brief Configure size negotiation for a given dimension
- *
- * @param[in] dimension The dimension to configure
- * @param[in] images The list of images to configure
- * @param[in] label The text label to configure
- */
- void ConfigureSizeNegotiationDimension( Dimension::Type dimension, const std::vector< Actor >& images, Actor& label );
-
- /**
- * @brief Sets either the selected or unselected icon.
- *
- * @param[in] state The icon state to set
- * @param[in] iconFilename The filename of the icon
- */
- void SetIcon( DecorationState state, const std::string iconFilename );
-
- /**
- * @brief Gets either the selected or unselected icon.
- *
- * @param[in] state The icon state to get
- * @return The filename of the icon
- */
- std::string& GetIcon( DecorationState state );
-
- /**
* @brief Sets the alignment mode to use to align the icon to the label.
*
* @param[in] iconAlignment The alignment mode to use
*/
const PushButton::IconAlignment GetIconAlignment() const;
- /**
- * @brief Sets the padding for the label.
- *
- * @param[in] padding The padding to set
- */
- void SetLabelPadding( const Vector4& padding );
-
- /**
- * @brief Gets the padding for the label.
- *
- * @return The label padding
- */
- Vector4 GetLabelPadding();
-
- /**
- * @brief Sets the padding for the icon.
- *
- * @param[in] padding The padding to set
- */
- void SetIconPadding( const Vector4& padding );
-
- /**
- * @brief Gets the padding for the icon.
- *
- * @return The icon padding
- */
- Vector4 GetIconPadding();
-
private:
// Undefined
private:
- std::string mIconName[ DECORATION_STATES ]; ///< The original filenames for the icons.
- Padding mLabelPadding; ///< The padding around the label (if present).
- Padding mIconPadding; ///< The padding around the icon (if present).
IconAlignment mIconAlignment; ///< The alignment of the icon against the label.
- Vector3 mSize; ///< The button's size.
};
} // namespace Internal
#include "radio-button-impl.h"
// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/images/resource-image.h>
+#if defined(DEBUG_ENABLED)
+ extern Debug::Filter* gLogButtonFilter;
+#endif
+
namespace Dali
{
TypeRegistration typeRegistration( typeid( Toolkit::RadioButton ), typeid( Toolkit::Button ), Create);
-const char* const UNSELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "radio-button-unselected.png";
-const char* const SELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "radio-button-selected.png";
-const char* const DISABLED_UNSELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "radio-button-unselected-disabled.png";
-const char* const DISABLED_SELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "radio-button-selected-disabled.png";
-
-const float DISTANCE_BETWEEN_IMAGE_AND_LABEL( 5.0f );
}
Dali::Toolkit::RadioButton RadioButton::New()
void RadioButton::OnInitialize()
{
Button::OnInitialize();
-
- Actor self = Self();
-
- // Wrap size of radio button around all its children
- self.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
-
- SetUnselectedImage( UNSELECTED_BUTTON_IMAGE_DIR );
- SetSelectedImage( SELECTED_BUTTON_IMAGE_DIR );
- SetDisabledImage( DISABLED_UNSELECTED_BUTTON_IMAGE_DIR );
- SetDisabledSelectedImage( DISABLED_SELECTED_BUTTON_IMAGE_DIR );
-
- RelayoutRequest();
}
-void RadioButton::OnButtonUp()
+bool RadioButton::OnToggleReleased()
{
- if( ButtonDown == GetState() )
+ // Radio button overrides toggle release (button up) as doesn't allow un-selection to be performed on it directly.
+ bool stateChanged = false;
+ if( !IsSelected() )
{
- // Don't allow selection on an already selected radio button
- if( !IsSelected() )
- {
- SetSelected( !IsSelected() );
- }
+ Button::SetSelected( true ); // Set button to selected as previously unselected
+ stateChanged = true;
}
+ return stateChanged;
}
-void RadioButton::OnLabelSet( bool noPadding )
+void RadioButton::OnStateChange( State newState )
{
- Actor& label = GetLabelActor();
+ // Radio button can be part of a group, if a button in the group is selected then all others should be unselected
+ DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "RadioButton::OnStateChange state(%d)\n", newState );
- if( label )
+ if ( SELECTED_STATE == newState )
{
- label.SetParentOrigin( ParentOrigin::CENTER_LEFT );
- label.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
-
- // Radio button width is FIT_TO_CHILDREN, so the label must have a sensible policy to fill out the space
- if( label.GetResizePolicy( Dimension::WIDTH ) == ResizePolicy::FILL_TO_PARENT )
+ Actor parent = Self().GetParent();
+ if( parent )
{
- label.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::WIDTH );
- }
-
- if( IsSelected() && GetSelectedImage() )
- {
- label.SetX( GetSelectedImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
- }
- else if( GetUnselectedImage() )
- {
- label.SetX( GetUnselectedImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
- }
- else
- {
- label.SetX( DISTANCE_BETWEEN_IMAGE_AND_LABEL );
- }
- }
-}
-
-void RadioButton::OnSelected()
-{
- Actor& label = GetLabelActor();
-
- PaintState paintState = GetPaintState();
- switch( paintState )
- {
- case UnselectedState:
- {
- Actor parent = Self().GetParent();
- if( parent )
+ for( unsigned int i = 0; i < parent.GetChildCount(); ++i )
{
- for( unsigned int i = 0; i < parent.GetChildCount(); ++i )
+ Dali::Toolkit::RadioButton radioButtonChild = Dali::Toolkit::RadioButton::DownCast( parent.GetChildAt( i ) );
+ if( radioButtonChild && radioButtonChild != Self() )
{
- Dali::Toolkit::RadioButton radioButtonChild = Dali::Toolkit::RadioButton::DownCast( parent.GetChildAt( i ) );
- if( radioButtonChild && radioButtonChild != Self() )
- {
- radioButtonChild.SetSelected( false );
- }
+ radioButtonChild.SetSelected( false );
}
}
-
- Actor& selectedImage = GetSelectedImage();
- if( label && selectedImage )
- {
- label.SetX( selectedImage.GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
- }
- break;
- }
- case SelectedState:
- {
- Actor& buttonImage = GetUnselectedImage();
- if( label && buttonImage )
- {
- label.SetX( buttonImage.GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
- }
- break;
- }
- default:
- {
- break;
}
}
}
virtual void OnInitialize();
/**
- * @copydoc Toolkit::Internal::Button::OnButtonUp
+ * @copydoc Toolkit::Internal::Button::OnStateChange
*/
- virtual void OnButtonUp();
+ virtual void OnStateChange( State newState );
/**
- * @copydoc Toolkit::Internal::Button::OnSelected
+ * @copydoc Toolkit::Internal::Button::OnToggleReleased
*/
- virtual void OnSelected();
-
- /**
- * @copydoc Toolkit::Internal::Button::OnLabelSet
- */
- virtual void OnLabelSet( bool noPadding );
+ virtual bool OnToggleReleased();
private:
Actor child = mChildrenNodes[i].actor.GetHandle();
if( child )
{
- if( child.GetResizePolicy( Dimension::WIDTH ) != ResizePolicy::USE_ASSIGNED_SIZE )
+ if( child.GetPropertyType( Toolkit::FlexContainer::ChildProperty::FLEX ) != Property::NONE )
{
- child.SetResizePolicy( ResizePolicy::USE_ASSIGNED_SIZE, Dimension::WIDTH );
- }
- if( child.GetResizePolicy( Dimension::HEIGHT ) != ResizePolicy::USE_ASSIGNED_SIZE )
- {
- child.SetResizePolicy( ResizePolicy::USE_ASSIGNED_SIZE, Dimension::HEIGHT );
+ // Only Set to USE_ASSIGNED_SIZE if the child actor is flexible.
+
+ if( child.GetResizePolicy( Dimension::WIDTH ) != ResizePolicy::USE_ASSIGNED_SIZE )
+ {
+ child.SetResizePolicy( ResizePolicy::USE_ASSIGNED_SIZE, Dimension::WIDTH );
+ }
+ if( child.GetResizePolicy( Dimension::HEIGHT ) != ResizePolicy::USE_ASSIGNED_SIZE )
+ {
+ child.SetResizePolicy( ResizePolicy::USE_ASSIGNED_SIZE, Dimension::HEIGHT );
+ }
}
container.Add( child, Vector2(mChildrenNodes[i].node->layout.dimensions[CSS_WIDTH], mChildrenNodes[i].node->layout.dimensions[CSS_HEIGHT] ) );
void ImageView::SetImage( Image image )
{
- if( ( mImage != image ) ||
- ! mUrl.empty() || // If we're changing from a URL type to an Image type
- ! mPropertyMap.Empty() ) // If we're changing from a property map type to an Image type
- {
- mUrl.clear();
- mPropertyMap.Clear();
-
- mImage = image;
+ // Don't bother comparing if we had a visual previously, just drop old visual and create new one
+ mImage = image;
+ mUrl.clear();
+ mPropertyMap.Clear();
- mVisual = Toolkit::VisualFactory::Get().CreateVisual( image );
- RegisterVisual( Toolkit::ImageView::Property::IMAGE, mVisual );
- mImageSize = image ? ImageDimensions( image.GetWidth(), image.GetHeight() ) : ImageDimensions( 0, 0 );
+ mVisual = Toolkit::VisualFactory::Get().CreateVisual( image );
+ RegisterVisual( Toolkit::ImageView::Property::IMAGE, mVisual );
- RelayoutRequest();
- }
+ RelayoutRequest();
}
-void ImageView::SetImage( Property::Map map )
+void ImageView::SetImage( const Property::Map& map )
{
+ // Comparing a property map is too expensive so just creating a new visual
+ mPropertyMap = map;
mUrl.clear();
mImage.Reset();
- mPropertyMap = map;
mVisual = Toolkit::VisualFactory::Get().CreateVisual( mPropertyMap );
RegisterVisual( Toolkit::ImageView::Property::IMAGE, mVisual );
- Property::Value* widthValue = mPropertyMap.Find( "width" );
- if( widthValue )
- {
- int width;
- if( widthValue->Get( width ) )
- {
- mImageSize = ImageDimensions( width, mImageSize.GetHeight() );
- }
- }
-
- Property::Value* heightValue = mPropertyMap.Find( "height" );
- if( heightValue )
- {
- int height;
- if( heightValue->Get( height ) )
- {
- mImageSize = ImageDimensions( mImageSize.GetWidth(), height );
- }
- }
-
RelayoutRequest();
}
void ImageView::SetImage( const std::string& url, ImageDimensions size )
{
- if( ( mUrl != url ) ||
- mImage || // If we're changing from an Image type to a URL type
- ! mPropertyMap.Empty() ) // If we're changing from a property map type to a URL type
- {
- mImage.Reset();
- mPropertyMap.Clear();
-
- mUrl = url;
-
- if( size.GetWidth() != 0u && size.GetHeight() != 0u )
- {
- mImageSize = size;
- }
+ // Don't bother comparing if we had a visual previously, just drop old visual and create new one
+ mUrl = url;
+ mImage.Reset();
+ mPropertyMap.Clear();
- mVisual = Toolkit::VisualFactory::Get().CreateVisual( url, size );
- RegisterVisual( Toolkit::ImageView::Property::IMAGE, mVisual );
+ mVisual = Toolkit::VisualFactory::Get().CreateVisual( url, size );
+ RegisterVisual( Toolkit::ImageView::Property::IMAGE, mVisual );
- RelayoutRequest();
- }
+ RelayoutRequest();
}
Image ImageView::GetImage() const
return Vector3( rendererNaturalSize );
}
- Vector3 size;
- size.x = mImageSize.GetWidth();
- size.y = mImageSize.GetHeight();
-
- if( size.x > 0 && size.y > 0 )
- {
- size.z = std::min(size.x, size.y);
- return size;
- }
- else
- {
- // if no image then use Control's natural size
- return Control::GetNaturalSize();
- }
+ // if no visual then use Control's natural size
+ return Control::GetNaturalSize();
}
float ImageView::GetHeightForWidth( float width )
{
- if( mImageSize.GetWidth() > 0 && mImageSize.GetHeight() > 0 )
+ if( mVisual )
{
- return GetHeightForWidthBase( width );
+ return mVisual.GetHeightForWidth( width );
}
else
{
float ImageView::GetWidthForHeight( float height )
{
- if( mImageSize.GetWidth() > 0 && mImageSize.GetHeight() > 0 )
+ if( mVisual )
{
- return GetWidthForHeightBase( height );
+ return mVisual.GetWidthForHeight( height );
}
else
{
* If the handle is empty, ImageView will display nothing
* @param[in] map The Dali::Property::Map to use for to display.
*/
- void SetImage( Dali::Property::Map map );
+ void SetImage( const Dali::Property::Map& map );
/**
* @copydoc Dali::Toolkit::SetImage
private:
Toolkit::Visual::Base mVisual;
- ImageDimensions mImageSize;
std::string mUrl; ///< the url for the image if the image came from a URL, empty otherwise
Image mImage; ///< the Image if the image came from a Image, null otherwise
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/text/rendering-backend.h>
+#include <dali-toolkit/public-api/visuals/color-visual-properties.h>
#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/internal/text/rendering/text-backend.h>
#include <dali-toolkit/internal/text/text-effects-style.h>
#include <dali-toolkit/internal/text/text-font-style.h>
self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
self.OnStageSignal().Connect( this, &TextEditor::OnStageConnect );
+
+ // Creates an extra control to be used as stencil buffer.
+ mStencil = Control::New();
+ mStencil.SetAnchorPoint( AnchorPoint::CENTER );
+ mStencil.SetParentOrigin( ParentOrigin::CENTER );
+
+ // Creates a background visual. Even if the color is transparent it updates the stencil.
+ mStencil.SetProperty( Toolkit::Control::Property::BACKGROUND,
+ Property::Map().Add( Toolkit::Visual::Property::TYPE, DevelVisual::COLOR ).
+ Add( ColorVisual::Property::MIX_COLOR, Color::TRANSPARENT ) );
+
+ // Enable the clipping property.
+ mStencil.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
+ mStencil.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+
+ self.Add( mStencil );
}
void TextEditor::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
mRenderer = Backend::Get().NewRenderer( mRenderingBackend );
}
- EnableClipping( size );
RenderText( updateTextType );
}
void TextEditor::RenderText( Text::Controller::UpdateTextType updateTextType )
{
- Actor self = Self();
Actor renderableActor;
if( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType ) )
mRenderableActor.SetPosition( scrollOffset.x, scrollOffset.y );
- Actor clipRootActor;
- if( mClipper )
- {
- clipRootActor = mClipper->GetRootActor();
- }
+ // Make sure the actors are parented correctly with/without clipping
+ Actor self = mStencil ? mStencil : Self();
for( std::vector<Actor>::const_iterator it = mClippingDecorationActors.begin(),
endIt = mClippingDecorationActors.end();
it != endIt;
++it )
{
- Actor actor = *it;
-
- if( clipRootActor )
- {
- clipRootActor.Add( actor );
- }
- else
- {
- self.Add( actor );
- }
+ self.Add( *it );
}
mClippingDecorationActors.clear();
- // Make sure the actor is parented correctly with/without clipping
- if( clipRootActor )
- {
- clipRootActor.Add( mRenderableActor );
- }
- else
- {
- self.Add( mRenderableActor );
- }
+ self.Add( mRenderableActor );
}
}
}
}
-void TextEditor::EnableClipping( const Vector2& size )
-{
- // Not worth to created clip actor if width or height is equal to zero.
- if( size.width > Math::MACHINE_EPSILON_1000 && size.height > Math::MACHINE_EPSILON_1000 )
- {
- if( !mClipper )
- {
- Actor self = Self();
-
- mClipper = Clipper::New( size );
- self.Add( mClipper->GetRootActor() );
- self.Add( mClipper->GetImageView() );
- }
- else if ( mClipper )
- {
- mClipper->Refresh( size );
- }
- }
-}
-
void TextEditor::OnClipboardTextSelected( ClipboardEventNotifier& clipboard )
{
mController->PasteClipboardItemEvent();
TextEditor::~TextEditor()
{
- mClipper.Reset();
+ UnparentAndReset( mStencil );
if( ( NULL != mIdleCallback ) && Adaptor::IsAvailable() )
{
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/control-impl.h>
#include <dali-toolkit/public-api/controls/text-controls/text-editor.h>
-#include <dali-toolkit/internal/text/clipping/text-clipper.h>
#include <dali-toolkit/internal/text/decorator/text-decorator.h>
#include <dali-toolkit/internal/text/text-control-interface.h>
#include <dali-toolkit/internal/text/text-editable-control-interface.h>
void GetHandleImagePropertyValue( Property::Value& value, Text::HandleType handleType, Text::HandleImageType handleImageType );
/**
- * @brief Enable or disable clipping.
- *
- * @param[in] size The area to clip within.
- */
- void EnableClipping( const Vector2& size );
-
- /**
* @brief Callback when keyboard is shown/hidden.
*
* @param[in] keyboardShown True if keyboard is shown.
Text::ControllerPtr mController;
Text::RendererPtr mRenderer;
Text::DecoratorPtr mDecorator;
- Text::ClipperPtr mClipper;
+ Toolkit::Control mStencil;
std::vector<Actor> mClippingDecorationActors; ///< Decoration actors which need clipping.
Actor mRenderableActor;
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/text/rendering-backend.h>
+#include <dali-toolkit/public-api/visuals/color-visual-properties.h>
#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/internal/text/rendering/text-backend.h>
#include <dali-toolkit/internal/text/text-effects-style.h>
#include <dali-toolkit/internal/text/text-font-style.h>
}
case Toolkit::TextField::Property::EXCEED_POLICY:
{
- // TODO
+ impl.mExceedPolicy = value.Get<int>();
+
+ if( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP == impl.mExceedPolicy )
+ {
+ impl.EnableClipping();
+ }
+ else
+ {
+ UnparentAndReset( impl.mStencil );
+ }
+ impl.RequestTextRelayout();
break;
}
case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT:
}
case Toolkit::TextField::Property::VERTICAL_ALIGNMENT:
{
- if( impl.mController )
+ if( impl.mController )
{
const char* name = Scripting::GetEnumerationName< Toolkit::Text::Layout::VerticalAlignment >( impl.mController->GetVerticalAlignment(),
VERTICAL_ALIGNMENT_STRING_TABLE,
self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
self.OnStageSignal().Connect( this, &TextField::OnStageConnect );
+
+ if( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP == mExceedPolicy )
+ {
+ EnableClipping();
+ }
}
void TextField::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
mRenderer = Backend::Get().NewRenderer( mRenderingBackend );
}
- EnableClipping( size );
RenderText( updateTextType );
}
void TextField::RenderText( Text::Controller::UpdateTextType updateTextType )
{
- Actor self = Self();
Actor renderableActor;
if( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType ) )
mRenderableActor.SetPosition( scrollOffset.x, scrollOffset.y );
- Actor clipRootActor;
- if( mClipper )
- {
- clipRootActor = mClipper->GetRootActor();
- }
+ // Make sure the actors are parented correctly with/without clipping
+ Actor self = mStencil ? mStencil : Self();
for( std::vector<Actor>::const_iterator it = mClippingDecorationActors.begin(),
endIt = mClippingDecorationActors.end();
it != endIt;
++it )
{
- Actor actor = *it;
-
- if( clipRootActor )
- {
- clipRootActor.Add( actor );
- }
- else
- {
- self.Add( actor );
- }
+ self.Add( *it );
}
mClippingDecorationActors.clear();
- // Make sure the actor is parented correctly with/without clipping
- if( clipRootActor )
- {
- clipRootActor.Add( mRenderableActor );
- }
- else
- {
- self.Add( mRenderableActor );
- }
+ self.Add( mRenderableActor );
}
}
}
}
-void TextField::EnableClipping( const Vector2& size )
+void TextField::EnableClipping()
{
- if( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP == mExceedPolicy )
- {
- // Not worth to created clip actor if width or height is equal to zero.
- if( size.width > Math::MACHINE_EPSILON_1000 && size.height > Math::MACHINE_EPSILON_1000 )
- {
- if( !mClipper )
- {
- Actor self = Self();
-
- mClipper = Clipper::New( size );
- self.Add( mClipper->GetRootActor() );
- self.Add( mClipper->GetImageView() );
- }
- else if ( mClipper )
- {
- mClipper->Refresh( size );
- }
- }
- }
- else
+ if( !mStencil )
{
- // Note - this will automatically remove the root actor & the image view
- mClipper.Reset();
+ // Creates an extra control to be used as stencil buffer.
+ mStencil = Control::New();
+ mStencil.SetAnchorPoint( AnchorPoint::CENTER );
+ mStencil.SetParentOrigin( ParentOrigin::CENTER );
+
+ // Creates a background visual. Even if the color is transparent it updates the stencil.
+ // Property::Map backgroundMap;
+ mStencil.SetProperty( Toolkit::Control::Property::BACKGROUND,
+ Property::Map().Add( Toolkit::Visual::Property::TYPE, DevelVisual::COLOR ).
+ Add( ColorVisual::Property::MIX_COLOR, Color::TRANSPARENT ) );
+
+ // Enable the clipping property.
+ mStencil.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
+ mStencil.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+
+ Self().Add( mStencil );
}
}
TextField::~TextField()
{
- mClipper.Reset();
+ UnparentAndReset( mStencil );
if( ( NULL != mIdleCallback ) && Adaptor::IsAvailable() )
{
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/control-impl.h>
#include <dali-toolkit/public-api/controls/text-controls/text-field.h>
-#include <dali-toolkit/internal/text/clipping/text-clipper.h>
#include <dali-toolkit/internal/text/decorator/text-decorator.h>
#include <dali-toolkit/internal/text/text-control-interface.h>
#include <dali-toolkit/internal/text/text-editable-control-interface.h>
/**
* @brief Enable or disable clipping.
- *
- * @param[in] size The area to clip within.
*/
- void EnableClipping( const Vector2& size );
+ void EnableClipping();
/**
* @brief Callback when keyboard is shown/hidden.
Text::ControllerPtr mController;
Text::RendererPtr mRenderer;
Text::DecoratorPtr mDecorator;
- Text::ClipperPtr mClipper; ///< For EXCEED_POLICY_CLIP
+ Toolkit::Control mStencil; ///< For EXCEED_POLICY_CLIP
std::vector<Actor> mClippingDecorationActors; ///< Decoration actors which need clipping.
Actor mRenderableActor;
#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
#include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup-callback-interface.h>
+#include <dali-toolkit/devel-api/visuals/text-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
namespace Dali
{
// Label properties.
Property::Map buttonLabelProperties;
- buttonLabelProperties.Insert( "text", button.caption );
+ buttonLabelProperties.Insert( Toolkit::TextVisual::Property::TEXT, button.caption );
option.SetProperty( Toolkit::Button::Property::LABEL, buttonLabelProperties );
}
if( showIcons )
$(toolkit_src_dir)/styling/style-manager-impl.cpp \
$(toolkit_src_dir)/text/bidirectional-support.cpp \
$(toolkit_src_dir)/text/character-set-conversion.cpp \
- $(toolkit_src_dir)/text/clipping/text-clipper.cpp \
$(toolkit_src_dir)/text/color-segmentation.cpp \
$(toolkit_src_dir)/text/cursor-helper-functions.cpp \
$(toolkit_src_dir)/text/glyph-metrics-helper.cpp \
DALI_TYPE_REGISTRATION_END()
+const unsigned int MAX_HISTORY_AMOUNT = 30; ///< Max length of focus history stack
+
} // unnamed namespace
Toolkit::KeyboardFocusManager KeyboardFocusManager::Get()
// Save the current focused actor
mCurrentFocusActor = actorID;
+ // Push Current Focused Actor to FocusHistory
+ mFocusHistory.PushBack( &actor.GetBaseObject() );
+
+ // Delete first element before add new element when Stack is full.
+ if( mFocusHistory.Count() > MAX_HISTORY_AMOUNT )
+ {
+ FocusStackIterator beginPos = mFocusHistory.Begin();
+ mFocusHistory.Erase( beginPos );
+ }
+
DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] SUCCEED\n", __FUNCTION__, __LINE__);
success = true;
}
return GetFocusGroup(GetCurrentFocusActor());
}
+void KeyboardFocusManager::MoveFocusBackward()
+{
+ // Find Pre Focused Actor when the list size is more than 1
+ if( mFocusHistory.Count() > 1 )
+ {
+ // Delete current focused actor in history
+ FocusStackIterator endPos = mFocusHistory.End();
+ endPos = mFocusHistory.Erase( --endPos );
+
+ // If pre-focused actors are not on stage, remove them in stack
+ while( !Dali::Actor::DownCast(BaseHandle(mFocusHistory[ mFocusHistory.Count() - 1 ])).OnStage() )
+ {
+ endPos = mFocusHistory.Erase( --endPos );
+ }
+
+ // Get pre focused actor
+ BaseObject* object = mFocusHistory[ mFocusHistory.Count() - 1 ];
+ BaseHandle handle( object );
+ Actor preFocusedActor = Dali::Actor::DownCast( handle );
+
+ // Delete pre focused actor in history because it will pushed again by SetCurrentFocusActor()
+ mFocusHistory.Erase( --endPos );
+
+ SetCurrentFocusActor( preFocusedActor );
+ }
+}
+
bool KeyboardFocusManager::IsLayoutControl(Actor actor) const
{
Toolkit::Control control = Toolkit::Control::DownCast(actor);
{
// Emit signal to go back to the previous view???
}
+ else if (keyName == "Escape" && !isAccessibilityEnabled)
+ {
+ }
}
else if(event.state == KeyEvent::Up)
{
*/
Actor GetFocusIndicatorActor();
+ /**
+ * Move current focus to backward
+ */
+ void MoveFocusBackward();
+
public:
/**
private:
+ typedef Dali::Vector< Dali::BaseObject* > FocusStack; ///< Define Dali::Vector< Dali::BaseObject* > as FocusStack to contain focus history
+ typedef FocusStack::Iterator FocusStackIterator; ///< Define FocusStack::Iterator as FocusStackIterator to navigate FocusStack
+
/**
* Get the focus group of current focused actor.
* @pre The FocusManager has been initialized.
bool mIsWaitingKeyboardFocusChangeCommit:1; /// A flag to indicate PreFocusChangeSignal emitted but the proposed focus actor is not commited by the application yet.
+ FocusStack mFocusHistory; ///< Stack to contain pre-focused actor's BaseObject*
+
+ FocusStackIterator mFocusHistoryIter; ///< Iterator for mFocusHistory
+
SlotDelegate< KeyboardFocusManager > mSlotDelegate;
+
};
} // namespace Internal
+++ /dev/null
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali-toolkit/internal/text/clipping/text-clipper.h>
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/common/stage.h>
-#include <dali/public-api/render-tasks/render-task-list.h>
-#include <dali/public-api/rendering/renderer.h>
-
-namespace
-{
-
-// Currently on desktop machines 2k x 2k is the maximum frame buffer size, on target is 4k x 4k.
-const float MAX_OFFSCREEN_RENDERING_SIZE = 2048.f;
-
-} // namespace
-
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Text
-{
-
-ClipperPtr Clipper::New( const Vector2& size )
-{
- ClipperPtr clipper( new Clipper() );
-
- // Second-phase init
- clipper->Initialize( size );
-
- return clipper;
-}
-
-Actor Clipper::GetRootActor() const
-{
- return mOffscreenRootActor;
-}
-
-Actor Clipper::GetImageView() const
-{
- return mImageView;
-}
-
-void Clipper::Refresh( const Vector2& size )
-{
- const Size offscreenSize( std::min( MAX_OFFSCREEN_RENDERING_SIZE, size.width ),
- std::min( MAX_OFFSCREEN_RENDERING_SIZE, size.height ) );
-
- const bool sizeChanged = offscreenSize != mCurrentOffscreenSize;
-
- if( sizeChanged )
- {
- // Reconfigure camera for current size.
- mOffscreenCameraActor.SetOrthographicProjection( offscreenSize );
-
- // Recreate frame buffer for offscreen rendering when the size changes.
- FrameBufferImage frameBufferImage = FrameBufferImage::New( offscreenSize.width,
- offscreenSize.height,
- Pixel::RGBA8888 );
-
- mOffscreenRootActor.SetSize( size );
-
- mImageView.SetSize( offscreenSize );
- mImageView.SetImage( frameBufferImage );
- mRenderTask.SetTargetFrameBuffer( frameBufferImage );
-
- // Stores current sizPe to avoid create new Dali resources if text changes.
- mCurrentOffscreenSize = offscreenSize;
- }
-
- mRenderTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
-}
-
-void Clipper::Initialize( const Vector2& size )
-{
- const Size offscreenSize( std::min( MAX_OFFSCREEN_RENDERING_SIZE, size.width ),
- std::min( MAX_OFFSCREEN_RENDERING_SIZE, size.height ) );
-
- // Create a root actor and an image view for offscreen rendering.
- mOffscreenRootActor = Layer::New();
- mOffscreenRootActor.SetColorMode( USE_OWN_COLOR );
- mOffscreenRootActor.SetInheritPosition( false );
- mOffscreenRootActor.SetInheritScale( false );
- mOffscreenRootActor.SetDepthTestDisabled( true );
- mOffscreenRootActor.SetSize( offscreenSize );
-
- mImageView = ImageView::New();
- mImageView.SetParentOrigin( ParentOrigin::CENTER );
- mImageView.SetScale( Vector3( 1.0f, -1.0f, 1.0f ) );
- mImageView.SetSize( offscreenSize );
-
- // Creates a new camera actor.
- mOffscreenCameraActor = CameraActor::New();
- mOffscreenCameraActor.SetParentOrigin( ParentOrigin::CENTER );
- mOffscreenCameraActor.SetOrthographicProjection( offscreenSize );
- mOffscreenRootActor.Add( mOffscreenCameraActor ); // camera to shoot the offscreen text
-
- // Creates a new render task.
- mRenderTask = Stage::GetCurrent().GetRenderTaskList().CreateTask();
- mRenderTask.SetSourceActor( mOffscreenRootActor );
- mRenderTask.SetClearColor( Color::TRANSPARENT );
- mRenderTask.SetClearEnabled( true );
- mRenderTask.SetExclusive( true );
- mRenderTask.SetCameraActor( mOffscreenCameraActor );
-
- // Creates a frame buffer for offscreen rendering
- FrameBufferImage frameBufferImage = FrameBufferImage::New( offscreenSize.width,
- offscreenSize.height,
- Pixel::RGBA8888 );
- mImageView.SetImage( frameBufferImage );
- mRenderTask.SetTargetFrameBuffer( frameBufferImage );
- mImageView.OnStageSignal().Connect(this, &Clipper::OnStageConnect);
-
- // Stores current size to avoid create new Dali resources if text changes.
- mCurrentOffscreenSize = offscreenSize;
-}
-
-void Clipper::OnStageConnect( Dali::Actor actor )
-{
- Renderer renderer = mImageView.GetRendererAt(0);
- renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::ONE );
- renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ONE_MINUS_SRC_ALPHA );
- renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::ONE );
- renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ONE );
-}
-
-Clipper::Clipper()
-{
-}
-
-Clipper::~Clipper()
-{
- if( Stage::IsInstalled() )
- {
- UnparentAndReset( mOffscreenRootActor );
- UnparentAndReset( mImageView );
-
- Stage::GetCurrent().GetRenderTaskList().RemoveTask( mRenderTask );
- }
-}
-
-} // namespace Text
-
-} // namespace Toolkit
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_TOOLKIT_INTERNAL_TEXT_CLIPPER_H__
-#define __DALI_TOOLKIT_INTERNAL_TEXT_CLIPPER_H__
-
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/actors/layer.h>
-#include <dali/public-api/actors/camera-actor.h>
-#include <dali/public-api/render-tasks/render-task.h>
-#include <dali-toolkit/public-api/controls/image-view/image-view.h>
-#include <dali/public-api/signals/connection-tracker.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Text
-{
-
-class Clipper;
-typedef IntrusivePtr<Clipper> ClipperPtr;
-
-/**
- * @brief A helper class for clipping actors using a FrameBufferImage.
- */
-class Clipper : public RefObject, public ConnectionTracker
-{
-public:
-
- /**
- * @brief Create a clipper.
- *
- * @param[in] size The size of the clipping region.
- */
- static ClipperPtr New( const Vector2& size );
-
- /**
- * @brief Children added to this actor will be clipped with the specified region.
- *
- * @note This is done by rendering to a FrameBufferImage which must then be displayed; see also GetImageView().
- * @return The root actor.
- */
- Actor GetRootActor() const;
-
- /**
- * @brief This actor will display the resulting FrameBufferImage.
- *
- * @return The image view.
- */
- Actor GetImageView() const;
-
- /**
- * @brief Refresh the contents of the FrameBufferImage.
- *
- * @param[in] size The size of the clipping region.
- */
- void Refresh( const Vector2& size );
-
-private: // Implementation
-
- /**
- * @brief Second-phase init
- *
- * @param[in] size The size of the clipping region.
- */
- void Initialize( const Vector2& size );
-
- /**
- * The renderer is not created until the clipper actor is set on stage, only by then the blend function could be set.
- *
- * @param[in] actor The actor connected to stage.
- */
- void OnStageConnect( Dali::Actor actor );
-
- /**
- * Construct a new Clipper.
- */
- Clipper();
-
- /**
- * A reference counted object may only be deleted by calling Unreference()
- */
- virtual ~Clipper();
-
-private:
-
- // Undefined copy constructor and assignment operators
- Clipper(const Clipper&);
- Clipper& operator=(const Clipper& rhs);
-
-private: // Data
-
- Layer mOffscreenRootActor;
- CameraActor mOffscreenCameraActor;
- ImageView mImageView;
- RenderTask mRenderTask;
- Vector2 mCurrentOffscreenSize;
-};
-
-} // namespace Text
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_INTERNAL_TEXT_CLIPPER_H__
);
}
-BorderVisualPtr BorderVisual::New( VisualFactoryCache& factoryCache )
+BorderVisualPtr BorderVisual::New( VisualFactoryCache& factoryCache, const Property::Map& properties )
{
- return new BorderVisual( factoryCache );
+ BorderVisualPtr borderVisualPtr( new BorderVisual( factoryCache ) );
+ borderVisualPtr->SetProperties( properties );
+ return borderVisualPtr;
}
BorderVisual::BorderVisual( VisualFactoryCache& factoryCache )
* @brief Create a new border visual.
*
* @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
+ * @param[in] properties A Property::Map containing settings for this visual
* @return A smart-pointer to the newly allocated visual.
*/
- static BorderVisualPtr New( VisualFactoryCache& factoryCache );
+ static BorderVisualPtr New( VisualFactoryCache& factoryCache, const Property::Map& properties );
protected:
);
}
-ColorVisualPtr ColorVisual::New( VisualFactoryCache& factoryCache )
+ColorVisualPtr ColorVisual::New( VisualFactoryCache& factoryCache, const Property::Map& properties )
{
- return new ColorVisual( factoryCache );
+ ColorVisualPtr colorVisualPtr( new ColorVisual( factoryCache ) );
+ colorVisualPtr->SetProperties( properties );
+ return colorVisualPtr;
}
ColorVisual::ColorVisual( VisualFactoryCache& factoryCache )
* @brief Create a new color visual.
*
* @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
+ * @param[in] properties A Property::Map containing settings for this visual
* @return A smart-pointer to the newly allocated visual.
*/
- static ColorVisualPtr New( VisualFactoryCache& factoryCache );
+ static ColorVisualPtr New( VisualFactoryCache& factoryCache, const Property::Map& properties );
public: // from Visual
} // unnamed namespace
-GradientVisualPtr GradientVisual::New( VisualFactoryCache& factoryCache )
+GradientVisualPtr GradientVisual::New( VisualFactoryCache& factoryCache, const Property::Map& properties )
{
- return new GradientVisual( factoryCache );
+ GradientVisualPtr gradientVisualPtr( new GradientVisual( factoryCache ) );
+ gradientVisualPtr->SetProperties( properties );
+ return gradientVisualPtr;
}
GradientVisual::GradientVisual( VisualFactoryCache& factoryCache )
* @brief Create a new gradient visual.
*
* @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
+ * @param[in] properties A Property::Map containing settings for this visual
* @return A smart-pointer to the newly allocated visual.
*/
- static GradientVisualPtr New( VisualFactoryCache& factoryCache );
+ static GradientVisualPtr New( VisualFactoryCache& factoryCache, const Property::Map& properties );
public: // from Visual
} // unnamed namespace
-BatchImageVisualPtr BatchImageVisual::New( VisualFactoryCache& factoryCache, const std::string& url )
+BatchImageVisualPtr BatchImageVisual::New( VisualFactoryCache& factoryCache, const std::string& url, const Property::Map& properties )
{
BatchImageVisualPtr visual = new BatchImageVisual( factoryCache );
visual->mImageUrl = url;
+ visual->SetProperties( properties );
+
return visual;
}
* @brief Create a new batch-image visual.
*
* @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
+ * @param[in] url The URL of the image to use
+ * @param[in] properties A Property::Map containing settings for this visual
* @return A smart-pointer to the newly allocated visual.
*/
- static BatchImageVisualPtr New( VisualFactoryCache& factoryCache, const std::string& url );
+ static BatchImageVisualPtr New( VisualFactoryCache& factoryCache, const std::string& url, const Property::Map& properties = Property::Map() );
public: // from Visual
ImageVisualPtr ImageVisual::New( VisualFactoryCache& factoryCache,
const std::string& imageUrl,
+ const Property::Map& properties,
+ ImageDimensions size,
+ FittingMode::Type fittingMode,
+ Dali::SamplingMode::Type samplingMode )
+{
+ ImageVisualPtr imageVisualPtr( new ImageVisual( factoryCache, imageUrl, size, fittingMode, samplingMode ) );
+ imageVisualPtr->SetProperties( properties );
+ return imageVisualPtr;
+}
+
+ImageVisualPtr ImageVisual::New( VisualFactoryCache& factoryCache,
+ const std::string& imageUrl,
ImageDimensions size,
FittingMode::Type fittingMode,
Dali::SamplingMode::Type samplingMode )
mSamplingMode = Dali::SamplingMode::Type( value );
}
+ // Use a variable to detect if the width or height have been modified by the property map.
+ bool desiredSizeSpecified = false;
int desiredWidth = 0;
Property::Value* desiredWidthValue = propertyMap.Find( Toolkit::ImageVisual::Property::DESIRED_WIDTH, IMAGE_DESIRED_WIDTH );
if( desiredWidthValue )
{
desiredWidthValue->Get( desiredWidth );
+ desiredSizeSpecified = true;
}
int desiredHeight = 0;
if( desiredHeightValue )
{
desiredHeightValue->Get( desiredHeight );
+ desiredSizeSpecified = true;
}
- mDesiredSize = ImageDimensions( desiredWidth, desiredHeight );
+ // Only update the desired size if specified in the property map.
+ if( desiredSizeSpecified )
+ {
+ mDesiredSize = ImageDimensions( desiredWidth, desiredHeight );
+ }
Property::Value* pixelAreaValue = propertyMap.Find( Toolkit::ImageVisual::Property::PIXEL_AREA, PIXEL_AREA_UNIFORM_NAME );
if( pixelAreaValue )
void ImageVisual::InitializeRenderer( const std::string& imageUrl )
{
- DALI_ASSERT_DEBUG( !mImpl->mRenderer && "Renderer should have been removed from stage and already reset before initialization" );
-
mImageUrl = imageUrl;
mImpl->mFlags &= ~Impl::IS_ATLASING_APPLIED;
if( !mImpl->mCustomShader &&
- ( strncasecmp( imageUrl.c_str(), HTTP_URL, sizeof(HTTP_URL) -1 ) != 0 ) && // ignore remote images
+ ( strncasecmp( imageUrl.c_str(), HTTP_URL, sizeof(HTTP_URL) -1 ) != 0 ) && // dont atlas remote images
( strncasecmp( imageUrl.c_str(), HTTPS_URL, sizeof(HTTPS_URL) -1 ) != 0 ) )
{
bool defaultWrapMode = mWrapModeU <= WrapMode::CLAMP_TO_EDGE && mWrapModeV <= WrapMode::CLAMP_TO_EDGE;
void ImageVisual::InitializeRenderer( const Image& image )
{
- DALI_ASSERT_DEBUG( !mImpl->mRenderer && "Renderer should have been removed from stage and already reset before initialization" );
mImpl->mFlags &= ~Impl::IS_FROM_CACHE;
*
* @param[in] factoryCache The VisualFactoryCache object
* @param[in] imageUrl The URL of the image resource to use
+ * @param[in] properties A Property::Map containing settings for this visual
* @param[in] size The width and height to fit the loaded image to.
* @param[in] fittingMode The FittingMode of the resource to load
* @param[in] samplingMode The SamplingMode of the resource to load
+ * @return A smart-pointer to the newly allocated visual.
+ */
+ static ImageVisualPtr New( VisualFactoryCache& factoryCache,
+ const std::string& imageUrl,
+ const Property::Map& properties,
+ ImageDimensions size = ImageDimensions(),
+ FittingMode::Type fittingMode = FittingMode::DEFAULT,
+ Dali::SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR );
+
+ /**
+ * @brief Create a new image visual with a URL.
+ *
+ * The visual will load the Image asynchronously when the associated actor is put on stage, and destroy the image when it is off stage
+ *
+ * @param[in] factoryCache The VisualFactoryCache object
+ * @param[in] imageUrl The URL of the image resource to use
+ * @param[in] size The width and height to fit the loaded image to.
+ * @param[in] fittingMode The FittingMode of the resource to load
+ * @param[in] samplingMode The SamplingMode of the resource to load
+ * @return A smart-pointer to the newly allocated visual.
*/
static ImageVisualPtr New( VisualFactoryCache& factoryCache,
const std::string& imageUrl,
} // unnamed namespace
-MeshVisualPtr MeshVisual::New( VisualFactoryCache& factoryCache )
+MeshVisualPtr MeshVisual::New( VisualFactoryCache& factoryCache, const Property::Map& properties )
{
- return new MeshVisual( factoryCache );
+ MeshVisualPtr meshVisualPtr( new MeshVisual( factoryCache ) );
+ meshVisualPtr->SetProperties( properties );
+ return meshVisualPtr;
}
MeshVisual::MeshVisual( VisualFactoryCache& factoryCache )
* @brief Create a new mesh visual.
*
* @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
+ * @param[in] properties A Property::Map containing settings for this visual
* @return A smart-pointer to the newly allocated visual.
*/
- static MeshVisualPtr New( VisualFactoryCache& factoryCache );
+ static MeshVisualPtr New( VisualFactoryCache& factoryCache, const Property::Map& properties );
public: // from Visual
/////////////////NPatchVisual////////////////
+NPatchVisualPtr NPatchVisual::New( VisualFactoryCache& factoryCache, const std::string& imageUrl, const Property::Map& properties )
+{
+ NPatchVisualPtr nPatchVisual( new NPatchVisual( factoryCache ) );
+ nPatchVisual->mImageUrl = imageUrl;
+ nPatchVisual->SetProperties( properties );
+
+ return nPatchVisual;
+}
+
NPatchVisualPtr NPatchVisual::New( VisualFactoryCache& factoryCache, const std::string& imageUrl )
{
- NPatchVisual* nPatchVisual = new NPatchVisual( factoryCache );
+ NPatchVisualPtr nPatchVisual( new NPatchVisual( factoryCache ) );
nPatchVisual->mImageUrl = imageUrl;
return nPatchVisual;
NPatchVisualPtr NPatchVisual::New( VisualFactoryCache& factoryCache, NinePatchImage image )
{
- NPatchVisual* nPatchVisual = new NPatchVisual( factoryCache );
+ NPatchVisualPtr nPatchVisual( new NPatchVisual( factoryCache ) );
nPatchVisual->mImageUrl = image.GetUrl();
return nPatchVisual;
*
* @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
* @param[in] imageUrl The URL to 9 patch image resource to use
+ * @param[in] properties A Property::Map containing settings for this visual
+ * @return A smart-pointer to the newly allocated visual.
+ */
+ static NPatchVisualPtr New( VisualFactoryCache& factoryCache, const std::string& imageUrl, const Property::Map& properties );
+
+ /**
+ * @brief Create an N-patch visual using an image URL.
+ *
+ * The visual will load the image synchronously when the associated actor is put on stage, and destroy the image when it is off stage
+ *
+ * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
+ * @param[in] imageUrl The URL to 9 patch image resource to use
+ * @return A smart-pointer to the newly allocated visual.
*/
static NPatchVisualPtr New( VisualFactoryCache& factoryCache, const std::string& imageUrl );
} // unnamed namespace
-PrimitiveVisualPtr PrimitiveVisual::New( VisualFactoryCache& factoryCache )
+PrimitiveVisualPtr PrimitiveVisual::New( VisualFactoryCache& factoryCache, const Property::Map& properties )
{
- return new PrimitiveVisual( factoryCache );
+ PrimitiveVisualPtr primitiveVisualPtr( new PrimitiveVisual( factoryCache ) );
+ primitiveVisualPtr->SetProperties( properties );
+ return primitiveVisualPtr;
}
PrimitiveVisual::PrimitiveVisual( VisualFactoryCache& factoryCache )
* @brief Create a new primitive visual.
*
* @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
+ * @param[in] properties A Property::Map containing settings for this visual
* @return A smart-pointer to the newly allocated visual.
*/
- static PrimitiveVisualPtr New( VisualFactoryCache& factoryCache );
+ static PrimitiveVisualPtr New( VisualFactoryCache& factoryCache, const Property::Map& properties );
public: // from Visual
namespace Internal
{
+SvgVisualPtr SvgVisual::New( VisualFactoryCache& factoryCache, const std::string& imageUrl, const Property::Map& properties )
+{
+ SvgVisualPtr svgVisual( new SvgVisual( factoryCache ) );
+ svgVisual->ParseFromUrl( imageUrl );
+ svgVisual->SetProperties( properties );
+
+ return svgVisual;
+}
+
SvgVisualPtr SvgVisual::New( VisualFactoryCache& factoryCache, const std::string& imageUrl )
{
- SvgVisual* svgVisual = new SvgVisual( factoryCache );
+ SvgVisualPtr svgVisual( new SvgVisual( factoryCache ) );
svgVisual->ParseFromUrl( imageUrl );
+
return svgVisual;
}
*
* @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
* @param[in] imageUrl The URL to svg resource to use
+ * @param[in] properties A Property::Map containing settings for this visual
+ * @return A smart-pointer to the newly allocated visual.
+ */
+ static SvgVisualPtr New( VisualFactoryCache& factoryCache, const std::string& imageUrl, const Property::Map& properties );
+
+ /**
+ * @brief Create the SVG Visual using the image URL.
+ *
+ * The visual will parse the SVG image once it is set.
+ * And rasterize it into BufferImage synchronously when the associated actor is put on stage, and destroy the BufferImage when it is off stage
+ *
+ * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
+ * @param[in] imageUrl The URL to svg resource to use
+ * @return A smart-pointer to the newly allocated visual.
*/
static SvgVisualPtr New( VisualFactoryCache& factoryCache, const std::string& imageUrl );
uniform mediump mat4 uMvpMatrix;\n
uniform mediump vec3 uSize;\n
uniform mediump vec4 pixelArea;
+
+ uniform mediump mat4 uModelMatrix;\n
+ uniform mediump mat4 uViewMatrix;\n
+ uniform mediump mat4 uProjection;\n
+
varying mediump vec2 vTexCoord;\n
\n
-
//Visual size and offset
uniform mediump vec2 offset;\n
uniform mediump vec2 size;\n
void main()\n
{\n
- mediump vec4 vertexPosition = uMvpMatrix *ComputeVertexPosition();\n
+ mediump vec4 nonAlignedVertex = uViewMatrix*uModelMatrix*ComputeVertexPosition();\n
+ mediump vec4 pixelAlignedVertex = vec4 ( floor(nonAlignedVertex.xyz), 1.0 );\n
+ mediump vec4 vertexPosition = uProjection*pixelAlignedVertex;\n
+
vTexCoord = pixelArea.xy+pixelArea.zw*(aPosition + vec2(0.5) );\n
gl_Position = vertexPosition;\n
}\n
} // unnamed namespace
-TextVisualPtr TextVisual::New( VisualFactoryCache& factoryCache )
+TextVisualPtr TextVisual::New( VisualFactoryCache& factoryCache, const Property::Map& properties )
{
- return new TextVisual( factoryCache );
+ TextVisualPtr TextVisualPtr( new TextVisual( factoryCache ) );
+ TextVisualPtr->SetProperties( properties );
+ return TextVisualPtr;
}
-float TextVisual::GetHeightForWidth( float width ) const
+float TextVisual::GetHeightForWidth( float width )
{
return mController->GetHeightForWidth( width );
}
mFactoryCache.SaveGeometry( VisualFactoryCache::QUAD_GEOMETRY , geometry );
}
- Shader shader = mFactoryCache.GetShader( VisualFactoryCache::IMAGE_SHADER_ATLAS_DEFAULT_WRAP );
- if( !shader )
- {
- shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_ATLAS_CLAMP );
- mFactoryCache.SaveShader( VisualFactoryCache::IMAGE_SHADER_ATLAS_DEFAULT_WRAP, shader );
- }
+ Shader shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_ATLAS_CLAMP );
+ mFactoryCache.SaveShader( VisualFactoryCache::IMAGE_SHADER_ATLAS_DEFAULT_WRAP, shader );
+
shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
mImpl->mRenderer = Renderer::New( geometry, shader );
PixelData data = mTypesetter->Render( relayoutSize );
Vector4 atlasRect = FULL_TEXTURE_RECT;
- TextureSet textureSet = mFactoryCache.GetAtlasManager()->Add( atlasRect, data );
- if( textureSet )
- {
- mImpl->mFlags |= Impl::IS_ATLASING_APPLIED;
- }
- else
- {
- // It may happen the image atlas can't handle a pixel data it exceeds the maximum size.
- // In that case, create a texture. TODO: should tile the text.
+ // Texture set not retrieved from Atlas Manager whilst pixel offset visible.
- Texture texture = Texture::New( Dali::TextureType::TEXTURE_2D,
- data.GetPixelFormat(),
- data.GetWidth(),
- data.GetHeight() );
+ // It may happen the image atlas can't handle a pixel data it exceeds the maximum size.
+ // In that case, create a texture. TODO: should tile the text.
- texture.Upload( data );
+ Texture texture = Texture::New( Dali::TextureType::TEXTURE_2D,
+ data.GetPixelFormat(),
+ data.GetWidth(),
+ data.GetHeight() );
- textureSet = TextureSet::New();
- textureSet.SetTexture( 0u, texture );
+ texture.Upload( data );
- mImpl->mFlags &= ~Impl::IS_ATLASING_APPLIED;
- }
+ TextureSet textureSet = TextureSet::New();
+ textureSet.SetTexture( 0u, texture );
+
+ mImpl->mFlags &= ~Impl::IS_ATLASING_APPLIED;
mImpl->mRenderer.RegisterProperty( ATLAS_RECT_UNIFORM_NAME, atlasRect );
* @brief Create a new text visual.
*
* @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
+ * @param[in] properties A Property::Map containing settings for this visual
* @return A smart-pointer to the newly allocated visual.
*/
- static TextVisualPtr New( VisualFactoryCache& factoryCache );
+ static TextVisualPtr New( VisualFactoryCache& factoryCache, const Property::Map& properties );
public: // from Visual::Base
/**
* @copydoc Visual::Base::GetHeightForWidth()
*/
- virtual float GetHeightForWidth( float width ) const;
+ virtual float GetHeightForWidth( float width );
/**
* @copydoc Visual::Base::GetNaturalSize()
}
Internal::Visual::Base::Impl::Transform::Transform()
-: mOffset(0.0f,0.0f),
- mSize(1.0f,1.0f),
- mOffsetSizeMode(0.0f,0.0f,0.0f,0.0f),
- mOrigin(Toolkit::Align::CENTER),
- mAnchorPoint(Toolkit::Align::CENTER)
+: mOffset( 0.0f,0.0f ),
+ mSize( 1.0f,1.0f ),
+ mOffsetSizeMode( 0.0f,0.0f,0.0f,0.0f ),
+ mOrigin( Toolkit::Align::CENTER ),
+ mAnchorPoint( Toolkit::Align::CENTER )
{
}
void Internal::Visual::Base::Impl::Transform::SetPropertyMap( const Property::Map& map )
{
- //Set default values
- mOffset = Vector2(0.0f,0.0f);
- mSize = Vector2(1.0f,1.0f);
- mOffsetSizeMode = Vector4(0.0f,0.0f,0.0f,0.0f);
+ // Set default values
+ mOffset = Vector2( 0.0f,0.0f );
+ mSize = Vector2( 1.0f,1.0f );
+ mOffsetSizeMode = Vector4( 0.0f,0.0f,0.0f,0.0f );
mOrigin = Toolkit::Align::CENTER;
mAnchorPoint = Toolkit::Align::CENTER;
for( Property::Map::SizeType i(0); i<map.Count(); ++i )
{
KeyValuePair keyValue = map.GetKeyValue( i );
- if( keyValue.first == Toolkit::DevelVisual::Transform::Property::OFFSET )
+ if( keyValue.first.type == Property::Key::INDEX )
{
- keyValue.second.Get( mOffset );
- }
- else if( keyValue.first == Toolkit::DevelVisual::Transform::Property::SIZE )
- {
- keyValue.second.Get( mSize );
- }
- else if( keyValue.first == Toolkit::DevelVisual::Transform::Property::ORIGIN )
- {
- Toolkit::Align::Type align(Toolkit::Align::CENTER);
- if( Scripting::GetEnumerationProperty< Toolkit::Align::Type >( keyValue.second, ALIGN_TABLE, ALIGN_TABLE_COUNT, align ) )
+ switch( keyValue.first.indexKey )
{
- mOrigin = align;
+ case Toolkit::DevelVisual::Transform::Property::OFFSET:
+ {
+ keyValue.second.Get( mOffset );
+ break;
+ }
+ case Toolkit::DevelVisual::Transform::Property::SIZE:
+ {
+ keyValue.second.Get( mSize );
+ break;
+ }
+ case Toolkit::DevelVisual::Transform::Property::ORIGIN:
+ {
+ Scripting::GetEnumerationProperty< Toolkit::Align::Type >( keyValue.second, ALIGN_TABLE, ALIGN_TABLE_COUNT, mOrigin );
+ break;
+ }
+ case Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT:
+ {
+ Scripting::GetEnumerationProperty< Toolkit::Align::Type >( keyValue.second, ALIGN_TABLE, ALIGN_TABLE_COUNT, mAnchorPoint );
+ break;
+ }
+ case Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE:
+ {
+ keyValue.second.Get( mOffsetSizeMode );
+ break;
+ }
}
}
- else if( keyValue.first == Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT )
+ else // Key type is STRING
{
- Toolkit::Align::Type align(Toolkit::Align::CENTER);
- if( Scripting::GetEnumerationProperty< Toolkit::Align::Type >( keyValue.second, ALIGN_TABLE, ALIGN_TABLE_COUNT, align ) )
+ if( keyValue.first == "offset" )
{
- mAnchorPoint = align;
+ keyValue.second.Get( mOffset );
+ }
+ else if( keyValue.first == "size" )
+ {
+ keyValue.second.Get( mSize );
+ }
+ else if( keyValue.first == "origin" )
+ {
+ Toolkit::Align::Type align(Toolkit::Align::CENTER);
+ if( Scripting::GetEnumerationProperty< Toolkit::Align::Type >( keyValue.second, ALIGN_TABLE, ALIGN_TABLE_COUNT, align ) )
+ {
+ mOrigin = align;
+ }
+ }
+ else if( keyValue.first == "anchorPoint" )
+ {
+ Toolkit::Align::Type align(Toolkit::Align::CENTER);
+ if( Scripting::GetEnumerationProperty< Toolkit::Align::Type >( keyValue.second, ALIGN_TABLE, ALIGN_TABLE_COUNT, align ) )
+ {
+ mAnchorPoint = align;
+ }
+ }
+ else if( keyValue.first == "offsetSizeMode" )
+ {
+ keyValue.second.Get( mOffsetSizeMode );
}
- }
- else if( keyValue.first == Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE )
- {
- keyValue.second.Get( mOffsetSizeMode );
}
}
}
struct Base::Impl
{
+ /**
+ * Constructor
+ */
+ Impl();
+
+ /**
+ * Destructor
+ */
+ ~Impl();
+
enum Flags
{
IS_ON_STAGE = 1,
struct CustomShader
{
+ CustomShader( const Property::Map& map );
+ void SetPropertyMap( const Property::Map& map );
+ void CreatePropertyMap( Property::Map& map ) const;
+
std::string mVertexShader;
std::string mFragmentShader;
Dali::ImageDimensions mGridSize;
Dali::Shader::Hint::Value mHints; //(bitfield) values from enum Shader::Hint
-
- CustomShader( const Property::Map& map );
- void SetPropertyMap( const Property::Map& map );
- void CreatePropertyMap( Property::Map& map ) const;
};
struct Transform
{
- Vector2 mOffset;
- Vector2 mSize;
- Vector4 mOffsetSizeMode;
- Toolkit::Align::Type mOrigin;
- Toolkit::Align::Type mAnchorPoint;
-
Transform();
void SetPropertyMap( const Property::Map& map );
void GetPropertyMap( Property::Map& map ) const;
void RegisterUniforms( Renderer renderer, Toolkit::Direction::Type direction );
Vector2 GetVisualSize( const Vector2& controlSize );
+
+ Vector2 mOffset;
+ Vector2 mSize;
+ Vector4 mOffsetSizeMode;
+ Toolkit::Align::Type mOrigin;
+ Toolkit::Align::Type mAnchorPoint;
};
Renderer mRenderer;
Size mControlSize;
float mDepthIndex;
int mFlags;
-
- Impl();
- ~Impl();
};
} // namespace Visual
#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
#include <dali-toolkit/internal/visuals/visual-string-constants.h>
+namespace
+{
+#if defined(DEBUG_ENABLED)
+Debug::Filter* gVisualBaseLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_VISUAL_BASE" );
+#endif
+}
+
namespace Dali
{
void Visual::Base::SetProperties( const Property::Map& propertyMap )
{
- Property::Value* customShaderValue = propertyMap.Find( DevelVisual::Property::SHADER, CUSTOM_SHADER );
- if( customShaderValue )
+ for( size_t i = 0; i < propertyMap.Count(); ++i )
{
- Property::Map shaderMap;
- if( customShaderValue->Get( shaderMap ) )
+ const KeyValuePair& pair = propertyMap.GetKeyValue( i );
+ const Property::Key& key = pair.first;
+ const Property::Value& value = pair.second;
+ switch( key.indexKey )
{
- SetCustomShader( shaderMap );
- }
- }
-
- Property::Value* transform = propertyMap.Find( DevelVisual::Property::TRANSFORM, TRANSFORM );
- if( transform )
- {
- Property::Map map;
- if( transform->Get( map ) )
- {
- mImpl->mTransform.SetPropertyMap( map );
+ case DevelVisual::Property::SHADER:
+ {
+ Property::Map shaderMap;
+ if( value.Get( shaderMap ) )
+ {
+ SetCustomShader( shaderMap );
+ }
+ break;
+ }
+
+ case DevelVisual::Property::TRANSFORM:
+ {
+ Property::Map map;
+ if( value.Get( map ) )
+ {
+ mImpl->mTransform.SetPropertyMap( map );
+ }
+ break;
+ }
+
+ case DevelVisual::Property::PREMULTIPLIED_ALPHA:
+ {
+ bool premultipliedAlpha = false;
+ if( value.Get( premultipliedAlpha ) )
+ {
+ EnablePreMultipliedAlpha( premultipliedAlpha );
+ }
+ break;
+ }
}
}
{
mImpl->mControlSize = controlSize;
mImpl->mTransform.SetPropertyMap( transform );
+
+#if defined(DEBUG_ENABLED)
+ std::ostringstream oss;
+ oss << transform;
+ DALI_LOG_INFO( gVisualBaseLogFilter, Debug::General, "Visual::Base::SetTransformAndSize(%s) - [\e[1;32mtransform: %s controlSize: (%3.1f, %3.1f)]\e[0m\n",
+ GetName().c_str(), oss.str().c_str(), controlSize.x, controlSize.y );
+#endif
+
OnSetTransform();
}
return mImpl->mName;
}
-float Visual::Base::GetHeightForWidth( float width ) const
+float Visual::Base::GetHeightForWidth( float width )
{
- return 0.f;
+ float aspectCorrectedHeight = 0.f;
+ Vector2 naturalSize;
+ GetNaturalSize( naturalSize );
+ if( naturalSize.width )
+ {
+ aspectCorrectedHeight = naturalSize.height * width / naturalSize.width;
+ }
+ return aspectCorrectedHeight;
+}
+
+float Visual::Base::GetWidthForHeight( float height )
+{
+ float aspectCorrectedWidth = 0.f;
+ Vector2 naturalSize;
+ GetNaturalSize( naturalSize );
+ if( naturalSize.height > 0.0f )
+ {
+ aspectCorrectedWidth = naturalSize.width * height / naturalSize.height;
+ }
+ return aspectCorrectedWidth;
}
void Visual::Base::GetNaturalSize( Vector2& naturalSize )
Property::Map transform;
mImpl->mTransform.GetPropertyMap( transform );
map.Insert( DevelVisual::Property::TRANSFORM, transform );
+
+ bool premultipliedAlpha( IsPreMultipliedAlphaEnabled() );
+ map.Insert( DevelVisual::Property::PREMULTIPLIED_ALPHA, premultipliedAlpha );
}
void Visual::Base::EnablePreMultipliedAlpha( bool preMultipled )
{
- if(preMultipled)
+ if( preMultipled )
{
mImpl->mFlags |= Impl::IS_PREMULTIPLIED_ALPHA;
}
return mImpl->mFlags & Impl::IS_FROM_CACHE;
}
+Renderer Visual::Base::GetRenderer()
+{
+ return mImpl->mRenderer;
+}
+
} // namespace Internal
} // namespace Toolkit
#include <dali/public-api/common/intrusive-ptr.h>
#include <dali/public-api/images/image-operations.h>
#include <dali/public-api/object/base-object.h>
+#include <dali/public-api/rendering/renderer.h>
#include <dali/public-api/rendering/shader.h>
// INTERNAL INCLUDES
/**
* @copydoc Toolkit::Visual::Base::GetHeightForWidth
*/
- virtual float GetHeightForWidth( float width ) const;
+ virtual float GetHeightForWidth( float width );
+
+ /**
+ * @copydoc Toolkit::Visual::Base::GetWidthForHeight
+ */
+ virtual float GetWidthForHeight( float height );
/**
* @copydoc Toolkit::Visual::Base::GetNaturalSize
*/
Dali::Property::Value GetProperty( Dali::Property::Index index );
+ /**
+ * Gets currently staged renderer, or an empty handle if not staged
+ */
+ Renderer GetRenderer();
+
protected:
/**
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/text-visual-properties.h>
#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/internal/visuals/border/border-visual.h>
#include <dali-toolkit/internal/visuals/color/color-visual.h>
DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::Visual, IMAGE )
DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::Visual, MESH )
DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::Visual, PRIMITIVE )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::DevelVisual, TEXT )
DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::Visual, WIREFRAME )
DALI_ENUM_TO_STRING_TABLE_END( VISUAL_TYPE )
{
case Toolkit::Visual::BORDER:
{
- visualPtr = BorderVisual::New( *( mFactoryCache.Get() ) );
+ visualPtr = BorderVisual::New( *( mFactoryCache.Get() ), propertyMap );
break;
}
case Toolkit::Visual::COLOR:
{
- visualPtr = ColorVisual::New( *( mFactoryCache.Get() ) );
+ visualPtr = ColorVisual::New( *( mFactoryCache.Get() ), propertyMap );
break;
}
case Toolkit::Visual::GRADIENT:
{
- visualPtr = GradientVisual::New( *( mFactoryCache.Get() ) );
+ visualPtr = GradientVisual::New( *( mFactoryCache.Get() ), propertyMap );
break;
}
UrlType::Type type = ResolveUrlType( imageUrl );
if( UrlType::N_PATCH == type )
{
- visualPtr = NPatchVisual::New( *( mFactoryCache.Get() ), imageUrl );
+ visualPtr = NPatchVisual::New( *( mFactoryCache.Get() ), imageUrl, propertyMap );
}
else if( UrlType::SVG == type )
{
- visualPtr = SvgVisual::New( *( mFactoryCache.Get() ), imageUrl );
+ visualPtr = SvgVisual::New( *( mFactoryCache.Get() ), imageUrl, propertyMap );
}
else // Regular image
{
if( batchingEnabled )
{
- visualPtr = BatchImageVisual::New( *( mFactoryCache.Get() ), imageUrl );
- break;
+ visualPtr = BatchImageVisual::New( *( mFactoryCache.Get() ), imageUrl, propertyMap );
}
else
{
- visualPtr = ImageVisual::New( *( mFactoryCache.Get() ), imageUrl );
+ visualPtr = ImageVisual::New( *( mFactoryCache.Get() ), imageUrl, propertyMap );
}
}
}
case Toolkit::Visual::MESH:
{
- visualPtr = MeshVisual::New( *( mFactoryCache.Get() ) );
+ visualPtr = MeshVisual::New( *( mFactoryCache.Get() ), propertyMap );
break;
}
case Toolkit::Visual::PRIMITIVE:
{
- visualPtr = PrimitiveVisual::New( *( mFactoryCache.Get() ) );
+ visualPtr = PrimitiveVisual::New( *( mFactoryCache.Get() ), propertyMap );
break;
}
case Toolkit::DevelVisual::TEXT:
{
- visualPtr = TextVisual::New( *( mFactoryCache.Get() ) );
+ visualPtr = TextVisual::New( *( mFactoryCache.Get() ), propertyMap );
break;
}
}
}
- if( visualPtr )
- {
- visualPtr->SetProperties( propertyMap );
- }
- else
+ if( !visualPtr )
{
DALI_LOG_ERROR( "Renderer type unknown\n" );
}
extern const char * const ORIGIN( "origin" );
extern const char * const ANCHOR_POINT( "anchorPoint" );
+// Premultipled alpha
+extern const char * const PREMULTIPLIED_ALPHA( "premultipliedAlpha" );
+
// Image visual
const char * const IMAGE_URL_NAME( "url" );
const char * const ATLAS_RECT_UNIFORM_NAME ( "uAtlasRect" );
extern const char * const CUSTOM_SUBDIVIDE_GRID_Y;
extern const char * const CUSTOM_SHADER_HINTS;
-//Transform
+// Transform
extern const char * const TRANSFORM;
extern const char * const SIZE;
extern const char * const OFFSET;
extern const char * const ORIGIN;
extern const char * const ANCHOR_POINT;
+// Premultiplied alpha
+extern const char * const PREMULTIPLIED_ALPHA;
// Image visual
extern const char * const IMAGE_URL_NAME;
*/
// CLASS HEADER
-
#include <dali-toolkit/public-api/controls/buttons/button.h>
-// INTERNAL INCLUDES
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/object/property-map.h>
+#include <dali/public-api/images/resource-image.h>
+// INTERNAL INCLUDES
#include <dali-toolkit/internal/controls/buttons/button-impl.h>
#include <dali-toolkit/public-api/controls/image-view/image-view.h>
+#include <dali-toolkit/devel-api/visuals/text-visual-properties.h>
namespace Dali
{
void Button::SetDisabled( bool disabled )
{
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetDisabled() is deprecated and will be removed from next release. Use SetProperty DISABLED or Styling file instead.\n" );
+
Dali::Toolkit::GetImplementation( *this ).SetDisabled( disabled );
}
bool Button::IsDisabled() const
{
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: IsDisabled() is deprecated and will be removed from next release. Use GetProperty DISABLED instead.\n" );
+
return Dali::Toolkit::GetImplementation( *this ).IsDisabled();
}
void Button::SetAutoRepeating( bool autoRepeating )
{
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetAutoRepeating() is deprecated and will be removed from next release. Use SetProperty AUTO_REPEATING or Styling file instead.\n" );
+
Dali::Toolkit::GetImplementation( *this ).SetAutoRepeating( autoRepeating );
}
bool Button::IsAutoRepeating() const
{
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: IsAutoRepeating() is deprecated and will be removed from next release. Use GetProperty AUTO_REPEATING instead.\n" );
+
return Dali::Toolkit::GetImplementation( *this ).IsAutoRepeating();
}
void Button::SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay )
{
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetInitialAutoRepeatingDelay() is deprecated and will be removed from next release. Use SetProperty INITIAL_AUTO_REPEATING_DELAY or Styling file instead.\n" );
+
Dali::Toolkit::GetImplementation( *this ).SetInitialAutoRepeatingDelay( initialAutoRepeatingDelay );
}
float Button::GetInitialAutoRepeatingDelay() const
{
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetPositionInheritanceMode() is deprecated and will be removed from next release. Use GetProperty INITIAL_AUTO_REPEATING_DELAY or Styling file instead.\n" );
+
return Dali::Toolkit::GetImplementation( *this ).GetInitialAutoRepeatingDelay();
}
void Button::SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay )
{
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetNextAutoRepeatingDelay() is deprecated and will be removed from next release. Use SetProperty NEXT_AUTO_REPEATING_DELAY or Styling file instead.\n" );
+
Dali::Toolkit::GetImplementation( *this ).SetNextAutoRepeatingDelay( nextAutoRepeatingDelay );
}
float Button::GetNextAutoRepeatingDelay() const
{
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetNextAutoRepeatingDelay() is deprecated and will be removed from next release. Use GetProperty NEXT_AUTO_REPEATING_DELAY instead.\n" );
+
return Dali::Toolkit::GetImplementation( *this ).GetNextAutoRepeatingDelay();
}
void Button::SetTogglableButton( bool togglable )
{
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetTogglableButton() is deprecated and will be removed from next release. Use SetProperty TOGGLABLE or Styling file instead.\n" );
+
Dali::Toolkit::GetImplementation( *this ).SetTogglableButton( togglable );
}
bool Button::IsTogglableButton() const
{
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: IsTogglableButton() is deprecated and will be removed from next release. Use GetProperty TOGGLABLE instead.\n" );
+
return Dali::Toolkit::GetImplementation( *this ).IsTogglableButton();
}
void Button::SetSelected( bool selected )
{
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetSelected() is deprecated and will be removed from next release. Use SetProperty SELECTED instead.\n" );
+
Dali::Toolkit::GetImplementation( *this ).SetSelected( selected );
}
bool Button::IsSelected() const
{
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: IsSelected() is deprecated and will be removed from next release. Use GetProperty SELECTED instead.\n" );
+
return Dali::Toolkit::GetImplementation( *this ).IsSelected();
}
void Button::SetAnimationTime( float animationTime )
{
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetAnimationTime() is deprecated and will be removed from next release. Use Styling file to set animation instead.\n" );
+
Dali::Toolkit::GetImplementation( *this ).SetAnimationTime( animationTime );
}
float Button::GetAnimationTime() const
{
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetAnimationTime() is deprecated and will be removed from next release.\n" );
+
return Dali::Toolkit::GetImplementation( *this ).GetAnimationTime();
}
void Button::SetLabelText( const std::string& label )
{
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetLabelText() is deprecated and will be removed from next release. Use SetProperty LABEL or Styling file instead.\n" );
+
Dali::Toolkit::GetImplementation( *this ).SetLabelText( label );
}
std::string Button::GetLabelText() const
{
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetLabelText() is deprecated and will be removed from next release. Use GetProperty LABEL instead.\n" );
+
return Dali::Toolkit::GetImplementation( *this ).GetLabelText();
}
void Button::SetUnselectedImage( const std::string& filename )
{
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetUnselectedImage() is deprecated and will be removed from next release. Use SetProperty UNSELECTED_STATE_IMAGE or Styling file instead.\n" );
+
Dali::Toolkit::GetImplementation( *this ).SetUnselectedImage( filename );
}
void Button::SetBackgroundImage( const std::string& filename )
{
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetBackgroundImage() is deprecated and will be removed from next release. Use Styling file instead.\n" );
+
Dali::Toolkit::GetImplementation( *this ).SetBackgroundImage( filename );
}
void Button::SetSelectedImage( const std::string& filename )
{
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetSelectedImage() is deprecated and will be removed from next release. Use SetProperty SELECTED_STATE_IMAGE or Styling file instead.\n" );
+
Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( filename );
}
void Button::SetSelectedBackgroundImage( const std::string& filename )
{
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetSelectedBackgroundImage() is deprecated and will be removed from next release. Use Styling file instead.\n" );
+
Dali::Toolkit::GetImplementation( *this ).SetSelectedBackgroundImage( filename );
}
void Button::SetDisabledBackgroundImage( const std::string& filename )
{
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetDisabledBackgroundImage() is deprecated and will be removed from next release. Use SetProperty DISABLED_STATE_IMAGE or Styling file instead.\n" );
+
Dali::Toolkit::GetImplementation( *this ).SetDisabledBackgroundImage( filename );
}
void Button::SetDisabledImage( const std::string& filename )
{
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetDisabledImage() is deprecated and will be removed from next release. Use Styling file instead.\n" );
+
Dali::Toolkit::GetImplementation( *this ).SetDisabledImage( filename );
}
void Button::SetDisabledSelectedImage( const std::string& filename )
{
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetDisabledSelectedImage() is deprecated and will be removed from next release. Use Styling file instead.\n" );
+
Dali::Toolkit::GetImplementation( *this ).SetDisabledSelectedImage( filename );
}
void Button::SetLabel( Actor label )
{
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetLabel() is deprecated and will be removed from next release. Use SetProperty LABEL instead.\n" );
+
Dali::Toolkit::GetImplementation( *this ).SetLabel( label );
}
void Button::SetButtonImage( Image image )
{
- Actor imageView = Toolkit::ImageView::New( image );
- imageView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
- Dali::Toolkit::GetImplementation( *this ).SetButtonImage( imageView );
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetButtonImage() is deprecated and will be removed from next release. Use Styling file instead.\n" );
+
+ Dali::Toolkit::GetImplementation( *this ).SetButtonImage( image );
}
void Button::SetSelectedImage( Image image )
{
- Actor imageView = Toolkit::ImageView::New( image );
- imageView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
- Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( imageView );
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetSelectedImage() is deprecated and will be removed from next release. Use Styling file instead.\n" );
+
+ Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( image );
}
Actor Button::GetButtonImage() const
{
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetButtonImage() is deprecated and will be removed from next release.\n" );
+
return Dali::Toolkit::GetImplementation( *this ).GetButtonImage();
}
Actor Button::GetSelectedImage() const
{
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetSelectedImage() is deprecated and will be removed from next release.\n" );
+
return Dali::Toolkit::GetImplementation( *this ).GetSelectedImage();
}
-
Button::Button( Internal::Button& implementation )
: Control( implementation )
{
*/
/**
- * @brief Button is a base class for different kind of buttons.
+ * @brief Button is a base class for different kinds of buttons.
*
* This class provides the disabled property and the clicked signal.
*
* When \e togglable is set to \e true, a Button::StateChangedSignal() signal is emitted, with the selected state.
* </ul>
*
- * The button's appearance can be modified by setting properties for the various image filenames.
+ * 'Visual' describes not just traditional images like png, bmp but refers to whatever is used to show the button, it could be a color, gradient or some other kind of renderer.
*
- * The \e background is always shown and doesn't change if the button is pressed or released. The \e button image is shown over the \e background image when the
- * button is not pressed and is replaced by the \e selected image when the button is pressed. The text label is placed always on the top of all images.
+ * The button's appearance can be modified by setting properties for the various visuals/images.
*
- * When the button is disabled, \e background, \e button and \e selected images are replaced by their \e disabled images.
+ * It is not mandatory to set all visuals. A button could be defined only by setting its \e background visual or by setting its \e background and \e selected visuals.
+ *
+ * The \e button visual is shown over the \e background visual.
+ * When pressed the unselected visuals are replaced by the \e selected visual. The text label is always placed on the top of all images.
+ *
+ * When the button is disabled, \e background, \e button and \e selected visuals are replaced by their \e disabled visuals.
*
- * Is not mandatory to set all images. A button could be defined only by setting its \e background image or by setting its \e background and \e selected images.
*
* Signals
* | %Signal Name | Method |
*/
struct Property
{
+ /**
+ * @brief An enumeration of properties belonging to the Button class.
+ * @SINCE_1_0.0
+ */
enum
{
- DISABLED = PROPERTY_START_INDEX, ///< name "disabled", @see SetDisabled(), type bool @SINCE_1_0.0
- AUTO_REPEATING, ///< name "autoRepeating", @see SetAutoRepeating(), type bool @SINCE_1_0.0
- INITIAL_AUTO_REPEATING_DELAY, ///< name "initialAutoRepeatingDelay", @see SetInitialAutoRepeatingDelay(), type float @SINCE_1_0.0
- NEXT_AUTO_REPEATING_DELAY, ///< name "nextAutoRepeatingDelay", @see SetNextAutoRepeatingDelay(), type float @SINCE_1_0.0
- TOGGLABLE, ///< name "togglable", @see SetTogglableButton(), type bool @SINCE_1_0.0
- SELECTED, ///< name "selected", @see SetSelected(), type bool @SINCE_1_0.0
- UNSELECTED_STATE_IMAGE, ///< name "unselectedStateImage", @see SetUnselectedImage(), type std::string @SINCE_1_0.0
- SELECTED_STATE_IMAGE, ///< name "selectedStateImage", @see SetSelectedImage(), type std::string @SINCE_1_0.0
- DISABLED_STATE_IMAGE, ///< name "disabledStateImage", @see SetDisabledImage(), type std::string @SINCE_1_0.0
- UNSELECTED_COLOR, ///< name "unselectedColor", type Vector4 @SINCE_1_0.0
- SELECTED_COLOR, ///< name "selectedColor", type Vector4 @SINCE_1_0.0
- LABEL, ///< name "label", type Property::Map @SINCE_1_0.0
-
- // Deprecated properties:
- LABEL_TEXT, ///< name "labelText", @see SetLabelText(), type std::string @SINCE_1_0.0
+ /**
+ * @brief name "disabled", type bool
+ * @details Sets the button as \e disabled.
+ * @SINCE_1_0.0
+ */
+ DISABLED = PROPERTY_START_INDEX,
+
+ /**
+ * @brief name "autoRepeating", type bool
+ * @details If the \e autorepeating property is set to \e true then the \e togglable property is set to false
+ * @SINCE_1_0.0
+ */
+ AUTO_REPEATING,
+
+ /**
+ * @brief name "initialAutoRepeatingDelay", type float
+ * @details By default this value is set to 0.15 seconds.
+ * @SINCE_1_0.0
+ */
+ INITIAL_AUTO_REPEATING_DELAY,
+
+ /**
+ * @brief name "nextAutoRepeatingDelay", type float
+ * @details default this value is set to 0.05 seconds
+ * @SINCE_1_0.0
+ */
+ NEXT_AUTO_REPEATING_DELAY,
+
+ /**
+ * @brief name "togglable", type bool
+ * @details If the \e togglable property is set to \e true, then the \e autorepeating property is set to false.
+ * @SINCE_1_0.0
+ */
+ TOGGLABLE,
+
+ /**
+ * @brief name "selected", type bool
+ * @details Sets the togglable button as either selected or unselected, \e togglable property must be set to \e true.
+ * @SINCE_1_0.0
+ */
+ SELECTED,
+
+ /**
+ * @DEPRECATED_1_1.XX Use UNSELECTED_VISUAL
+ * @brief name "unselectedStateImage", type string if it is a url, map otherwise
+ * @details Sets the unselected button foreground image
+ * @SINCE_1_0.0
+ */
+ UNSELECTED_STATE_IMAGE,
+
+ /**
+ * @DEPRECATED_1_1.XX Use SELECTED_VISUAL
+ * @brief name "selectedStateImage", type string if it is a url, map otherwise
+ * @details Sets the selected button foreground image
+ * @SINCE_1_0.0
+ */
+ SELECTED_STATE_IMAGE,
+
+ /**
+ * @DEPRECATED_1_1.XX Use DISABLED_UNSELECTED_VISUAL
+ * @brief name "disabledStateImage", type string if it is a url, map otherwise
+ * @details Sets the disabled whilst unselected foreground button visual
+ * @SINCE_1_0.0
+ */
+ DISABLED_STATE_IMAGE,
+
+ /**
+ * @DEPRECATED_1_1.XX Use UNSELECTED_BACKGROUND_VISUAL
+ * @brief name "unselectedColor", type Vector4
+ * @SINCE_1_0.0
+ */
+ UNSELECTED_COLOR,
+
+ /**
+ * @DEPRECATED_1_1.XX Use SELECTED_BACKGROUND_VISUAL
+ * @brief name "selectedColor", type Vector4
+ * @SINCE_1_0.0
+ */
+ SELECTED_COLOR,
+
+ /**
+ * @brief name "label", type Property::Map
+ * @SINCE_1_0.0
+ */
+ LABEL,
+
+ /**
+ * @DEPRECATED_1_1.32 Use LABEL
+ * @brief name "labelText", type std::string
+ * @SINCE_1_0.0
+ */
+ LABEL_TEXT
};
};
* @SINCE_1_0.0
* @param[in] disabled property.
*/
- void SetDisabled( bool disabled );
+ void SetDisabled( bool disabled ) DALI_DEPRECATED_API;
/**
* @DEPRECATED_1_1.32 Use GetProperty DISABLED
* @SINCE_1_0.0
* @return \e true if the button is \e disabled.
*/
- bool IsDisabled() const;
+ bool IsDisabled() const DALI_DEPRECATED_API;
/**
* @DEPRECATED_1_1.32 SetProperty AUTO_REPEATING or Styling file
* @SINCE_1_0.0
* @param[in] autoRepeating \e autorepeating property.
*/
- void SetAutoRepeating( bool autoRepeating );
+ void SetAutoRepeating( bool autoRepeating ) DALI_DEPRECATED_API;
/**
* @DEPRECATED_1_1.32 GetProperty AUTO_REPEATING
* @SINCE_1_0.0
* @return \e true if the \e autorepeating property is set.
*/
- bool IsAutoRepeating() const;
+ bool IsAutoRepeating() const DALI_DEPRECATED_API;
/**
* @DEPRECATED_1_1.32 SetProperty INITIAL_AUTO_REPEATING_DELAY or Styling file
* @param[in] initialAutoRepeatingDelay in seconds.
* @pre initialAutoRepeatingDelay must be greater than zero.
*/
- void SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay );
+ void SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay ) DALI_DEPRECATED_API;
/**
* @DEPRECATED_1_1.32 GetProperty INITIAL_AUTO_REPEATING_DELAY
* @SINCE_1_0.0
* @return the initial autorepeating delay in seconds.
*/
- float GetInitialAutoRepeatingDelay() const;
+ float GetInitialAutoRepeatingDelay() const DALI_DEPRECATED_API;
/**
* @DEPRECATED_1_1.32 SetProperty NEXT_AUTO_REPEATING_DELAY or Styling file
* @param[in] nextAutoRepeatingDelay in seconds.
* @pre nextAutoRepeatingDelay must be greater than zero.
*/
- void SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay );
+ void SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay ) DALI_DEPRECATED_API;
/**
* @DEPRECATED_1_1.32 GetProperty NEXT_AUTO_REPEATING_DELAY
* @SINCE_1_0.0
* @return the next autorepeating delay in seconds.
*/
- float GetNextAutoRepeatingDelay() const;
+ float GetNextAutoRepeatingDelay() const DALI_DEPRECATED_API;
/**
* @DEPRECATED_1_1.32 SetProperty TOGGLABLE or Styling file
* @SINCE_1_0.0
* @param[in] togglable property.
*/
- void SetTogglableButton( bool togglable );
+ void SetTogglableButton( bool togglable ) DALI_DEPRECATED_API;
/**
* @DEPRECATED_1_1.32 GetProperty TOGGLABLE
* @SINCE_1_0.0
* @return \e true if the \e togglable property is set.
*/
- bool IsTogglableButton() const;
+ bool IsTogglableButton() const DALI_DEPRECATED_API;
/**
* @DEPRECATED_1_1.32 SetProperty SELECTED
* @SINCE_1_0.0
* @param[in] selected property.
*/
- void SetSelected( bool selected );
+ void SetSelected( bool selected ) DALI_DEPRECATED_API;
/**
- * DEPRECATED_1_1.32 SetProperty SELECTED
+ * DEPRECATED_1_1.32 GetProperty SELECTED
*
* @brief Returns if the selected property is set and the button is togglable.
* @SINCE_1_0.0
* @return \e true if the button is \e selected.
*/
- bool IsSelected() const;
+ bool IsSelected() const DALI_DEPRECATED_API;
/**
* @DEPRECATED_1_1.32 Use Styling file to set animation
* @SINCE_1_0.0
* @param[in] animationTime The animation time in seconds.
*/
- void SetAnimationTime( float animationTime );
+ void SetAnimationTime( float animationTime ) DALI_DEPRECATED_API;
/**
* DEPRECATED_1_1.32 Use Styling file to set animation
* @SINCE_1_0.0
* @return The animation time in seconds.
*/
- float GetAnimationTime() const;
+ float GetAnimationTime() const DALI_DEPRECATED_API;
/**
- * @DEPRECATED_1_1.32 SetProperty LABEL or Styling file
+ * @DEPRECATED_1_1.32 SetProperty Property::LABEL or Styling file
*
* @brief Sets the button's label.
*
* @SINCE_1_0.0
* @param[in] label The label text.
*/
- void SetLabelText( const std::string& label );
+ void SetLabelText( const std::string& label ) DALI_DEPRECATED_API;
/**
* DEPRECATED_1_1.32 GetProperty LABEL
* @SINCE_1_0.0
* @return The label text.
*/
- std::string GetLabelText() const;
+ std::string GetLabelText() const DALI_DEPRECATED_API;
/**
- * @DEPRECATED_1_1.32 Use Styling file
+ * @DEPRECATED_1_1.32 Use Styling file Property::UNSELECTED_STATE_IMAGE
*
* @brief Sets the unselected button image.
*
* @SINCE_1_0.0
* @param[in] filename The button image.
*/
- void SetUnselectedImage( const std::string& filename );
+ void SetUnselectedImage( const std::string& filename ) DALI_DEPRECATED_API;
/**
- * @DEPRECATED_1_1.32 Use styling
+ * @DEPRECATED_1_1.32 Use styling Set Control::Property::BACKGROUND which is same as un-selected background
+ * Or use DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL
*
* @brief Sets the background image.
*
* @SINCE_1_0.0
* @param[in] filename The background image.
*/
- void SetBackgroundImage( const std::string& filename );
+ void SetBackgroundImage( const std::string& filename ) DALI_DEPRECATED_API;
/**
- * @DEPRECATED_1_1.32 Use styling file
+ * @DEPRECATED_1_1.32 Use styling file, Property::SELECTED_STATE_IMAGE
*
* @brief Sets the selected image.
*
* @SINCE_1_0.0
* @param[in] filename The selected image.
*/
- void SetSelectedImage( const std::string& filename );
+ void SetSelectedImage( const std::string& filename ) DALI_DEPRECATED_API;
/**
- * @DEPRECATED_1_1.32 Use styling file
+ * @DEPRECATED_1_1.32 Set Control::Property::BACKGROUND which is same as un-selected background
+ * Or use DevelButton::Property::SELECTED_BACKGROUND_VISUAL
*
* @brief Sets the selected background image.
*
* @SINCE_1_0.0
* @param[in] filename The selected background image.
*/
- void SetSelectedBackgroundImage( const std::string& filename );
+ void SetSelectedBackgroundImage( const std::string& filename ) DALI_DEPRECATED_API;
/**
- * @DEPRECATED_1_1.32 Use styling file
+ * @DEPRECATED_1_1.32 Only able to set Property::DISABLED_STATE_IMAGE
+ * Or use DevelButton::Property::DISABLED_SELECTED_BACKGROUND_VISUAL
*
* @brief Sets the disabled background image.
*
* @SINCE_1_0.0
* @param[in] filename The disabled background image.
*/
- void SetDisabledBackgroundImage( const std::string& filename );
+ void SetDisabledBackgroundImage( const std::string& filename ) DALI_DEPRECATED_API;
/**
- * @DEPRECATED_1_1.32 Use styling file
+ * @DEPRECATED_1_1.32 Use styling file Property::DISABLED_STATE_IMAGE
*
* @brief Sets the disabled button image.
*
* @SINCE_1_0.0
* @param[in] filename The disabled button image.
*/
- void SetDisabledImage( const std::string& filename );
+ void SetDisabledImage( const std::string& filename ) DALI_DEPRECATED_API;
/**
- * @DEPRECATED_1_1.32 Use styling file
+ * @DEPRECATED_1_1.32 Use Property::DISABLED_STATE_IMAGE which provides same disabled image for un/selected
+ * Or DevelButton::Property::DISABLED_SELECTED_VISUAL to disable selected visual.
*
* @brief Sets the disabled selected button image.
*
* @SINCE_1_0.0
* @param[in] filename The disabled selected button image.
*/
- void SetDisabledSelectedImage( const std::string& filename );
+ void SetDisabledSelectedImage( const std::string& filename ) DALI_DEPRECATED_API;
/**
* @DEPRECATED_1_0.50. Instead, use SetLabelText.
* @SINCE_1_0.0
* @param[in] label The actor to use as a label
*/
- void SetLabel( Actor label );
+ void SetLabel( Actor label ) DALI_DEPRECATED_API;
/**
* @DEPRECATED_1_0.50. Instead, use SetUnselectedImage.
* @SINCE_1_0.0
* @param[in] image The button image.
*/
- void SetButtonImage( Image image );
+ void SetButtonImage( Image image ) DALI_DEPRECATED_API;
/**
* @DEPRECATED_1_0.50. Instead, use SetSelectedImage( const std::string& filename ).
* @SINCE_1_0.0
* @param[in] image The selected image.
*/
- void SetSelectedImage( Image image );
+ void SetSelectedImage( Image image ) DALI_DEPRECATED_API;
/**
* @DEPRECATED_1_0.50
* @remarks Avoid using this method as it's a legacy code.
* @return An actor with the button image.
*/
- Actor GetButtonImage() const;
+ Actor GetButtonImage() const DALI_DEPRECATED_API;
/**
* @DEPRECATED_1_0.50
* @remarks Avoid using this method as it's a legacy code.
* @return An actor with the selected image.
*/
- Actor GetSelectedImage() const;
+ Actor GetSelectedImage() const DALI_DEPRECATED_API;
public: //Signals
*/
// CLASS HEADER
-
#include <dali-toolkit/public-api/controls/buttons/push-button.h>
-// INTERNAL INCLUDES
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/images/resource-image.h>
+
+// INTERNAL INCLUDES
#include <dali-toolkit/internal/controls/buttons/push-button-impl.h>
namespace Dali
void PushButton::SetButtonImage( Actor image )
{
- Dali::Toolkit::GetImplementation( *this ).SetButtonImage( image );
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetButtonImage() is deprecated and will be removed from next release. Use Button.SetProperty UNSELECTED_STATE_IMAGE or Styling file instead.\n" );
+
+ // Passing Image as Actor not supported
}
void PushButton::SetBackgroundImage( Actor image )
{
- Dali::Toolkit::GetImplementation( *this ).SetBackgroundImage( image );
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetBackgroundImage() is deprecated and will be removed from next release.\n" );
+
+ // Passing Image as Actor not supported}
}
void PushButton::SetSelectedImage( Actor image )
{
- Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( image );
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetSelectedImage() is deprecated and will be removed from next release. Use Button.SetProperty SELECTED_STATE_IMAGE or Styling file instead.\n" );
+
+ // Passing Image as Actor not supported}
}
void PushButton::SetSelectedBackgroundImage( Actor image )
{
- Dali::Toolkit::GetImplementation( *this ).SetSelectedBackgroundImage( image );
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetSelectedBackgroundImage() is deprecated and will be removed from next release.\n" );
+
+ // Passing Image as Actor not supported}
}
void PushButton::SetDisabledBackgroundImage( Actor image )
{
- Dali::Toolkit::GetImplementation( *this ).SetDisabledBackgroundImage( image );
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetDisabledBackgroundImage() is deprecated and will be removed from next release.\n" );
+ // Passing Image as Actor not supported}
}
void PushButton::SetDisabledImage( Actor image )
{
- Dali::Toolkit::GetImplementation( *this ).SetDisabledImage( image );
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetDisabledImage() is deprecated and will be removed from next release. Use Button.SetProperty DISABLED_STATE_IMAGE or Styling file instead.\n" );
+ // Passing Image as Actor not supported
}
void PushButton::SetDisabledSelectedImage( Actor image )
{
- Dali::Toolkit::GetImplementation( *this ).SetDisabledSelectedImage( image );
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetDisabledSelectedImage() is deprecated and will be removed from next release.\n" );
+ // Passing Image as Actor not supported
}
} // namespace Toolkit
*/
struct Property
{
+ /**
+ * @brief An enumeration of properties belonging to the PushButton class.
+ * @SINCE_1_0.0
+ */
enum
{
- UNSELECTED_ICON = PROPERTY_START_INDEX, ///< Property, name "unselectedIcon", type std::string @SINCE_1_0.0
- SELECTED_ICON, ///< Property, name "selectedIcon", type std::string @SINCE_1_0.0
- ICON_ALIGNMENT, ///< Property, name "iconAlignment", type std::string @SINCE_1_0.0
+ UNSELECTED_ICON = PROPERTY_START_INDEX, ///< Property, name "unselectedIcon", type std::string @SINCE_1_0.0 @DEPRECATED_1_2.XX Button::Property::UNSELECTED_VISUAL
+ SELECTED_ICON, ///< Property, name "selectedIcon", type std::string @SINCE_1_0.0 @DEPRECATED_1_2.XX Button::Property::SELECTED_VISUAL
+ ICON_ALIGNMENT, ///< Property, name "iconAlignment", type std::string @SINCE_1_0.0 @DEPRECATED_1_2.XX Use Button::Property::LABEL_RELATIVE_ALIGNMENT
LABEL_PADDING, ///< Property, name "labelPadding", type Vector4 @SINCE_1_0.0
ICON_PADDING, ///< Property, name "iconPadding", type Vector4 @SINCE_1_0.0
};
*/
static PushButton DownCast( BaseHandle handle );
-
+ ///////////////////////////////////////////////////////////////////////////
// Deprecated API
using Button::SetButtonImage;
* @SINCE_1_0.0
* @param[in] image The Actor to use.
*/
- void SetButtonImage( Actor image );
+ void SetButtonImage( Actor image ) DALI_DEPRECATED_API;
using Button::SetBackgroundImage;
* @SINCE_1_0.0
* @param[in] image The Actor to use.
*/
- void SetBackgroundImage( Actor image );
+ void SetBackgroundImage( Actor image ) DALI_DEPRECATED_API;
using Button::SetSelectedImage;
* @SINCE_1_0.0
* @param[in] image The Actor to use.
*/
- void SetSelectedImage( Actor image );
+ void SetSelectedImage( Actor image ) DALI_DEPRECATED_API;
using Button::SetSelectedBackgroundImage;
* @SINCE_1_0.0
* @param[in] image The Actor to use.
*/
- void SetSelectedBackgroundImage( Actor image );
+ void SetSelectedBackgroundImage( Actor image ) DALI_DEPRECATED_API;
using Button::SetDisabledBackgroundImage;
* @SINCE_1_0.0
* @param[in] image The Actor to use.
*/
- void SetDisabledBackgroundImage( Actor image );
+ void SetDisabledBackgroundImage( Actor image ) DALI_DEPRECATED_API;
using Button::SetDisabledImage;
* @SINCE_1_0.0
* @param[in] image The Actor to use.
*/
- void SetDisabledImage( Actor image );
+ void SetDisabledImage( Actor image ) DALI_DEPRECATED_API;
using Button::SetDisabledSelectedImage;
* @SINCE_1_0.0
* @param[in] image The Actor to use.
*/
- void SetDisabledSelectedImage( Actor image );
+ void SetDisabledSelectedImage( Actor image ) DALI_DEPRECATED_API;
public: // Not intended for application developers
#include <cstring> // for strcmp
#include <limits>
#include <stack>
+#include <typeinfo>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/animation/constraints.h>
#include <dali/public-api/object/type-registry.h>
{
#if defined(DEBUG_ENABLED)
-Debug::Filter* gLogFilter = Debug::Filter::New( Debug::General, false, "LOG_CONTROL_VISUALS");
+Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_CONTROL_VISUALS");
#endif
/**
{
#if defined(DEBUG_ENABLED)
std::ostringstream oss;
- oss << "Control::GetHandleIndex(" << visualName << ", " << propertyKey << ")" << std::endl;
+ oss << "Control::GetVisualProperty(" << visualName << ", " << propertyKey << ")" << std::endl;
DALI_LOG_INFO( gLogFilter, Debug::General, oss.str().c_str() );
#endif
RegisteredVisualContainer::Iterator iter;
for ( iter = visuals.Begin(); iter != visuals.End(); iter++ )
{
- if ( (*iter)->visual.GetName() == visualName )
+ Toolkit::Visual::Base visual = (*iter)->visual;
+ if( visual && visual.GetName() == visualName )
{
- break;
- }
- }
-
- // Does it's renderer have an associated property?
- if( iter != visuals.End() )
- {
- Actor self = controlImpl.Self();
- Property::Index index = DevelHandle::GetPropertyIndex( self, propertyKey );
- if( index != Property::INVALID_INDEX )
- {
- // It's an actor property:
- return HandleIndex( self, index );
- }
- else
- {
- // Check if it is a renderer property:
- if( self.GetRendererCount() > 0 )
+ Internal::Visual::Base& visualImpl = GetImplementation(visual);
+ Renderer renderer = visualImpl.GetRenderer();
+ if( renderer )
{
- // @todo Need to use correct renderer index
- Renderer renderer = self.GetRendererAt(0);
Property::Index index = DevelHandle::GetPropertyIndex( renderer, propertyKey );
if( index != Property::INVALID_INDEX )
{
- // It's a renderer property:
return HandleIndex( renderer, index );
}
}
- else
- {
- std::ostringstream oss;
- oss << propertyKey;
- DALI_LOG_WARNING( "Control::GetHandleIndex(%s, %s) No renderers\n", visualName.c_str(), oss.str().c_str() );
- }
}
}
+
+ std::ostringstream noRenderers;
+ noRenderers << propertyKey;
+ DALI_LOG_WARNING( "Control::GetVisualProperty(%s, %s) No renderers\n", visualName.c_str(), noRenderers.str().c_str() );
Handle handle;
return HandleIndex( handle, Property::INVALID_INDEX );
}
void Control::SetBackgroundImage( Image image )
{
- DALI_LOG_WARNING( "SetBackgroundImage is for the depreciated Property::BACKGROUND_IMAGE use SetBackground( const Property::Map& map )\n" );
Toolkit::Visual::Base visual = Toolkit::VisualFactory::Get().CreateVisual( image );
if( visual )
{
}
}
+ // If not set, set the name of the visual to the same name as the control's property.
+ // ( If the control has been type registered )
+ if( visual.GetName().empty() )
+ {
+ // Check if the control has been type registered:
+ TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(*this) );
+ if( typeInfo )
+ {
+ // Check if the property index has been registered:
+ Property::IndexContainer indices;
+ typeInfo.GetPropertyIndices( indices );
+ Property::IndexContainer::Iterator iter = std::find( indices.Begin(), indices.End(), index );
+ if( iter != indices.End() )
+ {
+ // If it has, then get it's name and use that for the visual
+ std::string visualName = typeInfo.GetPropertyName( index );
+ visual.SetName( visualName );
+ }
+ }
+ }
+
if( !visualReplaced ) // New registration entry
{
mImpl->mVisuals.PushBack( new RegisteredVisual( index, visual, enabled ) );
{
Toolkit::GetImplementation(visual).SetOnStage( self );
}
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::RegisterVisual number of registered visuals(%d)\n", mImpl->mVisuals.Size() );
+
}
void Control::UnregisterVisual( Property::Index index )
void Control::OnControlChildAdd( Actor& child )
{
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: OnControlChildAdd() is deprecated and will be removed from next release. Override OnChildAdd instead.\n" );
}
void Control::OnControlChildRemove( Actor& child )
{
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: OnControlChildRemove() is deprecated and will be removed from next release. Override OnChildRemove instead.\n" );
}
void Control::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
* @SINCE_1_0.0
* @param[in] child The added actor.
*/
- virtual void OnControlChildAdd( Actor& child );
+ virtual void OnControlChildAdd( Actor& child ) DALI_DEPRECATED_API;
/**
* @DEPRECATED_1_1.30. Override OnChildRemove instead.
* @SINCE_1_0.0
* @param[in] child The removed actor.
*/
- virtual void OnControlChildRemove( Actor& child );
+ virtual void OnControlChildRemove( Actor& child ) DALI_DEPRECATED_API;
// Styling
// CLASS HEADER
#include <dali-toolkit/public-api/controls/control.h>
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/control-impl.h>
void Control::SetBackgroundColor( const Vector4& color )
{
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetBackgroundImage() is deprecated and will be removed from next release. use Property::BACKGROUND instead.\n" );
+
Internal::GetImplementation(*this).SetBackgroundColor( color );
}
Vector4 Control::GetBackgroundColor() const
{
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetBackgroundColor() is deprecated and will be removed from next release. use Property::BACKGROUND instead.\n" );
+
return Internal::GetImplementation(*this).GetBackgroundColor();
}
*/
struct Property
{
+ /**
+ * @brief An enumeration of properties belonging to the Control class.
+ * @SINCE_1_0.0
+ */
enum
{
/**
* @SINCE_1_0.0
* @return The background color of the control.
*/
- Vector4 GetBackgroundColor() const;
+ Vector4 GetBackgroundColor() const DALI_DEPRECATED_API;
/**
- * @DEPRECATED_1_2.8, use Property::BACKGROUND instead
+ * @DEPRECATED_1_2_8, use Property::BACKGROUND instead
*
* @brief Sets an image as the background of the control.
*
* @SINCE_1_0.0
* @param[in] image The image to set as the background.
*/
- void SetBackgroundImage( Image image );
+ void SetBackgroundImage( Image image ) DALI_DEPRECATED_API;
/**
* @brief Clears the background.
*/
struct Property
{
+ /**
+ * @brief An enumeration of properties belonging to the FlexContainer class.
+ * @SINCE_1_1.35
+ */
enum
{
// Event side properties
*/
struct ChildProperty
{
+ /**
+ * @brief An enumeration of child properties belonging to the FlexContainer class.
+ * @SINCE_1_1.35
+ */
enum
{
// Event side child properties
#include <dali-toolkit/public-api/controls/image-view/image-view.h>
// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
#include <dali/public-api/images/resource-image.h>
#include <dali/public-api/object/property-map.h>
ImageView ImageView::New( Image image )
{
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: New() is deprecated and will be removed from next release. use New( const std::string& ) instead.\n" );
+
ImageView imageView = Internal::ImageView::New();
imageView.SetImage( image );
return imageView;
void ImageView::SetImage( Image image )
{
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetImage() is deprecated and will be removed from next release. Use SetImage( const std::string& ) instead.\n" );
+
Dali::Toolkit::GetImpl( *this ).SetImage( image );
}
Image ImageView::GetImage() const
{
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetImage() is deprecated and will be removed from next release.\n" );
+
return Dali::Toolkit::GetImpl( *this ).GetImage();
}
*/
struct Property
{
+ /**
+ * @brief An enumeration of properties belonging to the ImageView class.
+ * @SINCE_1_0.0
+ */
enum
{
// Event side properties
static ImageView New();
/**
- * @DEPRECATED_1_2.8, use New( const std::string& ) instead.
+ * @DEPRECATED_1_2_8, use New( const std::string& ) instead.
*
* @brief Create an initialized ImageView from an Image instance.
*
* @param[in] image The Image instance to display.
* @return A handle to a newly allocated ImageView.
*/
- static ImageView New( Image image );
+ static ImageView New( Image image ) DALI_DEPRECATED_API;
/**
* @brief Create an initialized ImageView from an URL to an image resource.
static ImageView DownCast( BaseHandle handle );
/**
- * @DEPRECATED_1_2.8, use SetImage( const std::string& ) instead.
+ * @DEPRECATED_1_2_8, use SetImage( const std::string& ) instead.
*
* @brief Sets this ImageView from an Image instance.
*
* @SINCE_1_0.0
* @param[in] image The Image instance to display.
*/
- void SetImage( Image image );
+ void SetImage( Image image ) DALI_DEPRECATED_API;
/**
* @brief Sets this ImageView from the given URL.
* @SINCE_1_0.0
* @return The Image instance currently used by the ImageView.
*/
- Image GetImage() const;
+ Image GetImage() const DALI_DEPRECATED_API;
public: // Not intended for application developers
*/
struct Property
{
+ /**
+ * @brief An enumeration of properties belonging to the TextLabel class.
+ * @SINCE_1_1.4
+ */
enum
{
GEOMETRY_URL = PROPERTY_START_INDEX, ///< name "geometryUrl", The path to the geometry file, type STRING @SINCE_1_1.4
*/
struct Property
{
+ /**
+ * @brief An enumeration of properties belonging to the ScrollBar class.
+ * @SINCE_1_0.0
+ */
enum
{
/**
*/
struct Property
{
+ /**
+ * @brief An enumeration of properties belonging to the ScrollView class.
+ * @SINCE_1_0.0
+ */
enum
{
// Event side properties
*/
struct Property
{
+ /**
+ * @brief An enumeration of properties belonging to the ScrollView class.
+ * @SINCE_1_0.0
+ */
enum
{
// Event side properties
*/
struct Property
{
+ /**
+ * @brief An enumeration of properties belonging to the Scrollable class.
+ * @SINCE_1_0.0
+ */
enum
{
// Event side properties
*/
struct Property
{
+ /**
+ * @brief An enumeration of properties belonging to the Slider class.
+ * @SINCE_1_1.39
+ */
enum
{
*/
struct Property
{
+ /**
+ * @brief An enumeration of properties belonging to the TableView class.
+ *
+ * @SINCE_1_0.0
+ */
enum
{
ROWS = PROPERTY_START_INDEX, ///< name "rows", type unsigned int @SINCE_1_0.0
*/
struct ChildProperty
{
+ /**
+ * @brief An enumeration of child properties belonging to the TableView class.
+ * @SINCE_1_1.36
+ */
enum
{
CELL_INDEX = CHILD_PROPERTY_START_INDEX, ///< name "cellIndex", The top-left cell this child occupies, if not set, the first available cell is used, type VECTOR2 @SINCE_1_1.36
*/
struct Property
{
+ /**
+ * @brief An enumeration of properties belonging to the TextEditor class.
+ * @SINCE_1_1.37
+ */
enum
{
RENDERING_BACKEND = PROPERTY_START_INDEX, ///< name "renderingBackend", The type or rendering e.g. bitmap-based, type INT @SINCE_1_1.37
*/
struct InputStyle
{
+ /**
+ * @brief Mask used by the signal InputStyleChangedSignal().
+ *
+ * @SINCE_1_2_2
+ */
enum Mask
{
NONE = 0x0000, ///< @SINCE_1_2_2
*/
struct Property
{
+ /**
+ * @brief An enumeration of properties belonging to the TextField class.
+ * @SINCE_1_0.0
+ */
enum
{
RENDERING_BACKEND = PROPERTY_START_INDEX, ///< name "renderingBackend", The type or rendering e.g. bitmap-based, type INT @SINCE_1_0.0
*/
struct InputStyle
{
+ /**
+ * @brief Mask used by the signal InputStyleChangedSignal().
+ *
+ * @SINCE_1_2_2
+ */
enum Mask
{
NONE = 0x0000, ///< @SINCE_1_2_2
*/
struct Property
{
+ /**
+ * @brief An enumeration of properties belonging to the TextLabel class.
+ * @SINCE_1_0.0
+ */
enum
{
/**
const unsigned int TOOLKIT_MAJOR_VERSION = 1;
const unsigned int TOOLKIT_MINOR_VERSION = 2;
-const unsigned int TOOLKIT_MICRO_VERSION = 17;
+const unsigned int TOOLKIT_MICRO_VERSION = 18;
const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
return GetImpl(*this).GetFocusIndicatorActor();
}
+void KeyboardFocusManager::MoveFocusBackward()
+{
+ return GetImpl(*this).MoveFocusBackward();
+}
+
KeyboardFocusManager::PreFocusChangeSignalType& KeyboardFocusManager::PreFocusChangeSignal()
{
return GetImpl(*this).PreFocusChangeSignal();
*/
Actor GetFocusIndicatorActor();
+ /**
+ * @brief Move the focus to prev focused actor
+ *
+ * @SINCE_1_2.17
+ */
+ void MoveFocusBackward();
+
public: // Signals
/**
{
"label":
{
- "pointSize":120,
- "fontStyle":{"weight":"light"}
+ "visualType":"TEXT",
+ "pointSize":120
+ },
+ "unselectedBackgroundVisual":
+ {
+ "visualType": "IMAGE",
+ "url": ""
+ },
+ "selectedBackgroundVisual":
+ {
+ "visualType": "IMAGE",
+ "url": ""
}
},
"TextSelectionToolbar":
"ProgressBarValueTextLabel":
{
"textColor":[0.8,0.8,1,1]
+ },
+ "Button":
+ {
+ "initialAutoRepeatingDelay":2.0,
+ "nextAutoRepeatingDelay":0.9
+ // Note: Visuals added to Button will be used in all derived buttons unless overridden.
+ },
+ "PushButton":
+ {
+ "styles":["Button"],
+ "autoRepeating":false,
+ "togglable":false,
+ "labelPadding":[ 12.0, 12.0, 12.0, 12.0 ],
+ "label":
+ {
+ "visualType": "TEXT",
+ "horizontalAlignment": "CENTER",
+ "pointSize" : 15.0, // Point size must always be provided to Text Visual
+ "verticalAlignment": "CENTER"
+ },
+ "unselectedBackgroundVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}button-up.9.png"
+ },
+ "selectedBackgroundVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}button-down.9.png"
+ },
+ "disabledSelectedBackgroundVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}button-down-disabled.9.png"
+ },
+ "disabledUnselectedBackgroundVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}button-disabled.9.png"
+ }
+ },
+ "CheckBoxButton":
+ {
+ "styles":["Button"],
+ "labelPadding":[ 12.0, 12.0, 0.0, 0.0 ],
+ "label":
+ {
+ "visualType": "TEXT",
+ "pointSize" : 15.0, // Point size must always be provided to Text Visual
+ "verticalAlignment": "CENTER"
+ },
+ "unselectedVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}checkbox-unselected.png"
+ },
+ "selectedVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}checkbox-selected.png"
+ },
+ "disabledUnselectedVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}checkbox-unselected-disabled.png"
+ },
+ "disabledSelectedVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}checkbox-selected-disabled.png"
+ }
+ },
+ "RadioButton":
+ {
+ "styles":["Button"],
+ "labelPadding":[ 12.0, 12.0, 0.0, 0.0 ],
+ "label":
+ {
+ "visualType": "TEXT",
+ "pointSize" : 15.0, // Point size must always be provided to Text Visual
+ "verticalAlignment": "CENTER"
+ },
+ "unselectedVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}radio-button-unselected.png"
+ },
+ "selectedVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}radio-button-selected.png"
+ },
+ "disabledUnselectedVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}radio-button-unselected-disabled.png"
+ },
+ "disabledSelectedVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}radio-button-selected-disabled.png"
+ }
}
}
}
{
"pointSize":25
},
- "RadioButton":
- {
- "unselectedStateImage":"{DALI_IMAGE_DIR}radio-button-unselected.png",
- "selectedStateImage":"{DALI_IMAGE_DIR}radio-button-selected.png",
- "disabledUnselectedStateImage":"{DALI_IMAGE_DIR}radio-button-unselected-disabled.png",
- "disabledSelectedStateImage":"{DALI_IMAGE_DIR}radio-button-selected-disabled.png"
- },
-
"TextField":
{
"pointSize":18,
{
"label":
{
- "pointSize":8,
- "fontStyle":{"weight":"light"}
+ "visualType":"TEXT",
+ "pointSize":8
+ },
+ "unselectedBackgroundVisual":
+ {
+ "visualType": "IMAGE",
+ "url": ""
+ },
+ "selectedBackgroundVisual":
+ {
+ "visualType": "IMAGE",
+ "url": ""
}
},
"TextSelectionToolbar":
"ProgressBarValueTextLabel":
{
"textColor":[0.8,0.8,1,1]
+ },
+ "Button":
+ {
+ "initialAutoRepeatingDelay":2.0,
+ "nextAutoRepeatingDelay":0.9
+ // Note: Visuals added to Button will be used in all derived buttons unless overridden.
+ },
+ "PushButton":
+ {
+ "styles":["Button"],
+ "autoRepeating":false,
+ "togglable":false,
+ "labelPadding":[ 12.0, 12.0, 12.0, 12.0 ],
+ "label":
+ {
+ "visualType": "TEXT",
+ "horizontalAlignment": "CENTER",
+ "pointSize" : 15.0, // Point size must always be provided to Text Visual
+ "verticalAlignment": "CENTER"
+ },
+ "unselectedBackgroundVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}button-up.9.png"
+ },
+ "selectedBackgroundVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}button-down.9.png"
+ },
+ "disabledSelectedBackgroundVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}button-down-disabled.9.png"
+ },
+ "disabledUnselectedBackgroundVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}button-disabled.9.png"
+ }
+ },
+ "CheckBoxButton":
+ {
+ "styles":["Button"],
+ "labelPadding":[ 12.0, 12.0, 0.0, 0.0 ],
+ "label":
+ {
+ "visualType": "TEXT",
+ "pointSize" : 15.0, // Point size must always be provided to Text Visual
+ "verticalAlignment": "CENTER"
+ },
+ "unselectedVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}checkbox-unselected.png"
+ },
+ "selectedVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}checkbox-selected.png"
+ },
+ "disabledUnselectedVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}checkbox-unselected-disabled.png"
+ },
+ "disabledSelectedVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}checkbox-selected-disabled.png"
+ }
+ },
+ "RadioButton":
+ {
+ "styles":["Button"],
+ "labelPadding":[ 12.0, 12.0, 0.0, 0.0 ],
+ "label":
+ {
+ "visualType": "TEXT",
+ "pointSize" : 15.0, // Point size must always be provided to Text Visual
+ "verticalAlignment": "CENTER"
+ },
+ "unselectedVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}radio-button-unselected.png"
+ },
+ "selectedVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}radio-button-selected.png"
+ },
+ "disabledUnselectedVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}radio-button-unselected-disabled.png"
+ },
+ "disabledSelectedVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}radio-button-selected-disabled.png"
+ }
}
}
}
{
"pointSize":25
},
- "RadioButton":
- {
- "unselectedStateImage":"{DALI_IMAGE_DIR}radio-button-unselected.png",
- "selectedStateImage":"{DALI_IMAGE_DIR}radio-button-selected.png",
- "disabledUnselectedStateImage":"{DALI_IMAGE_DIR}radio-button-unselected-disabled.png",
- "disabledSelectedStateImage":"{DALI_IMAGE_DIR}radio-button-selected-disabled.png"
- },
-
"TextField":
{
"pointSize":18,
{
"label":
{
- "pointSize":8,
- "fontStyle":{"weight":"light"}
+ "visualType":"TEXT",
+ "pointSize":8
+ },
+ "unselectedBackgroundVisual":
+ {
+ "visualType": "IMAGE",
+ "url": ""
+ },
+ "selectedBackgroundVisual":
+ {
+ "visualType": "IMAGE",
+ "url": ""
}
},
"TextSelectionToolbar":
"ProgressBarValueTextLabel":
{
"textColor":[0.8,0.8,1,1]
+ },
+ "Button":
+ {
+ "initialAutoRepeatingDelay":2.0,
+ "nextAutoRepeatingDelay":0.9
+ // Note: Visuals added to Button will be used in all derived buttons unless overridden.
+ },
+ "PushButton":
+ {
+ "styles":["Button"],
+ "autoRepeating":false,
+ "togglable":false,
+ "labelPadding":[ 12.0, 12.0, 12.0, 12.0 ],
+ "label":
+ {
+ "visualType": "TEXT",
+ "horizontalAlignment": "CENTER",
+ "pointSize" : 12.0, // Point size must always be provided to Text Visual
+ "verticalAlignment": "CENTER"
+ },
+ "unselectedBackgroundVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}button-up.9.png"
+ },
+ "selectedBackgroundVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}button-down.9.png"
+ },
+ "disabledSelectedBackgroundVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}button-down-disabled.9.png"
+ },
+ "disabledUnselectedBackgroundVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}button-disabled.9.png"
+ }
+ },
+ "CheckBoxButton":
+ {
+ "styles":["Button"],
+ "labelPadding":[ 12.0, 12.0, 0.0, 0.0 ],
+ "label":
+ {
+ "visualType": "TEXT",
+ "pointSize" : 12.0, // Point size must always be provided to Text Visual
+ "verticalAlignment": "CENTER"
+ },
+ "unselectedVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}checkbox-unselected.png"
+ },
+ "selectedVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}checkbox-selected.png"
+ },
+ "disabledUnselectedVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}checkbox-unselected-disabled.png"
+ },
+ "disabledSelectedVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}checkbox-selected-disabled.png"
+ }
+ },
+ "RadioButton":
+ {
+ "styles":["Button"],
+ "labelPadding":[ 12.0, 12.0, 0.0, 0.0 ],
+ "label":
+ {
+ "visualType": "TEXT",
+ "pointSize" : 12.0, // Point size must always be provided to Text Visual
+ "verticalAlignment": "CENTER"
+ },
+ "unselectedVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}radio-button-unselected.png"
+ },
+ "selectedVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}radio-button-selected.png"
+ },
+ "disabledUnselectedVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}radio-button-unselected-disabled.png"
+ },
+ "disabledSelectedVisual":
+ {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}radio-button-selected-disabled.png"
+ }
}
}
}
Two different macros are provided depending on whether the property is to be an event-side only property or an animatable property.
-<b>There are two stages:</b>
+<b>There are three stages:</b>
-- Define the properties as an enum in the public-api header file, along with a definition of the property ranges.
+- Define the property ranges as an enum in the public-api header file. There are two ranges, one for event-side only properties, and one for animatable properties. Each range should follow on from the range defined in the parent class.
+- Define the properties as an enum in the public-api header file
- Define the property details using the pre-defined macros to perform the type-registering of the properties. This is done for signals and actions also.
<b>Example: ImageView</b>
Source file: <b>image-view.h</b>:
-Note that the “PropertyRange” contents “PROPERTY_START_INDEX” & "ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX" are also used by the macro for order checking.
+ Note that the “PropertyRange” contents “PROPERTY_START_INDEX” & "ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX" are also used by the macro for order checking, so should always have these names.
@code
/**
a derived actor/control type along with specifying a method which is used to create this type. This
type registration normally takes place at library load time.
-Once a type is registered, signals, actions and properties can also be registered for all instances
+Once a type is registered, properties, signals and actions can also be registered for all instances
of this type.
-This then allows the application writer to create instances using just the type name; connect to
-signals using only the signal name; activate an action by just using the action name; and finally,
-getting and setting properties using a property name or index.
+This then allows the application writer to create instances using just the type name; getting and setting properties using a property name or index; connect to
+signals using only the signal name; and activate an action by just using the action name.
This topic covers:
- @ref register-type
+ - @ref register-property
- @ref register-signal
- @ref register-action
- - @ref register-property
- @ref using-type
+ - @ref using-property
- @ref using-signal
- @ref using-action
- - @ref using-property
@section register-type Registering a Type
namespace
{
-Dali::BaseHandle Create()
+Dali::BaseHandle CreateMyControl()
{
// Create an instance of MyControl and return the handle.
return MyControlImpl::New();
}
-Dali::TypeRegistration type(
- typeid( MyControl ), // Type ID of our Control
- typeid( Dali::Toolkit::Control ), // Type ID of what our Control derives from
- Create // Function which creates our Control, signature shown above
-);
+DALI_TYPE_REGISTRATION_BEGIN( MyControl, Toolkit::Control, CreateMyControl );
+DALI_TYPE_REGISTRATION_END()
} // unnamed namespace
@endcode
-This registration informs DALi of the existence of MyControl type.
+This registration macro informs DALi of the existence of MyControl type, which class it derives from, and a method for creating an instance of MyControl.
+
+
+@section register-property Registering a Property
+
+DALi has a property system which can be extended by registering more properties through the type
+registry. The property index is <b><i>very important</i></b> when registering these properties and
+all property indices should be between Dali::PROPERTY_REGISTRATION_START_INDEX and
+Dali::PROPERTY_REGISTRATION_MAX_INDEX.
+
+Furthermore, if deriving from a \link Dali::Toolkit::Control Control\endlink, the control
+writer needs to be aware of their parent class's property range to avoid overlapping indices, so should start their property indices after their parent's range.
+Control reserves a property range between
+\link Dali::Toolkit::Control::CONTROL_PROPERTY_START_INDEX Control::CONTROL_PROPERTY_START_INDEX\endlink
+and \link Dali::Toolkit::Control::CONTROL_PROPERTY_END_INDEX Control::CONTROL_PROPERTY_END_INDEX\endlink.
+
+Any control deriving from \link Dali::Toolkit::Control Control\endlink
+should start at
+\link Dali::Toolkit::Control::CONTROL_PROPERTY_END_INDEX Control::CONTROL_PROPERTY_END_INDEX\endlink + 1.
+Controls deriving from an existing control such as \link Dali::Toolkit::Button Button\endlink should start at
+\link Dali::Toolkit::Button::PROPERTY_END_INDEX Button::PROPERTY_END_INDEX\endlink + 1.
+
+Please have a look at \ref property-indices for more information.
+
+The following code shows how a property can be added to a type.
+
+@code
+// Define the indices we will use for the properties:
+
+class MyControl : public Control
+{
+ /**
+ * @brief The start and end property ranges for this control.
+ */
+ enum PropertyRange
+ {
+ PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
+ PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000,
+
+ ANIMATABLE_PROPERTY_START_INDEX = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX,
+ ANIMATABLE_PROPERTY_END_INDEX = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1000
+ };
+
+ struct Property
+ {
+ enum
+ {
+ // Event side properties
+
+ /**
+ * @brief name "propertyOne", type bool
+ * @details Enables the feature.
+ * @SINCE_1_0.0
+ */
+ PROPERTY_ONE = PROPERTY_START_INDEX,
+
+ /**
+ * @brief name "propertyTwo", type float
+ * @details Controls the level of the feature
+ * @SINCE_1_0.0
+ */
+ PROPERTY_TWO,
+
+ /**
+ * @brief name "propertyThree", type Vector4
+ * @details The foreground color
+ * @SINCE_1_0.0
+ */
+ PROPERTY_THREE,
+
+ // Animatable properties
+
+ /**
+ * @brief name "propertyFour", type Vector4
+ * @details Animatable parameters of the feature
+ * @SINCE_1_0.0
+ */
+ PROPERTY_FOUR = ANIMATABLE_PROPERTY_START_INDEX,
+ };
+ };
+
+ /// ...
+};
+@endcode
+
+The control and properties are registered with the TypeRegistry using the following macros:
+
+@code
+DALI_TYPE_REGISTRATION_BEGIN( MyControl, Toolkit::Control, CreateMyControl );
+DALI_PROPERTY_REGISTRATION( AppNamespace, MyControl, "property1", BOOLEAN, PROPERTY_ONE )
+DALI_PROPERTY_REGISTRATION( AppNamespace, MyControl, "property2", FLOAT, PROPERTY_TWO )
+DALI_PROPERTY_REGISTRATION( AppNamespace, MyControl, "property3", VECTOR4, PROPERTY_THREE )
+
+DALI_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT( AppNamespace, MyControl, "property4", Vector4(0.f, 0.f, 1.f, 1.f), PROPERTY_FOUR )
+
+DALI_TYPE_REGISTRATION_END()
+@endcode
+
+The DALI_PROPERTY_REGISTRATION macro requires that you define the class methods SetProperty() and GetProperty().
+
+The DALI_ANIMATABLE_PROPERTY_REGISTRATION macros automatically create and handle scene-graph values, and do not need any code in your derived class. Just use the property index in animation or constraint methods.
+
+The SetProperty class method has to be static, and follows the format:
+
+@code
+void MyControl::SetProperty(
+ Dali::BaseObject* object, // A pointer to an instance of MyControl
+ Dali::Property::Index index, // The index of the property to set
+ const Dali::Property::Value& value // The value to set the property to
+)
+{
+ // DownCast to MyControl so that we can do the specific behaviour
+ MyControl control = MyControl::DownCast( Dali::BaseHandle ( object ) );
+
+ if ( control )
+ {
+ MyControlImpl& controlImpl( GetImplementation( control ) );
+
+ switch ( index )
+ {
+ case PROPERTY_ONE:
+ {
+ // Assume we already have a method in MyControl which sets the appropriate value and takes in a boolean
+ bool property;
+ if( value.Get( property ) )
+ {
+ controlImpl.SetPropertyOne( property );
+ }
+ break;
+ }
+
+ case PROPERTY_TWO
+ {
+ // Assume we already have a method in MyControl which sets the appropriate value and takes in a float
+ float property;
+ if( value.Get( property ) )
+ {
+ controlImpl.SetPropertyTwo( property );
+ }
+ break;
+ }
+
+ case PROPERTY_THREE
+ {
+ // Assume we already have a method in MyControl which sets the appropriate value and takes in a Vector4
+ Vector4 property;
+ if( value.Get( property ) )
+ {
+ controlImpl.SetPropertyThree( property );
+ }
+ break;
+ }
+ }
+ }
+}
+@endcode
+
+And the GetProperty method also has to be static and takes the form:
+
+@code
+Property::Value MyControl::GetProperty(
+ BaseObject* object, // A pointer to an instance of MyControl
+ Property::Index index ) // The index of the property to retrieve
+{
+ Property::Value value;
+
+ // DownCast to MyControl so that we can do the specific behaviour
+ MyControl control = MyControl::DownCast( Dali::BaseHandle ( object ) );
+
+ if ( control )
+ {
+ MyControlImpl& controlImpl( GetImplementation( control ) );
+
+ switch ( index )
+ {
+ case PROPERTY_ONE:
+ {
+ // Assume we have a member variable that stores the value of this property
+ value = controlImpl.mPropertyOne;
+ break;
+ }
+
+ case PROPERTY_TWO:
+ {
+ // Assume we have a member variable that stores the value of this property
+ value = controlImpl.mPropertyTwo;
+ break;
+ }
+
+ case PROPERTY_THREE:
+ {
+ // Assume we have a member variable that stores the value of this property
+ value = controlImpl.mPropertyThree;
+ break;
+ }
+ }
+ }
+}
+@endcode
+
+@section using-property Setting & Getting Registered Properties
+
+Like other properties, type registered properties can also be set and their values can be retrieved
+in a similar manner. The code below shows how this can be done.
+
+@code
+Dali::TypeInfo type = Dali::TypeRegistry::Get().GetTypeInfo( "MyControl" );
+
+if ( type )
+{
+ Dali::BaseHandle baseHandle = type.CreateInstance();
+
+ if ( baseHandle )
+ {
+ // Handle deals with properties, so DownCast
+ Dali::Handle handle = Dali::Handle::DownCast( baseHandle );
+
+ if ( handle )
+ {
+ // Setting a property
+ handle.SetProperty( MyControl::Property::PROPERTY_ONE, 11.0f );
+
+ // Get the property name
+ std::cout << "Property1 name is: " << handle.GetPropertyName( MyControl::Property::PROPERTY_ONE ) << std::endl;
+
+ // Get the property
+ bool propertyOne = handle.GetProperty< bool >( MyControl::Property::PROPERTY_ONE );
+
+ // Set the second property
+ handle.SetProperty( MyControl::Property::PROPERTY_TWO, 4.0f );
+ }
+ }
+}
+@endcode
@section register-signal Registering a Signal
For example, in the above case, MyControl can perform "action1" so should return true, but it
cannot perform "action4" so should return false and propagate the action to Control.
-@section register-property Registering a Property
-
-DALi has a property system which can be extended by registering more properties through the type
-registry. The property index is <b><i>very important</i></b> when registering these properties and
-all property indices should be between Dali::PROPERTY_REGISTRATION_START_INDEX and
-Dali::PROPERTY_REGISTRATION_MAX_INDEX.
-
-Furthermore, if deriving from \link Dali::Toolkit::Control Control\endlink, the control writer
-needs to be aware of their parent class's property range. Control reserves a property range between
-\link Dali::Toolkit::Control::CONTROL_PROPERTY_START_INDEX ControlImpl::CONTROL_PROPERTY_START_INDEX\endlink
-and \link Dali::Toolkit::Control::CONTROL_PROPERTY_END_INDEX Control::CONTROL_PROPERTY_END_INDEX\endlink.
-Any deriving control should start their property indices from
-\link Dali::Toolkit::Control::CONTROL_PROPERTY_END_INDEX Control::CONTROL_PROPERTY_END_INDEX\endlink + 1.
-
-Please have a look at \ref property-indices for more information.
-
-The following code shows how a property can be added to a type.
-
-@code
-// Define the indices we will use for the properties
-static const int PROPERTY_ONE( Dali::Toolkit::Internal::Control::CONTROL_PROPERTY_END_INDEX + 1 );
-static const int PROPERTY_TWO( Dali::Toolkit::Internal::Control::CONTROL_PROPERTY_END_INDEX + 2 );
-static const int PROPERTY_THREE( Dali::Toolkit::Internal::Control::CONTROL_PROPERTY_END_INDEX + 3 );
-
-Dali::PropertyRegistration property1(
- type, // Reference to type registration object (see above)
- "property1", // Name of the property
- PROPERTY_ONE, // Index of this property
- Dali::Property::BOOLEAN, // The property type
- &MyControl::SetProperty, // Method called when property is set
- &MyControl::GetProperty // Method called when retrieving the value of the property
-);
-
-// Register more properties
-Dali::PropertyRegistration property2(
- type, "property2", PROPERTY_TWO, Dali::Property::FLOAT,
- NULL, // SetProperty is NULL, means that this property is a read-only property
- &MyControl::GetProperty
-);
-Dali::PropertyRegistration property3( type, "property3", PROPERTY_THREE, Dali::Property::FLOAT, &MyControl::SetProperty, &MyControl::GetProperty);
-@endcode
-
-It is recommended to use static members (of MyControl class) for the property indices. That way
-applications can also use the static member as well. If they require the property name, they can
-just call the Dali::Handle::GetPropertyName().
-
-The method that deals with setting the property has to be static, and follows the format:
-
-@code
-void MyControl::SetProperty(
- Dali::BaseObject* object, // A pointer to an instance of MyControl
- Dali::Property::Index index, // The index of the property to set
- const Dali::Property::Value& value // The value to set the property to
-)
-{
- // DownCast to MyControl so that we can do the specific behaviour
- MyControl control = MyControl::DownCast( Dali::BaseHandle ( object ) );
-
- if ( control )
- {
- MyControlImpl& controlImpl( GetImplementation( control ) );
-
- switch ( index )
- {
- case PROPERTY_ONE:
- {
- // Assume we already have a method in MyControl which sets the appropriate value and takes in a boolean
- controlImpl.SetPropertyOne( value.Get< bool >() );
- break;
- }
-
- // PROPERTY_TWO is read-only so does not need to be handled
-
- case PROPERTY_THREE
- {
- // Assume we already have a method in MyControl which sets the appropriate value and takes in a float
- controlImpl.SetPropertyThree( value.Get< float >() );
- break;
- }
- }
- }
-}
-@endcode
-
-And the function to retrieve the property value also has to be static and takes the form:
-
-@code
-Property::Value MyControl::GetProperty(
- BaseObject* object, // A pointer to an instance of MyControl
- Property::Index index // The index of the property to retrieve
-)
-{
- Property::Value value;
-
- // DownCast to MyControl so that we can do the specific behaviour
- MyControl control = MyControl::DownCast( Dali::BaseHandle ( object ) );
-
- if ( control )
- {
- MyControlImpl& controlImpl( GetImplementation( control ) );
-
- switch ( index )
- {
- case PROPERTY_ONE:
- {
- // Assume we have a member variable that stores the value of this property
- value = controlImpl.mPropertyOne;
- break;
- }
-
- case PROPERTY_TWO:
- {
- // Assume we have a member variable that stores the value of this property
- value = controlImpl.mPropertyTwo;
- break;
- }
-
- case PROPERTY_THREE:
- {
- // Assume we have a member variable that stores the value of this property
- value = controlImpl.mPropertyThree;
- break;
- }
- }
- }
-}
-@endcode
@section using-type Creating an instance of a Registered Type
}
@endcode
-@section using-property Setting & Getting Registered Properties
-
-Like other properties, type registered properties can also be set and their values can be retrieved
-in a similar manner. The code below shows how this can be done.
-
-@code
-Dali::TypeInfo type = Dali::TypeRegistry::Get().GetTypeInfo( "MyControl" );
-
-if ( type )
-{
- Dali::BaseHandle baseHandle = type.CreateInstance();
-
- if ( baseHandle )
- {
- // Handle deals with properties, so DownCast
- Dali::Handle handle = Dali::Handle::DownCast( baseHandle );
-
- if ( handle )
- {
- // Setting a property
- handle.SetProperty( PROPERTY_ONE, true ); // Assume Property indices are publicly accessible
-
- // Get the property name
- std::cout << "Property1 name is: " << handle.GetPropertyName( PROPERTY_ONE ) << std::endl;
-
- // Get the property
- bool propertyOne = handle.GetProperty< bool >( PROPERTY_ONE );
-
- // Attempt to write a read-only property...
- handle.SetProperty( PROPERTY_TWO, 4.0f ); // !!! Will assert as PROPERTY_TWO is read-only !!!
- }
- }
-}
-@endcode
*
*/
This allows the creation of the control via a JSON file, as well as registering properties, signals and actions.
To ensure your control is stylable, the process described in [Type Registration](@ref type-registration) should be followed.
+
+#### Properties
To aid development, some macros are provided for registering properties which are described in the [Property](@ref properties) section.
Control properties can be one of three types:
Name: dali-addon
Summary: DALi module for Node.JS
-Version: 1.2.17
+Version: 1.2.18
Release: 1
Group: Development/Libraries
License: Apache License, Version 2.0
Name: NDalic
Summary: dali wrapper
-Version: 1.2.17
+Version: 1.2.18
Release: 1
Group: uifw/graphic
License: TO_BE_FILLED_IN
Name: dali-toolkit
Summary: The OpenGLES Canvas Core Library Toolkit
-Version: 1.2.17
+Version: 1.2.18
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-2-Clause and MIT
%include <dali/public-api/object/ref-object.h>
%include <dali/public-api/object/any.h>
+%include <dali/public-api/common/dali-common.h>
%include <dali/public-api/common/intrusive-ptr.h>
%include <dali/public-api/math/vector2.h>