X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=base%2Fdali-toolkit%2Fpublic-api%2Fcontrols%2Fcontrol-impl.cpp;h=456393cd97f69173cc0455e2e0e43830c59ddc29;hp=9e85139cb2db42929a5f565252cab7b0fb850503;hb=4314e7c509e44abac7585ff142fb28393b6c6593;hpb=16e2b98c54081905fa9e26e017e96672581c9f34 diff --git a/base/dali-toolkit/public-api/controls/control-impl.cpp b/base/dali-toolkit/public-api/controls/control-impl.cpp index 9e85139..456393c 100644 --- a/base/dali-toolkit/public-api/controls/control-impl.cpp +++ b/base/dali-toolkit/public-api/controls/control-impl.cpp @@ -1,18 +1,19 @@ -// -// 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. + * + */ #include @@ -20,13 +21,15 @@ #include -#include "dali-toolkit/internal/controls/style-change-processor.h" #include "dali-toolkit/internal/controls/relayout-controller.h" #include "dali-toolkit/internal/controls/relayout-helper.h" #include "dali-toolkit/public-api/focus-manager/keyinput-focus-manager.h" #include "dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h" #include +#include +#include + namespace Dali { @@ -236,23 +239,24 @@ public: // Construction & Destruction Impl(Control& controlImpl) : mControlImpl(controlImpl), - mInitialized( false ), + mBackground( NULL ), + mKeyEventSignalV2(), mPinchGestureDetector(), mPanGestureDetector(), mTapGestureDetector(), mLongPressGestureDetector(), mStartingPinchScale(), - mLockSetSize( false ), - mWidthPolicy( Toolkit::Control::Fixed ), - mHeightPolicy( Toolkit::Control::Fixed ), mSize(), mSetSize(), mMinimumSize(), mMaximumSize( MAX_FLOAT_VALUE, MAX_FLOAT_VALUE, MAX_FLOAT_VALUE ), + mLockSetSize( false ), + mWidthPolicy( Toolkit::Control::Fixed ), + mHeightPolicy( Toolkit::Control::Fixed ), + mFlags( Control::CONTROL_BEHAVIOUR_NONE ), mIsKeyboardNavigationSupported(false), mIsKeyboardFocusGroup(false), - mKeyEventSignalV2(), - mBackground( NULL ) + mInitialized( false ) { } @@ -493,39 +497,30 @@ public: // Data Control& mControlImpl; - - bool mInitialized:1; - + Background* mBackground; ///< Only create the background if we use it ConnectionTracker mConnectionTracker; // signal connection tracker + Toolkit::Control::KeyEventSignalV2 mKeyEventSignalV2; // Gesture Detection - PinchGestureDetector mPinchGestureDetector; PanGestureDetector mPanGestureDetector; TapGestureDetector mTapGestureDetector; LongPressGestureDetector mLongPressGestureDetector; - Vector3 mStartingPinchScale; ///< The scale when a pinch gesture starts - // Relayout and size negotiation - - bool mLockSetSize; ///< Used to avoid. Can't be a bitfield as a reference to this member is used in SetSizeLock helper class. - - Toolkit::Control::SizePolicy mWidthPolicy; ///< Stores the width policy. - Toolkit::Control::SizePolicy mHeightPolicy; ///< Stores the height policy. - Vector3 mSize; ///< Stores the current control's size. Vector3 mSetSize; ///< Always stores the size set through the Actor's API. Useful when reset to the initial size is needed. Vector3 mMinimumSize; ///< Stores the control's minimum size. Vector3 mMaximumSize; ///< Stores the control's maximum size. - bool mIsKeyboardNavigationSupported; ///< Stores whether keyboard navigation is supported by the control. - bool mIsKeyboardFocusGroup; ///< Stores whether the control is a focus group. - - Toolkit::Control::KeyEventSignalV2 mKeyEventSignalV2; + bool mLockSetSize; ///< Used to avoid. Can't be a bitfield as a reference to this member is used in SetSizeLock helper class. - // Background - Background* mBackground; ///< Only create the background if we use it + Toolkit::Control::SizePolicy mWidthPolicy:3; ///< Stores the width policy. 3 bits covers 8 values + Toolkit::Control::SizePolicy mHeightPolicy:3; ///< Stores the height policy. 3 bits covers 8 values + ControlBehaviour mFlags:4; ///< Flags passed in from constructor. Need to increase this size when new enums are added + bool mIsKeyboardNavigationSupported:1; ///< Stores whether keyboard navigation is supported by the control. + bool mIsKeyboardFocusGroup:1; ///< Stores whether the control is a focus group. + bool mInitialized:1; // Properties - these need to be members of Internal::Control::Impl as they need to functions within this class. static PropertyRegistration PROPERTY_1; @@ -548,7 +543,7 @@ PropertyRegistration Control::Impl::PROPERTY_7( CONTROL_TYPE, "key-input-focus", Toolkit::Control Control::New() { // Create the implementation, temporarily owned on stack - IntrusivePtr controlImpl = new Control( false ); + IntrusivePtr controlImpl = new Control( CONTROL_BEHAVIOUR_NONE ); // Pass ownership to handle Toolkit::Control handle( *controlImpl ); @@ -562,22 +557,26 @@ Toolkit::Control Control::New() Control::~Control() { - if( mImpl->mInitialized ) - { - // Unregister only if control has been initialized. - Internal::StyleChangeProcessor::Unregister( this ); - } delete mImpl; } void Control::Initialize() { - // Register with the style change processor so we are informed when the default style changes - Internal::StyleChangeProcessor::Register( this ); // Calling deriving classes OnInitialize(); + if( mImpl->mFlags & REQUIRES_STYLE_CHANGE_SIGNALS ) + { + Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get(); + + // Register for style changes + styleManager.StyleChangeSignal().Connect( this, &ControlImpl::DoStyleChange ); + + // SetTheme + GetImpl( styleManager ).ApplyThemeStyle( GetOwner() ); + } + mImpl->mInitialized = true; } @@ -734,6 +733,11 @@ Actor Control::GetBackgroundActor() const return Actor(); } +void Control::OnThemeChange( Toolkit::StyleManager styleManager ) +{ + GetImpl( styleManager ).ApplyThemeStyle( GetOwner() ); +} + void Control::OnPinch(PinchGesture pinch) { if (pinch.state == Gesture::Started) @@ -766,7 +770,7 @@ void Control::OnChildAdd(Actor& child) return; } - // Request for relayout. + // Request for relayout as we may need to position the new child and old ones RelayoutRequest(); // Notify derived classes. @@ -781,7 +785,7 @@ void Control::OnChildRemove(Actor& child) return; } - // Request for relayout. + // Request for relayout as we may need to re-position the old child RelayoutRequest(); // Notify derived classes. @@ -889,12 +893,32 @@ bool Control::DoAction(BaseObject* object, const std::string& actionName, const { bool ret = false; + if( object && (actionName == Toolkit::Control::ACTION_CONTROL_ACTIVATED) ) + { + Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) ); + if( control ) + { + // if cast succeeds there is an implementation so no need to check + control.GetImplementation().OnActivated(); + } + } + return ret; } -void Control::DoActivatedAction(const PropertyValueContainer& attributes) +void Control::DoStyleChange( Toolkit::StyleManager styleManager, StyleChange change ) { - OnActivated(); + if( change.themeChange ) + { + OnThemeChange( styleManager ); + } + else if( change.defaultFontChange || change.defaultFontSizeChange ) + { + // This OnStyleChange(StyleChange change ) is deprecated, use OnFontChange instead + OnStyleChange( change ); + + OnFontChange( change.defaultFontChange, change.defaultFontSizeChange ); + } } Toolkit::Control::KeyEventSignalV2& Control::KeyEventSignal() @@ -1033,7 +1057,12 @@ void Control::ClearKeyInputFocus() void Control::RelayoutRequest() { - Internal::RelayoutController::Get().Request(); + // unfortunate double negative but thats to guarantee new controls get size negotiation + // by default and have to "opt-out" if they dont want it + if( !(mImpl->mFlags & NO_SIZE_NEGOTIATION) ) + { + Internal::RelayoutController::Request(); + } } void Control::Relayout( Vector2 size, ActorSizeContainer& container ) @@ -1222,6 +1251,13 @@ Control::Control( bool requiresTouchEvents ) { } +Control::Control( ControlBehaviour behaviourFlags ) +: CustomActorImpl( behaviourFlags & REQUIRES_TOUCH_EVENTS ), + mImpl(new Impl(*this)) +{ + mImpl->mFlags = behaviourFlags; +} + } // namespace Internal } // namespace Toolkit