-//
-// 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 "button-impl.h"
-namespace
-{
-const char* const PROPERTY_DIMMED = "dimmed";
-} // unnamed namespace
+// EXTERNAL INCLUDES
+#include <dali/public-api/events/touch-event.h>
+#include <dali/public-api/object/type-registry.h>
namespace Dali
{
namespace Toolkit
{
-const Property::Index Button::PROPERTY_DIMMED( Internal::Button::BUTTON_PROPERTY_START_INDEX );
+const Property::Index Button::PROPERTY_DISABLED = Internal::Button::BUTTON_PROPERTY_START_INDEX;
+const Property::Index Button::PROPERTY_AUTO_REPEATING = Internal::Button::BUTTON_PROPERTY_START_INDEX + 1;
+const Property::Index Button::PROPERTY_INITIAL_AUTO_REPEATING_DELAY = Internal::Button::BUTTON_PROPERTY_START_INDEX + 2;
+const Property::Index Button::PROPERTY_NEXT_AUTO_REPEATING_DELAY = Internal::Button::BUTTON_PROPERTY_START_INDEX + 3;
+const Property::Index Button::PROPERTY_TOGGLABLE = Internal::Button::BUTTON_PROPERTY_START_INDEX + 4;
+const Property::Index Button::PROPERTY_TOGGLED = Internal::Button::BUTTON_PROPERTY_START_INDEX + 5;
+const Property::Index Button::PROPERTY_NORMAL_STATE_ACTOR = Internal::Button::BUTTON_PROPERTY_START_INDEX + 6;
+const Property::Index Button::PROPERTY_SELECTED_STATE_ACTOR = Internal::Button::BUTTON_PROPERTY_START_INDEX + 7;
+const Property::Index Button::PROPERTY_DISABLED_STATE_ACTOR = Internal::Button::BUTTON_PROPERTY_START_INDEX + 8;
+const Property::Index Button::PROPERTY_LABEL_ACTOR = Internal::Button::BUTTON_PROPERTY_START_INDEX + 9;
namespace Internal
{
TypeRegistration typeRegistration( typeid(Toolkit::Button), typeid(Toolkit::Control), Create );
SignalConnectorType signalConnector1( typeRegistration, Toolkit::Button::SIGNAL_CLICKED, &Button::DoConnectSignal );
-
-PropertyRegistration property1( typeRegistration, "dimmed", Toolkit::Button::PROPERTY_DIMMED, Property::BOOLEAN, &Button::SetProperty, &Button::GetProperty );
+SignalConnectorType signalConnector2( typeRegistration, Toolkit::Button::SIGNAL_STATE_CHANGED, &Button::DoConnectSignal );
+
+PropertyRegistration property1( typeRegistration, "disabled", Toolkit::Button::PROPERTY_DISABLED, Property::BOOLEAN, &Button::SetProperty, &Button::GetProperty );
+PropertyRegistration property2( typeRegistration, "auto-repeating", Toolkit::Button::PROPERTY_AUTO_REPEATING, Property::BOOLEAN, &Button::SetProperty, &Button::GetProperty );
+PropertyRegistration property3( typeRegistration, "initial-auto-repeating-delay", Toolkit::Button::PROPERTY_INITIAL_AUTO_REPEATING_DELAY, Property::FLOAT, &Button::SetProperty, &Button::GetProperty );
+PropertyRegistration property4( typeRegistration, "next-auto-repeating-delay", Toolkit::Button::PROPERTY_NEXT_AUTO_REPEATING_DELAY, Property::FLOAT, &Button::SetProperty, &Button::GetProperty );
+PropertyRegistration property5( typeRegistration, "togglable", Toolkit::Button::PROPERTY_TOGGLABLE, Property::BOOLEAN, &Button::SetProperty, &Button::GetProperty );
+PropertyRegistration property6( typeRegistration, "toggled", Toolkit::Button::PROPERTY_TOGGLED, Property::BOOLEAN, &Button::SetProperty, &Button::GetProperty );
+PropertyRegistration property7( typeRegistration, "normal-state-actor", Toolkit::Button::PROPERTY_NORMAL_STATE_ACTOR, Property::MAP, &Button::SetProperty, &Button::GetProperty );
+PropertyRegistration property8( typeRegistration, "selected-state-actor", Toolkit::Button::PROPERTY_SELECTED_STATE_ACTOR, Property::MAP, &Button::SetProperty, &Button::GetProperty );
+PropertyRegistration property9( typeRegistration, "disabled-state-actor", Toolkit::Button::PROPERTY_DISABLED_STATE_ACTOR, Property::MAP, &Button::SetProperty, &Button::GetProperty );
+PropertyRegistration property10( typeRegistration, "label-actor", Toolkit::Button::PROPERTY_LABEL_ACTOR, Property::MAP, &Button::SetProperty, &Button::GetProperty );
} // unnamed namespace
Button::Button()
-: Control( true ),
+: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ),
+ mPainter( NULL ),
mState( ButtonUp ),
- mDimmed( false ),
- mPainter( NULL )
+ mDisabled( false )
{
}
{
}
-void Button::SetDimmed( bool dimmed )
+void Button::SetDisabled( bool disabled )
{
- mDimmed = dimmed;
+ mDisabled = disabled;
// Notifies the painter.
Toolkit::Button handle( GetOwner() );
if( mPainter )
{
- mPainter->SetDimmed( handle, mDimmed );
+ mPainter->SetDisabled( handle, mDisabled );
}
}
-bool Button::IsDimmed() const
+bool Button::IsDisabled() const
{
- return mDimmed;
+ return mDisabled;
}
void Button::SetAnimationTime( float animationTime )
// nothing to do.
}
+void Button::OnButtonDown()
+{
+
+}
+
+void Button::OnButtonUp()
+{
+
+}
+
float Button::OnAnimationTimeRequested() const
{
return 0.f;
}
-Toolkit::Button::ClickedSignalV2& Button::ClickedSignal()
+Toolkit::Button::ClickedSignalType& Button::ClickedSignal()
+{
+ return mClickedSignal;
+}
+
+Toolkit::Button::StateChangedSignalType& Button::StateChangedSignal()
{
- return mClickedSignalV2;
+ return mStateChangedSignal;
}
bool Button::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
{
button.ClickedSignal().Connect( tracker, functor );
}
+ else if( Dali::Toolkit::Button::SIGNAL_STATE_CHANGED == signalName )
+ {
+ button.StateChangedSignal().Connect( tracker, functor );
+ }
else
{
// signalName does not match any signal
bool Button::OnTouchEvent(const TouchEvent& event)
{
- // Only events are processed when the button is not dimmed and the touch event has only
+ // Only events are processed when the button is not disabled and the touch event has only
// one touch point.
- if( ( !mDimmed ) && ( 1 == event.GetPointCount() ) )
+ if( ( !mDisabled ) && ( 1 == event.GetPointCount() ) )
{
switch( event.GetPoint(0).state )
{
}
}
-void Button::OnTap(Actor actor, TapGesture tap)
+void Button::OnTap(Actor actor, const TapGesture& tap)
{
// Do nothing.
}
-void Button::OnStageDisconnection()
+void Button::OnControlStageDisconnection()
{
- if( ButtonUp != mState )
- {
- OnTouchPointLeave(); // Notification for derived classes.
- mState = ButtonUp;
- }
+ OnButtonStageDisconnection(); // Notification for derived classes.
+ mState = ButtonUp;
}
void Button::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
{
Toolkit::Button button = Toolkit::Button::DownCast( Dali::BaseHandle( object ) );
- if ( button && ( index == Toolkit::Button::PROPERTY_DIMMED ) )
+ if ( button && ( index == Toolkit::Button::PROPERTY_DISABLED ) )
{
- GetImplementation( button ).SetDimmed( value.Get<bool>() );
+ GetImplementation( button ).SetDisabled( value.Get<bool>() );
}
}
{
Toolkit::Button button = Toolkit::Button::DownCast( Dali::BaseHandle( object ) );
- if ( button && ( propertyIndex == Toolkit::Button::PROPERTY_DIMMED ) )
+ if ( button && ( propertyIndex == Toolkit::Button::PROPERTY_DISABLED ) )
{
- return Property::Value( GetImplementation( button ).mDimmed );
+ return Property::Value( GetImplementation( button ).mDisabled );
}
return Property::Value();