mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 15:10:30 +00:00
!42130 【RichEditor】修改symbol、shadow无法跟随深浅色切换颜色的问题
Merge pull request !42130 from xuyue/darkLightRe
This commit is contained in:
commit
e5ba6f5407
@ -90,13 +90,6 @@ std::string SpanToHtml::ColorToHtml(const std::optional<Color>& value)
|
||||
return ToHtmlStyleFormat("color", color);
|
||||
}
|
||||
|
||||
std::string SpanToHtml::ColorToHtml(const std::optional<DynamicColor>& value)
|
||||
{
|
||||
auto color = value.value_or(DynamicColor(Color::BLACK)).ToColor().ColorToString();
|
||||
ToHtmlColor(color);
|
||||
return ToHtmlStyleFormat("color", color);
|
||||
}
|
||||
|
||||
std::string SpanToHtml::FontFamilyToHtml(const std::optional<std::vector<std::string>>& value)
|
||||
{
|
||||
return ToHtmlStyleFormat("font-family", GetFontFamilyInJson(value));
|
||||
|
@ -31,7 +31,6 @@ private:
|
||||
static std::string FontSizeToHtml(const std::optional<Dimension>& value);
|
||||
static std::string FontWeightToHtml(const std::optional<FontWeight>& value);
|
||||
static std::string ColorToHtml(const std::optional<Color>& value);
|
||||
static std::string ColorToHtml(const std::optional<DynamicColor>& value);
|
||||
static std::string FontFamilyToHtml(const std::optional<std::vector<std::string>>& value);
|
||||
static std::string TextDecorationToHtml(TextDecoration decoration);
|
||||
static std::string TextDecorationStyleToHtml(TextDecorationStyle decorationStyle);
|
||||
|
@ -80,7 +80,6 @@
|
||||
OHOS::Ace::ResourceWrapper::*;
|
||||
OHOS::Ace::NG::AppBarView::*;
|
||||
OHOS::Ace::Color::*;
|
||||
OHOS::Ace::DynamicColor::*;
|
||||
OHOS::Ace::NG::UIObserverHandler::*;
|
||||
OHOS::Ace::UIDisplaySync::*;
|
||||
OHOS::Ace::Dimension::*;
|
||||
|
@ -1084,7 +1084,7 @@ void JSRichEditor::SetPlaceholder(const JSCallbackInfo& info)
|
||||
JSRef<JSVal> colorVal = object->GetProperty("fontColor");
|
||||
Color fontColor;
|
||||
if (!colorVal->IsNull() && JSContainerBase::ParseJsColor(colorVal, fontColor)) {
|
||||
options.fontColor = DynamicColor(fontColor, ParseColorResourceId(colorVal));
|
||||
options.fontColor = fontColor;
|
||||
}
|
||||
}
|
||||
auto textTheme = pipelineContext->GetTheme<TextTheme>();
|
||||
@ -1166,18 +1166,15 @@ void JSRichEditor::SetCaretColor(const JSCallbackInfo& info)
|
||||
return;
|
||||
}
|
||||
Color color;
|
||||
DynamicColor dynamicColor;
|
||||
JSRef<JSVal> colorVal = info[0];
|
||||
if (!ParseJsColor(colorVal, color)) {
|
||||
auto pipeline = PipelineBase::GetCurrentContext();
|
||||
CHECK_NULL_VOID(pipeline);
|
||||
auto theme = pipeline->GetThemeManager()->GetTheme<NG::RichEditorTheme>();
|
||||
CHECK_NULL_VOID(theme);
|
||||
dynamicColor = theme->GetCaretColor();
|
||||
} else {
|
||||
dynamicColor = DynamicColor(color, ParseColorResourceId(colorVal));
|
||||
color = theme->GetCaretColor();
|
||||
}
|
||||
RichEditorModel::GetInstance()->SetCaretColor(dynamicColor);
|
||||
RichEditorModel::GetInstance()->SetCaretColor(color);
|
||||
}
|
||||
|
||||
void JSRichEditor::SetSelectedBackgroundColor(const JSCallbackInfo& info)
|
||||
@ -1187,18 +1184,15 @@ void JSRichEditor::SetSelectedBackgroundColor(const JSCallbackInfo& info)
|
||||
return;
|
||||
}
|
||||
Color selectedColor;
|
||||
DynamicColor dynamicSelectedColor;
|
||||
JSRef<JSVal> colorVal = info[0];
|
||||
if (!ParseJsColor(colorVal, selectedColor)) {
|
||||
auto pipeline = PipelineBase::GetCurrentContext();
|
||||
CHECK_NULL_VOID(pipeline);
|
||||
auto theme = pipeline->GetThemeManager()->GetTheme<NG::RichEditorTheme>();
|
||||
CHECK_NULL_VOID(theme);
|
||||
dynamicSelectedColor = theme->GetSelectedBackgroundColor();
|
||||
} else {
|
||||
dynamicSelectedColor = DynamicColor(selectedColor, ParseColorResourceId(colorVal));
|
||||
selectedColor = theme->GetSelectedBackgroundColor();
|
||||
}
|
||||
RichEditorModel::GetInstance()->SetSelectedBackgroundColor(dynamicSelectedColor);
|
||||
RichEditorModel::GetInstance()->SetSelectedBackgroundColor(selectedColor);
|
||||
}
|
||||
|
||||
void JSRichEditor::SetEnterKeyType(const JSCallbackInfo& info)
|
||||
@ -1263,18 +1257,6 @@ void JSRichEditor::SetOnSubmit(const JSCallbackInfo& info)
|
||||
CreateJsRichEditorCommonEvent(info);
|
||||
}
|
||||
|
||||
std::optional<uint32_t> JSRichEditor::ParseColorResourceId(JSRef<JSVal> colorVal)
|
||||
{
|
||||
CHECK_NULL_RETURN(colorVal->IsObject(), std::nullopt);
|
||||
JSRef<JSObject> jsObj = JSRef<JSObject>::Cast(colorVal);
|
||||
JSViewAbstract::CompleteResourceObject(jsObj);
|
||||
JSRef<JSVal> resId = jsObj->GetProperty("id");
|
||||
CHECK_NULL_RETURN(resId->IsNumber(), std::nullopt);
|
||||
auto type = jsObj->GetPropertyValue<int32_t>("type", -1);
|
||||
CHECK_NULL_RETURN(type == static_cast<int32_t>(ResourceType::COLOR), std::nullopt);
|
||||
return resId->ToNumber<uint32_t>();
|
||||
}
|
||||
|
||||
void JSRichEditor::SetEnableKeyboardOnFocus(const JSCallbackInfo& info)
|
||||
{
|
||||
CHECK_NULL_VOID(info.Length() > 0);
|
||||
@ -2236,9 +2218,8 @@ void JSRichEditorBaseController::ParseJsTextStyle(
|
||||
JSRef<JSVal> fontColor = styleObject->GetProperty("fontColor");
|
||||
Color textColor;
|
||||
if (!fontColor->IsNull() && JSContainerBase::ParseJsColor(fontColor, textColor)) {
|
||||
DynamicColor dynamicColor = DynamicColor(textColor, JSRichEditor::ParseColorResourceId(fontColor));
|
||||
style.SetTextColor(dynamicColor);
|
||||
updateSpanStyle.updateTextColor = dynamicColor;
|
||||
style.SetTextColor(textColor);
|
||||
updateSpanStyle.updateTextColor = textColor;
|
||||
updateSpanStyle.useThemeFontColor = false;
|
||||
}
|
||||
JSRef<JSVal> fontSize = styleObject->GetProperty("fontSize");
|
||||
@ -2356,9 +2337,8 @@ void JSRichEditorBaseController::ParseTextDecoration(
|
||||
JSRef<JSVal> color = decorationObject->GetProperty("color");
|
||||
Color decorationColor;
|
||||
if (!color->IsNull() && JSContainerBase::ParseJsColor(color, decorationColor)) {
|
||||
DynamicColor dynamicColor = DynamicColor(decorationColor, JSRichEditor::ParseColorResourceId(color));
|
||||
updateSpanStyle.updateTextDecorationColor = dynamicColor;
|
||||
style.SetTextDecorationColor(dynamicColor);
|
||||
updateSpanStyle.updateTextDecorationColor = decorationColor;
|
||||
style.SetTextDecorationColor(decorationColor);
|
||||
updateSpanStyle.useThemeDecorationColor = false;
|
||||
}
|
||||
JSRef<JSVal> textDecorationStyle = decorationObject->GetProperty("style");
|
||||
@ -2368,8 +2348,8 @@ void JSRichEditorBaseController::ParseTextDecoration(
|
||||
style.SetTextDecorationStyle(static_cast<TextDecorationStyle>(textDecorationStyle->ToNumber<int32_t>()));
|
||||
}
|
||||
if (!updateSpanStyle.updateTextDecorationColor.has_value() && updateSpanStyle.updateTextColor.has_value()) {
|
||||
updateSpanStyle.updateTextDecorationColor = style.GetDynamicTextColor();
|
||||
style.SetTextDecorationColor(style.GetDynamicTextColor());
|
||||
updateSpanStyle.updateTextDecorationColor = style.GetTextColor();
|
||||
style.SetTextDecorationColor(style.GetTextColor());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,6 @@ public:
|
||||
static std::optional<NG::MarginProperty> ParseMarginAttr(JsiRef<JSVal> marginAttr);
|
||||
static CalcDimension ParseLengthMetrics(const JSRef<JSObject>& obj);
|
||||
static void EditMenuOptions(const JSCallbackInfo& info);
|
||||
static std::optional<uint32_t> ParseColorResourceId(JSRef<JSVal> colorVal);
|
||||
static void SetEnableKeyboardOnFocus(const JSCallbackInfo& info);
|
||||
static void SetEnableHapticFeedback(const JSCallbackInfo& info);
|
||||
static JSRef<JSArray> CreateJsTextShadowObjectArray(const TextStyleResult& textStyleResult);
|
||||
|
@ -5463,6 +5463,7 @@ bool JSViewAbstract::ParseJsObjColorFromResource(const JSRef<JSObject> &jsObj, C
|
||||
}
|
||||
if (type == static_cast<int32_t>(ResourceType::COLOR)) {
|
||||
result = resourceWrapper->GetColor(resId->ToNumber<uint32_t>());
|
||||
result.SetResourceId(resId->ToNumber<uint32_t>());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -38,8 +38,8 @@ class ACE_EXPORT RichEditorModelImpl : public RichEditorModel {
|
||||
void SetTextDetectEnable(bool value) override {}
|
||||
void SetSupportPreviewText(bool value) override {}
|
||||
void SetTextDetectConfig(const TextDetectConfig& textDetectConfig) override {}
|
||||
void SetSelectedBackgroundColor(const DynamicColor& selectedColor) override {}
|
||||
void SetCaretColor(const DynamicColor& color) override {}
|
||||
void SetSelectedBackgroundColor(const Color& selectedColor) override {}
|
||||
void SetCaretColor(const Color& color) override {}
|
||||
void SetOnEditingChange(std::function<void(const bool&)>&& func) override {}
|
||||
void SetOnSubmit(std::function<void(int32_t, NG::TextFieldCommonEvent&)>&& func) override {}
|
||||
void SetEnterKeyType(TextInputAction value) override {}
|
||||
|
@ -590,66 +590,15 @@ bool Color::IsOpacityValid(double value)
|
||||
return value >= MIN_RGBA_OPACITY && value <= MAX_RGBA_OPACITY;
|
||||
}
|
||||
|
||||
DynamicColor::DynamicColor(const Color& color)
|
||||
{
|
||||
SetValue(color.GetValue());
|
||||
}
|
||||
|
||||
DynamicColor::DynamicColor(const Color& color, std::optional<uint32_t> resId) : resourceId(resId)
|
||||
{
|
||||
SetValue(color.GetValue());
|
||||
}
|
||||
|
||||
DynamicColor::DynamicColor(const Color& color, uint32_t resId) : resourceId(resId)
|
||||
{
|
||||
SetValue(color.GetValue());
|
||||
}
|
||||
|
||||
void DynamicColor::UpdateColorByResourceId()
|
||||
void Color::UpdateColorByResourceId()
|
||||
{
|
||||
#ifndef ACE_UNITTEST
|
||||
CHECK_NULL_VOID(resourceId);
|
||||
CHECK_NULL_VOID(resourceId_ != 0);
|
||||
auto resourceAdapter = ResourceManager::GetInstance().GetResourceAdapter();
|
||||
CHECK_NULL_VOID(resourceAdapter);
|
||||
auto newColor = resourceAdapter->GetColor(resourceId.value());
|
||||
auto newColor = resourceAdapter->GetColor(resourceId_);
|
||||
SetValue(newColor.GetValue());
|
||||
#endif
|
||||
}
|
||||
|
||||
Color DynamicColor::ToColor() const
|
||||
{
|
||||
return Color(GetValue());
|
||||
}
|
||||
|
||||
std::string DynamicColor::ToString() const
|
||||
{
|
||||
std::string ret = "color=";
|
||||
ret += Color::ToString();
|
||||
ret += ", resourceId=";
|
||||
ret += resourceId ? std::to_string(resourceId.value()) : "nullopt";
|
||||
return ret;
|
||||
}
|
||||
|
||||
DynamicColor& DynamicColor::operator=(const Color& rhs)
|
||||
{
|
||||
SetValue(rhs.GetValue());
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool DynamicColor::operator==(const DynamicColor& rhs) const
|
||||
{
|
||||
if (this->GetValue() != rhs.GetValue()) {
|
||||
return false;
|
||||
}
|
||||
if (!this->resourceId && !rhs.resourceId) {
|
||||
return true;
|
||||
}
|
||||
return this->resourceId && rhs.resourceId && *(this->resourceId) == *(rhs.resourceId);
|
||||
}
|
||||
|
||||
bool DynamicColor::operator!=(const DynamicColor& rhs) const
|
||||
{
|
||||
return !operator==(rhs);
|
||||
}
|
||||
|
||||
} // namespace OHOS::Ace
|
||||
|
@ -55,6 +55,8 @@ class ACE_FORCE_EXPORT Color {
|
||||
public:
|
||||
Color() = default;
|
||||
constexpr explicit Color(uint32_t value) : colorValue_(ColorParam { .value = value }) {}
|
||||
constexpr explicit Color(uint32_t value, uint32_t resId)
|
||||
: colorValue_(ColorParam { .value = value }), resourceId_(resId) {}
|
||||
~Color() = default;
|
||||
|
||||
static Color FromARGB(uint8_t alpha, uint8_t red, uint8_t green, uint8_t blue);
|
||||
@ -95,6 +97,16 @@ public:
|
||||
return colorValue_.value;
|
||||
}
|
||||
|
||||
void SetResourceId(uint32_t id)
|
||||
{
|
||||
resourceId_ = id;
|
||||
}
|
||||
|
||||
uint32_t GetResourceId() const
|
||||
{
|
||||
return resourceId_;
|
||||
}
|
||||
|
||||
uint8_t GetAlpha() const
|
||||
{
|
||||
return colorValue_.argb.alpha;
|
||||
@ -115,6 +127,8 @@ public:
|
||||
return colorValue_.argb.blue;
|
||||
}
|
||||
|
||||
void UpdateColorByResourceId();
|
||||
|
||||
bool operator==(const Color& color) const
|
||||
{
|
||||
return colorValue_.value == color.GetValue();
|
||||
@ -139,7 +153,7 @@ public:
|
||||
|
||||
std::string ToString() const;
|
||||
|
||||
protected:
|
||||
private:
|
||||
constexpr explicit Color(ColorParam colorValue) : colorValue_(colorValue) {}
|
||||
|
||||
static double ConvertGammaToLinear(uint8_t value);
|
||||
@ -162,24 +176,7 @@ protected:
|
||||
|
||||
float CalculateBlend(float alphaLeft, float alphaRight, float valueLeft, float valueRight) const;
|
||||
ColorParam colorValue_ { .value = 0xff000000 };
|
||||
};
|
||||
|
||||
class ACE_FORCE_EXPORT DynamicColor : public Color {
|
||||
public:
|
||||
DynamicColor() {}
|
||||
DynamicColor(const Color& color);
|
||||
DynamicColor(const Color& color, std::optional<uint32_t> resId);
|
||||
DynamicColor(const Color& color, uint32_t resId);
|
||||
|
||||
void UpdateColorByResourceId();
|
||||
std::string ToString() const;
|
||||
Color ToColor() const;
|
||||
|
||||
DynamicColor& operator=(const Color& rhs);
|
||||
bool operator==(const DynamicColor& rhs) const;
|
||||
bool operator!=(const DynamicColor& rhs) const;
|
||||
|
||||
std::optional<uint32_t> resourceId = std::nullopt;
|
||||
uint32_t resourceId_ = 0;
|
||||
};
|
||||
|
||||
namespace StringUtils {
|
||||
|
@ -237,6 +237,11 @@ public:
|
||||
return blurRadius_ > 0.0 || spreadRadius_ > 0.0 || offset_ != Offset::Zero();
|
||||
}
|
||||
|
||||
void UpdateColorByResourceId()
|
||||
{
|
||||
color_.UpdateColorByResourceId();
|
||||
}
|
||||
|
||||
private:
|
||||
float lightHeight_ = LIGHT_HEIGHT;
|
||||
float lightRadius_ = LIGHT_RADIUS;
|
||||
|
@ -80,6 +80,8 @@ void TextStyle::UpdateColorByResourceId()
|
||||
{
|
||||
textColor_.UpdateColorByResourceId();
|
||||
textDecorationColor_.UpdateColorByResourceId();
|
||||
std::for_each(renderColors_.begin(), renderColors_.end(), [](Color& cl) { cl.UpdateColorByResourceId(); });
|
||||
std::for_each(textShadows_.begin(), textShadows_.end(), [](Shadow& sd) { sd.UpdateColorByResourceId(); });
|
||||
}
|
||||
|
||||
std::string TextStyle::ToString() const
|
||||
|
@ -368,11 +368,6 @@ public:
|
||||
enableVariableFontWeight_ = enableVariableFontWeight;
|
||||
}
|
||||
const Color GetTextColor() const
|
||||
{
|
||||
return textColor_.ToColor();
|
||||
}
|
||||
|
||||
const DynamicColor GetDynamicTextColor() const
|
||||
{
|
||||
return textColor_;
|
||||
}
|
||||
@ -382,11 +377,6 @@ public:
|
||||
textColor_ = textColor;
|
||||
}
|
||||
|
||||
void SetTextColor(const DynamicColor& textColor)
|
||||
{
|
||||
textColor_ = textColor;
|
||||
}
|
||||
|
||||
TextDecoration GetTextDecoration() const
|
||||
{
|
||||
return textDecoration_;
|
||||
@ -408,16 +398,11 @@ public:
|
||||
}
|
||||
|
||||
const Color GetTextDecorationColor() const
|
||||
{
|
||||
return textDecorationColor_.ToColor();
|
||||
}
|
||||
|
||||
const DynamicColor GetDynamicTextDecorationColor() const
|
||||
{
|
||||
return textDecorationColor_;
|
||||
}
|
||||
|
||||
void SetTextDecorationColor(const DynamicColor& textDecorationColor)
|
||||
void SetTextDecorationColor(const Color& textDecorationColor)
|
||||
{
|
||||
textDecorationColor_ = textDecorationColor;
|
||||
}
|
||||
@ -811,8 +796,8 @@ private:
|
||||
TextCase textCase_ { TextCase::NORMAL };
|
||||
EllipsisMode ellipsisMode_ = EllipsisMode::TAIL;
|
||||
LineBreakStrategy lineBreakStrategy_ { LineBreakStrategy::GREEDY };
|
||||
DynamicColor textColor_ { Color::BLACK };
|
||||
DynamicColor textDecorationColor_ { Color::BLACK };
|
||||
Color textColor_ { Color::BLACK };
|
||||
Color textDecorationColor_ { Color::BLACK };
|
||||
uint32_t maxLines_ = UINT32_MAX;
|
||||
int32_t variableFontWeight_ = 0;
|
||||
bool hasHeightOverride_ = false;
|
||||
|
@ -97,13 +97,13 @@ struct UpdateSpanStyle {
|
||||
updateSymbolEffectStrategy.reset();
|
||||
}
|
||||
|
||||
std::optional<DynamicColor> updateTextColor = std::nullopt;
|
||||
std::optional<Color> updateTextColor = std::nullopt;
|
||||
std::optional<CalcDimension> updateFontSize = std::nullopt;
|
||||
std::optional<FontStyle> updateItalicFontStyle = std::nullopt;
|
||||
std::optional<FontWeight> updateFontWeight = std::nullopt;
|
||||
std::optional<std::vector<std::string>> updateFontFamily = std::nullopt;
|
||||
std::optional<TextDecoration> updateTextDecoration = std::nullopt;
|
||||
std::optional<DynamicColor> updateTextDecorationColor = std::nullopt;
|
||||
std::optional<Color> updateTextDecorationColor = std::nullopt;
|
||||
std::optional<TextDecorationStyle> updateTextDecorationStyle = std::nullopt;
|
||||
std::optional<std::vector<Shadow>> updateTextShadows = std::nullopt;
|
||||
std::optional<NG::FONT_FEATURES_LIST> updateFontFeature = std::nullopt;
|
||||
@ -134,6 +134,14 @@ struct UpdateSpanStyle {
|
||||
if (updateTextDecorationColor) {
|
||||
updateTextDecorationColor->UpdateColorByResourceId();
|
||||
}
|
||||
if (updateTextShadows) {
|
||||
auto& shadows = updateTextShadows.value();
|
||||
std::for_each(shadows.begin(), shadows.end(), [](Shadow& sd) { sd.UpdateColorByResourceId(); });
|
||||
}
|
||||
if (updateSymbolColor) {
|
||||
auto& colors = updateSymbolColor.value();
|
||||
std::for_each(colors.begin(), colors.end(), [](Color& cl) { cl.UpdateColorByResourceId(); });
|
||||
}
|
||||
}
|
||||
|
||||
std::string ToString() const
|
||||
@ -240,7 +248,7 @@ struct PlaceholderOptions {
|
||||
std::optional<std::string> value;
|
||||
std::optional<FontWeight> fontWeight;
|
||||
std::optional<Dimension> fontSize;
|
||||
std::optional<DynamicColor> fontColor;
|
||||
std::optional<Color> fontColor;
|
||||
std::optional<FontStyle> fontStyle;
|
||||
std::vector<std::string> fontFamilies;
|
||||
|
||||
@ -341,8 +349,8 @@ public:
|
||||
virtual void SetTextDetectEnable(bool value) = 0;
|
||||
virtual void SetSupportPreviewText(bool value) = 0;
|
||||
virtual void SetTextDetectConfig(const TextDetectConfig& textDetectConfig) = 0;
|
||||
virtual void SetSelectedBackgroundColor(const DynamicColor& selectedColor) = 0;
|
||||
virtual void SetCaretColor(const DynamicColor& color) = 0;
|
||||
virtual void SetSelectedBackgroundColor(const Color& selectedColor) = 0;
|
||||
virtual void SetCaretColor(const Color& color) = 0;
|
||||
virtual void SetOnEditingChange(std::function<void(const bool&)>&& func) = 0;
|
||||
virtual void SetEnterKeyType(TextInputAction value) = 0;
|
||||
virtual void SetOnSubmit(std::function<void(int32_t, NG::TextFieldCommonEvent&)>&& func) = 0;
|
||||
|
@ -337,7 +337,7 @@ void RichEditorModelNG::SetTextDetectEnable(FrameNode* frameNode, bool value)
|
||||
richEditorPattern->SetTextDetectEnable(value);
|
||||
}
|
||||
|
||||
void RichEditorModelNG::SetSelectedBackgroundColor(const DynamicColor& selectedColor)
|
||||
void RichEditorModelNG::SetSelectedBackgroundColor(const Color& selectedColor)
|
||||
{
|
||||
auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
@ -346,14 +346,14 @@ void RichEditorModelNG::SetSelectedBackgroundColor(const DynamicColor& selectedC
|
||||
pattern->SetSelectedBackgroundColor(selectedColor);
|
||||
}
|
||||
|
||||
void RichEditorModelNG::SetSelectedBackgroundColor(FrameNode* frameNode, const DynamicColor& selectedColor)
|
||||
void RichEditorModelNG::SetSelectedBackgroundColor(FrameNode* frameNode, const Color& selectedColor)
|
||||
{
|
||||
auto pattern = frameNode->GetPattern<RichEditorPattern>();
|
||||
CHECK_NULL_VOID(pattern);
|
||||
pattern->SetSelectedBackgroundColor(selectedColor);
|
||||
}
|
||||
|
||||
void RichEditorModelNG::SetCaretColor(const DynamicColor& color)
|
||||
void RichEditorModelNG::SetCaretColor(const Color& color)
|
||||
{
|
||||
auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode();
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
@ -362,7 +362,7 @@ void RichEditorModelNG::SetCaretColor(const DynamicColor& color)
|
||||
pattern->SetCaretColor(color);
|
||||
}
|
||||
|
||||
void RichEditorModelNG::SetCaretColor(FrameNode* frameNode, const DynamicColor& color)
|
||||
void RichEditorModelNG::SetCaretColor(FrameNode* frameNode, const Color& color)
|
||||
{
|
||||
auto pattern = frameNode->GetPattern<RichEditorPattern>();
|
||||
CHECK_NULL_VOID(pattern);
|
||||
|
@ -41,8 +41,8 @@ public:
|
||||
void SetTextDetectEnable(bool value) override;
|
||||
void SetSupportPreviewText(bool value) override;
|
||||
void SetTextDetectConfig(const TextDetectConfig& textDetectConfig) override;
|
||||
void SetSelectedBackgroundColor(const DynamicColor& selectedColor) override;
|
||||
void SetCaretColor(const DynamicColor& color) override;
|
||||
void SetSelectedBackgroundColor(const Color& selectedColor) override;
|
||||
void SetCaretColor(const Color& color) override;
|
||||
void SetOnEditingChange(std::function<void(const bool&)>&& func) override;
|
||||
void SetOnWillChange(std::function<bool(const RichEditorChangeValue&)>&& func) override;
|
||||
void SetOnDidChange(std::function<void(const RichEditorChangeValue&)>&& func) override;
|
||||
@ -64,12 +64,12 @@ public:
|
||||
static void SetOnDidIMEInput(FrameNode* frameNode, std::function<void(const TextRange&)>&& callback);
|
||||
static void SetCopyOption(FrameNode* frameNode, CopyOptions& copyOptions);
|
||||
static void SetOnSelectionChange(FrameNode* frameNode, std::function<void(const BaseEventInfo*)>&& callback);
|
||||
static void SetCaretColor(FrameNode* frameNode, const DynamicColor& color);
|
||||
static void SetCaretColor(FrameNode* frameNode, const Color& color);
|
||||
static void SetOnSelect(FrameNode* frameNode, std::function<void(const BaseEventInfo*)>&& callback);
|
||||
static void SetOnReady(FrameNode* frameNode, std::function<void()>&& callback);
|
||||
static void SetOnDeleteComplete(FrameNode* frameNode, std::function<void()>&& callback);
|
||||
static void SetOnEditingChange(FrameNode* frameNode, std::function<void(const bool&)>&& callback);
|
||||
static void SetSelectedBackgroundColor(FrameNode* frameNode, const DynamicColor& selectedColor);
|
||||
static void SetSelectedBackgroundColor(FrameNode* frameNode, const Color& selectedColor);
|
||||
static void SetOnPaste(FrameNode* frameNode, std::function<void(NG::TextCommonEvent&)>&& func);
|
||||
static void SetOnCut(FrameNode* frameNode, std::function<void(NG::TextCommonEvent&)>&& func);
|
||||
static void SetOnCopy(FrameNode* frameNode, std::function<void(NG::TextCommonEvent&)>&& func);
|
||||
|
@ -910,7 +910,7 @@ int32_t RichEditorPattern::AddTextSpanOperation(
|
||||
spanNode->UpdateContent(options.value);
|
||||
spanNode->AddPropertyInfo(PropertyInfo::NONE);
|
||||
if (options.style.has_value()) {
|
||||
spanNode->UpdateTextColor(options.style.value().GetDynamicTextColor());
|
||||
spanNode->UpdateTextColor(options.style.value().GetTextColor());
|
||||
spanNode->AddPropertyInfo(PropertyInfo::FONTCOLOR);
|
||||
spanNode->UpdateFontSize(options.style.value().GetFontSize());
|
||||
spanNode->AddPropertyInfo(PropertyInfo::FONTSIZE);
|
||||
@ -922,7 +922,7 @@ int32_t RichEditorPattern::AddTextSpanOperation(
|
||||
spanNode->AddPropertyInfo(PropertyInfo::FONTFAMILY);
|
||||
spanNode->UpdateTextDecoration(options.style.value().GetTextDecoration());
|
||||
spanNode->AddPropertyInfo(PropertyInfo::TEXTDECORATION);
|
||||
spanNode->UpdateTextDecorationColor(options.style.value().GetDynamicTextDecorationColor());
|
||||
spanNode->UpdateTextDecorationColor(options.style.value().GetTextDecorationColor());
|
||||
spanNode->AddPropertyInfo(PropertyInfo::NONE);
|
||||
spanNode->UpdateTextDecorationStyle(options.style.value().GetTextDecorationStyle());
|
||||
spanNode->AddPropertyInfo(PropertyInfo::NONE);
|
||||
@ -1662,7 +1662,7 @@ void RichEditorPattern::UpdateTextStyle(
|
||||
CHECK_NULL_VOID(host);
|
||||
UpdateFontFeatureTextStyle(spanNode, updateSpanStyle, textStyle);
|
||||
if (updateSpanStyle.updateTextColor.has_value()) {
|
||||
spanNode->UpdateTextColor(textStyle.GetDynamicTextColor());
|
||||
spanNode->UpdateTextColor(textStyle.GetTextColor());
|
||||
spanNode->GetSpanItem()->useThemeFontColor = false;
|
||||
spanNode->AddPropertyInfo(PropertyInfo::FONTCOLOR);
|
||||
}
|
||||
@ -1708,7 +1708,7 @@ void RichEditorPattern::UpdateDecoration(
|
||||
spanNode->AddPropertyInfo(PropertyInfo::TEXTDECORATION);
|
||||
}
|
||||
if (updateSpanStyle.updateTextDecorationColor.has_value()) {
|
||||
spanNode->UpdateTextDecorationColor(textStyle.GetDynamicTextDecorationColor());
|
||||
spanNode->UpdateTextDecorationColor(textStyle.GetTextDecorationColor());
|
||||
spanNode->AddPropertyInfo(PropertyInfo::NONE);
|
||||
}
|
||||
if (updateSpanStyle.updateTextDecorationStyle.has_value()) {
|
||||
@ -1974,7 +1974,7 @@ void RichEditorPattern::SetSelectSpanStyle(int32_t start, int32_t end, KeyCode c
|
||||
spanStyle = spanTextStyle.value();
|
||||
}
|
||||
HandleSelectFontStyleWrapper(code, spanStyle);
|
||||
updateSpanStyle.updateTextColor = spanStyle.GetDynamicTextColor();
|
||||
updateSpanStyle.updateTextColor = spanStyle.GetTextColor();
|
||||
updateSpanStyle.updateFontSize = spanStyle.GetFontSize();
|
||||
updateSpanStyle.updateItalicFontStyle = spanStyle.GetFontStyle();
|
||||
updateSpanStyle.updateFontWeight = spanStyle.GetFontWeight();
|
||||
@ -8401,7 +8401,7 @@ bool RichEditorPattern::SetPlaceholder(std::vector<std::list<RefPtr<SpanItem>>>&
|
||||
return true;
|
||||
}
|
||||
|
||||
DynamicColor RichEditorPattern::GetCaretColor()
|
||||
Color RichEditorPattern::GetCaretColor()
|
||||
{
|
||||
if (caretColor_.has_value()) {
|
||||
return caretColor_.value();
|
||||
@ -8413,9 +8413,9 @@ DynamicColor RichEditorPattern::GetCaretColor()
|
||||
return richEditorTheme->GetCaretColor();
|
||||
}
|
||||
|
||||
DynamicColor RichEditorPattern::GetSelectedBackgroundColor()
|
||||
Color RichEditorPattern::GetSelectedBackgroundColor()
|
||||
{
|
||||
DynamicColor selectedBackgroundColor;
|
||||
Color selectedBackgroundColor;
|
||||
if (selectedBackgroundColor_.has_value()) {
|
||||
selectedBackgroundColor = selectedBackgroundColor_.value();
|
||||
} else {
|
||||
|
@ -784,19 +784,19 @@ public:
|
||||
|
||||
void OnVirtualKeyboardAreaChanged() override;
|
||||
|
||||
void SetCaretColor(const DynamicColor& caretColor)
|
||||
void SetCaretColor(const Color& caretColor)
|
||||
{
|
||||
caretColor_ = caretColor;
|
||||
}
|
||||
|
||||
DynamicColor GetCaretColor();
|
||||
Color GetCaretColor();
|
||||
|
||||
void SetSelectedBackgroundColor(const DynamicColor& selectedBackgroundColor)
|
||||
void SetSelectedBackgroundColor(const Color& selectedBackgroundColor)
|
||||
{
|
||||
selectedBackgroundColor_ = selectedBackgroundColor;
|
||||
}
|
||||
|
||||
DynamicColor GetSelectedBackgroundColor();
|
||||
Color GetSelectedBackgroundColor();
|
||||
|
||||
void SetCustomKeyboardOption(bool supportAvoidance);
|
||||
void StopEditing();
|
||||
@ -1269,8 +1269,8 @@ private:
|
||||
std::optional<struct UpdateSpanStyle> typingStyle_;
|
||||
std::optional<TextStyle> typingTextStyle_;
|
||||
std::list<ResultObject> dragResultObjects_;
|
||||
std::optional<DynamicColor> caretColor_;
|
||||
std::optional<DynamicColor> selectedBackgroundColor_;
|
||||
std::optional<Color> caretColor_;
|
||||
std::optional<Color> selectedBackgroundColor_;
|
||||
std::function<void()> customKeyboardBuilder_;
|
||||
std::function<void(int32_t)> caretChangeListener_;
|
||||
RefPtr<OverlayManager> keyboardOverlay_;
|
||||
|
@ -494,13 +494,13 @@ public:
|
||||
}
|
||||
|
||||
DEFINE_SPAN_FONT_STYLE_ITEM(FontSize, Dimension);
|
||||
DEFINE_SPAN_FONT_STYLE_ITEM(TextColor, DynamicColor);
|
||||
DEFINE_SPAN_FONT_STYLE_ITEM(TextColor, Color);
|
||||
DEFINE_SPAN_FONT_STYLE_ITEM(ItalicFontStyle, Ace::FontStyle);
|
||||
DEFINE_SPAN_FONT_STYLE_ITEM(FontWeight, FontWeight);
|
||||
DEFINE_SPAN_FONT_STYLE_ITEM(FontFamily, std::vector<std::string>);
|
||||
DEFINE_SPAN_FONT_STYLE_ITEM(TextDecoration, TextDecoration);
|
||||
DEFINE_SPAN_FONT_STYLE_ITEM(TextDecorationStyle, TextDecorationStyle);
|
||||
DEFINE_SPAN_FONT_STYLE_ITEM(TextDecorationColor, DynamicColor);
|
||||
DEFINE_SPAN_FONT_STYLE_ITEM(TextDecorationColor, Color);
|
||||
DEFINE_SPAN_FONT_STYLE_ITEM(FontFeature, FONT_FEATURES_LIST);
|
||||
DEFINE_SPAN_FONT_STYLE_ITEM(TextCase, TextCase);
|
||||
DEFINE_SPAN_FONT_STYLE_ITEM(TextShadow, std::vector<Shadow>);
|
||||
|
@ -67,7 +67,7 @@ public:
|
||||
|
||||
ACE_DEFINE_PROPERTY_GROUP(FontStyle, FontStyle);
|
||||
ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP(FontStyle, FontSize, Dimension, PROPERTY_UPDATE_MEASURE);
|
||||
ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP(FontStyle, TextColor, DynamicColor, PROPERTY_UPDATE_MEASURE_SELF);
|
||||
ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP(FontStyle, TextColor, Color, PROPERTY_UPDATE_MEASURE_SELF);
|
||||
ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP(FontStyle, TextShadow, std::vector<Shadow>, PROPERTY_UPDATE_MEASURE);
|
||||
ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP(FontStyle, ItalicFontStyle, Ace::FontStyle, PROPERTY_UPDATE_MEASURE);
|
||||
ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP(FontStyle, FontWeight, FontWeight, PROPERTY_UPDATE_MEASURE);
|
||||
@ -112,7 +112,7 @@ public:
|
||||
ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP_ITEM(
|
||||
PlaceholderFontStyle, FontSize, PlaceholderFontSize, Dimension, PROPERTY_UPDATE_MEASURE);
|
||||
ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP_ITEM(
|
||||
PlaceholderFontStyle, TextColor, PlaceholderTextColor, DynamicColor, PROPERTY_UPDATE_MEASURE_SELF);
|
||||
PlaceholderFontStyle, TextColor, PlaceholderTextColor, Color, PROPERTY_UPDATE_MEASURE_SELF);
|
||||
ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP_ITEM(
|
||||
PlaceholderFontStyle, ItalicFontStyle, PlaceholderItalicFontStyle, Ace::FontStyle, PROPERTY_UPDATE_MEASURE);
|
||||
ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP_ITEM(
|
||||
|
@ -196,4 +196,22 @@ std::string GetSymbolEffectOptionsInJson(const std::optional<SymbolEffectOptions
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
void FontStyle::UpdateColorByResourceId()
|
||||
{
|
||||
if (propTextColor) {
|
||||
propTextColor->UpdateColorByResourceId();
|
||||
}
|
||||
if (propTextDecorationColor) {
|
||||
propTextDecorationColor->UpdateColorByResourceId();
|
||||
}
|
||||
if (propTextShadow) {
|
||||
auto& shadows = propTextShadow.value();
|
||||
std::for_each(shadows.begin(), shadows.end(), [](Shadow& sd) { sd.UpdateColorByResourceId(); });
|
||||
}
|
||||
if (propSymbolColorList) {
|
||||
auto& colors = propSymbolColorList.value();
|
||||
std::for_each(colors.begin(), colors.end(), [](Color& cl) { cl.UpdateColorByResourceId(); });
|
||||
}
|
||||
}
|
||||
} // namespace OHOS::Ace::NG
|
||||
|
@ -151,7 +151,7 @@ constexpr Dimension TEXT_DEFAULT_FONT_SIZE = 16.0_fp;
|
||||
using FONT_FEATURES_LIST = std::list<std::pair<std::string, int32_t>>;
|
||||
struct FontStyle {
|
||||
ACE_DEFINE_PROPERTY_GROUP_ITEM(FontSize, Dimension);
|
||||
ACE_DEFINE_PROPERTY_GROUP_ITEM(TextColor, DynamicColor);
|
||||
ACE_DEFINE_PROPERTY_GROUP_ITEM(TextColor, Color);
|
||||
ACE_DEFINE_PROPERTY_GROUP_ITEM(TextShadow, std::vector<Shadow>);
|
||||
ACE_DEFINE_PROPERTY_GROUP_ITEM(ItalicFontStyle, Ace::FontStyle);
|
||||
ACE_DEFINE_PROPERTY_GROUP_ITEM(FontWeight, FontWeight);
|
||||
@ -160,13 +160,13 @@ struct FontStyle {
|
||||
ACE_DEFINE_PROPERTY_GROUP_ITEM(FontFamily, std::vector<std::string>);
|
||||
ACE_DEFINE_PROPERTY_GROUP_ITEM(FontFeature, FONT_FEATURES_LIST);
|
||||
ACE_DEFINE_PROPERTY_GROUP_ITEM(TextDecoration, TextDecoration);
|
||||
ACE_DEFINE_PROPERTY_GROUP_ITEM(TextDecorationColor, DynamicColor);
|
||||
ACE_DEFINE_PROPERTY_GROUP_ITEM(TextDecorationColor, Color);
|
||||
ACE_DEFINE_PROPERTY_GROUP_ITEM(TextDecorationStyle, TextDecorationStyle);
|
||||
ACE_DEFINE_PROPERTY_GROUP_ITEM(TextCase, TextCase);
|
||||
ACE_DEFINE_PROPERTY_GROUP_ITEM(AdaptMinFontSize, Dimension);
|
||||
ACE_DEFINE_PROPERTY_GROUP_ITEM(AdaptMaxFontSize, Dimension);
|
||||
ACE_DEFINE_PROPERTY_GROUP_ITEM(LetterSpacing, Dimension);
|
||||
ACE_DEFINE_PROPERTY_GROUP_ITEM(ForegroundColor, DynamicColor);
|
||||
ACE_DEFINE_PROPERTY_GROUP_ITEM(ForegroundColor, Color);
|
||||
ACE_DEFINE_PROPERTY_GROUP_ITEM(SymbolColorList, std::vector<Color>);
|
||||
ACE_DEFINE_PROPERTY_GROUP_ITEM(SymbolRenderingStrategy, uint32_t);
|
||||
ACE_DEFINE_PROPERTY_GROUP_ITEM(SymbolEffectStrategy, uint32_t);
|
||||
@ -174,15 +174,7 @@ struct FontStyle {
|
||||
ACE_DEFINE_PROPERTY_GROUP_ITEM(MinFontScale, float);
|
||||
ACE_DEFINE_PROPERTY_GROUP_ITEM(MaxFontScale, float);
|
||||
|
||||
void UpdateColorByResourceId()
|
||||
{
|
||||
if (propTextColor) {
|
||||
propTextColor->UpdateColorByResourceId();
|
||||
}
|
||||
if (propTextDecorationColor) {
|
||||
propTextDecorationColor->UpdateColorByResourceId();
|
||||
}
|
||||
}
|
||||
void UpdateColorByResourceId();
|
||||
};
|
||||
|
||||
struct TextLineStyle {
|
||||
|
@ -490,7 +490,7 @@ void SetRichEditorPlaceholder(ArkUINodeHandle node, ArkUI_CharPtr* stringParamet
|
||||
if (SetRichEditorPlaceholderValue(valuesArray, 3, valuesCount, colorResourceId) && // 3: colorResourceId
|
||||
GreatOrEqual(colorResourceId, 0.0)) {
|
||||
fontColor.SetValue(static_cast<ArkUI_Uint32>(result));
|
||||
options.fontColor = DynamicColor(fontColor, static_cast<ArkUI_Uint32>(colorResourceId));
|
||||
options.fontColor = fontColor;
|
||||
} else {
|
||||
fontColor.SetValue(static_cast<ArkUI_Uint32>(result));
|
||||
options.fontColor = fontColor;
|
||||
|
Loading…
Reference in New Issue
Block a user