X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fcontrol%2Fcontrol-data-impl.cpp;h=2c9dca5929d808e566cec9032c1ac158bf4215fa;hp=3914e6a924c2ac2277792490f59026b7c1510203;hb=798ef5fa1591aa78851e9e3d08fe37411192176a;hpb=8a647e87a01c5c78451653c1264a9eea81ac9b20 diff --git a/dali-toolkit/internal/controls/control/control-data-impl.cpp b/dali-toolkit/internal/controls/control/control-data-impl.cpp index 3914e6a..2c9dca5 100755 --- a/dali-toolkit/internal/controls/control/control-data-impl.cpp +++ b/dali-toolkit/internal/controls/control/control-data-impl.cpp @@ -169,6 +169,24 @@ Toolkit::Visual::Base GetVisualByName( return visualHandle; } +Toolkit::Visual::Base GetVisualByIndex( + const RegisteredVisualContainer& visuals, + Property::Index index) +{ + Toolkit::Visual::Base visualHandle; + + RegisteredVisualContainer::Iterator iter; + for(iter = visuals.Begin(); iter != visuals.End(); iter++) + { + if((*iter)->index == index) + { + visualHandle = (*iter)->visual; + break; + } + } + return visualHandle; +} + /** * Move visual from source to destination container */ @@ -189,71 +207,64 @@ void MoveVisual( RegisteredVisualContainer::Iterator sourceIter, RegisteredVisua * @param[in] attributes The attributes with which to perfrom this action. * @return true if action has been accepted by this control */ -const char* ACTION_ACCESSIBILITY_ACTIVATED = "accessibilityActivated"; -const char* ACTION_ACCESSIBILITY_READING_SKIPPED = "ReadingSkipped"; +const char* ACTION_ACCESSIBILITY_ACTIVATED = "accessibilityActivated"; const char* ACTION_ACCESSIBILITY_READING_CANCELLED = "ReadingCancelled"; -const char* ACTION_ACCESSIBILITY_READING_STOPPED = "ReadingStopped"; +const char* ACTION_ACCESSIBILITY_READING_PAUSED = "ReadingPaused"; +const char* ACTION_ACCESSIBILITY_READING_RESUMED = "ReadingResumed"; +const char* ACTION_ACCESSIBILITY_READING_SKIPPED = "ReadingSkipped"; +const char* ACTION_ACCESSIBILITY_READING_STOPPED = "ReadingStopped"; static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes ) { - bool ret = false; + bool ret = true; + + Dali::BaseHandle handle( object ); + + Toolkit::Control control = Toolkit::Control::DownCast( handle ); + + DALI_ASSERT_ALWAYS( control ); - if( object && - ( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_ACTIVATED ) || - actionName == "activate" ) ) + if( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_ACTIVATED ) || + actionName == "activate" ) { - Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) ); - if( control ) - { - // if cast succeeds there is an implementation so no need to check - if (!DevelControl::AccessibilityActivateSignal( control ).Empty()) { - DevelControl::AccessibilityActivateSignal( control ).Emit(); - ret = true; - } - else - ret = Internal::GetImplementation( control ).OnAccessibilityActivated(); - } + // if cast succeeds there is an implementation so no need to check + if( !DevelControl::AccessibilityActivateSignal( control ).Empty() ) + DevelControl::AccessibilityActivateSignal( control ).Emit(); + else ret = Internal::GetImplementation( control ).OnAccessibilityActivated(); } - else if( object && ( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_READING_SKIPPED ) ) ) + else if( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_READING_SKIPPED ) ) { - Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) ); - if( control ) - { - // if cast succeeds there is an implementation so no need to check - if (!DevelControl::AccessibilityReadingSkippedSignal( control ).Empty()) - { - DevelControl::AccessibilityReadingSkippedSignal( control ).Emit(); - ret = true; - } - } + // if cast succeeds there is an implementation so no need to check + if( !DevelControl::AccessibilityReadingSkippedSignal( control ).Empty() ) + DevelControl::AccessibilityReadingSkippedSignal( control ).Emit(); } - else if( object && ( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_READING_CANCELLED ) ) ) + else if( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_READING_PAUSED ) ) { - Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) ); - if( control ) - { - // if cast succeeds there is an implementation so no need to check - if (!DevelControl::AccessibilityReadingCancelledSignal( control ).Empty()) - { - DevelControl::AccessibilityReadingCancelledSignal( control ).Emit(); - ret = true; - } - } + // if cast succeeds there is an implementation so no need to check + if( !DevelControl::AccessibilityReadingPausedSignal( control ).Empty() ) + DevelControl::AccessibilityReadingPausedSignal( control ).Emit(); } - else if( object && ( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_READING_STOPPED ) ) ) + else if( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_READING_RESUMED ) ) { - Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) ); - if( control ) - { - // if cast succeeds there is an implementation so no need to check - if (!DevelControl::AccessibilityReadingStoppedSignal( control ).Empty()) - { - DevelControl::AccessibilityReadingStoppedSignal( control ).Emit(); - ret = true; - } - } + // if cast succeeds there is an implementation so no need to check + if( !DevelControl::AccessibilityReadingResumedSignal( control ).Empty() ) + DevelControl::AccessibilityReadingResumedSignal( control ).Emit(); + } + else if( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_READING_CANCELLED ) ) + { + // if cast succeeds there is an implementation so no need to check + if( !DevelControl::AccessibilityReadingCancelledSignal( control ).Empty() ) + DevelControl::AccessibilityReadingCancelledSignal( control ).Emit(); + } + else if( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_READING_STOPPED ) ) + { + // if cast succeeds there is an implementation so no need to check + if(!DevelControl::AccessibilityReadingStoppedSignal( control ).Empty()) + DevelControl::AccessibilityReadingStoppedSignal( control ).Emit(); + } else + { + ret = false; } - return ret; } @@ -364,6 +375,8 @@ TypeAction registerAction2( typeRegistration, ACTION_ACCESSIBILITY_ACTIVATED, &D TypeAction registerAction3( typeRegistration, ACTION_ACCESSIBILITY_READING_SKIPPED, &DoAction ); TypeAction registerAction4( typeRegistration, ACTION_ACCESSIBILITY_READING_CANCELLED, &DoAction ); TypeAction registerAction5( typeRegistration, ACTION_ACCESSIBILITY_READING_STOPPED, &DoAction ); +TypeAction registerAction6( typeRegistration, ACTION_ACCESSIBILITY_READING_PAUSED, &DoAction ); +TypeAction registerAction7( typeRegistration, ACTION_ACCESSIBILITY_READING_RESUMED, &DoAction ); DALI_TYPE_REGISTRATION_END() @@ -464,6 +477,16 @@ Control::Impl::Impl( Control& controlImpl ) Control::Impl::~Impl() { + for( auto&& iter : mVisuals ) + { + StopObservingVisual( iter->visual ); + } + + for( auto&& iter : mRemoveVisuals ) + { + StopObservingVisual( iter->visual ); + } + AccessibilityDeregister(); // All gesture detectors will be destroyed so no need to disconnect. delete mStartingPinchScale; @@ -1212,13 +1235,21 @@ void Control::Impl::SetProperty( BaseObject* object, Property::Index index, cons case Toolkit::DevelControl::Property::ACCESSIBILITY_ATTRIBUTES: { - value.Get( controlImpl.mImpl->mAccessibilityAttributes ); + const Property::Map* map = value.GetMap(); + if( map && !map->Empty() ) + { + controlImpl.mImpl->mAccessibilityAttributes = *map; + } break; } case Toolkit::DevelControl::Property::ACCESSIBILITY_ANIMATED: { - value.Get( controlImpl.mImpl->mAccessibilityAnimated ); + bool animated; + if( value.Get( animated ) ) + { + controlImpl.mImpl->mAccessibilityAnimated = animated; + } break; } } @@ -1807,6 +1838,19 @@ void Control::Impl::ClearShadow() mControlImpl.RelayoutRequest(); } +Dali::Property Control::Impl::GetVisualProperty(Dali::Property::Index index, Dali::Property::Key visualPropertyKey) +{ + Toolkit::Visual::Base visual = GetVisualByIndex(mVisuals, index); + if(visual) + { + Internal::Visual::Base& visualImpl = Toolkit::GetImplementation(visual); + return visualImpl.GetPropertyObject(visualPropertyKey); + } + + Handle handle; + return Dali::Property(handle, Property::INVALID_INDEX); +} + void Control::Impl::EmitResourceReadySignal() { if(!mIsEmittingResourceReadySignal) @@ -1889,6 +1933,32 @@ Control::Impl::AccessibleImpl::AccessibleImpl(Dali::Actor self, Dali::Accessibil Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( internalControl ); if( controlImpl.mAccessibilityRole == Dali::Accessibility::Role::UNKNOWN ) controlImpl.mAccessibilityRole = role; + + self.PropertySetSignal().Connect(&controlImpl, [this, &controlImpl](Dali::Handle &handle, Dali::Property::Index index, Dali::Property::Value value) + { + if (this->self != Dali::Accessibility::Accessible::GetCurrentlyHighlightedActor()) + { + return; + } + + if (index == DevelControl::Property::ACCESSIBILITY_NAME + || (index == GetNamePropertyIndex() && !controlImpl.mAccessibilityNameSet)) + { + if (controlImpl.mAccessibilityGetNameSignal.Empty()) + { + Emit(Dali::Accessibility::ObjectPropertyChangeEvent::NAME); + } + } + + if (index == DevelControl::Property::ACCESSIBILITY_DESCRIPTION + || (index == GetDescriptionPropertyIndex() && !controlImpl.mAccessibilityDescriptionSet)) + { + if (controlImpl.mAccessibilityGetDescriptionSignal.Empty()) + { + Emit(Dali::Accessibility::ObjectPropertyChangeEvent::DESCRIPTION); + } + } + }); } std::string Control::Impl::AccessibleImpl::GetName() @@ -1907,12 +1977,15 @@ std::string Control::Impl::AccessibleImpl::GetName() if (controlImpl.mAccessibilityNameSet) return controlImpl.mAccessibilityName; - return GetNameRaw(); + if (auto raw = GetNameRaw(); !raw.empty()) + return raw; + + return self.GetProperty< std::string >( Actor::Property::NAME ); } std::string Control::Impl::AccessibleImpl::GetNameRaw() { - return self.GetProperty< std::string >( Actor::Property::NAME ); + return {}; } std::string Control::Impl::AccessibleImpl::GetDescription() @@ -1981,19 +2054,21 @@ Dali::Accessibility::States Control::Impl::AccessibleImpl::CalculateStates() s[Dali::Accessibility::State::FOCUSABLE] = self.GetProperty< bool >( Actor::Property::KEYBOARD_FOCUSABLE ); s[Dali::Accessibility::State::FOCUSED] = Toolkit::KeyboardFocusManager::Get().GetCurrentFocusActor() == self; if(self.GetProperty( Toolkit::DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE ).GetType() == Property::NONE ) - s[Dali::Accessibility::State::HIGHLIGHTABLE] = true; + s[Dali::Accessibility::State::HIGHLIGHTABLE] = false; else s[Dali::Accessibility::State::HIGHLIGHTABLE] = self.GetProperty( Toolkit::DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE ).Get< bool >(); s[Dali::Accessibility::State::HIGHLIGHTED] = GetCurrentlyHighlightedActor() == self; s[Dali::Accessibility::State::ENABLED] = true; s[Dali::Accessibility::State::SENSITIVE] = true; s[Dali::Accessibility::State::ANIMATED] = self.GetProperty( Toolkit::DevelControl::Property::ACCESSIBILITY_ANIMATED ).Get< bool >(); - s[Dali::Accessibility::State::VISIBLE] = self.GetCurrentProperty< bool >( Actor::Property::VISIBLE ); + s[Dali::Accessibility::State::VISIBLE] = true; if( modal ) { s[Dali::Accessibility::State::MODAL] = true; } - s[Dali::Accessibility::State::SHOWING] = !self.GetProperty( Dali::DevelActor::Property::CULLED ).Get< bool >(); + s[Dali::Accessibility::State::SHOWING] = !self.GetProperty( Dali::DevelActor::Property::CULLED ).Get< bool >() + && self.GetCurrentProperty< bool >( Actor::Property::VISIBLE ); + s[Dali::Accessibility::State::DEFUNCT] = !self.GetProperty( Dali::DevelActor::Property::CONNECTED_TO_SCENE ).Get< bool >(); return s; } @@ -2105,6 +2180,7 @@ bool Control::Impl::AccessibleImpl::GrabHighlight() highlight.SetProperty( Actor::Property::POSITION_Z, 1.0f ); highlight.SetProperty( Actor::Property::POSITION, Vector2( 0.0f, 0.0f )); + EnsureSelfVisible(); self.Add( highlight ); SetCurrentlyHighlightedActor( self ); EmitHighlighted( true ); @@ -2128,11 +2204,6 @@ bool Control::Impl::AccessibleImpl::ClearHighlight() return false; } -int Control::Impl::AccessibleImpl::GetHighlightIndex() -{ - return 0; -} - std::string Control::Impl::AccessibleImpl::GetActionName( size_t index ) { if ( index >= GetActionCount() ) return ""; @@ -2208,6 +2279,29 @@ std::vector Control::Impl::AccessibleImpl::GetRel return ret; } +void Control::Impl::AccessibleImpl::EnsureChildVisible(Actor child) +{ +} + +void Control::Impl::AccessibleImpl::EnsureSelfVisible() +{ + auto parent = dynamic_cast(GetParent()); + if (parent) + { + parent->EnsureChildVisible(self); + } +} + +Property::Index Control::Impl::AccessibleImpl::GetNamePropertyIndex() +{ + return Actor::Property::NAME; +} + +Property::Index Control::Impl::AccessibleImpl::GetDescriptionPropertyIndex() +{ + return Property::INVALID_INDEX; +} + void Control::Impl::PositionOrSizeChangedCallback( PropertyNotification &p ) { auto self = Dali::Actor::DownCast(p.GetTarget());