mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 07:01:24 +00:00
优化获取最大宽度逻辑
Signed-off-by: wangzhihao <wangzhihao42@huawei.com>
This commit is contained in:
parent
c6bbe25854
commit
977711ccdd
@ -176,21 +176,4 @@ SystemGridInfo GridSystemManager::GetSystemGridInfo(const GridTemplateType& temp
|
||||
return GRID_TEMPLATE_COLUMNS_12;
|
||||
}
|
||||
}
|
||||
|
||||
double GridSystemManager::GetMaxWidthWithColumnType(GridColumnType gridColumnType)
|
||||
{
|
||||
RefPtr<GridColumnInfo> columnInfo = GridSystemManager::GetInstance().GetInfoByType(gridColumnType);
|
||||
if (columnInfo->GetParent()) {
|
||||
columnInfo->GetParent()->BuildColumnWidth();
|
||||
}
|
||||
auto gridSizeType = GridSystemManager::GetInstance().GetCurrentSize();
|
||||
if (gridSizeType > GridSizeType::LG) {
|
||||
gridSizeType = GridSizeType::LG;
|
||||
}
|
||||
if (gridSizeType < GridSizeType::SM) {
|
||||
gridSizeType = GridSizeType::SM;
|
||||
}
|
||||
auto columns = columnInfo->GetColumns(gridSizeType);
|
||||
return columnInfo->GetWidth(columns);
|
||||
}
|
||||
} // namespace OHOS::Ace
|
||||
|
@ -75,8 +75,6 @@ public:
|
||||
return ScreenSystemManager::GetInstance().GetDensity();
|
||||
}
|
||||
|
||||
double GetMaxWidthWithColumnType(GridColumnType gridColumnType);
|
||||
|
||||
private:
|
||||
GridSystemManager() = default;
|
||||
|
||||
|
@ -3290,7 +3290,7 @@ std::vector<FrameNode*> FrameNode::GetNodesPtrById(const std::unordered_set<int3
|
||||
double FrameNode::GetPreviewScaleVal() const
|
||||
{
|
||||
double scale = 1.0;
|
||||
auto maxWidth = GridSystemManager::GetInstance().GetMaxWidthWithColumnType(GridColumnType::DRAG_PANEL);
|
||||
auto maxWidth = DragDropManager::GetMaxWidthBaseOnGridSystem(GetContextRefPtr());
|
||||
auto geometryNode = GetGeometryNode();
|
||||
CHECK_NULL_RETURN(geometryNode, scale);
|
||||
auto width = geometryNode->GetFrameRect().Width();
|
||||
|
@ -842,7 +842,7 @@ void UINode::GenerateOneDepthAllFrame(std::list<RefPtr<FrameNode>>& visibleList)
|
||||
}
|
||||
}
|
||||
|
||||
PipelineContext* UINode::GetContext()
|
||||
PipelineContext* UINode::GetContext() const
|
||||
{
|
||||
PipelineContext* context = nullptr;
|
||||
if (context_) {
|
||||
@ -871,7 +871,7 @@ PipelineContext* UINode::GetContextWithCheck()
|
||||
return PipelineContext::GetCurrentContextPtrSafelyWithCheck();
|
||||
}
|
||||
|
||||
RefPtr<PipelineContext> UINode::GetContextRefPtr()
|
||||
RefPtr<PipelineContext> UINode::GetContextRefPtr() const
|
||||
{
|
||||
auto* context = GetContext();
|
||||
return Claim(context);
|
||||
|
@ -182,10 +182,10 @@ public:
|
||||
// Tree operation end.
|
||||
|
||||
// performance.
|
||||
PipelineContext* GetContext();
|
||||
PipelineContext* GetContext() const;
|
||||
PipelineContext* GetContextWithCheck();
|
||||
|
||||
RefPtr<PipelineContext> GetContextRefPtr();
|
||||
RefPtr<PipelineContext> GetContextRefPtr() const;
|
||||
|
||||
// When FrameNode creates a layout task, the corresponding LayoutWrapper tree is created, and UINode needs to update
|
||||
// the corresponding LayoutWrapper tree node at this time like add self wrapper to wrapper tree.
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "core/components_ng/gestures/recognizers/pinch_recognizer.h"
|
||||
#include "core/components_ng/gestures/recognizers/rotation_recognizer.h"
|
||||
#include "core/components_ng/gestures/recognizers/swipe_recognizer.h"
|
||||
#include "core/components_ng/manager/drag_drop/drag_drop_manager.h"
|
||||
#include "core/components_ng/manager/drag_drop/utils/drag_animation_helper.h"
|
||||
#include "core/components_ng/pattern/image/image_pattern.h"
|
||||
#include "core/components_ng/pattern/text_drag/text_drag_base.h"
|
||||
@ -429,7 +430,7 @@ bool GestureEventHub::IsPixelMapNeedScale() const
|
||||
auto frameNode = GetFrameNode();
|
||||
CHECK_NULL_RETURN(frameNode, false);
|
||||
auto width = pixelMap_->GetWidth();
|
||||
auto maxWidth = GridSystemManager::GetInstance().GetMaxWidthWithColumnType(GridColumnType::DRAG_PANEL);
|
||||
auto maxWidth = DragDropManager::GetMaxWidthBaseOnGridSystem(frameNode->GetContextRefPtr());
|
||||
if (!frameNode->GetDragPreviewOption().isScaleEnabled || width == 0 || width < maxWidth) {
|
||||
return false;
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ static bool CheckInternalDragging(const RefPtr<Container>& container)
|
||||
void GetShadowInfoArray(
|
||||
std::shared_ptr<OHOS::Ace::NG::ArkUIInteralDragAction> dragAction, std::vector<ShadowInfoCore>& shadowInfos)
|
||||
{
|
||||
auto minScaleWidth = GridSystemManager::GetInstance().GetMaxWidthWithColumnType(GridColumnType::DRAG_PANEL);
|
||||
auto minScaleWidth = NG::DragDropFuncWrapper::GetScaleWidth(dragAction->instanceId);
|
||||
for (auto& pixelMap : dragAction->pixelMapList) {
|
||||
double scale = 1.0;
|
||||
if (pixelMap.GetRawPtr()) {
|
||||
@ -474,4 +474,11 @@ std::optional<EffectOption> DragDropFuncWrapper::BrulStyleToEffection(
|
||||
return std::optional<EffectOption>(bgEffection);
|
||||
}
|
||||
|
||||
[[maybe_unused]] double DragDropFuncWrapper::GetScaleWidth(int32_t containerId)
|
||||
{
|
||||
auto pipeline = Container::GetContainer(containerId)->GetPipelineContext();
|
||||
CHECK_NULL_RETURN(pipeline, -1.0f);
|
||||
return DragDropManager::GetMaxWidthBaseOnGridSystem(pipeline);
|
||||
}
|
||||
|
||||
} // namespace OHOS::Ace
|
||||
|
@ -45,6 +45,7 @@ public:
|
||||
static std::optional<BorderRadiusProperty> GetDefaultBorderRadius();
|
||||
static float RadiusToSigma(float radius);
|
||||
static std::optional<EffectOption> BrulStyleToEffection(const std::optional<BlurStyleOption>& blurStyleOp);
|
||||
[[maybe_unused]] static double GetScaleWidth(int32_t containerId);
|
||||
};
|
||||
} // namespace OHOS::Ace::NG
|
||||
|
||||
|
@ -14,14 +14,17 @@
|
||||
*/
|
||||
|
||||
#include "core/components_ng/manager/drag_drop/drag_drop_manager.h"
|
||||
#include "drag_drop_manager.h"
|
||||
|
||||
#include "base/geometry/ng/offset_t.h"
|
||||
#include "base/geometry/point.h"
|
||||
#include "base/subwindow/subwindow_manager.h"
|
||||
#include "base/utils/system_properties.h"
|
||||
#include "base/utils/utils.h"
|
||||
#include "core/common/interaction/interaction_data.h"
|
||||
#include "core/common/interaction/interaction_interface.h"
|
||||
#include "core/components/common/layout/grid_system_manager.h"
|
||||
#include "core/components/common/layout/grid_column_info.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/root/root_pattern.h"
|
||||
@ -1507,7 +1510,7 @@ bool DragDropManager::GetDragPreviewInfo(const RefPtr<OverlayManager>& overlayMa
|
||||
if (badgeNode) {
|
||||
dragPreviewInfo.textNode = badgeNode;
|
||||
}
|
||||
double maxWidth = GridSystemManager::GetInstance().GetMaxWidthWithColumnType(GridColumnType::DRAG_PANEL);
|
||||
double maxWidth = DragDropManager::GetMaxWidthBaseOnGridSystem(imageNode->GetContextRefPtr());
|
||||
auto width = imageNode->GetGeometryNode()->GetFrameRect().Width();
|
||||
dragPreviewInfo.scale = static_cast<float>(imageNode->GetPreviewScaleVal());
|
||||
if (!isMouseDragged_ && dragPreviewInfo.scale == 1.0f) {
|
||||
@ -2012,4 +2015,34 @@ bool DragDropManager::IsUIExtensionComponent(const RefPtr<NG::UINode>& node)
|
||||
return (V2::UI_EXTENSION_COMPONENT_ETS_TAG == node->GetTag() || V2::EMBEDDED_COMPONENT_ETS_TAG == node->GetTag()) &&
|
||||
(!IsUIExtensionShowPlaceholder(node));
|
||||
}
|
||||
|
||||
double DragDropManager::GetMaxWidthBaseOnGridSystem(const RefPtr<PipelineBase>& pipeline)
|
||||
{
|
||||
auto context = DynamicCast<NG::PipelineContext>(pipeline);
|
||||
CHECK_NULL_RETURN(context, -1.0f);
|
||||
auto dragDropMgr = context->GetDragDropManager();
|
||||
CHECK_NULL_RETURN(dragDropMgr, -1.0f);
|
||||
auto& columnInfo = dragDropMgr->columnInfo_;
|
||||
if (!columnInfo) {
|
||||
columnInfo = GridSystemManager::GetInstance().GetInfoByType(GridColumnType::DRAG_PANEL);
|
||||
auto gridContainer = columnInfo->GetParent();
|
||||
if (gridContainer) {
|
||||
// cannot handle multi-screen
|
||||
gridContainer->BuildColumnWidth(context->GetRootWidth());
|
||||
}
|
||||
dragDropMgr->columnInfo_ = columnInfo;
|
||||
}
|
||||
|
||||
auto gridSizeType = GridSystemManager::GetInstance().GetCurrentSize();
|
||||
if (gridSizeType > GridSizeType::LG) {
|
||||
gridSizeType = GridSizeType::LG;
|
||||
}
|
||||
if (gridSizeType < GridSizeType::SM) {
|
||||
gridSizeType = GridSizeType::SM;
|
||||
}
|
||||
auto columns = columnInfo->GetColumns(gridSizeType);
|
||||
double maxWidth = columnInfo->GetWidth(columns);
|
||||
return maxWidth;
|
||||
}
|
||||
|
||||
} // namespace OHOS::Ace::NG
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
namespace OHOS::Ace {
|
||||
class UnifiedData;
|
||||
class GridColumnInfo;
|
||||
}
|
||||
namespace OHOS::Ace::NG {
|
||||
enum class DragDropMgrState : int32_t {
|
||||
@ -472,6 +473,8 @@ public:
|
||||
|
||||
float GetCurrentDistance(float x, float y);
|
||||
|
||||
static double GetMaxWidthBaseOnGridSystem(const RefPtr<PipelineBase>& pipeline);
|
||||
|
||||
private:
|
||||
double CalcDragPreviewDistanceWithPoint(
|
||||
const OHOS::Ace::Dimension& preserverHeight, int32_t x, int32_t y, const DragPreviewInfo& info);
|
||||
@ -573,7 +576,7 @@ private:
|
||||
OffsetF lastDragMovePosition_ = OffsetF(0.0f, 0.0f);
|
||||
OffsetF dragTotalMovePosition_ = OffsetF(0.0f, 0.0f);
|
||||
std::shared_ptr<OHOS::Ace::NG::ArkUIInteralDragAction> dragAction_;
|
||||
|
||||
RefPtr<GridColumnInfo> columnInfo_;
|
||||
ACE_DISALLOW_COPY_AND_MOVE(DragDropManager);
|
||||
};
|
||||
} // namespace OHOS::Ace::NG
|
||||
|
@ -621,7 +621,7 @@ void GetShadowInfoArray(DragControllerAsyncCtx* asyncCtx,
|
||||
std::vector<Msdp::DeviceStatus::ShadowInfo>& shadowInfos)
|
||||
{
|
||||
std::set<Media::PixelMap*> scaledPixelMaps;
|
||||
auto minScaleWidth = GridSystemManager::GetInstance().GetMaxWidthWithColumnType(GridColumnType::DRAG_PANEL);
|
||||
auto minScaleWidth = NG::DragDropFuncWrapper::GetScaleWidth(asyncCtx->instanceId);
|
||||
for (const auto& pixelMap: asyncCtx->pixelMapList) {
|
||||
double scale = 1.0;
|
||||
if (!scaledPixelMaps.count(pixelMap.get())) {
|
||||
@ -842,7 +842,7 @@ void OnComplete(DragControllerAsyncCtx* asyncCtx)
|
||||
dataSize = badgeNumber.value();
|
||||
}
|
||||
double scale = 1.0;
|
||||
auto minScaleWidth = GridSystemManager::GetInstance().GetMaxWidthWithColumnType(GridColumnType::DRAG_PANEL);
|
||||
auto minScaleWidth = NG::DragDropFuncWrapper::GetScaleWidth(asyncCtx->instanceId);
|
||||
if (asyncCtx->pixelMap->GetWidth() > minScaleWidth && asyncCtx->dragPreviewOption.isScaleEnabled) {
|
||||
scale = minScaleWidth / asyncCtx->pixelMap->GetWidth();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user