diff --git a/com.samsung.dali-demo.xml b/com.samsung.dali-demo.xml index 8a205b4..1705678 100644 --- a/com.samsung.dali-demo.xml +++ b/com.samsung.dali-demo.xml @@ -194,4 +194,7 @@ + + + diff --git a/examples-reel/dali-examples-reel.cpp b/examples-reel/dali-examples-reel.cpp index 6dc8f5b..2995ea8 100644 --- a/examples-reel/dali-examples-reel.cpp +++ b/examples-reel/dali-examples-reel.cpp @@ -59,6 +59,7 @@ int DALI_EXPORT_API main(int argc, char **argv) demo.AddExample(Example("motion-stretch.example", DALI_DEMO_STR_TITLE_MOTION_STRETCH)); demo.AddExample(Example("native-image-source.example", DALI_DEMO_STR_TITLE_NATIVE_IMAGE_SOURCE)); demo.AddExample(Example("popup.example", DALI_DEMO_STR_TITLE_POPUP)); + demo.AddExample(Example("pivot.example", DALI_DEMO_STR_TITLE_PIVOT)); demo.AddExample(Example("primitive-shapes.example", DALI_DEMO_STR_TITLE_PRIMITIVE_SHAPES)); demo.AddExample(Example("progress-bar.example", DALI_DEMO_STR_TITLE_PROGRESS_BAR)); demo.AddExample(Example("rendering-line.example", DALI_DEMO_STR_TITLE_RENDERING_DRAW_LINE)); diff --git a/examples/pivot/pivot-example.cpp b/examples/pivot/pivot-example.cpp new file mode 100644 index 0000000..9ea5f47 --- /dev/null +++ b/examples/pivot/pivot-example.cpp @@ -0,0 +1,159 @@ +/* + * 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. + * 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. + * + */ + +#include +#include + +#include + +using namespace Dali; +using namespace Dali::Toolkit; + +namespace +{ +const int TABLE_VIEW_ROWS = 5; +const int TABLE_VIEW_COLUMNS = 3; +const Vector3 TABLE_VIEW_SIZE_MODE_FACTOR( 0.6f, 0.6f, 1.0f ); + +const Quaternion ANIMATION_ROTATION( Degree( 360.0f), Vector3::ZAXIS ); +const AlphaFunction::BuiltinFunction ROTATION_ANIMATION_ALPHA_FUNCTION( AlphaFunction::EASE_IN_OUT ); +const TimePeriod ROTATION_ANIMATION_TIME_PERIOD( 0.0f, 0.5f ); + +const Vector3 ANIMATION_SCALE( 2.0f, 2.0f, 1.0f ); +const AlphaFunction::BuiltinFunction SCALE_ANIMATION_ALPHA_FUNCTION( AlphaFunction::SIN ); +const TimePeriod SCALE_ANIMATION_TIME_PERIOD( 0.15f, 0.85f ); +} // unnamed namespace + +/** + * @brief Demonstrates how to animate a control in a layout-container using the anchor point as the pivot. + * + * Positions of the controls in the layout-container will be set using the top-left of the control. + */ +class PivotController : public ConnectionTracker +{ +public: + + /** + * @brief Constructor. + * @param[in] application Reference to the application instance. + */ + PivotController( Application& application ) + : mApplication( application ) + { + mApplication.InitSignal().Connect( this, &PivotController::Create ); + } + +private: + + /** + * @brief The Init signal is received once (only) during the Application lifetime. + */ + void Create( Application& /* application */ ) + { + // Get a handle to the stage + Stage stage = Stage::GetCurrent(); + stage.SetBackgroundColor( Color::WHITE ); + stage.KeyEventSignal().Connect( this, &PivotController::OnKeyEvent ); + + // Create a table view. + TableView tableView = TableView::New( TABLE_VIEW_ROWS, TABLE_VIEW_COLUMNS ); + tableView.SetAnchorPoint( AnchorPoint::CENTER ); + tableView.SetParentOrigin( ParentOrigin::CENTER ); + tableView.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); + tableView.SetSizeModeFactor( TABLE_VIEW_SIZE_MODE_FACTOR ); + stage.Add( tableView ); + + // Create a tap detector - we are going to rotate an actor round our anchor-point (pivot) when one of our controls is tapped. + mTapDetector = TapGestureDetector::New(); + mTapDetector.DetectedSignal().Connect( this, &PivotController::OnTap ); + + Vector3 anchorPoint( AnchorPoint::CENTER ); // This will be changed depending on the row and column. + + // Add controls to the table-view - each control will have a random color. + for( int row = 0; row < TABLE_VIEW_ROWS; ++row ) + { + anchorPoint.y = ( row % TABLE_VIEW_ROWS ) * ( 1.0f / ( TABLE_VIEW_ROWS - 1 ) ); // Calculate this row's y anchor-point. + + for( int column = 0; column < TABLE_VIEW_COLUMNS; ++column ) + { + anchorPoint.x = ( column % TABLE_VIEW_COLUMNS ) * ( 1.0f / ( TABLE_VIEW_COLUMNS - 1 ) ); // Calculate this column's x anchor-point. + + // Create a control with a randomly chosen background color. + Control control = Control::New(); + control.SetBackgroundColor( Vector4( Random::Range( 0.0f, 1.0f ), Random::Range( 0.0f, 1.0f ), Random::Range( 0.0f, 1.0f ), 1.0f ) ); + control.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); + control.SetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT, false ); // Ensures the position always uses top-left for its calculations. + control.SetAnchorPoint( anchorPoint ); // This anchor-point is used for the rotation and the scale. + + // Add to the table-view + tableView.AddChild( control, TableView::CellPosition( row, column ) ); + + // Attach each control to the tap-detector so we can start the animation around our anchor point. + mTapDetector.Attach( control ); + } + } + } + + /** + * @brief Called when a control is tapped. + * + * Here we will start an animation around our pivot. + */ + void OnTap( Actor actor, const TapGesture& /* tap */ ) + { + // Raise the actor to the top. + DevelActor::RaiseToTop( actor ); + + // Create the animation to rotate and scale our actor. + Animation animation = Animation::New( 1.0f ); + animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), ANIMATION_ROTATION, ROTATION_ANIMATION_ALPHA_FUNCTION, ROTATION_ANIMATION_TIME_PERIOD ); + animation.AnimateTo( Property( actor, Actor::Property::SCALE ), ANIMATION_SCALE, SCALE_ANIMATION_ALPHA_FUNCTION, SCALE_ANIMATION_TIME_PERIOD ); + + // Play the animation. + animation.Play(); + } + + /** + * @brief Called when any key event is received + * + * Will use this to quit the application if Back or the Escape key is received + * @param[in] event The key event information + */ + void OnKeyEvent( const KeyEvent& event ) + { + if( event.state == KeyEvent::Down ) + { + if ( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) ) + { + mApplication.Quit(); + } + } + } + +private: + + Application& mApplication; ///< Reference to the Application instance. + TapGestureDetector mTapDetector; ///< Used for animating the tapped control. +}; + +int DALI_EXPORT_API main( int argc, char **argv ) +{ + Application application = Application::New( &argc, &argv ); + PivotController test( application ); + application.MainLoop(); + return 0; +} diff --git a/examples/video-view/video-view-example.cpp b/examples/video-view/video-view-example.cpp index 371c7a5..b13df4e 100644 --- a/examples/video-view/video-view-example.cpp +++ b/examples/video-view/video-view-example.cpp @@ -143,13 +143,13 @@ class VideoViewController: public ConnectionTracker mMenu.Add( mForwardButton ); mPauseButton.SetVisible( false ); - mPauseButton.SetDisabled( true ); + mPauseButton.SetProperty( Button::Property::DISABLED, true ); mPlayButton.SetVisible( true ); - mPlayButton.SetDisabled( false ); + mPlayButton.SetProperty( Button::Property::DISABLED, false ); mStopButton.SetVisible( true ); - mStopButton.SetDisabled( false ); + mStopButton.SetProperty( Button::Property::DISABLED, false ); mResetButton.SetVisible( false ); - mResetButton.SetDisabled( true ); + mResetButton.SetProperty( Button::Property::DISABLED, true ); mPlayButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, PLAY_IMAGE ); mPlayButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, PLAY_IMAGE ); @@ -198,9 +198,9 @@ class VideoViewController: public ConnectionTracker if( mIsPlay ) { mPauseButton.SetVisible( false ); - mPauseButton.SetDisabled( true ); + mPauseButton.SetProperty( Button::Property::DISABLED, true ); mPlayButton.SetVisible( true ); - mPlayButton.SetDisabled( false ); + mPlayButton.SetProperty( Button::Property::DISABLED, false ); mIsPlay = false; mVideoView.Pause(); @@ -214,9 +214,9 @@ class VideoViewController: public ConnectionTracker } mPauseButton.SetVisible( true ); - mPauseButton.SetDisabled( false ); + mPauseButton.SetProperty( Button::Property::DISABLED, false ); mPlayButton.SetVisible( false ); - mPlayButton.SetDisabled( true ); + mPlayButton.SetProperty( Button::Property::DISABLED, true ); mIsPlay = true; mVideoView.Play(); @@ -226,13 +226,13 @@ class VideoViewController: public ConnectionTracker if( mIsStop ) { mPauseButton.SetVisible( true ); - mPauseButton.SetDisabled( false ); + mPauseButton.SetProperty( Button::Property::DISABLED, false ); mPlayButton.SetVisible( false ); - mPlayButton.SetDisabled( true ); + mPlayButton.SetProperty( Button::Property::DISABLED, true ); mResetButton.SetVisible( false ); - mResetButton.SetDisabled( true ); + mResetButton.SetProperty( Button::Property::DISABLED, true ); mStopButton.SetVisible( true ); - mStopButton.SetDisabled( false ); + mStopButton.SetProperty( Button::Property::DISABLED, false ); mIsStop = false; mIsPlay = true; @@ -243,13 +243,13 @@ class VideoViewController: public ConnectionTracker else if( mStopButton.GetId() == button.GetId()) { mPauseButton.SetVisible( false ); - mPauseButton.SetDisabled( true ); + mPauseButton.SetProperty( Button::Property::DISABLED, true ); mPlayButton.SetVisible( true ); - mPlayButton.SetDisabled( false ); + mPlayButton.SetProperty( Button::Property::DISABLED, false ); mResetButton.SetVisible( true ); - mResetButton.SetDisabled( false ); + mPlayButton.SetProperty( Button::Property::DISABLED, false ); mStopButton.SetVisible( false ); - mStopButton.SetDisabled( true ); + mStopButton.SetProperty( Button::Property::DISABLED, true ); mIsStop = true; mVideoView.Stop(); diff --git a/examples/visual-transitions/transition-application.cpp b/examples/visual-transitions/transition-application.cpp index fcb7c00..7094d14 100644 --- a/examples/visual-transitions/transition-application.cpp +++ b/examples/visual-transitions/transition-application.cpp @@ -35,6 +35,16 @@ using namespace Dali; using namespace Dali::Toolkit; +namespace +{ + +void SetLabelText( Button button, const char* label ) +{ + button.SetProperty( Toolkit::Button::Property::LABEL, label ); +} + +} + namespace Demo { @@ -43,7 +53,6 @@ const char* DALI_LOGO_PATH( DEMO_IMAGE_DIR "Logo-for-demo.png" ); const char* DALI_ROBOT_MODEL_PATH( DEMO_MODEL_DIR "ToyRobot-Metal.obj" ); const char* DALI_ROBOT_MATERIAL_PATH( DEMO_MODEL_DIR "ToyRobot-Metal.mtl" ); - TransitionApplication::TransitionApplication( Application& application ) : mApplication( application ), mTitle(), @@ -151,10 +160,11 @@ void TransitionApplication::Create( Application& application ) mActionButtons[i].ClickedSignal().Connect( this, &TransitionApplication::OnActionButtonClicked ); actionButtonLayout.AddChild( mActionButtons[i], TableView::CellPosition( 0, 1+i ) ); } - mActionButtons[0].SetLabelText( "Bounce" ); - mActionButtons[1].SetLabelText( "X" ); - mActionButtons[2].SetLabelText( "Y" ); - mActionButtons[3].SetLabelText( "Fade" ); + + SetLabelText( mActionButtons[0], "Bounce" ); + SetLabelText( mActionButtons[1], "X" ); + SetLabelText( mActionButtons[2], "Y" ); + SetLabelText( mActionButtons[3], "Fade" ); contentLayout.Add( actionButtonLayout ); contentLayout.SetFitHeight(3); diff --git a/packaging/com.samsung.dali-demo.spec b/packaging/com.samsung.dali-demo.spec index ac29ff8..1e3003c 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.2.29 +Version: 1.2.30 Release: 1 Group: System/Libraries License: Apache-2.0 diff --git a/resources/po/en_GB.po b/resources/po/en_GB.po index 9c43823..6ab4531 100755 --- a/resources/po/en_GB.po +++ b/resources/po/en_GB.po @@ -94,6 +94,9 @@ msgstr "Negotiate Size" msgid "DALI_DEMO_STR_TITLE_POPUP" msgstr "Popup" +msgid "DALI_DEMO_STR_TITLE_PIVOT" +msgstr "Pivot" + msgid "DALI_DEMO_STR_TITLE_PROGRESS_BAR" msgstr "Progress Bar" diff --git a/resources/po/en_US.po b/resources/po/en_US.po index 30cedc6..bdf64d4 100755 --- a/resources/po/en_US.po +++ b/resources/po/en_US.po @@ -94,6 +94,9 @@ msgstr "Negotiate Size" msgid "DALI_DEMO_STR_TITLE_POPUP" msgstr "Popup" +msgid "DALI_DEMO_STR_TITLE_PIVOT" +msgstr "Pivot" + msgid "DALI_DEMO_STR_TITLE_PROGRESS_BAR" msgstr "Progress Bar" diff --git a/resources/style/mobile/style-example-theme-one.json.in b/resources/style/mobile/style-example-theme-one.json.in index 53bbcde..67ade2d 100644 --- a/resources/style/mobile/style-example-theme-one.json.in +++ b/resources/style/mobile/style-example-theme-one.json.in @@ -125,19 +125,21 @@ { "backgroundVisual":{ "visualType":"IMAGE", - "url":"{STYLE_DIR}/images/shadowButtonBg.9.png" + "url":"{STYLE_DIR}/images/shadowButtonBg.9.png", + "depthIndex":0 }, "checkboxBgVisual":{ "visualType":"IMAGE", "url":"{STYLE_DIR}/images/CheckBg.png", "transform":{ - "size":[0.09, 0.28], + "size":[0.12, 0.37], "offset":[30,0], "offsetSizeMode":[1,1,0,0], "origin":"CENTER_BEGIN", "anchorPoint":"CENTER_BEGIN" - } + }, + "depthIndex":1 }, "labelVisual":{ @@ -147,14 +149,15 @@ "horizontalAlignment":"END", "verticalAlignment":"CENTER", "textColor":[1,1,1,1], - "mixColor":[0, 0, 0, 1], + "mixColor":[0,0,0,1], "transform":{ "size":[0.9, 0.9], "offset":[-30,0], "offsetSizeMode":[1,1,0,0], "origin":"CENTER_END", "anchorPoint":"CENTER_END" - } + }, + "depthIndex":1 } }, @@ -168,12 +171,13 @@ "visualType":"IMAGE", "url":"{STYLE_DIR}/images/Tick.png", "transform":{ - "size":[0.09, 0.28], + "size":[0.12, 0.37], "offset":[30,0], "offsetSizeMode":[1,1,0,0], "origin":"CENTER_BEGIN", "anchorPoint":"CENTER_BEGIN" - } + }, + "depthIndex":2 } }, "entryTransition": @@ -261,7 +265,8 @@ "offsetSizeMode":[1,1,0,0], "origin":"CENTER_BEGIN", "anchorPoint":"CENTER_BEGIN" - } + }, + "depthIndex":0 }, "checkboxFgVisual":{ @@ -273,7 +278,8 @@ "offsetSizeMode":[1,1,0,0], "origin":"CENTER_BEGIN", "anchorPoint":"CENTER_BEGIN" - } + }, + "depthIndex":1 }, "labelVisual":{ @@ -290,7 +296,32 @@ "offsetSizeMode":[1,1,0,0], "origin":"CENTER_END", "anchorPoint":"CENTER_END" + }, + "depthIndex":1 + } + }, + "states": + { + "CHECKED": + { + "visuals": + { + "checkboxFgVisual":{ + "visualType":"IMAGE", + "url":"{STYLE_DIR}/images/Tick.png", + "transform":{ + "size":[0.09, 0.28], + "offset":[30,0], + "offsetSizeMode":[1,1,0,0], + "origin":"CENTER_BEGIN", + "anchorPoint":"CENTER_BEGIN" + }, + "depthIndex":2 + } } + }, + "UNCHECKED": + { } } } @@ -312,6 +343,7 @@ "from":"DISABLED", "to":"NORMAL", "visualName":"*", + "effect":"CROSSFADE", "animator": { "alphaFunction":"EASE_OUT_BACK", @@ -333,6 +365,7 @@ "from":"NORMAL", "to":"DISABLED", "visualName":"*", + "effect":"CROSSFADE", "animator": { "alphaFunction":"EASE_OUT_BACK", diff --git a/resources/style/style-example-theme-one.json.in b/resources/style/style-example-theme-one.json.in index d495a3d..eb10fa3 100644 --- a/resources/style/style-example-theme-one.json.in +++ b/resources/style/style-example-theme-one.json.in @@ -125,19 +125,21 @@ { "backgroundVisual":{ "visualType":"IMAGE", - "url":"{STYLE_DIR}/images/shadowButtonBg.9.png" + "url":"{STYLE_DIR}/images/shadowButtonBg.9.png", + "depthIndex":0 }, "checkboxBgVisual":{ "visualType":"IMAGE", "url":"{STYLE_DIR}/images/CheckBg.png", "transform":{ - "size":[0.09, 0.28], + "size":[0.12, 0.37], "offset":[30,0], "offsetSizeMode":[1,1,0,0], "origin":"CENTER_BEGIN", "anchorPoint":"CENTER_BEGIN" - } + }, + "depthIndex":1 }, "labelVisual":{ @@ -147,14 +149,15 @@ "horizontalAlignment":"END", "verticalAlignment":"CENTER", "textColor":[1,1,1,1], - "mixColor":[0, 0, 0, 1], + "mixColor":[0,0,0,1], "transform":{ "size":[0.9, 0.9], "offset":[-30,0], "offsetSizeMode":[1,1,0,0], "origin":"CENTER_END", "anchorPoint":"CENTER_END" - } + }, + "depthIndex":1 } }, @@ -168,12 +171,13 @@ "visualType":"IMAGE", "url":"{STYLE_DIR}/images/Tick.png", "transform":{ - "size":[0.09, 0.28], + "size":[0.12, 0.37], "offset":[30,0], "offsetSizeMode":[1,1,0,0], "origin":"CENTER_BEGIN", "anchorPoint":"CENTER_BEGIN" - } + }, + "depthIndex":2 } }, "entryTransition": @@ -261,7 +265,8 @@ "offsetSizeMode":[1,1,0,0], "origin":"CENTER_BEGIN", "anchorPoint":"CENTER_BEGIN" - } + }, + "depthIndex":0 }, "checkboxFgVisual":{ @@ -273,7 +278,8 @@ "offsetSizeMode":[1,1,0,0], "origin":"CENTER_BEGIN", "anchorPoint":"CENTER_BEGIN" - } + }, + "depthIndex":1 }, "labelVisual":{ @@ -290,7 +296,32 @@ "offsetSizeMode":[1,1,0,0], "origin":"CENTER_END", "anchorPoint":"CENTER_END" + }, + "depthIndex":1 + } + }, + "states": + { + "CHECKED": + { + "visuals": + { + "checkboxFgVisual":{ + "visualType":"IMAGE", + "url":"{STYLE_DIR}/images/Tick.png", + "transform":{ + "size":[0.09, 0.28], + "offset":[30,0], + "offsetSizeMode":[1,1,0,0], + "origin":"CENTER_BEGIN", + "anchorPoint":"CENTER_BEGIN" + }, + "depthIndex":2 + } } + }, + "UNCHECKED": + { } } } @@ -312,6 +343,7 @@ "from":"DISABLED", "to":"NORMAL", "visualName":"*", + "effect":"CROSSFADE", "animator": { "alphaFunction":"EASE_OUT_BACK", @@ -333,6 +365,7 @@ "from":"NORMAL", "to":"DISABLED", "visualName":"*", + "effect":"CROSSFADE", "animator": { "alphaFunction":"EASE_OUT_BACK", diff --git a/shared/dali-demo-strings.h b/shared/dali-demo-strings.h index e8f490e..11be2f6 100644 --- a/shared/dali-demo-strings.h +++ b/shared/dali-demo-strings.h @@ -65,6 +65,7 @@ extern "C" #define DALI_DEMO_STR_TITLE_NATIVE_IMAGE_SOURCE dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_NATIVE_IMAGE_SOURCE") #define DALI_DEMO_STR_TITLE_NEGOTIATE_SIZE dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_NEGOTIATE_SIZE") #define DALI_DEMO_STR_TITLE_POPUP dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_POPUP") +#define DALI_DEMO_STR_TITLE_PIVOT dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_PIVOT") #define DALI_DEMO_STR_TITLE_PRIMITIVE_SHAPES dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_PRIMITIVE_SHAPES") #define DALI_DEMO_STR_TITLE_PROGRESS_BAR dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_PROGRESS_BAR") #define DALI_DEMO_STR_TITLE_RENDERING_DRAW_LINE dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_RENDERING_DRAW_LINE") @@ -123,6 +124,7 @@ extern "C" #define DALI_DEMO_STR_TITLE_NATIVE_IMAGE_SOURCE "Native Image Source" #define DALI_DEMO_STR_TITLE_NEGOTIATE_SIZE "Negotiate Size" #define DALI_DEMO_STR_TITLE_POPUP "Popup" +#define DALI_DEMO_STR_TITLE_PIVOT "Pivot" #define DALI_DEMO_STR_TITLE_PRIMITIVE_SHAPES "Primitive Shapes" #define DALI_DEMO_STR_TITLE_PROGRESS_BAR "Progress Bar" #define DALI_DEMO_STR_TITLE_RENDERING_DRAW_LINE "Draw Line"