mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 15:10:30 +00:00
Merge branch 'master' of https://gitee.com/openharmony/arkui_ace_engine into partial_code_specification
Change-Id: I474df172fab53a2b5523971a0f831417a16d6ddb
This commit is contained in:
commit
4359517249
@ -572,7 +572,7 @@ void ClipboardImpl::GetDataAsync(const std::function<void(const std::string&, bo
|
||||
}
|
||||
|
||||
void ClipboardImpl::GetSpanStringData(
|
||||
const std::function<void(std::vector<std::vector<uint8_t>>&, const std::string&)>& callback, bool syncMode)
|
||||
const std::function<void(std::vector<std::vector<uint8_t>>&, const std::string&, bool&)>& callback, bool syncMode)
|
||||
{
|
||||
#ifdef SYSTEM_CLIPBOARD_SUPPORTED
|
||||
if (!taskExecutor_ || !callback) {
|
||||
@ -584,7 +584,7 @@ void ClipboardImpl::GetSpanStringData(
|
||||
}
|
||||
|
||||
void ClipboardImpl::GetSpanStringDataHelper(
|
||||
const std::function<void(std::vector<std::vector<uint8_t>>&, const std::string&)>& callback, bool syncMode)
|
||||
const std::function<void(std::vector<std::vector<uint8_t>>&, const std::string&, bool&)>& callback, bool syncMode)
|
||||
{
|
||||
auto task = [callback, weakExecutor = WeakClaim(RawPtr(taskExecutor_)), weak = WeakClaim(this)]() {
|
||||
auto clip = weak.Upgrade();
|
||||
@ -598,14 +598,15 @@ void ClipboardImpl::GetSpanStringDataHelper(
|
||||
CHECK_NULL_VOID(getDataRes);
|
||||
std::vector<std::vector<uint8_t>> arrays;
|
||||
std::string text;
|
||||
clip->ProcessSpanStringData(arrays, pasteData, text);
|
||||
bool isMultiTypeRecord = false;
|
||||
clip->ProcessSpanStringData(arrays, pasteData, text, isMultiTypeRecord);
|
||||
auto textData = pasteData.GetPrimaryText();
|
||||
if (textData && text.empty()) {
|
||||
text.append(*textData);
|
||||
}
|
||||
auto result = text;
|
||||
taskExecutor->PostTask(
|
||||
[callback, arrays, result]() mutable { callback(arrays, result); },
|
||||
[callback, arrays, result, isMultiTypeRecord]() mutable { callback(arrays, result, isMultiTypeRecord); },
|
||||
TaskExecutor::TaskType::UI, "ArkUIClipboardGetSpanStringDataCallback");
|
||||
};
|
||||
if (syncMode) {
|
||||
@ -615,8 +616,8 @@ void ClipboardImpl::GetSpanStringDataHelper(
|
||||
}
|
||||
}
|
||||
|
||||
void ClipboardImpl::ProcessSpanStringData(
|
||||
std::vector<std::vector<uint8_t>>& arrays, const OHOS::MiscServices::PasteData& pasteData, std::string& text)
|
||||
void ClipboardImpl::ProcessSpanStringData(std::vector<std::vector<uint8_t>>& arrays,
|
||||
const OHOS::MiscServices::PasteData& pasteData, std::string& text, bool& isMultiTypeRecord)
|
||||
{
|
||||
for (const auto& pasteDataRecord : pasteData.AllRecords()) {
|
||||
if (pasteDataRecord == nullptr) {
|
||||
@ -644,6 +645,7 @@ void ClipboardImpl::ProcessSpanStringData(
|
||||
if (pasteDataRecord->GetPlainText() != nullptr) {
|
||||
auto textData = pasteDataRecord->GetPlainText();
|
||||
text.append(*textData);
|
||||
isMultiTypeRecord = !(*textData).empty() && hasSpanString;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,8 @@ public:
|
||||
void HasDataType(
|
||||
const std::function<void(bool hasData)>& callback, const std::vector<std::string>& mimeTypes) override;
|
||||
void Clear() override;
|
||||
void GetSpanStringData(const std::function<void(std::vector<std::vector<uint8_t>>&, const std::string&)>& callback,
|
||||
void GetSpanStringData(
|
||||
const std::function<void(std::vector<std::vector<uint8_t>>&, const std::string&, bool&)>& callback,
|
||||
bool syncMode = false) override;
|
||||
|
||||
#ifdef SYSTEM_CLIPBOARD_SUPPORTED
|
||||
@ -69,10 +70,10 @@ private:
|
||||
void GetPixelMapDataSync(const std::function<void(const RefPtr<PixelMap>&)>& callback);
|
||||
void GetPixelMapDataAsync(const std::function<void(const RefPtr<PixelMap>&)>& callback);
|
||||
void GetSpanStringDataHelper(
|
||||
const std::function<void(std::vector<std::vector<uint8_t>>&, const std::string&)>& callback,
|
||||
const std::function<void(std::vector<std::vector<uint8_t>>&, const std::string&, bool&)>& callback,
|
||||
bool syncMode = false);
|
||||
void ProcessSpanStringData(
|
||||
std::vector<std::vector<uint8_t>>& arrays, const OHOS::MiscServices::PasteData& pasteData, std::string& text);
|
||||
void ProcessSpanStringData(std::vector<std::vector<uint8_t>>& arrays,
|
||||
const OHOS::MiscServices::PasteData& pasteData, std::string& text, bool& isMultiTypeRecord);
|
||||
const std::string GetMimeType(
|
||||
std::map<std::string, std::shared_ptr<OHOS::MiscServices::EntryValue>> multiTypeDataMap);
|
||||
#endif
|
||||
|
@ -196,18 +196,6 @@ void ReleaseStorageReference(void* sharedRuntime, NativeReference* storage)
|
||||
napi_delete_reference(env, reinterpret_cast<napi_ref>(storage));
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateLanguage(const std::string& languageTag, ConfigurationChange& configurationChange)
|
||||
{
|
||||
std::string language;
|
||||
std::string script;
|
||||
std::string region;
|
||||
Localization::ParseLocaleTag(languageTag, language, script, region, false);
|
||||
if (!language.empty() || !script.empty() || !region.empty()) {
|
||||
configurationChange.languageUpdate = true;
|
||||
AceApplicationInfo::GetInstance().SetLocale(language, region, script, "");
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
AceContainer::AceContainer(int32_t instanceId, FrontendType type, std::shared_ptr<OHOS::AppExecFwk::Ability> aceAbility,
|
||||
@ -2588,11 +2576,6 @@ void AceContainer::UpdateConfiguration(const ParsedConfig& parsedConfig, const s
|
||||
SystemProperties::SetDeviceAccess(parsedConfig.deviceAccess == "true");
|
||||
resConfig.SetDeviceAccess(parsedConfig.deviceAccess == "true");
|
||||
}
|
||||
if (!parsedConfig.preferredLanguage.empty()) {
|
||||
UpdateLanguage(parsedConfig.preferredLanguage, configurationChange);
|
||||
} else if (!parsedConfig.languageTag.empty()) {
|
||||
UpdateLanguage(parsedConfig.languageTag, configurationChange);
|
||||
}
|
||||
if (!parsedConfig.languageTag.empty()) {
|
||||
std::string language;
|
||||
std::string script;
|
||||
@ -2627,6 +2610,7 @@ void AceContainer::UpdateConfiguration(const ParsedConfig& parsedConfig, const s
|
||||
}
|
||||
if (!parsedConfig.preferredLanguage.empty()) {
|
||||
resConfig.SetPreferredLanguage(parsedConfig.preferredLanguage);
|
||||
configurationChange.languageUpdate = true;
|
||||
}
|
||||
SetFontScaleAndWeightScale(parsedConfig, configurationChange);
|
||||
SetResourceConfiguration(resConfig);
|
||||
|
@ -384,7 +384,7 @@ public:
|
||||
double GetWindowDensity() const
|
||||
{
|
||||
if (!uiWindow_) {
|
||||
return 0.0;
|
||||
return 1.0;
|
||||
}
|
||||
return static_cast<double>(uiWindow_->GetVirtualPixelRatio());
|
||||
}
|
||||
|
@ -54,11 +54,6 @@ void NavigationRouteOhos::InitRouteMap()
|
||||
moduleInfos_ = bundleInfo.hapModuleInfos;
|
||||
}
|
||||
|
||||
void NavigationRouteOhos::OnPackageChange()
|
||||
{
|
||||
InitRouteMap();
|
||||
}
|
||||
|
||||
bool NavigationRouteOhos::GetRouteItem(const std::string& name, NG::RouteItem& info)
|
||||
{
|
||||
AppExecFwk::RouterItem routeItem;
|
||||
|
@ -44,12 +44,11 @@ public:
|
||||
|
||||
bool IsNavigationItemExits(const std::string& name) override;
|
||||
|
||||
void OnPackageChange() override;
|
||||
void InitRouteMap() override;
|
||||
|
||||
private:
|
||||
bool GetRouteItemFromBundle(const std::string& name, AppExecFwk::RouterItem& routeItem);
|
||||
int32_t LoadPageFromHapModule(const std::string& name);
|
||||
void InitRouteMap();
|
||||
sptr<AppExecFwk::IBundleMgr> GetBundleManager();
|
||||
AppExecFwk::RouterItem GetRouteItem(const std::string name);
|
||||
std::vector<AppExecFwk::RouterItem> allRouteItems_;
|
||||
|
@ -189,6 +189,7 @@ int32_t StylusDetectorMgr::StylusDetectorCallBack::DeleteText(int32_t nodeId, vo
|
||||
auto UiNode = ElementRegister::GetInstance()->GetUINodeById(nodeId);
|
||||
auto frameNode = AceType::DynamicCast<NG::FrameNode>(UiNode);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
ContainerScope scope(frameNode->GetInstanceId());
|
||||
auto pipeline = frameNode->GetContextRefPtr();
|
||||
CHECK_NULL_VOID(pipeline);
|
||||
auto windowRect = pipeline->GetCurrentWindowRect();
|
||||
@ -227,11 +228,10 @@ int32_t StylusDetectorMgr::StylusDetectorCallBack::ChoiceText(int32_t nodeId, vo
|
||||
taskScheduler->PostSyncTask(
|
||||
[&resultCode, nodeId, choiceTextOption]() {
|
||||
auto rect = choiceTextOption.rect;
|
||||
TAG_LOGI(AceLogTag::ACE_STYLUS, "stylusGesture global rect:%{public}f, %{public}f, %{public}f, %{public}f",
|
||||
rect.Left, rect.Top, rect.Width, rect.Height);
|
||||
auto UiNode = ElementRegister::GetInstance()->GetUINodeById(nodeId);
|
||||
auto frameNode = AceType::DynamicCast<NG::FrameNode>(UiNode);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
ContainerScope scope(frameNode->GetInstanceId());
|
||||
auto pipeline = frameNode->GetContextRefPtr();
|
||||
CHECK_NULL_VOID(pipeline);
|
||||
auto windowRect = pipeline->GetCurrentWindowRect();
|
||||
@ -247,6 +247,14 @@ int32_t StylusDetectorMgr::StylusDetectorCallBack::ChoiceText(int32_t nodeId, vo
|
||||
CHECK_NULL_VOID(textBase);
|
||||
auto wtextLength = textBase->GetContentWideTextLength();
|
||||
TAG_LOGI(AceLogTag::ACE_STYLUS, "stylusGesture wtextLength:%{public}d", wtextLength);
|
||||
if (StylusDetectorMgr::GetInstance()->sInd_ == static_cast<int32_t>(sInd.position_) &&
|
||||
StylusDetectorMgr::GetInstance()->eInd_ == static_cast<int32_t>(eInd.position_) &&
|
||||
StylusDetectorMgr::GetInstance()->showMenu_ == choiceTextOption.showMenu) {
|
||||
return;
|
||||
}
|
||||
StylusDetectorMgr::GetInstance()->sInd_ = static_cast<int32_t>(sInd.position_);
|
||||
StylusDetectorMgr::GetInstance()->eInd_ = static_cast<int32_t>(eInd.position_);
|
||||
StylusDetectorMgr::GetInstance()->showMenu_ = choiceTextOption.showMenu;
|
||||
auto ret = CalculateIntersectedRegion(sInd, eInd, wtextLength);
|
||||
if (std::get<0>(ret) == 0) {
|
||||
auto textInputClient = frameNode->GetPattern<TextInputClient>();
|
||||
@ -277,6 +285,7 @@ int32_t StylusDetectorMgr::StylusDetectorCallBack::InsertSpace(int32_t nodeId, v
|
||||
auto UiNode = ElementRegister::GetInstance()->GetUINodeById(nodeId);
|
||||
auto frameNode = AceType::DynamicCast<NG::FrameNode>(UiNode);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
ContainerScope scope(frameNode->GetInstanceId());
|
||||
auto pipeline = frameNode->GetContextRefPtr();
|
||||
CHECK_NULL_VOID(pipeline);
|
||||
auto windowRect = pipeline->GetCurrentWindowRect();
|
||||
@ -310,6 +319,7 @@ int32_t StylusDetectorMgr::StylusDetectorCallBack::MoveCursor(int32_t nodeId, vo
|
||||
auto UiNode = ElementRegister::GetInstance()->GetUINodeById(nodeId);
|
||||
auto frameNode = AceType::DynamicCast<NG::FrameNode>(UiNode);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
ContainerScope scope(frameNode->GetInstanceId());
|
||||
auto pipeline = frameNode->GetContextRefPtr();
|
||||
CHECK_NULL_VOID(pipeline);
|
||||
auto windowRect = pipeline->GetCurrentWindowRect();
|
||||
@ -359,6 +369,13 @@ NG::PositionWithAffinity StylusDetectorMgr::StylusDetectorCallBack::GetGlyphPosi
|
||||
}
|
||||
TAG_LOGI(AceLogTag::ACE_STYLUS, "stylusGesture localOffset:%{public}f, %{public}f", localOffset.GetX(),
|
||||
localOffset.GetY());
|
||||
auto textDragBase = frameNode->GetPattern<NG::TextDragBase>();
|
||||
CHECK_NULL_RETURN(textDragBase, finalResult);
|
||||
auto textRect = textDragBase->GetTextRect();
|
||||
if (localOffset.GetY() < textRect.GetY() || localOffset.GetY() > textRect.GetY() + textRect.Height()) {
|
||||
TAG_LOGI(AceLogTag::ACE_STYLUS, "stylusGesture point outside the area");
|
||||
return finalResult;
|
||||
}
|
||||
// calculate the start and end indexes of the intersecting region.
|
||||
auto layoutInfo = StylusDetectorMgr::GetInstance()->layoutInfo_.Upgrade();
|
||||
CHECK_NULL_RETURN(layoutInfo, finalResult);
|
||||
@ -585,10 +602,11 @@ bool StylusDetectorMgr::IsNeedInterceptedTouchEvent(
|
||||
info.x = touchEvent.screenX;
|
||||
info.y = touchEvent.screenY;
|
||||
info.bundleName = bundleName;
|
||||
if (!isRegistered_) {
|
||||
auto stylusDetectorCallback = std::make_shared<StylusDetectorCallBack>();
|
||||
isRegistered_ = RegisterStylusInteractionListener(bundleName, stylusDetectorCallback);
|
||||
}
|
||||
sInd_ = -1;
|
||||
eInd_ = -1;
|
||||
showMenu_ = false;
|
||||
return Notify(info);
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ void ClipboardImpl::GetData(const std::function<void(const std::string&, bool is
|
||||
const std::function<void(const std::string&, bool isLastRecord)>& urlCallback, bool syncMode)
|
||||
{}
|
||||
void ClipboardImpl::GetSpanStringData(
|
||||
const std::function<void(std::vector<std::vector<uint8_t>>&, const std::string&)>& callback, bool syncMode)
|
||||
const std::function<void(std::vector<std::vector<uint8_t>>&, const std::string&, bool&)>& callback, bool syncMode)
|
||||
{}
|
||||
|
||||
RefPtr<PasteDataMix> ClipboardImpl::CreatePasteDataMix()
|
||||
|
@ -56,7 +56,8 @@ public:
|
||||
void GetData(const std::function<void(const std::string&, bool isLastRecord)>& textCallback,
|
||||
const std::function<void(const RefPtr<PixelMap>&, bool isLastRecord)>& pixelMapCallback,
|
||||
const std::function<void(const std::string&, bool isLastRecord)>& urlCallback, bool syncMode = false) override;
|
||||
void GetSpanStringData(const std::function<void(std::vector<std::vector<uint8_t>>&, const std::string&)>& callback,
|
||||
void GetSpanStringData(
|
||||
const std::function<void(std::vector<std::vector<uint8_t>>&, const std::string&, bool&)>& callback,
|
||||
bool syncMode = false) override;
|
||||
RefPtr<PasteDataMix> CreatePasteDataMix() override;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -410,7 +410,6 @@ export struct SelectDialog {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@Builder
|
||||
buildContent(): void {
|
||||
Scroll(this.contentScroller) {
|
||||
@ -461,6 +460,7 @@ export struct SelectDialog {
|
||||
.borderRadius($r('sys.float.corner_radius_level8'))
|
||||
.buttonStyle(ButtonStyleMode.TEXTUAL)
|
||||
.paddingStyle()
|
||||
|
||||
if (index < this.radioContent.length - 1) {
|
||||
Divider().color(this.dividerColorWithTheme).paddingStyle();
|
||||
}
|
||||
@ -1059,7 +1059,7 @@ struct CustomDialogContentComponent {
|
||||
.margin(this.customStyle ? {
|
||||
start: LengthMetrics.resource($r('sys.float.ohos_id_dialog_margin_start')),
|
||||
end: LengthMetrics.resource($r('sys.float.ohos_id_dialog_margin_end')),
|
||||
bottom: $r('sys.float.ohos_id_dialog_margin_bottom'),
|
||||
bottom: LengthMetrics.resource($r('sys.float.ohos_id_dialog_margin_bottom')),
|
||||
} : { left: 0, right: 0, bottom: 0 })
|
||||
.backgroundColor(this.customStyle ? $r('sys.color.ohos_id_color_dialog_bg') : Color.Transparent)
|
||||
}
|
||||
@ -1325,26 +1325,26 @@ struct CustomDialogContentComponent {
|
||||
buildSingleButton(buttonOptions: ButtonOptions): void {
|
||||
if (this.isNewPropertiesHighPriority(buttonOptions)) {
|
||||
Button(buttonOptions.value)
|
||||
.setButtonProperties(buttonOptions, this.controller)
|
||||
.setButtonProperties(buttonOptions, this.buttons, this.controller)
|
||||
.role(buttonOptions.role ?? ButtonRole.NORMAL)
|
||||
.key(`advanced_dialog_button_${this.keyIndex++}`)
|
||||
.labelStyle({ maxLines: 1, maxFontSize: this.buttonMaxFontSize, minFontSize: this.buttonMinFontSize })
|
||||
} else if (buttonOptions.background !== undefined && buttonOptions.fontColor !== undefined) {
|
||||
Button(buttonOptions.value)
|
||||
.setButtonProperties(buttonOptions, this.controller)
|
||||
.setButtonProperties(buttonOptions, this.buttons, this.controller)
|
||||
.backgroundColor(buttonOptions.background)
|
||||
.fontColor(buttonOptions.fontColor)
|
||||
.key(`advanced_dialog_button_${this.keyIndex++}`)
|
||||
.labelStyle({ maxLines: 1, maxFontSize: this.buttonMaxFontSize, minFontSize: this.buttonMinFontSize })
|
||||
} else if (buttonOptions.background !== undefined) {
|
||||
Button(buttonOptions.value)
|
||||
.setButtonProperties(buttonOptions, this.controller)
|
||||
.setButtonProperties(buttonOptions, this.buttons, this.controller)
|
||||
.backgroundColor(buttonOptions.background)
|
||||
.key(`advanced_dialog_button_${this.keyIndex++}`)
|
||||
.labelStyle({ maxLines: 1, maxFontSize: this.buttonMaxFontSize, minFontSize: this.buttonMinFontSize })
|
||||
} else {
|
||||
Button(buttonOptions.value)
|
||||
.setButtonProperties(buttonOptions, this.controller)
|
||||
.setButtonProperties(buttonOptions, this.buttons, this.controller)
|
||||
.fontColor(buttonOptions.fontColor)
|
||||
.key(`advanced_dialog_button_${this.keyIndex++}`)
|
||||
.labelStyle({ maxLines: 1, maxFontSize: this.buttonMaxFontSize, minFontSize: this.buttonMinFontSize })
|
||||
@ -1467,19 +1467,43 @@ struct CustomDialogContentComponent {
|
||||
}
|
||||
|
||||
@Extend(Button)
|
||||
function setButtonProperties(buttonOptions: ButtonOptions, controller?: CustomDialogController) {
|
||||
function setButtonProperties(buttonOptions: ButtonOptions, buttonList?: ButtonOptions[],
|
||||
controller?: CustomDialogController) {
|
||||
.onClick(() => {
|
||||
if (buttonOptions.action) {
|
||||
buttonOptions.action();
|
||||
}
|
||||
controller?.close();
|
||||
})
|
||||
.defaultFocus(true)
|
||||
.defaultFocus(buttonOptions.defaultFocus ? true : isHasDefaultFocus(buttonList) ? false : true)
|
||||
.buttonStyle(buttonOptions.buttonStyle ?? ALERT_BUTTON_STYLE)
|
||||
.layoutWeight(BUTTON_LAYOUT_WEIGHT)
|
||||
.type(ButtonType.ROUNDED_RECTANGLE)
|
||||
}
|
||||
|
||||
/**
|
||||
* is button list has default focus
|
||||
*
|
||||
* @param buttonList button list
|
||||
* @returns boolean
|
||||
*/
|
||||
function isHasDefaultFocus(buttonList?: ButtonOptions[]): boolean {
|
||||
try {
|
||||
let isHasDefaultFocus: boolean = false;
|
||||
buttonList?.forEach((button) => {
|
||||
if (button.defaultFocus) {
|
||||
isHasDefaultFocus = true;
|
||||
}
|
||||
})
|
||||
return isHasDefaultFocus;
|
||||
} catch (error) {
|
||||
let code: number = (error as BusinessError).code;
|
||||
let message: string = (error as BusinessError).message;
|
||||
hilog.error(0x3900, 'Ace', `get defaultFocus exist error, code: ${code}, message: ${message}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get resource size
|
||||
*
|
||||
|
@ -28,6 +28,7 @@ public:
|
||||
static int32_t SilentInstall(const std::string& moduleName, const std::function<void()>& callback,
|
||||
const std::function<void(int32_t, const std::string&)>& silentInstallErrorCallBack);
|
||||
static bool IsHspExist(const std::string& moduleName, const std::string& pathName);
|
||||
static void InitRouteMap();
|
||||
|
||||
private:
|
||||
static OHOS::sptr<OHOS::AppExecFwk::IBundleMgr> GetBundleManager();
|
||||
|
@ -26,6 +26,7 @@ class HspSilentInstallNapi {
|
||||
public:
|
||||
static napi_value SilentInstall(napi_env env, napi_callback_info info);
|
||||
static napi_value IsHspExist(napi_env env, napi_callback_info info);
|
||||
static napi_value InitRouteMap(napi_env env, napi_callback_info info);
|
||||
|
||||
private:
|
||||
struct CallbackData {
|
||||
|
@ -34,6 +34,7 @@ export class NavPushPathHelper {
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
navPushPathHelperApi.silentInstall(moduleName, () => {
|
||||
navPushPathHelperApi.initRouteMap();
|
||||
this.navPathStack_?.pushPath(info, optionParam);
|
||||
resolve();
|
||||
},
|
||||
@ -53,6 +54,7 @@ export class NavPushPathHelper {
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
navPushPathHelperApi.silentInstall(moduleName, () => {
|
||||
navPushPathHelperApi.initRouteMap();
|
||||
this.navPathStack_?.pushDestination(info, optionParam)
|
||||
.then(resolve).catch(reject);
|
||||
}, (error) => {
|
||||
@ -71,6 +73,7 @@ export class NavPushPathHelper {
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
navPushPathHelperApi.silentInstall(moduleName, () => {
|
||||
navPushPathHelperApi.initRouteMap();
|
||||
this.navPathStack_?.pushPathByName(name, param, onPop, optionParam);
|
||||
resolve();
|
||||
}, (error) => {
|
||||
@ -89,6 +92,7 @@ export class NavPushPathHelper {
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
navPushPathHelperApi.silentInstall(moduleName, () => {
|
||||
navPushPathHelperApi.initRouteMap();
|
||||
this.navPathStack_?.pushDestinationByName(name, param, onPop, optionParam)
|
||||
.then(resolve).catch(reject);
|
||||
}, (error) => {
|
||||
@ -107,6 +111,7 @@ export class NavPushPathHelper {
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
navPushPathHelperApi.silentInstall(moduleName, () => {
|
||||
navPushPathHelperApi.initRouteMap();
|
||||
this.navPathStack_?.replacePath(info, optionParam);
|
||||
resolve();
|
||||
}, (error) => {
|
||||
@ -125,6 +130,8 @@ export class NavPushPathHelper {
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
navPushPathHelperApi.silentInstall(moduleName, () => {
|
||||
hilog.info(0x3900, tag, `silentInstall success`);
|
||||
navPushPathHelperApi.initRouteMap();
|
||||
this.navPathStack_?.replacePathByName(name, param, optionParam);
|
||||
resolve();
|
||||
}, (error) => {
|
||||
|
@ -105,4 +105,13 @@ bool HspSilentInstall::IsHspExist(const std::string &moduleName, const std::stri
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void HspSilentInstall::InitRouteMap()
|
||||
{
|
||||
auto container = OHOS::Ace::Container::CurrentSafely();
|
||||
CHECK_NULL_VOID(container);
|
||||
auto navigationRoute = container->GetNavigationRoute();
|
||||
CHECK_NULL_VOID(navigationRoute);
|
||||
navigationRoute->InitRouteMap();
|
||||
}
|
||||
} // namespace OHOS::NavPushPathHelper
|
@ -56,6 +56,12 @@ napi_value HspSilentInstallNapi::IsHspExist(napi_env env, napi_callback_info inf
|
||||
return jsResult;
|
||||
}
|
||||
|
||||
napi_value HspSilentInstallNapi::InitRouteMap(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HspSilentInstall::InitRouteMap();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
napi_value HspSilentInstallNapi::SilentInstall(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value result = nullptr;
|
||||
|
@ -34,6 +34,7 @@ namespace OHOS::NavPushPathHelper {
|
||||
napi_property_descriptor desc[] = {
|
||||
DECLARE_NAPI_FUNCTION("silentInstall", HspSilentInstallNapi::SilentInstall),
|
||||
DECLARE_NAPI_FUNCTION("isHspExist", HspSilentInstallNapi::IsHspExist),
|
||||
DECLARE_NAPI_FUNCTION("initRouteMap", HspSilentInstallNapi::InitRouteMap),
|
||||
};
|
||||
NAPI_CALL(env, napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc));
|
||||
return exports;
|
||||
|
@ -4729,40 +4729,40 @@ class UIGestureEvent {
|
||||
case CommonGestureType.TAP_GESTURE: {
|
||||
let tapGesture: TapGestureHandler = gesture as TapGestureHandler;
|
||||
getUINativeModule().common.addTapGesture(this._nodePtr, priority, mask, tapGesture.gestureTag,
|
||||
tapGesture.fingers, tapGesture.count, tapGesture.onActionCallback);
|
||||
tapGesture.allowedTypes, tapGesture.fingers, tapGesture.count, tapGesture.onActionCallback);
|
||||
break;
|
||||
}
|
||||
case CommonGestureType.LONG_PRESS_GESTURE: {
|
||||
let longPressGesture: LongPressGestureHandler = gesture as LongPressGestureHandler;
|
||||
getUINativeModule().common.addLongPressGesture(this._nodePtr, priority, mask, longPressGesture.gestureTag,
|
||||
longPressGesture.fingers, longPressGesture.repeat, longPressGesture.duration,
|
||||
longPressGesture.allowedTypes, longPressGesture.fingers, longPressGesture.repeat, longPressGesture.duration,
|
||||
longPressGesture.onActionCallback, longPressGesture.onActionEndCallback, longPressGesture.onActionCancelCallback);
|
||||
break;
|
||||
}
|
||||
case CommonGestureType.PAN_GESTURE: {
|
||||
let panGesture: PanGestureHandler = gesture as PanGestureHandler;
|
||||
getUINativeModule().common.addPanGesture(this._nodePtr, priority, mask, panGesture.gestureTag,
|
||||
panGesture.fingers, panGesture.direction, panGesture.distance, panGesture.onActionStartCallback,
|
||||
panGesture.allowedTypes, panGesture.fingers, panGesture.direction, panGesture.distance, panGesture.onActionStartCallback,
|
||||
panGesture.onActionUpdateCallback, panGesture.onActionEndCallback, panGesture.onActionCancelCallback);
|
||||
break;
|
||||
}
|
||||
case CommonGestureType.SWIPE_GESTURE: {
|
||||
let swipeGesture: SwipeGestureHandler = gesture as SwipeGestureHandler;
|
||||
getUINativeModule().common.addSwipeGesture(this._nodePtr, priority, mask, swipeGesture.gestureTag,
|
||||
swipeGesture.fingers, swipeGesture.direction, swipeGesture.speed, swipeGesture.onActionCallback);
|
||||
swipeGesture.allowedTypes, swipeGesture.fingers, swipeGesture.direction, swipeGesture.speed, swipeGesture.onActionCallback);
|
||||
break;
|
||||
}
|
||||
case CommonGestureType.PINCH_GESTURE: {
|
||||
let pinchGesture: PinchGestureHandler = gesture as PinchGestureHandler;
|
||||
getUINativeModule().common.addPinchGesture(this._nodePtr, priority, mask, pinchGesture.gestureTag,
|
||||
pinchGesture.fingers, pinchGesture.distance, pinchGesture.onActionStartCallback,
|
||||
pinchGesture.allowedTypes, pinchGesture.fingers, pinchGesture.distance, pinchGesture.onActionStartCallback,
|
||||
pinchGesture.onActionUpdateCallback, pinchGesture.onActionEndCallback, pinchGesture.onActionCancelCallback);
|
||||
break;
|
||||
}
|
||||
case CommonGestureType.ROTATION_GESTURE: {
|
||||
let rotationGesture: RotationGestureHandler = gesture as RotationGestureHandler;
|
||||
getUINativeModule().common.addRotationGesture(this._nodePtr, priority, mask, rotationGesture.gestureTag,
|
||||
rotationGesture.fingers, rotationGesture.angle, rotationGesture.onActionStartCallback,
|
||||
rotationGesture.allowedTypes, rotationGesture.fingers, rotationGesture.angle, rotationGesture.onActionStartCallback,
|
||||
rotationGesture.onActionUpdateCallback, rotationGesture.onActionEndCallback,
|
||||
rotationGesture.onActionCancelCallback);
|
||||
break;
|
||||
@ -4802,40 +4802,40 @@ function addGestureToGroup(gesture: any, gestureGroupPtr: any) {
|
||||
switch (gesture.gestureType) {
|
||||
case CommonGestureType.TAP_GESTURE: {
|
||||
let tapGesture: TapGestureHandler = gesture as TapGestureHandler;
|
||||
getUINativeModule().common.addTapGestureToGroup(tapGesture.gestureTag,
|
||||
getUINativeModule().common.addTapGestureToGroup(tapGesture.gestureTag, tapGesture.allowedTypes,
|
||||
tapGesture.fingers, tapGesture.count, tapGesture.onActionCallback, gestureGroupPtr);
|
||||
break;
|
||||
}
|
||||
case CommonGestureType.LONG_PRESS_GESTURE: {
|
||||
let longPressGesture: LongPressGestureHandler = gesture as LongPressGestureHandler;
|
||||
getUINativeModule().common.addLongPressGestureToGroup(longPressGesture.gestureTag,
|
||||
getUINativeModule().common.addLongPressGestureToGroup(longPressGesture.gestureTag, longPressGesture.allowedTypes,
|
||||
longPressGesture.fingers, longPressGesture.repeat, longPressGesture.duration,
|
||||
longPressGesture.onActionCallback, longPressGesture.onActionEndCallback, longPressGesture.onActionCancelCallback, gestureGroupPtr);
|
||||
break;
|
||||
}
|
||||
case CommonGestureType.PAN_GESTURE: {
|
||||
let panGesture: PanGestureHandler = gesture as PanGestureHandler;
|
||||
getUINativeModule().common.addPanGestureToGroup(panGesture.gestureTag,
|
||||
getUINativeModule().common.addPanGestureToGroup(panGesture.gestureTag, panGesture.allowedTypes,
|
||||
panGesture.fingers, panGesture.direction, panGesture.distance, panGesture.onActionStartCallback,
|
||||
panGesture.onActionUpdateCallback, panGesture.onActionEndCallback, panGesture.onActionCancelCallback, gestureGroupPtr);
|
||||
break;
|
||||
}
|
||||
case CommonGestureType.SWIPE_GESTURE: {
|
||||
let swipeGesture: SwipeGestureHandler = gesture as SwipeGestureHandler;
|
||||
getUINativeModule().common.addSwipeGestureToGroup(swipeGesture.gestureTag,
|
||||
getUINativeModule().common.addSwipeGestureToGroup(swipeGesture.gestureTag, swipeGesture.allowedTypes,
|
||||
swipeGesture.fingers, swipeGesture.direction, swipeGesture.speed, swipeGesture.onActionCallback, gestureGroupPtr);
|
||||
break;
|
||||
}
|
||||
case CommonGestureType.PINCH_GESTURE: {
|
||||
let pinchGesture: PinchGestureHandler = gesture as PinchGestureHandler;
|
||||
getUINativeModule().common.addPinchGestureToGroup(pinchGesture.gestureTag,
|
||||
getUINativeModule().common.addPinchGestureToGroup(pinchGesture.gestureTag, pinchGesture.allowedTypes,
|
||||
pinchGesture.fingers, pinchGesture.distance, pinchGesture.onActionStartCallback,
|
||||
pinchGesture.onActionUpdateCallback, pinchGesture.onActionEndCallback, pinchGesture.onActionCancelCallback, gestureGroupPtr);
|
||||
break;
|
||||
}
|
||||
case CommonGestureType.ROTATION_GESTURE: {
|
||||
let rotationGesture: RotationGestureHandler = gesture as RotationGestureHandler;
|
||||
getUINativeModule().common.addRotationGestureToGroup(rotationGesture.gestureTag,
|
||||
getUINativeModule().common.addRotationGestureToGroup(rotationGesture.gestureTag, rotationGesture.allowedTypes,
|
||||
rotationGesture.fingers, rotationGesture.angle, rotationGesture.onActionStartCallback,
|
||||
rotationGesture.onActionUpdateCallback, rotationGesture.onActionEndCallback,
|
||||
rotationGesture.onActionCancelCallback, gestureGroupPtr);
|
||||
|
@ -36,6 +36,7 @@ class TapGestureHandler extends GestureHandler {
|
||||
fingers?: number;
|
||||
count?: number;
|
||||
gestureTag?: string;
|
||||
allowedTypes?: Array<SourceTool>;
|
||||
onActionCallback?: Callback<GestureEvent>;
|
||||
|
||||
constructor(options?: TapGestureHandlerOptions) {
|
||||
@ -53,6 +54,10 @@ class TapGestureHandler extends GestureHandler {
|
||||
this.gestureTag = tag;
|
||||
return this;
|
||||
}
|
||||
allowedTypes(types: Array<SourceTool>) {
|
||||
this.allowedTypes = types;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
class LongPressGestureHandler extends GestureHandler {
|
||||
@ -60,6 +65,7 @@ class LongPressGestureHandler extends GestureHandler {
|
||||
repeat?: boolean;
|
||||
duration?: number;
|
||||
gestureTag?: string;
|
||||
allowedTypes?: Array<SourceTool>;
|
||||
onActionCallback?: Callback<GestureEvent>;
|
||||
onActionEndCallback?: Callback<GestureEvent>;
|
||||
onActionCancelCallback?: Callback<void>;
|
||||
@ -91,6 +97,11 @@ class LongPressGestureHandler extends GestureHandler {
|
||||
this.gestureTag = tag;
|
||||
return this;
|
||||
}
|
||||
|
||||
allowedTypes(types: Array<SourceTool>) {
|
||||
this.allowedTypes = types;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
class PanGestureHandler extends GestureHandler {
|
||||
@ -98,6 +109,7 @@ class PanGestureHandler extends GestureHandler {
|
||||
direction?: PanDirection;
|
||||
distance?: number;
|
||||
gestureTag?: string;
|
||||
allowedTypes?: Array<SourceTool>;
|
||||
onActionStartCallback?: Callback<GestureEvent>;
|
||||
onActionUpdateCallback?: Callback<GestureEvent>;
|
||||
onActionEndCallback?: Callback<GestureEvent>;
|
||||
@ -135,6 +147,11 @@ class PanGestureHandler extends GestureHandler {
|
||||
this.gestureTag = tag;
|
||||
return this;
|
||||
}
|
||||
|
||||
allowedTypes(types: Array<SourceTool>) {
|
||||
this.allowedTypes = types;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
class SwipeGestureHandler extends GestureHandler {
|
||||
@ -142,6 +159,7 @@ class SwipeGestureHandler extends GestureHandler {
|
||||
direction?: SwipeDirection;
|
||||
speed?: number;
|
||||
gestureTag?: string;
|
||||
allowedTypes?: Array<SourceTool>;
|
||||
onActionCallback?: Callback<GestureEvent>;
|
||||
constructor(options?: SwipeGestureHandlerOptions) {
|
||||
super(CommonGestureType.PAN_GESTURE);
|
||||
@ -161,12 +179,18 @@ class SwipeGestureHandler extends GestureHandler {
|
||||
this.gestureTag = tag;
|
||||
return this;
|
||||
}
|
||||
|
||||
allowedTypes(types: Array<SourceTool>) {
|
||||
this.allowedTypes = types;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
class PinchGestureHandler extends GestureHandler {
|
||||
fingers?: number;
|
||||
distance?: number;
|
||||
gestureTag?: string;
|
||||
allowedTypes?: Array<SourceTool>;
|
||||
onActionStartCallback?: Callback<GestureEvent>;
|
||||
onActionUpdateCallback?: Callback<GestureEvent>;
|
||||
onActionEndCallback?: Callback<GestureEvent>;
|
||||
@ -203,12 +227,18 @@ class PinchGestureHandler extends GestureHandler {
|
||||
this.gestureTag = tag;
|
||||
return this;
|
||||
}
|
||||
|
||||
allowedTypes(types: Array<SourceTool>) {
|
||||
this.allowedTypes = types;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
class RotationGestureHandler extends GestureHandler {
|
||||
fingers?: number;
|
||||
angle?: number;
|
||||
gestureTag?: string;
|
||||
allowedTypes?: Array<SourceTool>;
|
||||
onActionStartCallback?: Callback<GestureEvent>;
|
||||
onActionUpdateCallback?: Callback<GestureEvent>;
|
||||
onActionEndCallback?: Callback<GestureEvent>;
|
||||
@ -245,6 +275,11 @@ class RotationGestureHandler extends GestureHandler {
|
||||
this.gestureTag = tag;
|
||||
return this;
|
||||
}
|
||||
|
||||
allowedTypes(types: Array<SourceTool>) {
|
||||
this.allowedTypes = types;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
class GestureGroupHandler extends GestureHandler {
|
||||
|
@ -4350,6 +4350,10 @@ class TapGestureHandler extends GestureHandler {
|
||||
this.gestureTag = tag;
|
||||
return this;
|
||||
}
|
||||
allowedTypes(types) {
|
||||
this.allowedTypes = types;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
class LongPressGestureHandler extends GestureHandler {
|
||||
@ -4381,6 +4385,11 @@ class LongPressGestureHandler extends GestureHandler {
|
||||
this.gestureTag = tag;
|
||||
return this;
|
||||
}
|
||||
|
||||
allowedTypes(types) {
|
||||
this.allowedTypes = types;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
class PanGestureHandler extends GestureHandler {
|
||||
@ -4417,6 +4426,11 @@ class PanGestureHandler extends GestureHandler {
|
||||
this.gestureTag = tag;
|
||||
return this;
|
||||
}
|
||||
|
||||
allowedTypes(types) {
|
||||
this.allowedTypes = types;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
class SwipeGestureHandler extends GestureHandler {
|
||||
@ -4438,6 +4452,11 @@ class SwipeGestureHandler extends GestureHandler {
|
||||
this.gestureTag = tag;
|
||||
return this;
|
||||
}
|
||||
|
||||
allowedTypes(types) {
|
||||
this.allowedTypes = types;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
class PinchGestureHandler extends GestureHandler {
|
||||
@ -4473,6 +4492,11 @@ class PinchGestureHandler extends GestureHandler {
|
||||
this.gestureTag = tag;
|
||||
return this;
|
||||
}
|
||||
|
||||
allowedTypes(types) {
|
||||
this.allowedTypes = types;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
class RotationGestureHandler extends GestureHandler {
|
||||
@ -4508,6 +4532,11 @@ class RotationGestureHandler extends GestureHandler {
|
||||
this.gestureTag = tag;
|
||||
return this;
|
||||
}
|
||||
|
||||
allowedTypes(types) {
|
||||
this.allowedTypes = types;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
class GestureGroupHandler extends GestureHandler {
|
||||
@ -4679,40 +4708,40 @@ class UIGestureEvent {
|
||||
case CommonGestureType.TAP_GESTURE: {
|
||||
let tapGesture = gesture;
|
||||
getUINativeModule().common.addTapGesture(this._nodePtr, priority, mask, tapGesture.gestureTag,
|
||||
tapGesture.fingers, tapGesture.count, tapGesture.onActionCallback);
|
||||
tapGesture.allowedTypes, tapGesture.fingers, tapGesture.count, tapGesture.onActionCallback);
|
||||
break;
|
||||
}
|
||||
case CommonGestureType.LONG_PRESS_GESTURE: {
|
||||
let longPressGesture = gesture;
|
||||
getUINativeModule().common.addLongPressGesture(this._nodePtr, priority, mask, longPressGesture.gestureTag,
|
||||
longPressGesture.fingers, longPressGesture.repeat, longPressGesture.duration,
|
||||
longPressGesture.allowedTypes, longPressGesture.fingers, longPressGesture.repeat, longPressGesture.duration,
|
||||
longPressGesture.onActionCallback, longPressGesture.onActionEndCallback, longPressGesture.onActionCancelCallback);
|
||||
break;
|
||||
}
|
||||
case CommonGestureType.PAN_GESTURE: {
|
||||
let panGesture = gesture;
|
||||
getUINativeModule().common.addPanGesture(this._nodePtr, priority, mask, panGesture.gestureTag,
|
||||
panGesture.fingers, panGesture.direction, panGesture.distance, panGesture.onActionStartCallback,
|
||||
panGesture.allowedTypes, panGesture.fingers, panGesture.direction, panGesture.distance, panGesture.onActionStartCallback,
|
||||
panGesture.onActionUpdateCallback, panGesture.onActionEndCallback, panGesture.onActionCancelCallback);
|
||||
break;
|
||||
}
|
||||
case CommonGestureType.SWIPE_GESTURE: {
|
||||
let swipeGesture = gesture;
|
||||
getUINativeModule().common.addSwipeGesture(this._nodePtr, priority, mask, swipeGesture.gestureTag,
|
||||
swipeGesture.fingers, swipeGesture.direction, swipeGesture.speed, swipeGesture.onActionCallback);
|
||||
swipeGesture.allowedTypes, swipeGesture.fingers, swipeGesture.direction, swipeGesture.speed, swipeGesture.onActionCallback);
|
||||
break;
|
||||
}
|
||||
case CommonGestureType.PINCH_GESTURE: {
|
||||
let pinchGesture = gesture;
|
||||
getUINativeModule().common.addPinchGesture(this._nodePtr, priority, mask, pinchGesture.gestureTag,
|
||||
pinchGesture.fingers, pinchGesture.distance, pinchGesture.onActionStartCallback,
|
||||
pinchGesture.allowedTypes, pinchGesture.fingers, pinchGesture.distance, pinchGesture.onActionStartCallback,
|
||||
pinchGesture.onActionUpdateCallback, pinchGesture.onActionEndCallback, pinchGesture.onActionCancelCallback);
|
||||
break;
|
||||
}
|
||||
case CommonGestureType.ROTATION_GESTURE: {
|
||||
let rotationGesture = gesture;
|
||||
getUINativeModule().common.addRotationGesture(this._nodePtr, priority, mask, rotationGesture.gestureTag,
|
||||
rotationGesture.fingers, rotationGesture.angle, rotationGesture.onActionStartCallback,
|
||||
rotationGesture.allowedTypes, rotationGesture.fingers, rotationGesture.angle, rotationGesture.onActionStartCallback,
|
||||
rotationGesture.onActionUpdateCallback, rotationGesture.onActionEndCallback,
|
||||
rotationGesture.onActionCancelCallback);
|
||||
break;
|
||||
@ -4752,40 +4781,40 @@ function addGestureToGroup(gesture, gestureGroupPtr) {
|
||||
switch (gesture.gestureType) {
|
||||
case CommonGestureType.TAP_GESTURE: {
|
||||
let tapGesture = gesture;
|
||||
getUINativeModule().common.addTapGestureToGroup(tapGesture.gestureTag,
|
||||
getUINativeModule().common.addTapGestureToGroup(tapGesture.gestureTag, tapGesture.allowedTypes,
|
||||
tapGesture.fingers, tapGesture.count, tapGesture.onActionCallback, gestureGroupPtr);
|
||||
break;
|
||||
}
|
||||
case CommonGestureType.LONG_PRESS_GESTURE: {
|
||||
let longPressGesture = gesture;
|
||||
getUINativeModule().common.addLongPressGestureToGroup(longPressGesture.gestureTag,
|
||||
getUINativeModule().common.addLongPressGestureToGroup(longPressGesture.gestureTag, longPressGesture.allowedTypes,
|
||||
longPressGesture.fingers, longPressGesture.repeat, longPressGesture.duration,
|
||||
longPressGesture.onActionCallback, longPressGesture.onActionEndCallback, longPressGesture.onActionCancelCallback, gestureGroupPtr);
|
||||
break;
|
||||
}
|
||||
case CommonGestureType.PAN_GESTURE: {
|
||||
let panGesture = gesture;
|
||||
getUINativeModule().common.addPanGestureToGroup(panGesture.gestureTag,
|
||||
getUINativeModule().common.addPanGestureToGroup(panGesture.gestureTag, panGesture.allowedTypes,
|
||||
panGesture.fingers, panGesture.direction, panGesture.distance, panGesture.onActionStartCallback,
|
||||
panGesture.onActionUpdateCallback, panGesture.onActionEndCallback, panGesture.onActionCancelCallback, gestureGroupPtr);
|
||||
break;
|
||||
}
|
||||
case CommonGestureType.SWIPE_GESTURE: {
|
||||
let swipeGesture = gesture;
|
||||
getUINativeModule().common.addSwipeGestureToGroup(swipeGesture.gestureTag,
|
||||
getUINativeModule().common.addSwipeGestureToGroup(swipeGesture.gestureTag, swipeGesture.allowedTypes,
|
||||
swipeGesture.fingers, swipeGesture.direction, swipeGesture.speed, swipeGesture.onActionCallback, gestureGroupPtr);
|
||||
break;
|
||||
}
|
||||
case CommonGestureType.PINCH_GESTURE: {
|
||||
let pinchGesture = gesture;
|
||||
getUINativeModule().common.addPinchGestureToGroup(pinchGesture.gestureTag,
|
||||
getUINativeModule().common.addPinchGestureToGroup(pinchGesture.gestureTag, pinchGesture.allowedTypes,
|
||||
pinchGesture.fingers, pinchGesture.distance, pinchGesture.onActionStartCallback,
|
||||
pinchGesture.onActionUpdateCallback, pinchGesture.onActionEndCallback, pinchGesture.onActionCancelCallback, gestureGroupPtr);
|
||||
break;
|
||||
}
|
||||
case CommonGestureType.ROTATION_GESTURE: {
|
||||
let rotationGesture = gesture;
|
||||
getUINativeModule().common.addRotationGestureToGroup(rotationGesture.gestureTag,
|
||||
getUINativeModule().common.addRotationGestureToGroup(rotationGesture.gestureTag, rotationGesture.allowedTypes,
|
||||
rotationGesture.fingers, rotationGesture.angle, rotationGesture.onActionStartCallback,
|
||||
rotationGesture.onActionUpdateCallback, rotationGesture.onActionEndCallback,
|
||||
rotationGesture.onActionCancelCallback, gestureGroupPtr);
|
||||
|
@ -773,7 +773,7 @@ static const std::unordered_map<std::string, std::function<void(BindingTarget)>>
|
||||
{ "RichText", JSRichText::JSBind },
|
||||
{ "Web", JSWeb::JSBind },
|
||||
{ "WebController", JSWebController::JSBind },
|
||||
#if defined(PLAYER_FRAMEWORK_EXISTS) && defined(VIDEO_SUPPORTED)
|
||||
#if defined(PLAYER_FRAMEWORK_EXISTS)
|
||||
{ "Video", JSVideo::JSBind },
|
||||
{ "VideoController", JSVideoController::JSBind },
|
||||
#endif
|
||||
|
@ -49,6 +49,7 @@ constexpr int NUM_7 = 7;
|
||||
constexpr int NUM_8 = 8;
|
||||
constexpr int NUM_9 = 9;
|
||||
constexpr int NUM_10 = 10;
|
||||
constexpr int NUM_11 = 11;
|
||||
constexpr int NUM_13 = 13;
|
||||
constexpr int SIZE_OF_TWO = 2;
|
||||
constexpr int SIZE_OF_THREE = 3;
|
||||
@ -6207,6 +6208,31 @@ void CommonBridge::SetGestureTag(ArkUIRuntimeCallInfo* runtimeCallInfo, uint32_t
|
||||
}
|
||||
}
|
||||
|
||||
void CommonBridge::SetGestureAllowedTypes(ArkUIRuntimeCallInfo* runtimeCallInfo, uint32_t argNumber,
|
||||
ArkUIGesture* gesture)
|
||||
{
|
||||
EcmaVM* vm = runtimeCallInfo->GetVM();
|
||||
CHECK_NULL_VOID(vm);
|
||||
Local<JSValueRef> typesArg = runtimeCallInfo->GetCallArgRef(argNumber);
|
||||
if (typesArg.IsNull() || typesArg->IsUndefined() || !typesArg->IsArray(vm)) {
|
||||
return;
|
||||
}
|
||||
auto typesArr = panda::Local<panda::ArrayRef>(typesArg);
|
||||
auto typesLength = typesArr->Length(vm);
|
||||
std::set<SourceTool> allowedTypes{};
|
||||
for (size_t i = 0; i < typesLength; ++i) {
|
||||
auto type = panda::ArrayRef::GetValueAt(vm, typesArr, i);
|
||||
if (type->IsNumber()) {
|
||||
allowedTypes.insert(static_cast<SourceTool>(type->Int32Value(vm)));
|
||||
}
|
||||
}
|
||||
if (allowedTypes.empty()) {
|
||||
return;
|
||||
}
|
||||
auto gesturePtr = Referenced::Claim(reinterpret_cast<Gesture*>(gesture));
|
||||
gesturePtr->SetAllowedTypes(allowedTypes);
|
||||
}
|
||||
|
||||
void CommonBridge::GetTapGestureValue(ArkUIRuntimeCallInfo* runtimeCallInfo, int32_t& fingers,
|
||||
int32_t& count, double& distanceThreshold, uint32_t argNumber)
|
||||
{
|
||||
@ -7188,11 +7214,12 @@ ArkUINativeModuleValue CommonBridge::AddTapGesture(ArkUIRuntimeCallInfo* runtime
|
||||
int32_t fingers = DEFAULT_TAP_FINGER;
|
||||
int32_t count = DEFAULT_TAP_COUNT;
|
||||
double distanceThreshold = DEFAULT_TAP_DISTANCE;
|
||||
GetTapGestureValue(runtimeCallInfo, fingers, count, distanceThreshold, NUM_4);
|
||||
GetTapGestureValue(runtimeCallInfo, fingers, count, distanceThreshold, NUM_5);
|
||||
auto* gesture = GetArkUINodeModifiers()->getGestureModifier()->
|
||||
createTapGestureWithDistanceThreshold(count, fingers, distanceThreshold, nullptr);
|
||||
SetGestureTag(runtimeCallInfo, NUM_3, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::ACTION, NUM_6, gesture);
|
||||
SetGestureAllowedTypes(runtimeCallInfo, NUM_4, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::ACTION, NUM_7, gesture);
|
||||
GetArkUINodeModifiers()->getGestureModifier()->addGestureToNodeWithRefCountDecrease(
|
||||
nativeNode, gesture, priority, mask);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
@ -7212,13 +7239,14 @@ ArkUINativeModuleValue CommonBridge::AddLongPressGesture(ArkUIRuntimeCallInfo* r
|
||||
int32_t fingers = DEFAULT_LONG_PRESS_FINGER;
|
||||
bool repeat = false;
|
||||
int32_t duration = DEFAULT_LONG_PRESS_DURATION;
|
||||
GetLongPressGestureValue(runtimeCallInfo, fingers, repeat, duration, NUM_4);
|
||||
GetLongPressGestureValue(runtimeCallInfo, fingers, repeat, duration, NUM_5);
|
||||
auto* gesture = GetArkUINodeModifiers()->getGestureModifier()->createLongPressGesture(
|
||||
fingers, repeat, duration, nullptr);
|
||||
SetGestureTag(runtimeCallInfo, NUM_3, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::ACTION, NUM_7, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::END, NUM_8, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::CANCEL, NUM_9, gesture);
|
||||
SetGestureAllowedTypes(runtimeCallInfo, NUM_4, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::ACTION, NUM_8, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::END, NUM_9, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::CANCEL, NUM_10, gesture);
|
||||
GetArkUINodeModifiers()->getGestureModifier()->addGestureToNodeWithRefCountDecrease(
|
||||
nativeNode, gesture, priority, mask);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
@ -7238,14 +7266,15 @@ ArkUINativeModuleValue CommonBridge::AddPanGesture(ArkUIRuntimeCallInfo* runtime
|
||||
int32_t fingers = DEFAULT_PAN_FINGER;
|
||||
int32_t direction = PanDirection::ALL;
|
||||
double distance = DEFAULT_PAN_DISTANCE.ConvertToPx();
|
||||
GetPanGestureValue(runtimeCallInfo, fingers, direction, distance, NUM_4);
|
||||
GetPanGestureValue(runtimeCallInfo, fingers, direction, distance, NUM_5);
|
||||
auto* gesture = GetArkUINodeModifiers()->getGestureModifier()->createPanGesture(
|
||||
fingers, direction, distance, nullptr);
|
||||
SetGestureTag(runtimeCallInfo, NUM_3, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::START, NUM_7, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::UPDATE, NUM_8, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::END, NUM_9, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::CANCEL, NUM_10, gesture);
|
||||
SetGestureAllowedTypes(runtimeCallInfo, NUM_4, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::START, NUM_8, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::UPDATE, NUM_9, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::END, NUM_10, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::CANCEL, NUM_11, gesture);
|
||||
GetArkUINodeModifiers()->getGestureModifier()->addGestureToNodeWithRefCountDecrease(
|
||||
nativeNode, gesture, priority, mask);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
@ -7265,11 +7294,12 @@ ArkUINativeModuleValue CommonBridge::AddSwipeGesture(ArkUIRuntimeCallInfo* runti
|
||||
int32_t fingers = DEFAULT_SLIDE_FINGER;
|
||||
int32_t direction = SwipeDirection::ALL;
|
||||
double speed = DEFAULT_SLIDE_SPEED;
|
||||
GetSwipeGestureValue(runtimeCallInfo, fingers, direction, speed, NUM_4);
|
||||
GetSwipeGestureValue(runtimeCallInfo, fingers, direction, speed, NUM_5);
|
||||
auto* gesture =
|
||||
GetArkUINodeModifiers()->getGestureModifier()->createSwipeGestureByModifier(fingers, direction, speed);
|
||||
SetGestureTag(runtimeCallInfo, NUM_3, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::ACTION, NUM_7, gesture);
|
||||
SetGestureAllowedTypes(runtimeCallInfo, NUM_4, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::ACTION, NUM_8, gesture);
|
||||
GetArkUINodeModifiers()->getGestureModifier()->addGestureToNodeWithRefCountDecrease(
|
||||
nativeNode, gesture, priority, mask);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
@ -7288,13 +7318,14 @@ ArkUINativeModuleValue CommonBridge::AddPinchGesture(ArkUIRuntimeCallInfo* runti
|
||||
GetGestureCommonValue(runtimeCallInfo, priority, mask);
|
||||
int32_t fingers = DEFAULT_PINCH_FINGER;
|
||||
double distance = DEFAULT_PINCH_DISTANCE;
|
||||
GetPinchGestureValue(runtimeCallInfo, fingers, distance, NUM_4);
|
||||
GetPinchGestureValue(runtimeCallInfo, fingers, distance, NUM_5);
|
||||
auto* gesture = GetArkUINodeModifiers()->getGestureModifier()->createPinchGesture(fingers, distance, nullptr);
|
||||
SetGestureTag(runtimeCallInfo, NUM_3, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::START, NUM_6, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::UPDATE, NUM_7, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::END, NUM_8, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::CANCEL, NUM_9, gesture);
|
||||
SetGestureAllowedTypes(runtimeCallInfo, NUM_4, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::START, NUM_7, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::UPDATE, NUM_8, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::END, NUM_9, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::CANCEL, NUM_10, gesture);
|
||||
GetArkUINodeModifiers()->getGestureModifier()->addGestureToNodeWithRefCountDecrease(
|
||||
nativeNode, gesture, priority, mask);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
@ -7313,13 +7344,14 @@ ArkUINativeModuleValue CommonBridge::AddRotationGesture(ArkUIRuntimeCallInfo* ru
|
||||
GetGestureCommonValue(runtimeCallInfo, priority, mask);
|
||||
int32_t fingers = DEFAULT_ROTATION_FINGER;
|
||||
double angle = DEFAULT_ROTATION_ANGLE;
|
||||
GetRotationGestureValue(runtimeCallInfo, fingers, angle, NUM_4);
|
||||
GetRotationGestureValue(runtimeCallInfo, fingers, angle, NUM_5);
|
||||
auto* gesture = GetArkUINodeModifiers()->getGestureModifier()->createRotationGesture(fingers, angle, nullptr);
|
||||
SetGestureTag(runtimeCallInfo, NUM_3, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::START, NUM_6, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::UPDATE, NUM_7, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::END, NUM_8, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::CANCEL, NUM_9, gesture);
|
||||
SetGestureAllowedTypes(runtimeCallInfo, NUM_4, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::START, NUM_7, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::UPDATE, NUM_8, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::END, NUM_9, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::CANCEL, NUM_10, gesture);
|
||||
GetArkUINodeModifiers()->getGestureModifier()->addGestureToNodeWithRefCountDecrease(
|
||||
nativeNode, gesture, priority, mask);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
@ -7344,12 +7376,13 @@ ArkUINativeModuleValue CommonBridge::AddTapGestureToGroup(ArkUIRuntimeCallInfo*
|
||||
int32_t fingers = DEFAULT_TAP_FINGER;
|
||||
int32_t count = DEFAULT_TAP_COUNT;
|
||||
double distanceThreshold = DEFAULT_TAP_DISTANCE;
|
||||
GetTapGestureValue(runtimeCallInfo, fingers, count, distanceThreshold, NUM_1);
|
||||
GetTapGestureValue(runtimeCallInfo, fingers, count, distanceThreshold, NUM_2);
|
||||
auto* gesture = GetArkUINodeModifiers()->getGestureModifier()->
|
||||
createTapGestureWithDistanceThreshold(count, fingers, distanceThreshold, nullptr);
|
||||
SetGestureTag(runtimeCallInfo, NUM_0, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::ACTION, NUM_3, gesture);
|
||||
auto* group = GetGestureGroup(runtimeCallInfo, NUM_4);
|
||||
SetGestureAllowedTypes(runtimeCallInfo, NUM_1, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::ACTION, NUM_4, gesture);
|
||||
auto* group = GetGestureGroup(runtimeCallInfo, NUM_5);
|
||||
GetArkUINodeModifiers()->getGestureModifier()->addGestureToGestureGroupWithRefCountDecrease(group, gesture);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
@ -7361,14 +7394,15 @@ ArkUINativeModuleValue CommonBridge::AddLongPressGestureToGroup(ArkUIRuntimeCall
|
||||
int32_t fingers = DEFAULT_LONG_PRESS_FINGER;
|
||||
bool repeat = false;
|
||||
int32_t duration = DEFAULT_LONG_PRESS_DURATION;
|
||||
GetLongPressGestureValue(runtimeCallInfo, fingers, repeat, duration, NUM_1);
|
||||
GetLongPressGestureValue(runtimeCallInfo, fingers, repeat, duration, NUM_2);
|
||||
auto* gesture = GetArkUINodeModifiers()->getGestureModifier()->createLongPressGesture(
|
||||
fingers, repeat, duration, nullptr);
|
||||
SetGestureTag(runtimeCallInfo, NUM_0, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::ACTION, NUM_4, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::END, NUM_5, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::CANCEL, NUM_6, gesture);
|
||||
auto* group = GetGestureGroup(runtimeCallInfo, NUM_7);
|
||||
SetGestureAllowedTypes(runtimeCallInfo, NUM_1, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::ACTION, NUM_5, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::END, NUM_6, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::CANCEL, NUM_7, gesture);
|
||||
auto* group = GetGestureGroup(runtimeCallInfo, NUM_8);
|
||||
GetArkUINodeModifiers()->getGestureModifier()->addGestureToGestureGroupWithRefCountDecrease(group, gesture);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
@ -7380,15 +7414,16 @@ ArkUINativeModuleValue CommonBridge::AddPanGestureToGroup(ArkUIRuntimeCallInfo*
|
||||
int32_t fingers = DEFAULT_PAN_FINGER;
|
||||
int32_t direction = PanDirection::ALL;
|
||||
double distance = DEFAULT_PAN_DISTANCE.ConvertToPx();
|
||||
GetPanGestureValue(runtimeCallInfo, fingers, direction, distance, NUM_1);
|
||||
GetPanGestureValue(runtimeCallInfo, fingers, direction, distance, NUM_2);
|
||||
auto* gesture = GetArkUINodeModifiers()->getGestureModifier()->createPanGesture(
|
||||
fingers, direction, distance, nullptr);
|
||||
SetGestureTag(runtimeCallInfo, NUM_0, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::START, NUM_4, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::UPDATE, NUM_5, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::END, NUM_6, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::CANCEL, NUM_7, gesture);
|
||||
auto* group = GetGestureGroup(runtimeCallInfo, NUM_8);
|
||||
SetGestureAllowedTypes(runtimeCallInfo, NUM_1, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::START, NUM_5, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::UPDATE, NUM_6, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::END, NUM_7, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::CANCEL, NUM_8, gesture);
|
||||
auto* group = GetGestureGroup(runtimeCallInfo, NUM_9);
|
||||
GetArkUINodeModifiers()->getGestureModifier()->addGestureToGestureGroupWithRefCountDecrease(group, gesture);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
@ -7400,12 +7435,13 @@ ArkUINativeModuleValue CommonBridge::AddSwipeGestureToGroup(ArkUIRuntimeCallInfo
|
||||
int32_t fingers = DEFAULT_SLIDE_FINGER;
|
||||
int32_t direction = SwipeDirection::ALL;
|
||||
double speed = DEFAULT_SLIDE_SPEED;
|
||||
GetSwipeGestureValue(runtimeCallInfo, fingers, direction, speed, NUM_1);
|
||||
GetSwipeGestureValue(runtimeCallInfo, fingers, direction, speed, NUM_2);
|
||||
auto* gesture =
|
||||
GetArkUINodeModifiers()->getGestureModifier()->createSwipeGestureByModifier(fingers, direction, speed);
|
||||
SetGestureTag(runtimeCallInfo, NUM_0, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::ACTION, NUM_4, gesture);
|
||||
auto* group = GetGestureGroup(runtimeCallInfo, NUM_5);
|
||||
SetGestureAllowedTypes(runtimeCallInfo, NUM_1, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::ACTION, NUM_5, gesture);
|
||||
auto* group = GetGestureGroup(runtimeCallInfo, NUM_6);
|
||||
GetArkUINodeModifiers()->getGestureModifier()->addGestureToGestureGroupWithRefCountDecrease(group, gesture);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
@ -7416,14 +7452,15 @@ ArkUINativeModuleValue CommonBridge::AddPinchGestureToGroup(ArkUIRuntimeCallInfo
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
int32_t fingers = DEFAULT_PINCH_FINGER;
|
||||
double distance = DEFAULT_PINCH_DISTANCE;
|
||||
GetPinchGestureValue(runtimeCallInfo, fingers, distance, NUM_1);
|
||||
GetPinchGestureValue(runtimeCallInfo, fingers, distance, NUM_2);
|
||||
auto* gesture = GetArkUINodeModifiers()->getGestureModifier()->createPinchGesture(fingers, distance, nullptr);
|
||||
SetGestureTag(runtimeCallInfo, NUM_0, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::START, NUM_3, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::UPDATE, NUM_4, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::END, NUM_5, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::CANCEL, NUM_6, gesture);
|
||||
auto* group = GetGestureGroup(runtimeCallInfo, NUM_7);
|
||||
SetGestureAllowedTypes(runtimeCallInfo, NUM_1, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::START, NUM_4, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::UPDATE, NUM_5, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::END, NUM_6, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::CANCEL, NUM_7, gesture);
|
||||
auto* group = GetGestureGroup(runtimeCallInfo, NUM_8);
|
||||
GetArkUINodeModifiers()->getGestureModifier()->addGestureToGestureGroupWithRefCountDecrease(group, gesture);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
@ -7434,14 +7471,15 @@ ArkUINativeModuleValue CommonBridge::AddRotationGestureToGroup(ArkUIRuntimeCallI
|
||||
CHECK_NULL_RETURN(vm, panda::JSValueRef::Undefined(vm));
|
||||
int32_t fingers = DEFAULT_ROTATION_FINGER;
|
||||
double angle = DEFAULT_ROTATION_ANGLE;
|
||||
GetRotationGestureValue(runtimeCallInfo, fingers, angle, NUM_1);
|
||||
GetRotationGestureValue(runtimeCallInfo, fingers, angle, NUM_2);
|
||||
auto* gesture = GetArkUINodeModifiers()->getGestureModifier()->createRotationGesture(fingers, angle, nullptr);
|
||||
SetGestureTag(runtimeCallInfo, NUM_0, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::START, NUM_3, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::UPDATE, NUM_4, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::END, NUM_5, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::CANCEL, NUM_6, gesture);
|
||||
auto* group = GetGestureGroup(runtimeCallInfo, NUM_7);
|
||||
SetGestureAllowedTypes(runtimeCallInfo, NUM_1, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::START, NUM_4, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::UPDATE, NUM_5, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::END, NUM_6, gesture);
|
||||
SetOnGestureEvent(runtimeCallInfo, GestureEventAction::CANCEL, NUM_7, gesture);
|
||||
auto* group = GetGestureGroup(runtimeCallInfo, NUM_8);
|
||||
GetArkUINodeModifiers()->getGestureModifier()->addGestureToGestureGroupWithRefCountDecrease(group, gesture);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
@ -268,6 +268,8 @@ public:
|
||||
static Local<panda::ObjectRef> CreateAreaObject(EcmaVM* vm, const RectF& rect, const OffsetF& origin);
|
||||
static void GetGestureCommonValue(ArkUIRuntimeCallInfo* runtimeCallInfo, int32_t& priority, int32_t& mask);
|
||||
static void SetGestureTag(ArkUIRuntimeCallInfo* runtimeCallInfo, uint32_t argNumber, ArkUIGesture* gesture);
|
||||
static void SetGestureAllowedTypes(
|
||||
ArkUIRuntimeCallInfo* runtimeCallInfo, uint32_t argNumber, ArkUIGesture* gesture);
|
||||
static void GetTapGestureValue(ArkUIRuntimeCallInfo* runtimeCallInfo, int32_t& fingers,
|
||||
int32_t& count, double& distanceThreshold, uint32_t argNumber);
|
||||
static void GetLongPressGestureValue(
|
||||
|
@ -89,7 +89,7 @@ void JSFormMenuItem::RequestPublishFormWithSnapshot(JSRef<JSVal> wantValue,
|
||||
errObj->SetProperty<int32_t>("code", errCode);
|
||||
errObj->SetProperty<std::string>("message", errMsg);
|
||||
params[0] = errObj;
|
||||
params[1] = JSRef<JSVal>::Make(ToJSValue(formId));
|
||||
params[1] = JSRef<JSVal>::Make(ToJSValue(std::to_string(formId)));
|
||||
jsCBFunc->ExecuteJS(NUM_CALLBACKNUM, params);
|
||||
}
|
||||
|
||||
|
@ -507,6 +507,31 @@ void JSGesture::SetTag(const JSCallbackInfo& args)
|
||||
GestureModel::GetInstance()->SetTag(tag);
|
||||
}
|
||||
|
||||
void JSGesture::SetAllowedTypes(const JSCallbackInfo& args)
|
||||
{
|
||||
if (args.Length() < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
JSRef<JSVal> jsTypes = args[0];
|
||||
if (!jsTypes->IsArray()) {
|
||||
return;
|
||||
}
|
||||
JSRef<JSArray> jsTypesArr = JSRef<JSArray>::Cast(jsTypes);
|
||||
std::set<SourceTool> allowedTypes{};
|
||||
auto typesArrLength = jsTypesArr->Length();
|
||||
for (size_t i = 0; i < typesArrLength; ++i) {
|
||||
auto type = jsTypesArr->GetValueAt(i);
|
||||
if (type->IsNumber()) {
|
||||
allowedTypes.insert(static_cast<SourceTool>(type->ToNumber<int32_t>()));
|
||||
}
|
||||
}
|
||||
if (allowedTypes.empty()) {
|
||||
return;
|
||||
}
|
||||
GestureModel::GetInstance()->SetAllowedTypes(allowedTypes);
|
||||
}
|
||||
|
||||
void JSGesture::JsHandlerOnAction(const JSCallbackInfo& args)
|
||||
{
|
||||
JSGesture::JsHandlerOnGestureEvent(Ace::GestureEventAction::ACTION, args);
|
||||
@ -649,6 +674,7 @@ void JSGesture::JSBind(BindingTarget globalObj)
|
||||
JSClass<JSTapGesture>::Declare("TapGesture");
|
||||
JSClass<JSTapGesture>::StaticMethod("create", &JSTapGesture::Create, opt);
|
||||
JSClass<JSTapGesture>::StaticMethod("tag", &JSGesture::SetTag, opt);
|
||||
JSClass<JSTapGesture>::StaticMethod("allowedTypes", &JSGesture::SetAllowedTypes);
|
||||
JSClass<JSTapGesture>::StaticMethod("pop", &JSGesture::Pop);
|
||||
JSClass<JSTapGesture>::StaticMethod("onAction", &JSGesture::JsHandlerOnAction);
|
||||
JSClass<JSTapGesture>::StaticMethod("onActionUpdate", &JSGesture::JsHandlerOnActionUpdate);
|
||||
@ -657,6 +683,7 @@ void JSGesture::JSBind(BindingTarget globalObj)
|
||||
JSClass<JSLongPressGesture>::Declare("LongPressGesture");
|
||||
JSClass<JSLongPressGesture>::StaticMethod("create", &JSLongPressGesture::Create, opt);
|
||||
JSClass<JSLongPressGesture>::StaticMethod("tag", &JSGesture::SetTag, opt);
|
||||
JSClass<JSLongPressGesture>::StaticMethod("allowedTypes", &JSGesture::SetAllowedTypes);
|
||||
JSClass<JSLongPressGesture>::StaticMethod("pop", &JSGesture::Pop);
|
||||
JSClass<JSLongPressGesture>::StaticMethod("onAction", &JSGesture::JsHandlerOnAction);
|
||||
JSClass<JSLongPressGesture>::StaticMethod("onActionEnd", &JSGesture::JsHandlerOnActionEnd);
|
||||
@ -667,6 +694,7 @@ void JSGesture::JSBind(BindingTarget globalObj)
|
||||
JSClass<JSPanGesture>::Declare("PanGesture");
|
||||
JSClass<JSPanGesture>::StaticMethod("create", &JSPanGesture::Create, opt);
|
||||
JSClass<JSPanGesture>::StaticMethod("tag", &JSGesture::SetTag, opt);
|
||||
JSClass<JSPanGesture>::StaticMethod("allowedTypes", &JSGesture::SetAllowedTypes);
|
||||
JSClass<JSPanGesture>::StaticMethod("pop", &JSGesture::Pop);
|
||||
JSClass<JSPanGesture>::StaticMethod("onActionStart", &JSGesture::JsHandlerOnActionStart);
|
||||
JSClass<JSPanGesture>::StaticMethod("onActionUpdate", &JSGesture::JsHandlerOnActionUpdate);
|
||||
@ -677,6 +705,7 @@ void JSGesture::JSBind(BindingTarget globalObj)
|
||||
JSClass<JSSwipeGesture>::Declare("SwipeGesture");
|
||||
JSClass<JSSwipeGesture>::StaticMethod("create", &JSSwipeGesture::Create, opt);
|
||||
JSClass<JSSwipeGesture>::StaticMethod("tag", &JSGesture::SetTag, opt);
|
||||
JSClass<JSSwipeGesture>::StaticMethod("allowedTypes", &JSGesture::SetAllowedTypes);
|
||||
JSClass<JSSwipeGesture>::StaticMethod("pop", &JSGesture::Pop);
|
||||
JSClass<JSSwipeGesture>::StaticMethod("onAction", &JSGesture::JsHandlerOnAction);
|
||||
JSClass<JSSwipeGesture>::Bind(globalObj);
|
||||
@ -684,6 +713,7 @@ void JSGesture::JSBind(BindingTarget globalObj)
|
||||
JSClass<JSPinchGesture>::Declare("PinchGesture");
|
||||
JSClass<JSPinchGesture>::StaticMethod("create", &JSPinchGesture::Create, opt);
|
||||
JSClass<JSPinchGesture>::StaticMethod("tag", &JSGesture::SetTag, opt);
|
||||
JSClass<JSPinchGesture>::StaticMethod("allowedTypes", &JSGesture::SetAllowedTypes);
|
||||
JSClass<JSPinchGesture>::StaticMethod("pop", &JSGesture::Pop);
|
||||
JSClass<JSPinchGesture>::StaticMethod("onActionStart", &JSGesture::JsHandlerOnActionStart);
|
||||
JSClass<JSPinchGesture>::StaticMethod("onActionUpdate", &JSGesture::JsHandlerOnActionUpdate);
|
||||
@ -694,6 +724,7 @@ void JSGesture::JSBind(BindingTarget globalObj)
|
||||
JSClass<JSRotationGesture>::Declare("RotationGesture");
|
||||
JSClass<JSRotationGesture>::StaticMethod("create", &JSRotationGesture::Create, opt);
|
||||
JSClass<JSRotationGesture>::StaticMethod("tag", &JSGesture::SetTag, opt);
|
||||
JSClass<JSRotationGesture>::StaticMethod("allowedTypes", &JSGesture::SetAllowedTypes);
|
||||
JSClass<JSRotationGesture>::StaticMethod("pop", &JSGesture::Pop);
|
||||
JSClass<JSRotationGesture>::StaticMethod("onActionStart", &JSGesture::JsHandlerOnActionStart);
|
||||
JSClass<JSRotationGesture>::StaticMethod("onActionUpdate", &JSGesture::JsHandlerOnActionUpdate);
|
||||
|
@ -45,6 +45,7 @@ public:
|
||||
static void JsHandlerOnActionCancel(const JSCallbackInfo& args);
|
||||
static void JsHandlerOnGestureEvent(Ace::GestureEventAction action, const JSCallbackInfo& args);
|
||||
static void SetTag(const JSCallbackInfo& args);
|
||||
static void SetAllowedTypes(const JSCallbackInfo& args);
|
||||
}; // JSGesture
|
||||
|
||||
class JSTapGesture : public JSGesture {
|
||||
|
@ -28,6 +28,7 @@ public:
|
||||
void SetOnGestureEvent(const GestureEventNoParameter& gestureEventNoParameter) override;
|
||||
void SetOnActionFunc(const GestureEventFunc& gestureEventFunc, const Ace::GestureEventAction& action) override;
|
||||
void SetTag(const std::string& tag) override {}
|
||||
void SetAllowedTypes(const std::set<SourceTool>& allowedTypes) override {}
|
||||
};
|
||||
|
||||
class TapGestureModelImpl : public OHOS::Ace::TapGestureModel {
|
||||
|
@ -52,7 +52,7 @@ public:
|
||||
virtual RefPtr<PasteDataMix> CreatePasteDataMix() = 0;
|
||||
virtual void Clear() = 0;
|
||||
virtual void GetSpanStringData(
|
||||
const std::function<void(std::vector<std::vector<uint8_t>>&, const std::string&)>& callback,
|
||||
const std::function<void(std::vector<std::vector<uint8_t>>&, const std::string&, bool&)>& callback,
|
||||
bool syncMode = false) = 0;
|
||||
|
||||
protected:
|
||||
|
@ -144,19 +144,30 @@ void GetMatchedNodes(const std::string& pageUrl, const RefPtr<NG::UINode>& root,
|
||||
}
|
||||
}
|
||||
|
||||
void EventController::ApplyNewestConfig()
|
||||
void EventController::ApplyNewestConfig() const
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(cacheLock_);
|
||||
if (clientList_.empty()) {
|
||||
return;
|
||||
}
|
||||
auto containerId = EventRecorder::Get().GetContainerId();
|
||||
auto config = clientList_.back().config.GetConfig();
|
||||
|
||||
auto context = NG::PipelineContext::GetContextByContainerId(containerId);
|
||||
CHECK_NULL_VOID(context);
|
||||
auto taskExecutor = context->GetTaskExecutor();
|
||||
CHECK_NULL_VOID(taskExecutor);
|
||||
taskExecutor->PostDelayedTask([config]() { EventController::Get().ApplyExposureCfgInner(config); },
|
||||
TaskExecutor::TaskType::UI, EXPOSURE_REGISTER_DELAY, "EventController");
|
||||
}
|
||||
|
||||
void EventController::ApplyExposureCfgInner(const std::shared_ptr<Config>& config) const
|
||||
{
|
||||
auto containerId = EventRecorder::Get().GetContainerId();
|
||||
auto pageUrl = GetPageUrlByContainerId(containerId);
|
||||
if (pageUrl.empty()) {
|
||||
return;
|
||||
}
|
||||
auto config = clientList_.back().config.GetConfig();
|
||||
lock.unlock();
|
||||
auto pageIter = config->find(pageUrl);
|
||||
if (pageIter == config->end()) {
|
||||
return;
|
||||
@ -173,18 +184,12 @@ void EventController::ApplyNewestConfig()
|
||||
[&exposureSet](const std::list<ExposureCfg>::value_type& cfg) { exposureSet.emplace(cfg); });
|
||||
std::list<ExposureWrapper> targets;
|
||||
GetMatchedNodes(pageUrl, rootNode, exposureSet, targets);
|
||||
auto taskExecutor = context->GetTaskExecutor();
|
||||
CHECK_NULL_VOID(taskExecutor);
|
||||
taskExecutor->PostDelayedTask(
|
||||
[containerId, wrapperList = std::move(targets)]() {
|
||||
for (auto& item : wrapperList) {
|
||||
for (auto& item : targets) {
|
||||
item.processor->SetContainerId(containerId);
|
||||
auto node = item.node.Upgrade();
|
||||
CHECK_NULL_VOID(node);
|
||||
node->SetExposureProcessor(item.processor);
|
||||
}
|
||||
},
|
||||
TaskExecutor::TaskType::UI, EXPOSURE_REGISTER_DELAY, "EventController");
|
||||
}
|
||||
|
||||
void EventController::Unregister(const std::shared_ptr<UIEventObserver>& observer)
|
||||
|
@ -48,9 +48,10 @@ private:
|
||||
EventController() = default;
|
||||
~EventController() = default;
|
||||
void NotifyConfigChange();
|
||||
void ApplyNewestConfig();
|
||||
void ApplyNewestConfig() const;
|
||||
void ApplyExposureCfgInner(const std::shared_ptr<Config>& config) const;
|
||||
|
||||
std::shared_mutex cacheLock_;
|
||||
std::shared_mutex mutable cacheLock_;
|
||||
std::vector<UIEventClient> clientList_;
|
||||
|
||||
ACE_DISALLOW_COPY_AND_MOVE(EventController);
|
||||
|
@ -111,6 +111,9 @@ private:
|
||||
bool isRegistered_ = false;
|
||||
int32_t nodeId_ = 0;
|
||||
WeakPtr<NG::LayoutInfoInterface> layoutInfo_;
|
||||
int32_t sInd_ = -1;
|
||||
int32_t eInd_ = -1;
|
||||
bool showMenu_ = false;
|
||||
};
|
||||
} // namespace OHOS::Ace
|
||||
#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_STYLUS_STYLUS_DETECTOR_MGR_H
|
@ -15,12 +15,6 @@
|
||||
|
||||
#include "core/components/button/rosen_render_button.h"
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
#include "include/core/SkMaskFilter.h"
|
||||
#include "include/core/SkPath.h"
|
||||
#include "include/core/SkRRect.h"
|
||||
#endif
|
||||
|
||||
#include "core/components/box/render_box.h"
|
||||
#include "core/pipeline/base/rosen_render_context.h"
|
||||
#ifdef OHOS_PLATFORM
|
||||
@ -82,22 +76,12 @@ void RosenRenderButton::UpdateLayer()
|
||||
opacityLayer_ = DEFAULT_OPACITY * opacity_;
|
||||
}
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void RosenRenderButton::PaintLayer(SkCanvas* canvas)
|
||||
#else
|
||||
void RosenRenderButton::PaintLayer(RSCanvas* canvas)
|
||||
#endif
|
||||
{
|
||||
#ifdef OHOS_PLATFORM
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
auto recordingCanvas = static_cast<Rosen::RSRecordingCanvas*>(canvas);
|
||||
recordingCanvas->MultiplyAlpha(opacityLayer_ / 255.0f);
|
||||
recordingCanvas->concat(RosenSvgPainter::ToSkMatrix(transformLayer_));
|
||||
#else
|
||||
auto recordingCanvas = static_cast<RSRecordingCanvas*>(canvas);
|
||||
recordingCanvas->ConcatMatrix(RosenSvgPainter::ToDrawingMatrix(transformLayer_));
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void RosenRenderButton::Paint(RenderContext& context, const Offset& offset)
|
||||
@ -251,43 +235,6 @@ void RosenRenderButton::ResetBoxRadius()
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void RosenRenderButton::DrawShape(SkCanvas* canvas, const Offset& offset, bool isStroke)
|
||||
{
|
||||
SkPaint paint;
|
||||
if (isStroke) {
|
||||
uint32_t focusColorValue = buttonComponent_->GetFocusColor().GetValue();
|
||||
uint32_t borderColorValue = buttonComponent_->GetBorderEdge().GetColor().GetValue();
|
||||
paint.setColor(needFocusColor_ ? focusColorValue : borderColorValue);
|
||||
paint.setStyle(SkPaint::Style::kStroke_Style);
|
||||
paint.setStrokeWidth(NormalizeToPx(borderEdge_.GetWidth()));
|
||||
} else {
|
||||
paint.setColor(GetStateColor());
|
||||
paint.setStyle(SkPaint::Style::kFill_Style);
|
||||
}
|
||||
paint.setAntiAlias(true);
|
||||
SkRRect rRect;
|
||||
|
||||
if (buttonComponent_->GetType() == ButtonType::CUSTOM) {
|
||||
ConvertToSkVector(buttonComponent_->GetRectRadii(), radii_);
|
||||
rRect.setRectRadii(SkRect::MakeIWH(buttonSize_.Width(), buttonSize_.Height()), radii_);
|
||||
} else {
|
||||
rRect.setRectXY(SkRect::MakeIWH(buttonSize_.Width(), buttonSize_.Height()), rrectRadius_, rrectRadius_);
|
||||
}
|
||||
rRect.offset(offset.GetX(), offset.GetY());
|
||||
|
||||
#ifdef OHOS_PLATFORM
|
||||
auto recordingCanvas = static_cast<Rosen::RSRecordingCanvas*>(canvas);
|
||||
if (buttonComponent_->GetType() == ButtonType::CAPSULE) {
|
||||
recordingCanvas->DrawAdaptiveRRectScale(0.5f, paint);
|
||||
} else {
|
||||
recordingCanvas->DrawAdaptiveRRect(rRect.getSimpleRadii().x(), paint);
|
||||
}
|
||||
#else
|
||||
canvas->drawRRect(rRect, paint);
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
void RosenRenderButton::DrawShape(RSCanvas* canvas, const Offset& offset, bool isStroke)
|
||||
{
|
||||
RSRoundRect rRect;
|
||||
@ -335,26 +282,7 @@ void RosenRenderButton::DrawShape(RSCanvas* canvas, const Offset& offset, bool i
|
||||
canvas->DetachBrush();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void RosenRenderButton::DrawArc(SkCanvas* canvas, const Offset& offset)
|
||||
{
|
||||
double offsetDelta = NormalizeToPx((OVAL_WIDTH - CIRCLE_DIAMETER)) / 2;
|
||||
SkPath arcPath;
|
||||
arcPath.addArc({ 0, NormalizeToPx(OFFSET_Y), NormalizeToPx(OVAL_WIDTH), NormalizeToPx(OVAL_HEIGHT + OFFSET_Y) },
|
||||
OVAL_START_ANGLE * RADIAN_TO_DEGREE, OVAL_SWEEP_ANGLE * RADIAN_TO_DEGREE);
|
||||
arcPath.addArc({ offsetDelta, 0, NormalizeToPx(CIRCLE_DIAMETER) + offsetDelta, NormalizeToPx(CIRCLE_DIAMETER) },
|
||||
CIRCLE_START_ANGLE * RADIAN_TO_DEGREE, CIRCLE_SWEEP_ANGLE * RADIAN_TO_DEGREE);
|
||||
arcPath.offset(offset.GetX() - NormalizeToPx(OFFSET_X), offset.GetY() - NormalizeToPx(OFFSET_Y));
|
||||
|
||||
SkPaint paint;
|
||||
paint.setColor(GetStateColor());
|
||||
paint.setStyle(SkPaint::Style::kFill_Style);
|
||||
paint.setAntiAlias(true);
|
||||
canvas->drawPath(arcPath, paint);
|
||||
}
|
||||
#else
|
||||
void RosenRenderButton::DrawArc(RSCanvas* canvas, const Offset& offset)
|
||||
{
|
||||
double offsetDelta = NormalizeToPx((OVAL_WIDTH - CIRCLE_DIAMETER)) / 2;
|
||||
@ -374,24 +302,7 @@ void RosenRenderButton::DrawArc(RSCanvas* canvas, const Offset& offset)
|
||||
canvas->DrawPath(arcPath);
|
||||
canvas->DetachBrush();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void RosenRenderButton::DrawLineProgress(SkCanvas* canvas, const Offset& offset)
|
||||
{
|
||||
SkPaint paint;
|
||||
paint.setColor(needFocusColor_ ? progressFocusColor_.GetValue() : progressColor_.GetValue());
|
||||
paint.setStyle(SkPaint::Style::kFill_Style);
|
||||
paint.setAntiAlias(true);
|
||||
SkRRect rRect;
|
||||
rRect.setRectXY(SkRect::MakeWH(buttonSize_.Width(), buttonSize_.Height()), rrectRadius_, rrectRadius_);
|
||||
rRect.offset(offset.GetX(), offset.GetY());
|
||||
canvas->save();
|
||||
canvas->clipRRect(rRect, true);
|
||||
canvas->drawRect({ offset.GetX(), offset.GetY(), progressWidth_, buttonSize_.Height() }, paint);
|
||||
canvas->restore();
|
||||
}
|
||||
#else
|
||||
void RosenRenderButton::DrawLineProgress(RSCanvas* canvas, const Offset& offset)
|
||||
{
|
||||
RSBrush brush;
|
||||
@ -407,36 +318,7 @@ void RosenRenderButton::DrawLineProgress(RSCanvas* canvas, const Offset& offset)
|
||||
canvas->DetachBrush();
|
||||
canvas->Restore();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void RosenRenderButton::DrawLineProgressAnimation(SkCanvas* canvas, const Offset& offset)
|
||||
{
|
||||
double offsetX = offset.GetX();
|
||||
double offsetY = offset.GetY();
|
||||
double radius = buttonSize_.Height() / 2.0;
|
||||
SkPath path;
|
||||
path.addArc({ offsetX, offsetY, buttonSize_.Height() + offsetX, buttonSize_.Height() + offsetY }, 90, 180);
|
||||
if (LessNotEqual(progressWidth_, radius)) {
|
||||
path.addArc({ progressWidth_ + offsetX, offsetY, buttonSize_.Height() - progressWidth_ + offsetX,
|
||||
buttonSize_.Height() + offsetY },
|
||||
270, -180);
|
||||
} else if (GreatNotEqual(progressWidth_, buttonSize_.Width() - radius)) {
|
||||
path.addRect(
|
||||
{ radius + offsetX, offsetY, buttonSize_.Width() - radius + offsetX, buttonSize_.Height() + offsetY });
|
||||
path.addArc({ (buttonSize_.Width() - radius) * 2.0 - progressWidth_ + offsetX, offsetY,
|
||||
progressWidth_ + offsetX, buttonSize_.Height() + offsetY },
|
||||
270, 180);
|
||||
} else {
|
||||
path.addRect({ radius + offsetX, offsetY, progressWidth_ + offsetX, buttonSize_.Height() + offsetY });
|
||||
}
|
||||
SkPaint paint;
|
||||
paint.setColor(progressColor_.GetValue());
|
||||
paint.setStyle(SkPaint::Style::kFill_Style);
|
||||
paint.setAntiAlias(true);
|
||||
canvas->drawPath(path, paint);
|
||||
}
|
||||
#else
|
||||
void RosenRenderButton::DrawLineProgressAnimation(RSCanvas* canvas, const Offset& offset)
|
||||
{
|
||||
double offsetX = offset.GetX();
|
||||
@ -468,22 +350,7 @@ void RosenRenderButton::DrawLineProgressAnimation(RSCanvas* canvas, const Offset
|
||||
canvas->DrawPath(path);
|
||||
canvas->DetachBrush();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void RosenRenderButton::DrawCircleProgress(SkCanvas* canvas, const Offset& offset)
|
||||
{
|
||||
SkPaint paint;
|
||||
paint.setAntiAlias(true);
|
||||
paint.setColor(progressColor_.GetValue());
|
||||
paint.setStyle(SkPaint::Style::kStroke_Style);
|
||||
paint.setStrokeWidth(NormalizeToPx(CIRCLE_PROGRESS_THICKNESS));
|
||||
paint.setStrokeCap(SkPaint::kRound_Cap);
|
||||
canvas->drawArc(
|
||||
{ offset.GetX(), offset.GetY(), progressDiameter_ + offset.GetX(), progressDiameter_ + offset.GetY() },
|
||||
PROGRESS_START_ANGLE * RADIAN_TO_DEGREE, 360 * progressPercent_, false, paint);
|
||||
}
|
||||
#else
|
||||
void RosenRenderButton::DrawCircleProgress(RSCanvas* canvas, const Offset& offset)
|
||||
{
|
||||
RSPen pen;
|
||||
@ -497,25 +364,10 @@ void RosenRenderButton::DrawCircleProgress(RSCanvas* canvas, const Offset& offse
|
||||
PROGRESS_START_ANGLE * RADIAN_TO_DEGREE, 360 * progressPercent_);
|
||||
canvas->DetachPen();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void RosenRenderButton::DrawDownloadButton(SkCanvas* canvas, const Offset& offset)
|
||||
#else
|
||||
void RosenRenderButton::DrawDownloadButton(RSCanvas* canvas, const Offset& offset)
|
||||
#endif
|
||||
{
|
||||
if (isWatch_) {
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
SkPaint paint;
|
||||
paint.setAntiAlias(true);
|
||||
paint.setStyle(SkPaint::Style::kFill_Style);
|
||||
canvas->save();
|
||||
paint.setColor(GetStateColor());
|
||||
canvas->drawCircle(offset.GetX() + buttonSize_.Width() / 2, offset.GetY() + buttonSize_.Height() / 2,
|
||||
(progressDiameter_ + NormalizeToPx(WATCH_DOWNLOAD_SIZE_DELTA)) / 2, paint);
|
||||
canvas->restore();
|
||||
#else
|
||||
RSBrush brush;
|
||||
brush.SetAntiAlias(true);
|
||||
canvas->Save();
|
||||
@ -526,7 +378,6 @@ void RosenRenderButton::DrawDownloadButton(RSCanvas* canvas, const Offset& offse
|
||||
(progressDiameter_ + NormalizeToPx(WATCH_DOWNLOAD_SIZE_DELTA)) / 2);
|
||||
canvas->DetachBrush();
|
||||
canvas->Restore();
|
||||
#endif
|
||||
if (progressDisplay_) {
|
||||
DrawCircleProgress(canvas, offset + Offset((buttonSize_.Width() - progressDiameter_) / 2,
|
||||
(buttonSize_.Height() - progressDiameter_) / 2));
|
||||
@ -552,11 +403,7 @@ void RosenRenderButton::DrawDownloadButton(RSCanvas* canvas, const Offset& offse
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void RosenRenderButton::DrawButton(SkCanvas* canvas, const Offset& inOffset)
|
||||
#else
|
||||
void RosenRenderButton::DrawButton(RSCanvas* canvas, const Offset& inOffset)
|
||||
#endif
|
||||
{
|
||||
Offset offset = inOffset + offsetDelta_;
|
||||
if (buttonComponent_->GetType() == ButtonType::ARC) {
|
||||
@ -630,11 +477,7 @@ bool RosenRenderButton::HasEffectiveTransform() const
|
||||
return scale_ != INIT_SCALE;
|
||||
}
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void RosenRenderButton::ConvertToSkVector(const std::array<Radius, 4>& radii, SkVector* skRadii)
|
||||
#else
|
||||
void RosenRenderButton::ConvertToVector(const std::array<Radius, 4>& radii, std::vector<RSPoint>& pRadii)
|
||||
#endif
|
||||
{
|
||||
auto context = context_.Upgrade();
|
||||
if (!context) {
|
||||
@ -642,13 +485,8 @@ void RosenRenderButton::ConvertToVector(const std::array<Radius, 4>& radii, std:
|
||||
}
|
||||
double dipScale = context->GetDipScale();
|
||||
for (int32_t i = 0; i < 4; ++i) {
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
skRadii[i].set(SkDoubleToScalar(std::max(radii[i].GetX().ConvertToPx(dipScale), 0.0)),
|
||||
SkDoubleToScalar(std::max(radii[i].GetY().ConvertToPx(dipScale), 0.0)));
|
||||
#else
|
||||
pRadii[i].SetX(static_cast<float>(std::max(radii[i].GetX().ConvertToPx(dipScale), 0.0)));
|
||||
pRadii[i].SetY(static_cast<float>(std::max(radii[i].GetY().ConvertToPx(dipScale), 0.0)));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -669,19 +507,6 @@ void RosenRenderButton::PaintFocus(RenderContext& context, const Offset& offset)
|
||||
if (buttonComponent_->GetType() == ButtonType::NORMAL) {
|
||||
focusRadius = rrectRadius_ + NormalizeToPx(FOCUS_PADDING);
|
||||
}
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
SkPaint paint;
|
||||
paint.setColor(FOCUS_BORDER_COLOR);
|
||||
paint.setStyle(SkPaint::Style::kStroke_Style);
|
||||
paint.setStrokeWidth(NormalizeToPx(FOCUS_BORDER_WIDTH));
|
||||
paint.setAntiAlias(true);
|
||||
SkRRect rRect;
|
||||
rRect.setRectXY(SkRect::MakeIWH(focusBorderWidth, focusBorderHeight), focusRadius, focusRadius);
|
||||
rRect.offset(-NormalizeToPx(FOCUS_PADDING + FOCUS_BORDER_WIDTH * HALF),
|
||||
-NormalizeToPx(FOCUS_PADDING + FOCUS_BORDER_WIDTH * HALF));
|
||||
canvas->drawRRect(rRect, paint);
|
||||
#else
|
||||
RSPen pen;
|
||||
pen.SetColor(FOCUS_BORDER_COLOR);
|
||||
pen.SetWidth(NormalizeToPx(FOCUS_BORDER_WIDTH));
|
||||
@ -692,36 +517,8 @@ void RosenRenderButton::PaintFocus(RenderContext& context, const Offset& offset)
|
||||
canvas->AttachPen(pen);
|
||||
canvas->DrawRoundRect(rRect);
|
||||
canvas->DetachPen();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void RosenRenderButton::PaintPopupFocus(RenderContext& context)
|
||||
{
|
||||
auto canvas = static_cast<RosenRenderContext*>(&context)->GetCanvas();
|
||||
if (!canvas) {
|
||||
LOGE("paint canvas is null");
|
||||
return;
|
||||
}
|
||||
Size canvasSize = GetLayoutSize();
|
||||
double focusBorderHeight = canvasSize.Height() - NormalizeToPx(FOCUS_BORDER_WIDTH) / HALF;
|
||||
double focusBorderWidth = canvasSize.Width() - NormalizeToPx(FOCUS_BORDER_WIDTH) / HALF;
|
||||
double focusRadius = focusBorderHeight * HALF;
|
||||
if (!buttonComponent_) {
|
||||
return;
|
||||
}
|
||||
|
||||
SkPaint paint;
|
||||
paint.setColor(FOCUS_POPUP_BORDER_COLOR);
|
||||
paint.setStyle(SkPaint::Style::kStroke_Style);
|
||||
paint.setStrokeWidth(NormalizeToPx(FOCUS_BORDER_WIDTH));
|
||||
paint.setAntiAlias(true);
|
||||
SkRRect rRect;
|
||||
rRect.setRectXY(SkRect::MakeIWH(focusBorderWidth, focusBorderHeight), focusRadius, focusRadius);
|
||||
rRect.offset(NormalizeToPx(FOCUS_BORDER_WIDTH), NormalizeToPx(FOCUS_BORDER_WIDTH));
|
||||
canvas->drawRRect(rRect, paint);
|
||||
}
|
||||
#else
|
||||
void RosenRenderButton::PaintPopupFocus(RenderContext& context)
|
||||
{
|
||||
auto canvas = static_cast<RosenRenderContext*>(&context)->GetCanvas();
|
||||
@ -749,7 +546,6 @@ void RosenRenderButton::PaintPopupFocus(RenderContext& context)
|
||||
canvas->DrawRoundRect(rRect);
|
||||
canvas->DetachPen();
|
||||
}
|
||||
#endif
|
||||
|
||||
void RosenRenderButton::SyncFocusGeometryProperties()
|
||||
{
|
||||
|
@ -16,12 +16,7 @@
|
||||
#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_BUTTON_ROSEN_RENDER_BUTTON_H
|
||||
#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_BUTTON_ROSEN_RENDER_BUTTON_H
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
#include "include/core/SkCanvas.h"
|
||||
#include "include/core/SkPoint.h"
|
||||
#else
|
||||
#include "core/components_ng/render/drawing.h"
|
||||
#endif
|
||||
|
||||
#include "core/components/button/render_button.h"
|
||||
|
||||
@ -47,17 +42,6 @@ private:
|
||||
void MeasureCircle();
|
||||
void MeasureCapsule();
|
||||
void ResetBoxRadius();
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void PaintLayer(SkCanvas* canvas);
|
||||
void DrawShape(SkCanvas* canvas, const Offset& offset, bool isStroke = false);
|
||||
void DrawArc(SkCanvas* canvas, const Offset& offset);
|
||||
void DrawLineProgress(SkCanvas* canvas, const Offset& offset);
|
||||
void DrawLineProgressAnimation(SkCanvas* canvas, const Offset& offset);
|
||||
void DrawCircleProgress(SkCanvas* canvas, const Offset& offset);
|
||||
void DrawDownloadButton(SkCanvas* canvas, const Offset& offset);
|
||||
void DrawButton(SkCanvas* canvas, const Offset& offset);
|
||||
void ConvertToSkVector(const std::array<Radius, 4>& radii, SkVector* skRadii);
|
||||
#else
|
||||
void PaintLayer(RSCanvas* canvas);
|
||||
void DrawShape(RSCanvas* canvas, const Offset& offset, bool isStroke = false);
|
||||
void DrawArc(RSCanvas* canvas, const Offset& offset);
|
||||
@ -67,17 +51,12 @@ private:
|
||||
void DrawDownloadButton(RSCanvas* canvas, const Offset& offset);
|
||||
void DrawButton(RSCanvas* canvas, const Offset& offset);
|
||||
void ConvertToVector(const std::array<Radius, 4>& radii, std::vector<RSPoint>& pRadii);
|
||||
#endif
|
||||
void PaintFocus(RenderContext& context, const Offset& offset);
|
||||
void PaintPopupFocus(RenderContext& context);
|
||||
uint32_t GetStateColor();
|
||||
bool NeedClickedColor(const Color& backgroundColor);
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
SkVector radii_[4] = { { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 } };
|
||||
#else
|
||||
std::vector<RSPoint> radii_ = { { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 } };
|
||||
#endif
|
||||
Matrix4 transformLayer_ = Matrix4::CreateIdentity();
|
||||
float opacityLayer_ = 1.0f;
|
||||
};
|
||||
|
@ -64,15 +64,6 @@ std::unique_ptr<Rosen::Typography> GetTextParagraph(const std::string& text, con
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
#ifndef USE_GRAPHIC_TEXT_GINE
|
||||
void DrawCalendarText(
|
||||
SkCanvas* canvas, const std::string& text, const txt::TextStyle& textStyle, const Rect& boxRect, Rect& textRect)
|
||||
#else
|
||||
void DrawCalendarText(
|
||||
SkCanvas* canvas, const std::string& text, const Rosen::TextStyle& textStyle, const Rect& boxRect, Rect& textRect)
|
||||
#endif
|
||||
#else
|
||||
#ifndef USE_GRAPHIC_TEXT_GINE
|
||||
void DrawCalendarText(RSCanvas* canvas,
|
||||
const std::string& text, const txt::TextStyle& textStyle, const Rect& boxRect, Rect& textRect)
|
||||
@ -80,7 +71,6 @@ void DrawCalendarText(RSCanvas* canvas,
|
||||
void DrawCalendarText(RSCanvas* canvas,
|
||||
const std::string& text, const Rosen::TextStyle& textStyle, const Rect& boxRect, Rect& textRect)
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
// The lunar calendar description is truncated by more than three characters.
|
||||
std::string newText { text };
|
||||
@ -106,13 +96,6 @@ void DrawCalendarText(RSCanvas* canvas,
|
||||
textRect.SetRect(offset.GetX() + textPaintOffsetX, offset.GetY() + textPaintOffsetY, textWidth, textHeight);
|
||||
}
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
#ifndef USE_GRAPHIC_TEXT_GINE
|
||||
void DrawCalendarText(SkCanvas* canvas, const std::string& text, const txt::TextStyle& textStyle, const Rect& boxRect)
|
||||
#else
|
||||
void DrawCalendarText(SkCanvas* canvas, const std::string& text, const Rosen::TextStyle& textStyle, const Rect& boxRect)
|
||||
#endif
|
||||
#else
|
||||
#ifndef USE_GRAPHIC_TEXT_GINE
|
||||
void DrawCalendarText(RSCanvas* canvas,
|
||||
const std::string& text, const txt::TextStyle& textStyle, const Rect& boxRect)
|
||||
@ -120,7 +103,6 @@ void DrawCalendarText(RSCanvas* canvas,
|
||||
void DrawCalendarText(RSCanvas* canvas,
|
||||
const std::string& text, const Rosen::TextStyle& textStyle, const Rect& boxRect)
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
Rect textRect;
|
||||
DrawCalendarText(canvas, text, textStyle, boxRect, textRect);
|
||||
@ -158,11 +140,7 @@ void RosenRenderCalendar::Paint(RenderContext& context, const Offset& offset)
|
||||
if (isV2Component_) {
|
||||
#ifdef OHOS_PLATFORM
|
||||
const Size& layout = GetLayoutSize();
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
OHOS::Rosen::RSRecordingCanvas canvas(layout.Width(), layout.Height());
|
||||
#else
|
||||
RSRecordingCanvas canvas(layout.Width(), layout.Height());
|
||||
#endif
|
||||
DrawWeekAndDates(&canvas, offset);
|
||||
drawCmdList_ = canvas.GetDrawCmdList();
|
||||
isNeedRepaint_ = false;
|
||||
@ -232,11 +210,7 @@ void RosenRenderCalendar::PerformLayout()
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void RosenRenderCalendar::DrawWeekAndDates(SkCanvas* canvas, Offset offset)
|
||||
#else
|
||||
void RosenRenderCalendar::DrawWeekAndDates(RSCanvas* canvas, Offset offset)
|
||||
#endif
|
||||
{
|
||||
uint32_t totalWeek = weekNumbers_.size();
|
||||
uint32_t daysCount = static_cast<uint32_t>(rowCount_) * totalWeek;
|
||||
@ -274,13 +248,8 @@ void RosenRenderCalendar::DrawWeekAndDates(RSCanvas* canvas, Offset offset)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void RosenRenderCalendar::DrawFocusedArea(
|
||||
SkCanvas* canvas, const Offset& offset, const CalendarDay& day, double x, double y) const
|
||||
#else
|
||||
void RosenRenderCalendar::DrawFocusedArea(
|
||||
RSCanvas* canvas, const Offset& offset, const CalendarDay& day, double x, double y) const
|
||||
#endif
|
||||
{
|
||||
auto pipelineContext = context_.Upgrade();
|
||||
if (!pipelineContext) {
|
||||
@ -295,29 +264,6 @@ void RosenRenderCalendar::DrawFocusedArea(
|
||||
pipelineContext->ShowFocusAnimation(focusAnimationRRect, Color::WHITE, circleStart);
|
||||
|
||||
// draw focus background circle
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
SkPaint paint;
|
||||
paint.setAntiAlias(true);
|
||||
|
||||
if (SystemProperties::GetDeviceType() == DeviceType::WATCH || type_ == CalendarType::SIMPLE) {
|
||||
if (day.dayMark == "work" && showHoliday_) {
|
||||
paint.setColor(workDayMarkColor_);
|
||||
} else if (day.dayMark == "off" && showHoliday_) {
|
||||
paint.setColor(offDayMarkColor_);
|
||||
} else {
|
||||
paint.setColor(focusedAreaBackgroundColor_);
|
||||
}
|
||||
} else {
|
||||
paint.setColor(focusedAreaBackgroundColor_);
|
||||
}
|
||||
Offset circleCenter =
|
||||
type_ == CalendarType::SIMPLE
|
||||
? Offset(x - (focusedAreaRadius_ * 2 - dayWidth_) / 2 + focusedAreaRadius_, y + focusedAreaRadius_)
|
||||
: Offset(x - (focusedAreaRadius_ * 2 - dayWidth_) / 2 + focusedAreaRadius_,
|
||||
y - NormalizeToPx(1.0_vp) + focusedAreaRadius_);
|
||||
Offset bgCircleStart = offset + circleCenter;
|
||||
canvas->drawCircle(bgCircleStart.GetX(), bgCircleStart.GetY(), focusedAreaRadius_, paint);
|
||||
#else
|
||||
RSBrush brush;
|
||||
brush.SetAntiAlias(true);
|
||||
|
||||
@ -341,14 +287,9 @@ void RosenRenderCalendar::DrawFocusedArea(
|
||||
canvas->AttachBrush(brush);
|
||||
canvas->DrawCircle(RSPoint(bgCircleStart.GetX(), bgCircleStart.GetY()), focusedAreaRadius_);
|
||||
canvas->DetachBrush();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void RosenRenderCalendar::DrawWeek(SkCanvas* canvas, const Offset& offset) const
|
||||
#else
|
||||
void RosenRenderCalendar::DrawWeek(RSCanvas* canvas, const Offset& offset) const
|
||||
#endif
|
||||
{
|
||||
uint32_t totalWeek = weekNumbers_.size();
|
||||
#ifndef USE_GRAPHIC_TEXT_GINE
|
||||
@ -385,11 +326,7 @@ void RosenRenderCalendar::DrawWeek(RSCanvas* canvas, const Offset& offset) const
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void RosenRenderCalendar::DrawBlurArea(SkCanvas* canvas, const Offset& offset, double x, double y) const
|
||||
#else
|
||||
void RosenRenderCalendar::DrawBlurArea(RSCanvas* canvas, const Offset& offset, double x, double y) const
|
||||
#endif
|
||||
{
|
||||
auto pipelineContext = GetContext().Upgrade();
|
||||
if (!pipelineContext) {
|
||||
@ -397,15 +334,6 @@ void RosenRenderCalendar::DrawBlurArea(RSCanvas* canvas, const Offset& offset, d
|
||||
return;
|
||||
}
|
||||
// start focus animation
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
SkPaint paint;
|
||||
paint.setAntiAlias(true);
|
||||
paint.setColor(blurAreaBackgroundColor_);
|
||||
Offset circleCenter = Offset(x - (focusedAreaRadius_ * 2 - dayWidth_) / 2 + focusedAreaRadius_,
|
||||
y - NormalizeToPx(1.0_vp) + focusedAreaRadius_);
|
||||
Offset bgCircleStart = offset + circleCenter;
|
||||
canvas->drawCircle(bgCircleStart.GetX(), bgCircleStart.GetY(), focusedAreaRadius_, paint);
|
||||
#else
|
||||
RSBrush brush;
|
||||
brush.SetAntiAlias(true);
|
||||
brush.SetColor(blurAreaBackgroundColor_);
|
||||
@ -415,18 +343,8 @@ void RosenRenderCalendar::DrawBlurArea(RSCanvas* canvas, const Offset& offset, d
|
||||
canvas->AttachBrush(brush);
|
||||
canvas->DrawCircle(RSPoint(bgCircleStart.GetX(), bgCircleStart.GetY()), focusedAreaRadius_);
|
||||
canvas->DetachBrush();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
#ifndef USE_GRAPHIC_TEXT_GINE
|
||||
void RosenRenderCalendar::PaintDay(
|
||||
SkCanvas* canvas, const Offset& offset, const CalendarDay& day, txt::TextStyle& textStyle) const
|
||||
#else
|
||||
void RosenRenderCalendar::PaintDay(
|
||||
SkCanvas* canvas, const Offset& offset, const CalendarDay& day, Rosen::TextStyle& textStyle) const
|
||||
#endif
|
||||
#else
|
||||
#ifndef USE_GRAPHIC_TEXT_GINE
|
||||
void RosenRenderCalendar::PaintDay(
|
||||
RSCanvas* canvas, const Offset& offset, const CalendarDay& day, txt::TextStyle& textStyle) const
|
||||
@ -434,7 +352,6 @@ void RosenRenderCalendar::PaintDay(
|
||||
void RosenRenderCalendar::PaintDay(
|
||||
RSCanvas* canvas, const Offset& offset, const CalendarDay& day, Rosen::TextStyle& textStyle) const
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
// paint day
|
||||
Rect boxRect { offset.GetX(), offset.GetY(), dayWidth_, gregorianCalendarHeight_ };
|
||||
@ -445,19 +362,11 @@ void RosenRenderCalendar::PaintDay(
|
||||
Rosen::TextStyle workStateStyle;
|
||||
#endif
|
||||
if (!day.dayMark.empty() && showHoliday_ && type_ == CalendarType::SIMPLE) {
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
if (day.dayMark == "work") {
|
||||
textStyle.color = SkColor(calendarTheme_.simpleWorkTextColor.GetValue());
|
||||
} else if (day.dayMark == "off") {
|
||||
textStyle.color = SkColor(calendarTheme_.simpleOffTextColor.GetValue());
|
||||
}
|
||||
#else
|
||||
if (day.dayMark == "work") {
|
||||
textStyle.color = RSColorQuad(calendarTheme_.simpleWorkTextColor.GetValue());
|
||||
} else if (day.dayMark == "off") {
|
||||
textStyle.color = RSColorQuad(calendarTheme_.simpleOffTextColor.GetValue());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if ((SystemProperties::GetDeviceType() == DeviceType::WATCH || type_ == CalendarType::SIMPLE) && IsToday(day) &&
|
||||
!day.dayMark.empty() && showHoliday_) {
|
||||
@ -510,25 +419,6 @@ void RosenRenderCalendar::PaintDay(
|
||||
workStateStyle.color = offDayMarkColor_;
|
||||
}
|
||||
} else {
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
if (day.dayMark == "work") {
|
||||
#ifndef USE_GRAPHIC_TEXT_GINE
|
||||
workStateStyle.font_size = workDayMarkSize_;
|
||||
#else
|
||||
workStateStyle.fontSize = workDayMarkSize_;
|
||||
#endif
|
||||
workStateStyle.color = isV2Component_ ? SkColorSetA(workDayMarkColor_, WEEKEND_TRANSPARENT)
|
||||
: nonCurrentMonthWorkDayMarkColor_;
|
||||
} else if (day.dayMark == "off") {
|
||||
#ifndef USE_GRAPHIC_TEXT_GINE
|
||||
workStateStyle.font_size = offDayMarkSize_;
|
||||
#else
|
||||
workStateStyle.fontSize = offDayMarkSize_;
|
||||
#endif
|
||||
workStateStyle.color = isV2Component_ ? SkColorSetA(offDayMarkColor_, WEEKEND_TRANSPARENT)
|
||||
: nonCurrentMonthOffDayMarkColor_;
|
||||
}
|
||||
#else
|
||||
if (day.dayMark == "work") {
|
||||
#ifndef USE_GRAPHIC_TEXT_GINE
|
||||
workStateStyle.font_size = workDayMarkSize_;
|
||||
@ -550,7 +440,6 @@ void RosenRenderCalendar::PaintDay(
|
||||
RSColor::ColorQuadGetG(offDayMarkColor_), RSColor::ColorQuadGetB(offDayMarkColor_))
|
||||
: nonCurrentMonthOffDayMarkColor_;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (day.focused) {
|
||||
workStateStyle.color = Color::BLACK.GetValue();
|
||||
@ -563,15 +452,6 @@ void RosenRenderCalendar::PaintDay(
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
#ifndef USE_GRAPHIC_TEXT_GINE
|
||||
void RosenRenderCalendar::PaintLunarDay(
|
||||
SkCanvas* canvas, const Offset& offset, const CalendarDay& day, const txt::TextStyle& textStyle) const
|
||||
#else
|
||||
void RosenRenderCalendar::PaintLunarDay(
|
||||
SkCanvas* canvas, const Offset& offset, const CalendarDay& day, const Rosen::TextStyle& textStyle) const
|
||||
#endif
|
||||
#else
|
||||
#ifndef USE_GRAPHIC_TEXT_GINE
|
||||
void RosenRenderCalendar::PaintLunarDay(
|
||||
RSCanvas* canvas, const Offset& offset, const CalendarDay& day, const txt::TextStyle& textStyle) const
|
||||
@ -579,7 +459,6 @@ void RosenRenderCalendar::PaintLunarDay(
|
||||
void RosenRenderCalendar::PaintLunarDay(
|
||||
RSCanvas* canvas, const Offset& offset, const CalendarDay& day, const Rosen::TextStyle& textStyle) const
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
Rect boxRect;
|
||||
cardCalendar_ || isV2Component_
|
||||
@ -596,14 +475,6 @@ void RosenRenderCalendar::SetNonFocusStyle(
|
||||
const CalendarDay& day, Rosen::TextStyle& dateTextStyle, Rosen::TextStyle& lunarTextStyle)
|
||||
#endif
|
||||
{
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
SkColor dateTextColor;
|
||||
SkColor lunarTextColor;
|
||||
if (day.month.month != currentMonth_.month) {
|
||||
dateTextColor = nonCurrentMonthDayColor_;
|
||||
lunarTextColor =
|
||||
day.markLunarDay ? SkColorSetA(markLunarColor_, WEEKEND_TRANSPARENT) : nonCurrentMonthLunarColor_;
|
||||
#else
|
||||
RSColorQuad dateTextColor;
|
||||
RSColorQuad lunarTextColor;
|
||||
if (day.month.month != currentMonth_.month) {
|
||||
@ -611,7 +482,6 @@ void RosenRenderCalendar::SetNonFocusStyle(
|
||||
lunarTextColor = day.markLunarDay ? RSColor::ColorQuadSetARGB(WEEKEND_TRANSPARENT,
|
||||
RSColor::ColorQuadGetR(markLunarColor_), RSColor::ColorQuadGetG(markLunarColor_),
|
||||
RSColor::ColorQuadGetB(markLunarColor_)) : nonCurrentMonthLunarColor_;
|
||||
#endif
|
||||
} else if (IsToday(day)) {
|
||||
dateTextColor = todayDayColor_;
|
||||
lunarTextColor = todayLunarColor_;
|
||||
@ -638,18 +508,10 @@ void RosenRenderCalendar::DrawTouchedArea(RenderContext& context, Offset offset)
|
||||
return;
|
||||
}
|
||||
offset += { touchCircleStrokeWidth_, 0 };
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
SkPaint paint;
|
||||
paint.setAntiAlias(true);
|
||||
paint.setColor(focusedAreaBackgroundColor_);
|
||||
paint.setStrokeWidth(touchCircleStrokeWidth_);
|
||||
paint.setStyle(SkPaint::kStroke_Style);
|
||||
#else
|
||||
RSPen pen;
|
||||
pen.SetAntiAlias(true);
|
||||
pen.SetColor(focusedAreaBackgroundColor_);
|
||||
pen.SetWidth(touchCircleStrokeWidth_);
|
||||
#endif
|
||||
static const Dimension dateOffset = 4.0_vp;
|
||||
const static int32_t totalWeek = 7;
|
||||
int32_t column = touchIndex_ % totalWeek;
|
||||
@ -661,22 +523,13 @@ void RosenRenderCalendar::DrawTouchedArea(RenderContext& context, Offset offset)
|
||||
Offset circleCenter = Offset(x - (focusedAreaRadius_ * 2 - dayWidth_) / 2 + focusedAreaRadius_,
|
||||
y - NormalizeToPx(1.0_vp) + focusedAreaRadius_);
|
||||
Offset bgCircleStart = offset + circleCenter;
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
canvas->drawCircle(bgCircleStart.GetX(), bgCircleStart.GetY(), focusedAreaRadius_, paint);
|
||||
#else
|
||||
canvas->AttachPen(pen);
|
||||
canvas->DrawCircle(RSPoint(bgCircleStart.GetX(), bgCircleStart.GetY()), focusedAreaRadius_);
|
||||
canvas->DetachPen();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void RosenRenderCalendar::DrawCardCalendar(
|
||||
SkCanvas* canvas, const Offset& offset, const Offset& dayOffset, const CalendarDay& day, int32_t dateNumber)
|
||||
#else
|
||||
void RosenRenderCalendar::DrawCardCalendar(
|
||||
RSCanvas* canvas, const Offset& offset, const Offset& dayOffset, const CalendarDay& day, int32_t dateNumber)
|
||||
#endif
|
||||
{
|
||||
#ifndef USE_GRAPHIC_TEXT_GINE
|
||||
txt::TextStyle dateTextStyle;
|
||||
@ -707,8 +560,7 @@ void RosenRenderCalendar::DrawCardCalendar(
|
||||
|
||||
if (isV2Component_ && day.touched) {
|
||||
if (IsToday(day) && (day.month.month == currentMonth_.month)) {
|
||||
dateTextStyle.color = focusedDayColor_;
|
||||
lunarTextStyle.color = focusedDayColor_;
|
||||
SetTextStyleColor(dateTextStyle, lunarTextStyle);
|
||||
DrawFocusedArea(canvas, offset, day, x, y);
|
||||
}
|
||||
}
|
||||
@ -722,7 +574,19 @@ void RosenRenderCalendar::DrawCardCalendar(
|
||||
auto dayYAxisOffset = calendarTheme_.dayYAxisOffset;
|
||||
Offset dateNumberOffset = offset + Offset(x, y + NormalizeToPx(dayYAxisOffset));
|
||||
PaintDay(canvas, dateNumberOffset, day, dateTextStyle);
|
||||
HandleAdditionalConditions(canvas, offset, dayOffset, day, lunarTextStyle);
|
||||
}
|
||||
|
||||
#ifndef USE_GRAPHIC_TEXT_GINE
|
||||
void RosenRenderCalendar::HandleAdditionalConditions(RSCanvas* canvas, const Offset& offset, const Offset& dayOffset,
|
||||
const CalendarDay& day, txt::TextStyle& lunarTextStyle)
|
||||
#else
|
||||
void RosenRenderCalendar::HandleAdditionalConditions(RSCanvas* canvas, const Offset& offset, const Offset& dayOffset,
|
||||
const CalendarDay& day, Rosen::TextStyle& lunarTextStyle)
|
||||
#endif
|
||||
{
|
||||
auto x = dayOffset.GetX();
|
||||
auto y = dayOffset.GetY();
|
||||
if (dataAdapter_->ShowLunar() && !day.lunarDay.empty()) {
|
||||
auto lunarDayYAxisOffset = calendarTheme_.lunarDayYAxisOffset;
|
||||
Offset lunarDayOffset = offset + Offset(x, y + NormalizeToPx(lunarDayYAxisOffset));
|
||||
@ -746,13 +610,8 @@ void RosenRenderCalendar::DrawCardCalendar(
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void RosenRenderCalendar::DrawTvCalendar(
|
||||
SkCanvas* canvas, const Offset& offset, const Offset& dayOffset, const CalendarDay& day, int32_t dateNumber)
|
||||
#else
|
||||
void RosenRenderCalendar::DrawTvCalendar(RSCanvas* canvas,
|
||||
const Offset& offset, const Offset& dayOffset, const CalendarDay& day, int32_t dateNumber)
|
||||
#endif
|
||||
{
|
||||
if ((SystemProperties::GetDeviceType() == DeviceType::WATCH || type_ == CalendarType::SIMPLE) &&
|
||||
day.month.month != currentMonth_.month) {
|
||||
@ -778,8 +637,7 @@ void RosenRenderCalendar::DrawTvCalendar(RSCanvas* canvas,
|
||||
auto y = dayOffset.GetY();
|
||||
if (SystemProperties::GetDeviceType() == DeviceType::WATCH || type_ == CalendarType::SIMPLE) {
|
||||
if (IsToday(day) && (day.month.month == currentMonth_.month)) {
|
||||
dateTextStyle.color = focusedDayColor_;
|
||||
lunarTextStyle.color = focusedDayColor_;
|
||||
SetTextStyleColor(dateTextStyle, lunarTextStyle);
|
||||
DrawFocusedArea(canvas, offset, day, x, y);
|
||||
} else {
|
||||
SetNonFocusStyle(day, dateTextStyle, lunarTextStyle);
|
||||
@ -787,8 +645,7 @@ void RosenRenderCalendar::DrawTvCalendar(RSCanvas* canvas,
|
||||
} else {
|
||||
if (day.focused && day.month.month == currentMonth_.month && !renderSwiper->GetMoveStatus() &&
|
||||
indexOfContainer_ == calendarController_->GetCurrentIndex()) {
|
||||
dateTextStyle.color = focusedDayColor_;
|
||||
lunarTextStyle.color = focusedLunarColor_;
|
||||
SetTextStyleColor(dateTextStyle, lunarTextStyle);
|
||||
DrawFocusedArea(canvas, offset, day, x, y);
|
||||
} else {
|
||||
SetNonFocusStyle(day, dateTextStyle, lunarTextStyle);
|
||||
@ -815,6 +672,18 @@ void RosenRenderCalendar::DrawTvCalendar(RSCanvas* canvas,
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef USE_GRAPHIC_TEXT_GINE
|
||||
void RosenRenderCalendar::SetTextStyleColor(
|
||||
txt::TextStyle& dateTextStyle, txt::TextStyle& lunarTextStyle)
|
||||
#else
|
||||
void RosenRenderCalendar::SetTextStyleColor(
|
||||
Rosen::TextStyle& dateTextStyle, Rosen::TextStyle& lunarTextStyle)
|
||||
#endif
|
||||
{
|
||||
dateTextStyle.color = focusedDayColor_;
|
||||
lunarTextStyle.color = focusedDayColor_;
|
||||
}
|
||||
|
||||
#ifndef USE_GRAPHIC_TEXT_GINE
|
||||
void RosenRenderCalendar::InitTextStyle(txt::TextStyle& dateTextStyle, txt::TextStyle& lunarTextStyle)
|
||||
{
|
||||
@ -835,31 +704,6 @@ void RosenRenderCalendar::InitTextStyle(Rosen::TextStyle& dateTextStyle, Rosen::
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void RosenRenderCalendar::PaintUnderscore(SkCanvas* canvas, const Offset& offset, const CalendarDay& day)
|
||||
{
|
||||
auto underscoreWidth = calendarTheme_.underscoreWidth;
|
||||
auto underscoreLength = calendarTheme_.underscoreLength;
|
||||
SkPaint paint;
|
||||
SkColor color;
|
||||
if (day.month.month != currentMonth_.month) {
|
||||
color = SkColorSetA(focusedAreaBackgroundColor_, NON_CURRENT_MONTH_TRANSPARENT);
|
||||
} else if (IsToday(day)) {
|
||||
color = isV2Component_ && !day.touched ? SkColorSetA(focusedAreaBackgroundColor_, CURRENT_MONTH_TRANSPARENT)
|
||||
: focusedDayColor_;
|
||||
} else if (day.weekend) {
|
||||
color = SkColorSetA(focusedAreaBackgroundColor_, WEEKEND_TRANSPARENT);
|
||||
} else {
|
||||
color = SkColorSetA(focusedAreaBackgroundColor_, CURRENT_MONTH_TRANSPARENT);
|
||||
}
|
||||
paint.setAntiAlias(true);
|
||||
paint.setColor(color);
|
||||
paint.setStyle(SkPaint::Style::kStroke_Style);
|
||||
paint.setStrokeWidth(NormalizeToPx(underscoreWidth));
|
||||
canvas->drawLine(offset.GetX(), offset.GetY() + NormalizeToPx(underscoreWidth) / 2,
|
||||
offset.GetX() + NormalizeToPx(underscoreLength), offset.GetY() + NormalizeToPx(underscoreWidth) / 2, paint);
|
||||
}
|
||||
#else
|
||||
void RosenRenderCalendar::PaintUnderscore(RSCanvas* canvas, const Offset& offset, const CalendarDay& day)
|
||||
{
|
||||
auto underscoreWidth = calendarTheme_.underscoreWidth;
|
||||
@ -887,32 +731,14 @@ void RosenRenderCalendar::PaintUnderscore(RSCanvas* canvas, const Offset& offset
|
||||
pen.SetColor(color);
|
||||
pen.SetWidth(NormalizeToPx(underscoreWidth));
|
||||
canvas->AttachPen(pen);
|
||||
canvas->DrawLine(RSPoint(offset.GetX(), offset.GetY() + NormalizeToPx(underscoreWidth) / 2),
|
||||
canvas->DrawLine(RSPoint(offset.GetX(),
|
||||
offset.GetY() + NormalizeToPx(underscoreWidth) / 2), // 2:division factor
|
||||
RSPoint(
|
||||
offset.GetX() + NormalizeToPx(underscoreLength), offset.GetY() + NormalizeToPx(underscoreWidth) / 2));
|
||||
offset.GetX() + NormalizeToPx(underscoreLength),
|
||||
offset.GetY() + NormalizeToPx(underscoreWidth) / 2)); // 2:division factor
|
||||
canvas->DetachPen();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void RosenRenderCalendar::PaintScheduleMarker(SkCanvas* canvas, const Offset& offset, const CalendarDay& day)
|
||||
{
|
||||
auto scheduleMarkerRadius = calendarTheme_.scheduleMarkerRadius;
|
||||
SkPaint paint;
|
||||
SkColor color;
|
||||
if (day.month.month != currentMonth_.month) {
|
||||
color = SkColorSetA(focusedAreaBackgroundColor_, NON_CURRENT_MONTH_TRANSPARENT);
|
||||
} else if (IsToday(day)) {
|
||||
color = isV2Component_ && !day.touched ? SkColorSetA(focusedAreaBackgroundColor_, SCHEDULE_MARKER_TRANSPARENT)
|
||||
: focusedDayColor_;
|
||||
} else {
|
||||
color = SkColorSetA(focusedAreaBackgroundColor_, SCHEDULE_MARKER_TRANSPARENT);
|
||||
}
|
||||
paint.setAntiAlias(true);
|
||||
paint.setColor(color);
|
||||
canvas->drawCircle(offset.GetX(), offset.GetY(), NormalizeToPx(scheduleMarkerRadius), paint);
|
||||
}
|
||||
#else
|
||||
void RosenRenderCalendar::PaintScheduleMarker(RSCanvas* canvas, const Offset& offset, const CalendarDay& day)
|
||||
{
|
||||
auto scheduleMarkerRadius = calendarTheme_.scheduleMarkerRadius;
|
||||
@ -938,7 +764,6 @@ void RosenRenderCalendar::PaintScheduleMarker(RSCanvas* canvas, const Offset& of
|
||||
canvas->DrawCircle(RSPoint(offset.GetX(), offset.GetY()), NormalizeToPx(scheduleMarkerRadius));
|
||||
canvas->DetachBrush();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef USE_GRAPHIC_TEXT_GINE
|
||||
void RosenRenderCalendar::InitWorkStateStyle(
|
||||
@ -974,15 +799,10 @@ void RosenRenderCalendar::InitWorkStateStyle(
|
||||
#endif
|
||||
|
||||
if (day.month.month != currentMonth_.month) {
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
auto offColor = SkColorSetA(markLunarColor_, WEEKEND_TRANSPARENT);
|
||||
auto workColor = SkColorSetA(workDayMarkColor_, WEEKEND_TRANSPARENT);
|
||||
#else
|
||||
auto offColor = RSColor::ColorQuadSetARGB(WEEKEND_TRANSPARENT, RSColor::ColorQuadGetR(markLunarColor_),
|
||||
RSColor::ColorQuadGetG(markLunarColor_), RSColor::ColorQuadGetB(markLunarColor_));
|
||||
auto workColor = RSColor::ColorQuadSetARGB(WEEKEND_TRANSPARENT, RSColor::ColorQuadGetR(workDayMarkColor_),
|
||||
RSColor::ColorQuadGetG(workDayMarkColor_), RSColor::ColorQuadGetB(workDayMarkColor_));
|
||||
#endif
|
||||
SetWorkStateStyle(day, workColor, offColor, workStateStyle);
|
||||
} else if (IsToday(day)) {
|
||||
SetWorkStateStyle(day, focusedDayColor_, focusedDayColor_, workStateStyle);
|
||||
@ -995,15 +815,6 @@ void RosenRenderCalendar::InitWorkStateStyle(
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
#ifndef USE_GRAPHIC_TEXT_GINE
|
||||
void RosenRenderCalendar::SetWorkStateStyle(
|
||||
const CalendarDay& day, SkColor workColor, SkColor offColor, txt::TextStyle& workStateStyle) const
|
||||
#else
|
||||
void RosenRenderCalendar::SetWorkStateStyle(
|
||||
const CalendarDay& day, SkColor workColor, SkColor offColor, Rosen::TextStyle& workStateStyle) const
|
||||
#endif
|
||||
#else
|
||||
#ifndef USE_GRAPHIC_TEXT_GINE
|
||||
void RosenRenderCalendar::SetWorkStateStyle(const CalendarDay& day, RSColorQuad workColor,
|
||||
RSColorQuad offColor, txt::TextStyle& workStateStyle) const
|
||||
@ -1011,7 +822,6 @@ void RosenRenderCalendar::SetWorkStateStyle(const CalendarDay& day, RSColorQuad
|
||||
void RosenRenderCalendar::SetWorkStateStyle(
|
||||
const CalendarDay& day, SkColor workColor, RSColorQuad offColor, Rosen::TextStyle& workStateStyle) const
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
if (day.dayMark == "work") {
|
||||
workStateStyle.color = workColor;
|
||||
@ -1026,27 +836,6 @@ void RosenRenderCalendar::SetCalendarTheme()
|
||||
if (cardCalendar_ && theme) {
|
||||
calendarTheme_ = theme->GetCardCalendarTheme();
|
||||
}
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
touchColor_ = SkColor(calendarTheme_.touchColor.GetValue());
|
||||
weekColor_ = SkColor(calendarTheme_.weekColor.GetValue());
|
||||
dayColor_ = SkColor(calendarTheme_.dayColor.GetValue());
|
||||
lunarColor_ = SkColor(calendarTheme_.lunarColor.GetValue());
|
||||
weekendDayColor_ = SkColor(calendarTheme_.weekendDayColor.GetValue());
|
||||
weekendLunarColor_ = SkColor(calendarTheme_.weekendLunarColor.GetValue());
|
||||
todayDayColor_ = SkColor(calendarTheme_.todayColor.GetValue());
|
||||
todayLunarColor_ = SkColor(calendarTheme_.todayLunarColor.GetValue());
|
||||
nonCurrentMonthDayColor_ = SkColor(calendarTheme_.nonCurrentMonthDayColor.GetValue());
|
||||
nonCurrentMonthLunarColor_ = SkColor(calendarTheme_.nonCurrentMonthLunarColor.GetValue());
|
||||
workDayMarkColor_ = SkColor(calendarTheme_.workDayMarkColor.GetValue());
|
||||
offDayMarkColor_ = SkColor(calendarTheme_.offDayMarkColor.GetValue());
|
||||
nonCurrentMonthWorkDayMarkColor_ = SkColor(calendarTheme_.nonCurrentMonthWorkDayMarkColor.GetValue());
|
||||
nonCurrentMonthOffDayMarkColor_ = SkColor(calendarTheme_.nonCurrentMonthOffDayMarkColor.GetValue());
|
||||
focusedDayColor_ = SkColor(calendarTheme_.focusedDayColor.GetValue());
|
||||
focusedLunarColor_ = SkColor(calendarTheme_.focusedLunarColor.GetValue());
|
||||
focusedAreaBackgroundColor_ = SkColor(calendarTheme_.focusedAreaBackgroundColor.GetValue());
|
||||
blurAreaBackgroundColor_ = SkColor(calendarTheme_.blurAreaBackgroundColor.GetValue());
|
||||
markLunarColor_ = SkColor(calendarTheme_.markLunarColor.GetValue());
|
||||
#else
|
||||
touchColor_ = RSColorQuad(calendarTheme_.touchColor.GetValue());
|
||||
weekColor_ = RSColorQuad(calendarTheme_.weekColor.GetValue());
|
||||
dayColor_ = RSColorQuad(calendarTheme_.dayColor.GetValue());
|
||||
@ -1066,7 +855,6 @@ void RosenRenderCalendar::SetCalendarTheme()
|
||||
focusedAreaBackgroundColor_ = RSColorQuad(calendarTheme_.focusedAreaBackgroundColor.GetValue());
|
||||
blurAreaBackgroundColor_ = RSColorQuad(calendarTheme_.blurAreaBackgroundColor.GetValue());
|
||||
markLunarColor_ = RSColorQuad(calendarTheme_.markLunarColor.GetValue());
|
||||
#endif
|
||||
dayFontWeight_ = StringUtils::StringToFontWeight(calendarTheme_.dayFontWeight);
|
||||
lunarDayFontWeight_ = StringUtils::StringToFontWeight(calendarTheme_.lunarDayFontWeight);
|
||||
workStateFontWeight_ = StringUtils::StringToFontWeight(calendarTheme_.workStateFontWeight);
|
||||
|
@ -16,16 +16,6 @@
|
||||
#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_CALENDAR_ROSEN_RENDER_CALENDAR_H
|
||||
#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_CALENDAR_ROSEN_RENDER_CALENDAR_H
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
#ifndef USE_GRAPHIC_TEXT_GINE
|
||||
#include "include/core/SkCanvas.h"
|
||||
#include "include/core/SkColor.h"
|
||||
#else
|
||||
#include "third_party/skia/include/core/SkCanvas.h"
|
||||
#include "third_party/skia/include/core/SkColor.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef USE_GRAPHIC_TEXT_GINE
|
||||
#include "third_party/txt/src/txt/text_style.h"
|
||||
#else
|
||||
@ -33,9 +23,7 @@
|
||||
#endif
|
||||
|
||||
#include "core/components/calendar/render_calendar.h"
|
||||
#ifdef USE_ROSEN_DRAWING
|
||||
#include "core/components_ng/render/drawing.h"
|
||||
#endif
|
||||
|
||||
namespace OHOS::Rosen {
|
||||
class DrawCmdList;
|
||||
@ -56,70 +44,45 @@ public:
|
||||
void PerformLayout() override;
|
||||
|
||||
private:
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void DrawWeekAndDates(SkCanvas* canvas, Offset offset);
|
||||
void DrawFocusedArea(SkCanvas* canvas, const Offset& offset, const CalendarDay& day, double x, double y) const;
|
||||
void DrawWeek(SkCanvas* canvas, const Offset& offset) const;
|
||||
void DrawBlurArea(SkCanvas* canvas, const Offset& offset, double x, double y) const;
|
||||
#else
|
||||
void DrawWeekAndDates(RSCanvas* canvas, Offset offset);
|
||||
void DrawFocusedArea(
|
||||
RSCanvas* canvas, const Offset& offset, const CalendarDay& day, double x, double y) const;
|
||||
void DrawWeek(RSCanvas* canvas, const Offset& offset) const;
|
||||
void DrawBlurArea(RSCanvas* canvas, const Offset& offset, double x, double y) const;
|
||||
#endif
|
||||
void DrawTouchedArea(RenderContext& context, Offset offset) const;
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
#ifndef USE_GRAPHIC_TEXT_GINE
|
||||
void PaintDay(SkCanvas* canvas, const Offset& offset, const CalendarDay& day, txt::TextStyle& textStyle) const;
|
||||
void PaintLunarDay(
|
||||
SkCanvas* canvas, const Offset& offset, const CalendarDay& day, const txt::TextStyle& textStyle) const;
|
||||
#else
|
||||
void PaintDay(SkCanvas* canvas, const Offset& offset, const CalendarDay& day, Rosen::TextStyle& textStyle) const;
|
||||
void PaintLunarDay(
|
||||
SkCanvas* canvas, const Offset& offset, const CalendarDay& day, const Rosen::TextStyle& textStyle) const;
|
||||
#endif
|
||||
#else
|
||||
#ifndef USE_GRAPHIC_TEXT_GINE
|
||||
void PaintDay(
|
||||
RSCanvas* canvas, const Offset& offset, const CalendarDay& day, txt::TextStyle& textStyle) const;
|
||||
void PaintLunarDay(RSCanvas* canvas, const Offset& offset, const CalendarDay& day,
|
||||
const txt::TextStyle& textStyle) const;
|
||||
void HandleAdditionalConditions(RSCanvas* canvas, const Offset& offset, const Offset& dayOffset,
|
||||
const CalendarDay& day, txt::TextStyle& lunarTextStyle);
|
||||
void SetTextStyleColor(txt::TextStyle& dateTextStyle, txt::TextStyle& lunarTextStyle);
|
||||
#else
|
||||
void PaintDay(
|
||||
RSCanvas* canvas, const Offset& offset, const CalendarDay& day, Rosen::TextStyle& textStyle) const;
|
||||
void PaintLunarDay(RSCanvas* canvas, const Offset& offset, const CalendarDay& day,
|
||||
const Rosen::TextStyle& textStyle) const;
|
||||
#endif
|
||||
void HandleAdditionalConditions(RSCanvas* canvas, const Offset& offset, const Offset& dayOffset,
|
||||
const CalendarDay& day, Rosen::TextStyle& lunarTextStyle);
|
||||
void SetTextStyleColor(Rosen::TextStyle& dateTextStyle, Rosen::TextStyle& lunarTextStyle);
|
||||
#endif
|
||||
#ifndef USE_GRAPHIC_TEXT_GINE
|
||||
void SetNonFocusStyle(const CalendarDay& day, txt::TextStyle& dateTextStyle, txt::TextStyle& lunarTextStyle);
|
||||
#else
|
||||
void SetNonFocusStyle(const CalendarDay& day, Rosen::TextStyle& dateTextStyle, Rosen::TextStyle& lunarTextStyle);
|
||||
#endif
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void DrawCardCalendar(
|
||||
SkCanvas* canvas, const Offset& offset, const Offset& dayOffset, const CalendarDay& day, int32_t dateNumber);
|
||||
void DrawTvCalendar(
|
||||
SkCanvas* canvas, const Offset& offset, const Offset& dayOffset, const CalendarDay& day, int32_t dateNumber);
|
||||
#else
|
||||
void DrawCardCalendar(RSCanvas* canvas, const Offset& offset, const Offset& dayOffset,
|
||||
const CalendarDay& day, int32_t dateNumber);
|
||||
void DrawTvCalendar(RSCanvas* canvas, const Offset& offset, const Offset& dayOffset,
|
||||
const CalendarDay& day, int32_t dateNumber);
|
||||
#endif
|
||||
#ifndef USE_GRAPHIC_TEXT_GINE
|
||||
void InitTextStyle(txt::TextStyle& dateTextStyle, txt::TextStyle& lunarTextStyle);
|
||||
#else
|
||||
void InitTextStyle(Rosen::TextStyle& dateTextStyle, Rosen::TextStyle& lunarTextStyle);
|
||||
#endif
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void PaintUnderscore(SkCanvas* canvas, const Offset& offset, const CalendarDay& day);
|
||||
void PaintScheduleMarker(SkCanvas* canvas, const Offset& offset, const CalendarDay& day);
|
||||
#else
|
||||
void PaintUnderscore(RSCanvas* canvas, const Offset& offset, const CalendarDay& day);
|
||||
void PaintScheduleMarker(RSCanvas* canvas, const Offset& offset, const CalendarDay& day);
|
||||
#endif
|
||||
#ifndef USE_GRAPHIC_TEXT_GINE
|
||||
void InitWorkStateStyle(
|
||||
const CalendarDay& day, const Offset& offset, txt::TextStyle& workStateStyle, Rect& boxRect) const;
|
||||
@ -127,22 +90,12 @@ private:
|
||||
void InitWorkStateStyle(
|
||||
const CalendarDay& day, const Offset& offset, Rosen::TextStyle& workStateStyle, Rect& boxRect) const;
|
||||
#endif
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
#ifndef USE_GRAPHIC_TEXT_GINE
|
||||
void SetWorkStateStyle(
|
||||
const CalendarDay& day, SkColor workColor, SkColor offColor, txt::TextStyle& workStateStyle) const;
|
||||
#else
|
||||
void SetWorkStateStyle(
|
||||
const CalendarDay& day, SkColor workColor, SkColor offColor, Rosen::TextStyle& workStateStyle) const;
|
||||
#endif
|
||||
#else
|
||||
#ifndef USE_GRAPHIC_TEXT_GINE
|
||||
void SetWorkStateStyle(const CalendarDay& day, RSColorQuad workColor,
|
||||
RSColorQuad offColor, txt::TextStyle& workStateStyle) const;
|
||||
#else
|
||||
void SetWorkStateStyle(const CalendarDay& day, RSColorQuad workColor,
|
||||
RSColorQuad offColor, Rosen::TextStyle& workStateStyle) const;
|
||||
#endif
|
||||
#endif
|
||||
void SetCalendarTheme();
|
||||
bool IsOffDay(const CalendarDay& day) const;
|
||||
@ -164,27 +117,6 @@ private:
|
||||
double workStateVerticalMovingDistance_ = 0.0;
|
||||
double touchCircleStrokeWidth_ = 0.0;
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
SkColor weekColor_;
|
||||
SkColor touchColor_;
|
||||
SkColor dayColor_;
|
||||
SkColor lunarColor_;
|
||||
SkColor weekendDayColor_;
|
||||
SkColor weekendLunarColor_;
|
||||
SkColor todayDayColor_;
|
||||
SkColor todayLunarColor_;
|
||||
SkColor nonCurrentMonthDayColor_;
|
||||
SkColor nonCurrentMonthLunarColor_;
|
||||
SkColor workDayMarkColor_;
|
||||
SkColor offDayMarkColor_;
|
||||
SkColor nonCurrentMonthWorkDayMarkColor_;
|
||||
SkColor nonCurrentMonthOffDayMarkColor_;
|
||||
SkColor focusedDayColor_;
|
||||
SkColor focusedLunarColor_;
|
||||
SkColor focusedAreaBackgroundColor_;
|
||||
SkColor blurAreaBackgroundColor_;
|
||||
SkColor markLunarColor_;
|
||||
#else
|
||||
RSColorQuad weekColor_;
|
||||
RSColorQuad touchColor_;
|
||||
RSColorQuad dayColor_;
|
||||
@ -204,17 +136,12 @@ private:
|
||||
RSColorQuad focusedAreaBackgroundColor_;
|
||||
RSColorQuad blurAreaBackgroundColor_;
|
||||
RSColorQuad markLunarColor_;
|
||||
#endif
|
||||
|
||||
Size lastLayoutSize_;
|
||||
FontWeight dayFontWeight_ = FontWeight::W500;
|
||||
FontWeight lunarDayFontWeight_ = FontWeight::W500;
|
||||
FontWeight workStateFontWeight_ = FontWeight::W400;
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
std::shared_ptr<Rosen::DrawCmdList> drawCmdList_;
|
||||
#else
|
||||
std::shared_ptr<RSDrawCmdList> drawCmdList_;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace OHOS::Ace
|
||||
|
@ -15,12 +15,6 @@
|
||||
|
||||
#include "core/components/checkable/rosen_render_checkbox.h"
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
#include "include/core/SkMaskFilter.h"
|
||||
#include "include/core/SkPaint.h"
|
||||
#include "include/core/SkPath.h"
|
||||
#endif
|
||||
|
||||
#include "core/components/common/painter/rosen_universal_painter.h"
|
||||
#include "core/pipeline/base/rosen_render_context.h"
|
||||
|
||||
@ -73,16 +67,6 @@ void RosenRenderCheckbox::Paint(RenderContext& context, const Offset& offset)
|
||||
RequestFocusBorder(paintOffset, drawSize_, NormalizeToPx(borderRadius_));
|
||||
}
|
||||
}
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
SkPaint strokePaint;
|
||||
SkPaint shadowPaint;
|
||||
shadowPaint.setAntiAlias(true);
|
||||
strokePaint.setAntiAlias(true);
|
||||
shadowPaint.setColor(shadowColor_);
|
||||
shadowPaint.setStrokeCap(SkPaint::kRound_Cap);
|
||||
SetStrokeWidth(NormalizeToPx(checkStroke_ + shadowWidth_ * 2), shadowPaint);
|
||||
SetUIStatus(canvas, paintOffset, strokePaint, shadowPaint);
|
||||
#else
|
||||
RSPen strokePen;
|
||||
RSPen shadowPen;
|
||||
shadowPen.SetAntiAlias(true);
|
||||
@ -91,16 +75,10 @@ void RosenRenderCheckbox::Paint(RenderContext& context, const Offset& offset)
|
||||
shadowPen.SetCapStyle(RSPen::CapStyle::ROUND_CAP);
|
||||
SetStrokeWidth(NormalizeToPx(checkStroke_ + shadowWidth_ * 2), shadowPen);
|
||||
SetUIStatus(canvas, paintOffset, strokePen, shadowPen);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void RosenRenderCheckbox::SetUIStatus(SkCanvas* canvas,
|
||||
const Offset& paintOffset, SkPaint& strokePaint, SkPaint& shadowPaint)
|
||||
#else
|
||||
void RosenRenderCheckbox::SetUIStatus(RSCanvas* canvas,
|
||||
const Offset& paintOffset, RSPen& strokePaint, RSPen& shadowPaint)
|
||||
#endif
|
||||
{
|
||||
switch (uiStatus_) {
|
||||
case UIStatus::SELECTED: {
|
||||
@ -153,19 +131,6 @@ void RosenRenderCheckbox::SetUIStatus(RSCanvas* canvas,
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void RosenRenderCheckbox::DrawActiveBorder(SkCanvas* canvas, const Offset& paintOffset, SkPaint& strokePaint) const
|
||||
{
|
||||
SkPaint skPaint;
|
||||
skPaint.setAntiAlias(true);
|
||||
skPaint.setColor(activeColor_);
|
||||
DrawBorder(canvas, paintOffset, skPaint, drawSize_);
|
||||
|
||||
SetStrokeWidth(NormalizeToPx(checkStroke_), strokePaint);
|
||||
strokePaint.setColor(pointColor_);
|
||||
strokePaint.setStrokeCap(SkPaint::kRound_Cap);
|
||||
}
|
||||
#else
|
||||
void RosenRenderCheckbox::DrawActiveBorder(
|
||||
RSCanvas* canvas, const Offset& paintOffset, RSPen& strokePen) const
|
||||
{
|
||||
@ -180,26 +145,7 @@ void RosenRenderCheckbox::DrawActiveBorder(
|
||||
strokePen.SetColor(pointColor_);
|
||||
strokePen.SetCapStyle(RSPen::CapStyle::ROUND_CAP);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void RosenRenderCheckbox::DrawPartSelect(
|
||||
SkCanvas* canvas, const Offset& origin, SkPaint& paint, const SkPaint& shadowPaint) const
|
||||
{
|
||||
SkPath path;
|
||||
double originX = origin.GetX();
|
||||
double originY = origin.GetY();
|
||||
const Offset start =
|
||||
Offset(drawSize_.Width() * CHECK_MARK_PART_START_X_POSITION, drawSize_.Width() * CHECK_MARK_PART_Y_POSITION);
|
||||
const Offset end =
|
||||
Offset(drawSize_.Width() * CHECK_MARK_PART_END_Y_POSITION, drawSize_.Width() * CHECK_MARK_PART_Y_POSITION);
|
||||
|
||||
path.moveTo(originX + start.GetX(), originY + start.GetY());
|
||||
path.lineTo(originX + end.GetX(), originY + end.GetY());
|
||||
canvas->drawPath(path, shadowPaint);
|
||||
canvas->drawPath(path, paint);
|
||||
}
|
||||
#else
|
||||
void RosenRenderCheckbox::DrawPartSelect(RSCanvas* canvas, const Offset& origin,
|
||||
RSPen& pen, const RSPen& shadowPen) const
|
||||
{
|
||||
@ -221,36 +167,18 @@ void RosenRenderCheckbox::DrawPartSelect(RSCanvas* canvas, const Offset& origin,
|
||||
canvas->DrawPath(path);
|
||||
canvas->DetachPen();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void RosenRenderCheckbox::DrawUnselected(
|
||||
SkCanvas* canvas, const Offset& origin, uint32_t paintColor, SkPaint& paint) const
|
||||
#else
|
||||
void RosenRenderCheckbox::DrawUnselected(
|
||||
RSCanvas* canvas, const Offset& origin, uint32_t paintColor, RSPen& pen) const
|
||||
#endif
|
||||
{
|
||||
Offset paintOffset = origin;
|
||||
auto borderWidth = NormalizeToPx(borderWidth_);
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
SetStrokeWidth(borderWidth, paint);
|
||||
#else
|
||||
SetStrokeWidth(borderWidth, pen);
|
||||
#endif
|
||||
double strokeOffset = borderWidth / 2;
|
||||
paintOffset += Offset(strokeOffset, strokeOffset);
|
||||
Size paintSize = drawSize_;
|
||||
paintSize.SetWidth(paintSize.Width() - borderWidth);
|
||||
paintSize.SetHeight(paintSize.Height() - borderWidth);
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
paint.setColor(paintColor);
|
||||
auto bgPaint = paint;
|
||||
bgPaint.setColor(inactivePointColor_);
|
||||
bgPaint.setStyle(SkPaint::Style::kFill_Style);
|
||||
DrawBorder(canvas, paintOffset, bgPaint, paintSize);
|
||||
DrawBorder(canvas, paintOffset, paint, paintSize);
|
||||
#else
|
||||
pen.SetColor(paintColor);
|
||||
|
||||
RSBrush bgBrush;
|
||||
@ -264,35 +192,8 @@ void RosenRenderCheckbox::DrawUnselected(
|
||||
canvas->AttachPen(pen);
|
||||
DrawBorder(canvas, paintOffset, paintSize);
|
||||
canvas->DetachPen();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void RosenRenderCheckbox::DrawCheck(
|
||||
SkCanvas* canvas, const Offset& origin, const SkPaint& paint, const SkPaint& shadowPaint) const
|
||||
{
|
||||
SkPath path;
|
||||
double originX = origin.GetX();
|
||||
double originY = origin.GetY();
|
||||
const Offset start =
|
||||
Offset(drawSize_.Width() * CHECK_MARK_START_X_POSITION, drawSize_.Width() * CHECK_MARK_START_Y_POSITION);
|
||||
const Offset middle =
|
||||
Offset(drawSize_.Width() * CHECK_MARK_MIDDLE_X_POSITION, drawSize_.Width() * CHECK_MARK_MIDDLE_Y_POSITION);
|
||||
const Offset end =
|
||||
Offset(drawSize_.Width() * CHECK_MARK_END_X_POSITION, drawSize_.Width() * CHECK_MARK_END_Y_POSITION);
|
||||
|
||||
path.moveTo(originX + start.GetX(), originY + start.GetY());
|
||||
path.lineTo(originX + middle.GetX(), originY + middle.GetY());
|
||||
|
||||
canvas->drawPath(path, shadowPaint);
|
||||
canvas->drawPath(path, paint);
|
||||
path.moveTo(originX + middle.GetX(), originY + middle.GetY());
|
||||
path.lineTo(originX + end.GetX(), originY + end.GetY());
|
||||
|
||||
canvas->drawPath(path, shadowPaint);
|
||||
canvas->drawPath(path, paint);
|
||||
}
|
||||
#else
|
||||
void RosenRenderCheckbox::DrawCheck(RSCanvas* canvas, const Offset& origin,
|
||||
const RSPen& pen, const RSPen& shadowPen) const
|
||||
{
|
||||
@ -328,21 +229,7 @@ void RosenRenderCheckbox::DrawCheck(RSCanvas* canvas, const Offset& origin,
|
||||
canvas->DrawPath(path);
|
||||
canvas->DetachPen();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void RosenRenderCheckbox::DrawBorder(
|
||||
SkCanvas* canvas, const Offset& origin, const SkPaint& paint, const Size& paintSize) const
|
||||
{
|
||||
SkRRect rrect;
|
||||
double originX = origin.GetX();
|
||||
double originY = origin.GetY();
|
||||
double borderRadius = NormalizeToPx(borderRadius_);
|
||||
rrect = SkRRect::MakeRectXY(
|
||||
{ originX, originY, paintSize.Width() + originX, paintSize.Height() + originY }, borderRadius, borderRadius);
|
||||
canvas->drawRRect(rrect, paint);
|
||||
}
|
||||
#else
|
||||
void RosenRenderCheckbox::DrawBorder(RSCanvas* canvas, const Offset& origin, const Size& paintSize) const
|
||||
{
|
||||
double originX = origin.GetX();
|
||||
@ -353,21 +240,11 @@ void RosenRenderCheckbox::DrawBorder(RSCanvas* canvas, const Offset& origin, con
|
||||
borderRadius, borderRadius);
|
||||
canvas->DrawRoundRect(rrect);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void RosenRenderCheckbox::DrawAnimationOffToOn(
|
||||
SkCanvas* canvas, const Offset& origin, const SkPaint& paint, const SkPaint& shadowPaint) const
|
||||
#else
|
||||
void RosenRenderCheckbox::DrawAnimationOffToOn(RSCanvas* canvas, const Offset& origin,
|
||||
const RSPen& pen, const RSPen& shadowPen) const
|
||||
#endif
|
||||
{
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
SkPath path;
|
||||
#else
|
||||
RSPath path;
|
||||
#endif
|
||||
double originX = origin.GetX();
|
||||
double originY = origin.GetY();
|
||||
const Offset start =
|
||||
@ -379,31 +256,6 @@ void RosenRenderCheckbox::DrawAnimationOffToOn(RSCanvas* canvas, const Offset& o
|
||||
|
||||
double deltaX = middle.GetX() - start.GetX();
|
||||
double deltaY = middle.GetY() - start.GetY();
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
path.moveTo(originX + start.GetX(), originY + start.GetY());
|
||||
double ratio = DEFAULT_MIN_CHECKBOX_SHAPE_SCALE;
|
||||
if (shapeScale_ < CHECK_MARK_LEFT_ANIMATION_PERCENT) {
|
||||
ratio = shapeScale_ / CHECK_MARK_LEFT_ANIMATION_PERCENT;
|
||||
path.lineTo(originX + start.GetX() + deltaX * ratio, originY + start.GetY() + deltaY * ratio);
|
||||
} else {
|
||||
path.lineTo(originX + middle.GetX(), originY + middle.GetY());
|
||||
}
|
||||
canvas->drawPath(path, shadowPaint);
|
||||
canvas->drawPath(path, paint);
|
||||
if (shapeScale_ > CHECK_MARK_LEFT_ANIMATION_PERCENT) {
|
||||
deltaX = end.GetX() - middle.GetX();
|
||||
deltaY = middle.GetY() - end.GetY();
|
||||
path.moveTo(originX + middle.GetX(), originY + middle.GetY());
|
||||
if (shapeScale_ == DEFAULT_MAX_CHECKBOX_SHAPE_SCALE) {
|
||||
path.lineTo(originX + end.GetX(), originY + end.GetY());
|
||||
} else {
|
||||
ratio = (shapeScale_ - CHECK_MARK_LEFT_ANIMATION_PERCENT) / CHECK_MARK_RIGHT_ANIMATION_PERCENT;
|
||||
path.lineTo(originX + middle.GetX() + deltaX * ratio, originY + middle.GetY() - deltaY * ratio);
|
||||
}
|
||||
canvas->drawPath(path, shadowPaint);
|
||||
canvas->drawPath(path, paint);
|
||||
}
|
||||
#else
|
||||
path.MoveTo(originX + start.GetX(), originY + start.GetY());
|
||||
double ratio = DEFAULT_MIN_CHECKBOX_SHAPE_SCALE;
|
||||
if (shapeScale_ < CHECK_MARK_LEFT_ANIMATION_PERCENT) {
|
||||
@ -438,25 +290,15 @@ void RosenRenderCheckbox::DrawAnimationOffToOn(RSCanvas* canvas, const Offset& o
|
||||
canvas->DrawPath(path);
|
||||
canvas->DetachPen();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void RosenRenderCheckbox::DrawAnimationOnToOff(
|
||||
SkCanvas* canvas, const Offset& origin, const SkPaint& paint, const SkPaint& shadowPaint) const
|
||||
#else
|
||||
void RosenRenderCheckbox::DrawAnimationOnToOff(RSCanvas* canvas, const Offset& origin,
|
||||
const RSPen& pen, const RSPen& shadowPen) const
|
||||
#endif
|
||||
{
|
||||
if (shapeScale_ == DEFAULT_MIN_CHECKBOX_SHAPE_SCALE) {
|
||||
return;
|
||||
}
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
SkPath path;
|
||||
#else
|
||||
RSRecordingPath path;
|
||||
#endif
|
||||
double originX = origin.GetX();
|
||||
double originY = origin.GetY();
|
||||
const Offset start =
|
||||
@ -469,20 +311,6 @@ void RosenRenderCheckbox::DrawAnimationOnToOff(RSCanvas* canvas, const Offset& o
|
||||
double deltaX = middlePoint.GetX() - start.GetX();
|
||||
double deltaY = middlePoint.GetY() - start.GetY();
|
||||
double ratio = DEFAULT_MAX_CHECKBOX_SHAPE_SCALE - shapeScale_;
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
path.moveTo(originX + start.GetX() + deltaX * ratio, originY + start.GetY() + deltaY * ratio);
|
||||
deltaX = middlePoint.GetX() - middle.GetX();
|
||||
deltaY = middle.GetY() - middlePoint.GetY();
|
||||
path.lineTo(originX + middle.GetX() + deltaX * ratio, originY + middle.GetY() - deltaY * ratio);
|
||||
canvas->drawPath(path, shadowPaint);
|
||||
canvas->drawPath(path, paint);
|
||||
path.moveTo(originX + middle.GetX() + deltaX * ratio, originY + middle.GetY() - deltaY * ratio);
|
||||
deltaX = end.GetX() - middlePoint.GetX();
|
||||
deltaY = middlePoint.GetY() - end.GetY();
|
||||
path.lineTo(originX + end.GetX() - deltaX * ratio, originY + end.GetY() + deltaY * ratio);
|
||||
canvas->drawPath(path, shadowPaint);
|
||||
canvas->drawPath(path, paint);
|
||||
#else
|
||||
path.MoveTo(originX + start.GetX() + deltaX * ratio, originY + start.GetY() + deltaY * ratio);
|
||||
deltaX = middlePoint.GetX() - middle.GetX();
|
||||
deltaY = middle.GetY() - middlePoint.GetY();
|
||||
@ -508,7 +336,6 @@ void RosenRenderCheckbox::DrawAnimationOnToOff(RSCanvas* canvas, const Offset& o
|
||||
canvas->AttachPen(pen);
|
||||
canvas->DrawPath(path);
|
||||
canvas->DetachPen();
|
||||
#endif
|
||||
}
|
||||
|
||||
void RosenRenderCheckbox::DrawFocusBorder(RenderContext& context, const Offset& offset)
|
||||
@ -523,18 +350,6 @@ void RosenRenderCheckbox::DrawFocusBorder(RenderContext& context, const Offset&
|
||||
double focusBorderWidth = paintSize.Width() + NormalizeToPx(FOCUS_PADDING * 2 + FOCUS_BORDER_WIDTH);
|
||||
double focusRadius = NormalizeToPx(borderRadius_ + FOCUS_PADDING);
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
SkPaint paint;
|
||||
paint.setColor(FOCUS_BORDER_COLOR);
|
||||
paint.setStyle(SkPaint::Style::kStroke_Style);
|
||||
paint.setStrokeWidth(NormalizeToPx(FOCUS_BORDER_WIDTH));
|
||||
paint.setAntiAlias(true);
|
||||
SkRRect rRect;
|
||||
rRect.setRectXY(SkRect::MakeIWH(focusBorderWidth, focusBorderHeight), focusRadius, focusRadius);
|
||||
rRect.offset(offset.GetX() - NormalizeToPx(FOCUS_PADDING + FOCUS_BORDER_WIDTH / 2),
|
||||
offset.GetY() - NormalizeToPx(FOCUS_PADDING + FOCUS_BORDER_WIDTH / 2));
|
||||
canvas->drawRRect(rRect, paint);
|
||||
#else
|
||||
RSPen pen;
|
||||
pen.SetColor(FOCUS_BORDER_COLOR);
|
||||
pen.SetWidth(NormalizeToPx(FOCUS_BORDER_WIDTH));
|
||||
@ -546,7 +361,6 @@ void RosenRenderCheckbox::DrawFocusBorder(RenderContext& context, const Offset&
|
||||
canvas->AttachPen(pen);
|
||||
canvas->DrawRoundRect(rRect);
|
||||
canvas->DetachPen();
|
||||
#endif
|
||||
}
|
||||
|
||||
void RosenRenderCheckbox::DrawTouchBoard(const Offset& offset, RenderContext& context)
|
||||
|
@ -31,19 +31,6 @@ public:
|
||||
void Paint(RenderContext& context, const Offset& offset) override;
|
||||
|
||||
private:
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void DrawCheck(SkCanvas* canvas, const Offset& origin, const SkPaint& paint, const SkPaint& shadowPaint) const;
|
||||
void DrawActiveBorder(SkCanvas* canvas, const Offset& paintOffset, SkPaint& strokePaint) const;
|
||||
void DrawPartSelect(
|
||||
SkCanvas* canvas, const Offset& paintOffset, SkPaint& strokePaint, const SkPaint& shadowPaint) const;
|
||||
void DrawUnselected(SkCanvas* canvas, const Offset& origin, uint32_t paintColor, SkPaint& paint) const;
|
||||
void SetUIStatus(SkCanvas* canvas, const Offset& paintOffset, SkPaint& strokePaint, SkPaint& shadowPaint);
|
||||
void DrawBorder(SkCanvas* canvas, const Offset& origin, const SkPaint& paint, const Size& paintSize) const;
|
||||
void DrawAnimationOffToOn(
|
||||
SkCanvas* canvas, const Offset& origin, const SkPaint& paint, const SkPaint& shadowPaint) const;
|
||||
void DrawAnimationOnToOff(
|
||||
SkCanvas* canvas, const Offset& origin, const SkPaint& paint, const SkPaint& shadowPaint) const;
|
||||
#else
|
||||
void DrawCheck(RSCanvas* canvas, const Offset& origin, const RSPen& pen,
|
||||
const RSPen& shadowPen) const;
|
||||
void DrawActiveBorder(
|
||||
@ -59,7 +46,6 @@ private:
|
||||
const RSPen& shadowPen) const;
|
||||
void DrawAnimationOnToOff(RSCanvas* canvas, const Offset& origin, const RSPen& pen,
|
||||
const RSPen& shadowPen) const;
|
||||
#endif
|
||||
void DrawFocusBorder(RenderContext& context, const Offset& offset);
|
||||
void DrawTouchBoard(const Offset& offset, RenderContext& context);
|
||||
void DrawHoverBoard(const Offset& offset, RenderContext& context);
|
||||
|
@ -35,14 +35,9 @@ void RosenRenderRadio::Paint(RenderContext& context, const Offset& offset)
|
||||
LOGE("Paint canvas is null");
|
||||
return;
|
||||
}
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
SkPaint paint;
|
||||
paint.setAntiAlias(true);
|
||||
#else
|
||||
RSPen pen;
|
||||
pen.SetAntiAlias(true);
|
||||
RSBrush brush;
|
||||
#endif
|
||||
if (!isDeclarative_) {
|
||||
if (IsPhone() && onFocus_) {
|
||||
RequestFocusBorder(paintOffset, drawSize_, drawSize_.Width() / 2.0);
|
||||
@ -61,56 +56,6 @@ void RosenRenderRadio::Paint(RenderContext& context, const Offset& offset)
|
||||
double centerX = outCircleRadius_ + paintOffset.GetX();
|
||||
double centerY = outCircleRadius_ + paintOffset.GetY();
|
||||
auto borderWidth = NormalizeToPx(borderWidth_);
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
switch (uiStatus_) {
|
||||
case UIStatus::SELECTED:
|
||||
// draw stroke border
|
||||
paint.setAntiAlias(true);
|
||||
paint.setColor(activeColor_);
|
||||
if (disabled_) {
|
||||
paint.setColor(Color(activeColor_).BlendOpacity(ConfigureOpacity(disabled_)).GetValue());
|
||||
}
|
||||
canvas->drawCircle(centerX, centerY, outCircleRadius_ * totalScale_, paint);
|
||||
|
||||
// draw shadow
|
||||
if (!NearZero(pointScale_) && !NearEqual(pointScale_, 1.0)) {
|
||||
paint.setColor(shadowColor_);
|
||||
canvas->drawCircle(
|
||||
centerX, centerY, outCircleRadius_ * pointScale_ + NormalizeToPx(shadowWidth_), paint);
|
||||
}
|
||||
|
||||
// draw inner circle
|
||||
paint.setColor(pointColor_);
|
||||
canvas->drawCircle(centerX, centerY, outCircleRadius_ * pointScale_, paint);
|
||||
break;
|
||||
case UIStatus::UNSELECTED:
|
||||
// draw inner circle
|
||||
paint.setColor(inactivePointColor_);
|
||||
canvas->drawCircle(centerX, centerY, outCircleRadius_ - borderWidth / 2.0, paint);
|
||||
|
||||
// draw border with unselected color
|
||||
paint.setColor(inactiveColor_);
|
||||
if (disabled_) {
|
||||
paint.setColor(Color(inactiveColor_).BlendOpacity(ConfigureOpacity(disabled_)).GetValue());
|
||||
}
|
||||
SetStrokeWidth(borderWidth, paint);
|
||||
canvas->drawCircle(centerX, centerY, outCircleRadius_ - borderWidth / 2.0, paint);
|
||||
break;
|
||||
case UIStatus::FOCUS: // focus of unselected
|
||||
// draw inner circle
|
||||
paint.setColor(inactivePointColor_);
|
||||
canvas->drawCircle(centerX, centerY, outCircleRadius_ - borderWidth / 2.0, paint);
|
||||
|
||||
// draw border with focus color
|
||||
SetStrokeWidth(borderWidth, paint);
|
||||
paint.setColor(focusColor_);
|
||||
canvas->drawCircle(centerX, centerY, outCircleRadius_ - borderWidth / 2.0, paint);
|
||||
break;
|
||||
default:
|
||||
LOGE("unknown ui status");
|
||||
break;
|
||||
}
|
||||
#else
|
||||
switch (uiStatus_) {
|
||||
case UIStatus::SELECTED:
|
||||
// draw stroke border
|
||||
@ -173,7 +118,6 @@ void RosenRenderRadio::Paint(RenderContext& context, const Offset& offset)
|
||||
LOGE("unknown ui status");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void RosenRenderRadio::DrawFocusBorder(RenderContext& context, const Offset& offset)
|
||||
@ -185,18 +129,6 @@ void RosenRenderRadio::DrawFocusBorder(RenderContext& context, const Offset& off
|
||||
double focusBorderWidth = drawSize_.Width() + NormalizeToPx(FOCUS_PADDING * 2 + FOCUS_BORDER_WIDTH);
|
||||
double focusBorderHeight = drawSize_.Height() + NormalizeToPx(FOCUS_PADDING * 2 + FOCUS_BORDER_WIDTH);
|
||||
double focusRadius = focusBorderHeight * HALF;
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
SkPaint paint;
|
||||
paint.setColor(FOCUS_BORDER_COLOR);
|
||||
paint.setStrokeWidth(NormalizeToPx(FOCUS_BORDER_WIDTH));
|
||||
paint.setStyle(SkPaint::Style::kStroke_Style);
|
||||
paint.setAntiAlias(true);
|
||||
SkRRect rRect;
|
||||
rRect.setRectXY(SkRect::MakeIWH(focusBorderWidth, focusBorderHeight), focusRadius, focusRadius);
|
||||
rRect.offset(offset.GetX() - NormalizeToPx(FOCUS_PADDING + FOCUS_BORDER_WIDTH * HALF),
|
||||
offset.GetY() - NormalizeToPx(FOCUS_PADDING + FOCUS_BORDER_WIDTH * HALF));
|
||||
canvas->drawRRect(rRect, paint);
|
||||
#else
|
||||
RSPen pen;
|
||||
pen.SetColor(FOCUS_BORDER_COLOR);
|
||||
pen.SetWidth(NormalizeToPx(FOCUS_BORDER_WIDTH));
|
||||
@ -208,7 +140,6 @@ void RosenRenderRadio::DrawFocusBorder(RenderContext& context, const Offset& off
|
||||
canvas->AttachPen(pen);
|
||||
canvas->DrawRoundRect(rRect);
|
||||
canvas->DetachPen();
|
||||
#endif
|
||||
}
|
||||
|
||||
void RosenRenderRadio::DrawTouchBoard(const Offset& offset, RenderContext& context)
|
||||
|
@ -27,10 +27,6 @@
|
||||
#include "core/pipeline/base/constants.h"
|
||||
#include "core/pipeline/base/render_node.h"
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
class SkCanvas;
|
||||
#endif
|
||||
|
||||
namespace OHOS::Ace {
|
||||
namespace {
|
||||
|
||||
@ -155,13 +151,8 @@ protected:
|
||||
virtual bool HandleMouseEvent(const MouseEvent& event) override;
|
||||
virtual void PaintFocus(
|
||||
const Offset& offset, double rrectRadius, const Size& boardSize, RenderContext& context) {}
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
virtual void PaintFocus(
|
||||
const Offset& offset, double rrectRadius, const Size& boardSize, SkCanvas* canvas) {}
|
||||
#else
|
||||
virtual void PaintFocus(
|
||||
const Offset& offset, double rrectRadius, const Size& boardSize, RSCanvas* canvas) {}
|
||||
#endif
|
||||
static void ConstrainScore(double& score, double lowerBoundary, double upperBoundary);
|
||||
|
||||
void SetRatingEvent(OperationEvent operationEvent)
|
||||
|
@ -15,13 +15,7 @@
|
||||
|
||||
#include "core/components/rating/rosen_render_rating.h"
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
#include "include/core/SkClipOp.h"
|
||||
#include "include/core/SkMaskFilter.h"
|
||||
#include "include/core/SkRRect.h"
|
||||
#else
|
||||
#include "core/components_ng/render/drawing.h"
|
||||
#endif
|
||||
|
||||
#include "core/components/common/painter/rosen_universal_painter.h"
|
||||
#include "core/pipeline/base/rosen_render_context.h"
|
||||
@ -76,11 +70,7 @@ void RosenRenderRating::Paint(RenderContext& context, const Offset& offset)
|
||||
PaintRatingBar(context, canvas);
|
||||
}
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void RosenRenderRating::PaintHoverRect(SkCanvas* canvas)
|
||||
#else
|
||||
void RosenRenderRating::PaintHoverRect(RSCanvas* canvas)
|
||||
#endif
|
||||
{
|
||||
Size hoverSize = Size(singleWidth_, ratingSize_.Height());
|
||||
for (auto& item : hoverColorMap_) {
|
||||
@ -93,11 +83,7 @@ void RosenRenderRating::PaintHoverRect(RSCanvas* canvas)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void RosenRenderRating::PaintRatingBar(RenderContext& context, SkCanvas* canvas)
|
||||
#else
|
||||
void RosenRenderRating::PaintRatingBar(RenderContext& context, RSCanvas* canvas)
|
||||
#endif
|
||||
{
|
||||
double imageVerticalOffset = ratingSize_.Width() * paddingVertical_.Value() / defaultHeight_.Value() / starNum_;
|
||||
auto imageOffset = offsetDelta_ + Offset(0.0, imageVerticalOffset);
|
||||
@ -146,24 +132,6 @@ void RosenRenderRating::PaintRatingBar(RenderContext& context, RSCanvas* canvas)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void RosenRenderRating::PaintImageArea(RenderContext& context, const RefPtr<RenderImage>& renderImage, SkCanvas* canvas,
|
||||
const ImageAreaProperties& properties)
|
||||
{
|
||||
canvas->save();
|
||||
auto clipOffset = properties.clipOffset;
|
||||
auto drawOffset = properties.drawOffset;
|
||||
auto imageAreaSize = properties.imageAreaSize;
|
||||
canvas->clipRect({ clipOffset.GetX(), clipOffset.GetY(), clipOffset.GetX() + imageAreaSize.Width(),
|
||||
clipOffset.GetY() + imageAreaSize.Height() },
|
||||
SkClipOp::kIntersect, true);
|
||||
for (int i = 0; i < properties.repeatNum; ++i) {
|
||||
renderImage->SetAdaptiveFrameRectFlag(false);
|
||||
renderImage->RenderWithContext(context, drawOffset + Offset(singleWidth_ * i, 0.0));
|
||||
}
|
||||
canvas->restore();
|
||||
}
|
||||
#else
|
||||
void RosenRenderRating::PaintImageArea(RenderContext& context, const RefPtr<RenderImage>& renderImage,
|
||||
RSCanvas* canvas, const ImageAreaProperties& properties)
|
||||
{
|
||||
@ -181,7 +149,6 @@ void RosenRenderRating::PaintImageArea(RenderContext& context, const RefPtr<Rend
|
||||
}
|
||||
canvas->Restore();
|
||||
}
|
||||
#endif
|
||||
|
||||
void RosenRenderRating::PaintFocus(
|
||||
const Offset& offset, double rRectRadius, const Size& boardSize, RenderContext& context)
|
||||
@ -191,16 +158,6 @@ void RosenRenderRating::PaintFocus(
|
||||
LOGE("Paint canvas is null");
|
||||
return;
|
||||
}
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
SkPaint paint;
|
||||
SkRRect rRect;
|
||||
paint.setColor(RATING_FOCUS_BOARD_COLOR);
|
||||
paint.setStyle(SkPaint::Style::kFill_Style);
|
||||
paint.setMaskFilter(SkMaskFilter::MakeBlur(SkBlurStyle::kSolid_SkBlurStyle, 1.0));
|
||||
rRect.setRectXY(SkRect::MakeWH(boardSize.Width(), boardSize.Height()), rRectRadius, rRectRadius);
|
||||
rRect.offset(offset.GetX(), offset.GetY());
|
||||
canvas->drawRRect(rRect, paint);
|
||||
#else
|
||||
RSBrush brush;
|
||||
brush.SetColor(RATING_FOCUS_BOARD_COLOR);
|
||||
RSFilter filter;
|
||||
@ -213,7 +170,6 @@ void RosenRenderRating::PaintFocus(
|
||||
canvas->AttachBrush(brush);
|
||||
canvas->DrawRoundRect(rRect);
|
||||
canvas->DetachBrush();
|
||||
#endif
|
||||
}
|
||||
|
||||
void RosenRenderRating::PaintFocusForTABLET(
|
||||
@ -224,17 +180,6 @@ void RosenRenderRating::PaintFocusForTABLET(
|
||||
LOGE("Paint canvas is null");
|
||||
return;
|
||||
}
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
SkPaint paint;
|
||||
SkRRect rRect;
|
||||
paint.setColor(FOCUS_BORDER_COLOR);
|
||||
paint.setStyle(SkPaint::Style::kStroke_Style);
|
||||
paint.setStrokeWidth(NormalizeToPx(FOCUS_BORDER_PADDING));
|
||||
paint.setAntiAlias(true);
|
||||
rRect.setRectXY(SkRect::MakeWH(boardSize.Width(), boardSize.Height()), rRectRadius, rRectRadius);
|
||||
rRect.offset(offset.GetX(), offset.GetY());
|
||||
canvas->drawRRect(rRect, paint);
|
||||
#else
|
||||
RSPen pen;
|
||||
pen.SetColor(FOCUS_BORDER_COLOR);
|
||||
pen.SetWidth(NormalizeToPx(FOCUS_BORDER_PADDING));
|
||||
@ -245,7 +190,6 @@ void RosenRenderRating::PaintFocusForTABLET(
|
||||
canvas->AttachPen(pen);
|
||||
canvas->DrawRoundRect(rRect);
|
||||
canvas->DetachPen();
|
||||
#endif
|
||||
}
|
||||
|
||||
void RosenRenderRating::PaintPress(
|
||||
|
@ -31,17 +31,10 @@ public:
|
||||
void PaintFocus(const Offset& offset, double rrectRadius, const Size& boardSize, RenderContext& context) override;
|
||||
void PaintFocusForTABLET(const Offset& offset, double rrectRadius, const Size& boardSize, RenderContext& context);
|
||||
void PaintPress(const Offset& offset, double rrectRadius, const Size& boardSize, RenderContext& context);
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void PaintRatingBar(RenderContext& context, SkCanvas* canvas);
|
||||
void PaintImageArea(RenderContext& context, const RefPtr<RenderImage>& renderImage, SkCanvas* canvas,
|
||||
const ImageAreaProperties& properties);
|
||||
void PaintHoverRect(SkCanvas* canvas);
|
||||
#else
|
||||
void PaintRatingBar(RenderContext& context, RSCanvas* canvas);
|
||||
void PaintImageArea(RenderContext& context, const RefPtr<RenderImage>& renderImage, RSCanvas* canvas,
|
||||
const ImageAreaProperties& properties);
|
||||
void PaintHoverRect(RSCanvas* canvas);
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace OHOS::Ace
|
||||
|
@ -15,12 +15,6 @@
|
||||
|
||||
#include "core/components/select_popup/rosen_render_select_popup.h"
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
#include "include/core/SkMaskFilter.h"
|
||||
#include "include/core/SkRect.h"
|
||||
#include "include/effects/SkGradientShader.h"
|
||||
#endif
|
||||
|
||||
#include "core/components/common/painter/rosen_decoration_painter.h"
|
||||
#include "core/pipeline/base/rosen_render_context.h"
|
||||
|
||||
@ -87,31 +81,6 @@ void RosenRenderSelectPopup::PaintGradient(RenderContext& context, bool isTop)
|
||||
LOGE("Paint canvas is null");
|
||||
return;
|
||||
}
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
SkPaint paintGradient;
|
||||
Rect gradientRect;
|
||||
auto interval = NormalizeToPx(optionInterval_);
|
||||
auto yPos = isTop ? GetOptionTop() : GetOptionBottom() - NormalizeToPx(GRADIENT_HEIGHT);
|
||||
gradientRect.SetOffset(Offset(GetOptionLeft() + interval, yPos));
|
||||
gradientRect.SetHeight(NormalizeToPx(GRADIENT_HEIGHT));
|
||||
gradientRect.SetWidth(GetOptionWidth() - 2 * interval);
|
||||
SkPoint beginPoint = SkPoint::Make(SkDoubleToScalar(gradientRect.Left()), SkDoubleToScalar(gradientRect.Top()));
|
||||
SkPoint endPoint = SkPoint::Make(SkDoubleToScalar(gradientRect.Left()), SkDoubleToScalar(gradientRect.Bottom()));
|
||||
SkPoint points[2] = { beginPoint, endPoint };
|
||||
// color with red 13, green 13, and blue 13 is used for color stop (0.85) in gradient
|
||||
SkColor colors[2] = { tvBackColor_.ChangeAlpha(0).GetValue(),
|
||||
Color::FromRGB(13, 13, 13).ChangeAlpha(GRADIENT_END_GRADIENT).GetValue() };
|
||||
if (isTop) {
|
||||
colors[0] = Color::FromRGB(13, 13, 13).ChangeAlpha(GRADIENT_END_GRADIENT).GetValue();
|
||||
colors[1] = tvBackColor_.ChangeAlpha(0).GetValue();
|
||||
}
|
||||
const float stopPositions[2] = { 0.0f, 0.85f };
|
||||
|
||||
paintGradient.setShader(
|
||||
SkGradientShader::MakeLinear(points, colors, stopPositions, std::size(colors), SkTileMode::kMirror));
|
||||
canvas->drawRect(
|
||||
{ gradientRect.Left(), gradientRect.Top(), gradientRect.Right(), gradientRect.Bottom() }, paintGradient);
|
||||
#else
|
||||
RSPen penGradient;
|
||||
Rect gradientRect;
|
||||
auto interval = NormalizeToPx(optionInterval_);
|
||||
@ -135,7 +104,6 @@ void RosenRenderSelectPopup::PaintGradient(RenderContext& context, bool isTop)
|
||||
canvas->AttachPen(penGradient);
|
||||
canvas->DrawRect(RSRect(gradientRect.Left(), gradientRect.Top(), gradientRect.Right(), gradientRect.Bottom()));
|
||||
canvas->DetachPen();
|
||||
#endif
|
||||
}
|
||||
|
||||
void RosenRenderSelectPopup::Paint(RenderContext& context, const Offset& offset)
|
||||
@ -150,14 +118,6 @@ void RosenRenderSelectPopup::Paint(RenderContext& context, const Offset& offset)
|
||||
LOGE("Paint canvas is null");
|
||||
return;
|
||||
}
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
canvas->save();
|
||||
SkPaint paint;
|
||||
paint.setARGB(tvBackColor_.GetAlpha(), tvBackColor_.GetRed(), tvBackColor_.GetGreen(), tvBackColor_.GetBlue());
|
||||
auto size = GetLayoutSize();
|
||||
canvas->drawRect(SkRect::MakeWH(size.Width(), size.Height()), paint);
|
||||
canvas->restore();
|
||||
#else
|
||||
canvas->Save();
|
||||
RSPen pen;
|
||||
pen.SetARGB(tvBackColor_.GetAlpha(), tvBackColor_.GetRed(), tvBackColor_.GetGreen(), tvBackColor_.GetBlue());
|
||||
@ -166,7 +126,6 @@ void RosenRenderSelectPopup::Paint(RenderContext& context, const Offset& offset)
|
||||
canvas->DrawRect(RSRect(0, 0, size.Width(), size.Height()));
|
||||
canvas->DetachPen();
|
||||
canvas->Restore();
|
||||
#endif
|
||||
}
|
||||
RenderNode::Paint(context, offset);
|
||||
|
||||
|
@ -16,10 +16,6 @@
|
||||
#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SELECT_POPUP_ROSEN_RENDER_SELECT_POPUP_H
|
||||
#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SELECT_POPUP_ROSEN_RENDER_SELECT_POPUP_H
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
#include "include/core/SkCanvas.h"
|
||||
#endif
|
||||
|
||||
#include "core/components/select_popup/render_select_popup.h"
|
||||
|
||||
namespace OHOS::Ace {
|
||||
|
@ -348,23 +348,6 @@ void RosenRenderSlider::PaintTrackFocus(RenderContext& context, const Offset& of
|
||||
trackFocusHeight = track->GetTrackThickness() + NormalizeToPx(FOCUS_PADDING * 2 + FOCUS_BORDER_WIDTH);
|
||||
trackFocusRadius = trackFocusHeight * HALF;
|
||||
}
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
SkPaint paint;
|
||||
paint.setColor(FOCUS_BORDER_COLOR);
|
||||
paint.setStrokeWidth(NormalizeToPx(FOCUS_BORDER_WIDTH));
|
||||
paint.setStyle(SkPaint::Style::kStroke_Style);
|
||||
paint.setAntiAlias(true);
|
||||
SkRRect rRect;
|
||||
rRect.setRectXY(SkRect::MakeIWH(trackFocusWidth, trackFocusHeight), trackFocusRadius, trackFocusRadius);
|
||||
if (direction_ == Axis::VERTICAL) {
|
||||
rRect.offset(track->GetTrackThickness() * HALF - NormalizeToPx(FOCUS_PADDING + FOCUS_BORDER_WIDTH * HALF),
|
||||
NormalizeToPx(FOCUS_BORDER_WIDTH * HALF * HALF));
|
||||
} else {
|
||||
rRect.offset(NormalizeToPx(FOCUS_BORDER_WIDTH * HALF * HALF),
|
||||
track->GetTrackThickness() * HALF - NormalizeToPx(FOCUS_PADDING + FOCUS_BORDER_WIDTH * HALF));
|
||||
}
|
||||
canvas->drawRRect(rRect, paint);
|
||||
#else
|
||||
RSPen pen;
|
||||
pen.SetColor(FOCUS_BORDER_COLOR);
|
||||
pen.SetWidth(NormalizeToPx(FOCUS_BORDER_WIDTH));
|
||||
@ -383,7 +366,6 @@ void RosenRenderSlider::PaintTrackFocus(RenderContext& context, const Offset& of
|
||||
canvas->AttachPen(pen);
|
||||
canvas->DrawRoundRect(rRect);
|
||||
canvas->DetachPen();
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace OHOS::Ace
|
||||
|
@ -64,7 +64,7 @@ public:
|
||||
theme->textStyle_.SetTextColor(pattern->GetAttr<Color>(PATTERN_TEXT_COLOR, Color::BLACK)
|
||||
.BlendOpacity(pattern->GetAttr<double>(PATTERN_TEXT_COLOR_ALPHA, 0.9)));
|
||||
theme->textStyle_.SetFontSize(pattern->GetAttr<Dimension>("text_font_size", 0.0_vp));
|
||||
theme->caretColor_ = pattern->GetAttr<Color>("text_caret_color", Color(0xff3f97e9));
|
||||
theme->caretColor_ = pattern->GetAttr<Color>("text_caret_color", Color(0xff006cde));
|
||||
theme->selectedColor_ = pattern->GetAttr<Color>(PATTERN_BG_COLOR_SELECTED, Color(0x33007dff));
|
||||
auto draggable = pattern->GetAttr<std::string>("draggable", "0");
|
||||
theme->draggable_ = StringUtils::StringToInt(draggable);
|
||||
|
@ -15,17 +15,11 @@
|
||||
|
||||
#include "core/components/toggle/rosen_render_toggle.h"
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
#include "include/core/SkRRect.h"
|
||||
#endif
|
||||
|
||||
#ifdef OHOS_PLATFORM
|
||||
#include "core/components/common/painter/rosen_svg_painter.h"
|
||||
#else
|
||||
#ifdef USE_ROSEN_DRAWING
|
||||
#include "core/components_ng/render/drawing.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace OHOS::Ace {
|
||||
|
||||
@ -54,13 +48,8 @@ void RosenRenderToggle::Paint(RenderContext& context, const Offset& offset)
|
||||
}
|
||||
UpdateLayer();
|
||||
#ifdef OHOS_PLATFORM
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
auto recordingCanvas = static_cast<Rosen::RSRecordingCanvas*>(canvas);
|
||||
recordingCanvas->concat(RosenSvgPainter::ToSkMatrix(transformLayer_));
|
||||
#else
|
||||
auto recordingCanvas = static_cast<RSRecordingCanvas*>(canvas);
|
||||
recordingCanvas->ConcatMatrix(RosenSvgPainter::ToDrawingMatrix(transformLayer_));
|
||||
#endif
|
||||
#endif
|
||||
DrawToggle(canvas, offset);
|
||||
RenderNode::Paint(context, offset);
|
||||
@ -75,21 +64,6 @@ Size RosenRenderToggle::Measure()
|
||||
return toggleSize_;
|
||||
}
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void RosenRenderToggle::DrawToggle(SkCanvas* canvas, const Offset& offset) const
|
||||
{
|
||||
SkPaint paint;
|
||||
paint.setColor(GetStatusColor().GetValue());
|
||||
paint.setStyle(SkPaint::Style::kFill_Style);
|
||||
paint.setAntiAlias(true);
|
||||
|
||||
SkRRect rRect;
|
||||
double radius = toggleSize_.Height() / 2;
|
||||
rRect.setRectXY(SkRect::MakeIWH(toggleSize_.Width(), toggleSize_.Height()), radius, radius);
|
||||
rRect.offset(offset.GetX(), offset.GetY());
|
||||
canvas->drawRRect(rRect, paint);
|
||||
}
|
||||
#else
|
||||
void RosenRenderToggle::DrawToggle(RSCanvas* canvas, const Offset& offset) const
|
||||
{
|
||||
RSBrush brush;
|
||||
@ -106,7 +80,6 @@ void RosenRenderToggle::DrawToggle(RSCanvas* canvas, const Offset& offset) const
|
||||
canvas->DrawRoundRect(rRect);
|
||||
canvas->DetachBrush();
|
||||
}
|
||||
#endif
|
||||
|
||||
Color RosenRenderToggle::GetStatusColor() const
|
||||
{
|
||||
|
@ -16,10 +16,6 @@
|
||||
#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_TOGGLE_ROSEN_RENDER_TOGGLE_H
|
||||
#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_TOGGLE_ROSEN_RENDER_TOGGLE_H
|
||||
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
#include "include/core/SkCanvas.h"
|
||||
#endif
|
||||
|
||||
#include "core/components/toggle/render_toggle.h"
|
||||
#include "core/components/transform/rosen_render_transform.h"
|
||||
|
||||
@ -38,11 +34,7 @@ public:
|
||||
|
||||
private:
|
||||
Size Measure() override;
|
||||
#ifndef USE_ROSEN_DRAWING
|
||||
void DrawToggle(SkCanvas* canvas, const Offset& offset) const;
|
||||
#else
|
||||
void DrawToggle(RSCanvas* canvas, const Offset& offset) const;
|
||||
#endif
|
||||
void UpdateLayer();
|
||||
Color GetStatusColor() const;
|
||||
Matrix4 transformLayer_ = Matrix4::CreateIdentity();
|
||||
|
@ -1498,12 +1498,6 @@ void DragEventActuator::BindClickEvent(const RefPtr<FrameNode>& columnNode)
|
||||
actuator->HidePixelMap();
|
||||
actuator->HideFilter();
|
||||
}
|
||||
|
||||
auto pipeline = PipelineContext::GetCurrentContext();
|
||||
CHECK_NULL_VOID(pipeline);
|
||||
auto dragDropManager = pipeline->GetDragDropManager();
|
||||
CHECK_NULL_VOID(dragDropManager);
|
||||
dragDropManager->SetIsDragNodeNeedClean(true);
|
||||
};
|
||||
auto columnGestureHub = columnNode->GetOrCreateGestureEventHub();
|
||||
CHECK_NULL_VOID(columnGestureHub);
|
||||
@ -1571,6 +1565,9 @@ void DragEventActuator::ExecutePreDragAction(const PreDragStatus preDragStatus,
|
||||
if (!gestureHub->IsAllowedDrag(eventHub) || gestureHub->GetTextDraggable()) {
|
||||
return;
|
||||
}
|
||||
if (preDragStatus == PreDragStatus::PREVIEW_LANDING_STARTED) {
|
||||
dragDropManager->SetIsDragNodeNeedClean(true);
|
||||
}
|
||||
auto onPreDragStatus = PreDragStatus::ACTION_CANCELED_BEFORE_DRAG;
|
||||
if (dragDropManager->GetPreDragStatus() <= preDragStatus &&
|
||||
preDragStatus != PreDragStatus::ACTION_CANCELED_BEFORE_DRAG) {
|
||||
@ -1983,6 +1980,8 @@ RefPtr<FrameNode> DragEventActuator::CreateImageNode(const RefPtr<FrameNode>& fr
|
||||
Vector5F rotate = Vector5F(0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
|
||||
imageContext->UpdateTransformRotate(rotate);
|
||||
imageContext->UpdateClipEdge(true);
|
||||
imageContext->UpdateBorderRadius(BorderRadiusProperty(Dimension()));
|
||||
imageContext->UpdateOpacity(1.0f);
|
||||
ClickEffectInfo clickEffectInfo;
|
||||
clickEffectInfo.level = ClickEffectLevel::LIGHT;
|
||||
clickEffectInfo.scaleNumber = SCALE_NUMBER;
|
||||
|
@ -37,6 +37,7 @@ public:
|
||||
: type_(type), recognizerType_(trueType), isSystemGesture_(isSystemGesture)
|
||||
{}
|
||||
explicit GestureInfo(std::string tag) : tag_(std::move(tag)) {}
|
||||
explicit GestureInfo(std::set<SourceTool> allowedTypes) : allowedTypes_(std::move(allowedTypes)) {}
|
||||
explicit GestureInfo(GestureTypeName type) : type_(type) {}
|
||||
explicit GestureInfo(bool isSystemGesture) : isSystemGesture_(isSystemGesture) {}
|
||||
~GestureInfo() override
|
||||
@ -57,6 +58,11 @@ public:
|
||||
return tag_;
|
||||
}
|
||||
|
||||
const std::set<SourceTool>& GetAllowedTypes() const
|
||||
{
|
||||
return allowedTypes_;
|
||||
}
|
||||
|
||||
GestureTypeName GetType() const
|
||||
{
|
||||
return type_;
|
||||
@ -77,6 +83,11 @@ public:
|
||||
tag_ = std::move(tag);
|
||||
}
|
||||
|
||||
void SetAllowedTypes(std::set<SourceTool> allowedTypes)
|
||||
{
|
||||
allowedTypes_ = std::move(allowedTypes);
|
||||
}
|
||||
|
||||
void SetType(GestureTypeName type)
|
||||
{
|
||||
type_ = type;
|
||||
@ -144,6 +155,7 @@ public:
|
||||
|
||||
private:
|
||||
std::optional<std::string> tag_;
|
||||
std::set<SourceTool> allowedTypes_{};
|
||||
GestureTypeName type_ = GestureTypeName::UNKNOWN;
|
||||
// used in onGestureRecognizerJudgeBegin
|
||||
GestureTypeName recognizerType_ = GestureTypeName::UNKNOWN;
|
||||
|
@ -166,6 +166,15 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void SetAllowedTypes(std::set<SourceTool> allowedTypes)
|
||||
{
|
||||
if (gestureInfo_) {
|
||||
gestureInfo_->SetAllowedTypes(std::move(allowedTypes));
|
||||
} else {
|
||||
gestureInfo_ = MakeRefPtr<GestureInfo>(allowedTypes);
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<std::string> GetTag()
|
||||
{
|
||||
if (gestureInfo_) {
|
||||
@ -174,6 +183,14 @@ public:
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::set<SourceTool> GetAllowedTypes()
|
||||
{
|
||||
if (gestureInfo_) {
|
||||
return gestureInfo_->GetAllowedTypes();
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
virtual int32_t SizeofMe()
|
||||
{
|
||||
return 0;
|
||||
|
@ -545,6 +545,7 @@ bool ClickRecognizer::ReconcileFrom(const RefPtr<NGGestureRecognizer>& recognize
|
||||
}
|
||||
|
||||
onAction_ = std::move(curr->onAction_);
|
||||
ReconcileGestureInfoFrom(recognizer);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -553,7 +554,8 @@ RefPtr<GestureSnapshot> ClickRecognizer::Dump() const
|
||||
RefPtr<GestureSnapshot> info = NGGestureRecognizer::Dump();
|
||||
std::stringstream oss;
|
||||
oss << "count: " << count_ << ", "
|
||||
<< "fingers: " << fingers_;
|
||||
<< "fingers: " << fingers_ << ", "
|
||||
<< DumpGestureInfo();
|
||||
info->customInfo = oss.str();
|
||||
return info;
|
||||
}
|
||||
|
@ -55,6 +55,17 @@ bool NGGestureRecognizer::ShouldResponse()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NGGestureRecognizer::IsAllowedType(SourceTool type)
|
||||
{
|
||||
// allow all types by default
|
||||
if (!gestureInfo_) {
|
||||
return true;
|
||||
}
|
||||
|
||||
auto allowedTypes = gestureInfo_->GetAllowedTypes();
|
||||
return allowedTypes.empty() || allowedTypes.find(type) != allowedTypes.end();
|
||||
}
|
||||
|
||||
void NGGestureRecognizer::OnRejectBridgeObj()
|
||||
{
|
||||
if (bridgeObjList_.empty()) {
|
||||
@ -71,10 +82,13 @@ void NGGestureRecognizer::OnRejectBridgeObj()
|
||||
|
||||
bool NGGestureRecognizer::HandleEvent(const TouchEvent& point)
|
||||
{
|
||||
if (!ShouldResponse()) {
|
||||
if (!IsAllowedType(point.sourceTool) && point.type != TouchType::CANCEL) {
|
||||
if (point.type == TouchType::DOWN) {
|
||||
RemoveUnsupportEvent(point.id);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (bridgeMode_) {
|
||||
if (!ShouldResponse() || bridgeMode_) {
|
||||
return true;
|
||||
}
|
||||
switch (point.type) {
|
||||
@ -85,11 +99,8 @@ bool NGGestureRecognizer::HandleEvent(const TouchEvent& point)
|
||||
case TouchType::DOWN: {
|
||||
deviceId_ = point.deviceId;
|
||||
deviceType_ = point.sourceType;
|
||||
if (deviceType_ == SourceType::MOUSE) {
|
||||
inputEventType_ = InputEventType::MOUSE_BUTTON;
|
||||
} else {
|
||||
inputEventType_ = InputEventType::TOUCH_SCREEN;
|
||||
}
|
||||
inputEventType_ = deviceType_ == SourceType::MOUSE ? InputEventType::MOUSE_BUTTON :
|
||||
InputEventType::TOUCH_SCREEN;
|
||||
auto result = AboutToAddCurrentFingers(point);
|
||||
if (result) {
|
||||
HandleTouchDownEvent(point);
|
||||
@ -123,10 +134,13 @@ bool NGGestureRecognizer::HandleEvent(const TouchEvent& point)
|
||||
|
||||
bool NGGestureRecognizer::HandleEvent(const AxisEvent& event)
|
||||
{
|
||||
if (!ShouldResponse()) {
|
||||
if (!IsAllowedType(event.sourceTool) && event.action != AxisAction::CANCEL) {
|
||||
if (event.action == AxisAction::BEGIN) {
|
||||
RemoveUnsupportEvent(event.id);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (bridgeMode_) {
|
||||
if (!ShouldResponse() || bridgeMode_) {
|
||||
return true;
|
||||
}
|
||||
switch (event.action) {
|
||||
@ -366,6 +380,15 @@ void NGGestureRecognizer::HandleDidAccept()
|
||||
}
|
||||
}
|
||||
|
||||
void NGGestureRecognizer::ReconcileGestureInfoFrom(const RefPtr<NGGestureRecognizer>& recognizer)
|
||||
{
|
||||
CHECK_NULL_VOID(recognizer);
|
||||
auto currGestureInfo = recognizer->GetGestureInfo();
|
||||
if (gestureInfo_ && currGestureInfo) {
|
||||
gestureInfo_->SetAllowedTypes(currGestureInfo->GetAllowedTypes());
|
||||
}
|
||||
}
|
||||
|
||||
RefPtr<GestureSnapshot> NGGestureRecognizer::Dump() const
|
||||
{
|
||||
RefPtr<GestureSnapshot> info = TouchEventTarget::Dump();
|
||||
|
@ -432,11 +432,15 @@ protected:
|
||||
virtual void OnResetStatus() = 0;
|
||||
|
||||
virtual void OnSucceedCancel() {}
|
||||
virtual void RemoveUnsupportEvent(int32_t touchId) {}
|
||||
bool ShouldResponse() override;
|
||||
bool IsAllowedType(SourceTool type);
|
||||
|
||||
void HandleWillAccept();
|
||||
void HandleDidAccept();
|
||||
|
||||
void ReconcileGestureInfoFrom(const RefPtr<NGGestureRecognizer>& recognizer);
|
||||
|
||||
RefereeState refereeState_ = RefereeState::READY;
|
||||
|
||||
GestureDisposal disposal_ = GestureDisposal::NONE;
|
||||
|
@ -402,7 +402,7 @@ bool LongPressRecognizer::ReconcileFrom(const RefPtr<NGGestureRecognizer>& recog
|
||||
onAction_ = std::move(curr->onAction_);
|
||||
onActionEnd_ = std::move(curr->onActionEnd_);
|
||||
onActionCancel_ = std::move(curr->onActionCancel_);
|
||||
|
||||
ReconcileGestureInfoFrom(recognizer);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -434,7 +434,8 @@ RefPtr<GestureSnapshot> LongPressRecognizer::Dump() const
|
||||
oss << "duration: " << duration_ << ", "
|
||||
<< "isForDrag: " << isForDrag_ << ", "
|
||||
<< "repeat: " << repeat_ << ", "
|
||||
<< "fingers: " << fingers_;
|
||||
<< "fingers: " << fingers_ << ", "
|
||||
<< DumpGestureInfo();
|
||||
info->customInfo = oss.str();
|
||||
return info;
|
||||
}
|
||||
|
@ -121,4 +121,29 @@ void MultiFingersRecognizer::UpdateTouchPointWithAxisEvent(const AxisEvent& even
|
||||
touchPoints_[event.id].pointers = { point };
|
||||
touchPoints_[event.id].pointerEvent = event.pointerEvent;
|
||||
}
|
||||
|
||||
std::string MultiFingersRecognizer::DumpGestureInfo() const
|
||||
{
|
||||
std::string infoStr;
|
||||
infoStr.append("allowedTypes: [");
|
||||
std::set<SourceTool> allowedTypes = {};
|
||||
if (gestureInfo_) {
|
||||
allowedTypes = gestureInfo_->GetAllowedTypes();
|
||||
}
|
||||
if (allowedTypes.empty()) {
|
||||
infoStr.append("all]");
|
||||
return infoStr;
|
||||
}
|
||||
|
||||
auto it = allowedTypes.begin();
|
||||
while (it != allowedTypes.end()) {
|
||||
infoStr.append(std::to_string(static_cast<int32_t>(*it)));
|
||||
it++;
|
||||
if (it != allowedTypes.end()) {
|
||||
infoStr.append(", ");
|
||||
}
|
||||
}
|
||||
infoStr.append("]");
|
||||
return infoStr;
|
||||
}
|
||||
} // namespace OHOS::Ace::NG
|
||||
|
@ -78,6 +78,14 @@ protected:
|
||||
touchPoints_[touchId] = {};
|
||||
}
|
||||
|
||||
void RemoveUnsupportEvent(int32_t touchId) override
|
||||
{
|
||||
if (touchPoints_.empty() || touchPoints_.find(touchId) == touchPoints_.end()) {
|
||||
return;
|
||||
}
|
||||
touchPoints_.erase(touchId);
|
||||
}
|
||||
|
||||
void UpdateTouchPointWithAxisEvent(const AxisEvent& event);
|
||||
|
||||
void OnFinishGestureReferee(int32_t touchId, bool isBlocked) override;
|
||||
@ -101,6 +109,8 @@ protected:
|
||||
return std::find(activeFingers_.begin(), activeFingers_.end(), touchId) != activeFingers_.end();
|
||||
}
|
||||
|
||||
std::string DumpGestureInfo() const;
|
||||
|
||||
std::map<int32_t, TouchEvent> touchPoints_;
|
||||
std::list<FingerInfo> fingerList_;
|
||||
std::list<int32_t> activeFingers_;
|
||||
|
@ -815,7 +815,7 @@ bool PanRecognizer::ReconcileFrom(const RefPtr<NGGestureRecognizer>& recognizer)
|
||||
onActionUpdate_ = std::move(curr->onActionUpdate_);
|
||||
onActionEnd_ = std::move(curr->onActionEnd_);
|
||||
onActionCancel_ = std::move(curr->onActionCancel_);
|
||||
|
||||
ReconcileGestureInfoFrom(recognizer);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -892,7 +892,8 @@ RefPtr<GestureSnapshot> PanRecognizer::Dump() const
|
||||
oss << "direction: " << direction_.type << ", "
|
||||
<< "isForDrag: " << isForDrag_ << ", "
|
||||
<< "distance: " << distance_ << ", "
|
||||
<< "fingers: " << fingers_;
|
||||
<< "fingers: " << fingers_ << ", "
|
||||
<< DumpGestureInfo();
|
||||
info->customInfo = oss.str();
|
||||
return info;
|
||||
}
|
||||
|
@ -485,8 +485,19 @@ bool PinchRecognizer::ReconcileFrom(const RefPtr<NGGestureRecognizer>& recognize
|
||||
onActionUpdate_ = std::move(curr->onActionUpdate_);
|
||||
onActionEnd_ = std::move(curr->onActionEnd_);
|
||||
onActionCancel_ = std::move(curr->onActionCancel_);
|
||||
|
||||
ReconcileGestureInfoFrom(recognizer);
|
||||
return true;
|
||||
}
|
||||
|
||||
RefPtr<GestureSnapshot> PinchRecognizer::Dump() const
|
||||
{
|
||||
RefPtr<GestureSnapshot> info = NGGestureRecognizer::Dump();
|
||||
std::stringstream oss;
|
||||
oss << "distance: " << distance_ << ", "
|
||||
<< "fingers: " << fingers_ << ", "
|
||||
<< DumpGestureInfo();
|
||||
info->customInfo = oss.str();
|
||||
return info;
|
||||
}
|
||||
|
||||
} // namespace OHOS::Ace::NG
|
||||
|
@ -34,6 +34,8 @@ public:
|
||||
void OnAccepted() override;
|
||||
void OnRejected() override;
|
||||
|
||||
virtual RefPtr<GestureSnapshot> Dump() const override;
|
||||
|
||||
private:
|
||||
void HandleTouchDownEvent(const TouchEvent& event) override;
|
||||
void HandleTouchUpEvent(const TouchEvent& event) override;
|
||||
|
@ -426,8 +426,19 @@ bool RotationRecognizer::ReconcileFrom(const RefPtr<NGGestureRecognizer>& recogn
|
||||
onActionUpdate_ = std::move(curr->onActionUpdate_);
|
||||
onActionEnd_ = std::move(curr->onActionEnd_);
|
||||
onActionCancel_ = std::move(curr->onActionCancel_);
|
||||
|
||||
ReconcileGestureInfoFrom(recognizer);
|
||||
return true;
|
||||
}
|
||||
|
||||
RefPtr<GestureSnapshot> RotationRecognizer::Dump() const
|
||||
{
|
||||
RefPtr<GestureSnapshot> info = NGGestureRecognizer::Dump();
|
||||
std::stringstream oss;
|
||||
oss << "angle: " << angle_ << ", "
|
||||
<< "fingers: " << fingers_ << ", "
|
||||
<< DumpGestureInfo();
|
||||
info->customInfo = oss.str();
|
||||
return info;
|
||||
}
|
||||
|
||||
} // namespace OHOS::Ace::NG
|
||||
|
@ -34,6 +34,8 @@ public:
|
||||
void OnAccepted() override;
|
||||
void OnRejected() override;
|
||||
|
||||
virtual RefPtr<GestureSnapshot> Dump() const override;
|
||||
|
||||
private:
|
||||
void HandleTouchDownEvent(const TouchEvent& event) override;
|
||||
void HandleTouchUpEvent(const TouchEvent& event) override;
|
||||
|
@ -463,6 +463,7 @@ bool SwipeRecognizer::ReconcileFrom(const RefPtr<NGGestureRecognizer>& recognize
|
||||
}
|
||||
|
||||
onAction_ = std::move(curr->onAction_);
|
||||
ReconcileGestureInfoFrom(recognizer);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -472,7 +473,8 @@ RefPtr<GestureSnapshot> SwipeRecognizer::Dump() const
|
||||
std::stringstream oss;
|
||||
oss << "direction: " << direction_.type << ", "
|
||||
<< "speed: " << speed_ << ", "
|
||||
<< "fingers: " << fingers_;
|
||||
<< "fingers: " << fingers_ << ", "
|
||||
<< DumpGestureInfo();
|
||||
info->customInfo = oss.str();
|
||||
return info;
|
||||
}
|
||||
|
@ -371,10 +371,16 @@ void SelectContentOverlayManager::MarkInfoChange(SelectOverlayDirtyFlag dirty)
|
||||
auto selectedInfo = selectOverlayHolder_->GetSelectedText();
|
||||
menuPattern->SetSelectInfo(selectedInfo);
|
||||
}
|
||||
}
|
||||
if ((dirty & DIRTY_VIEWPORT) == DIRTY_VIEWPORT) {
|
||||
auto viewPort = selectOverlayHolder_->GetAncestorNodeViewPort();
|
||||
if (menuPattern) {
|
||||
menuPattern->UpdateViewPort(viewPort);
|
||||
}
|
||||
auto handlePattern = GetSelectHandlePattern(WeakClaim(this));
|
||||
if (handlePattern) {
|
||||
handlePattern->UpdateViewPort(viewPort);
|
||||
}
|
||||
}
|
||||
UpdateHandleInfosWithFlag(dirty);
|
||||
selectOverlayHolder_->OnHandleMarkInfoChange(shareOverlayInfo_, dirty);
|
||||
|
@ -1249,8 +1249,8 @@ bool BubbleLayoutAlgorithm::CheckPositionInPlacementRect(
|
||||
{
|
||||
auto x = position.GetX();
|
||||
auto y = position.GetY();
|
||||
if (x < rect.Left() || (x + childSize.Width()) > rect.Right() || y < rect.Top() ||
|
||||
(y + childSize.Height()) > rect.Bottom()) {
|
||||
if (LessNotEqual(x, rect.Left()) || GreatNotEqual(x + childSize.Width(), rect.Right()) ||
|
||||
LessNotEqual(y, rect.Top()) || GreatNotEqual(y + childSize.Height(), rect.Bottom())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -104,6 +104,7 @@ void BubblePattern::OnAttachToFrameNode()
|
||||
auto host = GetHost();
|
||||
CHECK_NULL_VOID(host);
|
||||
host->GetRenderContext()->SetClipToFrame(true);
|
||||
|
||||
auto targetNode = FrameNode::GetFrameNode(targetTag_, targetNodeId_);
|
||||
CHECK_NULL_VOID(targetNode);
|
||||
auto pipelineContext = host->GetContextRefPtr();
|
||||
@ -111,28 +112,12 @@ void BubblePattern::OnAttachToFrameNode()
|
||||
hasOnAreaChange_ = pipelineContext->HasOnAreaChangeNode(targetNode->GetId());
|
||||
auto eventHub = targetNode->GetEventHub<EventHub>();
|
||||
CHECK_NULL_VOID(eventHub);
|
||||
OnAreaChangedFunc onAreaChangedFunc = [popupNodeWk = WeakPtr<FrameNode>(host)](const RectF& oldRect,
|
||||
const OffsetF& oldOrigin, const RectF& /* rect */,
|
||||
OnAreaChangedFunc onAreaChangedFunc = [popupNodeWk = WeakPtr<FrameNode>(host)](const RectF& /* oldRect */,
|
||||
const OffsetF& /* oldOrigin */, const RectF& /* rect */,
|
||||
const OffsetF& /* origin */) {
|
||||
// Not handle first change
|
||||
if (oldRect.IsEmpty() && oldOrigin.NonOffset()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto pipelineContext = PipelineContext::GetCurrentContext();
|
||||
AnimationOption option;
|
||||
option.SetCurve(pipelineContext->GetSafeAreaManager()->GetSafeAreaCurve());
|
||||
AnimationUtils::Animate(
|
||||
option,
|
||||
[weakPipeline = WeakPtr<PipelineContext>(pipelineContext), weakPopup = popupNodeWk]() {
|
||||
auto popup = weakPopup.Upgrade();
|
||||
CHECK_NULL_VOID(popup);
|
||||
auto pipeline = weakPipeline.Upgrade();
|
||||
CHECK_NULL_VOID(pipeline);
|
||||
popup->MarkDirtyNode(PROPERTY_UPDATE_MEASURE);
|
||||
pipeline->FlushUITasks();
|
||||
});
|
||||
pipelineContext->FlushPipelineImmediately();
|
||||
auto popupNode = popupNodeWk.Upgrade();
|
||||
CHECK_NULL_VOID(popupNode);
|
||||
popupNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE);
|
||||
};
|
||||
eventHub->AddInnerOnAreaChangedCallback(host->GetId(), std::move(onAreaChangedFunc));
|
||||
|
||||
|
@ -615,6 +615,9 @@ void BubbleView::UpdateCommonParam(int32_t popupId, const RefPtr<PopupParam>& pa
|
||||
if (param->GetChildWidth().has_value()) {
|
||||
childLayoutProperty->UpdateUserDefinedIdealSize(
|
||||
CalcSize(CalcLength(param->GetChildWidth().value()), std::nullopt));
|
||||
} else {
|
||||
childLayoutProperty->UpdateUserDefinedIdealSize(
|
||||
CalcSize(CalcLength(Dimension(popupMaxWidth)), std::nullopt));
|
||||
}
|
||||
if (renderContext) {
|
||||
if ((Container::LessThanAPIVersion(PlatformVersion::VERSION_ELEVEN))) {
|
||||
|
@ -36,6 +36,7 @@ public:
|
||||
virtual void SetOnGestureEvent(const GestureEventNoParameter& gestureEventNoParameter) = 0;
|
||||
virtual void SetOnActionFunc(const GestureEventFunc& gestureEventFunc, const Ace::GestureEventAction& action) = 0;
|
||||
virtual void SetTag(const std::string& tag) = 0;
|
||||
virtual void SetAllowedTypes(const std::set<SourceTool>& allowedTypes) = 0;
|
||||
|
||||
private:
|
||||
static std::unique_ptr<GestureModel> instance_;
|
||||
|
@ -113,6 +113,15 @@ void GestureModelNG::SetTag(const std::string& tag)
|
||||
gesture->SetTag(tag);
|
||||
}
|
||||
|
||||
void GestureModelNG::SetAllowedTypes(const std::set<SourceTool>& allowedTypes)
|
||||
{
|
||||
RefPtr<GestureProcessor> gestureProcessor;
|
||||
gestureProcessor = NG::ViewStackProcessor::GetInstance()->GetOrCreateGestureProcessor();
|
||||
auto gesture = gestureProcessor->TopGestureNG();
|
||||
CHECK_NULL_VOID(gesture);
|
||||
gesture->SetAllowedTypes(allowedTypes);
|
||||
}
|
||||
|
||||
void TapGestureModelNG::Create(int32_t countNum, int32_t fingersNum, double distanceThreshold)
|
||||
{
|
||||
RefPtr<GestureProcessor> gestureProcessor;
|
||||
|
@ -28,6 +28,7 @@ public:
|
||||
void SetOnGestureEvent(const GestureEventNoParameter& gestureEventNoParameter) override;
|
||||
void SetOnActionFunc(const GestureEventFunc& gestureEventFunc, const Ace::GestureEventAction& action) override;
|
||||
void SetTag(const std::string& tag) override;
|
||||
void SetAllowedTypes(const std::set<SourceTool>& allowedTypes) override;
|
||||
};
|
||||
|
||||
class ACE_EXPORT TapGestureModelNG : public OHOS::Ace::TapGestureModel {
|
||||
|
@ -74,11 +74,11 @@ public:
|
||||
ResetGridLayoutInfoAndMeasure();
|
||||
}
|
||||
|
||||
ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(MainIndex, int32_t, PROPERTY_UPDATE_LAYOUT);
|
||||
ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(CrossIndex, int32_t, PROPERTY_UPDATE_LAYOUT);
|
||||
|
||||
ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(RealColumnSpan, int32_t, PROPERTY_UPDATE_LAYOUT);
|
||||
ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(RealRowSpan, int32_t, PROPERTY_UPDATE_LAYOUT);
|
||||
/** Accessibility info cache */
|
||||
ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(MainIndex, int32_t, PROPERTY_UPDATE_NORMAL);
|
||||
ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(CrossIndex, int32_t, PROPERTY_UPDATE_NORMAL);
|
||||
ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(RealColumnSpan, int32_t, PROPERTY_UPDATE_NORMAL);
|
||||
ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(RealRowSpan, int32_t, PROPERTY_UPDATE_NORMAL);
|
||||
|
||||
int32_t GetCustomCrossIndex(Axis axis) const;
|
||||
int32_t GetMainSpan(Axis axis) const;
|
||||
|
@ -17,6 +17,23 @@
|
||||
|
||||
#include "core/components_v2/grid_layout/grid_container_utils.h"
|
||||
|
||||
namespace {
|
||||
std::string GetAlignItemsStr(OHOS::Ace::FlexAlign alignItems)
|
||||
{
|
||||
switch (alignItems) {
|
||||
case OHOS::Ace::FlexAlign::CENTER:
|
||||
return "ItemAlign.Center";
|
||||
case OHOS::Ace::FlexAlign::STRETCH:
|
||||
return "ItemAlign.Stretch";
|
||||
case OHOS::Ace::FlexAlign::FLEX_END:
|
||||
return "ItemAlign.End";
|
||||
case OHOS::Ace::FlexAlign::FLEX_START:
|
||||
return "ItemAlign.Start";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
};
|
||||
namespace OHOS::Ace::NG {
|
||||
using OHOS::Ace::V2::GridContainerUtils;
|
||||
void GridRowLayoutProperty::ToJsonValue(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const
|
||||
@ -47,8 +64,13 @@ void GridRowLayoutProperty::ToJsonValue(std::unique_ptr<JsonValue>& json, const
|
||||
}
|
||||
str = (static_cast<int32_t>(breakPoints.breakpoints.size()) > 1) ?
|
||||
str.substr(0, static_cast<int32_t>(str.size()) - 1).append("]") : str.append("]");
|
||||
json->PutExtAttr("breakpoints", std::to_string(columns).c_str(), filter);
|
||||
|
||||
json->PutExtAttr("breakpoints", str.c_str(), filter);
|
||||
if (breakPoints.reference == V2::BreakPointsReference::WindowSize) {
|
||||
str.assign("WindowSize");
|
||||
} else {
|
||||
str.assign("ComponentSize");
|
||||
}
|
||||
json->PutExtAttr("reference", str.c_str(), filter);
|
||||
auto direction = GetDirection();
|
||||
if (!direction) {
|
||||
str.assign("Row");
|
||||
@ -59,6 +81,8 @@ void GridRowLayoutProperty::ToJsonValue(std::unique_ptr<JsonValue>& json, const
|
||||
} else {
|
||||
str.assign("Unknown");
|
||||
}
|
||||
json->PutExtAttr("direction", std::to_string(columns).c_str(), filter);
|
||||
json->PutExtAttr("direction", str.c_str(), filter);
|
||||
auto alignItems = GetAlignItems();
|
||||
json->PutExtAttr("alignItems", GetAlignItemsStr(alignItems.value_or(FlexAlign::FLEX_START)).c_str(), filter);
|
||||
}
|
||||
} // namespace OHOS::Ace::NG
|
||||
|
@ -339,6 +339,8 @@ bool ListItemGroupLayoutAlgorithm::NeedMeasureItem(LayoutWrapper* layoutWrapper)
|
||||
if (NearZero(contentMainSize)) {
|
||||
return true;
|
||||
}
|
||||
bool layoutedEntirely = layoutedItemInfo_ && layoutedItemInfo_.value().startIndex <= 0 &&
|
||||
layoutedItemInfo_.value().endIndex >= totalItemCount_ - 1;
|
||||
if (forwardLayout_) {
|
||||
if (childrenSize_ && needAdjustRefPos_) {
|
||||
referencePos_ -= (totalMainSize_ - posMap_->GetPrevTotalHeight());
|
||||
@ -350,13 +352,11 @@ bool ListItemGroupLayoutAlgorithm::NeedMeasureItem(LayoutWrapper* layoutWrapper)
|
||||
if (LessNotEqual(totalMainSize_ - footerMainSize_, startPos_ - referencePos_)) {
|
||||
auto listPadding = listLayoutProperty_->CreatePaddingAndBorder().Offset();
|
||||
auto offset = layoutWrapper->GetGeometryNode()->GetMarginFrameOffset();
|
||||
bool atStart = GreatNotEqual(GetMainAxisOffset(offset, axis_), GetMainAxisOffset(listPadding, axis_));
|
||||
if (atStart && totalItemCount_ > 0 &&
|
||||
(!layoutedItemInfo_ || layoutedItemInfo_.value().endIndex < totalItemCount_ - 1)) {
|
||||
bool belowList = GreatOrEqual(GetMainAxisOffset(offset, axis_), GetMainAxisOffset(listPadding, axis_));
|
||||
if (belowList && totalItemCount_ > 0 && !layoutedEntirely) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (childrenSize_ && needAdjustRefPos_) {
|
||||
@ -364,6 +364,13 @@ bool ListItemGroupLayoutAlgorithm::NeedMeasureItem(LayoutWrapper* layoutWrapper)
|
||||
refPos_ += (totalMainSize_ - posMap_->GetPrevTotalHeight());
|
||||
}
|
||||
if (GreatNotEqual(headerMainSize_, endPos_ - (referencePos_ - totalMainSize_))) {
|
||||
auto listPadding = GetMainAxisOffset(listLayoutProperty_->CreatePaddingAndBorder().Offset(), axis_);
|
||||
auto offset = GetMainAxisOffset(layoutWrapper->GetGeometryNode()->GetMarginFrameOffset(), axis_);
|
||||
auto groupBottom = offset + totalMainSize_;
|
||||
auto aboveList = LessOrEqual(groupBottom, listPadding);
|
||||
if (aboveList && totalItemCount_ > 0 && !layoutedEntirely) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (LessNotEqual(totalMainSize_ - footerMainSize_, startPos_ - (referencePos_ - totalMainSize_))) {
|
||||
@ -1040,6 +1047,7 @@ void ListItemGroupLayoutAlgorithm::CheckRecycle(
|
||||
if (GreatOrEqual(pos->second.endPos, startPos - referencePos)) {
|
||||
break;
|
||||
}
|
||||
cachedItemPosition_.insert(*pos);
|
||||
pos = itemPosition_.erase(pos);
|
||||
}
|
||||
return;
|
||||
@ -1049,6 +1057,7 @@ void ListItemGroupLayoutAlgorithm::CheckRecycle(
|
||||
if (LessOrEqual(pos->second.startPos, endPos - (referencePos - totalMainSize_))) {
|
||||
break;
|
||||
}
|
||||
cachedItemPosition_.insert(*pos);
|
||||
removeIndexes.emplace_back(pos->first);
|
||||
}
|
||||
for (const auto& index : removeIndexes) {
|
||||
|
@ -89,6 +89,12 @@ public:
|
||||
cachedItemPosition_.clear();
|
||||
}
|
||||
|
||||
void ResetCachedIndex()
|
||||
{
|
||||
forwardCachedIndex_ = -1;
|
||||
backwardCachedIndex_ = INT_MAX;
|
||||
}
|
||||
|
||||
void SetItemsPosition(const PositionMap& itemPosition)
|
||||
{
|
||||
itemPosition_ = itemPosition;
|
||||
|
@ -121,6 +121,13 @@ RefPtr<NodePaintMethod> ListItemGroupPattern::CreateNodePaintMethod()
|
||||
return MakeRefPtr<ListItemGroupPaintMethod>(divider, listItemGroupPaintInfo, itemPosition_, pressedItem_);
|
||||
}
|
||||
|
||||
void ListItemGroupPattern::SyncItemsToCachedItemPosition()
|
||||
{
|
||||
itemPosition_.insert(cachedItemPosition_.begin(), cachedItemPosition_.end());
|
||||
cachedItemPosition_.swap(itemPosition_);
|
||||
itemPosition_.clear();
|
||||
}
|
||||
|
||||
bool ListItemGroupPattern::OnDirtyLayoutWrapperSwap(const RefPtr<LayoutWrapper>& dirty, const DirtySwapConfig& config)
|
||||
{
|
||||
if (config.skipMeasure && config.skipLayout) {
|
||||
@ -142,10 +149,13 @@ bool ListItemGroupPattern::OnDirtyLayoutWrapperSwap(const RefPtr<LayoutWrapper>&
|
||||
layoutAlgorithm->SetCacheParam(std::nullopt);
|
||||
return false;
|
||||
}
|
||||
if (lanes_ != layoutAlgorithm->GetLanes()) {
|
||||
lanes_ = layoutAlgorithm->GetLanes();
|
||||
ClearCachedItemPosition();
|
||||
}
|
||||
itemPosition_ = layoutAlgorithm->GetItemPosition();
|
||||
cachedItemPosition_ = layoutAlgorithm->GetCachedItemPosition();
|
||||
spaceWidth_ = layoutAlgorithm->GetSpaceWidth();
|
||||
lanes_ = layoutAlgorithm->GetLanes();
|
||||
axis_ = layoutAlgorithm->GetAxis();
|
||||
layoutDirection_ = layoutAlgorithm->GetLayoutDirection();
|
||||
mainSize_ = layoutAlgorithm->GetMainSize();
|
||||
@ -430,6 +440,30 @@ void ListItemGroupPattern::UpdateActiveChildRange(bool forward, int32_t cacheCou
|
||||
}
|
||||
}
|
||||
|
||||
void ListItemGroupPattern::UpdateActiveChildRange(bool show)
|
||||
{
|
||||
auto host = GetHost();
|
||||
CHECK_NULL_VOID(host);
|
||||
if (!itemPosition_.empty()) {
|
||||
auto start = itemStartIndex_ + itemPosition_.begin()->first;
|
||||
auto end = itemStartIndex_ + itemPosition_.rbegin()->first;
|
||||
host->SetActiveChildRange(start, end);
|
||||
} else if (headerIndex_ >= 0 || footerIndex_ >= 0) {
|
||||
host->SetActiveChildRange(-1, itemStartIndex_ - 1);
|
||||
} else {
|
||||
host->RemoveAllChildInRenderTree();
|
||||
}
|
||||
if (headerIndex_ >= 0) {
|
||||
host->GetOrCreateChildByIndex(headerIndex_);
|
||||
}
|
||||
if (footerIndex_ >= 0) {
|
||||
host->GetOrCreateChildByIndex(footerIndex_);
|
||||
}
|
||||
if (show) {
|
||||
host->RebuildRenderContextTree();
|
||||
}
|
||||
}
|
||||
|
||||
int32_t ListItemGroupPattern::UpdateCachedIndexForward(bool outOfView, bool show, int32_t cacheCount)
|
||||
{
|
||||
int32_t endIndex = (outOfView || itemPosition_.empty()) ? -1 : itemPosition_.rbegin()->first;
|
||||
@ -519,7 +553,7 @@ std::pair<int32_t, int32_t> ListItemGroupPattern::UpdateCachedIndexOmni(int32_t
|
||||
}
|
||||
|
||||
std::pair<int32_t, int32_t> ListItemGroupPattern::UpdateCachedIndex(
|
||||
bool outOfView, int32_t forwardCache, int32_t backwardCache)
|
||||
bool outOfView, bool reCache, int32_t forwardCache, int32_t backwardCache)
|
||||
{
|
||||
auto host = GetHost();
|
||||
if (!host) {
|
||||
@ -534,6 +568,14 @@ std::pair<int32_t, int32_t> ListItemGroupPattern::UpdateCachedIndex(
|
||||
CalculateItemStartIndex();
|
||||
itemTotalCount_ = host->GetTotalChildCount() - itemStartIndex_;
|
||||
}
|
||||
if (outOfView) {
|
||||
ClearItemPosition();
|
||||
}
|
||||
if (reCache || reCache_) {
|
||||
ClearCachedItemPosition();
|
||||
UpdateActiveChildRange(show);
|
||||
reCache_ = false;
|
||||
}
|
||||
if (forwardCache > -1 && backwardCache > -1 && !itemPosition_.empty()) {
|
||||
auto res = UpdateCachedIndexOmni(forwardCache, backwardCache);
|
||||
forwardCachedIndex_ = res.first;
|
||||
|
@ -298,11 +298,18 @@ public:
|
||||
void ClearCachedItemPosition();
|
||||
void CalculateItemStartIndex();
|
||||
bool NeedCacheForward(const LayoutWrapper* listWrapper) const;
|
||||
std::pair<int32_t, int32_t> UpdateCachedIndex(bool outOfView, int32_t forwardCache, int32_t backwardCache);
|
||||
std::pair<int32_t, int32_t> UpdateCachedIndex(bool outOfView, bool reCache,
|
||||
int32_t forwardCache, int32_t backwardCache);
|
||||
int32_t UpdateCachedIndexForward(bool outOfView, bool show, int32_t cacheCount);
|
||||
int32_t UpdateCachedIndexBackward(bool outOfView, bool show, int32_t cacheCount);
|
||||
std::pair<int32_t, int32_t> UpdateCachedIndexOmni(int32_t forwardCache, int32_t backwardCache);
|
||||
void UpdateActiveChildRange(bool forward, int32_t cacheCount, bool show);
|
||||
void UpdateActiveChildRange(bool show);
|
||||
void SyncItemsToCachedItemPosition();
|
||||
void SetRecache(bool value)
|
||||
{
|
||||
reCache_ = value;
|
||||
}
|
||||
void LayoutCache(const LayoutConstraintF& constraint, int64_t deadline, int32_t forwardCached,
|
||||
int32_t backwardCached, ListMainSizeValues listSizeValues);
|
||||
|
||||
@ -346,6 +353,7 @@ private:
|
||||
std::set<int32_t> pressedItem_;
|
||||
bool layouted_ = false;
|
||||
|
||||
bool reCache_ = false;
|
||||
int32_t backwardCachedIndex_ = INT_MAX;
|
||||
int32_t forwardCachedIndex_ = -1;
|
||||
ListItemGroupLayoutAlgorithm::PositionMap cachedItemPosition_;
|
||||
|
@ -547,93 +547,35 @@ std::list<int32_t> ListLanesLayoutAlgorithm::LayoutCachedItem(LayoutWrapper* lay
|
||||
float crossSize = GetLayoutCrossAxisSize(layoutWrapper);
|
||||
|
||||
auto& itemPosition = GetItemPosition();
|
||||
auto currIndex = itemPosition.rbegin()->first + 1;
|
||||
auto curIndex = itemPosition.rbegin()->first + 1;
|
||||
auto currPos = itemPosition.rbegin()->second.endPos + GetSpaceWidth();
|
||||
for (int32_t i = 0; i < cacheCount && currIndex <= GetMaxListItemIndex(); i++) {
|
||||
auto tmpList = LayoutCachedALineForward(layoutWrapper, currIndex, currPos, crossSize);
|
||||
for (int32_t i = 0; i < cacheCount && curIndex <= GetMaxListItemIndex(); i++) {
|
||||
auto tmpList = LayoutCachedALineForward(layoutWrapper, curIndex, currPos, crossSize);
|
||||
predictBuildList.merge(tmpList);
|
||||
}
|
||||
currIndex = itemPosition.begin()->first - 1;
|
||||
curIndex = itemPosition.begin()->first - 1;
|
||||
currPos = itemPosition.begin()->second.startPos - GetSpaceWidth();
|
||||
for (int32_t i = 0; i < cacheCount && currIndex >= 0; i++) {
|
||||
auto tmpList = LayoutCachedALineBackward(layoutWrapper, currIndex, currPos, crossSize);
|
||||
for (int32_t i = 0; i < cacheCount && curIndex >= 0; i++) {
|
||||
auto tmpList = LayoutCachedALineBackward(layoutWrapper, curIndex, currPos, crossSize);
|
||||
predictBuildList.merge(tmpList);
|
||||
}
|
||||
return predictBuildList;
|
||||
}
|
||||
|
||||
float ListLanesLayoutAlgorithm::GetLayoutCrossAxisSize(LayoutWrapper* layoutWrapper)
|
||||
{
|
||||
auto size = layoutWrapper->GetGeometryNode()->GetFrameSize();
|
||||
auto padding = layoutWrapper->GetLayoutProperty()->CreatePaddingAndBorder();
|
||||
MinusPaddingToSize(padding, size);
|
||||
return GetCrossAxisSize(size, axis_);
|
||||
}
|
||||
|
||||
// return current CachedCount and max CacheCount
|
||||
CachedIndexInfo ListLanesLayoutAlgorithm::GetLayoutGroupCachedCount(LayoutWrapper* layoutWrapper,
|
||||
const RefPtr<LayoutWrapper>& wrapper, int32_t forwardCache, int32_t backwardCache, bool outOfView)
|
||||
{
|
||||
CachedIndexInfo res;
|
||||
auto groupNode = AceType::DynamicCast<FrameNode>(wrapper);
|
||||
CHECK_NULL_RETURN(groupNode, res);
|
||||
auto groupPattern = groupNode->GetPattern<ListItemGroupPattern>();
|
||||
CHECK_NULL_RETURN(groupPattern, res);
|
||||
const auto& itemPos = groupPattern->GetItemPosition();
|
||||
int32_t itemCount = groupPattern->GetTotalItemCount();
|
||||
groupPattern->SetLanes(lanes_);
|
||||
int32_t lanes = groupPattern->GetLanesInGroup();
|
||||
lanes = lanes > 1 ? lanes : 1;
|
||||
bool forward = forwardCache > -1;
|
||||
bool backward = backwardCache > -1;
|
||||
if (groupNode->CheckNeedForceMeasureAndLayout()) {
|
||||
groupPattern->CalculateItemStartIndex();
|
||||
itemCount = groupNode->GetTotalChildCount() - groupPattern->GetItemStartIndex();
|
||||
}
|
||||
if (forward && backward && itemPos.empty()) {
|
||||
forward = groupPattern->NeedCacheForward(layoutWrapper);
|
||||
backward = !forward;
|
||||
forwardCache = forward ? forwardCache : -1;
|
||||
backwardCache = backward ? backwardCache : -1;
|
||||
}
|
||||
if (forward && backward) {
|
||||
auto [forwardIndex, backwardIndex] = groupPattern->UpdateCachedIndex(outOfView, forwardCache, backwardCache);
|
||||
auto startIndex = itemPos.begin()->first;
|
||||
auto endIndex = itemPos.rbegin()->first;
|
||||
res.forwardCachedCount = (int)(std::ceil((double)(forwardIndex - endIndex) / lanes));
|
||||
res.forwardCacheMax = (int)(std::ceil((double)(itemCount - 1 - endIndex) / lanes));
|
||||
res.backwardCachedCount = (int)(std::ceil((double)(startIndex - backwardIndex) / lanes));
|
||||
res.backwardCacheMax = (int)(std::ceil((double)startIndex / lanes));
|
||||
} else if (forward) {
|
||||
auto [forwardIndex, backwardIndex] = groupPattern->UpdateCachedIndex(outOfView, forwardCache, backwardCache);
|
||||
int32_t endIndex = (outOfView || itemPos.empty()) ? -1 : itemPos.rbegin()->first;
|
||||
res.forwardCachedCount = (int)(std::ceil((double)(forwardIndex - endIndex) / lanes));
|
||||
res.forwardCacheMax = (int)(std::ceil((double)(itemCount - 1 - endIndex) / lanes));
|
||||
} else {
|
||||
auto [forwardIndex, backwardIndex] = groupPattern->UpdateCachedIndex(outOfView, forwardCache, backwardCache);
|
||||
int32_t startIndex = (outOfView || itemPos.empty()) ? itemCount : itemPos.begin()->first;
|
||||
res.backwardCachedCount = (int)(std::ceil((double)(startIndex - backwardIndex) / lanes));
|
||||
res.backwardCacheMax = (int)(std::ceil((double)startIndex / lanes));
|
||||
}
|
||||
ACE_SCOPED_TRACE("GetLayoutGroupCachedCount forward:%d, %d, backward:%d, %d",
|
||||
res.forwardCachedCount, res.forwardCacheMax, res.backwardCachedCount, res.backwardCacheMax);
|
||||
return res;
|
||||
}
|
||||
|
||||
int32_t ListLanesLayoutAlgorithm::LayoutCachedForward(LayoutWrapper* layoutWrapper,
|
||||
int32_t cacheCount, int32_t& cachedCount, int32_t& currIndex)
|
||||
int32_t cacheCount, int32_t& cachedCount, int32_t& curIndex)
|
||||
{
|
||||
float crossSize = GetLayoutCrossAxisSize(layoutWrapper);
|
||||
RefPtr<LayoutWrapper> wrapper;
|
||||
currIndex = GetItemPosition().rbegin()->first + 1;
|
||||
curIndex = GetItemPosition().rbegin()->first + 1;
|
||||
auto startPos = GetItemPosition().rbegin()->second.endPos + GetSpaceWidth();
|
||||
while (cachedCount < cacheCount && currIndex <= GetMaxListItemIndex()) {
|
||||
while (cachedCount < cacheCount && curIndex <= GetMaxListItemIndex()) {
|
||||
ListLayoutAlgorithm::PositionMap posMap;
|
||||
float mainLen = 0.0f;
|
||||
bool isGroup = false;
|
||||
int32_t cnt = 0;
|
||||
for (int32_t i = 0; i < lanes_ && currIndex + i <= GetMaxListItemIndex() && !isGroup; i++) {
|
||||
wrapper = layoutWrapper->GetChildByIndex(currIndex + i, true);
|
||||
for (int32_t i = 0; i < lanes_ && curIndex + i <= GetMaxListItemIndex() && !isGroup; i++) {
|
||||
wrapper = layoutWrapper->GetChildByIndex(curIndex + i, true);
|
||||
if (!wrapper) {
|
||||
cacheCount = -1;
|
||||
break;
|
||||
@ -649,43 +591,43 @@ int32_t ListLanesLayoutAlgorithm::LayoutCachedForward(LayoutWrapper* layoutWrapp
|
||||
}
|
||||
cnt++;
|
||||
mainLen = std::max(mainLen, GetMainAxisSize(wrapper->GetGeometryNode()->GetMarginFrameSize(), axis_));
|
||||
auto id = wrapper->GetHostNode()->GetId();
|
||||
posMap[currIndex + i] = { id, startPos, startPos + mainLen, isGroup };
|
||||
posMap[curIndex + i] = { wrapper->GetHostNode()->GetId(), startPos, startPos + mainLen, isGroup };
|
||||
}
|
||||
auto startIndex = currIndex;
|
||||
for (auto& pos : posMap) {
|
||||
pos.second.endPos = startPos + mainLen;
|
||||
LayoutCachedALine(layoutWrapper, pos, startIndex, crossSize);
|
||||
}
|
||||
startPos = startPos + mainLen + GetSpaceWidth();
|
||||
auto startIndex = curIndex;
|
||||
if (isGroup) {
|
||||
auto res = GetLayoutGroupCachedCount(layoutWrapper, wrapper, cacheCount - cachedCount, -1, true);
|
||||
auto res = GetLayoutGroupCachedCount(layoutWrapper, wrapper, cacheCount - cachedCount, -1, curIndex, true);
|
||||
if (res.forwardCachedCount < res.forwardCacheMax && res.forwardCachedCount < cacheCount - cachedCount) {
|
||||
LayoutItem(wrapper, posMap.begin()->first, posMap.begin()->second, startIndex, crossSize);
|
||||
return res.forwardCachedCount;
|
||||
}
|
||||
cachedCount += std::max(res.forwardCacheMax, 1);
|
||||
} else if (cnt > 0) {
|
||||
cachedCount++;
|
||||
}
|
||||
currIndex += cnt;
|
||||
for (auto& pos : posMap) {
|
||||
pos.second.endPos = startPos + mainLen;
|
||||
LayoutCachedALine(layoutWrapper, pos, startIndex, crossSize);
|
||||
}
|
||||
startPos = startPos + mainLen + GetSpaceWidth();
|
||||
curIndex += cnt;
|
||||
}
|
||||
return cacheCount < 0 ? 0 : -1;
|
||||
}
|
||||
|
||||
int32_t ListLanesLayoutAlgorithm::LayoutCachedBackward(LayoutWrapper* layoutWrapper,
|
||||
int32_t cacheCount, int32_t& cachedCount, int32_t& currIndex)
|
||||
int32_t cacheCount, int32_t& cachedCount, int32_t& curIndex)
|
||||
{
|
||||
float crossSize = GetLayoutCrossAxisSize(layoutWrapper);
|
||||
RefPtr<LayoutWrapper> wrapper;
|
||||
currIndex = GetItemPosition().begin()->first - 1;
|
||||
curIndex = GetItemPosition().begin()->first - 1;
|
||||
auto endPos = GetItemPosition().begin()->second.startPos - GetSpaceWidth();
|
||||
while (cachedCount < cacheCount && currIndex >= 0) {
|
||||
while (cachedCount < cacheCount && curIndex >= 0) {
|
||||
ListLayoutAlgorithm::PositionMap posMap;
|
||||
float mainLen = 0.0f;
|
||||
bool isGroup = false;
|
||||
int32_t cnt = 0;
|
||||
for (int32_t i = 0; i < lanes_ && currIndex - i >= 0; i++) {
|
||||
auto idx = currIndex - i;
|
||||
for (int32_t i = 0; i < lanes_ && curIndex - i >= 0; i++) {
|
||||
auto idx = curIndex - i;
|
||||
wrapper = layoutWrapper->GetChildByIndex(idx, true);
|
||||
if (!wrapper) {
|
||||
cacheCount = -1;
|
||||
@ -707,22 +649,23 @@ int32_t ListLanesLayoutAlgorithm::LayoutCachedBackward(LayoutWrapper* layoutWrap
|
||||
break;
|
||||
}
|
||||
}
|
||||
auto startIndex = currIndex - cnt + 1;
|
||||
for (auto& pos: posMap) {
|
||||
pos.second.startPos = endPos - mainLen;
|
||||
LayoutCachedALine(layoutWrapper, pos, startIndex, crossSize);
|
||||
}
|
||||
endPos = endPos - mainLen - GetSpaceWidth();
|
||||
auto startIndex = curIndex - cnt + 1;
|
||||
if (isGroup) {
|
||||
auto res = GetLayoutGroupCachedCount(layoutWrapper, wrapper, -1, cacheCount - cachedCount, true);
|
||||
auto res = GetLayoutGroupCachedCount(layoutWrapper, wrapper, -1, cacheCount - cachedCount, curIndex, true);
|
||||
if (res.backwardCachedCount < res.backwardCacheMax && res.backwardCachedCount < cacheCount - cachedCount) {
|
||||
LayoutItem(wrapper, posMap.begin()->first, posMap.begin()->second, startIndex, crossSize);
|
||||
return res.backwardCachedCount;
|
||||
}
|
||||
cachedCount += std::max(res.backwardCacheMax, 1);
|
||||
} else if (cnt > 0) {
|
||||
cachedCount++;
|
||||
}
|
||||
currIndex -= cnt;
|
||||
for (auto& pos: posMap) {
|
||||
pos.second.startPos = endPos - mainLen;
|
||||
LayoutCachedALine(layoutWrapper, pos, startIndex, crossSize);
|
||||
}
|
||||
endPos = endPos - mainLen - GetSpaceWidth();
|
||||
curIndex -= cnt;
|
||||
}
|
||||
return cacheCount < 0 ? 0 : -1;
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
static int32_t CalculateLanesParam(std::optional<float>& minLaneLength, std::optional<float>& maxLaneLength,
|
||||
int32_t lanes, std::optional<float> crossSizeOptional, float laneGutter = 0.0f);
|
||||
|
||||
LayoutConstraintF& GetGroupLayoutConstraint() override
|
||||
const LayoutConstraintF& GetGroupLayoutConstraint() const override
|
||||
{
|
||||
return groupLayoutConstraint_;
|
||||
}
|
||||
@ -76,13 +76,10 @@ private:
|
||||
LayoutWrapper* layoutWrapper, int32_t& index, float& endPos, float crossSize);
|
||||
void LayoutCachedALine(LayoutWrapper* layoutWrapper, std::pair<const int, ListItemInfo>& pos,
|
||||
int32_t startIndex, float crossSize);
|
||||
float GetLayoutCrossAxisSize(LayoutWrapper* layoutWrapper);
|
||||
int32_t LayoutCachedForward(LayoutWrapper* layoutWrapper,
|
||||
int32_t cacheCount, int32_t& cachedCount, int32_t& currIndex) override;
|
||||
int32_t cacheCount, int32_t& cachedCount, int32_t& curIndex) override;
|
||||
int32_t LayoutCachedBackward(LayoutWrapper* layoutWrapper,
|
||||
int32_t cacheCount, int32_t& cachedCount, int32_t& currIndex) override;
|
||||
CachedIndexInfo GetLayoutGroupCachedCount(LayoutWrapper* layoutWrapper,
|
||||
const RefPtr<LayoutWrapper>& wrapper, int32_t forwardCache, int32_t backwardCache, bool outOfView) override;
|
||||
int32_t cacheCount, int32_t& cachedCount, int32_t& curIndex) override;
|
||||
static int32_t FindLanesStartIndex(LayoutWrapper* layoutWrapper, int32_t startIndex, int32_t index);
|
||||
static int32_t GetLazyForEachIndex(const RefPtr<FrameNode>& host);
|
||||
void MeasureGroup(LayoutWrapper* listWrapper, const RefPtr<LayoutWrapper>& groupWrapper,
|
||||
|
@ -214,7 +214,8 @@ bool ListLayoutAlgorithm::CheckNeedMeasure(const RefPtr<LayoutWrapper>& layoutWr
|
||||
CHECK_NULL_RETURN(geometryNode, true);
|
||||
auto constraint = geometryNode->GetParentLayoutConstraint();
|
||||
CHECK_NULL_RETURN(constraint, true);
|
||||
return constraint.value() != childLayoutConstraint_;
|
||||
bool isGroup = layoutWrapper->GetHostTag() == V2::LIST_ITEM_GROUP_ETS_TAG;
|
||||
return isGroup ? constraint.value() != GetGroupLayoutConstraint() : constraint.value() != childLayoutConstraint_;
|
||||
}
|
||||
|
||||
float ListLayoutAlgorithm::GetChildMaxCrossSize(LayoutWrapper* layoutWrapper, Axis axis) const
|
||||
@ -1085,12 +1086,6 @@ void ListLayoutAlgorithm::LayoutForward(LayoutWrapper* layoutWrapper, int32_t st
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (pos->second.isGroup) {
|
||||
auto wrapper = layoutWrapper->GetOrCreateChildByIndex(pos->first);
|
||||
if (wrapper && wrapper->GetHostNode() && wrapper->GetHostNode()->GetPattern<ListItemGroupPattern>()) {
|
||||
wrapper->GetHostNode()->GetPattern<ListItemGroupPattern>()->ClearItemPosition();
|
||||
}
|
||||
}
|
||||
recycledItemPosition_.emplace(pos->first, pos->second);
|
||||
pos = itemPosition_.erase(pos);
|
||||
}
|
||||
@ -1159,12 +1154,6 @@ void ListLayoutAlgorithm::LayoutBackward(LayoutWrapper* layoutWrapper, int32_t e
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (pos->second.isGroup) {
|
||||
auto wrapper = layoutWrapper->GetOrCreateChildByIndex(pos->first);
|
||||
if (wrapper && wrapper->GetHostNode() && wrapper->GetHostNode()->GetPattern<ListItemGroupPattern>()) {
|
||||
wrapper->GetHostNode()->GetPattern<ListItemGroupPattern>()->ClearItemPosition();
|
||||
}
|
||||
}
|
||||
recycledItemPosition_.emplace(pos->first, pos->second);
|
||||
removeIndexes.emplace_back(pos->first);
|
||||
}
|
||||
@ -1431,6 +1420,7 @@ void ListLayoutAlgorithm::ProcessCacheCount(LayoutWrapper* layoutWrapper, int32_
|
||||
pattern->SetPredictLayoutParamV2(std::nullopt);
|
||||
}
|
||||
} else {
|
||||
ResetLayoutItem(layoutWrapper);
|
||||
SetActiveChildRange(layoutWrapper, cacheCount, cacheCount, show);
|
||||
}
|
||||
}
|
||||
@ -1454,6 +1444,10 @@ void ListLayoutAlgorithm::ResetLayoutItem(LayoutWrapper* layoutWrapper)
|
||||
pos.second.endPos -= currentOffset_;
|
||||
if (pos.second.isGroup) {
|
||||
pos.second.groupInfo = GetListItemGroupLayoutInfo(wrapper);
|
||||
if (wrapper && wrapper->GetHostNode() && wrapper->GetHostNode()->GetPattern<ListItemGroupPattern>()) {
|
||||
auto groupPattern = wrapper->GetHostNode()->GetPattern<ListItemGroupPattern>();
|
||||
groupPattern->ClearItemPosition();
|
||||
}
|
||||
} else {
|
||||
pos.second.groupInfo.reset();
|
||||
}
|
||||
@ -1505,7 +1499,6 @@ void ListLayoutAlgorithm::Layout(LayoutWrapper* layoutWrapper)
|
||||
frameNode->MarkAndCheckNewOpIncNode();
|
||||
}
|
||||
}
|
||||
ResetLayoutItem(layoutWrapper);
|
||||
ProcessCacheCount(layoutWrapper, listProps->GetCachedCountValue(1), listProps->GetShowCachedItemsValue(false));
|
||||
UpdateOverlay(layoutWrapper);
|
||||
}
|
||||
@ -1641,6 +1634,14 @@ void ListLayoutAlgorithm::SetListItemGroupParam(const RefPtr<LayoutWrapper>& lay
|
||||
} else if (forwardFeature_ || backwardFeature_) {
|
||||
itemGroup->CheckNeedAllLayout(layoutWrapper, forwardLayout);
|
||||
}
|
||||
if (CheckNeedMeasure(layoutWrapper)) {
|
||||
itemGroup->ResetCachedItemPosition();
|
||||
itemGroup->ResetCachedIndex();
|
||||
if (layoutWrapper->GetHostNode() && layoutWrapper->GetHostNode()->GetPattern<ListItemGroupPattern>()) {
|
||||
auto groupPattern = layoutWrapper->GetHostNode()->GetPattern<ListItemGroupPattern>();
|
||||
groupPattern->SetRecache(true);
|
||||
}
|
||||
}
|
||||
layoutWrapper->GetLayoutProperty()->UpdatePropertyChangeFlag(PROPERTY_UPDATE_MEASURE_SELF);
|
||||
}
|
||||
|
||||
@ -1889,60 +1890,78 @@ void ListLayoutAlgorithm::PostIdleTask(RefPtr<FrameNode> frameNode, const ListPr
|
||||
|
||||
// return current CachedCount and max CacheCount
|
||||
CachedIndexInfo ListLayoutAlgorithm::GetLayoutGroupCachedCount(LayoutWrapper* layoutWrapper,
|
||||
const RefPtr<LayoutWrapper>& wrapper, int32_t forwardCache, int32_t backwardCache, bool outOfView)
|
||||
const RefPtr<LayoutWrapper>& wrapper, int32_t forwardCache, int32_t backwardCache, int32_t index, bool outOfView)
|
||||
{
|
||||
CachedIndexInfo res;
|
||||
auto groupNode = AceType::DynamicCast<FrameNode>(wrapper);
|
||||
CHECK_NULL_RETURN(groupNode, res);
|
||||
auto groupPattern = groupNode->GetPattern<ListItemGroupPattern>();
|
||||
CHECK_NULL_RETURN(groupPattern, res);
|
||||
const auto& itemPos = groupPattern->GetItemPosition();
|
||||
int32_t itemCount = groupPattern->GetTotalItemCount();
|
||||
auto group = groupNode->GetPattern<ListItemGroupPattern>();
|
||||
CHECK_NULL_RETURN(group, res);
|
||||
const auto& itemPos = group->GetItemPosition();
|
||||
int32_t lanes = group->GetLanesInGroup();
|
||||
bool reCache = lanes != GetLanes();
|
||||
lanes = GetLanes() > 1 ? GetLanes() : 1;
|
||||
group->SetLanes(lanes);
|
||||
if (outOfView && recycledItemPosition_.count(index) == 0) {
|
||||
reCache = reCache || CheckNeedMeasure(wrapper);
|
||||
} else if (outOfView) {
|
||||
wrapper->SetActive(true);
|
||||
wrapper->Layout();
|
||||
group->SyncItemsToCachedItemPosition();
|
||||
}
|
||||
int32_t itemCount = group->GetTotalItemCount();
|
||||
bool forward = forwardCache > -1;
|
||||
bool backward = backwardCache > -1;
|
||||
if (groupNode->CheckNeedForceMeasureAndLayout()) {
|
||||
groupPattern->CalculateItemStartIndex();
|
||||
itemCount = groupNode->GetTotalChildCount() - groupPattern->GetItemStartIndex();
|
||||
group->CalculateItemStartIndex();
|
||||
itemCount = groupNode->GetTotalChildCount() - group->GetItemStartIndex();
|
||||
}
|
||||
if (forward && backward && itemPos.empty()) {
|
||||
forward = groupPattern->NeedCacheForward(layoutWrapper);
|
||||
forward = group->NeedCacheForward(layoutWrapper);
|
||||
backward = !forward;
|
||||
forwardCache = forward ? forwardCache : -1;
|
||||
backwardCache = backward ? backwardCache : -1;
|
||||
}
|
||||
if (forward && backward) {
|
||||
auto [forwardIndex, backwardIndex] = groupPattern->UpdateCachedIndex(outOfView, forwardCache, backwardCache);
|
||||
auto [forwardIndex, backwardIndex] = group->UpdateCachedIndex(outOfView, reCache, forwardCache, backwardCache);
|
||||
auto startIndex = itemPos.begin()->first;
|
||||
auto endIndex = itemPos.rbegin()->first;
|
||||
res.forwardCachedCount = forwardIndex - endIndex;
|
||||
res.forwardCacheMax = itemCount - 1 - endIndex;
|
||||
res.backwardCachedCount = startIndex - backwardIndex;
|
||||
res.backwardCacheMax = startIndex;
|
||||
res.forwardCachedCount = (int)(std::ceil((double)(forwardIndex - endIndex) / lanes));
|
||||
res.forwardCacheMax = (int)(std::ceil((double)(itemCount - 1 - endIndex) / lanes));
|
||||
res.backwardCachedCount = (int)(std::ceil((double)(startIndex - backwardIndex) / lanes));
|
||||
res.backwardCacheMax = (int)(std::ceil((double)startIndex / lanes));
|
||||
} else if (forward) {
|
||||
auto [forwardIndex, backwardIndex] = groupPattern->UpdateCachedIndex(outOfView, forwardCache, backwardCache);
|
||||
auto [forwardIndex, backwardIndex] = group->UpdateCachedIndex(outOfView, reCache, forwardCache, backwardCache);
|
||||
int32_t endIndex = (outOfView || itemPos.empty()) ? -1 : itemPos.rbegin()->first;
|
||||
res.forwardCachedCount = forwardIndex - endIndex;
|
||||
res.forwardCacheMax = itemCount - 1 - endIndex;
|
||||
res.forwardCachedCount = (int)(std::ceil((double)(forwardIndex - endIndex) / lanes));
|
||||
res.forwardCacheMax = (int)(std::ceil((double)(itemCount - 1 - endIndex) / lanes));
|
||||
} else {
|
||||
auto [forwardIndex, backwardIndex] = groupPattern->UpdateCachedIndex(outOfView, forwardCache, backwardCache);
|
||||
auto [forwardIndex, backwardIndex] = group->UpdateCachedIndex(outOfView, reCache, forwardCache, backwardCache);
|
||||
int32_t startIndex = (outOfView || itemPos.empty()) ? itemCount : itemPos.begin()->first;
|
||||
res.backwardCachedCount = startIndex - backwardIndex;
|
||||
res.backwardCacheMax = startIndex;
|
||||
res.backwardCachedCount = (int)(std::ceil((double)(startIndex - backwardIndex) / lanes));
|
||||
res.backwardCacheMax = (int)(std::ceil((double)startIndex / lanes));
|
||||
}
|
||||
ACE_SCOPED_TRACE("GetLayoutGroupCachedCount forward:%d, %d, backward:%d, %d",
|
||||
res.forwardCachedCount, res.forwardCacheMax, res.backwardCachedCount, res.backwardCacheMax);
|
||||
return res;
|
||||
}
|
||||
|
||||
int32_t ListLayoutAlgorithm::LayoutCachedForward(LayoutWrapper* layoutWrapper,
|
||||
int32_t cacheCount, int32_t& cachedCount, int32_t& currIndex)
|
||||
float ListLayoutAlgorithm::GetLayoutCrossAxisSize(LayoutWrapper* layoutWrapper)
|
||||
{
|
||||
auto size = layoutWrapper->GetGeometryNode()->GetFrameSize();
|
||||
float crossSize = GetCrossAxisSize(size, axis_);
|
||||
currIndex = itemPosition_.rbegin()->first + 1;
|
||||
auto padding = layoutWrapper->GetLayoutProperty()->CreatePaddingAndBorder();
|
||||
MinusPaddingToSize(padding, size);
|
||||
return GetCrossAxisSize(size, axis_);
|
||||
}
|
||||
|
||||
int32_t ListLayoutAlgorithm::LayoutCachedForward(LayoutWrapper* layoutWrapper,
|
||||
int32_t cacheCount, int32_t& cachedCount, int32_t& curIndex)
|
||||
{
|
||||
float crossSize = GetLayoutCrossAxisSize(layoutWrapper);
|
||||
curIndex = itemPosition_.rbegin()->first + 1;
|
||||
auto currPos = itemPosition_.rbegin()->second.endPos + spaceWidth_;
|
||||
while (cachedCount < cacheCount && currIndex < totalItemCount_) {
|
||||
auto wrapper = layoutWrapper->GetChildByIndex(currIndex, true);
|
||||
while (cachedCount < cacheCount && curIndex < totalItemCount_) {
|
||||
auto wrapper = layoutWrapper->GetChildByIndex(curIndex, true);
|
||||
if (!wrapper) {
|
||||
return 0;
|
||||
}
|
||||
@ -1955,10 +1974,11 @@ int32_t ListLayoutAlgorithm::LayoutCachedForward(LayoutWrapper* layoutWrapper,
|
||||
int32_t id = wrapper->GetHostNode()->GetId();
|
||||
ListItemInfo pos = { id, currPos, endPos, isGroup };
|
||||
currPos = endPos + spaceWidth_;
|
||||
auto startIndex = currIndex;
|
||||
LayoutItem(wrapper, currIndex, pos, startIndex, crossSize);
|
||||
auto startIndex = curIndex;
|
||||
LayoutItem(wrapper, curIndex, pos, startIndex, crossSize);
|
||||
if (isGroup) {
|
||||
auto res = GetLayoutGroupCachedCount(layoutWrapper, wrapper, cacheCount - cachedCount, -1, true);
|
||||
auto res = GetLayoutGroupCachedCount(
|
||||
layoutWrapper, wrapper, cacheCount - cachedCount, -1, curIndex, true);
|
||||
if (res.forwardCachedCount < res.forwardCacheMax && res.forwardCachedCount < cacheCount - cachedCount) {
|
||||
return res.forwardCachedCount;
|
||||
}
|
||||
@ -1968,20 +1988,19 @@ int32_t ListLayoutAlgorithm::LayoutCachedForward(LayoutWrapper* layoutWrapper,
|
||||
}
|
||||
SyncGeometry(wrapper);
|
||||
wrapper->SetActive(false);
|
||||
currIndex++;
|
||||
curIndex++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t ListLayoutAlgorithm::LayoutCachedBackward(LayoutWrapper* layoutWrapper,
|
||||
int32_t cacheCount, int32_t& cachedCount, int32_t& currIndex)
|
||||
int32_t cacheCount, int32_t& cachedCount, int32_t& curIndex)
|
||||
{
|
||||
auto size = layoutWrapper->GetGeometryNode()->GetFrameSize();
|
||||
float crossSize = GetCrossAxisSize(size, axis_);
|
||||
currIndex = itemPosition_.begin()->first - 1;
|
||||
float crossSize = GetLayoutCrossAxisSize(layoutWrapper);
|
||||
curIndex = itemPosition_.begin()->first - 1;
|
||||
auto currPos = itemPosition_.begin()->second.startPos - spaceWidth_;
|
||||
while (cachedCount < cacheCount && currIndex >= 0) {
|
||||
auto wrapper = layoutWrapper->GetChildByIndex(currIndex, true);
|
||||
while (cachedCount < cacheCount && curIndex >= 0) {
|
||||
auto wrapper = layoutWrapper->GetChildByIndex(curIndex, true);
|
||||
if (!wrapper) {
|
||||
return 0;
|
||||
}
|
||||
@ -1994,10 +2013,11 @@ int32_t ListLayoutAlgorithm::LayoutCachedBackward(LayoutWrapper* layoutWrapper,
|
||||
int32_t id = wrapper->GetHostNode()->GetId();
|
||||
ListItemInfo pos = { id, startPos, currPos, isGroup };
|
||||
currPos = startPos - spaceWidth_;
|
||||
auto startIndex = currIndex;
|
||||
LayoutItem(wrapper, currIndex, pos, startIndex, crossSize);
|
||||
auto startIndex = curIndex;
|
||||
LayoutItem(wrapper, curIndex, pos, startIndex, crossSize);
|
||||
if (isGroup) {
|
||||
auto res = GetLayoutGroupCachedCount(layoutWrapper, wrapper, -1, cacheCount - cachedCount, true);
|
||||
auto res = GetLayoutGroupCachedCount(
|
||||
layoutWrapper, wrapper, -1, cacheCount - cachedCount, curIndex, true);
|
||||
if (res.backwardCachedCount < res.backwardCacheMax && res.backwardCachedCount < cacheCount - cachedCount) {
|
||||
return res.backwardCachedCount;
|
||||
}
|
||||
@ -2007,7 +2027,7 @@ int32_t ListLayoutAlgorithm::LayoutCachedBackward(LayoutWrapper* layoutWrapper,
|
||||
}
|
||||
SyncGeometry(wrapper);
|
||||
wrapper->SetActive(false);
|
||||
currIndex--;
|
||||
curIndex--;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@ -2021,7 +2041,7 @@ std::tuple<int32_t, int32_t, int32_t, int32_t> ListLayoutAlgorithm::LayoutCached
|
||||
int32_t cachedBackward = 0;
|
||||
if (startIndex == endIndex && itemPosition_.begin()->second.isGroup) {
|
||||
auto wrapper = layoutWrapper->GetChildByIndex(startIndex);
|
||||
auto res = GetLayoutGroupCachedCount(layoutWrapper, wrapper, cacheCount, cacheCount, false);
|
||||
auto res = GetLayoutGroupCachedCount(layoutWrapper, wrapper, cacheCount, cacheCount, startIndex, false);
|
||||
if ((res.forwardCachedCount < res.forwardCacheMax && res.forwardCachedCount < cacheCount) ||
|
||||
(res.backwardCachedCount < res.backwardCacheMax && res.backwardCachedCount < cacheCount)) {
|
||||
predictList.emplace_back(PredictLayoutItem { startIndex, cachedForward, cachedBackward });
|
||||
@ -2031,7 +2051,7 @@ std::tuple<int32_t, int32_t, int32_t, int32_t> ListLayoutAlgorithm::LayoutCached
|
||||
} else {
|
||||
if (itemPosition_.rbegin()->second.isGroup) {
|
||||
auto wrapper = layoutWrapper->GetChildByIndex(endIndex);
|
||||
auto res = GetLayoutGroupCachedCount(layoutWrapper, wrapper, cacheCount, -1, false);
|
||||
auto res = GetLayoutGroupCachedCount(layoutWrapper, wrapper, cacheCount, -1, endIndex, false);
|
||||
if (res.forwardCachedCount < res.forwardCacheMax && res.forwardCachedCount < cacheCount) {
|
||||
predictList.emplace_back(PredictLayoutItem { endIndex, cachedForward, -1 });
|
||||
}
|
||||
@ -2039,7 +2059,7 @@ std::tuple<int32_t, int32_t, int32_t, int32_t> ListLayoutAlgorithm::LayoutCached
|
||||
}
|
||||
if (itemPosition_.begin()->second.isGroup) {
|
||||
auto wrapper = layoutWrapper->GetChildByIndex(startIndex);
|
||||
auto res = GetLayoutGroupCachedCount(layoutWrapper, wrapper, -1, cacheCount, false);
|
||||
auto res = GetLayoutGroupCachedCount(layoutWrapper, wrapper, -1, cacheCount, startIndex, false);
|
||||
if (res.backwardCachedCount < res.backwardCacheMax && res.backwardCachedCount < cacheCount) {
|
||||
predictList.emplace_back(PredictLayoutItem { startIndex, -1, cachedBackward });
|
||||
}
|
||||
@ -2076,6 +2096,7 @@ std::list<PredictLayoutItem> ListLayoutAlgorithm::LayoutCachedItemV2(LayoutWrapp
|
||||
}
|
||||
int32_t cacheStart = itemPosition_.begin()->first - startIndex;
|
||||
int32_t cacheEnd = endIndex - itemPosition_.rbegin()->first;
|
||||
ResetLayoutItem(layoutWrapper);
|
||||
SetActiveChildRange(layoutWrapper, cacheStart, cacheEnd, show);
|
||||
return predictBuildList;
|
||||
}
|
||||
|
@ -389,7 +389,7 @@ public:
|
||||
const RefPtr<ListLayoutProperty>& layoutProperty, int32_t indexInGroup, int32_t judgeIndex,
|
||||
int32_t startIndex, int32_t endIndex);
|
||||
|
||||
virtual LayoutConstraintF& GetGroupLayoutConstraint()
|
||||
virtual const LayoutConstraintF& GetGroupLayoutConstraint() const
|
||||
{
|
||||
return childLayoutConstraint_;
|
||||
}
|
||||
@ -453,9 +453,10 @@ protected:
|
||||
ListItemInfo GetListItemGroupPosition(const RefPtr<LayoutWrapper>& layoutWrapper, int32_t index);
|
||||
bool CheckNeedMeasure(const RefPtr<LayoutWrapper>& layoutWrapper) const;
|
||||
void ReviseSpace(const RefPtr<ListLayoutProperty>& listLayoutProperty);
|
||||
virtual CachedIndexInfo GetLayoutGroupCachedCount(LayoutWrapper* layoutWrapper,
|
||||
const RefPtr<LayoutWrapper>& wrapper, int32_t forwardCache, int32_t backwardCache, bool outOfView);
|
||||
CachedIndexInfo GetLayoutGroupCachedCount(LayoutWrapper* layoutWrapper, const RefPtr<LayoutWrapper>& wrapper,
|
||||
int32_t forwardCache, int32_t backwardCache, int32_t index, bool outOfView);
|
||||
void AdjustStartPosition(const RefPtr<LayoutWrapper>& layoutWrapper, float& startPos);
|
||||
float GetLayoutCrossAxisSize(LayoutWrapper* layoutWrapper);
|
||||
|
||||
Axis axis_ = Axis::VERTICAL;
|
||||
LayoutConstraintF childLayoutConstraint_;
|
||||
@ -490,9 +491,9 @@ private:
|
||||
|
||||
void ProcessCacheCount(LayoutWrapper* layoutWrapper, int32_t cacheCount, bool show);
|
||||
virtual int32_t LayoutCachedForward(LayoutWrapper* layoutWrapper,
|
||||
int32_t cacheCount, int32_t& cachedCount, int32_t& currIndex);
|
||||
int32_t cacheCount, int32_t& cachedCount, int32_t& curIndex);
|
||||
virtual int32_t LayoutCachedBackward(LayoutWrapper* layoutWrapper,
|
||||
int32_t cacheCount, int32_t& cachedCount, int32_t& currIndex);
|
||||
int32_t cacheCount, int32_t& cachedCount, int32_t& curIndex);
|
||||
std::list<PredictLayoutItem> LayoutCachedItemV2(LayoutWrapper* layoutWrapper, int32_t cacheCount, bool show);
|
||||
std::tuple<int32_t, int32_t, int32_t, int32_t> LayoutCachedItemInEdgeGroup(LayoutWrapper* layoutWrapper,
|
||||
int32_t cacheCount, std::list<PredictLayoutItem>& predictList);
|
||||
|
@ -63,7 +63,7 @@ void ListPattern::OnModifyDone()
|
||||
auto scrollableEvent = GetScrollableEvent();
|
||||
CHECK_NULL_VOID(scrollableEvent);
|
||||
scrollable_ = scrollableEvent->GetScrollable();
|
||||
scrollable_->SetSnapMode(true);
|
||||
scrollable_->SetIsList(true);
|
||||
}
|
||||
|
||||
SetEdgeEffect();
|
||||
@ -919,7 +919,8 @@ bool ListPattern::OnScrollCallback(float offset, int32_t source)
|
||||
return UpdateCurrentOffset(offset, source);
|
||||
}
|
||||
|
||||
bool ListPattern::StartSnapAnimation(float snapDelta, float snapVelocity, float dragDistance)
|
||||
bool ListPattern::StartSnapAnimation(
|
||||
float snapDelta, float animationVelocity, float predictVelocity, float dragDistance)
|
||||
{
|
||||
auto listProperty = GetLayoutProperty<ListLayoutProperty>();
|
||||
CHECK_NULL_RETURN(listProperty, false);
|
||||
@ -934,7 +935,7 @@ bool ListPattern::StartSnapAnimation(float snapDelta, float snapVelocity, float
|
||||
snapTrigOnScrollStart_ = true;
|
||||
}
|
||||
predictSnapOffset_ = snapDelta;
|
||||
scrollSnapVelocity_ = snapVelocity;
|
||||
scrollSnapVelocity_ = animationVelocity;
|
||||
MarkDirtyNodeSelf();
|
||||
return true;
|
||||
}
|
||||
|
@ -271,7 +271,8 @@ public:
|
||||
predictSnapOffset_ = predictSnapOffset;
|
||||
}
|
||||
|
||||
bool StartSnapAnimation(float snapDelta, float snapVelocity, float dragDistance = 0.f) override;
|
||||
bool StartSnapAnimation(
|
||||
float snapDelta, float animationVelocity, float predictVelocity = 0.f, float dragDistance = 0.f) override;
|
||||
|
||||
void StartListSnapAnimation(float scrollSnapDelta, float scrollSnapVelocity);
|
||||
|
||||
|
@ -1182,6 +1182,13 @@ void MenuItemPattern::AddClickableArea()
|
||||
auto clickableContext = clickableArea->GetRenderContext();
|
||||
CHECK_NULL_VOID(clickableContext);
|
||||
clickableContext->UpdateBorderRadius(border);
|
||||
auto menuProperty = host->GetLayoutProperty<MenuItemLayoutProperty>();
|
||||
CHECK_NULL_VOID(menuProperty);
|
||||
std::string content = menuProperty->GetContent().value_or("");
|
||||
std::string label = menuProperty->GetLabel().value_or("");
|
||||
auto accessibilityProperty = clickableArea->GetAccessibilityProperty<AccessibilityProperty>();
|
||||
CHECK_NULL_VOID(accessibilityProperty);
|
||||
accessibilityProperty->SetAccessibilityText(content + "," + label);
|
||||
clickableArea_ = clickableArea;
|
||||
clickableArea_->MountToParent(host, CLICKABLE_AREA_VIEW_INDEX);
|
||||
}
|
||||
@ -1446,6 +1453,7 @@ void MenuItemPattern::UpdateFont(RefPtr<MenuLayoutProperty>& menuProperty, RefPt
|
||||
auto renderContext = node->GetRenderContext();
|
||||
CHECK_NULL_VOID(renderContext);
|
||||
if (menuItemRenderContext->HasForegroundColor()) {
|
||||
textProperty->UpdateTextColor(menuItemRenderContext->GetForegroundColorValue());
|
||||
renderContext->UpdateForegroundColor(menuItemRenderContext->GetForegroundColorValue());
|
||||
}
|
||||
}
|
||||
|
@ -192,35 +192,20 @@ void MenuPattern::OnAttachToFrameNode()
|
||||
auto eventHub = targetNode->GetEventHub<EventHub>();
|
||||
CHECK_NULL_VOID(eventHub);
|
||||
halfFoldHoverCallbackId_ = RegisterHalfFoldHover(targetNode);
|
||||
OnAreaChangedFunc onAreaChangedFunc = [menuNodeWk = WeakPtr<FrameNode>(host)](const RectF& oldRect,
|
||||
const OffsetF& oldOrigin, const RectF& /* rect */,
|
||||
OnAreaChangedFunc onAreaChangedFunc = [menuNodeWk = WeakPtr<FrameNode>(host)](const RectF& /* oldRect */,
|
||||
const OffsetF& /* oldOrigin */, const RectF& /* rect */,
|
||||
const OffsetF& /* origin */) {
|
||||
// Not handle first change
|
||||
if (oldRect.IsEmpty() && oldOrigin.NonOffset()) {
|
||||
return;
|
||||
}
|
||||
auto pipelineContext = PipelineContext::GetCurrentContext();
|
||||
AnimationOption option;
|
||||
option.SetCurve(pipelineContext->GetSafeAreaManager()->GetSafeAreaCurve());
|
||||
AnimationUtils::Animate(
|
||||
option,
|
||||
[weakPipeline = WeakPtr<PipelineContext>(pipelineContext), weakMenu = menuNodeWk]() {
|
||||
auto menu = weakMenu.Upgrade();
|
||||
CHECK_NULL_VOID(menu);
|
||||
auto menuPattern = menu->GetPattern<MenuPattern>();
|
||||
auto menuNode = menuNodeWk.Upgrade();
|
||||
CHECK_NULL_VOID(menuNode);
|
||||
auto menuPattern = menuNode->GetPattern<MenuPattern>();
|
||||
CHECK_NULL_VOID(menuPattern);
|
||||
auto menuWarpper = menuPattern->GetMenuWrapper();
|
||||
CHECK_NULL_VOID(menuWarpper);
|
||||
auto warpperPattern = menuWarpper->GetPattern<MenuWrapperPattern>();
|
||||
CHECK_NULL_VOID(warpperPattern);
|
||||
if (!warpperPattern->IsHide()) {
|
||||
auto pipeline = weakPipeline.Upgrade();
|
||||
CHECK_NULL_VOID(pipeline);
|
||||
menu->MarkDirtyNode(PROPERTY_UPDATE_MEASURE);
|
||||
pipeline->FlushUITasks();
|
||||
menuWarpper->MarkDirtyNode(PROPERTY_UPDATE_MEASURE);
|
||||
}
|
||||
});
|
||||
pipelineContext->FlushPipelineImmediately();
|
||||
};
|
||||
eventHub->AddInnerOnAreaChangedCallback(host->GetId(), std::move(onAreaChangedFunc));
|
||||
}
|
||||
|
@ -1287,6 +1287,8 @@ void MenuView::UpdateMenuBackgroundStyle(const RefPtr<FrameNode>& menuNode, cons
|
||||
menuParam.backgroundBlurStyle.value_or(static_cast<int>(BlurStyle::COMPONENT_ULTRA_THICK)));
|
||||
menuNodeRenderContext->UpdateBackBlurStyle(styleOption);
|
||||
menuNodeRenderContext->UpdateBackgroundColor(menuParam.backgroundColor.value_or(Color::TRANSPARENT));
|
||||
} else if (menuParam.backgroundColor.has_value()) {
|
||||
menuNodeRenderContext->UpdateBackgroundColor(menuParam.backgroundColor.value());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include "core/components_ng/pattern/navigation/navigation_declaration.h"
|
||||
#include "core/components_ng/pattern/navigation/navigation_pattern.h"
|
||||
#include "core/components_ng/pattern/navigation/navigation_title_util.h"
|
||||
#include "core/event/package/package_event_proxy.h"
|
||||
|
||||
namespace OHOS::Ace::NG {
|
||||
namespace {
|
||||
@ -1048,14 +1047,6 @@ void NavigationGroupNode::OnAttachToMainTree(bool recursive)
|
||||
if (!findNavdestination) {
|
||||
pipelineContext->AddNavigationNode(pageId, WeakClaim(this));
|
||||
}
|
||||
auto* eventProxy = PackageEventProxy::GetInstance();
|
||||
if (eventProxy) {
|
||||
auto container = OHOS::Ace::Container::CurrentSafely();
|
||||
CHECK_NULL_VOID(container);
|
||||
auto navigationRoute = container->GetNavigationRoute();
|
||||
CHECK_NULL_VOID(navigationRoute);
|
||||
eventProxy->Register(WeakClaim(AceType::RawPtr(navigationRoute)));
|
||||
}
|
||||
}
|
||||
|
||||
void NavigationGroupNode::FireHideNodeChange(NavDestinationLifecycle lifecycle)
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include <map>
|
||||
#include "base/memory/ace_type.h"
|
||||
#include "base/memory/referenced.h"
|
||||
#include "core/event/package/package_change_listener.h"
|
||||
|
||||
namespace OHOS::Ace::NG {
|
||||
using NavigationLoadPageCallback = std::function<int32_t(
|
||||
@ -34,8 +33,8 @@ struct RouteItem {
|
||||
std::map<std::string, std::string> data;
|
||||
};
|
||||
|
||||
class ACE_EXPORT NavigationRoute : public PackageChangeListener {
|
||||
DECLARE_ACE_TYPE(NavigationRoute, PackageChangeListener);
|
||||
class ACE_EXPORT NavigationRoute : public AceType {
|
||||
DECLARE_ACE_TYPE(NavigationRoute, AceType);
|
||||
public:
|
||||
NavigationRoute() = default;
|
||||
~NavigationRoute() = default;
|
||||
@ -65,7 +64,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
void OnPackageChange() override {}
|
||||
virtual void InitRouteMap() {}
|
||||
|
||||
protected:
|
||||
NavigationLoadPageCallback callback_;
|
||||
|
@ -88,6 +88,7 @@ void RichEditorBaseController::SetSelection(
|
||||
auto richEditorPattern = pattern_.Upgrade();
|
||||
CHECK_NULL_VOID(richEditorPattern);
|
||||
richEditorPattern->SetSelection(selectionStart, selectionEnd, options, isForward);
|
||||
richEditorPattern->TriggerAvoidOnCaretChange();
|
||||
}
|
||||
|
||||
const PreviewTextInfo RichEditorBaseController::GetPreviewTextInfo() const
|
||||
|
@ -4124,15 +4124,18 @@ void RichEditorPattern::SetSubMap(RefPtr<SpanString>& spanString)
|
||||
}
|
||||
auto start = spanItem->rangeStart;
|
||||
auto end = spanItem->position;
|
||||
std::list<RefPtr<SpanBase>> spanBases = {
|
||||
spanString->ToFontSpan(spanItem, start, end),
|
||||
std::list<RefPtr<SpanBase>> spanBases;
|
||||
if (spanItem->spanItemType == NG::SpanItemType::IMAGE) {
|
||||
spanBases = { spanString->ToImageSpan(spanItem, start, end) };
|
||||
} else if (spanItem->spanItemType == NG::SpanItemType::NORMAL) {
|
||||
spanBases = { spanString->ToFontSpan(spanItem, start, end),
|
||||
spanString->ToDecorationSpan(spanItem, start, end),
|
||||
spanString->ToBaselineOffsetSpan(spanItem, start, end),
|
||||
spanString->ToLetterSpacingSpan(spanItem, start, end),
|
||||
spanString->ToGestureSpan(spanItem, start, end),
|
||||
spanString->ToImageSpan(spanItem),
|
||||
spanString->ToParagraphStyleSpan(spanItem, start, end),
|
||||
spanString->ToLineHeightSpan(spanItem, start, end) };
|
||||
}
|
||||
for (auto& spanBase : spanBases) {
|
||||
if (!spanBase) {
|
||||
continue;
|
||||
@ -6639,6 +6642,7 @@ void RichEditorPattern::HandleTouchUpAfterLongPress()
|
||||
CalculateHandleOffsetAndShowOverlay();
|
||||
selectOverlay_->ProcessOverlay({ .animation = true });
|
||||
FireOnSelectionChange(selectStart, selectEnd);
|
||||
IF_TRUE(IsSingleHandle(), TriggerAvoidOnCaretChange());
|
||||
}
|
||||
|
||||
void RichEditorPattern::HandleTouchMove(const Offset& offset)
|
||||
@ -7309,15 +7313,18 @@ void RichEditorPattern::HandleOnPaste()
|
||||
clipboard_->GetData(pasteCallback);
|
||||
#else
|
||||
auto isSpanStringMode = isSpanStringMode_;
|
||||
auto pasteCallback = [weak = WeakClaim(this), isSpanStringMode](std::vector<std::vector<uint8_t>>& arrs, const std::string& text) {
|
||||
TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "pasteCallback callback");
|
||||
auto pasteCallback = [weak = WeakClaim(this), isSpanStringMode](std::vector<std::vector<uint8_t>>& arrs,
|
||||
const std::string& text, bool& isMulitiTypeRecord) {
|
||||
TAG_LOGI(AceLogTag::ACE_RICH_TEXT,
|
||||
"pasteCallback callback, isMulitiTypeRecord : [%{public}d], isSpanStringMode : [%{public}d]",
|
||||
isMulitiTypeRecord, isSpanStringMode);
|
||||
auto richEditor = weak.Upgrade();
|
||||
CHECK_NULL_VOID(richEditor);
|
||||
std::list<RefPtr<SpanString>> spanStrings;
|
||||
for (auto arr : arrs) {
|
||||
spanStrings.push_back(SpanString::DecodeTlv(arr));
|
||||
}
|
||||
if (!spanStrings.empty() && isSpanStringMode) {
|
||||
if (!spanStrings.empty() && !isMulitiTypeRecord) {
|
||||
for (auto spanString : spanStrings) {
|
||||
richEditor->AddSpanByPasteData(spanString);
|
||||
richEditor->RequestKeyboardToEdit();
|
||||
@ -7769,6 +7776,7 @@ void RichEditorPattern::InitSelection(const Offset& pos)
|
||||
TAG_LOGI(AceLogTag::ACE_RICH_TEXT, "select rect is empty, select nothing");
|
||||
textSelector_.Update(currentPosition, currentPosition);
|
||||
}
|
||||
TriggerAvoidOnCaretChangeAfterLayoutTask();
|
||||
}
|
||||
|
||||
std::pair<int32_t, SelectType> RichEditorPattern::JudgeSelectType(const Offset& pos)
|
||||
|
@ -628,9 +628,9 @@ void ScrollBar::HandleDragEnd(const GestureEvent& info)
|
||||
scrollBar->ProcessFrictionMotion(value);
|
||||
});
|
||||
}
|
||||
if (startSnapMotionCallback_) {
|
||||
CHECK_NULL_VOID(!startSnapMotionCallback_(
|
||||
CalcPatternOffset(frictionMotion_->GetFinalPosition()), -velocity, CalcPatternOffset(GetDragOffset())));
|
||||
if (startSnapAnimationCallback_) {
|
||||
CHECK_NULL_VOID(!startSnapAnimationCallback_(CalcPatternOffset(frictionMotion_->GetFinalPosition()), velocity,
|
||||
-velocity, CalcPatternOffset(GetDragOffset())));
|
||||
}
|
||||
|
||||
if (!frictionController_) {
|
||||
|
@ -285,9 +285,9 @@ public:
|
||||
{
|
||||
return scrollEndCallback_;
|
||||
}
|
||||
void SetStartSnapMotionCallback(StartSnapMotionCallback&& startSnapMotionCallback)
|
||||
void SetStartSnapAnimationCallback(StartSnapAnimationCallback&& startSnapAnimationCallback)
|
||||
{
|
||||
startSnapMotionCallback_ = std::move(startSnapMotionCallback);
|
||||
startSnapAnimationCallback_ = std::move(startSnapAnimationCallback);
|
||||
}
|
||||
void SetDragFRCSceneCallback(DragFRCSceneCallback&& dragFRCSceneCallback)
|
||||
{
|
||||
@ -460,7 +460,7 @@ private:
|
||||
std::function<void()> markNeedRenderFunc_;
|
||||
ScrollPositionCallback scrollPositionCallback_;
|
||||
ScrollEndCallback scrollEndCallback_;
|
||||
StartSnapMotionCallback startSnapMotionCallback_;
|
||||
StartSnapAnimationCallback startSnapAnimationCallback_;
|
||||
ScrollPageCallback scrollPageCallback_;
|
||||
OpacityAnimationType opacityAnimationType_ = OpacityAnimationType::NONE;
|
||||
HoverAnimationType hoverAnimationType_ = HoverAnimationType::NONE;
|
||||
|
@ -170,7 +170,7 @@ bool ScrollPattern::ScrollSnapTrigger()
|
||||
return false;
|
||||
}
|
||||
if (ScrollableIdle() && !AnimateRunning()) {
|
||||
if (StartSnapAnimation(0.f, 0.f, 0.f)) {
|
||||
if (StartSnapAnimation(0.f, 0.f, 0.f, 0.f)) {
|
||||
FireOnScrollStart();
|
||||
return true;
|
||||
}
|
||||
@ -1265,11 +1265,12 @@ std::string ScrollPattern::GetScrollSnapPagination() const
|
||||
return snapPaginationStr;
|
||||
}
|
||||
|
||||
bool ScrollPattern::StartSnapAnimation(float snapDelta, float snapVelocity, float dragDistance)
|
||||
bool ScrollPattern::StartSnapAnimation(
|
||||
float snapDelta, float animationVelocity, float predictVelocity, float dragDistance)
|
||||
{
|
||||
auto predictSnapOffset = CalcPredictSnapOffset(snapDelta, dragDistance, snapVelocity);
|
||||
auto predictSnapOffset = CalcPredictSnapOffset(snapDelta, dragDistance, predictVelocity);
|
||||
if (predictSnapOffset.has_value() && !NearZero(predictSnapOffset.value(), SPRING_ACCURACY)) {
|
||||
StartScrollSnapAnimation(predictSnapOffset.value(), GetScrollableCurrentVelocity());
|
||||
StartScrollSnapAnimation(predictSnapOffset.value(), animationVelocity);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -348,7 +348,8 @@ public:
|
||||
|
||||
void ToJsonValue(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const override;
|
||||
|
||||
bool StartSnapAnimation(float snapDelta, float snapVelocity, float dragDistance = 0.f) override;
|
||||
bool StartSnapAnimation(
|
||||
float snapDelta, float animationVelocity, float predictVelocity = 0.f, float dragDistance = 0.f) override;
|
||||
|
||||
void StartScrollSnapAnimation(float scrollSnapDelta, float scrollSnapVelocity);
|
||||
|
||||
|
@ -218,13 +218,12 @@ bool ScrollBarProxy::NotifySnapScroll(
|
||||
{
|
||||
auto scrollable = scorllableNode_.scrollableNode.Upgrade();
|
||||
CHECK_NULL_RETURN(scrollable, false);
|
||||
if (scorllableNode_.startSnapMotionCallback) {
|
||||
if (scorllableNode_.startSnapAnimationCallback) {
|
||||
auto controlDistance = GetScrollableNodeDistance(scrollable);
|
||||
auto patternOffset = CalcPatternOffset(controlDistance, barScrollableDistance, delta);
|
||||
dragDistance = CalcPatternOffset(controlDistance, barScrollableDistance, dragDistance);
|
||||
return scorllableNode_.startSnapMotionCallback(patternOffset, velocity, dragDistance);
|
||||
return scorllableNode_.startSnapAnimationCallback(patternOffset, velocity, -velocity, dragDistance);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ struct ScrollableNodeInfo {
|
||||
std::function<bool(double, int32_t source)> onPositionChanged;
|
||||
std::function<bool(double, int32_t source)> scrollStartCallback;
|
||||
std::function<void()> scrollEndCallback;
|
||||
StartSnapMotionCallback startSnapMotionCallback;
|
||||
StartSnapAnimationCallback startSnapAnimationCallback;
|
||||
ScrollBarFRCallback scrollbarFRcallback;
|
||||
std::function<void(bool, bool smooth)> scrollPageCallback;
|
||||
|
||||
|
@ -258,8 +258,8 @@ void Scrollable::HandleTouchUp()
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (state_ != AnimationState::SNAP && startSnapAnimationCallback_) {
|
||||
startSnapAnimationCallback_(0.f, 0.f, 0.f);
|
||||
if (isList_ && state_ != AnimationState::SNAP && startSnapAnimationCallback_) {
|
||||
startSnapAnimationCallback_(0.f, 0.f, 0.f, 0.f);
|
||||
}
|
||||
}
|
||||
|
||||
@ -331,9 +331,7 @@ void Scrollable::HandleDragStart(const OHOS::Ace::GestureEvent& info)
|
||||
HandleTouchDown();
|
||||
}
|
||||
currentVelocity_ = info.GetMainVelocity();
|
||||
if (dragFRCSceneCallback_) {
|
||||
dragFRCSceneCallback_(currentVelocity_, NG::SceneStatus::START);
|
||||
}
|
||||
ReportToDragFRCScene(currentVelocity_, NG::SceneStatus::START);
|
||||
if (continuousDragStatus_) {
|
||||
IncreaseContinueDragCount();
|
||||
task_.Cancel();
|
||||
@ -377,9 +375,7 @@ ScrollResult Scrollable::HandleScroll(double offset, int32_t source, NestedState
|
||||
void Scrollable::HandleDragUpdate(const GestureEvent& info)
|
||||
{
|
||||
currentVelocity_ = info.GetMainVelocity();
|
||||
if (dragFRCSceneCallback_) {
|
||||
dragFRCSceneCallback_(currentVelocity_, NG::SceneStatus::RUNNING);
|
||||
}
|
||||
ReportToDragFRCScene(currentVelocity_, NG::SceneStatus::RUNNING);
|
||||
if (!NearZero(info.GetMainVelocity()) && dragCount_ >= FIRST_THRESHOLD) {
|
||||
if (Negative(lastGestureVelocity_ / info.GetMainVelocity())) {
|
||||
ResetContinueDragCount();
|
||||
@ -437,9 +433,7 @@ void Scrollable::HandleDragEnd(const GestureEvent& info)
|
||||
HandleDragUpdate(info);
|
||||
TAG_LOGI(AceLogTag::ACE_SCROLLABLE, "Scroll drag end, velocity is %{public}f id:%{public}d, tag:%{public}s",
|
||||
info.GetMainVelocity(), nodeId_, nodeTag_.c_str());
|
||||
if (dragFRCSceneCallback_) {
|
||||
dragFRCSceneCallback_(info.GetMainVelocity(), NG::SceneStatus::END);
|
||||
}
|
||||
ReportToDragFRCScene(info.GetMainVelocity(), NG::SceneStatus::END);
|
||||
bool isScrollFromTouchPad = info.GetSourceTool() == SourceTool::TOUCHPAD;
|
||||
isDragUpdateStop_ = false;
|
||||
touchUp_ = false;
|
||||
@ -451,11 +445,13 @@ void Scrollable::HandleDragEnd(const GestureEvent& info)
|
||||
double mainPosition = Round(GetMainOffset(Offset(info.GetGlobalPoint().GetX(), info.GetGlobalPoint().GetY())));
|
||||
if (!moved_ || IsMouseWheelScroll(info)) {
|
||||
LayoutDirectionEst(lastGestureVelocity_, flingVelocityScale_, isScrollFromTouchPad);
|
||||
if (!isList_) {
|
||||
currentPos_ = mainPosition;
|
||||
if (startSnapAnimationCallback_ && startSnapAnimationCallback_(0.f, 0.f, 0.f)) {
|
||||
if (startSnapAnimationCallback_ && startSnapAnimationCallback_(0.f, currentVelocity_, 0.f, 0.f)) {
|
||||
isTouching_ = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
HandleScrollEnd(currentVelocity_);
|
||||
currentVelocity_ = 0.f;
|
||||
#ifdef OHOS_PLATFORM
|
||||
@ -482,6 +478,12 @@ void Scrollable::HandleDragEnd(const GestureEvent& info)
|
||||
isTouching_ = false;
|
||||
}
|
||||
|
||||
void Scrollable::ReportToDragFRCScene(double velocity, NG::SceneStatus sceneStatus)
|
||||
{
|
||||
CHECK_NULL_VOID(dragFRCSceneCallback_);
|
||||
dragFRCSceneCallback_(velocity, sceneStatus);
|
||||
}
|
||||
|
||||
void Scrollable::CalcOverScrollVelocity()
|
||||
{
|
||||
auto gamma = 0.0f;
|
||||
@ -513,7 +515,10 @@ void Scrollable::StartScrollAnimation(float mainPosition, float correctVelocity,
|
||||
finalPosition_ = mainPosition + correctVelocity / (friction * -FRICTION_SCALE);
|
||||
currentPos_ = mainPosition;
|
||||
CHECK_NULL_VOID(!(startSnapAnimationCallback_ &&
|
||||
startSnapAnimationCallback_(GetFinalPosition() - mainPosition, correctVelocity, GetDragOffset())));
|
||||
startSnapAnimationCallback_(GetFinalPosition() - mainPosition,
|
||||
correctVelocity,
|
||||
correctVelocity,
|
||||
GetDragOffset())));
|
||||
auto frictionVelocityTh =
|
||||
isScrollFromTouchPad ? FRICTION_VELOCITY_THRESHOLD * touchPadVelocityScaleRate_ : FRICTION_VELOCITY_THRESHOLD;
|
||||
if (NearZero(correctVelocity, frictionVelocityTh)) {
|
||||
@ -934,7 +939,7 @@ void Scrollable::ProcessScrollMotionStop(bool stopFriction)
|
||||
{
|
||||
if (needScrollSnapChange_ && startSnapAnimationCallback_ && frictionOffsetProperty_) {
|
||||
needScrollSnapChange_ = false;
|
||||
CHECK_NULL_VOID(!startSnapAnimationCallback_(GetFinalPosition() - currentPos_, 0.f, 0.f));
|
||||
CHECK_NULL_VOID(!startSnapAnimationCallback_(GetFinalPosition() - currentPos_, currentVelocity_, 0.f, 0.f));
|
||||
}
|
||||
// spring effect special process
|
||||
if (scrollPause_) {
|
||||
@ -1214,14 +1219,14 @@ RefPtr<NodeAnimatablePropertyFloat> Scrollable::GetSnapProperty()
|
||||
scroll->lastVsyncTime_ = currentVsync;
|
||||
|
||||
if (NearEqual(scroll->endPos_, position, SPRING_ACCURACY)) {
|
||||
if (scroll->useListSnap_) {
|
||||
if (scroll->isList_) {
|
||||
scroll->ProcessListSnapMotion(scroll->endPos_);
|
||||
} else {
|
||||
scroll->ProcessScrollMotion(scroll->endPos_);
|
||||
}
|
||||
scroll->StopSnapAnimation();
|
||||
} else {
|
||||
if (scroll->useListSnap_) {
|
||||
if (scroll->isList_) {
|
||||
scroll->ProcessListSnapMotion(position);
|
||||
} else {
|
||||
scroll->ProcessScrollMotion(position);
|
||||
|
@ -60,7 +60,8 @@ using DragEndForRefreshCallback = std::function<void()>;
|
||||
using DragCancelRefreshCallback = std::function<void()>;
|
||||
using MouseLeftButtonScroll = std::function<bool()>;
|
||||
using ContinuousSlidingCallback = std::function<double()>;
|
||||
using StartSnapAnimationCallback = std::function<bool(float snapDelta, float snapVelocity, float dragDistance)>;
|
||||
using StartSnapAnimationCallback =
|
||||
std::function<bool(float snapDelta, float animationVelocity, float predictVelocity, float dragDistance)>;
|
||||
using NeedScrollSnapToSideCallback = std::function<bool(float delta)>;
|
||||
using NestableScrollCallback = std::function<ScrollResult(float, int32_t, NestedState)>;
|
||||
using DragFRCSceneCallback = std::function<void(double velocity, NG::SceneStatus sceneStatus)>;
|
||||
@ -134,12 +135,9 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param useListSnap true if runnning SnapAnimation for ListPattern, false if for ScrollPattern
|
||||
*/
|
||||
void SetSnapMode(bool useListSnap)
|
||||
void SetIsList(bool isList)
|
||||
{
|
||||
useListSnap_ = useListSnap;
|
||||
isList_ = isList;
|
||||
}
|
||||
|
||||
void OnCollectTouchTarget(TouchTestResult& result, const RefPtr<FrameNode>& frameNode,
|
||||
@ -192,6 +190,7 @@ public:
|
||||
bool HandleOverScroll(double velocity);
|
||||
ScrollResult HandleScroll(double offset, int32_t source, NestedState state);
|
||||
void LayoutDirectionEst(double correctVelocity, double velocityScale, bool isScrollFromTouchPad);
|
||||
void ReportToDragFRCScene(double velocity, NG::SceneStatus sceneStatus);
|
||||
|
||||
void SetMoved(bool value)
|
||||
{
|
||||
@ -569,7 +568,7 @@ private:
|
||||
bool needCenterFix_ = false;
|
||||
bool isDragUpdateStop_ = false;
|
||||
bool isFadingAway_ = false;
|
||||
bool useListSnap_ = false; // set to true to use Snap animation of ListPattern
|
||||
bool isList_ = false;
|
||||
// The accessibilityId of UINode
|
||||
int32_t nodeId_ = 0;
|
||||
// The tag of UINode
|
||||
|
@ -623,11 +623,11 @@ void ScrollablePattern::SetDragEndCallback(const RefPtr<Scrollable>& scrollable)
|
||||
void ScrollablePattern::SetStartSnapAnimationCallback(const RefPtr<Scrollable>& scrollable)
|
||||
{
|
||||
CHECK_NULL_VOID(scrollable);
|
||||
auto startSnapAnimationCallback = [weak = WeakClaim(this)](
|
||||
float snapDelta, float snapVelocity, float dragDistance) -> bool {
|
||||
auto startSnapAnimationCallback = [weak = WeakClaim(this)](float snapDelta, float animationVelocity,
|
||||
float predictVelocity, float dragDistance) -> bool {
|
||||
auto pattern = weak.Upgrade();
|
||||
CHECK_NULL_RETURN(pattern, false);
|
||||
return pattern->StartSnapAnimation(snapDelta, snapVelocity, dragDistance);
|
||||
return pattern->StartSnapAnimation(snapDelta, animationVelocity, predictVelocity, dragDistance);
|
||||
};
|
||||
scrollable->SetStartSnapAnimationCallback(std::move(startSnapAnimationCallback));
|
||||
}
|
||||
@ -904,12 +904,13 @@ void ScrollablePattern::RegisterScrollBarEventTask()
|
||||
pattern->OnScrollEnd();
|
||||
};
|
||||
scrollBar_->SetScrollEndCallback(std::move(scrollEnd));
|
||||
auto startSnapMotionCallback = [weak = WeakClaim(this)](float delta, float velocity, float dragDistance) -> bool {
|
||||
auto startSnapAnimationCallback = [weak = WeakClaim(this)](float delta, float animationVelocity,
|
||||
float predictVelocity, float dragDistance) -> bool {
|
||||
auto pattern = weak.Upgrade();
|
||||
CHECK_NULL_RETURN(pattern, false);
|
||||
return pattern->StartSnapAnimation(delta, velocity, dragDistance);
|
||||
return pattern->StartSnapAnimation(delta, animationVelocity, predictVelocity, dragDistance);
|
||||
};
|
||||
scrollBar_->SetStartSnapMotionCallback(std::move(startSnapMotionCallback));
|
||||
scrollBar_->SetStartSnapAnimationCallback(std::move(startSnapAnimationCallback));
|
||||
auto scrollPageCallback = [weak = WeakClaim(this)](bool reverse, bool smooth) {
|
||||
auto pattern = weak.Upgrade();
|
||||
CHECK_NULL_VOID(pattern);
|
||||
@ -1134,10 +1135,11 @@ void ScrollablePattern::SetScrollBarProxy(const RefPtr<ScrollBarProxy>& scrollBa
|
||||
CHECK_NULL_VOID(pattern);
|
||||
pattern->OnScrollEnd();
|
||||
};
|
||||
auto startSnapMotionCallback = [weak = WeakClaim(this)](float delta, float velocity, float dragDistance) -> bool {
|
||||
auto startSnapAnimationCallback = [weak = WeakClaim(this)](float delta, float animationVelocity,
|
||||
float predictVelocity, float dragDistance) -> bool {
|
||||
auto pattern = weak.Upgrade();
|
||||
CHECK_NULL_RETURN(pattern, false);
|
||||
return pattern->StartSnapAnimation(delta, velocity, dragDistance);
|
||||
return pattern->StartSnapAnimation(delta, animationVelocity, predictVelocity, dragDistance);
|
||||
};
|
||||
auto scrollbarFRcallback = [weak = WeakClaim(this)](double velocity, SceneStatus sceneStatus) {
|
||||
auto pattern = weak.Upgrade();
|
||||
@ -1151,7 +1153,7 @@ void ScrollablePattern::SetScrollBarProxy(const RefPtr<ScrollBarProxy>& scrollBa
|
||||
return pattern->ScrollPage(reverse, smooth);
|
||||
};
|
||||
ScrollableNodeInfo nodeInfo = { AceType::WeakClaim(this), std::move(scrollFunction), std::move(scrollStartCallback),
|
||||
std::move(scrollEndCallback), std::move(startSnapMotionCallback), std::move(scrollbarFRcallback),
|
||||
std::move(scrollEndCallback), std::move(startSnapAnimationCallback), std::move(scrollbarFRcallback),
|
||||
std::move(scrollPageCallback) };
|
||||
scrollBarProxy->RegisterScrollableNode(nodeInfo);
|
||||
scrollBarProxy_ = scrollBarProxy;
|
||||
|
@ -248,7 +248,8 @@ public:
|
||||
scrollable->StopScrollable();
|
||||
}
|
||||
|
||||
virtual bool StartSnapAnimation(float snapDelta, float snapVelocity, float dragDistance = 0.f)
|
||||
virtual bool StartSnapAnimation(
|
||||
float snapDelta, float animationVelocity, float predictVelocity = 0.f, float dragDistance = 0.f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -462,7 +462,8 @@ using OnScrollVisibleContentChangeEvent = std::function<void(ListItemIndex, List
|
||||
|
||||
using ScrollPositionCallback = std::function<bool(double, int32_t source)>;
|
||||
using ScrollEndCallback = std::function<void()>;
|
||||
using StartSnapMotionCallback = std::function<bool(float delta, float velocity, float dragDistance)>;
|
||||
using StartSnapAnimationCallback =
|
||||
std::function<bool(float delta, float animationVelocity, float predictVelocity, float dragDistance)>;
|
||||
using ScrollBarFRCallback = std::function<void(double velocity, NG::SceneStatus sceneStatus)>;
|
||||
using ScrollPageCallback = std::function<void(bool, bool smooth)>;
|
||||
|
||||
|
@ -1237,6 +1237,7 @@ void SearchPattern::HandleFocusEvent(bool forwardFocusMovement, bool backwardFoc
|
||||
CHECK_NULL_VOID(textFieldFrameNode);
|
||||
auto textFieldPattern = textFieldFrameNode->GetPattern<TextFieldPattern>();
|
||||
CHECK_NULL_VOID(textFieldPattern);
|
||||
textFieldPattern->SetIsFocusedBeforeClick(true);
|
||||
|
||||
focusChoice_ = FocusChoice::SEARCH;
|
||||
if (forwardFocusMovement || backwardFocusMovement) { // Don't update focus if no factical focus movement
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user