Merge "Allows you to specify the root when calculating the focus movement algorithm...
authorjoogab yun <joogab.yun@samsung.com>
Tue, 3 May 2022 06:56:51 +0000 (06:56 +0000)
committerGerrit Code Review <gerrit@review>
Tue, 3 May 2022 06:56:51 +0000 (06:56 +0000)
dali-scene-loader/public-api/shader-definition.h
dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp

index 5d0a49e..386a0c9 100644 (file)
@@ -80,7 +80,7 @@ public: // DATA
   std::vector<std::string> mDefines;
   std::vector<std::string> mHints;
   Property::Map            mUniforms;
-  bool                     mUseBuiltInShader;
+  bool                     mUseBuiltInShader{false};
 };
 
 } // namespace SceneLoader
index 0dceb47..3779e35 100644 (file)
@@ -530,6 +530,17 @@ void SnapWithVelocity(
   }
 }
 
+Dali::Vector2 GetPosition(Dali::Actor actor)
+{
+  Vector2     screenPosition          = actor.GetProperty<Vector2>(Actor::Property::SCREEN_POSITION);
+  Vector3     size                    = actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE) * actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE);
+  bool        positionUsesAnchorPoint = actor.GetProperty<bool>(Actor::Property::POSITION_USES_ANCHOR_POINT);
+  Vector3     anchorPointOffSet       = size * (positionUsesAnchorPoint ? actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT) : AnchorPoint::TOP_LEFT);
+  Vector2     position                = Vector2(screenPosition.x - anchorPointOffSet.x, screenPosition.y - anchorPointOffSet.y);
+
+  return position;
+}
+
 } // unnamed namespace
 
 namespace Dali
@@ -1272,21 +1283,11 @@ bool ScrollView::ScrollViewAccessible::ScrollToChild(Actor child)
     return false;
   }
 
-  // child can be one of descendants
-  // find direct child of ScrollView to avoid the ASSERT in ScrollTo
-  auto parent = child.GetParent();
-  while (parent && parent != Self())
-  {
-    child = parent;
-    parent = child.GetParent();
-  }
-  if (!parent)
-  {
-    return false;
-  }
+  auto childPosition = GetPosition(child);
+  auto selfPosition  = GetPosition(Self());
+
+  scrollView.ScrollTo(childPosition - selfPosition, scrollView.GetScrollFlickDuration());
 
-  // FIXME: ScrollTo does not work (snaps back to original position)
-  scrollView.ScrollTo(child, scrollView.GetScrollFlickDuration());
   return true;
 }