namespace
{
- static bool gPushButtonToggleState = false;
- bool PushButtonToggled( Button button, bool toggled )
+ static bool gPushButtonSelectedState = false;
+ bool PushButtonSelected( Button button )
{
- gPushButtonToggleState = toggled && ( toggled == static_cast<PushButton&>( button ).IsToggled() );
+ gPushButtonSelectedState = button.IsSelected();
return true;
}
END_TEST;
}
- int UtcDaliPushButtonSetGetToggleButton(void)
+ int UtcDaliPushButtonSetGetTogglableButton(void)
{
ToolkitTestApplication application;
- tet_infoline(" UtcDaliPushButtonSetGetToggleButton");
+ tet_infoline(" UtcDaliPushButtonSetGetTogglableButton");
PushButton pushButton = PushButton::New();
- pushButton.SetToggleButton( true );
+ pushButton.SetTogglableButton( true );
- DALI_TEST_CHECK( pushButton.IsToggleButton() );
+ DALI_TEST_CHECK( pushButton.IsTogglableButton() );
- pushButton.SetToggleButton( false );
+ pushButton.SetTogglableButton( false );
- DALI_TEST_CHECK( !pushButton.IsToggleButton() );
+ DALI_TEST_CHECK( !pushButton.IsTogglableButton() );
- pushButton.SetToggleButton( true );
+ pushButton.SetTogglableButton( true );
- DALI_TEST_CHECK( pushButton.IsToggleButton() );
+ DALI_TEST_CHECK( pushButton.IsTogglableButton() );
END_TEST;
}
- int UtcDaliPushButtonSetGetAutoRepeatingAndToggleButton(void)
+ int UtcDaliPushButtonSetGetAutoRepeatingAndTogglableButton(void)
{
ToolkitTestApplication application;
- tet_infoline(" UtcDaliPushButtonSetGetAutoRepeatingAndToggleButton");
+ tet_infoline(" UtcDaliPushButtonSetGetAutoRepeatingAndTogglableButton");
PushButton pushButton = PushButton::New();
pushButton.SetAutoRepeating( true );
- pushButton.SetToggleButton( true );
+ pushButton.SetTogglableButton( true );
- DALI_TEST_CHECK( pushButton.IsToggleButton() );
+ DALI_TEST_CHECK( pushButton.IsTogglableButton() );
DALI_TEST_CHECK( !pushButton.IsAutoRepeating() );
- pushButton.SetToggleButton( true );
+ pushButton.SetTogglableButton( true );
pushButton.SetAutoRepeating( true );
DALI_TEST_CHECK( pushButton.IsAutoRepeating() );
- DALI_TEST_CHECK( !pushButton.IsToggleButton() );
+ DALI_TEST_CHECK( !pushButton.IsTogglableButton() );
END_TEST;
}
- int UtcDaliPushButtonSetGetToggled01(void)
+ int UtcDaliPushButtonSetGetSelected01(void)
{
ToolkitTestApplication application;
- tet_infoline(" UtcDaliPushButtonSetGetToggled01");
+ tet_infoline(" UtcDaliPushButtonSetGetSelected01");
PushButton pushButton = PushButton::New();
- pushButton.SetToggleButton( true );
- pushButton.StateChangedSignal().Connect( &PushButtonToggled );
+ pushButton.SetTogglableButton( true );
+ pushButton.StateChangedSignal().Connect( &PushButtonSelected );
- gPushButtonToggleState = false;
- pushButton.SetToggled( true );
+ gPushButtonSelectedState = false;
+ pushButton.SetSelected( true );
- DALI_TEST_CHECK( pushButton.IsToggled() );
- DALI_TEST_CHECK( gPushButtonToggleState );
+ DALI_TEST_CHECK( pushButton.IsSelected() );
+ DALI_TEST_CHECK( gPushButtonSelectedState );
- pushButton.SetToggled( false );
+ pushButton.SetSelected( false );
- DALI_TEST_CHECK( !pushButton.IsToggled() );
- DALI_TEST_CHECK( !gPushButtonToggleState );
+ DALI_TEST_CHECK( !pushButton.IsSelected() );
+ DALI_TEST_CHECK( !gPushButtonSelectedState );
- pushButton.SetToggled( true );
+ pushButton.SetSelected( true );
- DALI_TEST_CHECK( pushButton.IsToggled() );
- DALI_TEST_CHECK( gPushButtonToggleState );
+ DALI_TEST_CHECK( pushButton.IsSelected() );
+ DALI_TEST_CHECK( gPushButtonSelectedState );
END_TEST;
}
- int UtcDaliPushButtonSetGetToggled02(void)
+ int UtcDaliPushButtonSetGetSelected02(void)
{
ToolkitTestApplication application;
- tet_infoline(" UtcDaliPushButtonSetGetToggled02");
+ tet_infoline(" UtcDaliPushButtonSetGetSelected02");
PushButton pushButton = PushButton::New();
- pushButton.SetToggleButton( false );
- pushButton.StateChangedSignal().Connect( &PushButtonToggled );
+ pushButton.SetTogglableButton( false );
+ pushButton.StateChangedSignal().Connect( &PushButtonSelected );
- gPushButtonToggleState = false;
- pushButton.SetToggled( true );
+ gPushButtonSelectedState = false;
+ pushButton.SetSelected( true );
- DALI_TEST_CHECK( !pushButton.IsToggled() );
- DALI_TEST_CHECK( !gPushButtonToggleState );
+ DALI_TEST_CHECK( !pushButton.IsSelected() );
+ DALI_TEST_CHECK( !gPushButtonSelectedState );
- pushButton.SetToggled( false );
+ pushButton.SetSelected( false );
- DALI_TEST_CHECK( !pushButton.IsToggled() );
- DALI_TEST_CHECK( !gPushButtonToggleState );
+ DALI_TEST_CHECK( !pushButton.IsSelected() );
+ DALI_TEST_CHECK( !gPushButtonSelectedState );
- pushButton.SetToggled( true );
+ pushButton.SetSelected( true );
- DALI_TEST_CHECK( !pushButton.IsToggled() );
- DALI_TEST_CHECK( !gPushButtonToggleState );
+ DALI_TEST_CHECK( !pushButton.IsSelected() );
+ DALI_TEST_CHECK( !gPushButtonSelectedState );
END_TEST;
}
application.SendNotification();
application.Render();
- TextView textView;
-
pushButton.SetLabel( STR );
- textView = TextView::DownCast( pushButton.GetLabel() );
- DALI_TEST_CHECK( STR == textView.GetText() );
-
- TextView text = TextView::New( STR );
- pushButton.SetLabel( text );
-
- textView = TextView::DownCast( pushButton.GetLabel() );
- DALI_TEST_CHECK( STR == textView.GetText() );
END_TEST;
}
END_TEST;
}
- int UtcDaliPushButtonToggled(void)
+ int UtcDaliPushButtonSelected(void)
{
ToolkitTestApplication application;
- tet_infoline(" UtcDaliPushButtonToggled");
+ tet_infoline(" UtcDaliPushButtonSelected");
PushButton pushButton = PushButton::New();
pushButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
application.Render();
// connect to its touch signal
- pushButton.StateChangedSignal().Connect( &PushButtonToggled );
+ pushButton.StateChangedSignal().Connect( &PushButtonSelected );
Dali::Integration::TouchEvent event;
- // Test1. No toggle button.
+ // Test1. No togglable button.
- gPushButtonToggleState = false;
+ gPushButtonSelectedState = false;
event = Dali::Integration::TouchEvent();
event.AddPoint( pointDownInside );
application.ProcessEvent( event );
event.AddPoint( pointUpInside );
application.ProcessEvent( event );
- DALI_TEST_CHECK( !gPushButtonToggleState );
+ DALI_TEST_CHECK( !gPushButtonSelectedState );
- // Set toggle property.
- pushButton.SetToggleButton( true );
+ // Set togglable property.
+ pushButton.SetTogglableButton( true );
// Test2. Touch point down and up inside the button twice.
- gPushButtonToggleState = false;
+ gPushButtonSelectedState = false;
event = Dali::Integration::TouchEvent();
event.AddPoint( pointDownInside );
application.ProcessEvent( event );
event.AddPoint( pointUpInside );
application.ProcessEvent( event );
- DALI_TEST_CHECK( gPushButtonToggleState );
+ DALI_TEST_CHECK( gPushButtonSelectedState );
event = Dali::Integration::TouchEvent();
event.AddPoint( pointDownInside );
event.AddPoint( pointUpInside );
application.ProcessEvent( event );
- DALI_TEST_CHECK( !gPushButtonToggleState );
+ DALI_TEST_CHECK( !gPushButtonSelectedState );
// Test3. Touch point down and up outside the button.
- gPushButtonToggleState = false;
+ gPushButtonSelectedState = false;
event = Dali::Integration::TouchEvent();
event.AddPoint( pointDownOutside );
application.ProcessEvent( event );
event.AddPoint( pointUpOutside );
application.ProcessEvent( event );
- DALI_TEST_CHECK( !gPushButtonToggleState );
+ DALI_TEST_CHECK( !gPushButtonSelectedState );
// Test4. Touch point down inside and up outside the button.
- gPushButtonToggleState = false;
+ gPushButtonSelectedState = false;
event = Dali::Integration::TouchEvent();
event.AddPoint( pointDownInside );
application.ProcessEvent( event );
event.AddPoint( pointUpOutside );
application.ProcessEvent( event );
- DALI_TEST_CHECK( !gPushButtonToggleState );
+ DALI_TEST_CHECK( !gPushButtonSelectedState );
// Test5. Touch point down outside and up inside the button.
- gPushButtonToggleState = false;
+ gPushButtonSelectedState = false;
event = Dali::Integration::TouchEvent();
event.AddPoint( pointDownOutside );
application.ProcessEvent( event );
event.AddPoint( pointUpInside );
application.ProcessEvent( event );
- DALI_TEST_CHECK( !gPushButtonToggleState );
+ DALI_TEST_CHECK( !gPushButtonSelectedState );
END_TEST;
}
int UtcDaliRadioButtonLabelActor(void)
{
- ToolkitTestApplication application;
-
- TextView actor1 = TextView::New( "test actor 1" );
-
- RadioButton radioButton = RadioButton::New( actor1 );
- DALI_TEST_CHECK( actor1 == radioButton.GetLabel() );
-
- TextView actor2 = TextView::New( "test actor 2" );
- radioButton.SetLabel( actor2 );
- DALI_TEST_CHECK( actor2 == radioButton.GetLabel() );
-
+ // TODO
END_TEST;
}
- int UtcDaliRadioButtonActive(void)
+ int UtcDaliRadioButtonSelected(void)
{
ToolkitTestApplication application;
RadioButton radioButton = RadioButton::New();
- // Default active
- DALI_TEST_CHECK( radioButton.IsSelected() == false );
-
- // False to true
- radioButton.ToggleState();
- DALI_TEST_CHECK( radioButton.IsSelected() == true );
-
- // True to false
- radioButton.ToggleState();
+ // Default selected
DALI_TEST_CHECK( radioButton.IsSelected() == false );
// False
END_TEST;
}
- int UtcDaliRadioButtonActiveProperty(void)
+ int UtcDaliRadioButtonSelectedProperty(void)
{
ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
- tet_infoline(" UtcDaliRadioButtonActiveProperty");
+ tet_infoline(" UtcDaliRadioButtonSelectedProperty");
// Create the RadioButton actor
RadioButton radioButton = RadioButton::New();
radioButton.SetAnchorPoint(ParentOrigin::TOP_LEFT);
radioButton.SetPosition( 0.0f, 0.0f );
- // Default active
- DALI_TEST_CHECK( radioButton.GetProperty<bool>( Button::PROPERTY_TOGGLED ) == false );
+ // Default selected
+ DALI_TEST_CHECK( radioButton.GetProperty<bool>( Button::PROPERTY_SELECTED ) == false );
- // Setting false active
- radioButton.SetProperty( Button::PROPERTY_TOGGLED, false );
- DALI_TEST_CHECK( radioButton.GetProperty<bool>( Button::PROPERTY_TOGGLED ) == false );
+ // Setting false selected
+ radioButton.SetProperty( Button::PROPERTY_SELECTED, false );
+ DALI_TEST_CHECK( radioButton.GetProperty<bool>( Button::PROPERTY_SELECTED ) == false );
- // Setting true active
- radioButton.SetProperty( Button::PROPERTY_TOGGLED, true );
- DALI_TEST_CHECK( radioButton.GetProperty<bool>( Button::PROPERTY_TOGGLED ) == true );
+ // Setting true selected
+ radioButton.SetProperty( Button::PROPERTY_SELECTED, true );
+ DALI_TEST_CHECK( radioButton.GetProperty<bool>( Button::PROPERTY_SELECTED ) == true );
// Setting false again
- radioButton.SetProperty( Button::PROPERTY_TOGGLED, false );
- DALI_TEST_CHECK( radioButton.GetProperty<bool>( Button::PROPERTY_TOGGLED ) == false );
+ radioButton.SetProperty( Button::PROPERTY_SELECTED, false );
+ DALI_TEST_CHECK( radioButton.GetProperty<bool>( Button::PROPERTY_SELECTED ) == false );
// Test selecting radio buttons
RadioButton radioButton2 = RadioButton::New( "label" );
application.Render();
// Simulate touch events
- DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::PROPERTY_TOGGLED ) == false );
- DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::PROPERTY_TOGGLED ) == false );
+ DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::PROPERTY_SELECTED ) == false );
+ DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::PROPERTY_SELECTED ) == false );
// Select first radio
{
- Dali::Integration::TouchEvent event = Dali::Integration::TouchEvent();
+ Dali::Integration::TouchEvent event1 = Dali::Integration::TouchEvent();
+ Dali::Integration::TouchEvent event2 = Dali::Integration::TouchEvent();
+ const Dali::TouchPoint pointDown( 0, TouchPoint::Down, 10.0f, 10.0f );
const Dali::TouchPoint pointUp( 0, TouchPoint::Up, 10.0f, 10.0f );
- event.AddPoint( pointUp );
- application.ProcessEvent( event );
+ event1.AddPoint( pointDown );
+ application.ProcessEvent( event1 );
+
+ event2.AddPoint( pointUp );
+ application.ProcessEvent( event2 );
application.SendNotification();
application.Render();
- DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::PROPERTY_TOGGLED ) == true );
- DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::PROPERTY_TOGGLED ) == false );
+ DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::PROPERTY_SELECTED ) == true );
+ DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::PROPERTY_SELECTED ) == false );
}
// Select an already selected radio
{
- Dali::Integration::TouchEvent event = Dali::Integration::TouchEvent();
+ Dali::Integration::TouchEvent event1 = Dali::Integration::TouchEvent();
+ Dali::Integration::TouchEvent event2 = Dali::Integration::TouchEvent();
- const Dali::TouchPoint pointDown( 0, TouchPoint::Up, 10.0f, 10.0f );
- event.AddPoint( pointDown );
+ const Dali::TouchPoint pointDown( 0, TouchPoint::Down, 10.0f, 10.0f );
+ const Dali::TouchPoint pointUp( 0, TouchPoint::Up, 10.0f, 10.0f );
+
+ event1.AddPoint( pointDown );
+ application.ProcessEvent( event1 );
- application.ProcessEvent( event );
+ event2.AddPoint( pointUp );
+ application.ProcessEvent( event2 );
application.SendNotification();
application.Render();
- DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::PROPERTY_TOGGLED ) == true );
- DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::PROPERTY_TOGGLED ) == false );
+ DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::PROPERTY_SELECTED ) == true );
+ DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::PROPERTY_SELECTED ) == false );
}
// Select second radio
{
- Dali::Integration::TouchEvent event = Dali::Integration::TouchEvent();
+ Dali::Integration::TouchEvent event1 = Dali::Integration::TouchEvent();
+ Dali::Integration::TouchEvent event2 = Dali::Integration::TouchEvent();
- const Dali::TouchPoint pointDown( 0, TouchPoint::Up, 10.0f, 50.0f );
- event.AddPoint( pointDown );
+ const Dali::TouchPoint pointDown( 0, TouchPoint::Down, 10.0f, 50.0f );
+ const Dali::TouchPoint pointUp( 0, TouchPoint::Up, 10.0f, 50.0f );
- application.ProcessEvent( event );
+ event1.AddPoint( pointDown );
+ application.ProcessEvent( event1 );
+
+ event2.AddPoint( pointUp );
+ application.ProcessEvent( event2 );
application.SendNotification();
application.Render();
- DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::PROPERTY_TOGGLED ) == false );
- DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::PROPERTY_TOGGLED ) == true );
+ DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::PROPERTY_SELECTED ) == false );
+ DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::PROPERTY_SELECTED ) == true );
}
// Select outside radio group
{
- Dali::Integration::TouchEvent event = Dali::Integration::TouchEvent();
+ Dali::Integration::TouchEvent event1 = Dali::Integration::TouchEvent();
+ Dali::Integration::TouchEvent event2 = Dali::Integration::TouchEvent();
+
+ const Dali::TouchPoint pointDown( 0, TouchPoint::Down, 10.0f, 500.0f );
+ const Dali::TouchPoint pointUp( 0, TouchPoint::Up, 10.0f, 500.0f );
- const Dali::TouchPoint pointDown( 0, TouchPoint::Up, 10.0f, 500.0f );
- event.AddPoint( pointDown );
+ event1.AddPoint( pointDown );
+ application.ProcessEvent( event1 );
- application.ProcessEvent( event );
+ event2.AddPoint( pointUp );
+ application.ProcessEvent( event2 );
application.SendNotification();
application.Render();
- DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::PROPERTY_TOGGLED ) == false );
- DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::PROPERTY_TOGGLED ) == true );
+ DALI_TEST_CHECK( radioButton2.GetProperty<bool>( Button::PROPERTY_SELECTED ) == false );
+ DALI_TEST_CHECK( radioButton3.GetProperty<bool>( Button::PROPERTY_SELECTED ) == true );
}
END_TEST;
#include <dali-toolkit/public-api/controls/slider/slider.h>
#include <dali-toolkit/public-api/controls/super-blur-view/super-blur-view.h>
#include <dali-toolkit/public-api/controls/table-view/table-view.h>
-#include <dali-toolkit/public-api/controls/text-input/text-input.h>
-#include <dali-toolkit/public-api/controls/text-view/text-view.h>
+#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
#include <dali-toolkit/public-api/controls/tool-bar/tool-bar.h>
#include <dali-toolkit/public-api/controls/view/view.h>
#include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
#include <dali-toolkit/public-api/focus-manager/keyinput-focus-manager.h>
-#include <dali-toolkit/public-api/markup-processor/markup-processor.h>
-
#include <dali-toolkit/public-api/shader-effects/alpha-discard-effect.h>
#include <dali-toolkit/public-api/shader-effects/bendy-effect.h>
#include <dali-toolkit/public-api/shader-effects/blind-effect.h>
#include <dali-toolkit/public-api/shader-effects/nine-patch-mask-effect.h>
#include <dali-toolkit/public-api/shader-effects/page-turn-book-spine-effect.h>
#include <dali-toolkit/public-api/shader-effects/page-turn-effect.h>
+ #include <dali-toolkit/public-api/shader-effects/quadratic-bezier.h>
#include <dali-toolkit/public-api/shader-effects/ripple-effect.h>
#include <dali-toolkit/public-api/shader-effects/ripple2d-effect.h>
#include <dali-toolkit/public-api/shader-effects/swirl-effect.h>
+#include <dali-toolkit/public-api/text/bidirectional-line-info-run.h>
+#include <dali-toolkit/public-api/text/bidirectional-paragraph-info-run.h>
+#include <dali-toolkit/public-api/text/bidirectional-support.h>
+#include <dali-toolkit/public-api/text/character-run.h>
+#include <dali-toolkit/public-api/text/character-set-conversion.h>
+#include <dali-toolkit/public-api/text/font-run.h>
+#include <dali-toolkit/public-api/text/line-run.h>
+#include <dali-toolkit/public-api/text/logical-model.h>
+#include <dali-toolkit/public-api/text/multi-language-support.h>
+#include <dali-toolkit/public-api/text/script.h>
+#include <dali-toolkit/public-api/text/script-run.h>
+#include <dali-toolkit/public-api/text/segmentation.h>
+#include <dali-toolkit/public-api/text/shaper.h>
+#include <dali-toolkit/public-api/text/text-controller.h>
+#include <dali-toolkit/public-api/text/text-definitions.h>
+#include <dali-toolkit/public-api/text/text-view.h>
+#include <dali-toolkit/public-api/text/text-view-interface.h>
+#include <dali-toolkit/public-api/text/visual-model.h>
+#include <dali-toolkit/public-api/text/decorator/text-decorator.h>
+#include <dali-toolkit/public-api/text/layouts/layout-engine.h>
+#include <dali-toolkit/public-api/text/rendering/text-renderer.h>
+#include <dali-toolkit/public-api/text/rendering/basic/text-basic-renderer.h>
+#include <dali-toolkit/public-api/text/rendering/shaders/text-basic-shader.h>
+
#include <dali-toolkit/public-api/transition-effects/cube-transition-effect.h>
#include <dali-toolkit/public-api/transition-effects/cube-transition-wave-effect.h>
#include <dali-toolkit/public-api/transition-effects/cube-transition-cross-effect.h>
// EXTERNAL INCLUDES
#include <dali/public-api/events/touch-event.h>
#include <dali/public-api/object/type-registry.h>
-#include <dali-toolkit/public-api/controls/text-view/text-view.h>
+ #include <dali/public-api/actors/image-actor.h>
+ #include <dali/public-api/scripting/scripting.h>
+
+ // INTERNAL INCLUDES
namespace Dali
{
const Property::Index Button::PROPERTY_INITIAL_AUTO_REPEATING_DELAY = Internal::Button::BUTTON_PROPERTY_START_INDEX + 2;
const Property::Index Button::PROPERTY_NEXT_AUTO_REPEATING_DELAY = Internal::Button::BUTTON_PROPERTY_START_INDEX + 3;
const Property::Index Button::PROPERTY_TOGGLABLE = Internal::Button::BUTTON_PROPERTY_START_INDEX + 4;
- const Property::Index Button::PROPERTY_TOGGLED = Internal::Button::BUTTON_PROPERTY_START_INDEX + 5;
+ const Property::Index Button::PROPERTY_SELECTED = Internal::Button::BUTTON_PROPERTY_START_INDEX + 5;
const Property::Index Button::PROPERTY_NORMAL_STATE_ACTOR = Internal::Button::BUTTON_PROPERTY_START_INDEX + 6;
const Property::Index Button::PROPERTY_SELECTED_STATE_ACTOR = Internal::Button::BUTTON_PROPERTY_START_INDEX + 7;
const Property::Index Button::PROPERTY_DISABLED_STATE_ACTOR = Internal::Button::BUTTON_PROPERTY_START_INDEX + 8;
namespace
{
+ const unsigned int INITIAL_AUTOREPEATING_DELAY( 0.15f );
+ const unsigned int NEXT_AUTOREPEATING_DELAY( 0.05f );
+
+ // Signals
+
+ const char* const SIGNAL_PRESSED = "pressed";
+ const char* const SIGNAL_RELEASED = "released";
+ const char* const SIGNAL_CLICKED = "clicked";
+ const char* const SIGNAL_STATE_CHANGED = "state-changed";
+
+ // Actions
+
+ const char* const ACTION_BUTTON_CLICK = "button-click";
+
BaseHandle Create()
{
// empty handle as we cannot create button (but type registered for clicked signal)
return BaseHandle();
}
- TypeRegistration typeRegistration( typeid(Toolkit::Button), typeid(Toolkit::Control), Create );
+ TypeRegistration typeRegistration( typeid( Toolkit::Button ), typeid( Toolkit::Control ), Create );
- SignalConnectorType signalConnector1( typeRegistration, Toolkit::Button::SIGNAL_CLICKED, &Button::DoConnectSignal );
- SignalConnectorType signalConnector2( typeRegistration, Toolkit::Button::SIGNAL_STATE_CHANGED, &Button::DoConnectSignal );
+ SignalConnectorType signalConnector1( typeRegistration, SIGNAL_PRESSED , &Button::DoConnectSignal );
+ SignalConnectorType signalConnector2( typeRegistration, SIGNAL_RELEASED, &Button::DoConnectSignal );
+ SignalConnectorType signalConnector3( typeRegistration, SIGNAL_CLICKED, &Button::DoConnectSignal );
+ SignalConnectorType signalConnector4( typeRegistration, SIGNAL_STATE_CHANGED, &Button::DoConnectSignal );
+
+ TypeAction action1( typeRegistration, ACTION_BUTTON_CLICK, &Button::DoAction );
PropertyRegistration property1( typeRegistration, "disabled", Toolkit::Button::PROPERTY_DISABLED, Property::BOOLEAN, &Button::SetProperty, &Button::GetProperty );
PropertyRegistration property2( typeRegistration, "auto-repeating", Toolkit::Button::PROPERTY_AUTO_REPEATING, Property::BOOLEAN, &Button::SetProperty, &Button::GetProperty );
PropertyRegistration property3( typeRegistration, "initial-auto-repeating-delay", Toolkit::Button::PROPERTY_INITIAL_AUTO_REPEATING_DELAY, Property::FLOAT, &Button::SetProperty, &Button::GetProperty );
PropertyRegistration property4( typeRegistration, "next-auto-repeating-delay", Toolkit::Button::PROPERTY_NEXT_AUTO_REPEATING_DELAY, Property::FLOAT, &Button::SetProperty, &Button::GetProperty );
PropertyRegistration property5( typeRegistration, "togglable", Toolkit::Button::PROPERTY_TOGGLABLE, Property::BOOLEAN, &Button::SetProperty, &Button::GetProperty );
- PropertyRegistration property6( typeRegistration, "toggled", Toolkit::Button::PROPERTY_TOGGLED, Property::BOOLEAN, &Button::SetProperty, &Button::GetProperty );
+ PropertyRegistration property6( typeRegistration, "selected", Toolkit::Button::PROPERTY_SELECTED, Property::BOOLEAN, &Button::SetProperty, &Button::GetProperty );
PropertyRegistration property7( typeRegistration, "normal-state-actor", Toolkit::Button::PROPERTY_NORMAL_STATE_ACTOR, Property::MAP, &Button::SetProperty, &Button::GetProperty );
PropertyRegistration property8( typeRegistration, "selected-state-actor", Toolkit::Button::PROPERTY_SELECTED_STATE_ACTOR, Property::MAP, &Button::SetProperty, &Button::GetProperty );
PropertyRegistration property9( typeRegistration, "disabled-state-actor", Toolkit::Button::PROPERTY_DISABLED_STATE_ACTOR, Property::MAP, &Button::SetProperty, &Button::GetProperty );
Button::Button()
: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ),
+ mTogglableButton( false ),
+ mSelected( false ),
mPainter( NULL ),
- mState( ButtonUp ),
- mDisabled( false )
+ mAutoRepeatingTimer(),
+ mDisabled( false ),
+ mAutoRepeating( false ),
+ // mTogglableButton( false ),
+ // mSelected( false ),
+ mInitialAutoRepeatingDelay( INITIAL_AUTOREPEATING_DELAY ),
+ mNextAutoRepeatingDelay( NEXT_AUTOREPEATING_DELAY ),
+ mClickActionPerforming( false ),
+ mState( ButtonUp )
{
}
Button::~Button()
{
+ if( mAutoRepeatingTimer )
+ {
+ mAutoRepeatingTimer.Reset();
+ }
}
void Button::SetDisabled( bool disabled )
return mDisabled;
}
+ void Button::SetAutoRepeating( bool autoRepeating )
+ {
+ mAutoRepeating = autoRepeating;
+
+ // An autorepeating button can't be a togglable button.
+ if( autoRepeating )
+ {
+ mTogglableButton = false;
+ if( mSelected )
+ {
+ // Emit a signal is not wanted, only change the appearance.
+ Toolkit::Button handle( GetOwner() );
+ mPainter->Selected( handle );
+ mSelected = false;
+ }
+ }
+
+ // Notifies the painter.
+ mPainter->SetAutoRepeating( mAutoRepeating );
+ }
+
+ bool Button::IsAutoRepeating() const
+ {
+ return mAutoRepeating;
+ }
+
+ void Button::SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay )
+ {
+ DALI_ASSERT_ALWAYS( initialAutoRepeatingDelay > 0.f );
+ mInitialAutoRepeatingDelay = initialAutoRepeatingDelay;
+ }
+
+ float Button::GetInitialAutoRepeatingDelay() const
+ {
+ return mInitialAutoRepeatingDelay;
+ }
+
+ void Button::SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay )
+ {
+ DALI_ASSERT_ALWAYS( nextAutoRepeatingDelay > 0.f );
+ mNextAutoRepeatingDelay = nextAutoRepeatingDelay;
+ }
+
+ float Button::GetNextAutoRepeatingDelay() const
+ {
+ return mNextAutoRepeatingDelay;
+ }
+
+ void Button::SetTogglableButton( bool togglable )
+ {
+ mTogglableButton = togglable;
+
+ // A togglable button can't be an autorepeating button.
+ if( togglable )
+ {
+ mAutoRepeating = false;
+
+ // Notifies the painter.
+ mPainter->SetAutoRepeating( mAutoRepeating );
+ }
+ }
+
+ bool Button::IsTogglableButton() const
+ {
+ return mTogglableButton;
+ }
+
+ void Button::SetSelected( bool selected )
+ {
+ if( !mDisabled && mTogglableButton && ( selected != mSelected ) )
+ {
+ mSelected = selected;
+
+ Toolkit::Button handle( GetOwner() );
+
+ // Notifies the painter the button has been selected.
+ mPainter->Selected( handle );
+
+ // Emit signal.
+ mStateChangedSignal.Emit( handle );
+ }
+ }
+
+ bool Button::IsSelected() const
+ {
+ return mTogglableButton && mSelected;
+ }
+
void Button::SetAnimationTime( float animationTime )
{
OnAnimationTimeSet( animationTime );
return OnAnimationTimeRequested();
}
- Toolkit::TextView textView = Toolkit::TextView::New( label );
- textView.SetWidthExceedPolicy( Toolkit::TextView::ShrinkToFit ); // Make sure our text always fits inside the button
- SetLabel( textView );
-
+ void Button::SetLabel( const std::string& label )
+ {
+ RelayoutRequest();
+ }
+
+ void Button::SetLabel( Actor label )
+ {
+ Toolkit::Button handle( GetOwner() );
+
+ mPainter->SetLabel( handle, label );
+ }
+
+ Actor Button::GetLabel() const
+ {
+ return mLabel;
+ }
+
+ Actor& Button::GetLabel()
+ {
+ return mLabel;
+ }
+
+ void Button::SetButtonImage( Image image )
+ {
+ SetButtonImage( ImageActor::New( image ) );
+ }
+
+ void Button::SetButtonImage( Actor image )
+ {
+ Toolkit::Button handle( GetOwner() );
+ mPainter->SetButtonImage( handle, image );
+ }
+
+ Actor Button::GetButtonImage() const
+ {
+ return mButtonImage;
+ }
+
+ Actor& Button::GetButtonImage()
+ {
+ return mButtonImage;
+ }
+
+ void Button::SetSelectedImage( Image image )
+ {
+ SetSelectedImage( ImageActor::New( image ) );
+ }
+
+ void Button::SetSelectedImage( Actor image )
+ {
+ Toolkit::Button handle( GetOwner() );
+ mPainter->SetSelectedImage( handle, image );
+ }
+
+ Actor Button::GetSelectedImage() const
+ {
+ return mSelectedImage;
+ }
+
+ Actor& Button::GetSelectedImage()
+ {
+ return mSelectedImage;
+ }
+
+ void Button::SetBackgroundImage( Image image )
+ {
+ SetBackgroundImage( ImageActor::New( image ) );
+ }
+
+ void Button::SetBackgroundImage( Actor image )
+ {
+ Toolkit::Button handle( GetOwner() );
+ mPainter->SetBackgroundImage( handle, image );
+ }
+
+ Actor Button::GetBackgroundImage() const
+ {
+ return mBackgroundImage;
+ }
+
+ Actor& Button::GetBackgroundImage()
+ {
+ return mBackgroundImage;
+ }
+
+ void Button::SetDisabledImage( Image image )
+ {
+ SetDisabledImage( ImageActor::New( image ) );
+ }
+
+ void Button::SetDisabledImage( Actor image )
+ {
+ Toolkit::Button handle( GetOwner() );
+ mPainter->SetDisabledImage( handle, image );
+ }
+
+ Actor Button::GetDisabledImage() const
+ {
+ return mDisabledImage;
+ }
+
+ Actor& Button::GetDisabledImage()
+ {
+ return mDisabledImage;
+ }
+
+ void Button::SetDisabledSelectedImage( Image image )
+ {
+ SetDisabledSelectedImage( ImageActor::New( image ) );
+ }
+
+ void Button::SetDisabledSelectedImage( Actor image )
+ {
+ Toolkit::Button handle( GetOwner() );
+ mPainter->SetDisabledSelectedImage( handle, image );
+ }
+
+ Actor Button::GetDisabledSelectedImage() const
+ {
+ return mDisabledSelectedImage;
+ }
+
+ Actor& Button::GetDisabledSelectedImage()
+ {
+ return mDisabledSelectedImage;
+ }
+
+ void Button::SetDisabledBackgroundImage( Image image )
+ {
+ SetDisabledBackgroundImage( ImageActor::New( image ) );
+ }
+
+ void Button::SetDisabledBackgroundImage( Actor image )
+ {
+ Toolkit::Button handle( GetOwner() );
+ mPainter->SetDisabledBackgroundImage( handle, image );
+ }
+
+ Actor Button::GetDisabledBackgroundImage() const
+ {
+ return mDisabledBackgroundImage;
+ }
+
+ Actor& Button::GetDisabledBackgroundImage()
+ {
+ return mDisabledBackgroundImage;
+ }
+
+ Actor& Button::GetFadeOutButtonImage()
+ {
+ return mFadeOutButtonImage;
+ }
+
+ Actor& Button::GetFadeOutSelectedImage()
+ {
+ return mFadeOutSelectedImage;
+ }
+
+ Actor& Button::GetFadeOutBackgroundImage()
+ {
+ return mFadeOutBackgroundImage;
+ }
+
+ bool Button::DoAction( BaseObject* object, const std::string& actionName, const PropertyValueContainer& attributes )
+ {
+ bool ret = false;
+
+ Dali::BaseHandle handle( object );
+
+ Toolkit::Button button = Toolkit::Button::DownCast( handle );
+
+ DALI_ASSERT_ALWAYS( button );
+
+ if( 0 == strcmp( actionName.c_str(), ACTION_BUTTON_CLICK ) )
+ {
+ GetImplementation( button ).DoClickAction( attributes );
+ ret = true;
+ }
+
+ return ret;
+ }
+
+ void Button::DoClickAction( const PropertyValueContainer& attributes )
+ {
+ // Prevents the button signals from doing a recursive loop by sending an action
+ // and re-emitting the signals.
+ if( !mClickActionPerforming )
+ {
+ mClickActionPerforming = true;
+ OnButtonDown();
+ mState = ButtonDown;
+ OnButtonUp();
+ mClickActionPerforming = false;
+ }
+ }
+
void Button::OnAnimationTimeSet( float animationTime )
{
- // nothing to do.
+ mPainter->SetAnimationTime( animationTime );
+ }
+
+ float Button::OnAnimationTimeRequested() const
+ {
+ return mPainter->GetAnimationTime();
+ }
+
+ void Button::OnButtonStageDisconnection()
+ {
+ if( ButtonDown == mState )
+ {
+ if( !mTogglableButton )
+ {
+ Toolkit::Button handle( GetOwner() );
+
+ // Notifies the painter the button has been released.
+ mPainter->Released( handle );
+
+ if( mAutoRepeating )
+ {
+ mAutoRepeatingTimer.Reset();
+ }
+ }
+ }
}
void Button::OnButtonDown()
{
+ if( !mTogglableButton )
+ {
+ Toolkit::Button handle( GetOwner() );
+
+ // Notifies the painter the button has been pressed.
+ mPainter->Pressed( handle );
+
+ if( mAutoRepeating )
+ {
+ SetUpTimer( mInitialAutoRepeatingDelay );
+ }
+ //Emit signal.
+ mPressedSignal.Emit( handle );
+ }
}
void Button::OnButtonUp()
{
+ if( ButtonDown == mState )
+ {
+ if( mTogglableButton )
+ {
+ SetSelected( !mSelected );
+ }
+ else
+ {
+ Toolkit::Button handle( GetOwner() );
+
+ // Notifies the painter the button has been clicked.
+ mPainter->Released( handle );
+ mPainter->Clicked( handle );
+
+ if( mAutoRepeating )
+ {
+ mAutoRepeatingTimer.Reset();
+ }
+ //Emit signal.
+ mReleasedSignal.Emit( handle );
+ mClickedSignal.Emit( handle );
+ }
+ }
}
- float Button::OnAnimationTimeRequested() const
+ void Button::OnTouchPointLeave()
+ {
+ if( ButtonDown == mState )
+ {
+ if( !mTogglableButton )
+ {
+ Toolkit::Button handle( GetOwner() );
+
+ // Notifies the painter the button has been released.
+ mPainter->Released( handle );
+
+ if( mAutoRepeating )
+ {
+ mAutoRepeatingTimer.Reset();
+ }
+
+ //Emit signal.
+ mReleasedSignal.Emit( handle );
+ }
+ }
+ }
+
+ void Button::OnTouchPointInterrupted()
{
- return 0.f;
+ OnTouchPointLeave();
}
- Toolkit::Button::ClickedSignalType& Button::ClickedSignal()
+ Toolkit::Button::ButtonSignalType& Button::PressedSignal()
+ {
+ return mPressedSignal;
+ }
+
+ Toolkit::Button::ButtonSignalType& Button::ReleasedSignal()
+ {
+ return mReleasedSignal;
+ }
+
+ Toolkit::Button::ButtonSignalType& Button::ClickedSignal()
{
return mClickedSignal;
}
- Toolkit::Button::StateChangedSignalType& Button::StateChangedSignal()
+ Toolkit::Button::ButtonSignalType& Button::StateChangedSignal()
{
return mStateChangedSignal;
}
Dali::BaseHandle handle( object );
bool connected( true );
- Toolkit::Button button = Toolkit::Button::DownCast(handle);
+ Toolkit::Button button = Toolkit::Button::DownCast( handle );
- if( Dali::Toolkit::Button::SIGNAL_CLICKED == signalName )
+ if( 0 == strcmp( signalName.c_str(), SIGNAL_PRESSED ) )
+ {
+ button.PressedSignal().Connect( tracker, functor );
+ }
+ else if( 0 == strcmp( signalName.c_str(), SIGNAL_RELEASED ) )
+ {
+ button.ReleasedSignal().Connect( tracker, functor );
+ }
+ else if( 0 == strcmp( signalName.c_str(), SIGNAL_CLICKED ) )
{
button.ClickedSignal().Connect( tracker, functor );
}
- else if( Dali::Toolkit::Button::SIGNAL_STATE_CHANGED == signalName )
+ else if( 0 == strcmp( signalName.c_str(), SIGNAL_STATE_CHANGED ) )
{
button.StateChangedSignal().Connect( tracker, functor );
}
self.SetKeyboardFocusable( true );
}
+ void Button::OnActivated()
+ {
+ // When the button is activated, it performs the click action
+ PropertyValueContainer attributes;
+ DoClickAction( attributes );
+ }
+
void Button::OnControlSizeSet(const Vector3& targetSize)
{
Toolkit::Button handle( GetOwner() );
// Do nothing.
}
+ void Button::SetUpTimer( float delay )
+ {
+ 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( !mDisabled )
+ {
+ // Restart the autorepeat timer.
+ SetUpTimer( mNextAutoRepeatingDelay );
+
+ Toolkit::Button handle( GetOwner() );
+
+ // Notifies the painter the button has been pressed.
+ mPainter->Pressed( handle );
+
+ //Emit signal.
+ consumed = mReleasedSignal.Emit( handle );
+ consumed |= mClickedSignal.Emit( handle );
+ consumed |= mPressedSignal.Emit( handle );
+ }
+
+ return consumed;
+ }
+
void Button::OnControlStageDisconnection()
{
OnButtonStageDisconnection(); // Notification for derived classes.
mState = ButtonUp;
}
+ void Button::SetPainter(ButtonPainterPtr painter)
+ {
+ mPainter = painter;
+ }
+
+ Button::ButtonState Button::GetState()
+ {
+ return mState;
+ }
+
void Button::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
{
Toolkit::Button button = Toolkit::Button::DownCast( Dali::BaseHandle( object ) );
- if ( button && ( index == Toolkit::Button::PROPERTY_DISABLED ) )
+ if ( button )
{
- GetImplementation( button ).SetDisabled( value.Get<bool>() );
+ switch ( index )
+ {
+ case Toolkit::Button::PROPERTY_DISABLED:
+ {
+ GetImplementation( button ).SetDisabled( value.Get<bool>() );
+ break;
+ }
+
+ case Toolkit::Button::PROPERTY_AUTO_REPEATING:
+ {
+ GetImplementation( button ).SetAutoRepeating( value.Get< bool >() );
+ break;
+ }
+
+ case Toolkit::Button::PROPERTY_INITIAL_AUTO_REPEATING_DELAY:
+ {
+ GetImplementation( button ).SetInitialAutoRepeatingDelay( value.Get< float >() );
+ break;
+ }
+
+ case Toolkit::Button::PROPERTY_NEXT_AUTO_REPEATING_DELAY:
+ {
+ GetImplementation( button ).SetNextAutoRepeatingDelay( value.Get< float >() );
+ break;
+ }
+
+ case Toolkit::Button::PROPERTY_TOGGLABLE:
+ {
+ GetImplementation( button ).SetTogglableButton( value.Get< bool >() );
+ break;
+ }
+
+ case Toolkit::Button::PROPERTY_SELECTED:
+ {
+ GetImplementation( button ).SetSelected( value.Get< bool >() );
+ break;
+ }
+
+ case Toolkit::Button::PROPERTY_NORMAL_STATE_ACTOR:
+ {
+ GetImplementation( button ).SetButtonImage( Scripting::NewActor( value.Get< Property::Map >() ) );
+ break;
+ }
+
+ case Toolkit::Button::PROPERTY_SELECTED_STATE_ACTOR:
+ {
+ GetImplementation( button ).SetSelectedImage( Scripting::NewActor( value.Get< Property::Map >() ) );
+ break;
+ }
+
+ case Toolkit::Button::PROPERTY_DISABLED_STATE_ACTOR:
+ {
+ GetImplementation( button ).SetDisabledImage( Scripting::NewActor( value.Get< Property::Map >() ) );
+ break;
+ }
+
+ case Toolkit::Button::PROPERTY_LABEL_ACTOR:
+ {
+ GetImplementation( button ).SetLabel( Scripting::NewActor( value.Get< Property::Map >() ) );
+ break;
+ }
+ }
}
}
Property::Value Button::GetProperty( BaseObject* object, Property::Index propertyIndex )
{
+ Property::Value value;
+
Toolkit::Button button = Toolkit::Button::DownCast( Dali::BaseHandle( object ) );
- if ( button && ( propertyIndex == Toolkit::Button::PROPERTY_DISABLED ) )
+ if ( button )
{
- return Property::Value( GetImplementation( button ).mDisabled );
+ switch ( propertyIndex )
+ {
+ case Toolkit::Button::PROPERTY_DISABLED:
+ {
+ value = GetImplementation( button ).mDisabled;
+ break;
+ }
+
+ case Toolkit::Button::PROPERTY_AUTO_REPEATING:
+ {
+ value = GetImplementation( button ).mAutoRepeating;
+ break;
+ }
+
+ case Toolkit::Button::PROPERTY_INITIAL_AUTO_REPEATING_DELAY:
+ {
+ value = GetImplementation( button ).mInitialAutoRepeatingDelay;
+ break;
+ }
+
+ case Toolkit::Button::PROPERTY_NEXT_AUTO_REPEATING_DELAY:
+ {
+ value = GetImplementation( button ).mNextAutoRepeatingDelay;
+ break;
+ }
+
+ case Toolkit::Button::PROPERTY_TOGGLABLE:
+ {
+ value = GetImplementation( button ).mTogglableButton;
+ break;
+ }
+
+ case Toolkit::Button::PROPERTY_SELECTED:
+ {
+ value = GetImplementation( button ).mSelected;
+ break;
+ }
+
+ case Toolkit::Button::PROPERTY_NORMAL_STATE_ACTOR:
+ {
+ Property::Map map;
+ Scripting::CreatePropertyMap( GetImplementation( button ).mButtonImage, map );
+ value = map;
+ break;
+ }
+
+ case Toolkit::Button::PROPERTY_SELECTED_STATE_ACTOR:
+ {
+ Property::Map map;
+ Scripting::CreatePropertyMap( GetImplementation( button ).mSelectedImage, map );
+ value = map;
+ break;
+ }
+
+ case Toolkit::Button::PROPERTY_DISABLED_STATE_ACTOR:
+ {
+ Property::Map map;
+ Scripting::CreatePropertyMap( GetImplementation( button ).mDisabledImage, map );
+ value = map;
+ break;
+ }
+
+ case Toolkit::Button::PROPERTY_LABEL_ACTOR:
+ {
+ Property::Map map;
+ Scripting::CreatePropertyMap( GetImplementation( button ).mLabel, map );
+ value = map;
+ break;
+ }
+ }
}
- return Property::Value();
+ return value;
}
} // namespace Internal
#include <algorithm>
#include <dali/public-api/actors/image-actor.h>
#include <dali/public-api/object/type-registry.h>
- #include <dali/public-api/scripting/scripting.h>
// INTERNAL INCLUDES
#include "push-button-default-painter-impl.h"
-#include <dali-toolkit/public-api/controls/text-view/text-view.h>
#include <dali-toolkit/internal/controls/relayout-helper.h>
namespace Dali
TypeRegistration typeRegistration( typeid(Toolkit::PushButton), typeid(Toolkit::Button), Create );
- SignalConnectorType signalConnector1( typeRegistration, Toolkit::PushButton::SIGNAL_PRESSED , &PushButton::DoConnectSignal );
- SignalConnectorType signalConnector2( typeRegistration, Toolkit::PushButton::SIGNAL_RELEASED, &PushButton::DoConnectSignal );
-
- TypeAction action1( typeRegistration, Toolkit::PushButton::ACTION_PUSH_BUTTON_CLICK, &PushButton::DoAction );
-
} // unnamed namespace
namespace
{
- const unsigned int INITIAL_AUTOREPEATING_DELAY( 0.15f );
- const unsigned int NEXT_AUTOREPEATING_DELAY( 0.05f );
-
const float TEXT_PADDING = 12.0f;
- // Helper function used to cast a ButtonPainter to PushButtonDefaultPainter
- PushButtonDefaultPainterPtr GetPushButtonPainter( Dali::Toolkit::Internal::ButtonPainterPtr painter )
- {
- return static_cast<PushButtonDefaultPainter*>( painter.Get() );
- }
-
/**
* Find the first image actor in the actor hierarchy
*/
return pushButton;
}
- void PushButton::SetAutoRepeating( bool autoRepeating )
- {
- mAutoRepeating = autoRepeating;
-
- // An autorepeating button can't be a toggle button.
- if( autoRepeating )
- {
- mToggleButton = false;
- if( mToggled )
- {
- // Emit a signal is not wanted, only change the appearance.
- Toolkit::PushButton handle( GetOwner() );
- GetPushButtonPainter( mPainter )->Toggled( handle );
- mToggled = false;
- }
- }
-
- // Notifies the painter.
- GetPushButtonPainter( mPainter )->SetAutoRepeating( mAutoRepeating );
- }
-
- bool PushButton::IsAutoRepeating() const
- {
- return mAutoRepeating;
- }
-
- void PushButton::SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay )
- {
- DALI_ASSERT_ALWAYS( initialAutoRepeatingDelay > 0.f );
- mInitialAutoRepeatingDelay = initialAutoRepeatingDelay;
- }
-
- float PushButton::GetInitialAutoRepeatingDelay() const
- {
- return mInitialAutoRepeatingDelay;
- }
-
- void PushButton::SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay )
- {
- DALI_ASSERT_ALWAYS( nextAutoRepeatingDelay > 0.f );
- mNextAutoRepeatingDelay = nextAutoRepeatingDelay;
- }
-
- float PushButton::GetNextAutoRepeatingDelay() const
- {
- return mNextAutoRepeatingDelay;
- }
-
- void PushButton::SetToggleButton( bool toggle )
- {
- mToggleButton = toggle;
-
- // A toggle button can't be an autorepeating button.
- if( toggle )
- {
- mAutoRepeating = false;
-
- // Notifies the painter.
- GetPushButtonPainter( mPainter )->SetAutoRepeating( mAutoRepeating );
- }
- }
-
- bool PushButton::IsToggleButton() const
- {
- return mToggleButton;
- }
-
- void PushButton::SetToggled( bool toggle )
- {
- if( !mDisabled && mToggleButton && ( toggle != mToggled ) )
- {
- mToggled = toggle;
-
- Toolkit::PushButton handle( GetOwner() );
-
- // Notifies the painter the button has been toggled.
- GetPushButtonPainter( mPainter )->Toggled( handle );
-
- // Emit signal.
- mStateChangedSignal.Emit( handle, mToggled );
- }
- }
-
- bool PushButton::IsToggled() const
- {
- return mToggleButton && mToggled;
- }
-
- void PushButton::SetButtonImage( Image image )
- {
- SetButtonImage( ImageActor::New( image ) );
- }
-
- void PushButton::SetButtonImage( Actor image )
- {
- Toolkit::PushButton handle( GetOwner() );
- GetPushButtonPainter( mPainter )->SetButtonImage( handle, image );
- }
-
- Actor& PushButton::GetButtonImage()
- {
- return mButtonImage;
- }
-
- Actor PushButton::GetButtonImage() const
- {
- return mButtonImage;
- }
-
- void PushButton::SetBackgroundImage( Image image )
- {
- SetBackgroundImage( ImageActor::New( image ) );
- }
-
- void PushButton::SetBackgroundImage( Actor image )
- {
- Toolkit::PushButton handle( GetOwner() );
- GetPushButtonPainter( mPainter )->SetBackgroundImage( handle, image );
- }
-
- Actor& PushButton::GetBackgroundImage()
- {
- return mBackgroundImage;
- }
-
- Actor PushButton::GetBackgroundImage() const
- {
- return mBackgroundImage;
- }
-
- void PushButton::SetSelectedImage( Image image )
- {
- SetSelectedImage( ImageActor::New( image ) );
- }
-
- void PushButton::SetSelectedImage( Actor image )
- {
- Toolkit::PushButton handle( GetOwner() );
- GetPushButtonPainter( mPainter )->SetSelectedImage( handle, image );
- }
-
- Actor& PushButton::GetSelectedImage()
- {
- return mSelectedImage;
- }
-
- Actor PushButton::GetSelectedImage() const
- {
- return mSelectedImage;
- }
-
- void PushButton::SetDisabledBackgroundImage( Image image )
- {
- SetDisabledBackgroundImage( ImageActor::New( image ) );
- }
-
- void PushButton::SetDisabledBackgroundImage( Actor image )
- {
- Toolkit::PushButton handle( GetOwner() );
- GetPushButtonPainter( mPainter )->SetDisabledBackgroundImage( handle, image );
- }
-
- Actor& PushButton::GetDisabledBackgroundImage()
- {
- return mDisabledBackgroundImage;
- }
-
- Actor PushButton::GetDisabledBackgroundImage() const
- {
- return mDisabledBackgroundImage;
- }
-
- void PushButton::SetDisabledImage( Image image )
- {
- SetDisabledImage( ImageActor::New( image ) );
- }
-
- void PushButton::SetDisabledImage( Actor image )
- {
- Toolkit::PushButton handle( GetOwner() );
- GetPushButtonPainter( mPainter )->SetDisabledImage( handle, image );
- }
-
- Actor& PushButton::GetDisabledImage()
- {
- return mDisabledImage;
- }
-
- Actor PushButton::GetDisabledImage() const
- {
- return mDisabledImage;
- }
-
- void PushButton::SetLabel( const std::string& label )
- {
- // TODO
- }
-
- void PushButton::SetLabel( Actor label )
- {
- Toolkit::PushButton handle( GetOwner() );
- GetPushButtonPainter( mPainter )->SetLabel( handle, label );
- }
-
- Actor PushButton::GetLabel() const
- {
- return mLabel;
- }
-
- Actor& PushButton::GetLabel()
- {
- return mLabel;
- }
-
- Actor& PushButton::GetFadeOutBackgroundImage()
- {
- return mFadeOutBackgroundImage;
- }
-
- Actor& PushButton::GetFadeOutButtonImage()
- {
- return mFadeOutButtonImage;
- }
-
- Toolkit::PushButton::PressedSignalType& PushButton::PressedSignal()
- {
- return mPressedSignal;
- }
-
- Toolkit::PushButton::ReleasedSignalType& PushButton::ReleasedSignal()
- {
- return mReleasedSignal;
- }
-
- bool PushButton::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
- {
- Dali::BaseHandle handle( object );
-
- bool connected( true );
- Toolkit::PushButton button = Toolkit::PushButton::DownCast(handle);
-
- if( Toolkit::PushButton::SIGNAL_STATE_CHANGED == signalName )
- {
- button.StateChangedSignal().Connect( tracker, functor );
- }
- else if( Toolkit::PushButton::SIGNAL_PRESSED == signalName )
- {
- button.PressedSignal().Connect( tracker, functor );
- }
- else if( Toolkit::PushButton::SIGNAL_RELEASED == signalName )
- {
- button.ReleasedSignal().Connect( tracker, functor );
- }
- else
- {
- // signalName does not match any signal
- connected = false;
- }
-
- return connected;
- }
-
- void PushButton::SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value )
- {
- Toolkit::PushButton pushButton = Toolkit::PushButton::DownCast( Dali::BaseHandle( object ) );
-
- if ( pushButton )
- {
- PushButton& pushButtonImpl( GetImplementation( pushButton ) );
-
- if ( propertyIndex == Toolkit::Button::PROPERTY_AUTO_REPEATING )
- {
- pushButtonImpl.SetAutoRepeating( value.Get< bool >() );
- }
- else if ( propertyIndex == Toolkit::Button::PROPERTY_INITIAL_AUTO_REPEATING_DELAY )
- {
- pushButtonImpl.SetInitialAutoRepeatingDelay( value.Get< float >() );
- }
- else if ( propertyIndex == Toolkit::Button::PROPERTY_NEXT_AUTO_REPEATING_DELAY )
- {
- pushButtonImpl.SetNextAutoRepeatingDelay( value.Get< float >() );
- }
- else if ( propertyIndex == Toolkit::Button::PROPERTY_TOGGLABLE )
- {
- pushButtonImpl.SetToggleButton( value.Get< bool >() );
- }
- else if ( propertyIndex == Toolkit::Button::PROPERTY_TOGGLED )
- {
- pushButtonImpl.SetToggled( value.Get< bool >() );
- }
- else if ( propertyIndex == Toolkit::Button::PROPERTY_NORMAL_STATE_ACTOR )
- {
- pushButtonImpl.SetButtonImage( Scripting::NewActor( value.Get< Property::Map >() ) );
- }
- else if ( propertyIndex == Toolkit::Button::PROPERTY_SELECTED_STATE_ACTOR )
- {
- pushButtonImpl.SetSelectedImage( Scripting::NewActor( value.Get< Property::Map >() ) );
- }
- else if ( propertyIndex == Toolkit::Button::PROPERTY_DISABLED_STATE_ACTOR )
- {
- pushButtonImpl.SetDisabledImage( Scripting::NewActor( value.Get< Property::Map >() ) );
- }
- else if ( propertyIndex == Toolkit::Button::PROPERTY_LABEL_ACTOR )
- {
- pushButtonImpl.SetLabel( Scripting::NewActor( value.Get< Property::Map >() ) );
- }
- }
- }
-
- Property::Value PushButton::GetProperty( BaseObject* object, Property::Index propertyIndex )
- {
- Property::Value value;
-
- Toolkit::PushButton pushButton = Toolkit::PushButton::DownCast( Dali::BaseHandle( object ) );
-
- if ( pushButton )
- {
- PushButton& pushButtonImpl( GetImplementation( pushButton ) );
-
- if ( propertyIndex == Toolkit::Button::PROPERTY_AUTO_REPEATING )
- {
- value = pushButtonImpl.mAutoRepeating;
- }
- else if ( propertyIndex == Toolkit::Button::PROPERTY_INITIAL_AUTO_REPEATING_DELAY )
- {
- value = pushButtonImpl.mInitialAutoRepeatingDelay;
- }
- else if ( propertyIndex == Toolkit::Button::PROPERTY_NEXT_AUTO_REPEATING_DELAY )
- {
- value = pushButtonImpl.mNextAutoRepeatingDelay;
- }
- else if ( propertyIndex == Toolkit::Button::PROPERTY_TOGGLABLE )
- {
- value = pushButtonImpl.mToggleButton;
- }
- else if ( propertyIndex == Toolkit::Button::PROPERTY_TOGGLED )
- {
- value = pushButtonImpl.mToggled;
- }
- else if ( propertyIndex == Toolkit::Button::PROPERTY_NORMAL_STATE_ACTOR )
- {
- Property::Map map;
- Scripting::CreatePropertyMap( pushButtonImpl.mButtonImage, map );
- value = map;
- }
- else if ( propertyIndex == Toolkit::Button::PROPERTY_SELECTED_STATE_ACTOR )
- {
- Property::Map map;
- Scripting::CreatePropertyMap( pushButtonImpl.mSelectedImage, map );
- value = map;
- }
- else if ( propertyIndex == Toolkit::Button::PROPERTY_DISABLED_STATE_ACTOR )
- {
- Property::Map map;
- Scripting::CreatePropertyMap( pushButtonImpl.mDisabledImage, map );
- value = map;
- }
- else if ( propertyIndex == Toolkit::Button::PROPERTY_LABEL_ACTOR )
- {
- Property::Map map;
- Scripting::CreatePropertyMap( pushButtonImpl.mLabel, map );
- value = map;
- }
- }
-
- return value;
- }
-
void PushButton::OnButtonInitialize()
{
// Push button requires the Leave event.
root.SetLeaveRequired( true );
}
- void PushButton::OnButtonDown()
- {
- if( !mToggleButton )
- {
- Toolkit::PushButton handle( GetOwner() );
-
- // Notifies the painter the button has been pressed.
- GetPushButtonPainter( mPainter )->Pressed( handle );
-
- if( mAutoRepeating )
- {
- SetUpTimer( mInitialAutoRepeatingDelay );
- }
-
- //Emit signal.
- mPressedSignal.Emit( handle );
- }
- }
-
- void PushButton::OnButtonUp()
- {
- if( ButtonDown == mState )
- {
- if( mToggleButton )
- {
- mToggled = !mToggled;
-
- Toolkit::PushButton handle( GetOwner() );
-
- // Notifies the painter the button has been toggled.
- GetPushButtonPainter( mPainter )->Toggled( handle );
-
- // Emit signal.
- mStateChangedSignal.Emit( handle, mToggled );
- }
- else
- {
- Toolkit::PushButton handle( GetOwner() );
-
- // Notifies the painter the button has been clicked.
- GetPushButtonPainter( mPainter )->Released( handle );
- GetPushButtonPainter( mPainter )->Clicked( handle );
-
- if( mAutoRepeating )
- {
- mAutoRepeatingTimer.Reset();
- }
-
- //Emit signal.
- mReleasedSignal.Emit( handle );
- mClickedSignal.Emit( handle );
- }
- }
- }
-
- void PushButton::OnTouchPointLeave()
- {
- if( ButtonDown == mState )
- {
- if( !mToggleButton )
- {
- Toolkit::PushButton handle( GetOwner() );
-
- // Notifies the painter the button has been released.
- GetPushButtonPainter( mPainter )->Released( handle );
-
- if( mAutoRepeating )
- {
- mAutoRepeatingTimer.Reset();
- }
-
- //Emit signal.
- mReleasedSignal.Emit( handle );
- }
- }
- }
-
- void PushButton::OnTouchPointInterrupted()
- {
- OnTouchPointLeave();
- }
-
- void PushButton::OnAnimationTimeSet( float animationTime )
- {
- GetPushButtonPainter( mPainter )->SetAnimationTime( animationTime );
- }
-
- float PushButton::OnAnimationTimeRequested() const
- {
- return GetPushButtonPainter( mPainter )->GetAnimationTime();
- }
-
- void PushButton::OnButtonStageDisconnection()
- {
- if( ButtonDown == mState )
- {
- if( !mToggleButton )
- {
- Toolkit::PushButton handle( GetOwner() );
-
- // Notifies the painter the button has been released.
- GetPushButtonPainter( mPainter )->Released( handle );
-
- if( mAutoRepeating )
- {
- mAutoRepeatingTimer.Reset();
- }
- }
- }
- }
-
PushButton::PushButton()
- : Button(),
- mAutoRepeating( false ),
- mInitialAutoRepeatingDelay( INITIAL_AUTOREPEATING_DELAY ),
- mNextAutoRepeatingDelay( NEXT_AUTOREPEATING_DELAY ),
- mToggleButton( false ),
- mAutoRepeatingTimer(),
- mToggled( false ),
- mClickActionPerforming(false)
+ : Button()
{
- // Creates specific painter.
- mPainter = PushButtonDefaultPainterPtr( new PushButtonDefaultPainter() );
+ // Creates specific painter.GetBu
+ ButtonPainterPtr painter = PushButtonDefaultPainterPtr( new PushButtonDefaultPainter() );
+ SetPainter( painter );
}
PushButton::~PushButton()
{
- if( mAutoRepeatingTimer )
- {
- mAutoRepeatingTimer.Reset();
- }
-
- mPainter = NULL;
- }
-
- void PushButton::SetUpTimer( float delay )
- {
- mAutoRepeatingTimer = Dali::Timer::New( static_cast<unsigned int>( 1000.f * delay ) );
- mAutoRepeatingTimer.TickSignal().Connect( this, &PushButton::AutoRepeatingSlot );
- mAutoRepeatingTimer.Start();
- }
-
- bool PushButton::AutoRepeatingSlot()
- {
- bool consumed = false;
- if( !mDisabled )
- {
- // Restart the autorepeat timer.
- SetUpTimer( mNextAutoRepeatingDelay );
-
- Toolkit::PushButton handle( GetOwner() );
-
- // Notifies the painter the button has been pressed.
- GetPushButtonPainter( mPainter )->Pressed( handle );
-
- //Emit signal.
- consumed = mReleasedSignal.Emit( handle );
- consumed |= mClickedSignal.Emit( handle );
- consumed |= mPressedSignal.Emit( handle );
- }
-
- return consumed;
- }
-
- void PushButton::OnActivated()
- {
- // When the button is activated, it performs the click action
- PropertyValueContainer attributes;
- DoClickAction(attributes);
+ SetPainter( NULL );
}
Vector3 PushButton::GetNaturalSize()
if( widthIsZero || heightIsZero )
{
// If background and background not scale9 try get size from that
- ImageActor imageActor = FindImageActor( mButtonImage );
+ ImageActor imageActor = FindImageActor( GetButtonImage() );
if( imageActor && imageActor.GetStyle() != ImageActor::STYLE_NINE_PATCH )
{
Vector3 imageSize = RelayoutHelper::GetNaturalSize( imageActor );
}
}
- ImageActor backgroundImageActor = FindImageActor( mBackgroundImage );
+ ImageActor backgroundImageActor = FindImageActor( GetBackgroundImage() );
if( backgroundImageActor && backgroundImageActor.GetStyle() != ImageActor::STYLE_NINE_PATCH )
{
Vector3 imageSize = RelayoutHelper::GetNaturalSize( backgroundImageActor );
size.height = std::max( size.height, imageSize.height );
}
}
-
- // If label, test against it's size
- Toolkit::TextView textView = Toolkit::TextView::DownCast( GetLabel() );
- if( textView )
- {
- Vector3 textViewSize = textView.GetNaturalSize();
-
- if( widthIsZero )
- {
- size.width = std::max( size.width, textViewSize.width + TEXT_PADDING * 2.0f );
- }
-
- if( heightIsZero )
- {
- size.height = std::max( size.height, textViewSize.height + TEXT_PADDING * 2.0f );
- }
- }
}
return size;
}
- void PushButton::DoClickAction(const PropertyValueContainer& attributes)
- {
- // Prevents the button signals from doing a recursive loop by sending an action
- // and re-emitting the signals.
- if(!mClickActionPerforming)
- {
- mClickActionPerforming = true;
- OnButtonDown();
- mState = ButtonDown;
- OnButtonUp();
- mClickActionPerforming = false;
- }
- }
-
- bool PushButton::DoAction(BaseObject* object, const std::string& actionName, const PropertyValueContainer& attributes)
- {
- bool ret = false;
-
- Dali::BaseHandle handle(object);
-
- Toolkit::PushButton button = Toolkit::PushButton::DownCast(handle);
-
- DALI_ASSERT_ALWAYS(button);
-
- if(Toolkit::PushButton::ACTION_PUSH_BUTTON_CLICK == actionName)
- {
- GetImplementation(button).DoClickAction(attributes);
- ret = true;
- }
-
- return ret;
- }
-
} // namespace Internal
} // namespace Toolkit
#include <dali/public-api/common/dali-vector.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/text-view/text-view.h>
#include <dali-toolkit/public-api/controls/buttons/radio-button.h>
#include "button-impl.h"
/**
* Construct a new PushButton with label.
*/
- RadioButton(const std::string& label);
+ RadioButton( const std::string& label );
/**
* Construct a new PushButton with label.
*/
- RadioButton(Actor label);
+ RadioButton( Actor label );
/**
* A reference counted object may only be deleted by calling Unreference()
virtual ~RadioButton();
/**
- * @copydoc Dali::Toolkit::RadioButton::SetLabel(const std::string& label)
+ * @copydoc Dali::Toolkit::Button::SetLabel( Actor label )
*/
- void SetLabel(const std::string& label);
+ virtual void SetLabel( Actor label ); // TODO: After refactoring painter, this will be removed
/**
- * @copydoc Dali::Toolkit::RadioButton::SetLabel(Actor label)
+ * @copydoc Dali::Toolkit::Button::SetSelected( bool selected )
*/
- void SetLabel(Actor label);
-
- /**
- * @copydoc Dali::Toolkit::RadioButton::GetLabel()
- */
- Actor GetLabel() const;
-
- /**
- * @copydoc Dali::Toolkit::RadioButton::SetSelected(bool selected)
- */
- void SetSelected(bool selected);
-
- /**
- * @copydoc Dali::Toolkit::RadioButton::IsSelected()
- */
- bool IsSelected()const;
-
- /**
- * @copydoc Dali::Toolkit::RadioButton::ToggleState()
- */
- void ToggleState();
+ virtual void SetSelected( bool selected );
/**
* @copydoc Dali::Toolkit::Control::OnRelayout()
*/
virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container );
- public:
- // Properties
-
- /**
- * @copydoc Button::SetProperty
- */
- static void SetProperty(BaseObject* object, Property::Index propertyIndex, const Property::Value& value);
-
- /**
- * @copydoc Button::GetProperty
- */
- static Property::Value GetProperty(BaseObject* object, Property::Index propertyIndex);
-
protected: // From Control
/**
private:
// Undefined
- RadioButton(const RadioButton& origin);
+ RadioButton( const RadioButton& origin );
// Undefined
- RadioButton& operator=(const RadioButton& origin);
+ RadioButton& operator=( const RadioButton& origin );
Image mUnselectedImage; ///< Stores the unselected image
Image mSelectedImage; ///< Stores the selected image
ImageActor mRadioIcon; ///< Stores the current image
- Actor mLabel; ///< Stores the button label
- bool mSelected; ///< Stores the selected state
- } ;
+ };
} // namespace Internal
*
*/
+ // CLASS HEADER
#include "navigation-title-bar.h"
namespace Dali
// title icon layout: the top row, the bottom row and the left column are all for margins
mTitleIconLayout= Toolkit::TableView::New( 3,2 );
SetFixedSizes();
-
- mTitle = Toolkit::TextView::New();
- mTitle.SetTextAlignment( Toolkit::Alignment::HorizontalLeft );
- mTitle.SetWidthExceedPolicy(Toolkit::TextView::ShrinkToFit);
- mSubTitle = Toolkit::TextView::New();
- mSubTitle.SetTextAlignment( Toolkit::Alignment::HorizontalLeft );
- mSubTitle.SetWidthExceedPolicy(Toolkit::TextView::ShrinkToFit);
}
void NavigationTitleBar::Update( Toolkit::Page page )
mLayout.AddChild(mButtonLayout, Toolkit::TableView::CellPosition(0,2));
}
- // add title and subtitle(if exist)
- mTitle.SetText( page.GetTitle() );
- mTitle.SetStyleToCurrentText(mCurrentStyle->titleTextStyle);
- if( page.GetSubTitle().empty() ) //display title
- {
- mTitleLayout.SetFixedHeight( 1,mCurrentStyle->titleHeightWithoutSubtitle - mCurrentStyle->subtitleHeight );
- mTitleLayout.AddChild( mTitle, Toolkit::TableView::CellPosition(1,0,2,1) );
- }
- else //display title and subtitle
- {
- mTitleLayout.SetFixedHeight( 1, mCurrentStyle->titleHeightWithSubtitle );
- mTitleLayout.AddChild( mTitle, Toolkit::TableView::CellPosition(1,0) );
- mSubTitle.SetText( page.GetSubTitle() );
- mSubTitle.SetStyleToCurrentText(mCurrentStyle->subtitleTextStyle);
- mTitleLayout.AddChild( mSubTitle, Toolkit::TableView::CellPosition(2,0) );
- }
-
// insert title icon to the left of the title(if exist)
if( page.GetTitleIcon() )
{
*
*/
+ // INTERNAL INCLUDES
+ #include <dali-toolkit/public-api/controls/navigation-frame/page.h>
#include <dali-toolkit/public-api/controls/table-view/table-view.h>
-#include <dali-toolkit/public-api/controls/text-view/text-view.h>
#include <dali-toolkit/internal/controls/navigation-frame/navigation-control-impl.h>
#include <dali-toolkit/internal/controls/navigation-frame/navigation-bar.h>
- #include <dali-toolkit/public-api/controls/navigation-frame/page.h>
namespace Dali
{
Toolkit::TableView mTitleLayout;
Toolkit::TableView mTitleIconLayout;
- Toolkit::TextView mTitle;
- Toolkit::TextView mSubTitle;
-
};
} // namespace Internal
*
*/
+ // INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/table-view/table-view.h>
-#include <dali-toolkit/public-api/controls/text-view/text-view.h>
#include <dali-toolkit/internal/controls/navigation-frame/navigation-control-impl.h>
#include <dali-toolkit/internal/controls/navigation-frame/navigation-bar.h>
#include <dali-toolkit/public-api/controls/navigation-frame/page.h>
#include <dali/public-api/events/touch-event.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/integration-api/debug.h>
+ #include <dali/public-api/images/resource-image.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/buttons/button.h>
const Vector3 DEFAULT_DIALOG_SIZE = Vector3(POPUP_TITLE_WIDTH/POPUP_WIDTH, 0.5f, 0.0f);
const Vector3 DEFAULT_BOTTOM_SIZE = Vector3(1.0f, 0.2f, 0.0f);
- const char* const PROPERTY_TITLE = "title";
- const char* const PROPERTY_STATE = "state";
+ // Signals
+
+ const char* const SIGNAL_TOUCHED_OUTSIDE = "touched-outside";
+ const char* const SIGNAL_HIDDEN = "hidden";
+
+ // Properties
+
+ const char* const PROPERTY_TITLE = "title";
+ const char* const PROPERTY_STATE = "state";
/**
* The background size should be at least as big as the Dialog.
return Toolkit::Popup::New();
}
- TypeRegistration typeRegistration( typeid(Toolkit::Popup), typeid(Toolkit::Control), Create );
+ TypeRegistration typeRegistration( typeid( Toolkit::Popup ), typeid( Toolkit::Control ), Create );
- SignalConnectorType signalConnector1( typeRegistration, Toolkit::Popup::SIGNAL_TOUCHED_OUTSIDE, &Popup::DoConnectSignal );
- SignalConnectorType signalConnector2( typeRegistration, Toolkit::Popup::SIGNAL_HIDDEN, &Popup::DoConnectSignal );
+ SignalConnectorType signalConnector1( typeRegistration, SIGNAL_TOUCHED_OUTSIDE, &Popup::DoConnectSignal );
+ SignalConnectorType signalConnector2( typeRegistration, SIGNAL_HIDDEN, &Popup::DoConnectSignal );
}
void Popup::SetTitle( const std::string& text )
{
- Toolkit::TextView titleActor = Toolkit::TextView::New();
- titleActor.SetText( text );
- titleActor.SetColor( Color::BLACK );
- titleActor.SetMultilinePolicy( Toolkit::TextView::SplitByWord );
- titleActor.SetWidthExceedPolicy( Toolkit::TextView::Split );
- titleActor.SetLineJustification( Toolkit::TextView::Center );
-
- SetTitle( titleActor );
-}
-
-void Popup::SetTitle( Toolkit::TextView titleActor )
-{
- // Replaces the current title actor.
- if( mTitle && mPopupBg )
- {
- mPopupBg.Remove( mTitle );
- }
- mTitle = titleActor;
-
- mPopupBg.Add( mTitle );
-
- RelayoutRequest();
}
-Toolkit::TextView Popup::GetTitle() const
+const std::string& Popup::GetTitle() const
{
- return mTitle;
+ static std::string temp("");
+ return temp;
}
void Popup::AddButton( Toolkit::Button button )
if(image != "")
{
- Image tail = Image::New( image );
+ Image tail = ResourceImage::New( image );
mTailImage = ImageActor::New(tail);
const Vector3 anchorPoint = AnchorPoint::FRONT_BOTTOM_RIGHT - position;
void Popup::SetDefaultBackgroundImage()
{
- Image bg = Image::New( mPopupStyle->backgroundImage );
+ Image bg = ResourceImage::New( mPopupStyle->backgroundImage );
ImageActor bgImage = ImageActor::New( bg );
bgImage.SetStyle( ImageActor::STYLE_NINE_PATCH );
bgImage.SetNinePatchBorder( mPopupStyle->backgroundScale9Border );
- Image buttonBg = Image::New( mPopupStyle->buttonAreaImage );
+ Image buttonBg = ResourceImage::New( mPopupStyle->buttonAreaImage );
ImageActor buttonBgImage = ImageActor::New( buttonBg );
buttonBgImage.SetStyle( ImageActor::STYLE_NINE_PATCH );
buttonBgImage.SetNinePatchBorder( mPopupStyle->buttonArea9PatchBorder );
Dali::BaseHandle handle( object );
bool connected( true );
- Toolkit::Popup popup = Toolkit::Popup::DownCast(handle);
+ Toolkit::Popup popup = Toolkit::Popup::DownCast( handle );
- if( Dali::Toolkit::Popup::SIGNAL_TOUCHED_OUTSIDE == signalName )
+ if( 0 == strcmp( signalName.c_str(), SIGNAL_TOUCHED_OUTSIDE ) )
{
popup.OutsideTouchedSignal().Connect( tracker, functor );
}
- else if( Dali::Toolkit::Popup::SIGNAL_HIDDEN == signalName )
+ else if( 0 == strcmp( signalName.c_str(), SIGNAL_HIDDEN ) )
{
popup.HiddenSignal().Connect( tracker, functor );
}
// Relayout title
Vector3 positionOffset( 0.0f, mPopupStyle->margin + POPUP_OUT_MARGIN_WIDTH, CONTENT_DEPTH );
- if( mTitle )
- {
- Vector2 titleSize;
- titleSize.width = popupSize.width;
- titleSize.height = mTitle.GetHeightForWidth( titleSize.width );
-
- // As the default size policy for text-view is Fixed & Fixed, a size needs to be set.
- // Otherwise size-negotiation algorithm uses the GetNaturalSize() with doesn't take
- // into account the multiline and exceed policies, giving as result a wrong size.
- mTitle.SetSize( titleSize );
- Relayout( mTitle, titleSize, container );
-
- mTitle.SetAnchorPoint( AnchorPoint::TOP_CENTER );
- mTitle.SetParentOrigin( ParentOrigin::TOP_CENTER );
- mTitle.SetPosition( positionOffset );
-
- positionOffset.y += titleSize.height + mPopupStyle->margin;
- }
+ // TODO
// Relayout content
if( mContent )
Vector3 naturalSize( 0.0f, 0.0f, 0.0f );
- if ( mTitle )
- {
- Vector3 titleNaturalSize = mTitle.GetImplementation().GetNaturalSize();
- // Buffer to avoid errors. The width of the popup could potentially be the width of the title text.
- // It was observed in this case that text wrapping was then inconsistent when seen on device
- const float titleBuffer = 0.5f;
- titleNaturalSize.width += titleBuffer;
-
- // As TextView GetNaturalSize does not take wrapping into account, limit the width
- // to that of the stage
- if( titleNaturalSize.width >= maxWidth)
- {
- naturalSize.width = maxWidth;
- naturalSize.height = mTitle.GetImplementation().GetHeightForWidth( naturalSize.width );
- }
- else
- {
- naturalSize += titleNaturalSize;
- }
-
- naturalSize.height += mPopupStyle->margin;
- }
-
if( mContent )
{
Vector3 contentSize = RelayoutHelper::GetNaturalSize( mContent );
float height( 0.0f );
float popupWidth( width - 2.f * ( POPUP_OUT_MARGIN_WIDTH + mPopupStyle->margin ) );
- if ( mTitle )
- {
- height += mTitle.GetImplementation().GetHeightForWidth( popupWidth );
- height += mPopupStyle->margin;
- }
-
if( mContent )
{
height += RelayoutHelper::GetHeightForWidth( mContent, popupWidth ) + mPopupStyle->margin;
*
*/
- // FILE HEADER
-
+ // CLASS HEADER
#include "relayout-controller-impl.h"
// EXTERNAL INCLUDES
#include <sstream>
#endif // defined(DEBUG_ENABLED)
-// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/text-view/text-view.h>
-
namespace Dali
{
*
*/
- // FILE HEADER
-
+ // CLASS HEADER
#include "relayout-controller.h"
- #include "relayout-controller-impl.h"
// EXTERNAL INCLUDES
#include <stack>
// INTERNAL INCLUDES
+ #include "relayout-controller-impl.h"
#include "dali-toolkit/public-api/controls/control.h"
#include "dali-toolkit/public-api/controls/control-impl.h"
-#include "dali-toolkit/public-api/controls/text-view/text-view.h"
namespace Dali
{
#include <dali-toolkit/internal/controls/slider/slider-impl.h>
// EXTERNAL INCLUDES
+ #include <sstream>
#include <dali/public-api/events/touch-event.h>
#include <dali/public-api/object/type-registry.h>
+ #include <dali/public-api/images/resource-image.h>
- // EXTERNAL INCLUDES
+ // INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/control-impl.h>
- #include <sstream>
-
using namespace Dali;
namespace Dali
const bool DEFAULT_ENABLED = true;
const bool DEFAULT_SNAP_TO_MARKS = false;
+ // Signals
+
+ const char* const SIGNAL_VALUE_CHANGED = "value-changed";
+ const char* const SIGNAL_MARK = "mark";
+
BaseHandle Create()
{
return Dali::Toolkit::Slider::New();
}
- TypeRegistration typeRegistration( typeid(Dali::Toolkit::Slider), typeid(Dali::Toolkit::Control), Create );
+ TypeRegistration typeRegistration( typeid( Dali::Toolkit::Slider ), typeid( Dali::Toolkit::Control ), Create );
- SignalConnectorType signalConnector1( typeRegistration, Toolkit::Slider::SIGNAL_VALUE_CHANGED, &Toolkit::Internal::Slider::DoConnectSignal );
- SignalConnectorType signalConnector2( typeRegistration, Toolkit::Slider::SIGNAL_MARK, &Toolkit::Internal::Slider::DoConnectSignal );
+ SignalConnectorType signalConnector1( typeRegistration, SIGNAL_VALUE_CHANGED, &Toolkit::Internal::Slider::DoConnectSignal );
+ SignalConnectorType signalConnector2( typeRegistration, SIGNAL_MARK, &Toolkit::Internal::Slider::DoConnectSignal );
PropertyRegistration property1( typeRegistration, "lower-bound", Toolkit::Slider::LOWER_BOUND_PROPERTY, Property::FLOAT, &Slider::SetProperty, &Slider::GetProperty );
PropertyRegistration property2( typeRegistration, "upper-bound", Toolkit::Slider::UPPER_BOUND_PROPERTY, Property::FLOAT, &Slider::SetProperty, &Slider::GetProperty );
mMarkSignal.Emit( self, markIndex );
}
}
-
- if( mHandleValueTextView )
- {
- std::stringstream ss;
- ss.precision( GetValuePrecision() );
- ss << std::fixed << clampledValue;
- mHandleValueTextView.SetText( ss.str() );
- }
}
void Slider::SetMarks( const MarkList& marks )
{
if( mBacking && imageName != String::EMPTY )
{
- Image image = Image::New( imageName );
+ Image image = ResourceImage::New( imageName );
mBacking.SetImage( image );
}
}
{
if( mBacking )
{
- return mBacking.GetImage().GetFilename();
+ return ResourceImage::DownCast( mBacking.GetImage() ).GetUrl();
}
return std::string( "" );
{
if( mProgress && imageName != String::EMPTY )
{
- Image image = Image::New( imageName );
+ Image image = ResourceImage::New( imageName );
mProgress.SetImage( image );
}
}
{
if( mProgress )
{
- return mProgress.GetImage().GetFilename();
+ return ResourceImage::DownCast( mProgress.GetImage()).GetUrl();
}
return std::string( "" );
{
if( mPopup && imageName != String::EMPTY )
{
- Image image = Image::New( imageName );
+ Image image = ResourceImage::New( imageName );
mPopup.SetImage( image );
}
}
{
if( mPopupArrow && imageName != String::EMPTY )
{
- Image image = Image::New( imageName );
+ Image image = ResourceImage::New( imageName );
mPopupArrow.SetImage( image );
}
}
return arrow;
}
-Toolkit::TextView Slider::CreatePopupText()
-{
- Toolkit::TextView textView = Toolkit::TextView::New();
- textView.SetParentOrigin( ParentOrigin::CENTER );
- textView.SetAnchorPoint( AnchorPoint::CENTER );
- textView.SetSizePolicy( Toolkit::Control::Flexible, Toolkit::Control::Flexible );
- textView.SetZ( VALUE_DISPLAY_TEXT_Z );
- return textView;
-}
+//Toolkit::TextView Slider::CreatePopupText()
+//{
+//}
ImageActor Slider::CreatePopup()
{
popup.SetParentOrigin( ParentOrigin::TOP_CENTER );
popup.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
- mValueTextView = CreatePopupText();
- popup.Add( mValueTextView );
-
return popup;
}
{
if( mHandle && imageName != String::EMPTY )
{
- Image image = Image::New( imageName );
+ Image image = ResourceImage::New( imageName );
mHandle.SetImage( image );
}
}
{
if( mHandle )
{
- return mHandle.GetImage().GetFilename();
+ return ResourceImage::DownCast( mHandle.GetImage() ).GetUrl();
}
return std::string( "" );
void Slider::CreateHandleValueDisplay()
{
- if( mHandle && !mHandleValueTextView )
- {
- mHandleValueTextView = Toolkit::TextView::New();
- mHandleValueTextView.SetParentOrigin( ParentOrigin::CENTER );
- mHandleValueTextView.SetAnchorPoint( AnchorPoint::CENTER );
- mHandleValueTextView.SetSize( GetHandleRegion() );
- mHandleValueTextView.SetZ( HANDLE_VALUE_DISPLAY_TEXT_Z );
- mHandle.Add( mHandleValueTextView );
- }
}
void Slider::DestroyHandleValueDisplay()
{
- if(mHandleValueTextView)
- {
- mHandleValueTextView.Unparent();
- mHandleValueTextView.Reset();
- }
}
void Slider::SetPopupTextColor( const Vector4& color )
return mMarkTolerance;
}
- // static class method to support script connecting signals
-
+ // Static class method to support script connecting signals
bool Slider::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
{
Dali::BaseHandle handle( object );
bool connected = true;
Toolkit::Slider slider = Toolkit::Slider::DownCast( handle );
- if( signalName == Dali::Toolkit::Slider::SIGNAL_VALUE_CHANGED )
+ if( 0 == strcmp( signalName.c_str(), SIGNAL_VALUE_CHANGED ) )
{
slider.ValueChangedSignal().Connect( tracker, functor );
}
- else if( signalName == Dali::Toolkit::Slider::SIGNAL_MARK )
+ else if( 0 == strcmp( signalName.c_str(), SIGNAL_MARK ) )
{
slider.MarkSignal().Connect( tracker, functor );
}
void Slider::DisplayPopup( float value )
{
- // Value displayDoConnectSignal
- if( mValueTextView )
- {
- std::stringstream ss;
- ss.precision( GetValuePrecision() );
- ss << std::fixed << value;
- mValueTextView.SetText( ss.str() );
- TextStyle style;
- style.SetTextColor( GetPopupTextColor() );
- mValueTextView.SetStyleToCurrentText( style, TextStyle::COLOR);
-
- if( mValueDisplay )
- {
- Font font = Font::New();
- float popupWidth = font.MeasureText( ss.str() ).x + VALUE_POPUP_MARGIN * 2.0f;
- if( popupWidth < VALUE_POPUP_MIN_WIDTH )
- {
- popupWidth = VALUE_POPUP_MIN_WIDTH;
- }
-
- mPopup.SetSize( popupWidth, VALUE_POPUP_HEIGHT );
- mValueDisplay.SetVisible( true );
-
- mValueTimer.SetInterval( VALUE_VIEW_SHOW_DURATION );
- }
- }
}
void Slider::SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value )
--- /dev/null
- #include <dali/public-api/images/image.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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/internal/controls/text-controls/text-field-impl.h>
+
+// EXTERNAL INCLUDES
- Image image = Image::New( value.Get< std::string >() );
- //ResourceImage image = ResourceImage::New( value.Get< std::string >() );
++#include <dali/public-api/images/resource-image.h>
+#include <dali/public-api/object/type-registry.h>
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/text/layouts/layout-engine.h>
+#include <dali-toolkit/public-api/text/rendering/basic/text-basic-renderer.h> // TODO - Get from RendererFactory
+
+using namespace Dali::Toolkit::Text;
+
+namespace
+{
+
+} // namespace
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+const Property::Index TextField::PROPERTY_PLACEHOLDER_TEXT( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX );
+const Property::Index TextField::PROPERTY_TEXT( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 1 );
+const Property::Index TextField::PROPERTY_CURSOR_IMAGE( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 2 );
+const Property::Index TextField::PROPERTY_PRIMARY_CURSOR_COLOR( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 3 );
+const Property::Index TextField::PROPERTY_SECONDARY_CURSOR_COLOR( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 4 );
+const Property::Index TextField::PROPERTY_ENABLE_CURSOR_BLINK( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 5 );
+const Property::Index TextField::PROPERTY_CURSOR_BLINK_INTERVAL( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 6 );
+const Property::Index TextField::PROPERTY_CURSOR_BLINK_DURATION( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 7 );
+
+namespace Internal
+{
+
+namespace
+{
+
+// Type registration
+BaseHandle Create()
+{
+ return Toolkit::TextField::New();
+}
+
+TypeRegistration mType( typeid(Toolkit::TextField), typeid(Toolkit::Control), Create );
+
+PropertyRegistration property1( mType, "placeholder-text", Toolkit::TextField::PROPERTY_PLACEHOLDER_TEXT, Property::STRING, &TextField::SetProperty, &TextField::GetProperty );
+PropertyRegistration property2( mType, "text", Toolkit::TextField::PROPERTY_TEXT, Property::STRING, &TextField::SetProperty, &TextField::GetProperty );
+PropertyRegistration property3( mType, "cursor-image", Toolkit::TextField::PROPERTY_CURSOR_IMAGE, Property::STRING, &TextField::SetProperty, &TextField::GetProperty );
+PropertyRegistration property4( mType, "primary-cursor-color", Toolkit::TextField::PROPERTY_PRIMARY_CURSOR_COLOR, Property::VECTOR4, &TextField::SetProperty, &TextField::GetProperty );
+PropertyRegistration property5( mType, "secondary-cursor-color", Toolkit::TextField::PROPERTY_SECONDARY_CURSOR_COLOR, Property::VECTOR4, &TextField::SetProperty, &TextField::GetProperty );
+PropertyRegistration property6( mType, "enable-cursor-blink", Toolkit::TextField::PROPERTY_ENABLE_CURSOR_BLINK, Property::BOOLEAN, &TextField::SetProperty, &TextField::GetProperty );
+PropertyRegistration property7( mType, "cursor-blink-interval", Toolkit::TextField::PROPERTY_CURSOR_BLINK_INTERVAL, Property::FLOAT, &TextField::SetProperty, &TextField::GetProperty );
+PropertyRegistration property8( mType, "cursor-blink-duration", Toolkit::TextField::PROPERTY_CURSOR_BLINK_DURATION, Property::FLOAT, &TextField::SetProperty, &TextField::GetProperty );
+
+} // namespace
+
+Toolkit::TextField TextField::New()
+{
+ // Create the implementation, temporarily owned by this handle on stack
+ IntrusivePtr< TextField > impl = new TextField();
+
+ // Pass ownership to CustomActor handle
+ Toolkit::TextField handle( *impl );
+
+ // Second-phase init of the implementation
+ // This can only be done after the CustomActor connection has been made...
+ impl->Initialize();
+
+ return handle;
+}
+
+void TextField::SetRenderer( Text::RendererPtr renderer )
+{
+ mRenderer = renderer;
+}
+
+void TextField::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
+{
+ Toolkit::TextField textField = Toolkit::TextField::DownCast( Dali::BaseHandle( object ) );
+
+ if( textField )
+ {
+ TextField& impl( GetImpl( textField ) );
+
+ switch( index )
+ {
+ case Toolkit::TextField::PROPERTY_PLACEHOLDER_TEXT:
+ {
+ if( impl.mController )
+ {
+ //impl.mController->SetPlaceholderText( value.Get< std::string >() ); TODO
+ }
+ break;
+ }
+ case Toolkit::TextField::PROPERTY_TEXT:
+ {
+ if( impl.mController )
+ {
+ impl.mController->SetText( value.Get< std::string >() );
+ }
+ break;
+ }
+ case Toolkit::TextField::PROPERTY_CURSOR_IMAGE:
+ {
- Image image = impl.mDecorator->GetCursorImage();
- //ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetCursorImage() );
++ ResourceImage image = ResourceImage::New( value.Get< std::string >() );
+
+ if( impl.mDecorator )
+ {
+ impl.mDecorator->SetCursorImage( image );
+ }
+ break;
+ }
+ case Toolkit::TextField::PROPERTY_PRIMARY_CURSOR_COLOR:
+ {
+ if( impl.mDecorator )
+ {
+ impl.mDecorator->SetColor( PRIMARY_CURSOR, value.Get< Vector4 >() );
+ }
+ break;
+ }
+ case Toolkit::TextField::PROPERTY_SECONDARY_CURSOR_COLOR:
+ {
+ if( impl.mDecorator )
+ {
+ impl.mDecorator->SetColor( SECONDARY_CURSOR, value.Get< Vector4 >() );
+ }
+ break;
+ }
+ case Toolkit::TextField::PROPERTY_ENABLE_CURSOR_BLINK:
+ {
+ if( impl.mController )
+ {
+ //impl.mController->SetEnableCursorBlink( value.Get< bool >() ); TODO
+ }
+ break;
+ }
+ case Toolkit::TextField::PROPERTY_CURSOR_BLINK_INTERVAL:
+ {
+ if( impl.mDecorator )
+ {
+ impl.mDecorator->SetCursorBlinkInterval( value.Get< float >() );
+ }
+ break;
+ }
+ case Toolkit::TextField::PROPERTY_CURSOR_BLINK_DURATION:
+ {
+ if( impl.mDecorator )
+ {
+ impl.mDecorator->SetCursorBlinkDuration( value.Get< float >() );
+ }
+ break;
+ }
+ }
+ }
+}
+
+Property::Value TextField::GetProperty( BaseObject* object, Property::Index index )
+{
+ Property::Value value;
+
+ Toolkit::TextField textField = Toolkit::TextField::DownCast( Dali::BaseHandle( object ) );
+
+ if( textField )
+ {
+ TextField& impl( GetImpl( textField ) );
+
+ switch( index )
+ {
+ case Toolkit::TextField::PROPERTY_PLACEHOLDER_TEXT:
+ {
+ DALI_LOG_WARNING( "UTF-8 text representation was discarded\n" );
+ break;
+ }
+ case Toolkit::TextField::PROPERTY_TEXT:
+ {
+ DALI_LOG_WARNING( "UTF-8 text representation was discarded\n" );
+ break;
+ }
+ case Toolkit::TextField::PROPERTY_CURSOR_IMAGE:
+ {
+ if( impl.mDecorator )
+ {
- value = image.GetFilename();
- //value = image.GetUrl();
++ ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetCursorImage() );
+ if( image )
+ {
++ value = image.GetUrl();
+ }
+ }
+ break;
+ }
+ case Toolkit::TextField::PROPERTY_PRIMARY_CURSOR_COLOR:
+ {
+ if( impl.mDecorator )
+ {
+ value = impl.mDecorator->GetColor( PRIMARY_CURSOR );
+ }
+ break;
+ }
+ case Toolkit::TextField::PROPERTY_SECONDARY_CURSOR_COLOR:
+ {
+ if( impl.mDecorator )
+ {
+ value = impl.mDecorator->GetColor( SECONDARY_CURSOR );
+ }
+ break;
+ }
+ case Toolkit::TextField::PROPERTY_ENABLE_CURSOR_BLINK:
+ {
+ //value = impl.mController->GetEnableCursorBlink(); TODO
+ break;
+ }
+ case Toolkit::TextField::PROPERTY_CURSOR_BLINK_INTERVAL:
+ {
+ if( impl.mDecorator )
+ {
+ value = impl.mDecorator->GetCursorBlinkInterval();
+ }
+ break;
+ }
+ case Toolkit::TextField::PROPERTY_CURSOR_BLINK_DURATION:
+ {
+ if( impl.mDecorator )
+ {
+ value = impl.mDecorator->GetCursorBlinkDuration();
+ }
+ break;
+ }
+ }
+ }
+
+ return value;
+}
+
+void TextField::OnInitialize()
+{
+ mDecorator = Text::Decorator::New( *this );
+
+ mController = Text::Controller::New();
+ mController->GetLayoutEngine().SetLayout( LayoutEngine::SINGLE_LINE_BOX );
+ //mController->EnableTextInput( mDecorator ); TODO
+}
+
+void TextField::OnRelayout( const Vector2& size, ActorSizeContainer& container )
+{
+ if( mController->Relayout( size ) )
+ {
+ if( !mRenderer )
+ {
+ // TODO - Get from RendererFactory
+ mRenderer = Dali::Toolkit::Text::BasicRenderer::New();
+ }
+
+ if( mRenderer )
+ {
+ Actor renderableActor = mRenderer->Render( mController->GetView() );
+
+ if( renderableActor )
+ {
+ Self().Add( renderableActor );
+ }
+ }
+ }
+}
+
+TextField::TextField()
+: Control( ControlBehaviour( CONTROL_BEHAVIOUR_NONE ) )
+{
+}
+
+TextField::~TextField()
+{
+}
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
*
*/
+ // CLASS HEADER
#include <dali-toolkit/public-api/controls/popup/popup.h>
+
+ // INTERNAL INCLUDES
#include <dali-toolkit/internal/controls/popup/popup-impl.h>
#include <dali-toolkit/public-api/controls/buttons/button.h>
// Popup
///////////////////////////////////////////////////////////////////////////////////////////////////
- const char* const Popup::SIGNAL_TOUCHED_OUTSIDE = "touched-outside";
- const char* const Popup::SIGNAL_HIDDEN = "hidden";
-
Popup::Popup()
{
}
GetImpl(*this).SetTitle( text );
}
-void Popup::SetTitle( TextView titleActor )
-{
- GetImpl(*this).SetTitle( titleActor );
-}
-
-TextView Popup::GetTitle() const
+const std::string& Popup::GetTitle() const
{
return GetImpl(*this).GetTitle();
}
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/control.h>
-#include <dali-toolkit/public-api/controls/text-view/text-view.h>
namespace Dali
{
*
* A popup can use various custom transition effects, e.g.
* Alpha fade, Scaling transition, position/rotation, shader effects.
+ *
+ * Signals
+ * | %Signal Name | Method |
+ * |-------------------|------------------------------|
+ * | touched-outside | @ref OutsideTouchedSignal() |
+ * | hidden | @ref HiddenSignal() |
*/
class DALI_IMPORT_API Popup : public Control
{
public:
- //Signal Names
- static const char* const SIGNAL_TOUCHED_OUTSIDE; ///< name "touched-outside"
- static const char* const SIGNAL_HIDDEN; ///< name "hidden"
-
/**
* @brief Current popup state.
*/
void SetTitle( const std::string& text );
/**
- * @brief Sets a title for this Popup.
- *
- * @param[in] titleActor The TextView to appear as the heading for this Popup
- */
- void SetTitle( TextView titleActor );
-
- /**
* @brief Gets the text (TextView) for this Popup.
*
- * @return The TextView representing this popup is returned.
+ * @return The text to appear as the heading for this Popup
*/
- TextView GetTitle() const;
+ const std::string& GetTitle() const;
/**
* @brief Adds a button to this Popup.
$(public_api_src_dir)/controls/slider/slider.cpp \
$(public_api_src_dir)/controls/super-blur-view/super-blur-view.cpp \
$(public_api_src_dir)/controls/table-view/table-view.cpp \
- $(public_api_src_dir)/controls/text-input/text-input.cpp \
- $(public_api_src_dir)/controls/text-view/text-view.cpp \
+ $(public_api_src_dir)/controls/text-controls/text-label.cpp \
++ $(public_api_src_dir)/controls/text-controls/text-field.cpp \
$(public_api_src_dir)/controls/tool-bar/tool-bar.cpp \
$(public_api_src_dir)/controls/bloom-view/bloom-view.cpp \
$(public_api_src_dir)/controls/cluster/cluster-style.cpp \
$(public_api_src_dir)/focus-manager/focus-manager.cpp \
$(public_api_src_dir)/focus-manager/keyboard-focus-manager.cpp \
$(public_api_src_dir)/focus-manager/keyinput-focus-manager.cpp \
- $(public_api_src_dir)/markup-processor/markup-processor.cpp \
$(public_api_src_dir)/shader-effects/bubble-effect/bubble-effect.cpp \
$(public_api_src_dir)/shader-effects/bubble-effect/color-adjuster.cpp \
$(public_api_src_dir)/shader-effects/alpha-discard-effect.cpp \
$(public_api_src_dir)/shader-effects/overlay-effect.cpp \
$(public_api_src_dir)/shader-effects/page-turn-book-spine-effect.cpp \
$(public_api_src_dir)/shader-effects/page-turn-effect.cpp \
+ $(public_api_src_dir)/shader-effects/quadratic-bezier.cpp \
$(public_api_src_dir)/shader-effects/ripple-effect.cpp \
$(public_api_src_dir)/shader-effects/ripple2d-effect.cpp \
$(public_api_src_dir)/shader-effects/shear-effect.cpp \
$(public_api_src_dir)/shader-effects/swirl-effect.cpp \
$(public_api_src_dir)/shader-effects/water-effect.cpp \
$(public_api_src_dir)/styling/style-manager.cpp \
+ $(public_api_src_dir)/text/bidirectional-support.cpp \
+ $(public_api_src_dir)/text/character-set-conversion.cpp \
+ $(public_api_src_dir)/text/logical-model.cpp \
+ $(public_api_src_dir)/text/multi-language-support.cpp \
+ $(public_api_src_dir)/text/script.cpp \
+ $(public_api_src_dir)/text/segmentation.cpp \
+ $(public_api_src_dir)/text/shaper.cpp \
+ $(public_api_src_dir)/text/text-controller.cpp \
+ $(public_api_src_dir)/text/text-view.cpp \
+ $(public_api_src_dir)/text/text-view-interface.cpp \
+ $(public_api_src_dir)/text/visual-model.cpp \
+ $(public_api_src_dir)/text/decorator/text-decorator.cpp \
+ $(public_api_src_dir)/text/layouts/layout-engine.cpp \
+ $(public_api_src_dir)/text/rendering/text-renderer.cpp \
+ $(public_api_src_dir)/text/rendering/basic/text-basic-renderer.cpp \
+ $(public_api_src_dir)/text/rendering/shaders/text-basic-shader.cpp \
$(public_api_src_dir)/transition-effects/cube-transition-cross-effect.cpp \
$(public_api_src_dir)/transition-effects/cube-transition-effect.cpp \
$(public_api_src_dir)/transition-effects/cube-transition-fold-effect.cpp \
public_api_table_view_header_files = \
$(public_api_src_dir)/controls/table-view/table-view.h
- $(public_api_src_dir)/controls/text-controls/text-label.h
+public_api_text_controls_header_files = \
++ $(public_api_src_dir)/controls/text-controls/text-label.h \
++ $(public_api_src_dir)/controls/text-controls/text-field.h
+
+public_api_text_header_files = \
+ $(public_api_src_dir)/text/bidirectional-line-info-run.h \
+ $(public_api_src_dir)/text/bidirectional-paragraph-info-run.h \
+ $(public_api_src_dir)/text/bidirectional-support.h \
+ $(public_api_src_dir)/text/character-run.h \
+ $(public_api_src_dir)/text/character-set-conversion.h \
+ $(public_api_src_dir)/text/font-run.h \
+ $(public_api_src_dir)/text/line-run.h \
+ $(public_api_src_dir)/text/logical-model.h \
+ $(public_api_src_dir)/text/multi-language-support.h \
+ $(public_api_src_dir)/text/script.h \
+ $(public_api_src_dir)/text/script-run.h \
+ $(public_api_src_dir)/text/segmentation.h \
+ $(public_api_src_dir)/text/shaper.h \
+ $(public_api_src_dir)/text/text-controller.h \
+ $(public_api_src_dir)/text/text-definitions.h \
+ $(public_api_src_dir)/text/text-view.h \
+ $(public_api_src_dir)/text/text-view-interface.h \
+ $(public_api_src_dir)/text/visual-model.h
+
+public_api_text_decorator_header_files = \
+ $(public_api_src_dir)/text/decorator/text-decorator.h
+
+public_api_text_layouts_header_files = \
+ $(public_api_src_dir)/text/layouts/layout-engine.h
+
+public_api_text_rendering_header_files = \
+ $(public_api_src_dir)/text/rendering/text-renderer.h
+
+public_api_text_rendering_basic_header_files = \
+ $(public_api_src_dir)/text/rendering/basic/text-basic-renderer.h
+
+public_api_text_rendering_shaders_header_files = \
+ $(public_api_src_dir)/text/rendering/shaders/text-basic-shader.h
+
public_api_text_input_header_files = \
$(public_api_src_dir)/controls/text-input/text-input.h
$(public_api_src_dir)/focus-manager/keyboard-focus-manager.h \
$(public_api_src_dir)/focus-manager/keyinput-focus-manager.h
-public_api_markup_processor_header_files = \
- $(public_api_src_dir)/markup-processor/markup-processor.h
-
public_api_shader_effects_header_files = \
$(public_api_src_dir)/shader-effects/alpha-discard-effect.h \
$(public_api_src_dir)/shader-effects/bendy-effect.h \
$(public_api_src_dir)/shader-effects/overlay-effect.h \
$(public_api_src_dir)/shader-effects/page-turn-book-spine-effect.h \
$(public_api_src_dir)/shader-effects/page-turn-effect.h \
+ $(public_api_src_dir)/shader-effects/quadratic-bezier.h \
$(public_api_src_dir)/shader-effects/ripple-effect.h \
$(public_api_src_dir)/shader-effects/ripple2d-effect.h \
$(public_api_src_dir)/shader-effects/shear-effect.h \
--- /dev/null
- Impl(Internal::Control& parent)
+/*
+ * 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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/public-api/text/decorator/text-decorator.h>
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/common/constants.h>
+#include <dali/public-api/images/image.h>
+#include <dali/public-api/math/vector2.h>
+#include <dali/public-api/math/vector4.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+struct Decorator::Impl
+{
+ struct CursorImpl
+ {
+ CursorImpl()
+ : x(0.0f),
+ y(0.0f),
+ height(0.0f),
+ color(Dali::Color::WHITE)
+ {
+ }
+
+ float x;
+ float y;
+ float height;
+
+ Vector4 color;
+ };
+
- Decorator::Decorator(Internal::Control& parent)
++ Impl(Dali::Toolkit::Internal::Control& parent)
+ : mParent(parent),
+ mActiveCursor(ACTIVE_CURSOR_NONE),
+ mCursorBlinkInterval(0.5f),
+ mCursorBlinkDuration(0.0f)
+ {
+ }
+
+ void Relayout( const Vector2& size )
+ {
+ // TODO
+ }
+
+ Internal::Control& mParent;
+
+ unsigned int mActiveCursor;
+
+ CursorImpl mCursor[CURSOR_COUNT];
+
+ Image mCursorImage;
+
+ float mCursorBlinkInterval;
+ float mCursorBlinkDuration;
+};
+
+DecoratorPtr Decorator::New(Internal::Control& parent)
+{
+ return DecoratorPtr( new Decorator(parent) );
+}
+
+void Decorator::Relayout( const Vector2& size )
+{
+ mImpl->Relayout( size );
+}
+
+void Decorator::SetActiveCursor( ActiveCursor activeCursor )
+{
+ mImpl->mActiveCursor = activeCursor;
+}
+
+unsigned int Decorator::GetActiveCursor() const
+{
+ return mImpl->mActiveCursor;
+}
+
+void Decorator::SetPosition( Cursor cursor, float x, float y, float height )
+{
+ mImpl->mCursor[cursor].x = x;
+ mImpl->mCursor[cursor].y = y;
+ mImpl->mCursor[cursor].height = height;
+}
+
+void Decorator::GetPosition( Cursor cursor, float& x, float& y, float& height ) const
+{
+ x = mImpl->mCursor[cursor].x;
+ y = mImpl->mCursor[cursor].y;
+ height = mImpl->mCursor[cursor].height;
+}
+
+void Decorator::SetCursorImage( Dali::Image image )
+{
+ mImpl->mCursorImage = image;
+}
+
+Dali::Image Decorator::GetCursorImage() const
+{
+ return mImpl->mCursorImage;
+}
+
+void Decorator::SetColor( Cursor cursor, const Dali::Vector4& color )
+{
+ mImpl->mCursor[cursor].color = color;
+}
+
+const Dali::Vector4& Decorator::GetColor( Cursor cursor ) const
+{
+ return mImpl->mCursor[cursor].color;
+}
+
+void Decorator::StartCursorBlink()
+{
+ // TODO
+}
+
+void Decorator::StopCursorBlink()
+{
+ // TODO
+}
+
+void Decorator::SetCursorBlinkInterval( float seconds )
+{
+ mImpl->mCursorBlinkInterval = seconds;
+}
+
+float Decorator::GetCursorBlinkInterval() const
+{
+ return mImpl->mCursorBlinkInterval;
+}
+
+void Decorator::SetCursorBlinkDuration( float seconds )
+{
+ mImpl->mCursorBlinkDuration = seconds;
+}
+
+float Decorator::GetCursorBlinkDuration() const
+{
+ return mImpl->mCursorBlinkDuration;
+}
+
+Decorator::~Decorator()
+{
+ delete mImpl;
+}
+
++Decorator::Decorator(Dali::Toolkit::Internal::Control& parent)
+: mImpl( NULL )
+{
+ mImpl = new Decorator::Impl(parent);
+}
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
- static DecoratorPtr New( Internal::Control& parent );
+#ifndef __DALI_TOOLKIT_TEXT_DECORATOR_H__
+#define __DALI_TOOLKIT_TEXT_DECORATOR_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/common/intrusive-ptr.h>
+#include <dali/public-api/object/ref-object.h>
+
+namespace Dali
+{
+
+class Image;
+class Vector2;
+class Vector4;
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+class Control;
+}
+
+namespace Text
+{
+
+class Decorator;
+typedef IntrusivePtr<Decorator> DecoratorPtr;
+
+// Used to set the cursor positions etc.
+enum Cursor
+{
+ PRIMARY_CURSOR, ///< The primary cursor for bidirectional text (or the regular cursor for single-direction text)
+ SECONDARY_CURSOR, ///< The secondary cursor for bidirectional text
+ CURSOR_COUNT
+};
+
+// Determines which of the cursors are active (if any).
+enum ActiveCursor
+{
+ ACTIVE_CURSOR_NONE, ///< Neither primary nor secondary cursor are active
+ ACTIVE_CURSOR_PRIMARY, ///< Primary cursor is active (only)
+ ACTIVE_CURSOR_BOTH ///< Both primary and secondary cursor are active
+};
+
+/**
+ * @brief A Text Decorator is used to display cursors, handles, selection highlights and pop-ups.
+ *
+ * The decorator is responsible for clipping decorations which are positioned outside of the parent area.
+ * In some cases the decorations will be moved or flipped around, to maintain visibility on-screen.
+ */
+class Decorator : public RefObject
+{
+public:
+
+ /**
+ * @brief Create a new instance of a Decorator.
+ *
+ * @param[in] parent Decorations will be added to this parent control.
+ * @return A pointer to a new Decorator.
+ */
- Decorator(Internal::Control& parent);
++ static DecoratorPtr New( Dali::Toolkit::Internal::Control& parent );
+
+ /**
+ * @brief The decorator waits until a relayout before creating actors etc.
+ *
+ * @param[in] size The size of the parent control after size-negotiation.
+ */
+ void Relayout( const Dali::Vector2& size );
+
+ /**
+ * @brief Sets which of the cursors are active.
+ *
+ * @note Cursor will only be visible if within the parent area.
+ * @param[in] activeCursor Which of the cursors should be active (if any).
+ */
+ void SetActiveCursor( ActiveCursor activeCursor );
+
+ /**
+ * @brief Sets whether a cursor should be visible.
+ *
+ * @return Which of the cursors are active (if any).
+ */
+ unsigned int GetActiveCursor() const;
+
+ /**
+ * @brief Sets the position of a cursor.
+ *
+ * @param[in] cursor The cursor to set.
+ * @param[in] x The x position relative to the top-left of the parent control.
+ * @param[in] y The y position relative to the top-left of the parent control.
+ * @param[in] height The logical height of the cursor.
+ */
+ void SetPosition( Cursor cursor, float x, float y, float height );
+
+ /**
+ * @brief Retrieves the position of a cursor.
+ *
+ * @param[in] cursor The cursor to get.
+ * @param[out] x The x position relative to the top-left of the parent control.
+ * @param[out] y The y position relative to the top-left of the parent control.
+ * @param[out] height The logical height of the cursor.
+ */
+ void GetPosition( Cursor cursor, float& x, float& y, float& height ) const;
+
+ /**
+ * @brief Sets the image for a cursor.
+ *
+ * @param[in] image The image to use.
+ */
+ void SetCursorImage( Dali::Image image );
+
+ /**
+ * @brief Retrieves the image for a cursor.
+ *
+ * @return The cursor image.
+ */
+ Dali::Image GetCursorImage() const;
+
+ /**
+ * @brief Sets the color for a cursor.
+ *
+ * @param[in] cursor Whether this color is for the primary or secondary cursor.
+ * @param[in] color The color to use.
+ */
+ void SetColor( Cursor cursor, const Dali::Vector4& color );
+
+ /**
+ * @brief Retrieves the color for a cursor.
+ *
+ * @param[in] cursor Whether this color is for the primary or secondary cursor.
+ * @return The cursor color.
+ */
+ const Dali::Vector4& GetColor( Cursor cursor ) const;
+
+ /**
+ * @brief Start blinking the cursor; see also SetCursorBlinkDuration().
+ */
+ void StartCursorBlink();
+
+ /**
+ * @brief Stop blinking the cursor.
+ */
+ void StopCursorBlink();
+
+ /**
+ * @brief Set the interval between cursor blinks.
+ *
+ * @param[in] seconds The interval in seconds.
+ */
+ void SetCursorBlinkInterval( float seconds );
+
+ /**
+ * @brief Retrieves the blink-interval for a cursor.
+ *
+ * @return The cursor blink-interval.
+ */
+ float GetCursorBlinkInterval() const;
+
+ /**
+ * @brief The cursor will stop blinking after this duration.
+ *
+ * @param[in] seconds The duration in seconds.
+ */
+ void SetCursorBlinkDuration( float seconds );
+
+ /**
+ * @brief Retrieves the blink-duration for a cursor.
+ *
+ * @return The cursor blink-duration.
+ */
+ float GetCursorBlinkDuration() const;
+
+protected:
+
+ /**
+ * @brief A reference counted object may only be deleted by calling Unreference().
+ */
+ virtual ~Decorator();
+
+private:
+
+ /**
+ * @brief Private constructor.
+ * @param[in] parent Decorations will be added to this parent control.
+ */
++ Decorator(Dali::Toolkit::Internal::Control& parent);
+
+ // Undefined
+ Decorator( const Decorator& handle );
+
+ // Undefined
+ Decorator& operator=( const Decorator& handle );
+
+private:
+
+ struct Impl;
+ Impl* mImpl;
+};
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_TOOLKIT_TEXT_DECORATOR_H__
--- /dev/null
- const Length numberOfScriptRuns = scripts.Count();
-
+/*
+ * 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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/public-api/text/shaper.h>
+
+// INTERNAL INCLUDES
+#include <dali/public-api/text-abstraction/shaping.h>
+#include <dali-toolkit/public-api/text/font-run.h>
+#include <dali-toolkit/public-api/text/logical-model.h>
+#include <dali-toolkit/public-api/text/script-run.h>
+#include <dali-toolkit/public-api/text/visual-model.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+CharacterIndex min( CharacterIndex index0,
+ CharacterIndex index1 )
+{
+ return ( index0 < index1 ) ? index0 : index1;
+}
+
+void ShapeText( const Vector<Character>& text,
+ const Vector<LineBreakInfo>& lineBreakInfo,
+ const Vector<ScriptRun>& scripts,
+ const Vector<FontRun>& fonts,
+ Vector<GlyphInfo>& glyphs,
+ Vector<CharacterIndex>& characterIndices,
+ Vector<Length>& charactersPerGlyph )
+{
+ const Length numberOfCharacters = text.Count();
+
+ if( 0u == numberOfCharacters )
+ {
+ // Nothing to do if there are no characters.
+ return;
+ }
+
++#ifdef DEBUG_ENABLED
+ const Length numberOfFontRuns = fonts.Count();
++ const Length numberOfScriptRuns = scripts.Count();
++#endif
+
+ DALI_ASSERT_DEBUG( ( 0u != numberOfFontRuns ) &&
+ ( numberOfCharacters == fonts[numberOfFontRuns - 1u].characterRun.characterIndex + fonts[numberOfFontRuns - 1u].characterRun.numberOfCharacters ) &&
+ "Toolkit::Text::ShapeText. All characters must have a font set." );
+
+ DALI_ASSERT_DEBUG( ( 0u != numberOfScriptRuns ) &&
+ ( numberOfCharacters == scripts[numberOfScriptRuns - 1u].characterRun.characterIndex + scripts[numberOfScriptRuns - 1u].characterRun.numberOfCharacters ) &&
+ "Toolkit::Text::ShapeText. All characters must have a script set." );
+
+ // The text needs to be split in chunks of consecutive characters.
+ // Each chunk must contain characters with the same font id and script set.
+ // A chunk of consecutive characters must not contain a LINE_MUST_BREAK, if there is one a new chunk have to be created.
+
+ TextAbstraction::Shaping shaping = TextAbstraction::Shaping::Get();
+
+ // To shape the text a font and an script is needed.
+ Vector<FontRun>::ConstIterator fontRunIt = fonts.Begin();
+ Vector<ScriptRun>::ConstIterator scriptRunIt = scripts.Begin();
+
+ // The line must break token converted to LineBreakInfo to be compared and avoid a compile error.
+ const LineBreakInfo MUST_BREAK = static_cast<LineBreakInfo>( TextAbstraction::LINE_MUST_BREAK );
+
+ // Index to the the next one to be shaped. Is pointing the character after the last one it was shaped.
+ CharacterIndex previousIndex = 0u;
+
+ // The current font id and script used to shape the text.
+ FontId currentFontId = 0u;
+ Script currentScript = TextAbstraction::UNKNOWN;
+
+ // Reserve some space to allocate the glyphs and the glyph to character map.
+ // There is no way to know the number of glyphs before shaping the text.
+ // To avoid reallocations it's reserved space for a slightly biger number of glyphs than the number of characters.
+
+ Length numberOfGlyphsReserved = static_cast<Length>( numberOfCharacters * 1.3f );
+ glyphs.Resize( numberOfGlyphsReserved );
+ charactersPerGlyph.Resize( numberOfGlyphsReserved );
+
+ // The actual number of glyphs.
+ Length totalNumberOfGlyphs = 0u;
+
+ // Traverse the characters and shape the text.
+ for( previousIndex = 0; previousIndex < numberOfCharacters; )
+ {
+ // Get the font id and the script.
+ const FontRun& fontRun = *fontRunIt;
+ const ScriptRun& scriptRun = *scriptRunIt;
+
+ currentFontId = fontRun.fontId;
+ currentScript = scriptRun.script;
+
+ // Get the min index to the last character of both runs.
+ CharacterIndex currentIndex = min( fontRun.characterRun.characterIndex + fontRun.characterRun.numberOfCharacters,
+ scriptRun.characterRun.characterIndex + scriptRun.characterRun.numberOfCharacters );
+
+ // Check if there is a line must break.
+ for( CharacterIndex index = previousIndex; index < currentIndex; ++index )
+ {
+ if( MUST_BREAK == lineBreakInfo.Begin() + index )
+ {
+ currentIndex = index;
+ break;
+ }
+ }
+
+ // Shape the text for the current chunk.
+ const Length numberOfGlyphs = shaping.Shape( text.Begin() + previousIndex,
+ currentIndex - previousIndex,
+ currentFontId,
+ currentScript );
+
+ const Length glyphIndex = totalNumberOfGlyphs;
+ totalNumberOfGlyphs += numberOfGlyphs;
+
+ if( totalNumberOfGlyphs > numberOfGlyphsReserved )
+ {
+ // Resize the vectors to get enough space.
+ numberOfGlyphsReserved = static_cast<Length>( totalNumberOfGlyphs * 1.3f );
+ glyphs.Resize( numberOfGlyphsReserved );
+ charactersPerGlyph.Resize( numberOfGlyphsReserved );
+ }
+
+ // Retrieve the glyphs and the glyph to character conversion map.
+ shaping.GetGlyphs( glyphs.Begin() + glyphIndex,
+ charactersPerGlyph.Begin() + glyphIndex );
+
+ // Update the iterators to get the next font or script run.
+ if( currentIndex == fontRun.characterRun.characterIndex + fontRun.characterRun.numberOfCharacters )
+ {
+ ++fontRunIt;
+ }
+ if( currentIndex == scriptRun.characterRun.characterIndex + scriptRun.characterRun.numberOfCharacters )
+ {
+ ++scriptRunIt;
+ }
+
+ // Update the previous index.
+ previousIndex = currentIndex;
+ }
+
+ characterIndices.Reserve( totalNumberOfGlyphs );
+ CharacterIndex characterIndex = 0u;
+ characterIndices.PushBack( characterIndex );
+ for( Length index = 0u, length = totalNumberOfGlyphs - 1u; index < length; ++index )
+ {
+ characterIndex += *( charactersPerGlyph.Begin() + index );
+ characterIndices.PushBack( characterIndex );
+ }
+
+ // Resize the vectors to set the right number of items.
+ glyphs.Resize( totalNumberOfGlyphs );
+ // characterIndices.Resize( totalNumberOfGlyphs );
+ charactersPerGlyph.Resize( totalNumberOfGlyphs );
+}
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
Name: dali-toolkit
Summary: The OpenGLES Canvas Core Library Toolkit
- Version: 1.0.29
+ Version: 1.0.30
Release: 1
Group: System/Libraries
License: Apache-2.0
BuildRequires: boost-devel
BuildRequires: pkgconfig(dali)
BuildRequires: pkgconfig(dali-core)
-BuildRequires: fribidi-devel
%description
The OpenGLES Canvas Core Library Toolkit - a set of controls that provide
%build
PREFIX="/usr"
CXXFLAGS+=" -Wall -g -Os -fPIC -fvisibility-inlines-hidden -fdata-sections -ffunction-sections "
- LDFLAGS+=" -Wl,--rpath=$PREFIX/lib -Wl,--as-needed -Wl,--gc-sections "
+ LDFLAGS+=" -Wl,--rpath=$PREFIX/lib -Wl,--as-needed -Wl,--gc-sections -Wl,-Bsymbolic-functions "
libtoolize --force
cd %{_builddir}/dali-toolkit-%{version}/build/tizen