// EXTERNAL INCLUDES
#include <dali-toolkit/dali-toolkit.h>
-#include <dali/public-api/text-abstraction/text-abstraction.h>
+#include <iostream>
// INTERNAL INCLUDES
#include "shared/multi-language-strings.h"
namespace
{
- const char* const BACKGROUND_IMAGE = DALI_IMAGE_DIR "button-up.9.png";
+ const char* const BACKGROUND_IMAGE = DEMO_IMAGE_DIR "grab-handle.png";
const unsigned int KEY_ZERO = 10;
const unsigned int KEY_ONE = 11;
+ const unsigned int KEY_F = 41;
const unsigned int KEY_H = 43;
const unsigned int KEY_V = 55;
const unsigned int KEY_M = 58;
*/
void Create( Application& application )
{
- DemoHelper::RequestThemeChange();
-
Stage stage = Stage::GetCurrent();
stage.KeyEventSignal().Connect(this, &TextLabelExample::OnKeyEvent);
mContainer.SetParentOrigin( ParentOrigin::CENTER );
mLayoutSize = Vector2(stageSize.width*0.6f, stageSize.width*0.6f);
mContainer.SetSize( mLayoutSize );
- mContainer.SetBackgroundImage( ResourceImage::New( BACKGROUND_IMAGE ) );
- mContainer.GetChildAt(0).SetZ(-1.0f);
+ mContainer.SetDrawMode( DrawMode::OVERLAY_2D );
stage.Add( mContainer );
// Resize the center layout when the corner is grabbed
- mGrabCorner = Control::New();
+ mGrabCorner = ImageView::New( BACKGROUND_IMAGE );
mGrabCorner.SetName( "GrabCorner" );
- mGrabCorner.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
+ mGrabCorner.SetAnchorPoint( AnchorPoint::TOP_CENTER );
mGrabCorner.SetParentOrigin( ParentOrigin::BOTTOM_RIGHT );
- mGrabCorner.SetSize( Vector2(stageSize.width*0.1f, stageSize.width*0.1f) );
- mGrabCorner.SetZ(1.0f);
+ mGrabCorner.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
mContainer.Add( mGrabCorner );
mPanGestureDetector = PanGestureDetector::New();
mLabel.SetName( "TextLabel" );
mLabel.SetAnchorPoint( AnchorPoint::TOP_LEFT );
mLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
- mLabel.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT );
+ mLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
mLabel.SetProperty( TextLabel::Property::MULTI_LINE, true );
+ mLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
mLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) );
mLabel.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLACK );
+ mLabel.SetBackgroundColor( Color::WHITE );
mContainer.Add( mLabel );
Property::Value labelText = mLabel.GetProperty( TextLabel::Property::TEXT );
// Resize the text-label with pan gesture
void OnPan( Actor actor, const PanGesture& gesture )
{
+ // Reset mLayoutSize when the pan starts
+ if( gesture.state == Gesture::Started )
+ {
+ if( mLayoutSize.x < 2.0f )
+ {
+ mLayoutSize.x = 2.0f;
+ }
+
+ if( mLayoutSize.y < 2.0f )
+ {
+ mLayoutSize.y = 2.0f;
+ }
+ }
+
mLayoutSize.x += gesture.displacement.x * 2.0f;
mLayoutSize.y += gesture.displacement.y * 2.0f;
- if( mLayoutSize.x >= 2.0f &&
+ if( mLayoutSize.x >= 2.0f ||
mLayoutSize.y >= 2.0f )
{
// Avoid pixel mis-alignment issue
- Vector2 clampedSize = Vector2( ConvertToEven(static_cast<int>(mLayoutSize.x)),
- ConvertToEven(static_cast<int>(mLayoutSize.y)) );
+ Vector2 clampedSize = Vector2( std::max( ConvertToEven( static_cast<int>( mLayoutSize.x )), 2 ),
+ std::max( ConvertToEven( static_cast<int>( mLayoutSize.y )), 2 ) );
mContainer.SetSize( clampedSize );
}
{
switch( event.keyCode )
{
+ // Select rendering back-end
case KEY_ZERO: // fall through
case KEY_ONE:
{
mLabel.SetProperty( TextLabel::Property::RENDERING_BACKEND, event.keyCode - 10 );
break;
}
- case KEY_H:
+ case KEY_F: // Fill vertically
+ {
+ if( ResizePolicy::DIMENSION_DEPENDENCY == mLabel.GetResizePolicy(Dimension::HEIGHT) )
+ {
+ mLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
+ }
+ else
+ {
+ mLabel.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT );
+ }
+ break;
+ }
+ case KEY_H: // Horizontal alignment
{
if( ++mAlignment >= H_ALIGNMENT_STRING_COUNT )
{
mLabel.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, H_ALIGNMENT_STRING_TABLE[ mAlignment ] );
break;
}
- case KEY_V:
+ case KEY_V: // Vertical alignment
{
if( ++mAlignment >= V_ALIGNMENT_STRING_COUNT )
{
mLabel.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, V_ALIGNMENT_STRING_TABLE[ mAlignment ] );
break;
}
- case KEY_M:
+ case KEY_M: // Multi-line
{
bool multiLine = mLabel.GetProperty<bool>( TextLabel::Property::MULTI_LINE );
mLabel.SetProperty( TextLabel::Property::MULTI_LINE, !multiLine );
break;
}
- case KEY_L:
+ case KEY_L: // Language
{
const Language& language = LANGUAGES[ mLanguageId ];
}
break;
}
- case KEY_S:
+ case KEY_S: // Shadow color
{
if( Color::BLACK == mLabel.GetProperty<Vector4>( TextLabel::Property::SHADOW_COLOR ) )
{
}
break;
}
- case KEY_PLUS:
+ case KEY_PLUS: // Increase shadow offset
{
mLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, mLabel.GetProperty<Vector2>( TextLabel::Property::SHADOW_OFFSET ) + Vector2( 1.0f, 1.0f ) );
break;
}
- case KEY_MINUS:
+ case KEY_MINUS: // Decrease shadow offset
{
mLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, mLabel.GetProperty<Vector2>( TextLabel::Property::SHADOW_OFFSET ) - Vector2( 1.0f, 1.0f ) );
break;
TextLabel mLabel;
Control mContainer;
- Actor mGrabCorner;
+ Control mGrabCorner;
PanGestureDetector mPanGestureDetector;
}
/** Entry point for Linux & Tizen applications */
-int main( int argc, char **argv )
+int DALI_EXPORT_API main( int argc, char **argv )
{
- Application application = Application::New( &argc, &argv );
+ Application application = Application::New( &argc, &argv, DEMO_THEME_PATH );
RunTest( application );