!47056 GetPaintRectCenter整改

Merge pull request !47056 from 贺晨韬/hct_fix_codeformat_1
This commit is contained in:
openharmony_ci 2024-10-31 02:54:31 +00:00 committed by Gitee
commit 0cd5dc026a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
9 changed files with 41 additions and 38 deletions

View File

@ -3424,33 +3424,6 @@ RectF FrameNode::GetPaintRectToWindowWithTransform()
return GetBoundingBox(pointList);
}
// returns a node's offset relative to window plus half of self rect size(w, h)
// and accumulate every ancestor node's graphic properties such as rotate and transform
// ancestor will NOT check boundary of window scene
OffsetF FrameNode::GetPaintRectCenter(bool checkWindowBoundary) const
{
auto context = GetRenderContext();
CHECK_NULL_RETURN(context, OffsetF());
auto paintRect = context->GetPaintRectWithoutTransform();
auto offset = paintRect.GetOffset();
PointF pointNode(offset.GetX() + paintRect.Width() / 2.0f, offset.GetY() + paintRect.Height() / 2.0f);
context->GetPointTransformRotate(pointNode);
auto parent = GetAncestorNodeOfFrame();
while (parent) {
if (checkWindowBoundary && parent->IsWindowBoundary()) {
break;
}
auto renderContext = parent->GetRenderContext();
CHECK_NULL_RETURN(renderContext, OffsetF());
offset = renderContext->GetPaintRectWithoutTransform().GetOffset();
pointNode.SetX(offset.GetX() + pointNode.GetX());
pointNode.SetY(offset.GetY() + pointNode.GetY());
renderContext->GetPointTransformRotate(pointNode);
parent = parent->GetAncestorNodeOfFrame();
}
return OffsetF(pointNode.GetX(), pointNode.GetY());
}
// returns a node's geometry offset relative to window
// used when a node is in the process of layout
// because offset during layout is NOT synced to renderContext yet

View File

@ -460,8 +460,6 @@ public:
RectF GetPaintRectToWindowWithTransform();
OffsetF GetPaintRectCenter(bool checkWindowBoundary = true) const;
std::pair<OffsetF, bool> GetPaintRectGlobalOffsetWithTranslate(bool excludeSelf = false) const;
OffsetF GetPaintRectOffsetToPage() const;

View File

