mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2025-02-22 05:34:53 +00:00
commit
f9bfa78b39
@ -22,7 +22,7 @@
|
||||
#include "core/components/theme/theme_constants_defines.h"
|
||||
|
||||
namespace OHOS::Ace {
|
||||
|
||||
constexpr float DRAG_BACKGROUND_OPACITY = 0.95f;
|
||||
/**
|
||||
* TextTheme defines color and styles of ThemeComponent. TextTheme should be built
|
||||
* using TextTheme::Builder.
|
||||
@ -63,6 +63,11 @@ public:
|
||||
theme->selectedColor_ = pattern->GetAttr<Color>(PATTERN_BG_COLOR_SELECTED, Color(0x33007dff));
|
||||
auto draggable = pattern->GetAttr<std::string>("draggable", "0");
|
||||
theme->draggable_ = StringUtils::StringToInt(draggable);
|
||||
auto dragBackgroundColor = pattern->GetAttr<Color>("drag_background_color", Color::WHITE);
|
||||
if (SystemProperties::GetColorMode() == ColorMode::DARK) {
|
||||
dragBackgroundColor = dragBackgroundColor.ChangeOpacity(DRAG_BACKGROUND_OPACITY);
|
||||
}
|
||||
theme->dragBackgroundColor_ = dragBackgroundColor;
|
||||
constexpr double childMinSize = 20.0;
|
||||
theme->linearSplitChildMinSize_ = pattern->GetAttr<double>(LINEAR_SPLIT_CHILD_MIN_SIZE, childMinSize);
|
||||
theme->isTextFadeout_ = pattern->GetAttr<std::string>("text_fadeout_enable", "") == "true";
|
||||
@ -109,12 +114,18 @@ public:
|
||||
return isShowHandle_;
|
||||
}
|
||||
|
||||
const Color& GetDragBackgroundColor() const
|
||||
{
|
||||
return dragBackgroundColor_;
|
||||
}
|
||||
|
||||
protected:
|
||||
TextTheme() = default;
|
||||
|
||||
private:
|
||||
TextStyle textStyle_;
|
||||
Color selectedColor_;
|
||||
Color dragBackgroundColor_ = Color::WHITE;
|
||||
bool draggable_ = false;
|
||||
double linearSplitChildMinSize_ = 20.0;
|
||||
bool isTextFadeout_ = false;
|
||||
|
@ -38,7 +38,7 @@ void TextDragOverlayModifier::onDraw(DrawingContext& context)
|
||||
auto pattern = DynamicCast<TextDragPattern>(pattern_.Upgrade());
|
||||
CHECK_NULL_VOID(pattern);
|
||||
auto& canvas = context.canvas;
|
||||
Color color(TEXT_DRAG_COLOR_BG);
|
||||
Color color = pattern->GetDragBackgroundColor();
|
||||
RSBrush brush;
|
||||
brush.SetColor(ToRSColor(color));
|
||||
brush.SetAntiAlias(true);
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <algorithm>
|
||||
|
||||
#include "base/utils/utils.h"
|
||||
#include "core/components/text/text_theme.h"
|
||||
#include "core/components_ng/pattern/text/text_pattern.h"
|
||||
#include "core/components_ng/pattern/text_drag/text_drag_base.h"
|
||||
#include "core/components_ng/render/drawing.h"
|
||||
@ -316,4 +317,13 @@ void TextDragPattern::CalculateLine(std::vector<TextPoint>& points, std::shared_
|
||||
path->LineTo(crossPoint.x, crossPoint.y);
|
||||
}
|
||||
}
|
||||
|
||||
Color TextDragPattern::GetDragBackgroundColor()
|
||||
{
|
||||
auto pipeline = PipelineContext::GetCurrentContext();
|
||||
CHECK_NULL_RETURN(pipeline, Color(TEXT_DRAG_COLOR_BG));
|
||||
auto textTheme = pipeline->GetTheme<TextTheme>();
|
||||
CHECK_NULL_RETURN(textTheme, Color(TEXT_DRAG_COLOR_BG));
|
||||
return textTheme->GetDragBackgroundColor();
|
||||
}
|
||||
} // namespace OHOS::Ace::NG
|
||||
|
@ -211,6 +211,7 @@ public:
|
||||
return TEXT_DRAG_RADIUS;
|
||||
}
|
||||
|
||||
Color GetDragBackgroundColor();
|
||||
protected:
|
||||
static TextDragData CalculateTextDragData(RefPtr<TextDragBase>& pattern, RefPtr<FrameNode>& dragNode);
|
||||
static RectF GetHandler(const bool isLeftHandler, const std::vector<RectF> boxes, const RectF contentRect,
|
||||
|
Loading…
x
Reference in New Issue
Block a user