From: Adeel Kazmi Date: Wed, 11 Mar 2015 10:09:19 +0000 (+0000) Subject: Show DALi version info when the logo is tapped X-Git-Tag: dali_1.0.33~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=938d6470068c91012e8785047610b7cb8435a178;p=platform%2Fcore%2Fuifw%2Fdali-demo.git Show DALi version info when the logo is tapped Change-Id: I310242f574e549ff412248a56db8e747a4981c43 --- diff --git a/demo/dali-table-view.cpp b/demo/dali-table-view.cpp index 5fa86f2..bb7bc7c 100644 --- a/demo/dali-table-view.cpp +++ b/demo/dali-table-view.cpp @@ -181,11 +181,36 @@ bool CompareByTitle( const Example& lhs, const Example& rhs ) } // namespace DaliTableView::DaliTableView( Application& application ) - : mApplication( application ), - mScrolling( false ), - mBackgroundImagePath( DEFAULT_BACKGROUND_IMAGE_PATH ), - mSortAlphabetically( false ), - mBackgroundAnimsPlaying( false ) +: mApplication( application ), + mBackgroundLayer(), + mRootActor(), + mRotateAnimation(), + mBackground(), + mLogo(), + mPressedAnimation(), + mScrollViewLayer(), + mScrollView(), + mScrollViewEffect(), + mScrollRulerX(), + mScrollRulerY(), + mButtons(), + mPressedActor(), + mAnimationTimer(), + mLogoTapDetector(), + mVersionPopup(), + mButtonsPageRelativeSize(), + mPages(), + mTableViewImages(), + mBackgroundActors(), + mBackgroundAnimations(), + mExampleList(), + mExampleMap(), + mBackgroundImagePath( DEFAULT_BACKGROUND_IMAGE_PATH ), + mTotalPages(), + mScrolling( false ), + mSortAlphabetically( false ), + mBackgroundAnimsPlaying( false ), + mVersionPopupShown( false ) { application.InitSignal().Connect( this, &DaliTableView::Initialize ); } @@ -247,6 +272,11 @@ void DaliTableView::Initialize( Application& application ) const float logoHeight = mLogo.GetImage().GetHeight() + logoMargin; mRootActor.SetFixedHeight( 1, logoHeight ); + // Show version in a popup when log is tapped + mLogoTapDetector = TapGestureDetector::New(); + mLogoTapDetector.Attach( mLogo ); + mLogoTapDetector.DetectedSignal().Connect( this, &DaliTableView::OnLogoTapped ); + const float bottomMargin = paddingHeight * BOTTOM_PADDING_RATIO; mButtonsPageRelativeSize = Vector3( TABLE_RELATIVE_SIZE.x, 1.f - ( toolbarHeight + logoHeight + bottomMargin) / stageSize.height, TABLE_RELATIVE_SIZE.z ); mRootActor.SetFixedHeight( 2, mButtonsPageRelativeSize.y * stageSize.height ); @@ -679,7 +709,14 @@ void DaliTableView::OnKeyEvent( const KeyEvent& event ) { if ( IsKey( event, Dali::DALI_KEY_ESCAPE) || IsKey( event, Dali::DALI_KEY_BACK) ) { - mApplication.Quit(); + if ( mVersionPopup && mVersionPopupShown ) + { + HideVersionPopup(); + } + else + { + mApplication.Quit(); + } } } } @@ -944,3 +981,46 @@ bool DaliTableView::OnTileHovered( Actor actor, const HoverEvent& event ) KeyboardFocusManager::Get().SetCurrentFocusActor( actor ); return true; } + +void DaliTableView::OnLogoTapped( Dali::Actor actor, const Dali::TapGesture& tap ) +{ + if ( !mVersionPopupShown ) + { + if ( !mVersionPopup ) + { + std::ostringstream stream; + stream << "DALi Core: " << CORE_MAJOR_VERSION << "." << CORE_MINOR_VERSION << "." << CORE_MICRO_VERSION << std::endl << "(" << CORE_BUILD_DATE << ")" << std::endl << std::endl; + stream << "DALi Adaptor: " << ADAPTOR_MAJOR_VERSION << "." << ADAPTOR_MINOR_VERSION << "." << ADAPTOR_MICRO_VERSION << std::endl << "(" << ADAPTOR_BUILD_DATE << ")" << std::endl << std::endl; + stream << "DALi Toolkit: " << TOOLKIT_MAJOR_VERSION << "." << TOOLKIT_MINOR_VERSION << "." << TOOLKIT_MICRO_VERSION << std::endl << "(" << TOOLKIT_BUILD_DATE << ")"; + + mVersionPopup = Dali::Toolkit::Popup::New(); + mVersionPopup.SetTitle( stream.str() ); + mVersionPopup.SetParentOrigin( ParentOrigin::CENTER ); + mVersionPopup.SetAnchorPoint( AnchorPoint::CENTER ); + mVersionPopup.HideTail(); + mVersionPopup.OutsideTouchedSignal().Connect( this, &DaliTableView::HideVersionPopup ); + mVersionPopup.HiddenSignal().Connect( this, &DaliTableView::PopupHidden ); + + Dali::Stage::GetCurrent().Add( mVersionPopup ); + } + + mVersionPopup.Show(); + mVersionPopupShown = true; + } +} + +void DaliTableView::HideVersionPopup() +{ + if ( mVersionPopup ) + { + mVersionPopup.Hide(); + } +} + +void DaliTableView::PopupHidden() +{ + if ( mVersionPopup ) + { + mVersionPopupShown = false; + } +} diff --git a/demo/dali-table-view.h b/demo/dali-table-view.h index bc77fba..fbaa2ea 100644 --- a/demo/dali-table-view.h +++ b/demo/dali-table-view.h @@ -360,38 +360,59 @@ private: // Application callbacks & implementation */ void OnFocusedActorActivated( Dali::Actor activatedActor ); + /** + * Called when the logo is tapped + * + * @param[in] actor The tapped actor + * @param[in] tap The tap information. + */ + void OnLogoTapped( Dali::Actor actor, const Dali::TapGesture& tap ); + + /** + * Hides the popup + */ + void HideVersionPopup(); + + /** + * Called when the popup is completely hidden + */ + void PopupHidden(); + private: - Dali::Application& mApplication; ///< Application instance. - Dali::Layer mBackgroundLayer; ///< Background resides on a separate layer. - Dali::Toolkit::TableView mRootActor; ///< All content (excluding background is anchored to this Actor) - Dali::Animation mRotateAnimation; ///< Animation to rotate and resize mRootActor. - Dali::ImageActor mBackground; ///< Background's static image. - Dali::ImageActor mLogo; ///< Logo's static image. - Dali::Animation mPressedAnimation; ///< Button press scaling animation. - Dali::Layer mScrollViewLayer; ///< ScrollView resides on a separate layer. - Dali::Toolkit::ScrollView mScrollView; ///< ScrollView container (for all Examples) - Dali::Toolkit::ScrollViewEffect mScrollViewEffect; ///< Effect to be applied to the scroll view - bool mScrolling; ///< Flag indicating whether view is currently being scrolled - Dali::Toolkit::RulerPtr mScrollRulerX; ///< ScrollView X (horizontal) ruler - Dali::Toolkit::RulerPtr mScrollRulerY; ///< ScrollView Y (vertical) ruler - Dali::Toolkit::TableView mButtons; ///< Navigation buttons - ExampleList mExampleList; ///< List of examples. - ExampleMap mExampleMap; ///< Map LUT for examples. - Dali::ActorContainer mPages; ///< List of pages. - Dali::Actor mPressedActor; ///< The currently pressed actor. - int mTotalPages; ///< Total pages within scrollview. - std::string mBackgroundImagePath; ///< The path to the background image. - bool mSortAlphabetically; ///< Sort examples alphabetically. - - Dali::ActorContainer mTableViewImages; ///< Offscreen render of tableview - Dali::ActorContainer mBackgroundActors; ///< List of background actors used in the effect - - AnimationList mBackgroundAnimations;///< List of background bubble animations - Dali::Timer mAnimationTimer; ///< Timer used to turn off animation after a specific time period - bool mBackgroundAnimsPlaying; ///< Are background animations playing - - Dali::Vector3 mButtonsPageRelativeSize; ///< Size of a buttons page relative to the stage size + Dali::Application& mApplication; ///< Application instance. + Dali::Layer mBackgroundLayer; ///< Background resides on a separate layer. + Dali::Toolkit::TableView mRootActor; ///< All content (excluding background is anchored to this Actor) + Dali::Animation mRotateAnimation; ///< Animation to rotate and resize mRootActor. + Dali::ImageActor mBackground; ///< Background's static image. + Dali::ImageActor mLogo; ///< Logo's static image. + Dali::Animation mPressedAnimation; ///< Button press scaling animation. + Dali::Layer mScrollViewLayer; ///< ScrollView resides on a separate layer. + Dali::Toolkit::ScrollView mScrollView; ///< ScrollView container (for all Examples) + Dali::Toolkit::ScrollViewEffect mScrollViewEffect; ///< Effect to be applied to the scroll view + Dali::Toolkit::RulerPtr mScrollRulerX; ///< ScrollView X (horizontal) ruler + Dali::Toolkit::RulerPtr mScrollRulerY; ///< ScrollView Y (vertical) ruler + Dali::Toolkit::TableView mButtons; ///< Navigation buttons + Dali::Actor mPressedActor; ///< The currently pressed actor. + Dali::Timer mAnimationTimer; ///< Timer used to turn off animation after a specific time period + Dali::TapGestureDetector mLogoTapDetector; ///< To detect taps on the logo + 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 + AnimationList mBackgroundAnimations; ///< List of background bubble animations + ExampleList mExampleList; ///< List of examples. + ExampleMap mExampleMap; ///< Map LUT for examples. + + std::string mBackgroundImagePath; ///< The path to the background image. + int mTotalPages; ///< Total pages within scrollview. + + bool mScrolling:1; ///< Flag indicating whether view is currently being scrolled + bool mSortAlphabetically:1; ///< Sort examples alphabetically. + bool mBackgroundAnimsPlaying:1; ///< Are background animations playing + bool mVersionPopupShown:1; ///< Whehter the version popup is shown or not }; #endif // __DALI_DEMO_H__