mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
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:
+3
-3
@@ -16,9 +16,9 @@ A reference to a normal [[type:font]] for drawing text.
|
||||
| @underline@ [[type:scriptable]] [[type:boolean]] @false@ Should the font be underlined?
|
||||
| @color@ [[type:scriptable]] [[type:color]] @rgb(0,0,0)@ What color should text be drawn in?
|
||||
| @shadow color@ [[type:scriptable]] [[type:color]] @"transparent"@ Color for a shadow below the text.
|
||||
| @shadow displacement x@ [[type:double]] @0@ Relative position of the shadow in pixels.
|
||||
| @shadow displacement y@ [[type:double]] @0@ ^^^
|
||||
| @shadow blur@ [[type:double]] @0@ How much should the shadow be blurred?
|
||||
| @shadow displacement x@ [[type:scriptable]] [[type:double]] @0@ Relative position of the shadow in pixels.
|
||||
| @shadow displacement y@ [[type:scriptable]] [[type:double]] @0@ ^^^
|
||||
| @shadow blur@ [[type:scriptable]] [[type:double]] @0@ How much should the shadow be blurred?
|
||||
| @separator color@ [[type:color]] @rgba(0,0,0,128)@ Color for @<sep-soft>@ tags inserted by the [[fun:combined_editor]] function.
|
||||
|
||||
--Example--
|
||||
|
||||
+2
-2
@@ -140,8 +140,8 @@ The rest of the properties depend on the type of [[type:field]] this style is fo
|
||||
| ^^^ @font@ [[type:font]] Font to use for rendering text.
|
||||
|
||||
! <<< <<< <<< <<<
|
||||
| @"color"@ @radius@ [[type:double]] @0@ Radius of rounded corners for the box in pixels.
|
||||
| ^^^ @left width@ [[type:double]] ∞ Draw only this many pixels from the side, creating a box with a hole in it, or a card border.
|
||||
| @"color"@ @radius@ [[type:scriptable]] [[type:double]] @0@ Radius of rounded corners for the box in pixels.
|
||||
| ^^^ @left width@ [[type:scriptable]] [[type:double]] ∞ Draw only this many pixels from the side, creating a box with a hole in it, or a card border.
|
||||
| ^^^ @right width@ ^^^ ^^^ ^^^
|
||||
| ^^^ @top width@ ^^^ ^^^ ^^^
|
||||
| ^^^ @bottom width@ ^^^ ^^^ ^^^
|
||||
|
||||
@@ -74,7 +74,23 @@ 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
|
||||
|
||||
@@ -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;
|
||||
|
||||
void checkContentDependencies(Context&, const Dependency&) const override;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : ColorValue
|
||||
|
||||
+14
-6
@@ -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,7 +128,8 @@ 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
@@ -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
|
||||
|
||||
@@ -219,7 +219,7 @@ void RotatedDC::DrawText(const String& text, const RealPoint& pos, Color color,
|
||||
}
|
||||
|
||||
void RotatedDC::DrawTextWithShadow(const String& text, const Font& font, const RealPoint& pos, double scale, double stretch) {
|
||||
DrawText(text, pos + font.shadow_displacement * scale, font.shadow_color, font.shadow_blur * scale, 1, stretch);
|
||||
DrawText(text, pos + RealSize(font.shadow_displacement_x, font.shadow_displacement_y) * scale, font.shadow_color, font.shadow_blur * scale, 1, stretch);
|
||||
DrawText(text, pos, font.color, 0, 1, stretch);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user