@ -28,6 +28,7 @@
#include "core/components_ng/base/inspector.h"
#include "core/components_ng/event/gesture_event_hub.h"
#include "core/components_ng/event/gesture_info.h"
#include "core/components_ng/manager/drag_drop/drag_drop_func_wrapper.h"
#include "core/components_ng/manager/drag_drop/utils/drag_animation_helper.h"
#include "core/components_ng/pattern/grid/grid_item_pattern.h"
#include "core/components_ng/pattern/list/list_item_pattern.h"
@ -951,7 +952,7 @@ void DragEventActuator::SetFilter(const RefPtr<DragEventActuator>& actuator)
OffsetF DragEventActuator::GetFloatImageOffset(const RefPtr<FrameNode>& frameNode, const RefPtr<PixelMap>& pixelMap)
{
CHECK_NULL_RETURN(frameNode, OffsetF());
auto centerPosition = frameNode->GetPaintRectCenter(true);
auto centerPosition = DragDropFuncWrapper::GetPaintRectCenter(frameNode, true);
float width = 0.0f;
float height = 0.0f;
if (pixelMap) {
@ -1047,7 +1048,7 @@ void DragEventActuator::CreatePreviewNode(
CHECK_NULL_VOID(frameNode);
auto pixelMap = frameNode->GetPixelMap();
CHECK_NULL_VOID(pixelMap);
auto center = frameNode->GetPaintRectCenter();
auto center = DragDropFuncWrapper::GetPaintRectCenter(frameNode);
auto frameOffset = OffsetF(center.GetX() - (pixelMap->GetWidth() / 2.0f),
center.GetY() - (pixelMap->GetHeight() / 2.0f));
imageNode = FrameNode::GetOrCreateFrameNode(V2::IMAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(),

View File

@ -230,7 +230,7 @@ void GestureEventHub::CalcFrameNodeOffsetAndSize(const RefPtr<FrameNode> frameNo
} else {
frameNodeSize_ = SizeF(0.0f, 0.0f);
}
auto rectCenter = frameNode->GetPaintRectCenter(false);
auto rectCenter = DragDropFuncWrapper::GetPaintRectCenter(frameNode, false);
frameNodeOffset_ = OffsetF(
rectCenter.GetX() - frameNodeSize_.Width() / 2.0f, rectCenter.GetY() - frameNodeSize_.Height() / 2.0f);
#ifdef WEB_SUPPORTED

View File

@ -519,4 +519,31 @@ std::string DragDropFuncWrapper::GetAnonyString(const std::string &fullString)
}
return anonyStr;
}
// returns a node's offset relative to window plus half of self rect size(w, h)
// and accumulate every ancestor node's graphic properties such as rotate and transform
// ancestor will NOT check boundary of window scene
OffsetF DragDropFuncWrapper::GetPaintRectCenter(const RefPtr<FrameNode>& frameNode, bool checkWindowBoundary)
{
auto context = frameNode->GetRenderContext();
CHECK_NULL_RETURN(context, OffsetF());
auto paintRect = context->GetPaintRectWithoutTransform();
auto offset = paintRect.GetOffset();
PointF pointNode(offset.GetX() + paintRect.Width() / 2.0f, offset.GetY() + paintRect.Height() / 2.0f);
context->GetPointTransformRotate(pointNode);
auto parent = frameNode->GetAncestorNodeOfFrame();
while (parent) {
if (checkWindowBoundary && parent->IsWindowBoundary()) {
break;
}
auto renderContext = parent->GetRenderContext();
CHECK_NULL_RETURN(renderContext, OffsetF());
offset = renderContext->GetPaintRectWithoutTransform().GetOffset();
pointNode.SetX(offset.GetX() + pointNode.GetX());
pointNode.SetY(offset.GetY() + pointNode.GetY());
renderContext->GetPointTransformRotate(pointNode);
parent = parent->GetAncestorNodeOfFrame();
}
return OffsetF(pointNode.GetX(), pointNode.GetY());
}
} // namespace OHOS::Ace

View File

@ -49,6 +49,7 @@ public:
static std::string GetSummaryString(const std::map<std::string, int64_t>& summary);
static void SetExtraInfo(int32_t containerId, std::string extraInfo);
static std::string GetAnonyString(const std::string &fullString);
static OffsetF GetPaintRectCenter(const RefPtr<FrameNode>& frameNode, bool checkWindowBoundary = true);
};
} // namespace OHOS::Ace::NG

View File

