Make some values scriptable

color radius
color left width
color right width
color top width
color bottom width
font shadow displacement x
font shadow displacement y
font shadow blur
This commit is contained in:
GenevensiS
2025-07-14 00:23:45 +02:00
committed by GitHub
parent dafd1a4f19
commit 58ab8f3636
7 changed files with 51 additions and 24 deletions
+17 -1
View File
@@ -74,9 +74,25 @@ IMPLEMENT_REFLECTION(ColorStyle) {
}
int ColorStyle::update(Context& ctx) {
return Style::update(ctx);
int changed = 0;
changed |= radius .update(ctx) * CHANGE_OTHER;
changed |= left_width .update(ctx) * CHANGE_OTHER;
changed |= right_width .update(ctx) * CHANGE_OTHER;
changed |= top_width .update(ctx) * CHANGE_OTHER;
changed |= bottom_width.update(ctx) * CHANGE_OTHER;
changed |= Style::update(ctx);
return changed;
}
void ColorStyle::checkContentDependencies(Context& ctx, const Dependency& dep) const {
radius .initDependencies(ctx, dep);
left_width .initDependencies(ctx, dep);
right_width .initDependencies(ctx, dep);
top_width .initDependencies(ctx, dep);
bottom_width.initDependencies(ctx, dep);
Style::checkContentDependencies(ctx, dep);
}
// ----------------------------------------------------------------------------- : ColorValue
ColorValue::ColorValue(const ColorFieldP& field)
+9 -7
View File
@@ -56,14 +56,16 @@ public:
ColorStyle(const ColorFieldP& field);
DECLARE_STYLE_TYPE(Color);
double radius; ///< Radius of round corners
double left_width; ///< Width of the colored region on the left side
double right_width; ///< Width of the colored region on the right side
double top_width; ///< Width of the colored region on the top side
double bottom_width; ///< Width of the colored region on the bottom side
ImageCombine combine; ///< How to combine image with the background
Scriptable<double> radius; ///< Radius of round corners
Scriptable<double> left_width; ///< Width of the colored region on the left side
Scriptable<double> right_width; ///< Width of the colored region on the right side
Scriptable<double> top_width; ///< Width of the colored region on the top side
Scriptable<double> bottom_width; ///< Width of the colored region on the bottom side
ImageCombine combine; ///< How to combine image with the background
int update(Context&) override;
int update(Context&) override;
void checkContentDependencies(Context&, const Dependency&) const override;
};
// ----------------------------------------------------------------------------- : ColorValue
+15 -7
View File
@@ -21,7 +21,8 @@ Font::Font()
, scale_down_to(100000)
, max_stretch(1.0)
, color(Color(0,0,0))
, shadow_displacement(0,0)
, shadow_displacement_x(0)
, shadow_displacement_y(0)
, shadow_blur(0)
, separator_color(Color(0,0,0,128))
, flags(FONT_NORMAL)
@@ -89,7 +90,10 @@ bool Font::update(Context& ctx) {
changes |= style .update(ctx);
changes |= underline .update(ctx);
changes |= color .update(ctx);
changes |= shadow_color.update(ctx);
changes |= shadow_color .update(ctx);
changes |= shadow_displacement_x.update(ctx);
changes |= shadow_displacement_y.update(ctx);
changes |= shadow_blur .update(ctx);
flags = (flags & ~FONT_BOLD & ~FONT_ITALIC)
| (weight() == _("bold") ? FONT_BOLD : FONT_NORMAL)
| (style() == _("italic") ? FONT_ITALIC : FONT_NORMAL);
@@ -103,7 +107,10 @@ void Font::initDependencies(Context& ctx, const Dependency& dep) const {
style .initDependencies(ctx, dep);
underline .initDependencies(ctx, dep);
color .initDependencies(ctx, dep);
shadow_color.initDependencies(ctx, dep);
shadow_color .initDependencies(ctx, dep);
shadow_displacement_x.initDependencies(ctx, dep);
shadow_displacement_y.initDependencies(ctx, dep);
shadow_blur .initDependencies(ctx, dep);
}
FontP Font::make(int add_flags, bool add_underline, String const* other_family, Color const* other_color, double const* other_size) const {
@@ -121,8 +128,9 @@ FontP Font::make(int add_flags, bool add_underline, String const* other_family,
}
if (add_flags & FONT_SOFT) {
f->color = f->separator_color;
f->shadow_displacement = RealSize(0,0); // no shadow
}
f->shadow_displacement_x = 0; // no shadow
f->shadow_displacement_y = 0; // no shadow
}
if (add_underline) {
f->underline = true;
}
@@ -185,8 +193,8 @@ IMPLEMENT_REFLECTION_NO_SCRIPT(Font) {
REFLECT(color);
REFLECT(scale_down_to);
REFLECT(max_stretch);
REFLECT_N("shadow_displacement_x", shadow_displacement.width);
REFLECT_N("shadow_displacement_y", shadow_displacement.height);
REFLECT(shadow_displacement_x);
REFLECT(shadow_displacement_y);
REFLECT(shadow_color);
REFLECT(shadow_blur);
REFLECT(separator_color);
+4 -3
View File
@@ -42,8 +42,9 @@ public:
double max_stretch; ///< How much should the font be stretched before scaling down?
Scriptable<Color> color; ///< Color to use
Scriptable<Color> shadow_color; ///< Color for shadow
RealSize shadow_displacement; ///< Position of the shadow
double shadow_blur; ///< Blur radius of the shadow
Scriptable<double> shadow_displacement_x;///< Position of the shadow
Scriptable<double> shadow_displacement_y;///< Position of the shadow
Scriptable<double> shadow_blur; ///< Blur radius of the shadow
Color separator_color; ///< Color for <sep> text
int flags; ///< FontFlags for this font
@@ -61,7 +62,7 @@ public:
/// Does this font have a shadow?
inline bool hasShadow() const {
return shadow_displacement.width != 0 || shadow_displacement.height != 0;
return shadow_displacement_x != 0.0 || shadow_displacement_y != 0.0;
}
/// Add style to a font, and optionally change the font family, color and size