-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.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://floralicense.org/license/
-//
-// 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.
-//
+/*
+ * 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.
+ *
+ */
// CLASS HEADER
-
#include "check-box-button-default-painter-impl.h"
-// INTERNAL INCLUDES
-
+// EXTERNAL INCLUDES
#include <dali/public-api/actors/image-actor.h>
+#include <dali/public-api/animation/active-constraint.h>
+#include <dali/public-api/animation/constraint.h>
+#include <dali/public-api/animation/constraints.h>
#include <dali/public-api/object/ref-object.h>
-#include "check-box-button-impl.h"
-// EXTERNAL INCLUDES
+// INTERNAL INCLUDES
+#include "check-box-button-impl.h"
namespace Dali
{
const float ANIMATION_TIME( 0.26f ); // EFL checkbox tick time
-const std::string PERCENTAGE_PARENT_SIZE_PROPERTY_NAME( "percentage-parent-size" );
-
-
-/**
- * Constraint to wrap an actor in y that is moving vertically
- */
-Vector3 EqualToPercentageWidthConstraint( const Vector3& current,
- const PropertyInput& percentageProperty,
- const PropertyInput& parentSizeProperty )
-{
- float percentage = percentageProperty.GetFloat();
- const Vector3& parentSize = parentSizeProperty.GetVector3();
-
- Vector3 size( parentSize );
- size.x *= percentage;
-
- return size;
-}
-
-
inline Toolkit::Internal::CheckBoxButton& GetCheckBoxButtonImpl( Toolkit::Button& button )
{
DALI_ASSERT_ALWAYS( button );
CheckBoxButtonDefaultPainter::CheckBoxButtonDefaultPainter()
: CheckBoxButtonPainter(),
- mDimmed( false ),
- mPaintState( UncheckedState ),
+ mDisabled( false ),
+ mPaintState( UnselectedState ),
mButton(NULL),
- mAnimationTime( ANIMATION_TIME ),
- mPercentageParentSizeProperty( Property::INVALID_INDEX )
+ mAnimationTime( ANIMATION_TIME )
{
}
}
}
-void CheckBoxButtonDefaultPainter::SetBackgroundImage( Toolkit::CheckBoxButton& checkBox, Actor image )
+void CheckBoxButtonDefaultPainter::Initialize( Toolkit::Button& button )
{
- Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetImplementation( checkBox );
- Actor& backgroundImage = checkBoxImpl.GetBackgroundImage();
- Actor& fadeOutBackgroundImage = checkBoxImpl.GetFadeOutBackgroundImage();
+ Toolkit::Internal::CheckBoxButton& buttonImpl = GetCheckBoxButtonImpl( button );
+ Actor& backgroundImage = buttonImpl.GetBackgroundImage();
+ Actor& selectedImage = buttonImpl.GetSelectedImage();
+ Actor& disabledBackgroundImage = buttonImpl.GetDisabledBackgroundImage();
+ Actor& disabledSelectedImage = buttonImpl.GetDisabledSelectedImage();
+
+ Toolkit::CheckBoxButton& checkBox = static_cast<Toolkit::CheckBoxButton&>( button );
+
+ if( backgroundImage )
+ {
+ SetBackgroundImage( checkBox, backgroundImage );
+ }
+
+ if( selectedImage )
+ {
+ SetSelectedImage( checkBox, selectedImage );
+ }
+
+ if( disabledBackgroundImage )
+ {
+ SetDisabledBackgroundImage( checkBox, disabledBackgroundImage );
+ }
+
+ if( disabledSelectedImage )
+ {
+ SetDisabledSelectedImage( checkBox, disabledSelectedImage );
+ }
+
+ SetDisabled( button, mDisabled );
+}
+
+void CheckBoxButtonDefaultPainter::SetSize( Toolkit::Button& button, const Vector3& size )
+{
+ Toolkit::Internal::CheckBoxButton& buttonImpl = GetCheckBoxButtonImpl( button );
+ Actor& backgroundImage = buttonImpl.GetBackgroundImage();
+ Actor& selectedImage = buttonImpl.GetSelectedImage();
+ Actor& disabledBackgroundImage = buttonImpl.GetDisabledBackgroundImage();
+ Actor& disabledSelectedImage = buttonImpl.GetDisabledSelectedImage();
+
+ ApplySelectedConstraint( selectedImage, FOREGROUND_DEPTH );
+ ApplyConstraint( backgroundImage, BACKGROUND_DEPTH );
+ ApplyConstraint( disabledSelectedImage, FOREGROUND_DEPTH );
+ ApplyConstraint( disabledBackgroundImage, BACKGROUND_DEPTH );
+}
+
+void CheckBoxButtonDefaultPainter::SetDisabled( Toolkit::Button& button, bool disabled )
+{
+ mDisabled = disabled;
+
+ Toolkit::Internal::CheckBoxButton& buttonImpl = GetCheckBoxButtonImpl( button );
+ Actor& backgroundImage = buttonImpl.GetBackgroundImage();
+ Actor& selectedImage = buttonImpl.GetSelectedImage();
+ Actor& disabledBackgroundImage = buttonImpl.GetDisabledBackgroundImage();
+ Actor& disabledSelectedImage = buttonImpl.GetDisabledSelectedImage();
+ Actor& fadeOutSelectedImage = buttonImpl.GetFadeOutSelectedImage();
+ Actor& fadeOutBackgroundImage = buttonImpl.GetFadeOutBackgroundImage();
+
+ Toolkit::CheckBoxButton& checkBox = static_cast<Toolkit::CheckBoxButton&>( button );
switch( mPaintState )
{
- case UncheckedState: // FALLTHROUGH
- case CheckedState:
- case UncheckedCheckedTransition:
- case CheckedUncheckedTransition:
+ case UnselectedState:
{
- if( backgroundImage && backgroundImage.GetParent() )
+ if( disabled )
{
StopCheckOutAnimation( checkBox );
- FadeOutImage( checkBox, Background, backgroundImage );
+ FadeOutImage( checkBox, Background, backgroundImage );
+ FadeInImage( checkBox, disabledBackgroundImage );
+ StartCheckOutAnimation( checkBox );
+ StartCheckInAnimation();
- backgroundImage = image;
+ mPaintState = UnselectedDisabledTransition;
+ }
+ break;
+ }
+ case SelectedState:
+ {
+ if( disabled )
+ {
+ StopCheckOutAnimation( checkBox );
+ FadeOutImage( checkBox, Background, backgroundImage );
+ FadeOutImage( checkBox, Foreground, selectedImage );
+ FadeInImage( checkBox, disabledSelectedImage );
+ FadeInImage( checkBox, disabledBackgroundImage );
+ StartCheckOutAnimation( checkBox );
+ StartCheckInAnimation();
+ mPaintState = SelectedDisabledTransition;
+ }
+ break;
+ }
+ case DisabledUnselectedState:
+ {
+ if( !disabled )
+ {
+ StopCheckOutAnimation( checkBox );
+ FadeOutImage( checkBox, Background, disabledBackgroundImage );
FadeInImage( checkBox, backgroundImage );
-
StartCheckOutAnimation( checkBox );
StartCheckInAnimation();
+
+ mPaintState = DisabledUnselectedTransition;
}
- else
+ break;
+ }
+ case DisabledSelectedState:
+ {
+ if( !disabled )
{
- backgroundImage = image;
- checkBox.Add( backgroundImage );
+ StopCheckOutAnimation( checkBox );
+ FadeOutImage( checkBox, Background, disabledBackgroundImage );
+ FadeOutImage( checkBox, Foreground, disabledSelectedImage );
+ FadeInImage( checkBox, backgroundImage );
+ FadeInImage( checkBox, selectedImage );
+ StartCheckOutAnimation( checkBox );
+ StartCheckInAnimation();
+
+ mPaintState = DisabledSelectedTransition;
}
break;
}
- case DimmedUncheckedTransition: // FALLTHROUGH
- case DimmedCheckedTransition:
+ case UnselectedSelectedTransition:
{
- StopCheckInAnimation();
- checkBox.Remove( backgroundImage );
+ if( disabled )
+ {
+ float opacity = 1.f;
+ if( selectedImage )
+ {
+ opacity = selectedImage.GetCurrentOpacity();
+ }
+ StopCheckOutAnimation( checkBox );
+ StopCheckInAnimation();
- backgroundImage = image;
+ FadeOutImage( checkBox, Foreground, selectedImage, opacity );
+ FadeOutImage( checkBox, Background, backgroundImage );
- FadeInImage( checkBox, backgroundImage );
- StartCheckInAnimation();
+ FadeInImage( checkBox, disabledSelectedImage );
+ FadeInImage( checkBox, disabledBackgroundImage );
+
+ StartCheckOutAnimation( checkBox );
+ StartCheckInAnimation();
+
+ mPaintState = SelectedDisabledTransition;
+ }
break;
}
- case CheckedDimmedTransition: // FALLTHROUGH
- case UncheckedDimmedTransition:
+ case SelectedUnselectedTransition:
{
- float opacity = 1.f;
- if( fadeOutBackgroundImage )
+ if( disabled )
{
- opacity = fadeOutBackgroundImage.GetCurrentOpacity();
- }
- StopCheckOutAnimation( checkBox );
+ float opacity = 1.f;
+ if( fadeOutSelectedImage )
+ {
+ opacity = fadeOutSelectedImage.GetCurrentOpacity();
+ }
+ StopCheckOutAnimation( checkBox );
+ StopCheckInAnimation();
- // Replaces the button image.
- backgroundImage = image;
+ button.Add( disabledSelectedImage );
+ FadeOutImage( checkBox, Foreground, disabledSelectedImage, opacity );
+ FadeOutImage( checkBox, Background, backgroundImage );
- checkBox.Add( backgroundImage );
- FadeOutImage( checkBox, Background, backgroundImage, opacity );
+ FadeInImage( checkBox, disabledBackgroundImage );
- StartCheckOutAnimation( checkBox );
+ StartCheckOutAnimation( checkBox );
+ StartCheckInAnimation();
+
+ mPaintState = UnselectedDisabledTransition;
+ }
break;
}
- default:
+ case UnselectedDisabledTransition:
{
- backgroundImage = image;
- break;
- }
- }
+ if( !disabled )
+ {
+ float opacity = 1.f;
+ if( fadeOutBackgroundImage )
+ {
+ opacity = fadeOutBackgroundImage.GetCurrentOpacity();
+ }
+ StopCheckOutAnimation( checkBox, false );
+ StopCheckInAnimation();
- backgroundImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- backgroundImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
- ApplyConstraint( backgroundImage, BACKGROUND_DEPTH );
-}
+ FadeOutImage( checkBox, Background, disabledBackgroundImage, 1.f - opacity );
+ FadeInImage( checkBox, backgroundImage, opacity );
-void CheckBoxButtonDefaultPainter::SetCheckedImage( Toolkit::CheckBoxButton& checkBox, Actor image )
-{
- Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetImplementation( checkBox );
- Actor& checkedImage = checkBoxImpl.GetCheckedImage();
- Actor& fadeOutCheckedImage = checkBoxImpl.GetFadeOutCheckedImage();
+ StartCheckOutAnimation( checkBox );
+ StartCheckInAnimation();
- switch( mPaintState )
- {
- case CheckedState:
+ mPaintState = DisabledUnselectedTransition;
+ }
+ break;
+ }
+ case DisabledUnselectedTransition:
{
- if( checkedImage && checkedImage.GetParent() )
+ if( disabled )
{
- StopCheckOutAnimation( checkBox );
- FadeOutImage( checkBox, Foreground, checkedImage );
-
- checkedImage = image;
+ float opacity = 1.f;
+ if( fadeOutBackgroundImage )
+ {
+ opacity = fadeOutBackgroundImage.GetCurrentOpacity();
+ }
+ StopCheckOutAnimation( checkBox, false );
+ StopCheckInAnimation();
- FadeInImage( checkBox, checkedImage );
+ FadeOutImage( checkBox, Background, backgroundImage, 1.f - opacity );
+ FadeInImage( checkBox, disabledBackgroundImage, opacity );
StartCheckOutAnimation( checkBox );
StartCheckInAnimation();
- }
- else
- {
- checkedImage = image;
- checkBox.Add( checkedImage );
+
+ mPaintState = UnselectedDisabledTransition;
}
break;
}
- case UncheckedCheckedTransition: // FALLTHROUGH
- case DimmedCheckedTransition:
+ case SelectedDisabledTransition:
{
- StopCheckInAnimation();
- checkBox.Remove( checkedImage );
+ if( !disabled )
+ {
+ float opacity = 1.f;
+ if( fadeOutBackgroundImage )
+ {
+ opacity = fadeOutBackgroundImage.GetCurrentOpacity();
+ }
+ StopCheckOutAnimation( checkBox, false );
+ StopCheckInAnimation();
- checkedImage = image;
+ FadeOutImage( checkBox, Foreground, disabledSelectedImage, 1.f - opacity );
+ FadeOutImage( checkBox, Background, disabledBackgroundImage, 1.f - opacity );
+ FadeInImage( checkBox, selectedImage, opacity );
+ FadeInImage( checkBox, backgroundImage, opacity );
- FadeInImage( checkBox, checkedImage );
- StartCheckInAnimation();
+ StartCheckOutAnimation( checkBox );
+ StartCheckInAnimation();
+
+ mPaintState = DisabledSelectedTransition;
+ }
break;
}
- case CheckedUncheckedTransition: // FALLTHROUGH
- case CheckedDimmedTransition:
+ case DisabledSelectedTransition:
{
- float opacity = 1.f;
- if( fadeOutCheckedImage )
+ if( disabled )
{
- opacity = fadeOutCheckedImage.GetCurrentOpacity();
- }
- StopCheckOutAnimation( checkBox );
+ float opacity = 1.f;
+ if( fadeOutBackgroundImage )
+ {
+ opacity = fadeOutBackgroundImage.GetCurrentOpacity();
+ }
+ StopCheckOutAnimation( checkBox, false );
+ StopCheckInAnimation();
- // Replaces the button image.
- checkedImage = image;
+ FadeOutImage( checkBox, Foreground, selectedImage, 1.f - opacity );
+ FadeOutImage( checkBox, Background, backgroundImage, 1.f - opacity );
+ FadeInImage( checkBox, disabledSelectedImage, opacity );
+ FadeInImage( checkBox, disabledBackgroundImage, opacity );
- checkBox.Add( checkedImage );
- FadeOutImage( checkBox, Foreground, checkedImage, opacity );
+ StartCheckOutAnimation( checkBox );
+ StartCheckInAnimation();
- StartCheckOutAnimation( checkBox );
+ mPaintState = SelectedDisabledTransition;
+ }
break;
}
default:
- {
- checkedImage = image;
break;
- }
- }
+ }
+}
- checkedImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- checkedImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
- ApplyCheckedConstraint( checkedImage, FOREGROUND_DEPTH );
+void CheckBoxButtonDefaultPainter::SetAnimationTime( float animationTime )
+{
+ mAnimationTime = animationTime;
}
-void CheckBoxButtonDefaultPainter::SetDimmedCheckedImage( Toolkit::CheckBoxButton& checkBox, Actor image )
+float CheckBoxButtonDefaultPainter::GetAnimationTime() const
{
- Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetImplementation( checkBox );
- Actor& dimmedCheckedImage = checkBoxImpl.GetDimmedCheckedImage();
- Actor& fadeOutCheckedImage = checkBoxImpl.GetFadeOutCheckedImage();
+ return mAnimationTime;
+}
+
+void CheckBoxButtonDefaultPainter::SetSelectedImage( Toolkit::Button& button, Actor image )
+{
+ Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( button );
+ Actor& selectedImage = checkBoxImpl.GetSelectedImage();
+ Actor& fadeOutSelectedImage = checkBoxImpl.GetFadeOutSelectedImage();
+
+ Toolkit::CheckBoxButton& checkBox = static_cast<Toolkit::CheckBoxButton&>( button );
switch( mPaintState )
{
- case DimmedCheckedState:
+ case SelectedState:
{
- if( dimmedCheckedImage && dimmedCheckedImage.GetParent() )
+ if( selectedImage && selectedImage.GetParent() )
{
StopCheckOutAnimation( checkBox );
- FadeOutImage( checkBox, Foreground, dimmedCheckedImage );
+ FadeOutImage( checkBox, Foreground, selectedImage );
- dimmedCheckedImage = image;
+ selectedImage = image;
- FadeInImage( checkBox, dimmedCheckedImage );
+ FadeInImage( checkBox, selectedImage );
StartCheckOutAnimation( checkBox );
StartCheckInAnimation();
}
else
{
- dimmedCheckedImage = image;
- checkBox.Add( dimmedCheckedImage );
+ selectedImage = image;
+ checkBox.Add( selectedImage );
}
break;
}
- case CheckedDimmedTransition:
+ case UnselectedSelectedTransition: // FALLTHROUGH
+ case DisabledSelectedTransition:
{
StopCheckInAnimation();
- checkBox.Remove( dimmedCheckedImage );
+ checkBox.Remove( selectedImage );
- dimmedCheckedImage = image;
+ selectedImage = image;
- FadeInImage( checkBox, dimmedCheckedImage );
+ FadeInImage( checkBox, selectedImage );
StartCheckInAnimation();
break;
}
- case DimmedCheckedTransition:
+ case SelectedUnselectedTransition: // FALLTHROUGH
+ case SelectedDisabledTransition:
{
float opacity = 1.f;
- if( fadeOutCheckedImage )
+ if( fadeOutSelectedImage )
{
- opacity = fadeOutCheckedImage.GetCurrentOpacity();
+ opacity = fadeOutSelectedImage.GetCurrentOpacity();
}
StopCheckOutAnimation( checkBox );
// Replaces the button image.
- dimmedCheckedImage = image;
+ selectedImage = image;
- checkBox.Add( dimmedCheckedImage );
- FadeOutImage( checkBox, Foreground, dimmedCheckedImage, opacity );
+ checkBox.Add( selectedImage );
+ FadeOutImage( checkBox, Foreground, selectedImage, opacity );
StartCheckOutAnimation( checkBox );
break;
}
default:
{
- dimmedCheckedImage = image;
+ selectedImage = image;
break;
}
- }
+ }
- dimmedCheckedImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- dimmedCheckedImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
- ApplyConstraint( dimmedCheckedImage, FOREGROUND_DEPTH );
+ selectedImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ selectedImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ ApplySelectedConstraint( selectedImage, FOREGROUND_DEPTH );
}
-void CheckBoxButtonDefaultPainter::SetDimmedBackgroundImage( Toolkit::CheckBoxButton& checkBox, Actor image )
+void CheckBoxButtonDefaultPainter::SetBackgroundImage( Toolkit::Button& button, Actor image )
{
- Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetImplementation( checkBox );
- Actor& dimmedBackgroundImage = checkBoxImpl.GetDimmedBackgroundImage();
+ Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( button );
+ Actor& backgroundImage = checkBoxImpl.GetBackgroundImage();
Actor& fadeOutBackgroundImage = checkBoxImpl.GetFadeOutBackgroundImage();
+ Toolkit::CheckBoxButton& checkBox = static_cast<Toolkit::CheckBoxButton&>( button );
+
switch( mPaintState )
{
- case DimmedCheckedState: // FALLTHROUGH
- case DimmedUncheckedState:
+ case UnselectedState: // FALLTHROUGH
+ case SelectedState:
+ case UnselectedSelectedTransition:
+ case SelectedUnselectedTransition:
{
- if( dimmedBackgroundImage && dimmedBackgroundImage.GetParent() )
+ if( backgroundImage && backgroundImage.GetParent() )
{
StopCheckOutAnimation( checkBox );
- FadeOutImage( checkBox, Background, dimmedBackgroundImage );
+ FadeOutImage( checkBox, Background, backgroundImage );
- dimmedBackgroundImage = image;
+ backgroundImage = image;
- FadeInImage( checkBox, dimmedBackgroundImage );
+ FadeInImage( checkBox, backgroundImage );
StartCheckOutAnimation( checkBox );
StartCheckInAnimation();
}
else
{
- dimmedBackgroundImage = image;
- checkBox.Add( dimmedBackgroundImage );
+ backgroundImage = image;
+ checkBox.Add( backgroundImage );
}
break;
}
- case UncheckedDimmedTransition: // FALLTHROUGH
- case CheckedDimmedTransition:
+ case DisabledUnselectedTransition: // FALLTHROUGH
+ case DisabledSelectedTransition:
{
StopCheckInAnimation();
- checkBox.Remove( dimmedBackgroundImage );
+ checkBox.Remove( backgroundImage );
- dimmedBackgroundImage = image;
+ backgroundImage = image;
- FadeInImage( checkBox, dimmedBackgroundImage );
+ FadeInImage( checkBox, backgroundImage );
StartCheckInAnimation();
break;
}
- case DimmedUncheckedTransition: // FALLTHROUGH
- case DimmedCheckedTransition:
+ case SelectedDisabledTransition: // FALLTHROUGH
+ case UnselectedDisabledTransition:
{
float opacity = 1.f;
if( fadeOutBackgroundImage )
StopCheckOutAnimation( checkBox );
// Replaces the button image.
- dimmedBackgroundImage = image;
+ backgroundImage = image;
- checkBox.Add( dimmedBackgroundImage );
- FadeOutImage( checkBox, Background, dimmedBackgroundImage, opacity );
+ checkBox.Add( backgroundImage );
+ FadeOutImage( checkBox, Background, backgroundImage, opacity );
StartCheckOutAnimation( checkBox );
break;
}
default:
{
- dimmedBackgroundImage = image;
+ backgroundImage = image;
break;
}
}
- dimmedBackgroundImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- dimmedBackgroundImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
- ApplyConstraint( dimmedBackgroundImage, BACKGROUND_DEPTH );
-}
-
-void CheckBoxButtonDefaultPainter::Initialize( Toolkit::Button& button )
-{
- Toolkit::Internal::CheckBoxButton& buttonImpl = GetCheckBoxButtonImpl( button );
- Actor& backgroundImage = buttonImpl.GetBackgroundImage();
- Actor& checkedImage = buttonImpl.GetCheckedImage();
- Actor& dimmedBackgroundImage = buttonImpl.GetDimmedBackgroundImage();
- Actor& dimmedCheckedImage = buttonImpl.GetDimmedCheckedImage();
-
- Toolkit::CheckBoxButton& checkBox = static_cast<Toolkit::CheckBoxButton&>( button );
-
- if( backgroundImage )
- {
- SetBackgroundImage( checkBox, backgroundImage );
- }
-
- if( checkedImage )
- {
- SetCheckedImage( checkBox, checkedImage );
- }
-
- if( dimmedBackgroundImage )
- {
- SetDimmedBackgroundImage( checkBox, dimmedBackgroundImage );
- }
-
- if( dimmedCheckedImage )
- {
- SetDimmedCheckedImage( checkBox, dimmedCheckedImage );
- }
-
- SetDimmed( button, mDimmed );
-}
-
-void CheckBoxButtonDefaultPainter::SetSize( Toolkit::Button& button, const Vector3& size )
-{
- Toolkit::Internal::CheckBoxButton& buttonImpl = GetCheckBoxButtonImpl( button );
- Actor& backgroundImage = buttonImpl.GetBackgroundImage();
- Actor& checkedImage = buttonImpl.GetCheckedImage();
- Actor& dimmedBackgroundImage = buttonImpl.GetDimmedBackgroundImage();
- Actor& dimmedCheckedImage = buttonImpl.GetDimmedCheckedImage();
-
- ApplyCheckedConstraint( checkedImage, FOREGROUND_DEPTH );
+ backgroundImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ backgroundImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
ApplyConstraint( backgroundImage, BACKGROUND_DEPTH );
- ApplyConstraint( dimmedCheckedImage, FOREGROUND_DEPTH );
- ApplyConstraint( dimmedBackgroundImage, BACKGROUND_DEPTH );
}
-void CheckBoxButtonDefaultPainter::SetDimmed( Toolkit::Button& button, bool dimmed )
+void CheckBoxButtonDefaultPainter::SetDisabledSelectedImage( Toolkit::Button& button, Actor image )
{
- mDimmed = dimmed;
-
- Toolkit::Internal::CheckBoxButton& buttonImpl = GetCheckBoxButtonImpl( button );
- Actor& backgroundImage = buttonImpl.GetBackgroundImage();
- Actor& checkedImage = buttonImpl.GetCheckedImage();
- Actor& dimmedBackgroundImage = buttonImpl.GetDimmedBackgroundImage();
- Actor& dimmedCheckedImage = buttonImpl.GetDimmedCheckedImage();
- Actor& fadeOutCheckedImage = buttonImpl.GetFadeOutCheckedImage();
- Actor& fadeOutBackgroundImage = buttonImpl.GetFadeOutBackgroundImage();
+ Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( button );
+ Actor& disabledSelectedImage = checkBoxImpl.GetDisabledSelectedImage();
+ Actor& fadeOutSelectedImage = checkBoxImpl.GetFadeOutSelectedImage();
Toolkit::CheckBoxButton& checkBox = static_cast<Toolkit::CheckBoxButton&>( button );
switch( mPaintState )
{
- case UncheckedState:
+ case DisabledSelectedState:
{
- if( dimmed )
+ if( disabledSelectedImage && disabledSelectedImage.GetParent() )
{
StopCheckOutAnimation( checkBox );
- FadeOutImage( checkBox, Background, backgroundImage );
- FadeInImage( checkBox, dimmedBackgroundImage );
- StartCheckOutAnimation( checkBox );
- StartCheckInAnimation();
+ FadeOutImage( checkBox, Foreground, disabledSelectedImage );
+
+ disabledSelectedImage = image;
+
+ FadeInImage( checkBox, disabledSelectedImage );
- mPaintState = UncheckedDimmedTransition;
- }
- break;
- }
- case CheckedState:
- {
- if( dimmed )
- {
- StopCheckOutAnimation( checkBox );
- FadeOutImage( checkBox, Background, backgroundImage );
- FadeOutImage( checkBox, Foreground, checkedImage );
- FadeInImage( checkBox, dimmedCheckedImage );
- FadeInImage( checkBox, dimmedBackgroundImage );
StartCheckOutAnimation( checkBox );
StartCheckInAnimation();
-
- mPaintState = CheckedDimmedTransition;
}
- break;
- }
- case DimmedUncheckedState:
- {
- if( !dimmed )
+ else
{
- StopCheckOutAnimation( checkBox );
- FadeOutImage( checkBox, Background, dimmedBackgroundImage );
- FadeInImage( checkBox, backgroundImage );
- StartCheckOutAnimation( checkBox );
- StartCheckInAnimation();
-
- mPaintState = DimmedUncheckedTransition;
+ disabledSelectedImage = image;
+ checkBox.Add( disabledSelectedImage );
}
break;
}
- case DimmedCheckedState:
+ case SelectedDisabledTransition:
{
- if( !dimmed )
- {
- StopCheckOutAnimation( checkBox );
- FadeOutImage( checkBox, Background, dimmedBackgroundImage );
- FadeOutImage( checkBox, Foreground, dimmedCheckedImage );
- FadeInImage( checkBox, backgroundImage );
- FadeInImage( checkBox, checkedImage );
- StartCheckOutAnimation( checkBox );
- StartCheckInAnimation();
+ StopCheckInAnimation();
+ checkBox.Remove( disabledSelectedImage );
- mPaintState = DimmedCheckedTransition;
- }
+ disabledSelectedImage = image;
+
+ FadeInImage( checkBox, disabledSelectedImage );
+ StartCheckInAnimation();
break;
}
- case UncheckedCheckedTransition:
+ case DisabledSelectedTransition:
{
- if( dimmed )
+ float opacity = 1.f;
+ if( fadeOutSelectedImage )
{
- float opacity = 1.f;
- if( checkedImage )
- {
- opacity = checkedImage.GetCurrentOpacity();
- }
- StopCheckOutAnimation( checkBox );
- StopCheckInAnimation();
-
- FadeOutImage( checkBox, Foreground, checkedImage, opacity );
- FadeOutImage( checkBox, Background, backgroundImage );
+ opacity = fadeOutSelectedImage.GetCurrentOpacity();
+ }
+ StopCheckOutAnimation( checkBox );
- FadeInImage( checkBox, dimmedCheckedImage );
- FadeInImage( checkBox, dimmedBackgroundImage );
+ // Replaces the button image.
+ disabledSelectedImage = image;
- StartCheckOutAnimation( checkBox );
- StartCheckInAnimation();
+ checkBox.Add( disabledSelectedImage );
+ FadeOutImage( checkBox, Foreground, disabledSelectedImage, opacity );
- mPaintState = CheckedDimmedTransition;
- }
+ StartCheckOutAnimation( checkBox );
break;
}
- case CheckedUncheckedTransition:
+ default:
{
- if( dimmed )
- {
- float opacity = 1.f;
- if( fadeOutCheckedImage )
- {
- opacity = fadeOutCheckedImage.GetCurrentOpacity();
- }
- StopCheckOutAnimation( checkBox );
- StopCheckInAnimation();
+ disabledSelectedImage = image;
+ break;
+ }
+ }
- button.Add( dimmedCheckedImage );
- FadeOutImage( checkBox, Foreground, dimmedCheckedImage, opacity );
- FadeOutImage( checkBox, Background, backgroundImage );
+ disabledSelectedImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ disabledSelectedImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ ApplyConstraint( disabledSelectedImage, FOREGROUND_DEPTH );
+}
- FadeInImage( checkBox, dimmedBackgroundImage );
+void CheckBoxButtonDefaultPainter::SetDisabledBackgroundImage( Toolkit::Button& button, Actor image )
+{
+ Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( button );
+ Actor& disabledBackgroundImage = checkBoxImpl.GetDisabledBackgroundImage();
+ Actor& fadeOutBackgroundImage = checkBoxImpl.GetFadeOutBackgroundImage();
- StartCheckOutAnimation( checkBox );
- StartCheckInAnimation();
+ Toolkit::CheckBoxButton& checkBox = static_cast<Toolkit::CheckBoxButton&>( button );
- mPaintState = UncheckedDimmedTransition;
- }
- break;
- }
- case UncheckedDimmedTransition:
+ switch( mPaintState )
+ {
+ case DisabledSelectedState: // FALLTHROUGH
+ case DisabledUnselectedState:
{
- if( !dimmed )
+ if( disabledBackgroundImage && disabledBackgroundImage.GetParent() )
{
- float opacity = 1.f;
- if( fadeOutBackgroundImage )
- {
- opacity = fadeOutBackgroundImage.GetCurrentOpacity();
- }
- StopCheckOutAnimation( checkBox, false );
- StopCheckInAnimation();
+ StopCheckOutAnimation( checkBox );
+ FadeOutImage( checkBox, Background, disabledBackgroundImage );
- FadeOutImage( checkBox, Background, dimmedBackgroundImage, 1.f - opacity );
- FadeInImage( checkBox, backgroundImage, opacity );
+ disabledBackgroundImage = image;
+
+ FadeInImage( checkBox, disabledBackgroundImage );
StartCheckOutAnimation( checkBox );
StartCheckInAnimation();
-
- mPaintState = DimmedUncheckedTransition;
}
- break;
- }
- case DimmedUncheckedTransition:
- {
- if( dimmed )
+ else
{
- float opacity = 1.f;
- if( fadeOutBackgroundImage )
- {
- opacity = fadeOutBackgroundImage.GetCurrentOpacity();
- }
- StopCheckOutAnimation( checkBox, false );
- StopCheckInAnimation();
-
- FadeOutImage( checkBox, Background, backgroundImage, 1.f - opacity );
- FadeInImage( checkBox, dimmedBackgroundImage, opacity );
-
- StartCheckOutAnimation( checkBox );
- StartCheckInAnimation();
-
- mPaintState = UncheckedDimmedTransition;
+ disabledBackgroundImage = image;
+ checkBox.Add( disabledBackgroundImage );
}
break;
}
- case CheckedDimmedTransition:
+ case UnselectedDisabledTransition: // FALLTHROUGH
+ case SelectedDisabledTransition:
{
- if( !dimmed )
- {
- float opacity = 1.f;
- if( fadeOutBackgroundImage )
- {
- opacity = fadeOutBackgroundImage.GetCurrentOpacity();
- }
- StopCheckOutAnimation( checkBox, false );
- StopCheckInAnimation();
-
- FadeOutImage( checkBox, Foreground, dimmedCheckedImage, 1.f - opacity );
- FadeOutImage( checkBox, Background, dimmedBackgroundImage, 1.f - opacity );
- FadeInImage( checkBox, checkedImage, opacity );
- FadeInImage( checkBox, backgroundImage, opacity );
+ StopCheckInAnimation();
+ checkBox.Remove( disabledBackgroundImage );
- StartCheckOutAnimation( checkBox );
- StartCheckInAnimation();
+ disabledBackgroundImage = image;
- mPaintState = DimmedCheckedTransition;
- }
+ FadeInImage( checkBox, disabledBackgroundImage );
+ StartCheckInAnimation();
break;
}
- case DimmedCheckedTransition:
+ case DisabledUnselectedTransition: // FALLTHROUGH
+ case DisabledSelectedTransition:
{
- if( dimmed )
+ float opacity = 1.f;
+ if( fadeOutBackgroundImage )
{
- float opacity = 1.f;
- if( fadeOutBackgroundImage )
- {
- opacity = fadeOutBackgroundImage.GetCurrentOpacity();
- }
- StopCheckOutAnimation( checkBox, false );
- StopCheckInAnimation();
+ opacity = fadeOutBackgroundImage.GetCurrentOpacity();
+ }
+ StopCheckOutAnimation( checkBox );
- FadeOutImage( checkBox, Foreground, checkedImage, 1.f - opacity );
- FadeOutImage( checkBox, Background, backgroundImage, 1.f - opacity );
- FadeInImage( checkBox, dimmedCheckedImage, opacity );
- FadeInImage( checkBox, dimmedBackgroundImage, opacity );
+ // Replaces the button image.
+ disabledBackgroundImage = image;
- StartCheckOutAnimation( checkBox );
- StartCheckInAnimation();
+ checkBox.Add( disabledBackgroundImage );
+ FadeOutImage( checkBox, Background, disabledBackgroundImage, opacity );
- mPaintState = CheckedDimmedTransition;
- }
+ StartCheckOutAnimation( checkBox );
break;
}
default:
+ {
+ disabledBackgroundImage = image;
break;
+ }
}
-}
-void CheckBoxButtonDefaultPainter::SetAnimationTime( float animationTime )
-{
- mAnimationTime = animationTime;
-}
-
-float CheckBoxButtonDefaultPainter::GetAnimationTime() const
-{
- return mAnimationTime;
+ disabledBackgroundImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ disabledBackgroundImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ ApplyConstraint( disabledBackgroundImage, BACKGROUND_DEPTH );
}
-void CheckBoxButtonDefaultPainter::Checked( Toolkit::CheckBoxButton& button )
+void CheckBoxButtonDefaultPainter::Selected( Toolkit::Button& button )
{
Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( button );
- Actor& checkedImage = checkBoxImpl.GetCheckedImage();
- Actor& fadeOutCheckedImage = checkBoxImpl.GetFadeOutCheckedImage();
+ Actor& selectedImage = checkBoxImpl.GetSelectedImage();
+ Actor& fadeOutSelectedImage = checkBoxImpl.GetFadeOutSelectedImage();
+
+ Toolkit::CheckBoxButton& checkBoxButton = static_cast<Toolkit::CheckBoxButton&>( button );
switch( mPaintState )
{
- case UncheckedState:
+ case UnselectedState:
{
// Fade in the 'check' actor.
- FadeInImage( button, checkedImage );
- SetupCheckedAnimation( button, checkedImage ); // Animate in the check actor
+ FadeInImage( checkBoxButton, selectedImage );
+ SetupSelectedAnimation( checkBoxButton, selectedImage ); // Animate in the check actor
StartCheckInAnimation();
- mPaintState = UncheckedCheckedTransition;
+ mPaintState = UnselectedSelectedTransition;
break;
}
- case CheckedState:
+ case SelectedState:
{
// Fade out the 'check' actor.
- StopCheckOutAnimation( button );
- FadeOutImage( button, Foreground, checkedImage );
- StartCheckOutAnimation( button );
+ StopCheckOutAnimation( checkBoxButton );
+ FadeOutImage( checkBoxButton, Foreground, selectedImage );
+ StartCheckOutAnimation( checkBoxButton );
- if( button.GetProperty<bool>( button.GetPropertyIndex( Toolkit::CheckBoxButton::USE_FADE_ANIMATION_PROPERTY_NAME ) ) )
- {
- mPaintState = CheckedUncheckedTransition;
- }
- else
- {
- mPaintState = UncheckedState;
- }
+ mPaintState = UnselectedState;
break;
}
- case UncheckedCheckedTransition:
+ case UnselectedSelectedTransition:
{
// Stop fade in and start fade out.
- StopCheckOutAnimation( button );
+ StopCheckOutAnimation( checkBoxButton );
StopCheckInAnimation();
float opacity = 0.f;
- if( checkedImage )
+ if( selectedImage )
{
- opacity = checkedImage.GetCurrentOpacity();
+ opacity = selectedImage.GetCurrentOpacity();
}
- FadeOutImage( button, Foreground, checkedImage, opacity );
- StartCheckOutAnimation( button );
+ FadeOutImage( checkBoxButton, Foreground, selectedImage, opacity );
+ StartCheckOutAnimation( checkBoxButton );
- if( button.GetProperty<bool>( button.GetPropertyIndex( Toolkit::CheckBoxButton::USE_FADE_ANIMATION_PROPERTY_NAME ) ) )
- {
- mPaintState = CheckedUncheckedTransition;
- }
- else
- {
- mPaintState = UncheckedState;
- }
+ mPaintState = UnselectedState;
break;
}
- case CheckedUncheckedTransition:
+ case SelectedUnselectedTransition:
{
// Stop fade out and start fade in.
float opacity = 1.f;
- if( fadeOutCheckedImage )
+ if( fadeOutSelectedImage )
{
- opacity = fadeOutCheckedImage.GetCurrentOpacity();
+ opacity = fadeOutSelectedImage.GetCurrentOpacity();
}
- StopCheckOutAnimation( button );
+ StopCheckOutAnimation( checkBoxButton );
- FadeInImage( button, checkedImage, opacity );
+ FadeInImage( checkBoxButton, selectedImage, opacity );
StartCheckInAnimation();
- mPaintState = UncheckedCheckedTransition;
+ mPaintState = UnselectedSelectedTransition;
break;
}
default:
}
}
-void CheckBoxButtonDefaultPainter::ApplyCheckedConstraint( Actor& actor, float depth )
+void CheckBoxButtonDefaultPainter::ApplySelectedConstraint( Actor& actor, float depth )
{
if( actor )
{
- if( mPercentageParentSizeProperty == Property::INVALID_INDEX )
- {
- mPercentageParentSizeProperty = actor.RegisterProperty( PERCENTAGE_PARENT_SIZE_PROPERTY_NAME, 1.0f );
- }
-
actor.RemoveConstraints();
- actor.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE,
- LocalSource( mPercentageParentSizeProperty ),
- ParentSource( Actor::SIZE ),
- EqualToPercentageWidthConstraint ) );
+ actor.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
actor.SetZ( depth );
}
}
}
Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( checkBox );
- Actor& fadeOutCheckedImage = checkBoxImpl.GetFadeOutCheckedImage();
+ Actor& fadeOutSelectedImage = checkBoxImpl.GetFadeOutSelectedImage();
Actor& fadeOutBackgroundImage = checkBoxImpl.GetFadeOutBackgroundImage();
if( remove )
{
- if( fadeOutCheckedImage && fadeOutCheckedImage.GetParent() )
+ if( fadeOutSelectedImage && fadeOutSelectedImage.GetParent() )
{
- fadeOutCheckedImage.GetParent().Remove( fadeOutCheckedImage );
+ fadeOutSelectedImage.GetParent().Remove( fadeOutSelectedImage );
}
if( fadeOutBackgroundImage && fadeOutBackgroundImage.GetParent() )
fadeOutBackgroundImage.GetParent().Remove( fadeOutBackgroundImage );
}
- fadeOutCheckedImage.Reset();
+ fadeOutSelectedImage.Reset();
fadeOutBackgroundImage.Reset();
}
}
checkBox.Add( image );
}
- if( checkBox.GetProperty<bool>( checkBox.GetPropertyIndex( Toolkit::CheckBoxButton::USE_FADE_ANIMATION_PROPERTY_NAME ) ) )
- {
- image.SetOpacity( opacity );
- AddToFadeInAnimation( image );
- }
- else
- {
- image.SetOpacity( 1.0f );
- }
+ image.SetOpacity( 1.0f );
}
}
if( image )
{
Toolkit::Internal::CheckBoxButton& checkBoxImpl = GetCheckBoxButtonImpl( checkBox );
- Actor& fadeOutCheckedImage = checkBoxImpl.GetFadeOutCheckedImage();
+ Actor& fadeOutSelectedImage = checkBoxImpl.GetFadeOutSelectedImage();
Actor& fadeOutBackgroundImage = checkBoxImpl.GetFadeOutBackgroundImage();
- Actor& actorLayer = ( ( Background == layer ) ? fadeOutBackgroundImage : fadeOutCheckedImage );
+ Actor& actorLayer = ( ( Background == layer ) ? fadeOutBackgroundImage : fadeOutSelectedImage );
actorLayer = image;
- if( checkBox.GetProperty<bool>( checkBox.GetPropertyIndex( Toolkit::CheckBoxButton::USE_FADE_ANIMATION_PROPERTY_NAME ) ) )
- {
- actorLayer.SetOpacity( opacity );
- AddToFadeOutAnimation( actorLayer );
- }
- else
- {
- actorLayer.SetOpacity( 0.0f );
- }
+ actorLayer.SetOpacity( 0.0f );
}
}
// Actor size anim
Handle handle = actor; // Get rid of const
- mCheckInAnimation.AnimateTo( Property( handle, mPercentageParentSizeProperty ), 1.0f );
+ mCheckInAnimation.AnimateTo( Property( handle, Actor::SCALE_X ), 1.0f);
}
-void CheckBoxButtonDefaultPainter::SetupCheckedAnimation( Toolkit::CheckBoxButton& checkBox, Actor& image )
+void CheckBoxButtonDefaultPainter::SetupSelectedAnimation( Toolkit::CheckBoxButton& checkBox, Actor& image )
{
- if( checkBox.GetProperty<bool>( checkBox.GetPropertyIndex( Toolkit::CheckBoxButton::USE_CHECK_ANIMATION_PROPERTY_NAME ) ) && image )
+ if( image )
{
if( !mTickUVEffect )
{
imageActor.SetShaderEffect( mTickUVEffect );
}
- // Register a custom property to animate size of tick over
- if( mPercentageParentSizeProperty != Property::INVALID_INDEX )
- {
- image.SetProperty( mPercentageParentSizeProperty, 0.0f );
- }
+ image.SetScale( Vector3( 0.0f, 1.0f, 1.0f ) );
mTickUVEffect.SetBottomRight( Vector2( 0.0f, 1.0f ) );
{
switch( mPaintState )
{
- case UncheckedCheckedTransition:
+ case UnselectedSelectedTransition:
{
- mPaintState = CheckedState;
+ mPaintState = SelectedState;
break;
}
- case CheckedUncheckedTransition:
+ case SelectedUnselectedTransition:
{
- mPaintState = UncheckedState;
+ mPaintState = UnselectedState;
break;
}
- case UncheckedDimmedTransition:
+ case UnselectedDisabledTransition:
{
- mPaintState = DimmedUncheckedState;
+ mPaintState = DisabledUnselectedState;
break;
}
- case DimmedUncheckedTransition:
+ case DisabledUnselectedTransition:
{
- mPaintState = UncheckedState;
+ mPaintState = UnselectedState;
break;
}
- case CheckedDimmedTransition:
+ case SelectedDisabledTransition:
{
- mPaintState = DimmedCheckedState;
+ mPaintState = DisabledSelectedState;
break;
}
- case DimmedCheckedTransition:
+ case DisabledSelectedTransition:
{
- mPaintState = CheckedState;
+ mPaintState = SelectedState;
break;
}
default:
{
switch( mPaintState )
{
- case UncheckedCheckedTransition:
+ case UnselectedSelectedTransition:
{
- mPaintState = CheckedState;
+ mPaintState = SelectedState;
break;
}
- case CheckedUncheckedTransition:
+ case SelectedUnselectedTransition:
{
- mPaintState = UncheckedState;
+ mPaintState = UnselectedState;
break;
}
- case UncheckedDimmedTransition:
+ case UnselectedDisabledTransition:
{
- mPaintState = DimmedUncheckedState;
+ mPaintState = DisabledUnselectedState;
break;
}
- case DimmedUncheckedTransition:
+ case DisabledUnselectedTransition:
{
- mPaintState = UncheckedState;
+ mPaintState = UnselectedState;
break;
}
- case CheckedDimmedTransition:
+ case SelectedDisabledTransition:
{
- mPaintState = DimmedCheckedState;
+ mPaintState = DisabledSelectedState;
break;
}
- case DimmedCheckedTransition:
+ case DisabledSelectedTransition:
{
- mPaintState = CheckedState;
+ mPaintState = SelectedState;
break;
}
default: