Merge "[ATSPI] Fix for SCREEN coordinate type in GetExtents" into devel/master
authorEunki Hong <eunkiki.hong@samsung.com>
Fri, 6 Aug 2021 03:46:40 +0000 (03:46 +0000)
committerGerrit Code Review <gerrit@review>
Fri, 6 Aug 2021 03:46:40 +0000 (03:46 +0000)
automated-tests/src/dali-toolkit-internal/utc-Dali-Accessibility-Accessible.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-Accessibility-Controls-BridgeUp.cpp
dali-toolkit/devel-api/controls/accessible-impl.cpp
dali-toolkit/devel-api/controls/accessible-impl.h
dali-toolkit/devel-api/focus-manager/focus-finder.cpp
packaging/dali-toolkit.spec

index 9b103e8..423893a 100644 (file)
@@ -64,3 +64,69 @@ int utcDaliAccessibilityCheckLabelText(void)
 
   END_TEST;
 }
+
+int UtcDaliAccessibilityCheckShowingState(void)
+{
+  ToolkitTestApplication application;
+
+  auto parentButton = Toolkit::PushButton::New();
+  parentButton.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
+  parentButton.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+  parentButton.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+  parentButton.SetProperty(Actor::Property::POSITION, Dali::Vector2(0.0f, 0.0f));
+  parentButton.SetProperty(Actor::Property::SIZE, Dali::Vector2(200.0f, 200.0f));
+  application.GetScene().Add( parentButton );
+
+  // Toatally inside of parent
+  auto buttonA = Toolkit::PushButton::New();
+  buttonA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+  buttonA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+  buttonA.SetProperty(Actor::Property::POSITION, Dali::Vector2(0.0f, 0.0f));
+  buttonA.SetProperty(Actor::Property::SIZE, Dali::Vector2(100.0f, 100.0f));
+  parentButton.Add(buttonA);
+
+  // Toatally outside of parent
+  auto buttonB = Toolkit::PushButton::New();
+  buttonB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+  buttonB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+  buttonB.SetProperty(Actor::Property::POSITION, Dali::Vector2(300.0f, 300.0f));
+  buttonB.SetProperty(Actor::Property::SIZE, Dali::Vector2(100.0f, 100.0f));
+  parentButton.Add(buttonB);
+
+  // Partially inside of parent
+  auto buttonC = Toolkit::PushButton::New();
+  buttonC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+  buttonC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+  buttonC.SetProperty(Actor::Property::POSITION, Dali::Vector2(100.0f,100.0f));
+  buttonC.SetProperty(Actor::Property::SIZE, Dali::Vector2(200.0f, 200.0f));
+  parentButton.Add(buttonC);
+
+  application.SendNotification();
+  application.Render(16);
+
+  auto q = Dali::Accessibility::Accessible::Get(buttonA);
+  DALI_TEST_CHECK(q);
+  auto states = q->GetStates();
+  DALI_TEST_EQUALS((int) states[Dali::Accessibility::State::SHOWING], (int) true, TEST_LOCATION);
+
+  q = Dali::Accessibility::Accessible::Get(buttonB);
+  DALI_TEST_CHECK(q);
+  states = q->GetStates();
+  DALI_TEST_EQUALS((int) states[Dali::Accessibility::State::SHOWING], (int) false, TEST_LOCATION);
+
+  q = Dali::Accessibility::Accessible::Get(buttonC);
+  DALI_TEST_CHECK(q);
+  states = q->GetStates();
+  DALI_TEST_EQUALS((int) states[Dali::Accessibility::State::SHOWING], (int) true, TEST_LOCATION);
+
+  // Make SHOWING object invisible
+  buttonC.SetProperty(Actor::Property::VISIBLE, false);
+
+  application.SendNotification();
+  application.Render(16);
+
+  states = q->GetStates();
+  DALI_TEST_EQUALS((int) states[Dali::Accessibility::State::SHOWING], (int) false, TEST_LOCATION);
+
+  END_TEST;
+}
\ No newline at end of file
index 1c24861..0b1ec0e 100644 (file)
@@ -1170,24 +1170,25 @@ int UtcDaliAccessibilityCheckHighlight(void)
 
   // Make precondition two children exist in parent area
   PushButton parentButton = PushButton::New();
+  parentButton.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX);
   parentButton.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
   parentButton.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
-  parentButton.SetProperty( Dali::Actor::Property::POSITION, Dali::Vector2(0.0f, 0.0f) );
-  parentButton.SetProperty( Dali::Actor::Property::SIZE, Dali::Vector2(100.0f, 200.0f) );
+  parentButton.SetProperty(Actor::Property::POSITION, Dali::Vector2(0.0f, 0.0f));
+  parentButton.SetProperty(Actor::Property::SIZE, Dali::Vector2(100.0f, 200.0f));
   application.GetScene().Add( parentButton );
 
   PushButton buttonA = PushButton::New();
   buttonA.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
   buttonA.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
-  buttonA.SetProperty( Dali::Actor::Property::POSITION, Dali::Vector2(0.0f, 0.0f) );
-  buttonA.SetProperty( Dali::Actor::Property::SIZE, Dali::Vector2(100.0f, 100.0f) );
+  buttonA.SetProperty(Actor::Property::POSITION, Dali::Vector2(0.0f, 0.0f));
+  buttonA.SetProperty(Actor::Property::SIZE, Dali::Vector2(100.0f, 100.0f));
   parentButton.Add(buttonA);
 
   PushButton buttonB = PushButton::New();
   buttonB.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
   buttonB.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
-  buttonB.SetProperty( Dali::Actor::Property::POSITION, Dali::Vector2(0.0f, 100.0f) );
-  buttonB.SetProperty( Dali::Actor::Property::SIZE, Dali::Vector2(100.0f, 100.0f) );
+  buttonB.SetProperty(Actor::Property::POSITION, Dali::Vector2(0.0f, 100.0f));
+  buttonB.SetProperty(Actor::Property::SIZE, Dali::Vector2(100.0f, 100.0f));
   parentButton.Add(buttonB);
   Wait(application);
 
@@ -1198,9 +1199,9 @@ int UtcDaliAccessibilityCheckHighlight(void)
   Wait(application);
 
   // Move first child (A) out of parent area through the parent's area top edge - single move outed event expected for A object and OUTGOING_TOP_LEFT direction
-  buttonA.SetProperty( Dali::Actor::Property::POSITION, Dali::Vector2(0.0f, -200.0f) );
+  buttonA.SetProperty(Actor::Property::POSITION, Dali::Vector2(0.0f, -200.0f));
   Wait(application);
-  // Need one more seding notificaiton to get correct updated position
+  // Need one more notificaiton to get correct updated position
   application.SendNotification();
   DALI_TEST_EQUALS( true, Dali::Accessibility::TestGetMoveOutedCalled(), TEST_LOCATION );
 
@@ -1210,7 +1211,7 @@ int UtcDaliAccessibilityCheckHighlight(void)
   // Move first child (A) outside of parent area (both start and end position are outside of parent area) - no move outed event expected for A object
   buttonA.SetProperty( Dali::Actor::Property::POSITION, Dali::Vector2(0.0f, -300.0f) );
   Wait(application);
-  // Need one more seding notificaiton to get correct updated position
+  // Need one more notificaiton to get correct updated position
   application.SendNotification();
   DALI_TEST_EQUALS( false, Dali::Accessibility::TestGetMoveOutedCalled(), TEST_LOCATION );
 
@@ -1227,7 +1228,7 @@ int UtcDaliAccessibilityCheckHighlight(void)
   // B: (0,100) --> (0, 50)
   buttonB.SetProperty( Dali::Actor::Property::POSITION, Dali::Vector2(0.0f, 50.0f) );
   Wait(application);
-  // Need one more seding notificaiton to get correct updated position
+  // Need one more notificaiton to get correct updated position
   application.SendNotification();
   DALI_TEST_EQUALS( false, Dali::Accessibility::TestGetMoveOutedCalled(), TEST_LOCATION );
 
@@ -1235,9 +1236,9 @@ int UtcDaliAccessibilityCheckHighlight(void)
   Dali::Accessibility::TestResetMoveOutedCalled();
 
   // Move second child (B) out of parent area through the parent's area right edge - single move outed event expected for B object and OUTGOING_BOTTOM_RIGHT direction
