mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-27 01:03:08 +00:00
commit
89a548c466
@ -140,7 +140,7 @@ TextDragData TextDragPattern::CalculateTextDragData(RefPtr<TextDragBase>& patter
|
||||
}
|
||||
} else {
|
||||
globalX = contentRect.Left() + globalOffset.GetX() - dragOffset;
|
||||
width = contentRect.Width();
|
||||
AdjustMaxWidth(width, contentRect, boxes);
|
||||
}
|
||||
float contentX = (leftHandler.GetY() == rightHandler.GetY() ? box.Left() : 0) - dragOffset - delta / CONSTANT_HALF;
|
||||
dragPattern->SetContentOffset({contentX, box.Top() - dragOffset});
|
||||
@ -156,6 +156,20 @@ TextDragData TextDragPattern::CalculateTextDragData(RefPtr<TextDragBase>& patter
|
||||
return data;
|
||||
}
|
||||
|
||||
void TextDragPattern::AdjustMaxWidth(float& width, const RectF& contentRect, const std::vector<RectF>& boxes)
|
||||
{
|
||||
width = contentRect.Width();
|
||||
CHECK_NULL_VOID(!boxes.empty());
|
||||
float startX = boxes.front().Left();
|
||||
float endX = boxes.front().Right();
|
||||
for (const auto& box : boxes) {
|
||||
startX = std::min(startX, box.Left());
|
||||
endX = std::max(endX, box.Right());
|
||||
}
|
||||
startX = std::min(0.0f, startX);
|
||||
width = std::abs(startX - endX);
|
||||
}
|
||||
|
||||
RectF TextDragPattern::GetHandler(const bool isLeftHandler, const std::vector<RectF> boxes, const RectF contentRect,
|
||||
const OffsetF globalOffset, const OffsetF textStartOffset)
|
||||
{
|
||||
|
@ -212,6 +212,7 @@ public:
|
||||
Color GetDragBackgroundColor();
|
||||
protected:
|
||||
static TextDragData CalculateTextDragData(RefPtr<TextDragBase>& pattern, RefPtr<FrameNode>& dragNode);
|
||||
static void AdjustMaxWidth(float& width, const RectF& contentRect, const std::vector<RectF>& boxes);
|
||||
static RectF GetHandler(const bool isLeftHandler, const std::vector<RectF> boxes, const RectF contentRect,
|
||||
const OffsetF globalOffset, const OffsetF textStartOffset);
|
||||
static void AdjustHandlers(const RectF contentRect, RectF& leftHandler, RectF& rightHandler);
|
||||
|
@ -297,7 +297,7 @@ HWTEST_F(TextDragTestNg, TextDragCreateNodeTestNg003, TestSize.Level1)
|
||||
* @tc.expected: lastLineHeight/textRect/contentoffset as expected.
|
||||
*/
|
||||
EXPECT_EQ(dragPattern_->GetContentOffset(), OffsetF(-8.f, 32.f));
|
||||
EXPECT_EQ(dragPattern_->GetTextRect(), RectF(8.f, -32.f, 460.f, 160.f));
|
||||
EXPECT_EQ(dragPattern_->GetTextRect(), RectF(8.f, -32.f, 160.f, 160.f));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user