@ -27,6 +27,7 @@
#include "core/components/common/layout/grid_column_info.h"
#include "core/components/common/layout/grid_system_manager.h"
#include "core/components_ng/base/frame_node.h"
#include "core/components_ng/manager/drag_drop/drag_drop_func_wrapper.h"
#include "core/components_ng/pattern/grid/grid_event_hub.h"
#include "core/components_ng/pattern/list/list_event_hub.h"
#include "core/components_ng/pattern/menu/wrapper/menu_wrapper_pattern.h"
@ -1732,7 +1733,7 @@ float DragDropManager::GetCurrentDistance(float x, float y)
auto subwindow = SubwindowManager::GetInstance()->GetSubwindow(containerId);
CHECK_NULL_RETURN(subwindow, distance);
auto overlayManager = subwindow->GetOverlayManager();
auto gatherNodeCenter = info_.imageNode->GetPaintRectCenter();
auto gatherNodeCenter = DragDropFuncWrapper::GetPaintRectCenter(info_.imageNode);
auto gatherDistance = CalcGatherNodeMaxDistanceWithPoint(overlayManager,
gatherNodeCenter.GetX(), gatherNodeCenter.GetY());
return std::max(distance, gatherDistance);
@ -1838,7 +1839,7 @@ void DragDropManager::DoDragStartAnimation(const RefPtr<OverlayManager>& overlay
CHECK_NULL_VOID(info_.imageNode);
isDragFwkShow_ = false;
ResetPullMoveReceivedForCurrentDrag();
auto gatherNodeCenter = info_.imageNode->GetPaintRectCenter();
auto gatherNodeCenter = DragDropFuncWrapper::GetPaintRectCenter(info_.imageNode);
Point point = { static_cast<int32_t>(event.GetGlobalLocation().GetX()),
static_cast<int32_t>(event.GetGlobalLocation().GetY()) };
Offset newOffset = CalcDragMoveOffset(PRESERVE_HEIGHT, static_cast<int32_t>(event.GetGlobalLocation().GetX()),
@ -2014,7 +2015,7 @@ void DragDropManager::UpdateGatherNodePosition(const RefPtr<OverlayManager>& ove
const RefPtr<FrameNode>& imageNode)
{
CHECK_NULL_VOID(imageNode);
auto gatherNodeCenter = imageNode->GetPaintRectCenter();
auto gatherNodeCenter = DragDropFuncWrapper::GetPaintRectCenter(imageNode);
CHECK_NULL_VOID(overlayManager);
Dimension x = Dimension(0.0f);
Dimension y = Dimension(0.0f);

View File

@ -14,6 +14,7 @@
*/
#include "core/components_ng/manager/drag_drop/utils/drag_animation_helper.h"
#include "core/components_ng/manager/drag_drop/drag_drop_func_wrapper.h"
#include "core/components_ng/pattern/menu/menu_theme.h"
namespace OHOS::Ace::NG {
@ -96,7 +97,7 @@ void DragAnimationHelper::PlayGatherNodeTranslateAnimation(const RefPtr<DragEven
option.SetCurve(Curves::SHARP);
auto frameNode = actuator->GetFrameNode();
CHECK_NULL_VOID(frameNode);
auto gatherNodeCenter = frameNode->GetPaintRectCenter();
auto gatherNodeCenter = DragDropFuncWrapper::GetPaintRectCenter(frameNode);
auto gatherNodeChildrenInfo = overlayManager->GetGatherNodeChildrenInfo();
bool isGrid = frameNode->GetTag() == V2::GRID_ITEM_ETS_TAG;
@ -221,7 +222,7 @@ void DragAnimationHelper::PlayGatherAnimation(const RefPtr<FrameNode>& frameNode
{
TAG_LOGI(AceLogTag::ACE_DRAG, "Play gather animation");
CHECK_NULL_VOID(frameNode);
auto gatherNodeCenter = frameNode->GetPaintRectCenter();
auto gatherNodeCenter = DragDropFuncWrapper::GetPaintRectCenter(frameNode);
CHECK_NULL_VOID(overlayManager);
auto gatherNodeChildrenInfo = overlayManager->GetGatherNodeChildrenInfo();
BorderRadiusProperty borderRadius;

View File

@ -54,6 +54,7 @@
#include "core/components_ng/base/view_abstract.h"
#include "core/components_ng/base/view_stack_processor.h"
#include "core/components_ng/event/focus_hub.h"
#include "core/components_ng/manager/drag_drop/drag_drop_func_wrapper.h"
#include "core/components_ng/manager/drag_drop/drag_drop_global_controller.h"
#include "core/components_ng/manager/focus/focus_view.h"
#include "core/components_ng/pattern/bubble/bubble_event_hub.h"
@ -698,7 +699,7 @@ bool OverlayManager::GetMenuPreviewCenter(NG::OffsetF& offset)
if (geometryNode && geometryNode->GetFrameRect().IsEmpty()) {
return false;
}
auto previewOffset = previewChild->GetPaintRectCenter();
auto previewOffset = DragDropFuncWrapper::GetPaintRectCenter(previewChild);
offset.SetX(previewOffset.GetX());
offset.SetY(previewOffset.GetY());
return true;