Commit 938d6470068c91012e8785047610b7cb8435a178

Authored by Adeel Kazmi
1 parent 3f600edd

Show DALi version info when the logo is tapped

Change-Id: I310242f574e549ff412248a56db8e747a4981c43
demo/dali-table-view.cpp
... ... @@ -181,11 +181,36 @@ bool CompareByTitle( const Example& lhs, const Example& rhs )
181 181 } // namespace
182 182  
183 183 DaliTableView::DaliTableView( Application& application )
184   - : mApplication( application ),
185   - mScrolling( false ),
186   - mBackgroundImagePath( DEFAULT_BACKGROUND_IMAGE_PATH ),
187   - mSortAlphabetically( false ),
188   - mBackgroundAnimsPlaying( false )
  184 +: mApplication( application ),
  185 + mBackgroundLayer(),
  186 + mRootActor(),
  187 + mRotateAnimation(),
  188 + mBackground(),
  189 + mLogo(),
  190 + mPressedAnimation(),
  191 + mScrollViewLayer(),
  192 + mScrollView(),
  193 + mScrollViewEffect(),
  194 + mScrollRulerX(),
  195 + mScrollRulerY(),
  196 + mButtons(),
  197 + mPressedActor(),
  198 + mAnimationTimer(),
  199 + mLogoTapDetector(),
  200 + mVersionPopup(),
  201 + mButtonsPageRelativeSize(),
  202 + mPages(),
  203 + mTableViewImages(),
  204 + mBackgroundActors(),
  205 + mBackgroundAnimations(),
  206 + mExampleList(),
  207 + mExampleMap(),
  208 + mBackgroundImagePath( DEFAULT_BACKGROUND_IMAGE_PATH ),
  209 + mTotalPages(),
  210 + mScrolling( false ),
  211 + mSortAlphabetically( false ),
  212 + mBackgroundAnimsPlaying( false ),
  213 + mVersionPopupShown( false )
189 214 {
190 215 application.InitSignal().Connect( this, &DaliTableView::Initialize );
191 216 }
... ... @@ -247,6 +272,11 @@ void DaliTableView::Initialize( Application& application )
247 272 const float logoHeight = mLogo.GetImage().GetHeight() + logoMargin;
248 273 mRootActor.SetFixedHeight( 1, logoHeight );
249 274  
  275 + // Show version in a popup when log is tapped
  276 + mLogoTapDetector = TapGestureDetector::New();
  277 + mLogoTapDetector.Attach( mLogo );
  278 + mLogoTapDetector.DetectedSignal().Connect( this, &DaliTableView::OnLogoTapped );
  279 +
