Updated demos to use DALi clang-format
[platform/core/uifw/dali-demo.git] / examples / text-label / expanding-buttons-impl.cpp
index 73003fc..1adc86e 100644 (file)
@@ -27,33 +27,30 @@ namespace Demo
 {
 namespace Internal
 {
-
 namespace
 {
-
 const unsigned int GAP_BETWEEN_BUTTONS = 3;
 
-const char* const STYLES_IMAGE = DEMO_IMAGE_DIR "FontStyleButton_Main.png";
+const char* const STYLES_IMAGE     = DEMO_IMAGE_DIR "FontStyleButton_Main.png";
 const char* const TICK_IMAGE_IMAGE = DEMO_IMAGE_DIR "FontStyleButton_OK_02.png";
 
 /**
  * Unparent the given number of registered controls from the supplied Vector of controls.
  */
-void ResetControls( std::vector< WeakHandle< Control > > controls, unsigned int numberOfButtons )
+void ResetControls(std::vector<WeakHandle<Control> > controls, unsigned int numberOfButtons)
 {
-  for( unsigned int index = 0; index < numberOfButtons; index++)
+  for(unsigned int index = 0; index < numberOfButtons; index++)
   {
     Dali::Toolkit::Control control = controls[index].GetHandle();
-    UnparentAndReset( control );
+    UnparentAndReset(control);
   }
 }
 
 } // anonymous namespace
 
-
 Internal::ExpandingButtons::ExpandingButtons()
-: Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
-  mStyleButtonsHidden( false )
+: Control(ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT)),
+  mStyleButtonsHidden(false)
 {
 }
 
@@ -63,8 +60,8 @@ Internal::ExpandingButtons::~ExpandingButtons()
 
 Demo::ExpandingButtons Internal::ExpandingButtons::New()
 {
-  IntrusivePtr<Internal::ExpandingButtons> impl = new Internal::ExpandingButtons();
-  Demo::ExpandingButtons handle = Demo::ExpandingButtons( *impl );
+  IntrusivePtr<Internal::ExpandingButtons> impl   = new Internal::ExpandingButtons();
+  Demo::ExpandingButtons                   handle = Demo::ExpandingButtons(*impl);
   impl->Initialize();
   return handle;
 }
@@ -73,43 +70,43 @@ void ExpandingButtons::OnInitialize()
 {
   mExpandButton = PushButton::New();
 
-  mExpandButton.ClickedSignal().Connect( this, &ExpandingButtons::OnExpandButtonClicked );
-  mExpandButton.SetProperty( Button::Property::TOGGLABLE, true );
-  mExpandButton.SetProperty( Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, STYLES_IMAGE ); // Default for Styles
-  mExpandButton.SetProperty( Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, TICK_IMAGE_IMAGE );
-  mExpandButton.SetProperty( Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
-  Self().Add( mExpandButton );
+  mExpandButton.ClickedSignal().Connect(this, &ExpandingButtons::OnExpandButtonClicked);
+  mExpandButton.SetProperty(Button::Property::TOGGLABLE, true);
+  mExpandButton.SetProperty(Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, STYLES_IMAGE); // Default for Styles
+  mExpandButton.SetProperty(Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, TICK_IMAGE_IMAGE);
+  mExpandButton.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+  Self().Add(mExpandButton);
 }
 
-void ExpandingButtons::OnRelayout( const Dali::Vector2& targetSize, Dali::RelayoutContainer& container )
+void ExpandingButtons::OnRelayout(const Dali::Vector2& targetSize, Dali::RelayoutContainer& container)
 {
   mButtonSize = targetSize;
-  mExpandButton.SetProperty( Actor::Property::SIZE, targetSize );
+  mExpandButton.SetProperty(Actor::Property::SIZE, targetSize);
 }
 
-void ExpandingButtons::RegisterButton( Dali::Toolkit::Control& control )
+void ExpandingButtons::RegisterButton(Dali::Toolkit::Control& control)
 {
-  mExpandingControls.push_back( control );
+  mExpandingControls.push_back(control);
 }
 
 void ExpandingButtons::Expand()
 {
-  if ( !mExpandCollapseAnimation )
+  if(!mExpandCollapseAnimation)
   {
-    mExpandCollapseAnimation = Animation::New( 0.2f );
-    mExpandCollapseAnimation.FinishedSignal().Connect( this, &ExpandingButtons::OnExpandAnimationFinished );
+    mExpandCollapseAnimation = Animation::New(0.2f);
+    mExpandCollapseAnimation.FinishedSignal().Connect(this, &ExpandingButtons::OnExpandAnimationFinished);
   }
 
   unsigned int numberOfControls = mExpandingControls.size();
 
-  for( unsigned int index = 0; index < numberOfControls; index++ )
+  for(unsigned int index = 0; index < numberOfControls; index++)
   {
     Dali::Toolkit::Control control = mExpandingControls[index].GetHandle();
-    if ( control )
+    if(control)
     {
-      Self().Add( control );
-      AlphaFunction focusedAlphaFunction = AlphaFunction( Vector2 ( 0.32f, 0.08f ), Vector2( 0.38f, 1.72f ) );
-      mExpandCollapseAnimation.AnimateTo( Property( control, Actor::Property::POSITION_X ), mButtonSize.width + ( mButtonSize.width + GAP_BETWEEN_BUTTONS ) * (index) , focusedAlphaFunction );
+      Self().Add(control);
+      AlphaFunction focusedAlphaFunction = AlphaFunction(Vector2(0.32f, 0.08f), Vector2(0.38f, 1.72f));
+      mExpandCollapseAnimation.AnimateTo(Property(control, Actor::Property::POSITION_X), mButtonSize.width + (mButtonSize.width + GAP_BETWEEN_BUTTONS) * (index), focusedAlphaFunction);
     }
   }
   Self().RaiseToTop();
@@ -117,12 +114,12 @@ void ExpandingButtons::Expand()
   mExpandCollapseAnimation.Play();
 }
 
-void ExpandingButtons::OnExpandAnimationFinished( Animation& animation )
+void ExpandingButtons::OnExpandAnimationFinished(Animation& animation)
 {
-  if ( mStyleButtonsHidden )
+  if(mStyleButtonsHidden)
   {
     unsigned int numberOfControls = mExpandingControls.size();
-    ResetControls( mExpandingControls, numberOfControls );
+    ResetControls(mExpandingControls, numberOfControls);
     animation.Clear();
     animation.Reset();
   }
@@ -130,22 +127,22 @@ void ExpandingButtons::OnExpandAnimationFinished( Animation& animation )
 
 void ExpandingButtons::Collapse()
 {
-  Demo::ExpandingButtons handle( GetOwner() );
-  mCollapsedSignal.Emit( handle );
+  Demo::ExpandingButtons handle(GetOwner());
+  mCollapsedSignal.Emit(handle);
 
   mStyleButtonsHidden = true;
-  mExpandButton.SetProperty(Button::Property::SELECTED, false );
+  mExpandButton.SetProperty(Button::Property::SELECTED, false);
 
-  if ( mExpandCollapseAnimation )
+  if(mExpandCollapseAnimation)
   {
     unsigned int numberOfControls = mExpandingControls.size();
 
-    for ( unsigned int index = 0; index < numberOfControls; index++ )
+    for(unsigned int index = 0; index < numberOfControls; index++)
     {
       Dali::Toolkit::Control control = mExpandingControls[index].GetHandle();
-      if ( control )
+      if(control)
       {
-        mExpandCollapseAnimation.AnimateTo( Property( control, Actor::Property::POSITION_X ), 0.0f );
+        mExpandCollapseAnimation.AnimateTo(Property(control, Actor::Property::POSITION_X), 0.0f);
       }
     }
     mExpandCollapseAnimation.Play();
@@ -153,9 +150,9 @@ void ExpandingButtons::Collapse()
 }
 
 // Hide or show (expand) buttons if expand button pressed
-bool ExpandingButtons::OnExpandButtonClicked( Toolkit::Button button )
+bool ExpandingButtons::OnExpandButtonClicked(Toolkit::Button button)
 {
-  if ( button.GetProperty( Toolkit::Button::Property::SELECTED ).Get<bool>() )
+  if(button.GetProperty(Toolkit::Button::Property::SELECTED).Get<bool>())
   {
     Expand();
   }
@@ -167,11 +164,10 @@ bool ExpandingButtons::OnExpandButtonClicked( Toolkit::Button button )
   return true;
 }
 
-
 Demo::ExpandingButtons::ExpandingButtonsSignalType& ExpandingButtons::CollapsingSignal()
 {
   return mCollapsedSignal;
 }
 
-} // Internal
-} // Demo
+} // namespace Internal
+} // namespace Demo