-  buttonB.SetProperty( Dali::Actor::Property::POSITION, Dali::Vector2(300.0f, 100.0f) );
+  buttonB.SetProperty(Actor::Property::POSITION, Dali::Vector2(300.0f, 100.0f));
   Wait(application);
-  // Need one more seding notificaiton to get correct updated position
+  // Need one more notificaiton to get correct updated position
   application.SendNotification();
   DALI_TEST_EQUALS( true, Dali::Accessibility::TestGetMoveOutedCalled(), TEST_LOCATION );
 
index b704578..9f1c78e 100644 (file)
@@ -200,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<bool>() || !self.GetCurrentProperty<bool>(Actor::Property::VISIBLE))
+  {
+    return false;
+  }
+
+  auto* child  = this;
+  auto* parent = dynamic_cast<Toolkit::DevelControl::AccessibleImpl*>(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<bool>();
+    auto parentExtent = parent->GetExtents(Dali::Accessibility::CoordinateType::WINDOW);
+    if ((clipMode != ClippingMode::DISABLED) && !parentExtent.Intersects(childExtent))
+    {
+      return false;
+    }
+    parent = dynamic_cast<Toolkit::DevelControl::AccessibleImpl*>(parent->GetParent());
+  }
+
+  return true;
+}
+
 Dali::Accessibility::States AccessibleImpl::CalculateStates()
 {
   Dali::Actor self = Self();
@@ -225,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<bool>() && self.GetCurrentProperty<bool>(Actor::Property::VISIBLE);
-
+  state[Dali::Accessibility::State::SHOWING] = IsShowing();
   state[Dali::Accessibility::State::DEFUNCT] = !self.GetProperty(Dali::DevelActor::Property::CONNECTED_TO_SCENE).Get<bool>();
   return state;
 }
index c8c1361..aa5084a 100644 (file)
@@ -76,6 +76,12 @@ protected:
    */
   void UnregisterPositionPropertyNotification();
 
+  /**
+   * @brief Check if the actor is showing
+   * @return True if the actor is showing
+   */
+  bool IsShowing();
+
 public:
   AccessibleImpl(Dali::Actor self, Dali::Accessibility::Role role, bool modal = false);
 