250 280 const float bottomMargin = paddingHeight * BOTTOM_PADDING_RATIO;
251 281 mButtonsPageRelativeSize = Vector3( TABLE_RELATIVE_SIZE.x, 1.f - ( toolbarHeight + logoHeight + bottomMargin) / stageSize.height, TABLE_RELATIVE_SIZE.z );
252 282 mRootActor.SetFixedHeight( 2, mButtonsPageRelativeSize.y * stageSize.height );
... ... @@ -679,7 +709,14 @@ void DaliTableView::OnKeyEvent( const KeyEvent& event )
679 709 {
680 710 if ( IsKey( event, Dali::DALI_KEY_ESCAPE) || IsKey( event, Dali::DALI_KEY_BACK) )
681 711 {
682   - mApplication.Quit();
  712 + if ( mVersionPopup && mVersionPopupShown )
  713 + {
  714 + HideVersionPopup();
  715 + }
  716 + else
  717 + {
  718 + mApplication.Quit();
  719 + }
683 720 }
684 721 }
685 722 }
... ... @@ -944,3 +981,46 @@ bool DaliTableView::OnTileHovered( Actor actor, const HoverEvent& event )
944 981 KeyboardFocusManager::Get().SetCurrentFocusActor( actor );
945 982 return true;
946 983 }
  984 +
  985 +void DaliTableView::OnLogoTapped( Dali::Actor actor, const Dali::TapGesture& tap )
  986 +{
  987 + if ( !mVersionPopupShown )
  988 + {
  989 + if ( !mVersionPopup )
  990 + {
  991 + std::ostringstream stream;
  992 + stream << "DALi Core: " << CORE_MAJOR_VERSION << "." << CORE_MINOR_VERSION << "." << CORE_MICRO_VERSION << std::endl << "(" << CORE_BUILD_DATE << ")" << std::endl << std::endl;
  993 + stream << "DALi Adaptor: " << ADAPTOR_MAJOR_VERSION << "." << ADAPTOR_MINOR_VERSION << "." << ADAPTOR_MICRO_VERSION << std::endl << "(" << ADAPTOR_BUILD_DATE << ")" << std::endl << std::endl;
  994 + stream << "DALi Toolkit: " << TOOLKIT_MAJOR_VERSION << "." << TOOLKIT_MINOR_VERSION << "." << TOOLKIT_MICRO_VERSION << std::endl << "(" << TOOLKIT_BUILD_DATE << ")";
  995 +
  996 + mVersionPopup = Dali::Toolkit::Popup::New();
  997 + mVersionPopup.SetTitle( stream.str() );
  998 + mVersionPopup.SetParentOrigin( ParentOrigin::CENTER );
  999 + mVersionPopup.SetAnchorPoint( AnchorPoint::CENTER );
  1000 + mVersionPopup.HideTail();
  1001 + mVersionPopup.OutsideTouchedSignal().Connect( this, &DaliTableView::HideVersionPopup );
  1002 + mVersionPopup.HiddenSignal().Connect( this, &DaliTableView::PopupHidden );
  1003 +
  1004 + Dali::Stage::GetCurrent().Add( mVersionPopup );
  1005 + }
  1006 +
  1007 + mVersionPopup.Show();
  1008 + mVersionPopupShown = true;
  1009 + }
  1010 +}
  1011 +
  1012 +void DaliTableView::HideVersionPopup()
  1013 +{
  1014 + if ( mVersionPopup )
  1015 + {
  1016 + mVersionPopup.Hide();
  1017 + }
  1018 +}
  1019 +
  1020 +void DaliTableView::PopupHidden()
  1021 +{
  1022 + if ( mVersionPopup )
  1023 + {
  1024 + mVersionPopupShown = false;
  1025 + }
  1026 +}
... ...
demo/dali-table-view.h
... ... @@ -360,38 +360,59 @@ private: // Application callbacks &amp; implementation
360 360 */
361 361 void OnFocusedActorActivated( Dali::Actor activatedActor );
362 362  
  363 + /**
  364 + * Called when the logo is tapped
  365 + *
  366 + * @param[in] actor The tapped actor
  367 + * @param[in] tap The tap information.
  368 + */
  369 + void OnLogoTapped( Dali::Actor actor, const Dali::TapGesture& tap );
  370 +
  371 + /**
  372 + * Hides the popup
  373 + */
  374 + void HideVersionPopup();
  375 +
  376 + /**
  377 + * Called when the popup is completely hidden
  378 + */
  379 + void PopupHidden();
  380 +
