diff --git a/adapter/ohos/entrance/ui_content_impl.cpp b/adapter/ohos/entrance/ui_content_impl.cpp index 4df749a08ceb37c628d05b784fb61fd20c23e7c7..60ac1273ed5e7fb16332d0c052c9dcc6f6de1e79 100644 --- a/adapter/ohos/entrance/ui_content_impl.cpp +++ b/adapter/ohos/entrance/ui_content_impl.cpp @@ -537,6 +537,13 @@ void UIContentImpl::InitWindowCallback(const std::shared_ptrClose()); }); + pipelineContext->SetWindowStartMoveCallBack([&window]() { + if (!window) { + return; + } + window->StartMove(); + }); + pipelineContext->SetWindowSplitCallBack([&window]() -> bool { if (!window) { return false; diff --git a/frameworks/core/components/box/box_component.h b/frameworks/core/components/box/box_component.h index 040e11ac36642300e5502e97df767189be6d6d92..ddea04d06eee5fc1ffdf38f08b5d6508f87f6a3b 100644 --- a/frameworks/core/components/box/box_component.h +++ b/frameworks/core/components/box/box_component.h @@ -21,6 +21,7 @@ #include "core/components/common/properties/color.h" #include "core/components/common/properties/decoration.h" #include "core/gestures/gesture_info.h" +#include "core/gestures/raw_recognizer.h" namespace OHOS::Ace { @@ -146,6 +147,16 @@ public: return onMouseId_; } + void SetOnTouchMoveId(const OnTouchEventCallback& onTouchMoveId) + { + onTouchMoveId_ = onTouchMoveId; + } + + const OnTouchEventCallback& GetOnTouchMoveId() const + { + return onTouchMoveId_; + } + RefPtr GetOnClick() const { return onClickId_; @@ -311,6 +322,7 @@ private: OnDropFunc onDropId_; OnHoverCallback onHoverId_; OnMouseCallback onMouseId_; + OnTouchEventCallback onTouchMoveId_; RefPtr onClickId_; RefPtr onLongPressId_; std::array, 3> gestures_; diff --git a/frameworks/core/components/box/render_box.cpp b/frameworks/core/components/box/render_box.cpp index 0d75dd653a0514b6b9aa47227012f42f5106e504..7deb27fdd77ad2e76d7e5fd0d34590d4653e2732 100644 --- a/frameworks/core/components/box/render_box.cpp +++ b/frameworks/core/components/box/render_box.cpp @@ -158,6 +158,7 @@ void RenderBox::Update(const RefPtr& component) box->HandleTouchEvent(false); } }); + touchRecognizer_->SetOnTouchMove(box->GetOnTouchMoveId()); } // In each update, the extensions will be updated with new one. if (eventExtensions_ && eventExtensions_->HasOnAreaChangeExtension()) { diff --git a/frameworks/core/components/container_modal/container_modal_component.cpp b/frameworks/core/components/container_modal/container_modal_component.cpp index 57c84ea461ba846423d370b41ee7cb55194a4174..94d47847c40e82dd92ef77552455d7c21183e57f 100644 --- a/frameworks/core/components/container_modal/container_modal_component.cpp +++ b/frameworks/core/components/container_modal/container_modal_component.cpp @@ -52,7 +52,7 @@ const Color TITLE_BUTTON_CLICKED_COLOR = Color(0x33000000); } // namespace RefPtr ContainerModalComponent::Create(const WeakPtr& context, - RefPtr child) + const RefPtr& child) { auto component = AceType::MakeRefPtr(context); component->SetChild(child); @@ -160,8 +160,23 @@ RefPtr ContainerModalComponent::BuildTitle() titleBox->SetHeight(CONTAINER_TITLE_HEIGHT); titleBox->SetBackDecoration(titleDecoration); auto row = AceType::MakeRefPtr(FlexAlign::FLEX_START, FlexAlign::CENTER, titleChildren); - titleBox->SetChild(row); + // handle mouse move + titleBox->SetOnMouseId([contextWptr](MouseInfo& info) { + auto context = contextWptr.Upgrade(); + if (context && info.GetButton() == MouseButton::LEFT_BUTTON && info.GetAction() == MouseAction::MOVE) { + context->FireWindowStartMoveCallBack(); + } + }); + + // handle touch move + titleBox->SetOnTouchMoveId([contextWptr](const TouchEventInfo&) { + auto context = contextWptr.Upgrade(); + if (context) { + context->FireWindowStartMoveCallBack(); + } + }); + titleBox->SetChild(row); return titleBox; } diff --git a/frameworks/core/components/container_modal/container_modal_component.h b/frameworks/core/components/container_modal/container_modal_component.h index 8330f0c3e5d55e538c3cdae173f5ee94a4a5d586..56be995678d50a28034ddcb6c791b91130388698 100644 --- a/frameworks/core/components/container_modal/container_modal_component.h +++ b/frameworks/core/components/container_modal/container_modal_component.h @@ -30,7 +30,7 @@ public: } ~ContainerModalComponent() override = default; - static RefPtr Create(const WeakPtr& context, RefPtr child); + static RefPtr Create(const WeakPtr& context, const RefPtr& child); RefPtr CreateElement() override; RefPtr CreateRenderNode() override; void BuildInnerChild(); diff --git a/frameworks/core/components/test/unittest/mock/container_modal_mock.cpp b/frameworks/core/components/test/unittest/mock/container_modal_mock.cpp index a3ebf4d35575448013b571d31e32d4a81491d957..3303ffcb348e06e125e3fdebeb5ce5a07e5d309c 100644 --- a/frameworks/core/components/test/unittest/mock/container_modal_mock.cpp +++ b/frameworks/core/components/test/unittest/mock/container_modal_mock.cpp @@ -18,7 +18,8 @@ namespace OHOS::Ace { -RefPtr ContainerModalComponent::Create(const WeakPtr& context, RefPtr child) +RefPtr ContainerModalComponent::Create(const WeakPtr& context, + const RefPtr& child) { return nullptr; } diff --git a/frameworks/core/pipeline/pipeline_context.h b/frameworks/core/pipeline/pipeline_context.h index 61df8a53260a96bc2b2c2818afe1db43e67a0895..2e13d185d653e2d37b4691111cef92f98544d51e 100644 --- a/frameworks/core/pipeline/pipeline_context.h +++ b/frameworks/core/pipeline/pipeline_context.h @@ -1009,7 +1009,7 @@ public: return isShiftDown_; } - void MarkIsShiftDown(bool isShiftDown) + void MarkIsShiftDown(bool isShiftDown) { isShiftDown_ = isShiftDown; } @@ -1019,7 +1019,7 @@ public: return isCtrlDown_; } - void MarkIsCtrlDown(bool isCtrlDown) + void MarkIsCtrlDown(bool isCtrlDown) { isCtrlDown_ = isCtrlDown; } @@ -1029,7 +1029,7 @@ public: return isKeyboardA_; } - void MarkIsKeyboardA(bool isKeyboardA) + void MarkIsKeyboardA(bool isKeyboardA) { isKeyboardA_ = isKeyboardA; } @@ -1076,6 +1076,11 @@ public: windowGetModeCallback_ = std::move(callback); } + void SetWindowStartMoveCallBack(std::function&& callback) + { + windowStartMoveCallback_ = std::move(callback); + } + bool FireWindowMinimizeCallBack() const { if (windowMinimizeCallback_) { @@ -1116,6 +1121,13 @@ public: return false; } + void FireWindowStartMoveCallBack() const + { + if (windowStartMoveCallback_) { + windowStartMoveCallback_(); + } + } + WindowMode FireWindowGetModeCallBack() const { if (windowGetModeCallback_) { @@ -1369,6 +1381,7 @@ private: std::function windowRecoverCallback_ = nullptr; std::function windowCloseCallback_ = nullptr; std::function windowSplitCallback_ = nullptr; + std::function windowStartMoveCallback_ = nullptr; std::function windowGetModeCallback_ = nullptr; ACE_DISALLOW_COPY_AND_MOVE(PipelineContext);