NDK C-API fix textinput default padding

Signed-off-by: liyi0309<liyi58@huawei.com>

Change-Id: Iee459ffa49abb01a0757e275bc9e66a35fc7ba50
This commit is contained in:
firminly 2024-04-02 15:18:36 +08:00
parent ba13f82869
commit 1d7f72f5f5
5 changed files with 32 additions and 3 deletions

View File

@ -1395,4 +1395,22 @@ void TextFieldModelNG::TextFieldModelNG::SetWordBreak(FrameNode* frameNode, Ace:
{
ACE_UPDATE_NODE_LAYOUT_PROPERTY(TextFieldLayoutProperty, WordBreak, value, frameNode);
}
void TextFieldModelNG::ResetTextInputPadding(FrameNode* frameNode)
{
CHECK_NULL_VOID(frameNode);
auto pipeline = frameNode->GetContext();
CHECK_NULL_VOID(pipeline);
auto themeManager = pipeline->GetThemeManager();
CHECK_NULL_VOID(themeManager);
auto textFieldTheme = themeManager->GetTheme<TextFieldTheme>();
CHECK_NULL_VOID(textFieldTheme);
auto themePadding = textFieldTheme->GetPadding();
PaddingProperty paddings;
paddings.top = NG::CalcLength(themePadding.Top().ConvertToPx());
paddings.bottom = NG::CalcLength(themePadding.Bottom().ConvertToPx());
paddings.left = NG::CalcLength(themePadding.Left().ConvertToPx());
paddings.right = NG::CalcLength(themePadding.Right().ConvertToPx());
ACE_UPDATE_NODE_LAYOUT_PROPERTY(TextFieldLayoutProperty, Padding, paddings, frameNode);
}
} // namespace OHOS::Ace::NG

View File

@ -195,6 +195,7 @@ public:
static int32_t GetTextSelectionIndex(FrameNode* frameNode, bool isEnd);
static void SetFontFeature(FrameNode* frameNode, const FONT_FEATURES_MAP& value);
static void SetWordBreak(FrameNode* frameNode, Ace::WordBreak value);
static void ResetTextInputPadding(FrameNode* frameNode);
private:
void AddDragFrameNodeToManager() const;

View File

@ -2298,6 +2298,7 @@ struct ArkUITextInputModifier {
void (*resetTextInputPasswordRules)(ArkUINodeHandle node);
void (*setTextInputEnableAutoFill)(ArkUINodeHandle node, ArkUI_Uint32 enableAutoFill);
void (*resetTextInputEnableAutoFill)(ArkUINodeHandle node);
void (*resetTextInputPadding)(ArkUINodeHandle node);
};
struct ArkUIWebModifier {

View File

@ -968,6 +968,12 @@ void ResetTextInputWordBreak(ArkUINodeHandle node)
CHECK_NULL_VOID(frameNode);
TextFieldModelNG::SetWordBreak(frameNode, WORD_BREAK_TYPES[2]); // 2 is the default value of WordBreak::BREAK_WORD
}
void ResetTextInputPadding(ArkUINodeHandle node)
{
auto *frameNode = reinterpret_cast<FrameNode *>(node);
TextFieldModelNG::ResetTextInputPadding(frameNode);
}
} // namespace
namespace NodeModifier {
@ -1000,7 +1006,7 @@ const ArkUITextInputModifier* GetTextInputModifier()
SetTextInputDecoration, ResetTextInputDecoration, SetTextInputLetterSpacing, ResetTextInputLetterSpacing,
SetTextInputLineHeight, ResetTextInputLineHeight, SetTextInputFontFeature, ResetTextInputFontFeature,
SetTextInputWordBreak, ResetTextInputWordBreak, SetTextInputPasswordRules, ResetTextInputPasswordRules,
SetTextInputEnableAutoFill, ResetTextInputEnableAutoFill };
SetTextInputEnableAutoFill, ResetTextInputEnableAutoFill, ResetTextInputPadding };
return &modifier;
}

View File

@ -725,7 +725,11 @@ int32_t SetPadding(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
void ResetPadding(ArkUI_NodeHandle node)
{
auto* fullImpl = GetFullImpl();
fullImpl->getNodeModifiers()->getCommonModifier()->resetPadding(node->uiNodeHandle);
if (node->type == ARKUI_NODE_TEXT_INPUT) {
fullImpl->getNodeModifiers()->getTextInputModifier()->resetTextInputPadding(node->uiNodeHandle);
} else {
fullImpl->getNodeModifiers()->getCommonModifier()->resetPadding(node->uiNodeHandle);
}
}
const ArkUI_AttributeItem* GetPadding(ArkUI_NodeHandle node)
@ -2984,7 +2988,6 @@ int32_t SetShowUnderline(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
if (actualSize < 0 || !InRegion(NUM_0, NUM_1, item->value[NUM_0].i32)) {
return ERROR_CODE_PARAM_INVALID;
}
// already check in entry point.
auto* fullImpl = GetFullImpl();
fullImpl->getNodeModifiers()->getTextInputModifier()->setTextInputShowUnderline(
node->uiNodeHandle, item->value[NUM_0].i32);