index 952c261..a7324b8 100644 (file)
@@ -37,6 +37,8 @@ namespace FocusFinder
 {\r
 namespace\r
 {\r
+static constexpr float FULLY_TRANSPARENT(0.01f); ///< Alpha values must rise above this, before an object is considered to be visible.\r
+\r
 static int MajorAxisDistanceRaw(Dali::Toolkit::Control::KeyboardFocus::Direction direction, Dali::Rect<float> source, Dali::Rect<float> dest)\r
 {\r
   switch(direction)\r
@@ -127,17 +129,15 @@ static int MinorAxisDistance(Dali::Toolkit::Control::KeyboardFocus::Direction di
     case Dali::Toolkit::Control::KeyboardFocus::RIGHT:\r
     {\r
       // the distance between the center verticals\r
-      return std::abs(\r
-        (((source.top + source.bottom) * 0.5f) -\r
-         (((dest.top + dest.bottom) * 0.5f))));\r
+      return std::abs((source.top + (source.bottom - source.top) * 0.5f) -\r
+                      (dest.top + (dest.bottom - dest.top) * 0.5f));\r
     }\r
     case Dali::Toolkit::Control::KeyboardFocus::UP:\r
     case Dali::Toolkit::Control::KeyboardFocus::DOWN:\r
     {\r
       // the distance between the center horizontals\r
-      return std::abs(\r
-        (((source.left + source.right) * 0.5f) -\r
-         (((dest.left + dest.right) * 0.5f))));\r
+      return std::abs((source.left + (source.right - source.left) * 0.5f) -\r
+                      (dest.left + (dest.right - dest.left) * 0.5f));\r
     }\r
     default:\r
     {\r
@@ -188,19 +188,19 @@ static bool IsCandidate(Dali::Rect<float> srcRect, Dali::Rect<float> destRect, D
   {\r
     case Dali::Toolkit::Control::KeyboardFocus::LEFT:\r
     {\r
-      return (srcRect.right > destRect.right || srcRect.left >= destRect.right) && srcRect.left > destRect.left;\r
+      return (srcRect.right > destRect.right || srcRect.left >= destRect.right);\r
     }\r
     case Dali::Toolkit::Control::KeyboardFocus::RIGHT:\r
     {\r
-      return (srcRect.left < destRect.left || srcRect.right <= destRect.left) && srcRect.right < destRect.right;\r
+      return (srcRect.left < destRect.left || srcRect.right <= destRect.left);\r
     }\r
     case Dali::Toolkit::Control::KeyboardFocus::UP:\r
     {\r
-      return (srcRect.bottom > destRect.bottom || srcRect.top >= destRect.bottom) && srcRect.top > destRect.top;\r
+      return (srcRect.bottom > destRect.bottom || srcRect.top >= destRect.bottom);\r
     }\r
     case Dali::Toolkit::Control::KeyboardFocus::DOWN:\r
     {\r
-      return (srcRect.top < destRect.top || srcRect.bottom <= destRect.top) && srcRect.bottom < destRect.bottom;\r
+      return (srcRect.top < destRect.top || srcRect.bottom <= destRect.top);\r
     }\r
     default:\r
     {\r
@@ -340,6 +340,14 @@ bool IsBetterCandidate(Toolkit::Control::KeyboardFocus::Direction direction, Rec
                                                                                                MinorAxisDistance(direction, focusedRect, bestCandidateRect)));\r
 }\r
 \r
+bool IsFocusable(Actor& actor)\r
+{\r
+  return (actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) &&\r
+          actor.GetProperty<bool>(Actor::Property::VISIBLE) &&\r
+          actor.GetProperty<bool>(Actor::Property::SENSITIVE) &&\r
+          actor.GetProperty<Vector4>(Actor::Property::WORLD_COLOR).a > FULLY_TRANSPARENT);\r
+}\r
+\r
 Actor FindNextFocus(Actor& actor, Actor& focusedActor, Rect<float>& focusedRect, Rect<float>& bestCandidateRect, Toolkit::Control::KeyboardFocus::Direction direction)\r
 {\r
   Actor nearestActor;\r
@@ -350,7 +358,7 @@ Actor FindNextFocus(Actor& actor, Actor& focusedActor, Rect<float>& focusedRect,
     for(auto i = 0u; i < childCount; ++i)\r
     {\r
       Dali::Actor child = actor.GetChildAt(i);\r
-      if(child && child != focusedActor && child.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE))\r
+      if(child && child != focusedActor && IsFocusable(child))\r
       {\r
         Rect<float> candidateRect = DevelActor::CalculateScreenExtents(child);\r
 \r
index 632815e..0a4cd44 100644 (file)
@@ -100,12 +100,6 @@ Requires:   %{dali2_scene_loader} = %{version}-%{release}
 %description -n %{dali2_scene_loader}-devel
 Development components for dali-scene-loader.
 
-##############################
-# Preparation
-##############################
-%prep
-%setup -q
-
 %define dali_data_rw_dir            %TZ_SYS_SHARE/dali/
 %define dali_data_ro_dir            %TZ_SYS_RO_SHARE/dali/
 
@@ -116,6 +110,16 @@ Development components for dali-scene-loader.
 
 %define dali_xml_file_dir     %TZ_SYS_RO_PACKAGES
 
+##############################
+# Preparation
+##############################
+%prep
+%setup -q
+
+##############################
+# Build
+##############################
+%build
 # PO
 {
 cd %{_builddir}/dali2-toolkit-%{version}/dali-toolkit/po
@@ -126,10 +130,6 @@ do
 done
 } &> /dev/null
 
-##############################
-# Build
-##############################
-%build
 PREFIX="/usr"
 CXXFLAGS+=" -Wall -g -Os -fPIC -fvisibility-inlines-hidden -fdata-sections -ffunction-sections "
 LDFLAGS+=" -Wl,--rpath=$PREFIX/lib -Wl,--as-needed -Wl,--gc-sections -Wl,-Bsymbolic-functions "