X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Fdevel-api%2Fcontrols%2Faccessible-impl.cpp;h=9f1c78e82981cf569eea16cf931cb5a186d8ece3;hp=c42cb8a40bc72a5bf00959351471b21345319903;hb=f934e958dc240633a80b94207bb076944e48d7a2;hpb=8e3fd25cab9b478aa0d0668d0a186b6fa93c10f6 diff --git a/dali-toolkit/devel-api/controls/accessible-impl.cpp b/dali-toolkit/devel-api/controls/accessible-impl.cpp index c42cb8a..9f1c78e 100644 --- a/dali-toolkit/devel-api/controls/accessible-impl.cpp +++ b/dali-toolkit/devel-api/controls/accessible-impl.cpp @@ -24,6 +24,7 @@ #endif #include +#include // INTERNAL INCLUDES #include @@ -199,6 +200,37 @@ std::string AccessibleImpl::GetLocalizedRoleName() return GetLocaleText(GetRoleName()); } +bool AccessibleImpl::IsShowing() +{ + Dali::Actor self = Self(); + if(self.GetProperty(Dali::DevelActor::Property::CULLED).Get() || !self.GetCurrentProperty(Actor::Property::VISIBLE)) + { + return false; + } + + auto* child = this; + auto* parent = dynamic_cast(child->GetParent()); + if(!parent) + { + return true; + } + + auto childExtent = child->GetExtents(Dali::Accessibility::CoordinateType::WINDOW); + while(parent) + { + auto control = Dali::Toolkit::Control::DownCast(parent->Self()); + auto clipMode = control.GetProperty(Actor::Property::CLIPPING_MODE).Get(); + auto parentExtent = parent->GetExtents(Dali::Accessibility::CoordinateType::WINDOW); + if ((clipMode != ClippingMode::DISABLED) && !parentExtent.Intersects(childExtent)) + { + return false; + } + parent = dynamic_cast(parent->GetParent()); + } + + return true; +} + Dali::Accessibility::States AccessibleImpl::CalculateStates() { Dali::Actor self = Self(); @@ -224,8 +256,7 @@ Dali::Accessibility::States AccessibleImpl::CalculateStates() { state[Dali::Accessibility::State::MODAL] = true; } - state[Dali::Accessibility::State::SHOWING] = !self.GetProperty(Dali::DevelActor::Property::CULLED).Get() && self.GetCurrentProperty(Actor::Property::VISIBLE); - + state[Dali::Accessibility::State::SHOWING] = IsShowing(); state[Dali::Accessibility::State::DEFUNCT] = !self.GetProperty(Dali::DevelActor::Property::CONNECTED_TO_SCENE).Get(); return state; } @@ -278,7 +309,16 @@ Dali::Rect<> AccessibleImpl::GetExtents(Dali::Accessibility::CoordinateType type Vector3 anchorPointOffSet = size * (positionUsesAnchorPoint ? self.GetCurrentProperty(Actor::Property::ANCHOR_POINT) : AnchorPoint::TOP_LEFT); Vector2 position = Vector2((screenPosition.x - anchorPointOffSet.x), (screenPosition.y - anchorPointOffSet.y)); - return {position.x, position.y, size.x, size.y}; + if(type == Dali::Accessibility::CoordinateType::WINDOW) + { + return {position.x, position.y, size.x, size.y}; + } + else // Dali::Accessibility::CoordinateType::SCREEN + { + auto window = Dali::DevelWindow::Get(self); + auto windowPosition = window.GetPosition(); + return {position.x + windowPosition.GetX(), position.y + windowPosition.GetY(), size.x, size.y}; + } } int16_t AccessibleImpl::GetMdiZOrder() @@ -328,6 +368,22 @@ void AccessibleImpl::ScrollToSelf() } } +void AccessibleImpl::RegisterPositionPropertyNotification() +{ + auto control = Dali::Toolkit::Control::DownCast(Self()); + Internal::Control& internalControl = Toolkit::Internal::GetImplementation(control); + Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get(internalControl); + controlImpl.RegisterAccessibilityPositionPropertyNotification(); +} + +void AccessibleImpl::UnregisterPositionPropertyNotification() +{ + auto control = Dali::Toolkit::Control::DownCast(Self()); + Internal::Control& internalControl = Toolkit::Internal::GetImplementation(control); + Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get(internalControl); + controlImpl.UnregisterAccessibilityPositionPropertyNotification(); +} + bool AccessibleImpl::GrabHighlight() { Dali::Actor self = Self(); @@ -360,11 +416,15 @@ bool AccessibleImpl::GrabHighlight() SetHighlightActor(highlight); } - highlight.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); - highlight.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + highlight.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); highlight.SetProperty(Actor::Property::POSITION_Z, 1.0f); highlight.SetProperty(Actor::Property::POSITION, Vector2(0.0f, 0.0f)); + // Need to set resize policy again, to update SIZE property which is set by + // AccessibleImpl_NUI. The highlight could move from AccessibleImpl_NUI to + // AccessibleImpl. In this case, highlight has incorrect size. + highlight.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + // Remember the highlight actor, so that when the default is changed with // SetHighlightActor(), the currently displayed highlight can still be cleared. mCurrentHighlightActor = highlight; @@ -372,6 +432,7 @@ bool AccessibleImpl::GrabHighlight() self.Add(highlight); SetCurrentlyHighlightedActor(self); EmitHighlighted(true); + RegisterPositionPropertyNotification(); return true; } @@ -387,6 +448,7 @@ bool AccessibleImpl::ClearHighlight() if(GetCurrentlyHighlightedActor() == self) { + UnregisterPositionPropertyNotification(); self.Remove(mCurrentHighlightActor.GetHandle()); mCurrentHighlightActor = {}; SetCurrentlyHighlightedActor({}); @@ -495,4 +557,14 @@ Dali::Property::Index AccessibleImpl::GetDescriptionPropertyIndex() return Dali::Property::INVALID_INDEX; } +void AccessibleImpl::SetLastPosition(Vector2 position) +{ + mLastPosition = position; +} + +Vector2 AccessibleImpl::GetLastPosition() const +{ + return mLastPosition; +} + } // namespace Dali::Toolkit::DevelControl