mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 15:10:30 +00:00
commit
ae4316a84f
@ -878,15 +878,15 @@ inline WordBreak StringToWordBreak(const std::string& wordBreak)
|
||||
|
||||
inline std::string FontWeightToString(const FontWeight& fontWeight)
|
||||
{
|
||||
static const LinearEnumMapNode<FontWeight, std::string> fontWeightTable[] = {
|
||||
static const std::unordered_map<FontWeight, std::string> fontWeightTable = {
|
||||
{ FontWeight::W100, "100" }, { FontWeight::W200, "200" }, { FontWeight::W300, "300" },
|
||||
{ FontWeight::W400, "400" }, { FontWeight::W500, "500" }, { FontWeight::W600, "600" },
|
||||
{ FontWeight::W700, "700" }, { FontWeight::W800, "800" }, { FontWeight::W900, "900" },
|
||||
{ FontWeight::BOLD, "bold" }, { FontWeight::BOLDER, "bolder" }, { FontWeight::LIGHTER, "lighter" },
|
||||
{ FontWeight::MEDIUM, "medium" }, { FontWeight::NORMAL, "normal" }, { FontWeight::REGULAR, "regular" },
|
||||
};
|
||||
auto weightIter = BinarySearchFindIndex(fontWeightTable, ArraySize(fontWeightTable), fontWeight);
|
||||
return weightIter != -1 ? fontWeightTable[weightIter].value : "";
|
||||
auto weightIter = fontWeightTable.find(fontWeight);
|
||||
return weightIter != fontWeightTable.end() ? weightIter->second : "";
|
||||
}
|
||||
|
||||
inline std::string ToString(const FontWeight& fontWeight)
|
||||
|
@ -1166,4 +1166,20 @@ std::vector<uint32_t> TextPickerModelNG::getTextPickerSelecteds(FrameNode* frame
|
||||
CHECK_NULL_RETURN(textPickerPattern, defaultValue);
|
||||
return textPickerPattern->GetSelecteds();
|
||||
}
|
||||
|
||||
void TextPickerModelNG::SetTextPickerRangeType(FrameNode* frameNode, int32_t rangeType)
|
||||
{
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
auto textPickerPattern = frameNode->GetPattern<TextPickerPattern>();
|
||||
CHECK_NULL_VOID(textPickerPattern);
|
||||
textPickerPattern->SetRangeType(rangeType);
|
||||
}
|
||||
|
||||
int32_t TextPickerModelNG::GetTextPickerRangeType(FrameNode* frameNode)
|
||||
{
|
||||
CHECK_NULL_RETURN(frameNode, 0);
|
||||
auto textPickerPattern = frameNode->GetPattern<TextPickerPattern>();
|
||||
CHECK_NULL_RETURN(textPickerPattern, 0);
|
||||
return textPickerPattern->GetRangeType();
|
||||
}
|
||||
} // namespace OHOS::Ace::NG
|
||||
|
@ -120,16 +120,14 @@ public:
|
||||
static std::string getTextPickerRange(FrameNode* frameNode);
|
||||
static void SetDivider(FrameNode* frameNode, const ItemDivider& divider);
|
||||
static void SetGradientHeight(FrameNode* frameNode, const Dimension& value);
|
||||
static int32_t isSingleRange()
|
||||
{
|
||||
return isSingleRange_;
|
||||
}
|
||||
static void SetOnCascadeChange(FrameNode* frameNode, TextCascadeChangeEvent&& onChange);
|
||||
static int32_t GetSelectedSize(FrameNode* frameNode);
|
||||
static std::string getTextPickerValues(FrameNode* frameNode);
|
||||
static std::vector<uint32_t> getTextPickerSelecteds(FrameNode* frameNode);
|
||||
static int32_t GetCanLoop(FrameNode* frameNode);
|
||||
static Dimension GetDefaultPickerItemHeight(FrameNode* frameNode);
|
||||
static void SetTextPickerRangeType(FrameNode* frameNode, int32_t rangeType);
|
||||
static int32_t GetTextPickerRangeType(FrameNode* frameNode);
|
||||
|
||||
private:
|
||||
static RefPtr<FrameNode> CreateStackNode();
|
||||
|
@ -399,6 +399,16 @@ public:
|
||||
return hasUserDefinedSelectedFontFamily_;
|
||||
}
|
||||
|
||||
void SetRangeType(int32_t rangeType)
|
||||
{
|
||||
rangeType_ = rangeType;
|
||||
}
|
||||
|
||||
int32_t GetRangeType()
|
||||
{
|
||||
return rangeType_;
|
||||
}
|
||||
|
||||
private:
|
||||
void OnModifyDone() override;
|
||||
void SetLayoutDirection(TextDirection textDirection);
|
||||
@ -470,6 +480,7 @@ private:
|
||||
ItemDivider divider_;
|
||||
bool customDividerFlag_ = false;
|
||||
Dimension value_;
|
||||
int32_t rangeType_ = 0;
|
||||
};
|
||||
} // namespace OHOS::Ace::NG
|
||||
|
||||
|
@ -3590,7 +3590,8 @@ struct ArkUITextPickerModifier {
|
||||
void (*resetTextPickerBackgroundColor)(ArkUINodeHandle node);
|
||||
ArkUI_CharPtr (*getTextPickerRangeStr)(ArkUINodeHandle node);
|
||||
ArkUI_Int32 (*getTextPickerSingleRange)(ArkUINodeHandle node);
|
||||
void (*setTextPickerRangeStr)(ArkUINodeHandle node, ArkUI_CharPtr rangeStr, ArkUI_Bool isSingleRange);
|
||||
void (*setTextPickerRangeStr)(ArkUINodeHandle node, ArkUI_CharPtr rangeStr, ArkUI_Bool isSingleRange,
|
||||
ArkUI_Int32 rangeType);
|
||||
ArkUI_CharPtr (*getTextPickerValue)(ArkUINodeHandle node);
|
||||
void (*setTextPickerValue)(ArkUINodeHandle node, ArkUI_CharPtr valueStr);
|
||||
void (*setTextPickerDivider)(ArkUINodeHandle node, ArkUI_Uint32 color, const ArkUI_Float32* values,
|
||||
|
@ -166,8 +166,7 @@ void ResetTextPickerTextStyle(ArkUINodeHandle node)
|
||||
TextPickerModelNG::SetNormalTextStyle(frameNode, pickerTheme, pickerTextStyle);
|
||||
}
|
||||
|
||||
void SetTextPickerSelectedTextStyle(
|
||||
ArkUINodeHandle node, ArkUI_Uint32 color, ArkUI_CharPtr fontInfo, ArkUI_Int32 style)
|
||||
void SetTextPickerSelectedTextStyle(ArkUINodeHandle node, ArkUI_Uint32 color, ArkUI_CharPtr fontInfo, ArkUI_Int32 style)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
@ -257,7 +256,7 @@ void ResetTextPickerDisappearTextStyle(ArkUINodeHandle node)
|
||||
ArkUI_Float32 GetTextPickerDefaultPickerItemHeight(ArkUINodeHandle node, ArkUI_Int32 dUnit)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_RETURN(frameNode, 0.0f);
|
||||
CHECK_NULL_RETURN(frameNode, -1.0f);
|
||||
return TextPickerModelNG::GetDefaultPickerItemHeight(frameNode).GetNativeValue(static_cast<DimensionUnit>(dUnit));
|
||||
}
|
||||
|
||||
@ -288,10 +287,11 @@ ArkUI_Int32 GetTextPickerSingleRange(ArkUINodeHandle node)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
|
||||
return !TextPickerModelNG::isSingleRange();
|
||||
return TextPickerModelNG::GetTextPickerRangeType(frameNode);
|
||||
}
|
||||
|
||||
void SetTextPickerRangeStr(ArkUINodeHandle node, ArkUI_CharPtr rangeStr, ArkUI_Bool isSingleRange)
|
||||
void SetTextPickerRangeStr(
|
||||
ArkUINodeHandle node, ArkUI_CharPtr rangeStr, ArkUI_Bool isSingleRange, ArkUI_Int32 rangeType)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
@ -316,6 +316,7 @@ void SetTextPickerRangeStr(ArkUINodeHandle node, ArkUI_CharPtr rangeStr, ArkUI_B
|
||||
}
|
||||
TextPickerModelNG::SetColumns(frameNode, multiResult);
|
||||
}
|
||||
TextPickerModelNG::SetTextPickerRangeType(frameNode, rangeType);
|
||||
}
|
||||
|
||||
ArkUI_CharPtr GetTextPickerValue(ArkUINodeHandle node)
|
||||
|
@ -7948,7 +7948,7 @@ int32_t SetTextPickerRange(ArkUI_NodeHandle node, const ArkUI_AttributeItem* ite
|
||||
{
|
||||
auto actualSize = CheckAttributeItemArray(item, REQUIRED_ONE_PARAM);
|
||||
if (actualSize < 0 || !InRegion(static_cast<int32_t>(ARKUI_TEXTPICKER_RANGETYPE_SINGLE),
|
||||
static_cast<int32_t>(ARKUI_TEXTPICKER_RANGETYPE_MULTI), item->value[NUM_0].i32)) {
|
||||
static_cast<int32_t>(ARKUI_TEXTPICKER_RANGETYPE_CASCADE_RANGE_CONTENT), item->value[NUM_0].i32)) {
|
||||
return ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
bool isSingleRange = false;
|
||||
@ -7958,15 +7958,14 @@ int32_t SetTextPickerRange(ArkUI_NodeHandle node, const ArkUI_AttributeItem* ite
|
||||
}
|
||||
isSingleRange = item->value[NUM_0].i32 == static_cast<int32_t>(ARKUI_TEXTPICKER_RANGETYPE_SINGLE);
|
||||
fullImpl->getNodeModifiers()->getTextPickerModifier()->setTextPickerRangeStr(
|
||||
node->uiNodeHandle, item->string, isSingleRange);
|
||||
node->uiNodeHandle, item->string, isSingleRange, item->value[NUM_0].i32);
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
void ResetTextPickerRange(ArkUI_NodeHandle node)
|
||||
{
|
||||
auto fullImpl = GetFullImpl();
|
||||
|
||||
fullImpl->getNodeModifiers()->getTextPickerModifier()->setTextPickerRangeStr(node->uiNodeHandle, "", true);
|
||||
fullImpl->getNodeModifiers()->getTextPickerModifier()->setTextPickerRangeStr(node->uiNodeHandle, "", true, NUM_0);
|
||||
}
|
||||
|
||||
const ArkUI_AttributeItem* GetTextPickerValue(ArkUI_NodeHandle node)
|
||||
|
Loading…
Reference in New Issue
Block a user