/*
- * 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/dali.h>
#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
using namespace Dali;
using namespace Dali::Toolkit;
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;
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.SetUnselectedImage( EDIT_IMAGE );
- editButton.SetSelectedImage( EDIT_IMAGE_SELECTED );
+ editButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, EDIT_IMAGE );
+ editButton.SetProperty( Toolkit::DevelButton::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.SetUnselectedImage( SPIRAL_LAYOUT_IMAGE );
- mLayoutButton.SetSelectedImage(SPIRAL_LAYOUT_IMAGE_SELECTED );
+ mLayoutButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, SPIRAL_LAYOUT_IMAGE );
+ mLayoutButton.SetProperty( Toolkit::DevelButton::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.SetUnselectedImage( DELETE_IMAGE );
- mDeleteButton.SetSelectedImage( DELETE_IMAGE_SELECTED );
- mDeleteButton.SetBackgroundImage( TOOLBAR_IMAGE );
+ mDeleteButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, DELETE_IMAGE );
+ mDeleteButton.SetProperty( Toolkit::DevelButton::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.SetUnselectedImage( INSERT_IMAGE );
- mInsertButton.SetSelectedImage( INSERT_IMAGE_SELECTED );
- mInsertButton.SetBackgroundImage( TOOLBAR_IMAGE );
+ mInsertButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, INSERT_IMAGE );
+ mInsertButton.SetProperty( Toolkit::DevelButton::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.SetUnselectedImage( REPLACE_IMAGE );
- mReplaceButton.SetSelectedImage( REPLACE_IMAGE_SELECTED );
- mReplaceButton.SetBackgroundImage( TOOLBAR_IMAGE );
+ mReplaceButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, REPLACE_IMAGE );
+ mReplaceButton.SetProperty( Toolkit::DevelButton::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 );
// Set the title and icon to the current layout
SetLayoutTitle();
SetLayoutImage();
+
+ mLongPressDetector = LongPressGestureDetector::New();
+ mLongPressDetector.Attach( mItemView );
+ mLongPressDetector.DetectedSignal().Connect( this, &ItemViewExample::OnLongPress );
}
Actor OnKeyboardPreFocusChange( Actor current, Actor proposed, Control::KeyboardFocus::Direction direction )
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.SetUnselectedImage( SPIRAL_LAYOUT_IMAGE );
- mLayoutButton.SetSelectedImage( SPIRAL_LAYOUT_IMAGE_SELECTED );
+ mLayoutButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, SPIRAL_LAYOUT_IMAGE );
+ mLayoutButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, SPIRAL_LAYOUT_IMAGE_SELECTED );
break;
}
case GRID_LAYOUT:
{
- mLayoutButton.SetUnselectedImage( GRID_LAYOUT_IMAGE );
- mLayoutButton.SetSelectedImage( GRID_LAYOUT_IMAGE_SELECTED );
+ mLayoutButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, GRID_LAYOUT_IMAGE );
+ mLayoutButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, GRID_LAYOUT_IMAGE_SELECTED );
break;
}
case DEPTH_LAYOUT:
{
- mLayoutButton.SetUnselectedImage( DEPTH_LAYOUT_IMAGE );
- mLayoutButton.SetSelectedImage( DEPTH_LAYOUT_IMAGE_SELECTED );
+ mLayoutButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, DEPTH_LAYOUT_IMAGE );
+ mLayoutButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, DEPTH_LAYOUT_IMAGE_SELECTED );
break;
}
borderActor.SetColorMode( USE_PARENT_COLOR );
Property::Map borderProperty;
- borderProperty.Insert( "rendererType", "border" );
- borderProperty.Insert( "borderColor", Color::WHITE );
- borderProperty.Insert( "borderSize", ITEM_BORDER_SIZE );
- borderProperty.Insert( "antiAliasing", true );
+ 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);
checkbox.SetZ( 0.1f );
Property::Map solidColorProperty;
- solidColorProperty.Insert( "rendererType", "color" );
- solidColorProperty.Insert( "blendColor", Vector4(0.f, 0.f, 0.f, 0.6f) );
+ 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 &&
Toolkit::PushButton mDeleteButton;
Toolkit::PushButton mInsertButton;
Toolkit::PushButton mReplaceButton;
+
+ 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, DEMO_THEME_PATH);
-
- RunTest(app);
-
return 0;
}