/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <dali/public-api/events/touch-data.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/object/type-registry-helper.h>
-#include <dali/public-api/images/resource-image.h>
// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/asset-manager/asset-manager.h>
+#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
#include <dali-toolkit/public-api/controls/control-impl.h>
#include <dali-toolkit/public-api/controls/image-view/image-view.h>
const float DEFAULT_HANDLE_HEIGHT = DEFAULT_HIT_HEIGHT;
const float POPUP_TEXT_PADDING = 10.0f;
-const char* SKINNED_TRACK_VISUAL = DALI_IMAGE_DIR "slider-skin.9.png";
-const char* SKINNED_HANDLE_VISUAL = DALI_IMAGE_DIR "slider-skin-handle.png";
-const char* SKINNED_PROGRESS_VISUAL = DALI_IMAGE_DIR "slider-skin-progress.9.png";
-const char* SKINNED_POPUP_VISUAL = DALI_IMAGE_DIR "slider-popup.9.png";
-const char* SKINNED_POPUP_ARROW_VISUAL = DALI_IMAGE_DIR "slider-popup-arrow.png";
+const char* SKINNED_TRACK_VISUAL_FILE_NAME = "slider-skin.9.png";
+const char* SKINNED_HANDLE_VISUAL_FILE_NAME = "slider-skin-handle.png";
+const char* SKINNED_PROGRESS_VISUAL_FILE_NAME = "slider-skin-progress.9.png";
+const char* SKINNED_POPUP_VISUAL_FILE_NAME = "slider-popup.9.png";
+const char* SKINNED_POPUP_ARROW_VISUAL_FILE_NAME = "slider-popup-arrow.png";
const Vector2 DEFAULT_HIT_REGION( DEFAULT_WIDTH, DEFAULT_HIT_HEIGHT );
const Vector2 DEFAULT_TRACK_REGION( DEFAULT_WIDTH, DEFAULT_HEIGHT );
}
Slider::Slider()
-: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ),
+: Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
mState( NORMAL ),
mPopupVisual(""),
mPopupArrowVisual(""),
SetTrackRegion( DEFAULT_TRACK_REGION );
SetHandleSize( DEFAULT_HANDLE_SIZE );
- SetTrackVisual( SKINNED_TRACK_VISUAL );
- SetHandleVisual( SKINNED_HANDLE_VISUAL );
- SetProgressVisual( SKINNED_PROGRESS_VISUAL );
- SetPopupVisual( SKINNED_POPUP_VISUAL );
- SetPopupArrowVisual( SKINNED_POPUP_ARROW_VISUAL );
+ const std::string imageDirPath = AssetManager::GetDaliImagePath();
+ SetTrackVisual( imageDirPath + SKINNED_TRACK_VISUAL_FILE_NAME );
+ SetHandleVisual( imageDirPath + SKINNED_HANDLE_VISUAL_FILE_NAME );
+ SetProgressVisual( imageDirPath + SKINNED_PROGRESS_VISUAL_FILE_NAME );
+ SetPopupVisual( imageDirPath + SKINNED_POPUP_VISUAL_FILE_NAME );
+ SetPopupArrowVisual( imageDirPath + SKINNED_POPUP_ARROW_VISUAL_FILE_NAME );
SetShowPopup( DEFAULT_SHOW_POPUP );
SetShowValue( DEFAULT_SHOW_VALUE );
self.TouchSignal().Connect( this, &Slider::OnTouch );
}
-void Slider::OnSizeSet( const Vector3& size )
-{
-}
-
void Slider::OnRelayout( const Vector2& size, RelayoutContainer& container )
{
SetHitRegion( Vector2( size.x, GetHitRegion().y ) );
Actor Slider::CreateHitRegion()
{
Actor hitRegion = Actor::New();
- hitRegion.SetParentOrigin( ParentOrigin::CENTER );
- hitRegion.SetAnchorPoint( AnchorPoint::CENTER );
+ hitRegion.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+ hitRegion.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
hitRegion.TouchSignal().Connect( this, &Slider::OnTouch );
return hitRegion;
Toolkit::ImageView Slider::CreateTrack()
{
Toolkit::ImageView track = Toolkit::ImageView::New();
- track.SetName("SliderTrack");
- track.SetParentOrigin( ParentOrigin::CENTER );
- track.SetAnchorPoint( AnchorPoint::CENTER );
+ track.SetProperty( Dali::Actor::Property::NAME,"SliderTrack");
+ track.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+ track.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
return track;
}
Toolkit::ImageView Slider::CreateProgress()
{
Toolkit::ImageView progress = Toolkit::ImageView::New();
- progress.SetName("SliderProgress");
- progress.SetParentOrigin( ParentOrigin::CENTER_LEFT );
- progress.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
+ progress.SetProperty( Dali::Actor::Property::NAME,"SliderProgress");
+ progress.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
+ progress.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
return progress;
}
{
if( mPopup && ( filename.size() > 0 ) )
{
- Image image = ResourceImage::New( filename );
- mPopup.SetImage( image );
+ Property::Map map;
+ map[Toolkit::ImageVisual::Property::URL] = filename;
+ mPopup.SetProperty( Toolkit::ImageView::Property::IMAGE, map );
}
}
{
if( mPopupArrow && ( filename.size() > 0 ) )
{
- Image image = ResourceImage::New( filename );
- mPopupArrow.SetImage( image );
+ Property::Map map;
+ map[Toolkit::ImageVisual::Property::URL] = filename;
+ mPopupArrow.SetProperty( Toolkit::ImageView::Property::IMAGE, map );
}
}
Toolkit::ImageView Slider::CreateHandle()
{
Toolkit::ImageView handle = Toolkit::ImageView::New();
- handle.SetName("SliderHandle");
- handle.SetParentOrigin( ParentOrigin::CENTER_LEFT );
- handle.SetAnchorPoint( AnchorPoint::CENTER );
+ handle.SetProperty( Dali::Actor::Property::NAME,"SliderHandle");
+ handle.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT );
+ handle.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
return handle;
}
{
Toolkit::ImageView arrow = Toolkit::ImageView::New();
arrow.SetStyleName("SliderPopupArrow");
- arrow.SetName("SliderPopupArrow");
- arrow.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
- arrow.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
+ arrow.SetProperty( Dali::Actor::Property::NAME,"SliderPopupArrow");
+ arrow.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_CENTER );
+ arrow.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_CENTER );
return arrow;
}
Toolkit::TextLabel Slider::CreatePopupText()
{
Toolkit::TextLabel textLabel = Toolkit::TextLabel::New();
- textLabel.SetName( "SliderPopupTextLabel" );
+ textLabel.SetProperty( Dali::Actor::Property::NAME, "SliderPopupTextLabel" );
textLabel.SetStyleName( "SliderPopupTextLabel" );
- textLabel.SetParentOrigin( ParentOrigin::CENTER );
- textLabel.SetAnchorPoint( AnchorPoint::CENTER );
+ textLabel.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+ textLabel.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
textLabel.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
textLabel.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
textLabel.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
Toolkit::ImageView Slider::CreatePopup()
{
Toolkit::ImageView popup = Toolkit::ImageView::New();
- popup.SetName( "SliderPopup" );
- popup.SetParentOrigin( ParentOrigin::TOP_CENTER );
- popup.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
+ popup.SetProperty( Dali::Actor::Property::NAME, "SliderPopup" );
+ popup.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER );
+ popup.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_CENTER );
popup.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::WIDTH );
mValueTextLabel = CreatePopupText();
if( mHandle && !mHandleValueTextLabel )
{
mHandleValueTextLabel = Toolkit::TextLabel::New();
- mHandleValueTextLabel.SetName("SliderHandleTextLabel");
+ mHandleValueTextLabel.SetProperty( Dali::Actor::Property::NAME,"SliderHandleTextLabel");
mHandleValueTextLabel.SetStyleName("SliderHandleTextLabel");
- mHandleValueTextLabel.SetParentOrigin( ParentOrigin::CENTER );
- mHandleValueTextLabel.SetAnchorPoint( AnchorPoint::CENTER );
+ mHandleValueTextLabel.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+ mHandleValueTextLabel.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
mHandleValueTextLabel.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
mHandleValueTextLabel.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
mHandle.Add( mHandleValueTextLabel );
Actor Slider::CreateValueDisplay()
{
Actor popup = Actor::New();
- popup.SetParentOrigin( ParentOrigin::TOP_CENTER );
- popup.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
+ popup.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER );
+ popup.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_CENTER );
mPopupArrow = CreatePopupArrow();
popup.Add( mPopupArrow );
{
case NORMAL:
{
- mTrack.SetColor( Color::WHITE );
- mHandle.SetColor( Color::WHITE );
- mProgress.SetColor( Color::WHITE );
+ mTrack.SetProperty( Actor::Property::COLOR, Color::WHITE );
+ mHandle.SetProperty( Actor::Property::COLOR, Color::WHITE );
+ mProgress.SetProperty( Actor::Property::COLOR, Color::WHITE );
break;
}
case DISABLED:
{
Vector4 disabledColor = GetDisabledColor();
- mTrack.SetColor( disabledColor );
- mHandle.SetColor( disabledColor );
- mProgress.SetColor( disabledColor );
+ mTrack.SetProperty( Actor::Property::COLOR, disabledColor );
+ mHandle.SetProperty( Actor::Property::COLOR, disabledColor );
+ mProgress.SetProperty( Actor::Property::COLOR, disabledColor );
break;
}
case PRESSED:
if( !mValueDisplay )
{
mValueDisplay = CreateValueDisplay();
- mValueDisplay.SetVisible( false );
+ mValueDisplay.SetProperty( Actor::Property::VISIBLE, false );
mHandle.Add( mValueDisplay );
CreatePopupImage( GetPopupVisual() );
{
if( mValueDisplay )
{
- mValueDisplay.SetVisible( false );
+ mValueDisplay.SetProperty( Actor::Property::VISIBLE, false );
}
return false;
if( mValueDisplay )
{
- mValueDisplay.SetVisible( true );
+ mValueDisplay.SetProperty( Actor::Property::VISIBLE, true );
mValueTimer.SetInterval( VALUE_VIEW_SHOW_DURATION );
}
case Toolkit::Slider::Property::MARKS:
{
- // TODO: Need to be able to return a PropertyArray
- // value = sliderImpl.GetMarks();
+ Property::Value value1( Property::ARRAY );
+ Property::Array* markArray = value1.GetArray();
+
+ if( markArray )
+ {
+ *markArray = sliderImpl.GetMarks();
+ }
+
+ value = value1;
break;
}