/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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 <sstream>
-#include <iostream>
-#include <vector>
-#include <string>
-#include <algorithm>
-#include <cstdlib> // rand
#include "shared/view.h"
#include <dali/dali.h>
#include <dali-toolkit/dali-toolkit.h>
-#include <dali/devel-api/images/atlas.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
using namespace Dali;
using namespace Dali::Toolkit;
};
const char* IMAGE_PATHS[] = {
- DALI_IMAGE_DIR "gallery-medium-1.jpg",
- DALI_IMAGE_DIR "gallery-medium-2.jpg",
- DALI_IMAGE_DIR "gallery-medium-3.jpg",
- DALI_IMAGE_DIR "gallery-medium-4.jpg",
- DALI_IMAGE_DIR "gallery-medium-5.jpg",
- DALI_IMAGE_DIR "gallery-medium-6.jpg",
- DALI_IMAGE_DIR "gallery-medium-7.jpg",
- DALI_IMAGE_DIR "gallery-medium-8.jpg",
- DALI_IMAGE_DIR "gallery-medium-9.jpg",
- DALI_IMAGE_DIR "gallery-medium-10.jpg",
- DALI_IMAGE_DIR "gallery-medium-11.jpg",
- DALI_IMAGE_DIR "gallery-medium-12.jpg",
- DALI_IMAGE_DIR "gallery-medium-13.jpg",
- DALI_IMAGE_DIR "gallery-medium-14.jpg",
- DALI_IMAGE_DIR "gallery-medium-15.jpg",
- DALI_IMAGE_DIR "gallery-medium-16.jpg",
- DALI_IMAGE_DIR "gallery-medium-17.jpg",
- DALI_IMAGE_DIR "gallery-medium-18.jpg",
- DALI_IMAGE_DIR "gallery-medium-19.jpg",
- DALI_IMAGE_DIR "gallery-medium-20.jpg",
- DALI_IMAGE_DIR "gallery-medium-21.jpg",
- DALI_IMAGE_DIR "gallery-medium-22.jpg",
- DALI_IMAGE_DIR "gallery-medium-23.jpg",
- DALI_IMAGE_DIR "gallery-medium-24.jpg",
- DALI_IMAGE_DIR "gallery-medium-25.jpg",
- DALI_IMAGE_DIR "gallery-medium-26.jpg",
- DALI_IMAGE_DIR "gallery-medium-27.jpg",
- DALI_IMAGE_DIR "gallery-medium-28.jpg",
- DALI_IMAGE_DIR "gallery-medium-29.jpg",
- DALI_IMAGE_DIR "gallery-medium-30.jpg",
- DALI_IMAGE_DIR "gallery-medium-31.jpg",
- DALI_IMAGE_DIR "gallery-medium-32.jpg",
- DALI_IMAGE_DIR "gallery-medium-33.jpg",
- DALI_IMAGE_DIR "gallery-medium-34.jpg",
- DALI_IMAGE_DIR "gallery-medium-35.jpg",
- DALI_IMAGE_DIR "gallery-medium-36.jpg",
- DALI_IMAGE_DIR "gallery-medium-37.jpg",
- DALI_IMAGE_DIR "gallery-medium-38.jpg",
- DALI_IMAGE_DIR "gallery-medium-39.jpg",
- DALI_IMAGE_DIR "gallery-medium-40.jpg",
- DALI_IMAGE_DIR "gallery-medium-41.jpg",
- DALI_IMAGE_DIR "gallery-medium-42.jpg",
- DALI_IMAGE_DIR "gallery-medium-43.jpg",
- DALI_IMAGE_DIR "gallery-medium-44.jpg",
- DALI_IMAGE_DIR "gallery-medium-45.jpg",
- DALI_IMAGE_DIR "gallery-medium-46.jpg",
- DALI_IMAGE_DIR "gallery-medium-47.jpg",
- DALI_IMAGE_DIR "gallery-medium-48.jpg",
- DALI_IMAGE_DIR "gallery-medium-49.jpg",
- DALI_IMAGE_DIR "gallery-medium-50.jpg",
- DALI_IMAGE_DIR "gallery-medium-51.jpg",
- DALI_IMAGE_DIR "gallery-medium-52.jpg",
- DALI_IMAGE_DIR "gallery-medium-53.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-1.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-2.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-3.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-4.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-5.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-6.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-7.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-8.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-9.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-10.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-11.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-12.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-13.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-14.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-15.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-16.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-17.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-18.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-19.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-20.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-21.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-22.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-23.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-24.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-25.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-26.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-27.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-28.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-29.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-30.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-31.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-32.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-33.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-34.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-35.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-36.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-37.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-38.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-39.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-40.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-41.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-42.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-43.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-44.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-45.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-46.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-47.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-48.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-49.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-50.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-51.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-52.jpg",
+ DEMO_IMAGE_DIR "gallery-medium-53.jpg",
};
const unsigned int NUM_IMAGES = sizeof(IMAGE_PATHS) / sizeof(char*);
-const unsigned int IMAGE_WIDTH = 256;
-const unsigned int IMAGE_HEIGHT = 256;
-const unsigned int NUM_IMAGE_PER_ROW_IN_ATLAS = 8;
-
const char* BACKGROUND_IMAGE( "" );
-const char* TOOLBAR_IMAGE( DALI_IMAGE_DIR "top-bar.png" );
-const char* EDIT_IMAGE( DALI_IMAGE_DIR "icon-edit.png" );
-const char* EDIT_IMAGE_SELECTED( DALI_IMAGE_DIR "icon-edit-selected.png" );
-const char* SPIRAL_LAYOUT_IMAGE( DALI_IMAGE_DIR "icon-item-view-layout-spiral.png" );
-const char* SPIRAL_LAYOUT_IMAGE_SELECTED( DALI_IMAGE_DIR "icon-item-view-layout-spiral-selected.png" );
-const char* GRID_LAYOUT_IMAGE( DALI_IMAGE_DIR "icon-item-view-layout-grid.png" );
-const char* GRID_LAYOUT_IMAGE_SELECTED( DALI_IMAGE_DIR "icon-item-view-layout-grid-selected.png" );
-const char* DEPTH_LAYOUT_IMAGE( DALI_IMAGE_DIR "icon-item-view-layout-depth.png" );
-const char* DEPTH_LAYOUT_IMAGE_SELECTED( DALI_IMAGE_DIR "icon-item-view-layout-depth-selected.png" );
-const char* DELETE_IMAGE( DALI_IMAGE_DIR "icon-delete.png" );
-const char* DELETE_IMAGE_SELECTED( DALI_IMAGE_DIR "icon-delete-selected.png" );
-const char* REPLACE_IMAGE( DALI_IMAGE_DIR "icon-replace.png" );
-const char* REPLACE_IMAGE_SELECTED( DALI_IMAGE_DIR "icon-replace-selected.png" );
-const char* INSERT_IMAGE( DALI_IMAGE_DIR "icon-insert.png" );
-const char* INSERT_IMAGE_SELECTED( DALI_IMAGE_DIR "icon-insert-selected.png" );
-const char* SELECTED_IMAGE( DALI_IMAGE_DIR "item-select-check.png" );
+const char* TOOLBAR_IMAGE( DEMO_IMAGE_DIR "top-bar.png" );
+const char* EDIT_IMAGE( DEMO_IMAGE_DIR "icon-edit.png" );
+const char* EDIT_IMAGE_SELECTED( DEMO_IMAGE_DIR "icon-edit-selected.png" );
+const char* SPIRAL_LAYOUT_IMAGE( DEMO_IMAGE_DIR "icon-item-view-layout-spiral.png" );
+const char* SPIRAL_LAYOUT_IMAGE_SELECTED( DEMO_IMAGE_DIR "icon-item-view-layout-spiral-selected.png" );
+const char* GRID_LAYOUT_IMAGE( DEMO_IMAGE_DIR "icon-item-view-layout-grid.png" );
+const char* GRID_LAYOUT_IMAGE_SELECTED( DEMO_IMAGE_DIR "icon-item-view-layout-grid-selected.png" );
+const char* DEPTH_LAYOUT_IMAGE( DEMO_IMAGE_DIR "icon-item-view-layout-depth.png" );
+const char* DEPTH_LAYOUT_IMAGE_SELECTED( DEMO_IMAGE_DIR "icon-item-view-layout-depth-selected.png" );
+const char* DELETE_IMAGE( DEMO_IMAGE_DIR "icon-delete.png" );
+const char* DELETE_IMAGE_SELECTED( DEMO_IMAGE_DIR "icon-delete-selected.png" );
+const char* REPLACE_IMAGE( DEMO_IMAGE_DIR "icon-replace.png" );
+const char* REPLACE_IMAGE_SELECTED( DEMO_IMAGE_DIR "icon-replace-selected.png" );
+const char* INSERT_IMAGE( DEMO_IMAGE_DIR "icon-insert.png" );
+const char* INSERT_IMAGE_SELECTED( DEMO_IMAGE_DIR "icon-insert-selected.png" );
+const char* SELECTED_IMAGE( DEMO_IMAGE_DIR "item-select-check.png" );
const char* APPLICATION_TITLE( "ItemView" );
const char* SPIRAL_LABEL("Spiral");
const char* GRID_LABEL("Grid");
const char* DEPTH_LABEL("Depth");
-const char* ITEM_BORDER_IMAGE_PATH( DALI_IMAGE_DIR "frame-128x128.png" );
-const Vector3 ITEM_BORDER_MARGIN_SIZE(24, 24, 0);
-
-// These values depend on the border image
-const float ITEM_IMAGE_BORDER_LEFT = 13.0f;
-const float ITEM_IMAGE_BORDER_RIGHT = 13.0f;
-const float ITEM_IMAGE_BORDER_TOP = 13.0f;
-const float ITEM_IMAGE_BORDER_BOTTOM = 13.0f;
+const float ITEM_BORDER_SIZE = 2.0f;
const float DEPTH_LAYOUT_ITEM_SIZE_FACTOR_PORTRAIT = 1.0f;
const float DEPTH_LAYOUT_ITEM_SIZE_FACTOR_LANDSCAPE = 0.8f;
const Vector3 INITIAL_OFFSCREEN_POSITION( 1000.0f, 0, -1000.0f );
+const float SCROLL_TO_ITEM_ANIMATION_TIME = 5.f;
+
static Vector3 DepthLayoutItemSizeFunctionPortrait( float layoutWidth )
{
float width = ( layoutWidth / ( DEPTH_LAYOUT_COLUMNS + 1.0f ) ) * DEPTH_LAYOUT_ITEM_SIZE_FACTOR_PORTRAIT;
{
Stage stage = Dali::Stage::GetCurrent();
stage.KeyEventSignal().Connect(this, &ItemViewExample::OnKeyEvent);
+ stage.GetRootLayer().SetBehavior(Layer::LAYER_3D);
Vector2 stageSize = Stage::GetCurrent().GetSize();
- // Create a border image shared by all the item actors
- mBorderImage = ResourceImage::New(ITEM_BORDER_IMAGE_PATH);
-
// Creates a default view with a default tool bar.
// The view is added to the stage.
+
Layer contents = DemoHelper::CreateView( mApplication,
mView,
mToolBar,
TOOLBAR_IMAGE,
"" );
- //app.GetWindow().GetOrientation().ChangedSignal().Connect( this, &ItemViewExample::OnOrientationChanged );
-
// Create an edit mode button. (left of toolbar)
Toolkit::PushButton editButton = Toolkit::PushButton::New();
- editButton.SetButtonImage( ResourceImage::New( EDIT_IMAGE ) );
- editButton.SetSelectedImage( ResourceImage::New( EDIT_IMAGE_SELECTED ) );
+ editButton.SetProperty( Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, EDIT_IMAGE );
+ editButton.SetProperty( Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, EDIT_IMAGE_SELECTED );
editButton.ClickedSignal().Connect( this, &ItemViewExample::OnModeButtonClicked);
editButton.SetLeaveRequired( true );
mToolBar.AddControl( editButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalLeft, DemoHelper::DEFAULT_MODE_SWITCH_PADDING );
// Create a layout toggle button. (right of toolbar)
mLayoutButton = Toolkit::PushButton::New();
- mLayoutButton.SetButtonImage( ResourceImage::New( SPIRAL_LAYOUT_IMAGE ) );
- mLayoutButton.SetSelectedImage( ResourceImage::New( SPIRAL_LAYOUT_IMAGE_SELECTED ) );
+ mLayoutButton.SetProperty( Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, SPIRAL_LAYOUT_IMAGE );
+ mLayoutButton.SetProperty( Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, SPIRAL_LAYOUT_IMAGE_SELECTED );
mLayoutButton.ClickedSignal().Connect( this, &ItemViewExample::OnLayoutButtonClicked);
mLayoutButton.SetLeaveRequired( true );
mToolBar.AddControl( mLayoutButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_MODE_SWITCH_PADDING );
mDeleteButton.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT);
mDeleteButton.SetPosition( BUTTON_BORDER, BUTTON_BORDER );
mDeleteButton.SetDrawMode( DrawMode::OVERLAY_2D );
- mDeleteButton.SetButtonImage( ResourceImage::New( DELETE_IMAGE ) );
- mDeleteButton.SetSelectedImage( ResourceImage::New( DELETE_IMAGE_SELECTED ) );
- mDeleteButton.SetBackgroundImage( ResourceImage::New( TOOLBAR_IMAGE ) );
+ mDeleteButton.SetProperty( Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, DELETE_IMAGE );
+ mDeleteButton.SetProperty( Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, DELETE_IMAGE_SELECTED );
+ mDeleteButton.SetProperty( Toolkit::Control::Property::BACKGROUND, TOOLBAR_IMAGE );
mDeleteButton.SetSize( Vector2( stageSize.width * 0.15f, stageSize.width * 0.15f ) );
mDeleteButton.ClickedSignal().Connect( this, &ItemViewExample::OnDeleteButtonClicked);
mDeleteButton.SetLeaveRequired( true );
mInsertButton.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT);
mInsertButton.SetPosition( BUTTON_BORDER, BUTTON_BORDER );
mInsertButton.SetDrawMode( DrawMode::OVERLAY_2D );
- mInsertButton.SetButtonImage( ResourceImage::New( INSERT_IMAGE ) );
- mInsertButton.SetSelectedImage( ResourceImage::New( INSERT_IMAGE_SELECTED ) );
- mInsertButton.SetBackgroundImage( ResourceImage::New( TOOLBAR_IMAGE ) );
+ mInsertButton.SetProperty( Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, INSERT_IMAGE );
+ mInsertButton.SetProperty( Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, INSERT_IMAGE_SELECTED );
+ mInsertButton.SetProperty( Toolkit::Control::Property::BACKGROUND, TOOLBAR_IMAGE );
mInsertButton.SetSize( stageSize.width * 0.15f, stageSize.width * 0.15f );
mInsertButton.ClickedSignal().Connect( this, &ItemViewExample::OnInsertButtonClicked);
mInsertButton.SetLeaveRequired( true );
mReplaceButton.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT);
mReplaceButton.SetPosition( BUTTON_BORDER, BUTTON_BORDER );
mReplaceButton.SetDrawMode( DrawMode::OVERLAY_2D );
- mReplaceButton.SetButtonImage( ResourceImage::New( REPLACE_IMAGE ) );
- mReplaceButton.SetSelectedImage( ResourceImage::New( REPLACE_IMAGE_SELECTED ) );
- mReplaceButton.SetBackgroundImage( ResourceImage::New( TOOLBAR_IMAGE ) );
+ mReplaceButton.SetProperty( Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, REPLACE_IMAGE );
+ mReplaceButton.SetProperty( Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, REPLACE_IMAGE_SELECTED );
+ mReplaceButton.SetProperty( Toolkit::Control::Property::BACKGROUND, TOOLBAR_IMAGE );
mReplaceButton.SetSize( stageSize.width * 0.15f, stageSize.width * 0.15f );
mReplaceButton.ClickedSignal().Connect( this, &ItemViewExample::OnReplaceButtonClicked);
mReplaceButton.SetLeaveRequired( true );
stage.Add( mReplaceButton );
// Create the item view actor
- mImageAtlas = CreateImageAtlas();
mItemView = ItemView::New(*this);
mItemView.SetParentOrigin(ParentOrigin::CENTER);
mItemView.SetAnchorPoint(AnchorPoint::CENTER);
SetLayoutTitle();
SetLayoutImage();
- // Store one 1x1 white image for multiple items to share for backgrounds:
- mWhiteImage = BufferImage::WHITE();
+ mLongPressDetector = LongPressGestureDetector::New();
+ mLongPressDetector.Attach( mItemView );
+ mLongPressDetector.DetectedSignal().Connect( this, &ItemViewExample::OnLongPress );
}
Actor OnKeyboardPreFocusChange( Actor current, Actor proposed, Control::KeyboardFocus::Direction direction )
*/
void SetLayout( int layoutId )
{
+ Stage stage = Dali::Stage::GetCurrent();
+ switch( mCurrentLayout )
+ {
+ case SPIRAL_LAYOUT:
+ case DEPTH_LAYOUT:
+ {
+ stage.GetRootLayer().SetBehavior(Layer::LAYER_3D);
+ break;
+ }
+ case GRID_LAYOUT:
+ {
+ stage.GetRootLayer().SetBehavior(Layer::LAYER_UI);
+ break;
+ }
+ }
+
// Set the new orientation to the layout
mItemView.GetLayout(layoutId)->SetOrientation(static_cast<ControlOrientation::Type>(mOrientation / 90));
mItemView.ActivateLayout( layoutId, Vector3(stageSize.x, stageSize.y, stageSize.x), 0.0f );
}
- /**
- * Orientation changed signal callback
- * @param orientation
- */
- void OnOrientationChanged( Orientation orientation )
- {
- const unsigned int angle = orientation.GetDegrees();
-
- // If orientation really changed
- if( mOrientation != angle )
- {
- // Remember orientation
- mOrientation = angle;
-
- SetLayout( mCurrentLayout );
- }
- }
-
bool OnLayoutButtonClicked( Toolkit::Button button )
{
// Switch to the next layout
}
}
+ void OnLongPress( Actor actor, const LongPressGesture& gesture )
+ {
+ switch( gesture.state )
+ {
+ case Gesture::Started:
+ {
+ const Size& size = Stage::GetCurrent().GetSize();
+
+ ItemRange range( 0u, 0u );
+ mItemView.GetItemsRange( range );
+
+ const unsigned int item = ( gesture.screenPoint.y < 0.5f * size.height ) ? range.begin : range.end;
+ mItemView.ScrollToItem( item, SCROLL_TO_ITEM_ANIMATION_TIME );
+
+ break;
+ }
+ case Gesture::Finished:
+ {
+ Property::Map attributes;
+ mItemView.DoAction( "stopScrolling", attributes );
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ }
+
bool OnDeleteButtonClicked( Toolkit::Button button )
{
ItemIdContainer removeList;
{
case SPIRAL_LAYOUT:
{
- mLayoutButton.SetButtonImage( ResourceImage::New( SPIRAL_LAYOUT_IMAGE ) );
- mLayoutButton.SetSelectedImage( ResourceImage::New( SPIRAL_LAYOUT_IMAGE_SELECTED ) );
+ mLayoutButton.SetProperty( Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, SPIRAL_LAYOUT_IMAGE );
+ mLayoutButton.SetProperty( Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, SPIRAL_LAYOUT_IMAGE_SELECTED );
break;
}
case GRID_LAYOUT:
{
- mLayoutButton.SetButtonImage( ResourceImage::New( GRID_LAYOUT_IMAGE ) );
- mLayoutButton.SetSelectedImage( ResourceImage::New( GRID_LAYOUT_IMAGE_SELECTED ) );
+ mLayoutButton.SetProperty( Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, GRID_LAYOUT_IMAGE );
+ mLayoutButton.SetProperty( Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, GRID_LAYOUT_IMAGE_SELECTED );
break;
}
case DEPTH_LAYOUT:
{
- mLayoutButton.SetButtonImage( ResourceImage::New( DEPTH_LAYOUT_IMAGE ) );
- mLayoutButton.SetSelectedImage( ResourceImage::New( DEPTH_LAYOUT_IMAGE_SELECTED ) );
+ mLayoutButton.SetProperty( Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, DEPTH_LAYOUT_IMAGE );
+ mLayoutButton.SetProperty( Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, DEPTH_LAYOUT_IMAGE_SELECTED );
break;
}
*/
virtual Actor NewItem(unsigned int itemId)
{
- // Create an image actor for this item
- unsigned int imageId = itemId % NUM_IMAGES;
- ImageActor::PixelArea pixelArea( (imageId%NUM_IMAGE_PER_ROW_IN_ATLAS)*IMAGE_WIDTH,
- (imageId/NUM_IMAGE_PER_ROW_IN_ATLAS)*IMAGE_HEIGHT,
- IMAGE_WIDTH,
- IMAGE_HEIGHT );
- Actor actor = ImageActor::New(mImageAtlas, pixelArea);
+ // Create an image view for this item
+ Property::Map propertyMap;
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
+ propertyMap.Insert(ImageVisual::Property::URL, IMAGE_PATHS[ itemId % NUM_IMAGES ] );
+ propertyMap.Insert(DevelVisual::Property::VISUAL_FITTING_MODE, DevelVisual::FILL);
+ ImageView actor = ImageView::New();
+ actor.SetProperty( Toolkit::ImageView::Property::IMAGE, propertyMap );
+ actor.SetZ( 0.0f );
actor.SetPosition( INITIAL_OFFSCREEN_POSITION );
// Add a border image child actor
- ImageActor borderActor = ImageActor::New(mBorderImage);
+ ImageView borderActor = ImageView::New();
borderActor.SetParentOrigin( ParentOrigin::CENTER );
borderActor.SetAnchorPoint( AnchorPoint::CENTER );
- borderActor.SetPosition( 0.f, 0.f, 1.f );
- borderActor.SetStyle( ImageActor::STYLE_NINE_PATCH );
- borderActor.SetNinePatchBorder( Vector4( ITEM_IMAGE_BORDER_LEFT, ITEM_IMAGE_BORDER_TOP, ITEM_IMAGE_BORDER_RIGHT, ITEM_IMAGE_BORDER_BOTTOM ) );
- borderActor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR ); // darken with parent image-actor
borderActor.SetResizePolicy( ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT, Dimension::ALL_DIMENSIONS );
- borderActor.SetSizeModeFactor( ITEM_BORDER_MARGIN_SIZE );
+ borderActor.SetSizeModeFactor( Vector3( 2.0f * ITEM_BORDER_SIZE, 2.0f * ITEM_BORDER_SIZE, 0.0f ) );
+ borderActor.SetColorMode( USE_PARENT_COLOR );
+
+ Property::Map borderProperty;
+ borderProperty.Insert( Toolkit::Visual::Property::TYPE, Visual::BORDER );
+ borderProperty.Insert( BorderVisual::Property::COLOR, Color::WHITE );
+ borderProperty.Insert( BorderVisual::Property::SIZE, ITEM_BORDER_SIZE );
+ borderProperty.Insert( BorderVisual::Property::ANTI_ALIASING, true );
+ borderActor.SetProperty( ImageView::Property::IMAGE, borderProperty );
+
actor.Add(borderActor);
+
actor.SetKeyboardFocusable( true );
Vector3 spiralItemSize;
static_cast<ItemLayout&>(*mSpiralLayout).GetItemSize( 0u, Vector3( Stage::GetCurrent().GetSize() ), spiralItemSize );
// Add a checkbox child actor; invisible until edit-mode is enabled
-
- ImageActor checkbox = ImageActor::New( mWhiteImage );
+ ImageView checkbox = ImageView::New();
checkbox.SetName( "CheckBox" );
- checkbox.SetColor( Vector4(0.0f,0.0f,0.0f,0.6f) );
+ checkbox.SetColorMode( USE_PARENT_COLOR );
checkbox.SetParentOrigin( ParentOrigin::TOP_RIGHT );
checkbox.SetAnchorPoint( AnchorPoint::TOP_RIGHT );
checkbox.SetSize( spiralItemSize.width * 0.2f, spiralItemSize.width * 0.2f );
checkbox.SetPosition( -SELECTION_BORDER_WIDTH, SELECTION_BORDER_WIDTH );
- checkbox.SetZ( 1.0f );
+ checkbox.SetZ( 0.1f );
+
+ Property::Map solidColorProperty;
+ solidColorProperty.Insert( Toolkit::Visual::Property::TYPE, Visual::COLOR );
+ solidColorProperty.Insert( ColorVisual::Property::MIX_COLOR, Vector4(0.f, 0.f, 0.f, 0.6f) );
+ checkbox.SetProperty( ImageView::Property::IMAGE, solidColorProperty );
+
if( MODE_REMOVE_MANY != mMode &&
MODE_INSERT_MANY != mMode &&
MODE_REPLACE_MANY != mMode )
{
checkbox.SetVisible( false );
}
- actor.Add( checkbox );
+ borderActor.Add( checkbox );
- ImageActor tick = ImageActor::New( ResourceImage::New(SELECTED_IMAGE) );
- tick.SetColorMode( USE_OWN_COLOR );
+ ImageView tick = ImageView::New( SELECTED_IMAGE );
tick.SetName( "Tick" );
+ tick.SetColorMode( USE_PARENT_COLOR );
tick.SetParentOrigin( ParentOrigin::TOP_RIGHT );
tick.SetAnchorPoint( AnchorPoint::TOP_RIGHT );
tick.SetSize( spiralItemSize.width * 0.2f, spiralItemSize.width * 0.2f );
- tick.SetZ( 1.0f );
+ tick.SetZ( 0.2f );
tick.SetVisible( false );
checkbox.Add( tick );
private:
/**
- * Create an Atlas to tile the images inside.
- */
- Atlas CreateImageAtlas()
- {
- const unsigned int atlas_width = IMAGE_WIDTH*NUM_IMAGE_PER_ROW_IN_ATLAS;
- const unsigned int atlas_height = IMAGE_HEIGHT*ceil( static_cast<float>(NUM_IMAGES)/ static_cast<float>(NUM_IMAGE_PER_ROW_IN_ATLAS));
- Atlas atlas = Atlas::New(atlas_width, atlas_height, Pixel::RGB888);
-
- for( unsigned int i = 0; i < NUM_IMAGES; i++ )
- {
- atlas.Upload( IMAGE_PATHS[i], (i%NUM_IMAGE_PER_ROW_IN_ATLAS)*IMAGE_WIDTH, (i/NUM_IMAGE_PER_ROW_IN_ATLAS)*IMAGE_HEIGHT );
- }
-
- return atlas;
- }
-
- /**
* Sets/Updates the title of the View
* @param[in] title The new title for the view.
*/
TextLabel mTitleActor; ///< The Toolbar's Title.
ItemView mItemView;
- Image mBorderImage;
- Atlas mImageAtlas;
unsigned int mCurrentLayout;
float mDurationSeconds;
Toolkit::PushButton mInsertButton;
Toolkit::PushButton mReplaceButton;
- BufferImage mWhiteImage;
+ LongPressGestureDetector mLongPressDetector;
};
-void RunTest(Application& app)
+int DALI_EXPORT_API main(int argc, char **argv)
{
+ Application app = Application::New(&argc, &argv, DEMO_THEME_PATH);
ItemViewExample test(app);
-
app.MainLoop();
-}
-
-int main(int argc, char **argv)
-{
- Application app = Application::New(&argc, &argv, DALI_DEMO_THEME_PATH);
-
- RunTest(app);
-
return 0;
}