diff --git a/demo/dali-table-view.cpp b/demo/dali-table-view.cpp index cb56cd5..2e6ec48 100644 --- a/demo/dali-table-view.cpp +++ b/demo/dali-table-view.cpp @@ -22,6 +22,7 @@ #include #include #include +#include // INTERNAL INCLUDES #include "shared/view.h" @@ -65,6 +66,8 @@ const float EFFECT_SNAP_DURATION = 0.66f; ///< Scroll Snap const float EFFECT_FLICK_DURATION = 0.5f; ///< Scroll Flick Duration for Effects const Vector3 ANGLE_CUBE_PAGE_ROTATE(Math::PI * 0.5f, Math::PI * 0.5f, 0.0f); + + const int NUM_BACKGROUND_IMAGES = 18; const float BACKGROUND_SWIPE_SCALE = 0.025f; const float BACKGROUND_SPREAD_SCALE = 1.5f; @@ -80,21 +83,6 @@ const Vector4 BACKGROUND_COLOR( 1.0f, 1.0f, 1.0f, 1.0f ); const float BUBBLE_MIN_Z = -1.0; const float BUBBLE_MAX_Z = 0.0f; -// 3D Effect constants -const Vector2 ANGLE_SWING_3DEFFECT( Math::PI_2 * 0.75, Math::PI_2 * 0.75f ); ///< Angle Swing in radians -const Vector2 POSITION_SWING_3DEFFECT( 0.55f, 0.4f ); ///< Position Swing relative to stage size. -const Vector3 ANCHOR_3DEFFECT_STYLE0( -105.0f, 30.0f, -240.0f ); ///< Rotation Anchor position for 3D Effect (Style 0) -const Vector3 ANCHOR_3DEFFECT_STYLE1( 65.0f, -70.0f, -500.0f ); ///< Rotation Anchor position for 3D Effect (Style 1) - -const Dali::Vector4 TABLE_TEXT_STYLE_COLOR(0.0f, 0.0f, 0.0f, 1.0f); - -Vector3 ScalePointSize(const Vector3& vec) -{ - return Vector3( DemoHelper::ScalePointSize( vec.x ), DemoHelper::ScalePointSize( vec.y ), DemoHelper::ScalePointSize( vec.z ) ); -} - -#define DP(x) DemoHelper::ScalePointSize(x) - /** * Creates the background image */ @@ -142,7 +130,7 @@ public: // Bubbles X position moves parallax to horizontal // panning by a scale factor unique to each bubble. - position.x = mInitialX + ( inputs[0]->GetVector3().x * mScale ); + position.x = mInitialX + ( inputs[0]->GetVector2().x * mScale ); } private: @@ -320,7 +308,7 @@ void DaliTableView::Initialize( Application& application ) Populate(); // Remove constraints for inner cube effect - ApplyCubeEffectToActors(); + ApplyCubeEffectToPages(); Dali::Window winHandle = application.GetWindow(); winHandle.AddAvailableOrientation( Dali::Window::PORTRAIT ); @@ -348,21 +336,14 @@ void DaliTableView::Initialize( Application& application ) KeyboardFocusManager::Get().FocusedActorActivatedSignal().Connect( this, &DaliTableView::OnFocusedActorActivated ); } -void DaliTableView::ApplyCubeEffectToActors() +void DaliTableView::ApplyCubeEffectToPages() { - for( ActorIter pageIter = mPages.begin(); pageIter != mPages.end(); ++pageIter ) + ScrollViewPagePathEffect effect = ScrollViewPagePathEffect::DownCast( mScrollViewEffect ); + unsigned int pageCount(0); + for( std::vector< Actor >::iterator pageIter = mPages.begin(); pageIter != mPages.end(); ++pageIter ) { Actor page = *pageIter; - - for( unsigned int i = 0, numChildren = page.GetChildCount(); i < numChildren; ++i) - { - // Remove old effect's manual constraints. - Actor child = page.GetChildAt(i); - if( child ) - { - ApplyCubeEffectToActor( child ); - } - } + effect.ApplyToPage( page, pageCount++ ); } } @@ -448,9 +429,9 @@ void DaliTableView::Populate() } // Update Ruler info. - mScrollRulerX = new FixedRuler( stageSize.width * TABLE_RELATIVE_SIZE.x ); + mScrollRulerX = new FixedRuler( stageSize.width * TABLE_RELATIVE_SIZE.x * 0.5f ); mScrollRulerY = new DefaultRuler(); - mScrollRulerX->SetDomain( RulerDomain( 0.0f, mTotalPages * stageSize.width * TABLE_RELATIVE_SIZE.x, true ) ); + mScrollRulerX->SetDomain( RulerDomain( 0.0f, (mTotalPages+1) * stageSize.width * TABLE_RELATIVE_SIZE.x * 0.5f, true ) ); mScrollRulerY->Disable(); mScrollView.SetRulerX( mScrollRulerX ); mScrollView.SetRulerY( mScrollRulerY ); @@ -523,7 +504,6 @@ Actor DaliTableView::CreateTile( const std::string& name, const std::string& tit label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" ); label.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT ); - label.SetColor( TABLE_TEXT_STYLE_COLOR ); content.Add( label ); // Set the tile to be keyboard focusable @@ -640,14 +620,14 @@ void DaliTableView::OnPressedAnimationFinished( Dali::Animation& source ) } } -void DaliTableView::OnScrollStart( const Dali::Vector3& position ) +void DaliTableView::OnScrollStart( const Dali::Vector2& position ) { mScrolling = true; PlayAnimation(); } -void DaliTableView::OnScrollComplete( const Dali::Vector3& position ) +void DaliTableView::OnScrollComplete( const Dali::Vector2& position ) { mScrolling = false; @@ -684,21 +664,29 @@ void DaliTableView::ApplyScrollViewEffect() void DaliTableView::SetupInnerPageCubeEffect() { - mScrollViewEffect = ScrollViewCubeEffect::New(); - mScrollView.SetScrollSnapDuration( EFFECT_SNAP_DURATION ); - mScrollView.SetScrollFlickDuration( EFFECT_FLICK_DURATION ); - mScrollView.RemoveConstraintsFromChildren(); -} - -void DaliTableView::ApplyCubeEffectToActor( Actor actor ) -{ - actor.RemoveConstraints(); + const Vector2 stageSize = Stage::GetCurrent().GetSize(); - ScrollViewCubeEffect cubeEffect = ScrollViewCubeEffect::DownCast(mScrollViewEffect); - cubeEffect.ApplyToActor( actor, - ScalePointSize( ( rand() & 1 ) ? ANCHOR_3DEFFECT_STYLE0 : ANCHOR_3DEFFECT_STYLE1 ), - ANGLE_SWING_3DEFFECT, - POSITION_SWING_3DEFFECT * Vector2(Stage::GetCurrent().GetSize())); + Dali::Path path = Dali::Path::New(); + Dali::Property::Array points; + points.Resize(3); + points[0] = Vector3( stageSize.x*0.5, 0.0f, stageSize.x*0.5f); + points[1] = Vector3( 0.0f, 0.0f, 0.0f ); + points[2] = Vector3( -stageSize.x*0.5f, 0.0f, stageSize.x*0.5f); + path.SetProperty( Path::Property::POINTS, points ); + + Dali::Property::Array controlPoints; + controlPoints.Resize(4); + controlPoints[0] = Vector3( stageSize.x*0.5f, 0.0f, stageSize.x*0.3f ); + controlPoints[1] = Vector3( stageSize.x*0.3f, 0.0f, 0.0f ); + controlPoints[2] = Vector3(-stageSize.x*0.3f, 0.0f, 0.0f ); + controlPoints[3] = Vector3(-stageSize.x*0.5f, 0.0f, stageSize.x*0.3f ); + path.SetProperty( Path::Property::CONTROL_POINTS, controlPoints ); + + + mScrollViewEffect = ScrollViewPagePathEffect::New(path, + Vector3(-1.0f,0.0f,0.0f), + Toolkit::ScrollView::Property::SCROLL_FINAL_X, + Vector3(stageSize.x*TABLE_RELATIVE_SIZE.x,stageSize.y*TABLE_RELATIVE_SIZE.y,0.0f),mTotalPages); } void DaliTableView::OnKeyEvent( const KeyEvent& event ) diff --git a/demo/dali-table-view.h b/demo/dali-table-view.h index 05640ef..163b52d 100644 --- a/demo/dali-table-view.h +++ b/demo/dali-table-view.h @@ -217,14 +217,14 @@ private: // Application callbacks & implementation * * @param[in] position The current position of the scroll contents. */ - void OnScrollStart(const Dali::Vector3& position); + void OnScrollStart(const Dali::Vector2& position); /** * Signal emitted when scrolling has completed. * * @param[in] position The current position of the scroll contents. */ - void OnScrollComplete(const Dali::Vector3& position); + void OnScrollComplete(const Dali::Vector2& position); /** * Signal emitted when any Sensitive Actor has been touched @@ -245,7 +245,7 @@ private: // Application callbacks & implementation /** * Apply the cube effect to all the page actors */ - void ApplyCubeEffectToActors(); + void ApplyCubeEffectToPages(); /** * Setup the inner cube effect @@ -253,11 +253,6 @@ private: // Application callbacks & implementation void SetupInnerPageCubeEffect(); /** - * Apply the cube effect to an actor - */ - void ApplyCubeEffectToActor( Dali::Actor actor ); - - /** * Apply a shader effect to a table tile */ void ApplyEffectToTile(Dali::Actor tile); @@ -410,9 +405,9 @@ private: Dali::Toolkit::Popup mVersionPopup; ///< Displays DALi library version information Dali::Vector3 mButtonsPageRelativeSize; ///< Size of a buttons page relative to the stage size - Dali::ActorContainer mPages; ///< List of pages. - Dali::ActorContainer mTableViewImages; ///< Offscreen render of tableview - Dali::ActorContainer mBackgroundActors; ///< List of background actors used in the effect + std::vector< Dali::Actor > mPages; ///< List of pages. + std::vector< Dali::Actor > mTableViewImages; ///< Offscreen render of tableview + std::vector< Dali::Actor > mBackgroundActors; ///< List of background actors used in the effect AnimationList mBackgroundAnimations; ///< List of background bubble animations ExampleList mExampleList; ///< List of examples. ExampleMap mExampleMap; ///< Map LUT for examples. diff --git a/examples/atlas/atlas-example.cpp b/examples/atlas/atlas-example.cpp index 6d45fd8..c6cc76f 100644 --- a/examples/atlas/atlas-example.cpp +++ b/examples/atlas/atlas-example.cpp @@ -16,6 +16,8 @@ */ #include +#include + #include "shared/view.h" #include #include diff --git a/examples/builder/examples.cpp b/examples/builder/examples.cpp index 2dad74c..e958659 100644 --- a/examples/builder/examples.cpp +++ b/examples/builder/examples.cpp @@ -20,7 +20,7 @@ // //------------------------------------------------------------------------------ -#include "dali.h" +#include #include #include #include @@ -36,6 +36,7 @@ #include "sys/stat.h" #include +#include #include #include "shared/view.h" @@ -141,11 +142,6 @@ const std::string ShortName( const std::string& name ) } } -static Vector3 SetItemSize(unsigned int numberOfColumns, float layoutWidth, float sideMargin, float columnSpacing) -{ - return Vector3(layoutWidth, 50, 1); -} - //------------------------------------------------------------------------------ // // @@ -275,6 +271,7 @@ public: void EnterSelection() { Stage stage = Stage::GetCurrent(); + stage.SetBackgroundColor( Color::WHITE ); mTapDetector = TapGestureDetector::New(); mTapDetector.DetectedSignal().Connect( this, &ExampleApp::OnTap ); @@ -290,17 +287,12 @@ public: stage.Add( mItemView ); mItemView.SetParentOrigin(ParentOrigin::CENTER); mItemView.SetAnchorPoint(AnchorPoint::CENTER); - mGridLayout = GridLayout::New(); - mGridLayout->SetNumberOfColumns(1); + mLayout = DefaultItemLayout::New( DefaultItemLayout::LIST ); - mGridLayout->SetItemSizeFunction(SetItemSize); + mLayout->SetItemSize( Vector3( stage.GetSize().width, 50, 1 ) ); - mGridLayout->SetTopMargin(DemoHelper::DEFAULT_VIEW_STYLE.mToolBarHeight); + mItemView.AddLayout( *mLayout ); - mItemView.AddLayout(*mGridLayout); - - Vector3 size(stage.GetSize()); - mItemView.ActivateLayout(0, size, 0.0f/*immediate*/); mItemView.SetKeyboardFocusable( true ); mFiles.clear(); @@ -368,9 +360,9 @@ public: SetTitle("Select"); - // Itemview renderes the previous items unless its scrolled. Not sure why at the moment so we force a scroll - mItemView.ScrollToItem(0, 0); - + // Activate the layout + Vector3 size(stage.GetSize()); + mItemView.ActivateLayout(0, size, 0.0f/*immediate*/); } void ExitSelection() @@ -584,7 +576,7 @@ public: private: Application& mApp; - GridLayoutPtr mGridLayout; + ItemLayoutPtr mLayout; ItemView mItemView; Toolkit::Control mView; diff --git a/examples/cluster/cluster-example.cpp b/examples/cluster/cluster-example.cpp index 7dd8673..958c8bb 100644 --- a/examples/cluster/cluster-example.cpp +++ b/examples/cluster/cluster-example.cpp @@ -38,7 +38,7 @@ const char * const BACKGROUND_IMAGE( DALI_IMAGE_DIR "background-default.png" ); const char * const TOOLBAR_IMAGE( DALI_IMAGE_DIR "top-bar.png" ); const char * const APPLICATION_TITLE( "Clusters" ); const char * const LAYOUT_NONE_IMAGE( DALI_IMAGE_DIR "icon-cluster-none.png" ); -const char * const LAYOUT_WOBBLE_IMAGE( DALI_IMAGE_DIR "icon-cluster-wobble.png" ); +const char * const LAYOUT_MOTION_BLUR_IMAGE( DALI_IMAGE_DIR "icon-cluster-wobble.png" ); const char * const LAYOUT_CAROUSEL_IMAGE( DALI_IMAGE_DIR "icon-cluster-carousel.png" ); const char * const LAYOUT_SPHERE_IMAGE( DALI_IMAGE_DIR "icon-cluster-sphere.png" ); @@ -134,9 +134,6 @@ const float CLUSTER_GROUP_DELAY_BOTTOM = 0.0f; ///< Delay for botto const float CLUSTER_COLUMN_INDENT = 0.1f; ///< Left Indentation in screen coordinates. const float CLUSTER_ROW_INDENT = 0.13f; ///< Top Indentation in screen coordinates. -const Vector3 SHEAR_EFFECT_ANCHOR_POINT(0.5f, 1.0f, 0.5f); ///< Anchor Point used for the shear effect (extends outside of Cluster) -const float SHEAR_EFFECT_MAX_OVERSHOOT = 30.0f; ///< Max Overshoot for shear effect (in degrees). - const float UI_MARGIN = 10.0f; ///< Screen Margin for placement of UI buttons const float CAROUSEL_EFFECT_RADIUS = 500.0f; ///< In Carousel Effect mode: Radius of carousel (Z peak depth) @@ -152,7 +149,7 @@ const float SPHERE_EFFECT_VERTICAL_DOMAIN = 0.15f; ///< In Sphere Effec enum ExampleEffectType { NO_EFFECT, - WOBBLE_EFFECT, + MOTION_BLUR_EFFECT, CAROUSEL_EFFECT, SPHERE_EFFECT, TOTAL_EFFECTS @@ -161,10 +158,10 @@ enum ExampleEffectType /** * List of effect type names that appear on the Effect button. */ -const char* EXAMPLE_EFFECT_LABEL[] = { "NONE", - "WOBBLE", - "CAROUSEL", - "SPHERE", +const char* EXAMPLE_EFFECT_LABEL[] = { "None", + "Motion Blur", + "Carousel", + "Sphere", }; /** @@ -205,96 +202,6 @@ struct CarouselEffectOrientationConstraint }; /** - * ShearEffectConstraint - * - * Constrains ShearEffect's tilt to be a function of scrollview's - * horizontal overshoot amount. - */ -struct ShearEffectConstraint -{ - /** - * @param[in] stageSize The stage size (not subject to orientation) - * @param[in] maxOvershoot Maximum amount overshoot can affect shear. - * @param[in] componentMask Whether constraint should take the X shear - * or the Y shear component. - */ - ShearEffectConstraint(Vector2 stageSize, float maxOvershoot, Vector2 componentMask) - : mStageSize(stageSize), - mMaxOvershoot(maxOvershoot), - mComponentMask(componentMask) - { - } - - /** - * @param[in,out] current The current shear effect Angle. - * @param[in] inputs Contains the overshoot property from ScrollView and the orientation of the view e.g. Portrait, Landscape. - * @return angle to provide ShearShaderEffect - */ - void operator()( float& current, const PropertyInputContainer& inputs ) - { - float f = inputs[0]->GetVector3().x; - - float mag = fabsf(f); - float halfWidth = mStageSize.x * 0.5f; - - // inverse exponential tail-off - float overshoot = 1.0f - halfWidth / (halfWidth + mag); - if (f > 0.0f) - { - overshoot = -overshoot; - } - - // Channel this shear value into either the X or Y axis depending on - // the component mask passed in. - Vector3 axis; - Radian angle; - inputs[1]->GetQuaternion().ToAxisAngle( axis, angle ); - Vector2 direction( cosf(angle), sinf(angle) ); - float yield = direction.x * mComponentMask.x + direction.y * mComponentMask.y; - - current = overshoot * mMaxOvershoot * yield; - } - - Vector2 mStageSize; - float mMaxOvershoot; - Vector2 mComponentMask; -}; - -/** - * ShearEffectCenterConstraint - * - * Sets ShearEffect's center to be a function of the - * screen orientation (portrait or landscape). - */ -struct ShearEffectCenterConstraint -{ - /** - * @param[in] stageSize The stage size (not subject to orientation) - * @param[in] center Shear Center position based on initial orientation. - */ - ShearEffectCenterConstraint(Vector2 stageSize, Vector2 center) - : mStageSize(stageSize), - mCenter(center) - { - } - - /** - * @param[in,out] current The current center - * @param[in] inputs Contains the current view size - * @return vector to provide ShearShaderEffect - */ - void operator()( Vector2& current, const PropertyInputContainer& inputs ) - { - float f = inputs[0]->GetVector3().width / mStageSize.width; - current.x = f * mCenter.x; - current.y = mCenter.y; - } - - Vector2 mStageSize; - Vector2 mCenter; -}; - -/** * SphereEffectOffsetConstraint * * Sets SphereEffect's center to be a function of the @@ -470,7 +377,7 @@ public: // Create a effect toggle button. (right of toolbar) mLayoutButtonImages[ NO_EFFECT ] = ResourceImage::New( LAYOUT_NONE_IMAGE ); - mLayoutButtonImages[ WOBBLE_EFFECT ] = ResourceImage::New( LAYOUT_WOBBLE_IMAGE ); + mLayoutButtonImages[ MOTION_BLUR_EFFECT ] = ResourceImage::New( LAYOUT_MOTION_BLUR_IMAGE ); mLayoutButtonImages[ CAROUSEL_EFFECT ] = ResourceImage::New( LAYOUT_CAROUSEL_IMAGE ); mLayoutButtonImages[ SPHERE_EFFECT ] = ResourceImage::New( LAYOUT_SPHERE_IMAGE ); @@ -482,10 +389,6 @@ public: mScrollView = ScrollView::New(); mScrollView.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - // attach Wobble Effect to ScrollView - mScrollViewEffect = ScrollViewWobbleEffect::New(); - mScrollView.ApplyEffect(mScrollViewEffect); - // anchor the scroll view from its center point to the middle of its parent mScrollView.SetAnchorPoint(AnchorPoint::CENTER); mScrollView.SetParentOrigin(ParentOrigin::CENTER); @@ -506,7 +409,7 @@ public: AddCluster( MUSIC, ClusterStyleStandard::New(ClusterStyleStandard::ClusterStyle2) ); AddCluster( MAGAZINE, ClusterStyleStandard::New(ClusterStyleStandard::ClusterStyle3) ); - SetEffect(WOBBLE_EFFECT); + SetEffect(MOTION_BLUR_EFFECT); } /** @@ -627,7 +530,7 @@ public: pageView.SetPosition(Vector3(stageSize.width * column, 0.0f, 0.0f)); pageView.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - // Create cluster actors, add them to scroll view, and set the shear effect with the given center point. + // Create cluster actors and add them to scroll view Vector3 clusterSize; Cluster cluster = CreateClusterActor( clusterType, style, clusterSize ); cluster.SetParentOrigin(ParentOrigin::TOP_LEFT); @@ -642,6 +545,40 @@ public: } /** + * Sets motion blur effect to a cluster and all its children + * + * @param[in] actor Cluster control to which the effect will be applied + */ + void SetMotionBlurEffect( Actor actor ) + { + /* + // only do something if the actor and effect are valid + if( actor ) + { + // first remove from this actor + RenderableActor renderable = RenderableActor::DownCast( actor ); + if( renderable ) + { + MotionBlurEffect shaderEffect = MotionBlurEffect::New(); + shaderEffect.SetSpeedScalingFactor(0.1f); + + Dali::Property::Index uModelProperty = shaderEffect.GetPropertyIndex( "uModelLastFrame" ); + Constraint constraint = Constraint::New( shaderEffect, uModelProperty, EqualToConstraint() ); + constraint.AddSource( Source( actor , Actor::Property::WORLD_MATRIX ) ); + constraint.Apply(); + renderable.SetShaderEffect( shaderEffect ); + } + // then all children recursively + const unsigned int count = actor.GetChildCount(); + for( unsigned int index = 0; index < count; ++index ) + { + Actor child( actor.GetChildAt( index ) ); + SetMotionBlurEffect( child ); + } + }*/ + } + + /** * Resets ScrollView and Clusters settings * to reflect the new ExampleEffectType * @@ -691,8 +628,8 @@ public: // Apply new shader-effects. // Move Y to origin incase we came from an effect where user could free pan in y axis. - const Vector3 currentScrollPosition(mScrollView.GetCurrentScrollPosition()); - mScrollView.ScrollTo(Vector3(currentScrollPosition.x, 0.0f, 0.0f)); + const Vector2 currentScrollPosition(mScrollView.GetCurrentScrollPosition()); + mScrollView.ScrollTo(Vector2(currentScrollPosition.x, 0.0f)); switch(type) { @@ -701,42 +638,11 @@ public: break; } - case WOBBLE_EFFECT: + case MOTION_BLUR_EFFECT: { for( std::vector::iterator i = mClusterInfo.begin(); i != mClusterInfo.end(); ++i ) { - Cluster cluster = i->mCluster; - Vector3 position = i->mPosition; - Vector3 size = i->mSize; - - ShearEffect shaderEffect = ShearEffect::New(); - Vector3 shearAnchor = SHEAR_EFFECT_ANCHOR_POINT; - - Vector2 shearCenter( Vector2(position.x + size.width * shearAnchor.x, position.y + size.height * shearAnchor.y) ); - Property::Index centerProperty = shaderEffect.GetPropertyIndex(shaderEffect.GetCenterPropertyName()); - Constraint constraint = Constraint::New( shaderEffect, centerProperty, ShearEffectCenterConstraint(stageSize, shearCenter) ); - constraint.AddSource( Source(mView, Actor::Property::SIZE) ); - - constraint.Apply(); - - SetShaderEffectRecursively( cluster,shaderEffect ); - - // Apply Constraint to Shader Effect - Property::Index scrollOvershootProperty = /*targetGroup*/mScrollView.GetPropertyIndex(ScrollViewWobbleEffect::EFFECT_OVERSHOOT); - Property::Index angleXAxisProperty = shaderEffect.GetPropertyIndex(shaderEffect.GetAngleXAxisPropertyName()); - Property::Index angleYAxisProperty = shaderEffect.GetPropertyIndex(shaderEffect.GetAngleYAxisPropertyName()); - - constraint = Constraint::New( shaderEffect, angleXAxisProperty, ShearEffectConstraint(stageSize, SHEAR_EFFECT_MAX_OVERSHOOT, Vector2::XAXIS) ); - constraint.AddSource( Source(mScrollView, scrollOvershootProperty) ); - constraint.AddSource( Source(mView, Actor::Property::ORIENTATION) ); - constraint.Apply(); - - constraint = Constraint::New( shaderEffect, angleYAxisProperty, ShearEffectConstraint(stageSize, SHEAR_EFFECT_MAX_OVERSHOOT, Vector2::YAXIS ) ); - constraint.AddSource( Source(mScrollView, scrollOvershootProperty) ); - constraint.AddSource( Source(mView, Actor::Property::ORIENTATION) ); - constraint.Apply(); - - + SetMotionBlurEffect( i->mCluster ); } break; } @@ -852,7 +758,6 @@ private: Layer mContentLayer; ///< Content layer (scrolling cluster content) ScrollView mScrollView; ///< The ScrollView container for all clusters - ScrollViewWobbleEffect mScrollViewEffect; ///< ScrollView Wobble effect Image mClusterBorderImage; ///< The border frame that appears on each image std::vector mClusterInfo; ///< Keeps track of each cluster's information. diff --git a/examples/cluster/cluster-impl.cpp b/examples/cluster/cluster-impl.cpp index 00b91f9..1185549 100644 --- a/examples/cluster/cluster-impl.cpp +++ b/examples/cluster/cluster-impl.cpp @@ -23,7 +23,7 @@ #include // for strcmp #include #include -#include +#include #include // INTERNAL INCLUDES diff --git a/examples/hello-world/hello-world-example.cpp b/examples/hello-world/hello-world-example.cpp index 9dea8ac..3a944fa 100644 --- a/examples/hello-world/hello-world-example.cpp +++ b/examples/hello-world/hello-world-example.cpp @@ -43,6 +43,7 @@ public: { // Get a handle to the stage Stage stage = Stage::GetCurrent(); + stage.SetBackgroundColor( Color::WHITE ); TextLabel textLabel = TextLabel::New( "Hello World" ); textLabel.SetAnchorPoint( AnchorPoint::TOP_LEFT ); diff --git a/examples/image-scaling-irregular-grid/grid-flags.h b/examples/image-scaling-irregular-grid/grid-flags.h index 68453b2..01bb44f 100644 --- a/examples/image-scaling-irregular-grid/grid-flags.h +++ b/examples/image-scaling-irregular-grid/grid-flags.h @@ -17,6 +17,7 @@ * */ #include +#include #include /** Controls the output of application logging. */ diff --git a/examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp b/examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp index d921645..259f0d2 100644 --- a/examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp +++ b/examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp @@ -335,13 +335,11 @@ public: mScrollView.ScrollStartedSignal().Connect( this, &ImageScalingIrregularGridController::OnScrollStarted ); mScrollView.ScrollCompletedSignal().Connect( this, &ImageScalingIrregularGridController::OnScrollCompleted ); - mScrollView.EnableScrollComponent( Scrollable::VerticalScrollBar ); - mScrollView.EnableScrollComponent( Scrollable::HorizontalScrollBar ); - mScrollView.SetAnchorPoint(AnchorPoint::CENTER); mScrollView.SetParentOrigin(ParentOrigin::CENTER); - mScrollView.SetSize( stageSize );//Vector2( stageSize.width, fieldHeight ) );//stageSize ); + mScrollView.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); + mScrollView.SetAxisAutoLock( true ); mScrollView.SetAxisAutoLockGradient( 1.0f ); @@ -351,7 +349,7 @@ public: rulerX->SetDomain( RulerDomain( stageSize.width * -0.125f, stageSize.width * 1.125f ) ); //< Scroll slightly left/right of image field. mScrollView.SetRulerX ( rulerX ); - RulerPtr rulerY = new DefaultRuler(); //stageSize.height ); //< Snap in multiples of a screen / stage height + RulerPtr rulerY = new DefaultRuler(); //< Snap in multiples of a screen / stage height rulerY->SetDomain( RulerDomain( - fieldHeight * 0.5f + stageSize.height * 0.5f - GRID_CELL_PADDING, fieldHeight * 0.5f + stageSize.height * 0.5f + GRID_CELL_PADDING ) ); mScrollView.SetRulerY ( rulerY ); @@ -359,8 +357,31 @@ public: mScrollView.Add( imageField ); mGridActor = imageField; + // Create the scroll bar + mScrollBarVertical = ScrollBar::New(Toolkit::ScrollBar::Vertical); + mScrollBarVertical.SetParentOrigin(ParentOrigin::TOP_RIGHT); + mScrollBarVertical.SetAnchorPoint(AnchorPoint::TOP_RIGHT); + mScrollBarVertical.SetResizePolicy(Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::HEIGHT); + mScrollBarVertical.SetResizePolicy(Dali::ResizePolicy::FIT_TO_CHILDREN, Dali::Dimension::WIDTH); + mScrollView.Add(mScrollBarVertical); + + mScrollBarHorizontal = ScrollBar::New(Toolkit::ScrollBar::Horizontal); + mScrollBarHorizontal.SetParentOrigin(ParentOrigin::BOTTOM_LEFT); + mScrollBarHorizontal.SetAnchorPoint(AnchorPoint::TOP_LEFT); + mScrollBarHorizontal.SetResizePolicy(Dali::ResizePolicy::FIT_TO_CHILDREN, Dali::Dimension::WIDTH); + mScrollBarHorizontal.SetOrientation(Quaternion(Radian( 1.5f * Math::PI ), Vector3::ZAXIS)); + mScrollView.Add(mScrollBarHorizontal); + + mScrollView.OnRelayoutSignal().Connect( this, &ImageScalingIrregularGridController::OnScrollViewRelayout ); + // Scroll to top of grid so first images loaded are on-screen: - mScrollView.ScrollTo( Vector3( 0, -1000000, 0 ) ); + mScrollView.ScrollTo( Vector2( 0, -1000000 ) ); + } + + void OnScrollViewRelayout(Actor actor) + { + // Make the height of the horizontal scroll bar to be the same as the width of scroll view. + mScrollBarHorizontal.SetSize(Vector2(0.0f, mScrollView.GetRelayoutSize( Dimension::WIDTH) )); } /** @@ -549,7 +570,7 @@ public: * note this state (mScrolling = true) * @param[in] position Current Scroll Position */ - void OnScrollStarted( const Vector3& position ) + void OnScrollStarted( const Vector2& position ) { mScrolling = true; } @@ -559,7 +580,7 @@ public: * note this state (mScrolling = false). * @param[in] position Current Scroll Position */ - void OnScrollCompleted( const Vector3& position ) + void OnScrollCompleted( const Vector2& position ) { mScrolling = false; } @@ -573,6 +594,8 @@ private: TextLabel mTitleActor; ///< The Toolbar's Title. Actor mGridActor; ///< The container for the grid of images ScrollView mScrollView; ///< ScrollView UI Component + ScrollBar mScrollBarVertical; + ScrollBar mScrollBarHorizontal; bool mScrolling; ///< ScrollView scrolling state (true = scrolling, false = stationary) std::map mFittingModes; ///< Stores the current scaling mode of each image, keyed by image actor id. std::map mSizes; ///< Stores the current size of each image, keyed by image actor id. diff --git a/examples/item-view/item-view-example.cpp b/examples/item-view/item-view-example.cpp index 6a0a6e2..851cfee 100644 --- a/examples/item-view/item-view-example.cpp +++ b/examples/item-view/item-view-example.cpp @@ -25,6 +25,7 @@ #include #include +#include using namespace Dali; using namespace Dali::Toolkit; @@ -103,16 +104,6 @@ const unsigned int IMAGE_WIDTH = 256; const unsigned int IMAGE_HEIGHT = 256; const unsigned int NUM_IMAGE_PER_ROW_IN_ATLAS = 8; -AlphaFunction ALPHA_FUNCTIONS[] = { AlphaFunction(AlphaFunction::LINEAR), - AlphaFunction(AlphaFunction::EASE_IN), - AlphaFunction(AlphaFunction::EASE_OUT) }; - -const unsigned int NUM_ALPHA_FUNCTIONS = sizeof(ALPHA_FUNCTIONS) / sizeof(AlphaFunction); - -const char* ALPHA_FUNCTIONS_TEXT[] = { "Linear", - "EaseIn", - "EaseOut" }; - const char* BACKGROUND_IMAGE( "" ); const char* TOOLBAR_IMAGE( DALI_IMAGE_DIR "top-bar.png" ); const char* EDIT_IMAGE( DALI_IMAGE_DIR "icon-edit.png" ); @@ -138,20 +129,10 @@ 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 unsigned int DEPTH_LAYOUT_ROWS_PORTRAIT = 26; -const unsigned int DEPTH_LAYOUT_ROWS_LANDSCAPE = 16; -const float DEPTH_LAYOUT_TILT_ANGLE_PORTRAIT = 25.0f; -const float DEPTH_LAYOUT_TILT_ANGLE_LANDSCAPE = 21.0f; -const float DEPTH_LAYOUT_ROW_SPACING_FACTOR = 0.1f; const float DEPTH_LAYOUT_ITEM_SIZE_FACTOR_PORTRAIT = 1.0f; const float DEPTH_LAYOUT_ITEM_SIZE_FACTOR_LANDSCAPE = 0.8f; -const float DEPTH_LAYOUT_BOTTOM_MARGIN_FACTOR_PORTRAIT = 0.2f; -const float DEPTH_LAYOUT_BOTTOM_MARGIN_FACTOR_LANDSCAPE = 0.1f; +const float DEPTH_LAYOUT_COLUMNS = 3.0f; -const float SPIRAL_LAYOUT_REVOLUTION_NUMBER_PORTRAIT = 4.5f; -const float SPIRAL_LAYOUT_REVOLUTION_NUMBER_LANDSCAPE = 2.5f; - -const float DEPTH_LAYOUT_HEIGHT_SCALE = 20.0f; const float MIN_SWIPE_DISTANCE = 15.0f; const float MIN_SWIPE_SPEED = 5.0f; @@ -162,33 +143,23 @@ const float LABEL_TEXT_SIZE_Y = 20.0f; const Vector3 INITIAL_OFFSCREEN_POSITION( 1000.0f, 0, -1000.0f ); -static Vector3 DepthLayoutItemSizeFunctionPortrait(unsigned int numberOfColumns, float layoutWidth) +static Vector3 DepthLayoutItemSizeFunctionPortrait( float layoutWidth ) { - float width = (layoutWidth / static_cast(numberOfColumns + 1)) * DEPTH_LAYOUT_ITEM_SIZE_FACTOR_PORTRAIT; + float width = ( layoutWidth / ( DEPTH_LAYOUT_COLUMNS + 1.0f ) ) * DEPTH_LAYOUT_ITEM_SIZE_FACTOR_PORTRAIT; // 1x1 aspect ratio return Vector3(width, width, width); } -static Vector3 DepthLayoutItemSizeFunctionLandscape(unsigned int numberOfColumns, float layoutWidth) +static Vector3 DepthLayoutItemSizeFunctionLandscape( float layoutWidth ) { - float width = (layoutWidth / static_cast(numberOfColumns + 1)) * DEPTH_LAYOUT_ITEM_SIZE_FACTOR_LANDSCAPE; + float width = ( layoutWidth / ( DEPTH_LAYOUT_COLUMNS + 1.0f ) ) * DEPTH_LAYOUT_ITEM_SIZE_FACTOR_LANDSCAPE; // 1x1 aspect ratio return Vector3(width, width, width); } -static float DepthLayoutBottomMarginFunctionPortrait(float layoutHeight) -{ - return layoutHeight * DEPTH_LAYOUT_BOTTOM_MARGIN_FACTOR_PORTRAIT; -} - -static float DepthLayoutBottomMarginFunctionLandscape(float layoutHeight) -{ - return layoutHeight * DEPTH_LAYOUT_BOTTOM_MARGIN_FACTOR_LANDSCAPE; -} - -} +} // unnamed namespace /** * This example shows how to use ItemView UI control. @@ -219,11 +190,9 @@ public: ItemViewExample( Application& application ) : mApplication( application ), mMode( MODE_NORMAL ), - mMenuShown( false ), mOrientation( 0 ), mCurrentLayout( SPIRAL_LAYOUT ), - mDurationSeconds( 1.0f ), - mAlphaFuncIndex( 0u ) + mDurationSeconds( 0.25f ) { // Connect to the Application's Init signal mApplication.InitSignal().Connect(this, &ItemViewExample::OnInit); @@ -321,9 +290,9 @@ public: stage.Add( mItemView ); // Create the layouts - mSpiralLayout = SpiralLayout::New(); - mDepthLayout = DepthLayout::New(); - mGridLayout = GridLayout::New(); + mSpiralLayout = DefaultItemLayout::New( DefaultItemLayout::SPIRAL ); + mDepthLayout = DefaultItemLayout::New( DefaultItemLayout::DEPTH ); + mGridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID ); // Add the layouts to item view mItemView.AddLayout(*mSpiralLayout); @@ -334,7 +303,7 @@ public: mItemView.SetMinimumSwipeSpeed(MIN_SWIPE_SPEED); // Activate the spiral layout - UseLayout(mCurrentLayout, 0.0f); + SetLayout( mCurrentLayout ); mItemView.SetKeyboardFocusable( true ); KeyboardFocusManager::Get().PreFocusChangeSignal().Connect( this, &ItemViewExample::OnKeyboardPreFocusChange ); @@ -357,49 +326,45 @@ public: } /** + * Animate to a different layout + */ + void ChangeLayout() + { + Animation animation = Animation::New( mDurationSeconds ); + animation.FinishedSignal().Connect( this, &ItemViewExample::AnimationFinished ); + animation.AnimateTo( Property( mItemView, Actor::Property::COLOR_ALPHA ), 0.0f ); + animation.Play(); + } + + void AnimationFinished( Animation& ) + { + SetLayout( mCurrentLayout ); + + Animation animation = Animation::New( mDurationSeconds ); + animation.AnimateTo( Property( mItemView, Actor::Property::COLOR_ALPHA ), 1.0f ); + animation.Play(); + } + + /** * Switch to a different item view layout */ - void UseLayout(int layoutId, float duration) + void SetLayout( int layoutId ) { // Set the new orientation to the layout mItemView.GetLayout(layoutId)->SetOrientation(static_cast(mOrientation / 90)); Vector2 stageSize = Stage::GetCurrent().GetSize(); - if(layoutId == SPIRAL_LAYOUT) - { - mSpiralLayout->SetRevolutionDistance(stageSize.height / Stage::GetCurrent().GetDpi().y * 45.0f); - } - - if(layoutId == GRID_LAYOUT) - { - // Set up the grid layout according to the new orientation - float layoutWidth = Toolkit::IsHorizontal(mGridLayout->GetOrientation()) ? stageSize.height : stageSize.width; - float gridItemSize = (layoutWidth / mGridLayout->GetNumberOfColumns()) * 0.5f; - mGridLayout->SetScrollSpeedFactor(mGridLayout->GetNumberOfColumns() / gridItemSize); - - float toolbarHeight = mToolBar.GetCurrentSize().y; - mGridLayout->SetTopMargin(toolbarHeight + mGridLayout->GetRowSpacing()); - } - if(layoutId == DEPTH_LAYOUT) { // Set up the depth layout according to the new orientation if(Toolkit::IsVertical(mDepthLayout->GetOrientation())) { - mDepthLayout->SetRowSpacing(stageSize.height * DEPTH_LAYOUT_ROW_SPACING_FACTOR); - mDepthLayout->SetNumberOfRows(DEPTH_LAYOUT_ROWS_PORTRAIT); - mDepthLayout->SetTiltAngle( Degree( DEPTH_LAYOUT_TILT_ANGLE_PORTRAIT - mDepthLayout->GetNumberOfColumns() ) ); - mDepthLayout->SetItemSizeFunction(DepthLayoutItemSizeFunctionPortrait); - mDepthLayout->SetBottomMarginFunction(DepthLayoutBottomMarginFunctionPortrait); + mDepthLayout->SetItemSize( DepthLayoutItemSizeFunctionPortrait( stageSize.width ) ); } else { - mDepthLayout->SetRowSpacing(stageSize.width * DEPTH_LAYOUT_ROW_SPACING_FACTOR); - mDepthLayout->SetNumberOfRows(DEPTH_LAYOUT_ROWS_LANDSCAPE); - mDepthLayout->SetTiltAngle( Degree( DEPTH_LAYOUT_TILT_ANGLE_LANDSCAPE - mDepthLayout->GetNumberOfColumns() ) ); - mDepthLayout->SetItemSizeFunction(DepthLayoutItemSizeFunctionLandscape); - mDepthLayout->SetBottomMarginFunction(DepthLayoutBottomMarginFunctionLandscape); + mDepthLayout->SetItemSize( DepthLayoutItemSizeFunctionLandscape( stageSize.height ) ); } } @@ -407,7 +372,7 @@ public: mItemView.SetAnchoring(layoutId == DEPTH_LAYOUT); // Activate the layout - mItemView.ActivateLayout(layoutId, Vector3(stageSize.x, stageSize.y, stageSize.x), duration); + mItemView.ActivateLayout( layoutId, Vector3(stageSize.x, stageSize.y, stageSize.x), 0.0f ); } /** @@ -424,7 +389,7 @@ public: // Remember orientation mOrientation = angle; - UseLayout(mCurrentLayout, mDurationSeconds); + SetLayout( mCurrentLayout ); } } @@ -433,7 +398,7 @@ public: // Switch to the next layout mCurrentLayout = (mCurrentLayout + 1) % mItemView.GetLayoutCount(); - UseLayout(mCurrentLayout, mDurationSeconds); + ChangeLayout(); SetLayoutTitle(); SetLayoutImage(); @@ -973,100 +938,6 @@ private: mTitleActor.SetProperty( TextLabel::Property::TEXT, title ); } - void ShowMenu() - { - Stage stage = Stage::GetCurrent(); - const float popupWidth = stage.GetSize().x * 0.75f; - - mMenu = Toolkit::Popup::New(); - mMenu.SetParentOrigin( ParentOrigin::BOTTOM_LEFT ); - mMenu.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT ); - mMenu.SetSize( popupWidth, MENU_OPTION_HEIGHT * 2 ); - mMenu.OutsideTouchedSignal().Connect( this, &ItemViewExample::HideMenu ); - - TableView tableView = TableView::New( 0, 0 ); - tableView.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - mMenu.Add( tableView ); - - Slider slider = Slider::New(); - slider.SetProperty( Slider::Property::LOWER_BOUND, 0.0f ); - slider.SetProperty( Slider::Property::UPPER_BOUND, 3.0f ); - slider.SetProperty( Slider::Property::VALUE, mDurationSeconds ); - slider.SetProperty( Slider::Property::VALUE_PRECISION, 2 ); - slider.SetProperty( Slider::Property::SHOW_POPUP, true ); - slider.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - slider.ValueChangedSignal().Connect( this, &ItemViewExample::SliderValueChange ); - tableView.AddChild( slider, TableView::CellPosition( 0, 0 ) ); - - TextLabel text = TextLabel::New( "Duration" ); - text.SetAnchorPoint( ParentOrigin::TOP_LEFT ); - text.SetParentOrigin( ParentOrigin::TOP_LEFT ); - text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); - text.SetResizePolicy( ResizePolicy::FIXED, Dimension::HEIGHT ); - text.SetSize( Vector2( 0.0f, LABEL_TEXT_SIZE_Y ) ); - slider.Add( text ); - - Actor textContainer = Actor::New(); - textContainer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - mAlphaFunctionText = TextLabel::New( ALPHA_FUNCTIONS_TEXT[mAlphaFuncIndex] ); - mAlphaFunctionText.SetAnchorPoint( ParentOrigin::CENTER ); - mAlphaFunctionText.SetParentOrigin( ParentOrigin::CENTER ); - textContainer.Add( mAlphaFunctionText ); - tableView.AddChild( textContainer, TableView::CellPosition( 1, 0 ) ); - - mTapDetector = TapGestureDetector::New(); - mTapDetector.Attach(mAlphaFunctionText); - mTapDetector.DetectedSignal().Connect( this, &ItemViewExample::ChangeAlphaFunctionOnTap ); - - text = TextLabel::New( "Alpha Function" ); - text.SetAnchorPoint( ParentOrigin::TOP_LEFT ); - text.SetParentOrigin( ParentOrigin::TOP_LEFT ); - text.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); - text.SetSize( 0.0f, LABEL_TEXT_SIZE_Y ); - textContainer.Add( text ); - - mMenu.Show(); - mMenuShown = true; - } - - bool SliderValueChange( Toolkit::Slider slider, float value ) - { - mDurationSeconds = value; - - return true; - } - - void ChangeAlphaFunctionOnTap( Actor actor, const TapGesture& tap ) - { - if( NUM_ALPHA_FUNCTIONS <= ++mAlphaFuncIndex ) - { - mAlphaFuncIndex = 0; - } - - if( mAlphaFunctionText ) - { - mAlphaFunctionText.SetProperty( TextLabel::Property::TEXT, std::string(ALPHA_FUNCTIONS_TEXT[mAlphaFuncIndex]) ); - } - - if( mItemView ) - { - mItemView.GetActiveLayout()->SetAlphaFunction( ALPHA_FUNCTIONS[mAlphaFuncIndex] ); - } - } - - void HideMenu() - { - mTapDetector.Reset(); - - if( mMenu ) - { - mMenu.Hide(); - mMenu.Reset(); - } - - mMenuShown = false; - } - /** * Main key event handler */ @@ -1074,27 +945,9 @@ private: { if(event.state == KeyEvent::Down) { - if( IsKey( event, DALI_KEY_MENU ) ) - { - if( mMenuShown ) - { - HideMenu(); - } - else - { - ShowMenu(); - } - } - else if( IsKey( event, DALI_KEY_ESCAPE) || IsKey( event, DALI_KEY_BACK ) ) + if( IsKey( event, DALI_KEY_ESCAPE) || IsKey( event, DALI_KEY_BACK ) ) { - if( mMenuShown ) - { - HideMenu(); - } - else - { - mApplication.Quit(); - } + mApplication.Quit(); } } } @@ -1103,7 +956,6 @@ private: Application& mApplication; Mode mMode; - bool mMenuShown; Toolkit::Control mView; unsigned int mOrientation; @@ -1117,11 +969,9 @@ private: unsigned int mCurrentLayout; float mDurationSeconds; - SpiralLayoutPtr mSpiralLayout; - DepthLayoutPtr mDepthLayout; - GridLayoutPtr mGridLayout; - - Toolkit::Popup mMenu; + ItemLayoutPtr mSpiralLayout; + ItemLayoutPtr mDepthLayout; + ItemLayoutPtr mGridLayout; TapGestureDetector mTapDetector; Toolkit::PushButton mLayoutButton; @@ -1129,8 +979,6 @@ private: Toolkit::PushButton mInsertButton; Toolkit::PushButton mReplaceButton; - unsigned int mAlphaFuncIndex; - TextLabel mAlphaFunctionText; BufferImage mWhiteImage; }; diff --git a/examples/logging/logging-example.cpp b/examples/logging/logging-example.cpp index a37fcb4..aa8d0ae 100644 --- a/examples/logging/logging-example.cpp +++ b/examples/logging/logging-example.cpp @@ -18,7 +18,7 @@ #include "shared/view.h" #include #include - +#include #include using namespace Dali; diff --git a/examples/scroll-view/scroll-view-example.cpp b/examples/scroll-view/scroll-view-example.cpp index da7a64b..b5b511a 100644 --- a/examples/scroll-view/scroll-view-example.cpp +++ b/examples/scroll-view/scroll-view-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * 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. @@ -31,18 +31,15 @@ namespace const char * const BACKGROUND_IMAGE( DALI_IMAGE_DIR "background-default.png" ); const char * const TOOLBAR_IMAGE( DALI_IMAGE_DIR "top-bar.png" ); const char * const APPLICATION_TITLE( "ScrollView" ); -const char * const EFFECT_DEPTH_IMAGE( DALI_IMAGE_DIR "icon-scroll-view-depth.png" ); -const char * const EFFECT_INNER_CUBE_IMAGE( DALI_IMAGE_DIR "icon-scroll-view-inner-cube.png" ); const char * const EFFECT_CAROUSEL_IMAGE( DALI_IMAGE_DIR "icon-scroll-view-carousel.png" ); const Vector3 ICON_SIZE(100.0f, 100.0f, 0.0f); const char* EFFECT_MODE_NAME[] = { - "Depth", - "Cube", "PageCarousel", "PageCube", - "PageSpiral" + "PageSpiral", + "PageWave" }; const char * const IMAGE_PATHS[] = { @@ -119,25 +116,6 @@ const int PAGE_COLUMNS = 10; ///< const int PAGE_ROWS = 1; ///< Number of Pages going down (rows) const int IMAGE_ROWS = 5; ///< Number of Images going down (rows) with a Page -// 3D Effect constants -const Vector3 ANGLE_CUBE_PAGE_ROTATE(Math::PI * 0.2f, Math::PI * 0.2f, 0.0f); ///< Cube page rotates as if it has ten sides with the camera positioned inside -const Vector2 ANGLE_CUSTOM_CUBE_SWING(-Math::PI * 0.45f, -Math::PI * 0.45f); ///< outer cube pages swing 90 degrees as they pan offscreen -const Vector2 ANGLE_SPIRAL_SWING_IN(Math::PI * 0.45f, Math::PI * 0.45f); -const Vector2 ANGLE_SPIRAL_SWING_OUT(Math::PI * 0.3f, Math::PI * 0.3f); - -// Depth Effect constants -const Vector2 POSITION_EXTENT_DEPTH_EFFECT(0.5f, 2.5f); ///< Extent of X & Y position to alter function exponent. -const Vector2 OFFSET_EXTENT_DEPTH_EFFECT(1.0f, 1.0f); ///< Function exponent offset constant. -const float POSITION_SCALE_DEPTH_EFFECT(1.5f); ///< Position scaling. -const float SCALE_EXTENT_DEPTH_EFFECT(0.5f); ///< Maximum scale factor when Actors scrolled one page away (50% size) - -// 3D Effect constants -const Vector2 ANGLE_SWING_3DEFFECT(Math::PI_2 * 0.75, Math::PI_2 * 0.75f); ///< Angle Swing in radians -const Vector2 POSITION_SWING_3DEFFECT(0.25f, 0.25f); ///< Position Swing relative to stage size. -const Vector3 ANCHOR_3DEFFECT_STYLE0(-105.0f, 30.0f, -240.0f); ///< Rotation Anchor position for 3D Effect (Style 0) -const Vector3 ANCHOR_3DEFFECT_STYLE1(65.0f, -70.0f, -300.0f); ///< Rotation Anchor position for 3D Effect (Style 1) - - const unsigned int IMAGE_THUMBNAIL_WIDTH = 256; ///< Width of Thumbnail Image in texels const unsigned int IMAGE_THUMBNAIL_HEIGHT = 256; ///< Height of Thumbnail Image in texels @@ -163,7 +141,7 @@ public: : mApplication( application ), mView(), mScrolling(false), - mEffectMode(CubeEffect) + mEffectMode(PageCarouselEffect) { // Connect to the Application's Init and orientation changed signal mApplication.InitSignal().Connect(this, &ExampleController::OnInit); @@ -196,11 +174,10 @@ public: TOOLBAR_IMAGE, "" ); - mEffectIcon[ DepthEffect ] = ResourceImage::New( EFFECT_DEPTH_IMAGE ); - mEffectIcon[ CubeEffect ] = ResourceImage::New( EFFECT_INNER_CUBE_IMAGE ); mEffectIcon[ PageCarouselEffect ] = ResourceImage::New( EFFECT_CAROUSEL_IMAGE ); mEffectIcon[ PageCubeEffect ] = ResourceImage::New( EFFECT_CAROUSEL_IMAGE ); mEffectIcon[ PageSpiralEffect ] = ResourceImage::New( EFFECT_CAROUSEL_IMAGE ); + mEffectIcon[ PageWaveEffect ] = ResourceImage::New( EFFECT_CAROUSEL_IMAGE ); // Create a effect change button. (right of toolbar) mEffectChangeButton = Toolkit::PushButton::New(); @@ -274,23 +251,11 @@ private: // apply new Effect to ScrollView ApplyEffectToScrollView(); - - for(ActorIter pageIter = mPages.begin(); pageIter != mPages.end(); ++pageIter) + unsigned int pageCount(0); + for( std::vector< Actor >::iterator pageIter = mPages.begin(); pageIter != mPages.end(); ++pageIter) { Actor page = *pageIter; - ApplyEffectToPage( page ); - - unsigned int numChildren = (*pageIter).GetChildCount(); - for(unsigned int i=0; iSetDomain(RulerDomain(0.0f, stageSize.x * PAGE_COLUMNS, !wrap)); + rulerY->Disable(); + + Dali::Path path = Dali::Path::New(); + Dali::Property::Array points; + points.Resize(3); + Dali::Property::Array controlPoints; + controlPoints.Resize(4); + Vector3 forward; + if( mEffectMode == PageCarouselEffect) { - case DepthEffect: - { - mScrollViewEffect = ScrollViewDepthEffect::New(); - mScrollView.SetScrollSnapDuration(EFFECT_SNAP_DURATION); - mScrollView.SetScrollFlickDuration(EFFECT_FLICK_DURATION); - mScrollView.SetScrollSnapAlphaFunction(AlphaFunction::EASE_OUT); - mScrollView.SetScrollFlickAlphaFunction(AlphaFunction::EASE_OUT); - mScrollView.RemoveConstraintsFromChildren(); - break; - } - case CubeEffect: - { - mScrollViewEffect = ScrollViewCubeEffect::New(); - mScrollView.SetScrollSnapDuration(EFFECT_SNAP_DURATION); - mScrollView.SetScrollFlickDuration(EFFECT_FLICK_DURATION); - mScrollView.SetScrollSnapAlphaFunction(AlphaFunction::EASE_OUT_BACK); - mScrollView.SetScrollFlickAlphaFunction(AlphaFunction::EASE_OUT_BACK); - mScrollView.RemoveConstraintsFromChildren(); - break; - } + points[0] = Vector3( stageSize.x*0.75, 0.0f, -stageSize.x*0.75f); + points[1] = Vector3( 0.0f, 0.0f, 0.0f ); + points[2] = Vector3( -stageSize.x*0.75f, 0.0f, -stageSize.x*0.75f); + path.SetProperty( Path::Property::POINTS, points ); - case PageCarouselEffect: - { - mScrollViewEffect = ScrollViewPageCarouselEffect::New(); - mScrollView.SetScrollSnapDuration(EFFECT_SNAP_DURATION); - mScrollView.SetScrollFlickDuration(EFFECT_FLICK_DURATION); - mScrollView.SetScrollSnapAlphaFunction(AlphaFunction::EASE_OUT); - mScrollView.SetScrollFlickAlphaFunction(AlphaFunction::EASE_OUT); - mScrollView.RemoveConstraintsFromChildren(); - break; - } + controlPoints[0] = Vector3( stageSize.x*0.5f, 0.0f, 0.0f ); + controlPoints[1] = Vector3( stageSize.x*0.5f, 0.0f, 0.0f ); + controlPoints[2] = Vector3(-stageSize.x*0.5f, 0.0f, 0.0f ); + controlPoints[3] = Vector3(-stageSize.x*0.5f, 0.0f, 0.0f ); + path.SetProperty( Path::Property::CONTROL_POINTS, controlPoints ); - case PageCubeEffect: - { - mScrollViewEffect = ScrollViewPageCubeEffect::New(); - mScrollView.SetScrollSnapDuration(EFFECT_SNAP_DURATION); - mScrollView.SetScrollFlickDuration(EFFECT_FLICK_DURATION); - mScrollView.SetScrollSnapAlphaFunction(AlphaFunction::EASE_OUT); - mScrollView.SetScrollFlickAlphaFunction(AlphaFunction::EASE_OUT); - mScrollView.RemoveConstraintsFromChildren(); - break; - } + forward = Vector3::ZERO; + } + else if( mEffectMode == PageCubeEffect) + { + points[0] = Vector3( stageSize.x*0.5, 0.0f, stageSize.x*0.5f); + points[1] = Vector3( 0.0f, 0.0f, 0.0f ); + points[2] = Vector3( -stageSize.x*0.5f, 0.0f, stageSize.x*0.5f); + path.SetProperty( Path::Property::POINTS, points ); + + controlPoints[0] = Vector3( stageSize.x*0.5f, 0.0f, stageSize.x*0.3f ); + controlPoints[1] = Vector3( stageSize.x*0.3f, 0.0f, 0.0f ); + controlPoints[2] = Vector3(-stageSize.x*0.3f, 0.0f, 0.0f ); + controlPoints[3] = Vector3(-stageSize.x*0.5f, 0.0f, stageSize.x*0.3f ); + path.SetProperty( Path::Property::CONTROL_POINTS, controlPoints ); + + forward = Vector3(-1.0f,0.0f,0.0f); + } + else if( mEffectMode == PageSpiralEffect) + { + points[0] = Vector3( stageSize.x*0.5, 0.0f, -stageSize.x*0.5f); + points[1] = Vector3( 0.0f, 0.0f, 0.0f ); + points[2] = Vector3( -stageSize.x*0.5f, 0.0f, -stageSize.x*0.5f); + path.SetProperty( Path::Property::POINTS, points ); + + controlPoints[0] = Vector3( stageSize.x*0.5f, 0.0f, 0.0f ); + controlPoints[1] = Vector3( stageSize.x*0.5f, 0.0f, 0.0f ); + controlPoints[2] = Vector3(-stageSize.x*0.5f, 0.0f, 0.0f ); + controlPoints[3] = Vector3(-stageSize.x*0.5f, 0.0f, 0.0f ); + path.SetProperty( Path::Property::CONTROL_POINTS, controlPoints ); + + forward = Vector3(-1.0f,0.0f,0.0f); + } + else if( mEffectMode == PageWaveEffect) + { + points[0] = Vector3( stageSize.x, 0.0f, -stageSize.x); + points[1] = Vector3( 0.0f, 0.0f, 0.0f ); + points[2] = Vector3( -stageSize.x, 0.0f, -stageSize.x); + path.SetProperty( Path::Property::POINTS, points ); + + controlPoints[0] = Vector3( 0.0f, 0.0f, -stageSize.x ); + controlPoints[1] = Vector3( stageSize.x*0.5f, 0.0f, 0.0f ); + controlPoints[2] = Vector3( -stageSize.x*0.5f, 0.0f, 0.0f); + controlPoints[3] = Vector3(0.0f, 0.0f,-stageSize.x ); + path.SetProperty( Path::Property::CONTROL_POINTS, controlPoints ); + + forward = Vector3(-1.0f,0.0f,0.0f); + } - case PageSpiralEffect: - { - mScrollViewEffect = ScrollViewPageSpiralEffect::New(); - mScrollView.SetScrollSnapDuration(EFFECT_SNAP_DURATION); - mScrollView.SetScrollFlickDuration(EFFECT_FLICK_DURATION); - mScrollView.SetScrollSnapAlphaFunction(AlphaFunction::EASE_OUT); - mScrollView.SetScrollFlickAlphaFunction(AlphaFunction::EASE_OUT); - mScrollView.RemoveConstraintsFromChildren(); - break; - } + mScrollViewEffect = ScrollViewPagePathEffect::New(path, forward,Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(stageSize.x,stageSize.y,0.0f),PAGE_COLUMNS); + mScrollView.SetScrollSnapDuration(EFFECT_SNAP_DURATION); + mScrollView.SetScrollFlickDuration(EFFECT_FLICK_DURATION); + mScrollView.SetScrollSnapAlphaFunction(AlphaFunction::EASE_OUT); + mScrollView.SetScrollFlickAlphaFunction(AlphaFunction::EASE_OUT); + mScrollView.RemoveConstraintsFromChildren(); - default: - { - break; - } + rulerX = CreateRuler(snap ? stageSize.width * 0.5f : 0.0f); + if( wrap ) + { + rulerX->SetDomain(RulerDomain(0.0f, stageSize.x * 0.5f * PAGE_COLUMNS, !wrap)); + } + else + { + rulerX->SetDomain(RulerDomain(0.0f, stageSize.x*0.5f* (PAGE_COLUMNS+1), !wrap)); } + unsigned int currentPage = mScrollView.GetCurrentPage(); if( mScrollViewEffect ) { mScrollView.ApplyEffect(mScrollViewEffect); } mScrollView.SetWrapMode(wrap); - - RulerPtr rulerX = CreateRuler(snap ? stageSize.width : 0.0f); - RulerPtr rulerY = new DefaultRuler; - rulerX->SetDomain(RulerDomain(0.0f, stageSize.x * PAGE_COLUMNS, !wrap)); - rulerY->Disable(); - mScrollView.SetRulerX( rulerX ); mScrollView.SetRulerY( rulerY ); + + mScrollView.ScrollTo( currentPage, 0.0f ); } /** @@ -449,110 +438,16 @@ private: * * @param[in] page The page Actor to apply effect to. */ - void ApplyEffectToPage(Actor page) + void ApplyEffectToPage(Actor page, unsigned int pageOrder ) { page.RemoveConstraints(); page.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - switch( mEffectMode ) - { - case PageCarouselEffect: - { - ScrollViewPageCarouselEffect effect = ScrollViewPageCarouselEffect::DownCast( mScrollViewEffect ); - effect.ApplyToPage( page ); - break; - } - - case PageCubeEffect: - { - ScrollViewPageCubeEffect effect = ScrollViewPageCubeEffect::DownCast( mScrollViewEffect ); - effect.ApplyToPage( page, ANGLE_SWING_3DEFFECT ); - break; - } - - case PageSpiralEffect: - { - ScrollViewPageSpiralEffect effect = ScrollViewPageSpiralEffect::DownCast( mScrollViewEffect ); - effect.ApplyToPage( page, ANGLE_SWING_3DEFFECT ); - break; - } - - default: - { - break; - } - } + ScrollViewPagePathEffect effect = ScrollViewPagePathEffect::DownCast( mScrollViewEffect ); + effect.ApplyToPage( page, pageOrder ); } /** - * [Actor] - * Applies effect to child which resides in page (which in turn resides in scrollview) - * - * @note Page is typically the Parent of child, although in - * some scenarios Page is simply a container which has a child as - * a descendent. - * - * @param[in] child The child actor to apply effect to - * @param[in] page The page which this child is inside - */ - void ApplyEffectToActor( Actor child, Actor page ) - { - switch( mEffectMode ) - { - case DepthEffect: - { - ApplyDepthEffectToActor( child ); - break; - } - - case CubeEffect: - { - ApplyCubeEffectToActor( child ); - break; - } - - default: - { - break; - } - } - } - - /** - * Applies depth effect to the child which resides in page (which in turn resides in scrollview) - * - * @param[in] child The child actor to apply depth effect to - */ - void ApplyDepthEffectToActor( Actor child ) - { - ScrollViewDepthEffect depthEffect = ScrollViewDepthEffect::DownCast(mScrollViewEffect); - depthEffect.ApplyToActor( child, - POSITION_EXTENT_DEPTH_EFFECT, - OFFSET_EXTENT_DEPTH_EFFECT, - POSITION_SCALE_DEPTH_EFFECT, - SCALE_EXTENT_DEPTH_EFFECT ); - } - - void ApplyCubeEffectToActor( Actor child ) - { - Vector3 anchor; - if(rand()&1) - { - anchor = ANCHOR_3DEFFECT_STYLE0; - } - else - { - anchor = ANCHOR_3DEFFECT_STYLE1; - } - - ScrollViewCubeEffect cubeEffect = ScrollViewCubeEffect::DownCast(mScrollViewEffect); - cubeEffect.ApplyToActor( child, - anchor, - ANGLE_SWING_3DEFFECT, - POSITION_SWING_3DEFFECT * Vector2(Stage::GetCurrent().GetSize())); - } - - /** * Creates an Image (Helper) * * @param[in] filename the path of the image. @@ -577,7 +472,7 @@ private: * note this state (mScrolling = true) * @param[in] position Current Scroll Position */ - void OnScrollStarted( const Vector3& position ) + void OnScrollStarted( const Vector2& position ) { mScrolling = true; } @@ -587,7 +482,7 @@ private: * note this state (mScrolling = false) * @param[in] position Current Scroll Position */ - void OnScrollCompleted( const Vector3& position ) + void OnScrollCompleted( const Vector2& position ) { mScrolling = false; } @@ -666,18 +561,17 @@ private: ScrollView mScrollView; ///< ScrollView UI Component bool mScrolling; ///< ScrollView scrolling state (true = scrolling, false = stationary) ScrollViewEffect mScrollViewEffect; ///< ScrollView Effect instance. - ActorContainer mPages; ///< Keeps track of all the pages for applying effects. + std::vector< Actor > mPages; ///< Keeps track of all the pages for applying effects. /** * Enumeration of different effects this scrollview can operate under. */ enum EffectMode { - DepthEffect, ///< Depth Effect - CubeEffect, ///< Cube effect PageCarouselEffect, ///< Page carousel effect PageCubeEffect, ///< Page cube effect PageSpiralEffect, ///< Page spiral effect + PageWaveEffect, ///< Page wave effect Total }; diff --git a/examples/size-negotiation/size-negotiation-example.cpp b/examples/size-negotiation/size-negotiation-example.cpp index 60ee45d..af19e24 100644 --- a/examples/size-negotiation/size-negotiation-example.cpp +++ b/examples/size-negotiation/size-negotiation-example.cpp @@ -193,17 +193,13 @@ public: mItemView.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); // Use a grid layout for tests - Toolkit::GridLayoutPtr gridLayout = Toolkit::GridLayout::New(); - gridLayout->SetNumberOfColumns( 2 ); - gridLayout->SetTopMargin( DP(TOOLBAR_HEIGHT) + DP(20.0f) ); - gridLayout->SetBottomMargin( DP(100.0f) ); - gridLayout->SetRowSpacing( DP(20.0f) ); - mItemView.AddLayout( *gridLayout ); - Vector2 stageSize = stage.GetSize(); - float layoutWidth = Toolkit::IsHorizontal( gridLayout->GetOrientation() ) ? stageSize.height : stageSize.width; - float gridItemSize = ( layoutWidth / gridLayout->GetNumberOfColumns() ) * 0.5f; - gridLayout->SetScrollSpeedFactor( gridLayout->GetNumberOfColumns() / gridItemSize * 0.5f ); + Toolkit::ItemLayoutPtr gridLayout = Toolkit::DefaultItemLayout::New( Toolkit::DefaultItemLayout::LIST ); + Vector3 itemSize; + gridLayout->GetItemSize( 0, Vector3( stageSize ), itemSize ); + itemSize.height = stageSize.y / 10; + gridLayout->SetItemSize( itemSize ); + mItemView.AddLayout( *gridLayout ); mItemView.ActivateLayout( 0, Vector3(stageSize.x, stageSize.y, stageSize.x), 0.0f ); diff --git a/examples/text-field/text-field-example.cpp b/examples/text-field/text-field-example.cpp index dfcd06a..12a29a9 100644 --- a/examples/text-field/text-field-example.cpp +++ b/examples/text-field/text-field-example.cpp @@ -22,20 +22,51 @@ // EXTERNAL INCLUDES #include -#include +#include // INTERNAL INCLUDES +#include "shared/multi-language-strings.h" #include "shared/view.h" using namespace Dali; using namespace Dali::Toolkit; +using namespace MultiLanguageStrings; namespace { -const char* const BACKGROUND_IMAGE = DALI_IMAGE_DIR "button-up.9.png"; + const char* const BACKGROUND_IMAGE = DALI_IMAGE_DIR "button-up.9.png"; -const float BORDER_WIDTH = 4.0f; + const float BORDER_WIDTH = 4.0f; + + 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; + const unsigned int KEY_L = 46; + const unsigned int KEY_S = 39; + const unsigned int KEY_PLUS = 21; + const unsigned int KEY_MINUS = 20; + + const char* H_ALIGNMENT_STRING_TABLE[] = + { + "BEGIN", + "CENTER", + "END" + }; + + const unsigned int H_ALIGNMENT_STRING_COUNT = sizeof( H_ALIGNMENT_STRING_TABLE ) / sizeof( H_ALIGNMENT_STRING_TABLE[0u] ); + + const char* V_ALIGNMENT_STRING_TABLE[] = + { + "TOP", + "CENTER", + "BOTTOM" + }; + + const unsigned int V_ALIGNMENT_STRING_COUNT = sizeof( V_ALIGNMENT_STRING_TABLE ) / sizeof( V_ALIGNMENT_STRING_TABLE[0u] ); } // unnamed namespace @@ -47,7 +78,9 @@ class TextFieldExample : public ConnectionTracker public: TextFieldExample( Application& application ) - : mApplication( application ) + : mApplication( application ), + mLanguageId( 0u ), + mAlignment( 0u ) { // Connect to the Application's Init signal mApplication.InitSignal().Connect( this, &TextFieldExample::Create ); @@ -67,33 +100,42 @@ public: Stage stage = Stage::GetCurrent(); + mTapGestureDetector = TapGestureDetector::New(); + mTapGestureDetector.Attach( stage.GetRootLayer() ); + mTapGestureDetector.DetectedSignal().Connect( this, &TextFieldExample::OnTap ); + stage.KeyEventSignal().Connect(this, &TextFieldExample::OnKeyEvent); Vector2 stageSize = stage.GetSize(); - mContainer = Control::New(); - mContainer.SetName( "Container" ); - mContainer.SetParentOrigin( ParentOrigin::CENTER ); - mContainer.SetSize( Vector2(stageSize.width*0.6f, stageSize.width*0.6f) ); - mContainer.SetBackgroundImage( ResourceImage::New( BACKGROUND_IMAGE ) ); - mContainer.GetChildAt(0).SetZ(-1.0f); - stage.Add( mContainer ); + Control container = Control::New(); + container.SetName( "Container" ); + container.SetParentOrigin( ParentOrigin::CENTER ); + container.SetSize( Vector2(stageSize.width*0.6f, stageSize.width*0.6f) ); + container.SetBackgroundColor( Color::WHITE ); + container.GetChildAt(0).SetZ(-1.0f); + stage.Add( container ); - TextField field = TextField::New(); - field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - field.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); - field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT ); + mField = TextField::New(); + mField.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + mField.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); + mField.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT ); + mField.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Unnamed folder" ); + mField.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Enter folder name." ); + mField.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect( BORDER_WIDTH, BORDER_WIDTH, stageSize.width - BORDER_WIDTH*2, stageSize.height - BORDER_WIDTH*2 ) ); - mContainer.Add( field ); + container.Add( mField ); - field.SetProperty( TextField::Property::TEXT, "Hello" ); - field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect( BORDER_WIDTH, BORDER_WIDTH, stageSize.width - BORDER_WIDTH*2, stageSize.height - BORDER_WIDTH*2 ) ); - - Property::Value fieldText = field.GetProperty( TextField::Property::TEXT ); + Property::Value fieldText = mField.GetProperty( TextField::Property::TEXT ); std::cout << "Displaying text: " << fieldText.Get< std::string >() << std::endl; } + void OnTap( Actor actor, const TapGesture& tapGesture ) + { + mField.ClearKeyInputFocus(); + } + /** * Main key event handler */ @@ -105,6 +147,73 @@ public: { mApplication.Quit(); } + else if( event.IsCtrlModifier() ) + { + switch( event.keyCode ) + { + // Select rendering back-end + case KEY_ZERO: // fall through + case KEY_ONE: + { + mField.SetProperty( TextField::Property::RENDERING_BACKEND, event.keyCode - 10 ); + break; + } + case KEY_H: // Horizontal alignment + { + if( ++mAlignment >= H_ALIGNMENT_STRING_COUNT ) + { + mAlignment = 0u; + } + + mField.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, H_ALIGNMENT_STRING_TABLE[ mAlignment ] ); + break; + } + case KEY_V: // Vertical alignment + { + if( ++mAlignment >= V_ALIGNMENT_STRING_COUNT ) + { + mAlignment = 0u; + } + + mField.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, V_ALIGNMENT_STRING_TABLE[ mAlignment ] ); + break; + } + case KEY_L: // Language + { + const Language& language = LANGUAGES[ mLanguageId ]; + + mField.SetProperty( TextField::Property::TEXT, language.text ); + + if( ++mLanguageId >= NUMBER_OF_LANGUAGES ) + { + mLanguageId = 0u; + } + break; + } + case KEY_S: // Shadow color + { + if( Color::BLACK == mField.GetProperty( TextField::Property::SHADOW_COLOR ) ) + { + mField.SetProperty( TextField::Property::SHADOW_COLOR, Color::RED ); + } + else + { + mField.SetProperty( TextField::Property::SHADOW_COLOR, Color::BLACK ); + } + break; + } + case KEY_PLUS: // Increase shadow offset + { + mField.SetProperty( TextField::Property::SHADOW_OFFSET, mField.GetProperty( TextField::Property::SHADOW_OFFSET ) + Vector2( 1.0f, 1.0f ) ); + break; + } + case KEY_MINUS: // Decrease shadow offset + { + mField.SetProperty( TextField::Property::SHADOW_OFFSET, mField.GetProperty( TextField::Property::SHADOW_OFFSET ) - Vector2( 1.0f, 1.0f ) ); + break; + } + } + } } } @@ -112,7 +221,12 @@ private: Application& mApplication; - Control mContainer; + TextField mField; + + TapGestureDetector mTapGestureDetector; + + unsigned int mLanguageId; + unsigned int mAlignment; }; void RunTest( Application& application ) diff --git a/examples/text-label-emojis/text-label-emojis.cpp b/examples/text-label-emojis/text-label-emojis.cpp index 3023974..bb1703b 100644 --- a/examples/text-label-emojis/text-label-emojis.cpp +++ b/examples/text-label-emojis/text-label-emojis.cpp @@ -17,7 +17,6 @@ // EXTERNAL INCLUDES #include -#include #include // INTERNAL INCLUDES @@ -56,6 +55,7 @@ public: void Create( Application& application ) { Stage stage = Stage::GetCurrent(); + stage.SetBackgroundColor( Color::WHITE ); stage.KeyEventSignal().Connect(this, &EmojiExample::OnKeyEvent); mTableView = Toolkit::TableView::New( NUMBER_OF_EMOJIS, 1 ); diff --git a/examples/text-label-multi-language/text-label-multi-language-example.cpp b/examples/text-label-multi-language/text-label-multi-language-example.cpp index 78ded00..6c30eb9 100644 --- a/examples/text-label-multi-language/text-label-multi-language-example.cpp +++ b/examples/text-label-multi-language/text-label-multi-language-example.cpp @@ -22,7 +22,6 @@ // EXTERNAL INCLUDES #include -#include // INTERNAL INCLUDES #include "shared/multi-language-strings.h" @@ -62,6 +61,7 @@ public: Stage stage = Stage::GetCurrent(); stage.KeyEventSignal().Connect(this, &TextLabelMultiLanguageExample::OnKeyEvent); + stage.SetBackgroundColor( Color::WHITE ); mTableView = Toolkit::TableView::New( NUMBER_OF_LANGUAGES, 1 ); mTableView.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); diff --git a/examples/text-label/text-label-example.cpp b/examples/text-label/text-label-example.cpp index 4816737..5c1b7b0 100644 --- a/examples/text-label/text-label-example.cpp +++ b/examples/text-label/text-label-example.cpp @@ -22,7 +22,7 @@ // EXTERNAL INCLUDES #include -#include +#include // INTERNAL INCLUDES #include "shared/multi-language-strings.h" @@ -131,9 +131,10 @@ public: mLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); 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( Vector4(0.3f,0.3f,0.6f,1.0f) ); + mLabel.SetBackgroundColor( Color::WHITE ); mContainer.Add( mLabel ); Property::Value labelText = mLabel.GetProperty( TextLabel::Property::TEXT ); diff --git a/examples/text-message-field/text-message-field-example.cpp b/examples/text-message-field/text-message-field-example.cpp index 37eb6a1..d7403c0 100644 --- a/examples/text-message-field/text-message-field-example.cpp +++ b/examples/text-message-field/text-message-field-example.cpp @@ -22,7 +22,6 @@ // EXTERNAL INCLUDES #include -#include using namespace Dali; using namespace Dali::Toolkit; diff --git a/packaging/com.samsung.dali-demo.spec b/packaging/com.samsung.dali-demo.spec index 40d65dc..49866ef 100755 --- a/packaging/com.samsung.dali-demo.spec +++ b/packaging/com.samsung.dali-demo.spec @@ -2,7 +2,7 @@ Name: com.samsung.dali-demo Summary: The OpenGLES Canvas Core Demo -Version: 1.0.39 +Version: 1.0.41 Release: 1 Group: System/Libraries License: Apache-2.0 diff --git a/resources/scripts/navigation.json b/resources/scripts/navigation.json deleted file mode 100644 index d09feac..0000000 --- a/resources/scripts/navigation.json +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ -{ - "stage": [{ - "type": "NavigationControl", - "name": "navigation", - "parent-origin": "CENTER", - "signals": [{ - "name": "on-stage", - "actor": "navigation", - "action": "push", - "parameters": ["page1"] - }], - "actors": [{ - "type": "Page", - "name": "page1", - "title": "title", - "sub-title": "sub title", - "actors": [{ - "type": "TextLabel", // styles can be additive - "parent-origin": [0.5, 0.5, 0], - "anchor-point": [0.5, 0.5, 0], - "size": [200, 200, 1], - "text": "Touch to push new item!", - "signals": [{ - "name": "touched", - "actor": "navigation", - "action": "push", - "parameters": ["page2"] - }] - }] - }, { - "type": "Page", - "name": "page2", - "actors": [{ - "type": "TextLabel", // styles can be additive - "parent-origin": [0.5, 0.5, 0.5], - "anchor-point": [0.5, 0.5, 0.5], - "size": [200, 200, 1], - "text": "Hello World!" - }, { - "type": "TextLabel", // styles can be additive - "parent-origin": [0.0, 0.0, 0.5], - "anchor-point": [0.0, 0.0, 0.5], - "size": [200, 200, 1], - "text": "Back", - "signals": [{ - "name": "touched", - "actor": "navigation", - "action": "pop" - }] - }, { - "type": "TextLabel", // styles can be additive - "parent-origin": [1.0, 1.0, 0.5], - "anchor-point": [1.0, 1.0, 0.5], - "size": [200, 200, 1], - "text": "Quit", - "signals": [{ - "name": "touched", - "action": "quit" - }] - }] - }] - }] -} diff --git a/resources/scripts/shader-effect-ripple.json b/resources/scripts/shader-effect-ripple.json new file mode 100644 index 0000000..82f8d23 --- /dev/null +++ b/resources/scripts/shader-effect-ripple.json @@ -0,0 +1,65 @@ +{ + "stage": [ + { + "type": "ImageActor", + "name": "Image1", + "position": [ + 0.40461349487305, + 0.9150390625, + 0.0 + ], + "parent-origin": [0.5, 0.5, 0.5], + "size": [200, 200, 0], + "effect": "Ripple2D", + "image": { + "filename": "{DALI_IMAGE_DIR}gallery-medium-25.jpg", + "width": 200, + "height": 80, + "load-policy": "IMMEDIATE", + "release-policy": "NEVER" + }, + "signals": [ + { + "name": "on-stage", + "action": "play", + "animation": "Animation_1" + } + ] + } + ], + "paths": {}, + "animations": { + "Animation_1": { + "loop":true, + "properties": [ + { + "actor": "Image1", + "property": "uTime", + "value": 10.0, + "alpha-function": "LINEAR", + "time-period": { + "delay": 0, + "duration": 10.0 + }, + "gui-builder-timeline-color": "#8dc0da" + } + ] + } + }, + "shader-effects": { + "Ripple2D": { + "program": { + "vertexPrefix": "", + "vertex": "void main(void)\n{\n gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\n vTexCoord = aTexCoord;\n}\n\n", + "fragmentPrefix": "", + "fragment": "precision mediump float;\nuniform float uAmplitude; // 0.02; (< 1)\nuniform float uTime;\nvoid main()\n{\n highp vec2 textureSize = sTextureRect.zw - sTextureRect.xy;\n highp vec2 pos = -1.0 + 2.0 * vTexCoord.st/textureSize;\n highp float len = length(pos);\n highp vec2 texCoord = vTexCoord.st/textureSize + pos/len * sin( len * 12.0 - uTime * 4.0 ) * uAmplitude; \n gl_FragColor = texture2D(sTexture, texCoord) * uColor;\n}\n\n\n", + "geometry-type": "GEOMETRY_TYPE_IMAGE" + }, + "geometry-hints": "HINT_NONE", + "grid-density": 0, + "loop": true, + "uAmplitude": 0.02, + "uTime": 0.0 + } + } +} diff --git a/shared/view.h b/shared/view.h index 930511e..44b6663 100644 --- a/shared/view.h +++ b/shared/view.h @@ -46,7 +46,6 @@ const ViewStyle DEFAULT_VIEW_STYLE( 0.1f, 0.7f, 80.f, 4.f ); const char* DEFAULT_TEXT_STYLE_FONT_FAMILY("HelveticaNue"); const char* DEFAULT_TEXT_STYLE_FONT_STYLE("Regular"); const float DEFAULT_TEXT_STYLE_POINT_SIZE( 8.0f ); -const Dali::Vector4 DEFAULT_TEXT_STYLE_COLOR(0.0f, 0.0f, 0.0f, 1.0f); const Dali::Toolkit::Alignment::Padding DEFAULT_PLAY_PADDING(12.0f, 12.0f, 12.0f, 12.0f); const Dali::Toolkit::Alignment::Padding DEFAULT_MODE_SWITCH_PADDING(8.0f, 8.0f, 8.0f, 8.0f); @@ -109,7 +108,6 @@ Dali::Layer CreateToolbar( Dali::Toolkit::ToolBar& toolBar, label.SetProperty( Dali::Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); label.SetProperty( Dali::Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" ); label.SetResizePolicy( Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::HEIGHT ); - label.SetColor( DEFAULT_TEXT_STYLE_COLOR ); // Add title to the tool bar. const float padding( style.mToolBarPadding ); @@ -174,7 +172,6 @@ Dali::Toolkit::TextLabel CreateToolBarLabel( const std::string& text ) label.SetProperty( Dali::Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); label.SetProperty( Dali::Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" ); label.SetResizePolicy( Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::HEIGHT ); - label.SetColor( DEFAULT_TEXT_STYLE_COLOR ); return label; }