363 381 private:
364 382  
365   - Dali::Application& mApplication; ///< Application instance.
366   - Dali::Layer mBackgroundLayer; ///< Background resides on a separate layer.
367   - Dali::Toolkit::TableView mRootActor; ///< All content (excluding background is anchored to this Actor)
368   - Dali::Animation mRotateAnimation; ///< Animation to rotate and resize mRootActor.
369   - Dali::ImageActor mBackground; ///< Background's static image.
370   - Dali::ImageActor mLogo; ///< Logo's static image.
371   - Dali::Animation mPressedAnimation; ///< Button press scaling animation.
372   - Dali::Layer mScrollViewLayer; ///< ScrollView resides on a separate layer.
373   - Dali::Toolkit::ScrollView mScrollView; ///< ScrollView container (for all Examples)
374   - Dali::Toolkit::ScrollViewEffect mScrollViewEffect; ///< Effect to be applied to the scroll view
375   - bool mScrolling; ///< Flag indicating whether view is currently being scrolled
376   - Dali::Toolkit::RulerPtr mScrollRulerX; ///< ScrollView X (horizontal) ruler
377   - Dali::Toolkit::RulerPtr mScrollRulerY; ///< ScrollView Y (vertical) ruler
378   - Dali::Toolkit::TableView mButtons; ///< Navigation buttons
379   - ExampleList mExampleList; ///< List of examples.
380   - ExampleMap mExampleMap; ///< Map LUT for examples.
381   - Dali::ActorContainer mPages; ///< List of pages.
382   - Dali::Actor mPressedActor; ///< The currently pressed actor.
383   - int mTotalPages; ///< Total pages within scrollview.
384   - std::string mBackgroundImagePath; ///< The path to the background image.
385   - bool mSortAlphabetically; ///< Sort examples alphabetically.
386   -
387   - Dali::ActorContainer mTableViewImages; ///< Offscreen render of tableview
388   - Dali::ActorContainer mBackgroundActors; ///< List of background actors used in the effect
389   -
390   - AnimationList mBackgroundAnimations;///< List of background bubble animations
391   - Dali::Timer mAnimationTimer; ///< Timer used to turn off animation after a specific time period
392   - bool mBackgroundAnimsPlaying; ///< Are background animations playing
393   -
394   - Dali::Vector3 mButtonsPageRelativeSize; ///< Size of a buttons page relative to the stage size
  383 + Dali::Application& mApplication; ///< Application instance.
  384 + Dali::Layer mBackgroundLayer; ///< Background resides on a separate layer.
  385 + Dali::Toolkit::TableView mRootActor; ///< All content (excluding background is anchored to this Actor)
  386 + Dali::Animation mRotateAnimation; ///< Animation to rotate and resize mRootActor.
  387 + Dali::ImageActor mBackground; ///< Background's static image.
  388 + Dali::ImageActor mLogo; ///< Logo's static image.
  389 + Dali::Animation mPressedAnimation; ///< Button press scaling animation.
  390 + Dali::Layer mScrollViewLayer; ///< ScrollView resides on a separate layer.
  391 + Dali::Toolkit::ScrollView mScrollView; ///< ScrollView container (for all Examples)
  392 + Dali::Toolkit::ScrollViewEffect mScrollViewEffect; ///< Effect to be applied to the scroll view
  393 + Dali::Toolkit::RulerPtr mScrollRulerX; ///< ScrollView X (horizontal) ruler
  394 + Dali::Toolkit::RulerPtr mScrollRulerY; ///< ScrollView Y (vertical) ruler
  395 + Dali::Toolkit::TableView mButtons; ///< Navigation buttons
  396 + Dali::Actor mPressedActor; ///< The currently pressed actor.
  397 + Dali::Timer mAnimationTimer; ///< Timer used to turn off animation after a specific time period
  398 + Dali::TapGestureDetector mLogoTapDetector; ///< To detect taps on the logo
  399 + Dali::Toolkit::Popup mVersionPopup; ///< Displays DALi library version information
  400 + Dali::Vector3 mButtonsPageRelativeSize; ///< Size of a buttons page relative to the stage size
  401 +
  402 + Dali::ActorContainer mPages; ///< List of pages.
  403 + Dali::ActorContainer mTableViewImages; ///< Offscreen render of tableview
  404 + Dali::ActorContainer mBackgroundActors; ///< List of background actors used in the effect
  405 + AnimationList mBackgroundAnimations; ///< List of background bubble animations
  406 + ExampleList mExampleList; ///< List of examples.
  407 + ExampleMap mExampleMap; ///< Map LUT for examples.
  408 +
  409 + std::string mBackgroundImagePath; ///< The path to the background image.
  410 + int mTotalPages; ///< Total pages within scrollview.
  411 +
  412 + bool mScrolling:1; ///< Flag indicating whether view is currently being scrolled
  413 + bool mSortAlphabetically:1; ///< Sort examples alphabetically.
  414 + bool mBackgroundAnimsPlaying:1; ///< Are background animations playing
  415 + bool mVersionPopupShown:1; ///< Whehter the version popup is shown or not
395 416 };
396 417  
397 418 #endif // __DALI_DEMO_H__
... ...