Signed-off-by: Ad0nis <1164818708@qq.com>
This commit is contained in:
Ad0nis 2024-10-30 09:39:32 +08:00
parent c87aad4ce6
commit 701ee8afd4
2 changed files with 32 additions and 26 deletions

View File

@ -15,6 +15,10 @@
#include "bridge/cj_frontend/interfaces/cj_ffi/cj_foreach_ffi.h"
#include <cstdlib>
#include <string>
#include <unordered_set>
#include "cj_lambda.h"
#include "bridge/cj_frontend/runtime/cj_runtime_delegate.h"

View File

@ -15,6 +15,8 @@
#include "bridge/cj_frontend/interfaces/cj_ffi/cj_interactable_view_ffi.h"
#include <cinttypes>
#include "cj_lambda.h"
#include "bridge/cj_frontend/interfaces/cj_ffi/utils.h"
@ -187,34 +189,34 @@ void FfiOHOSAceFrameworkInteractableViewOnHover(void (*callback)(bool))
void FfiOHOSAceFrameworkInteractableViewOnAreaChanged(void (*callback)(CJArea, CJArea))
{
auto onAreaChanged = CJLambda::Create(callback);
ViewAbstractModel::GetInstance()->SetOnAreaChanged([onAreaChanged](const Rect& lastRect, const Offset& lastOrigin,
const Rect& rect, const Offset& origin) {
CJArea lastCjArea {};
lastCjArea.width = PipelineBase::Px2VpWithCurrentDensity(lastRect.Width());
lastCjArea.height = PipelineBase::Px2VpWithCurrentDensity(lastRect.Height());
CJPosition lastCjPosition {};
CJPosition lastCjGlobalPosition {};
lastCjPosition.x = PipelineBase::Px2VpWithCurrentDensity(lastRect.GetOffset().GetX());
lastCjPosition.y = PipelineBase::Px2VpWithCurrentDensity(lastRect.GetOffset().GetY());
lastCjGlobalPosition.x = PipelineBase::Px2VpWithCurrentDensity(lastRect.GetOffset().GetX() + lastOrigin.GetX());
lastCjGlobalPosition.y = PipelineBase::Px2VpWithCurrentDensity(lastRect.GetOffset().GetY() + lastOrigin.GetY());
lastCjArea.position = &lastCjPosition;
lastCjArea.globalPosition = &lastCjGlobalPosition;
ViewAbstractModel::GetInstance()->SetOnAreaChanged(
[onAreaChanged](const Rect& lastRect, const Offset& lastOrigin, const Rect& rect, const Offset& origin) {
CJArea lastCjArea {};
lastCjArea.width = lastRect.Width();
lastCjArea.height = lastRect.Height();
CJPosition lastCjPosition {};
CJPosition lastCjGlobalPosition {};
lastCjPosition.x = lastRect.GetOffset().GetX();
lastCjPosition.y = lastRect.GetOffset().GetY();
lastCjGlobalPosition.x = lastRect.GetOffset().GetX() + lastOrigin.GetX();
lastCjGlobalPosition.y = lastRect.GetOffset().GetY() + lastOrigin.GetY();
lastCjArea.position = &lastCjPosition;
lastCjArea.globalPosition = &lastCjGlobalPosition;
CJArea cjArea {};
cjArea.width = PipelineBase::Px2VpWithCurrentDensity(rect.Width());
cjArea.height = PipelineBase::Px2VpWithCurrentDensity(rect.Height());
CJPosition cjPosition {};
CJPosition cjGlobalPosition {};
cjPosition.x = PipelineBase::Px2VpWithCurrentDensity(rect.GetOffset().GetX());
cjPosition.y = PipelineBase::Px2VpWithCurrentDensity(rect.GetOffset().GetY());
cjGlobalPosition.x = PipelineBase::Px2VpWithCurrentDensity(rect.GetOffset().GetX() + origin.GetX());
cjGlobalPosition.y = PipelineBase::Px2VpWithCurrentDensity(rect.GetOffset().GetY() + origin.GetY());
cjArea.position = &cjPosition;
cjArea.globalPosition = &cjGlobalPosition;
CJArea cjArea {};
cjArea.width = rect.Width();
cjArea.height = rect.Height();
CJPosition cjPosition {};
CJPosition cjGlobalPosition {};
cjPosition.x = rect.GetOffset().GetX();
cjPosition.y = rect.GetOffset().GetY();
cjGlobalPosition.x = rect.GetOffset().GetX() + origin.GetX();
cjGlobalPosition.y = rect.GetOffset().GetY() + origin.GetY();
cjArea.position = &cjPosition;
cjArea.globalPosition = &cjGlobalPosition;
onAreaChanged(lastCjArea, cjArea);
});
onAreaChanged(lastCjArea, cjArea);
});
}
void FfiOHOSAceFrameworkInteractableViewOnVisibleAreaChange(