mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-12 21:47:00 -04:00
Remove AColor class, because wxColour now supports alpha values.
This commit is contained in:
+3
-3
@@ -17,10 +17,10 @@ Font::Font()
|
|||||||
, underline(false)
|
, underline(false)
|
||||||
, scale_down_to(100000)
|
, scale_down_to(100000)
|
||||||
, max_stretch(1.0)
|
, max_stretch(1.0)
|
||||||
, color(AColor(0,0,0))
|
, color(Color(0,0,0))
|
||||||
, shadow_displacement(0,0)
|
, shadow_displacement(0,0)
|
||||||
, shadow_blur(0)
|
, shadow_blur(0)
|
||||||
, separator_color(AColor(0,0,0,128))
|
, separator_color(Color(0,0,0,128))
|
||||||
, flags(FONT_NORMAL)
|
, flags(FONT_NORMAL)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ void Font::initDependencies(Context& ctx, const Dependency& dep) const {
|
|||||||
shadow_color.initDependencies(ctx, dep);
|
shadow_color.initDependencies(ctx, dep);
|
||||||
}
|
}
|
||||||
|
|
||||||
FontP Font::make(int add_flags, AColor* other_color, double* other_size) const {
|
FontP Font::make(int add_flags, Color* other_color, double* other_size) const {
|
||||||
FontP f(new Font(*this));
|
FontP f(new Font(*this));
|
||||||
f->flags |= add_flags;
|
f->flags |= add_flags;
|
||||||
if (add_flags & FONT_CODE_STRING) {
|
if (add_flags & FONT_CODE_STRING) {
|
||||||
|
|||||||
+13
-13
@@ -34,19 +34,19 @@ enum FontFlags
|
|||||||
/** Contains additional information about scaling, color and shadow */
|
/** Contains additional information about scaling, color and shadow */
|
||||||
class Font : public IntrusivePtrBase<Font> {
|
class Font : public IntrusivePtrBase<Font> {
|
||||||
public:
|
public:
|
||||||
Scriptable<String> name; ///< Name of the font
|
Scriptable<String> name; ///< Name of the font
|
||||||
Scriptable<String> italic_name; ///< Font name for italic text (optional)
|
Scriptable<String> italic_name; ///< Font name for italic text (optional)
|
||||||
Scriptable<double> size; ///< Size of the font
|
Scriptable<double> size; ///< Size of the font
|
||||||
Scriptable<String> weight, style; ///< Weight and style of the font (bold/italic)
|
Scriptable<String> weight, style; ///< Weight and style of the font (bold/italic)
|
||||||
Scriptable<bool> underline; ///< Underlined?
|
Scriptable<bool> underline; ///< Underlined?
|
||||||
double scale_down_to; ///< Smallest size to scale down to
|
double scale_down_to; ///< Smallest size to scale down to
|
||||||
double max_stretch; ///< How much should the font be stretched before scaling down?
|
double max_stretch; ///< How much should the font be stretched before scaling down?
|
||||||
Scriptable<AColor> color; ///< Color to use
|
Scriptable<Color> color; ///< Color to use
|
||||||
Scriptable<AColor> shadow_color; ///< Color for shadow
|
Scriptable<Color> shadow_color; ///< Color for shadow
|
||||||
RealSize shadow_displacement; ///< Position of the shadow
|
RealSize shadow_displacement; ///< Position of the shadow
|
||||||
double shadow_blur; ///< Blur radius of the shadow
|
double shadow_blur; ///< Blur radius of the shadow
|
||||||
AColor separator_color; ///< Color for <sep> text
|
Color separator_color; ///< Color for <sep> text
|
||||||
int flags; ///< FontFlags for this font
|
int flags; ///< FontFlags for this font
|
||||||
|
|
||||||
Font();
|
Font();
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ class Font : public IntrusivePtrBase<Font> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Add style to a font, and optionally change the color and size
|
/// Add style to a font, and optionally change the color and size
|
||||||
FontP make(int add_flags, AColor* other_color, double* other_size) const;
|
FontP make(int add_flags, Color* other_color, double* other_size) const;
|
||||||
|
|
||||||
/// Convert this font to a wxFont
|
/// Convert this font to a wxFont
|
||||||
wxFont toWxFont(double scale) const;
|
wxFont toWxFont(double scale) const;
|
||||||
|
|||||||
@@ -736,7 +736,7 @@ KeywordParamValue::operator String() const {
|
|||||||
KeywordParamValue::operator int() const { return *to_script(value); } // a bit of a hack
|
KeywordParamValue::operator int() const { return *to_script(value); } // a bit of a hack
|
||||||
KeywordParamValue::operator double() const { return *to_script(value); }
|
KeywordParamValue::operator double() const { return *to_script(value); }
|
||||||
KeywordParamValue::operator bool() const { return *to_script(value); }
|
KeywordParamValue::operator bool() const { return *to_script(value); }
|
||||||
KeywordParamValue::operator AColor() const { return *to_script(value); }
|
KeywordParamValue::operator Color() const { return *to_script(value); }
|
||||||
int KeywordParamValue::itemCount() const { return to_script(value)->itemCount(); }
|
int KeywordParamValue::itemCount() const { return to_script(value)->itemCount(); }
|
||||||
|
|
||||||
ScriptValueP KeywordParamValue::getMember(const String& name) const {
|
ScriptValueP KeywordParamValue::getMember(const String& name) const {
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ class KeywordParamValue : public ScriptValue {
|
|||||||
virtual operator int() const;
|
virtual operator int() const;
|
||||||
virtual operator bool() const;
|
virtual operator bool() const;
|
||||||
virtual operator double() const;
|
virtual operator double() const;
|
||||||
virtual operator AColor() const;
|
virtual operator Color() const;
|
||||||
virtual int itemCount() const;
|
virtual int itemCount() const;
|
||||||
virtual ScriptValueP getMember(const String& name) const;
|
virtual ScriptValueP getMember(const String& name) const;
|
||||||
};
|
};
|
||||||
|
|||||||
+12
-24
@@ -13,47 +13,34 @@
|
|||||||
|
|
||||||
template <> void Reader::handle(Color& col) {
|
template <> void Reader::handle(Color& col) {
|
||||||
col = parse_color(getValue());
|
col = parse_color(getValue());
|
||||||
if (!col.Ok()) col = *wxBLACK;
|
if (!col.Ok()) col = Color(0,0,0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <> void Reader::handle(AColor& col) {
|
template <> void Writer::handle(const Color& col) {
|
||||||
col = parse_acolor(getValue());
|
handle(format_color(col));
|
||||||
if (!col.Ok()) col = AColor(0,0,0,0);
|
|
||||||
}
|
|
||||||
template <> void Writer::handle(const AColor& col) {
|
|
||||||
handle(format_acolor(col));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Color parse_color(const String& v) {
|
Color parse_color(const String& v) {
|
||||||
UInt r,g,b;
|
|
||||||
if (wxSscanf(v.c_str(),_("rgb(%u,%u,%u)"),&r,&g,&b)) {
|
|
||||||
return Color(r, g, b);
|
|
||||||
} else {
|
|
||||||
return Color(v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AColor parse_acolor(const String& v) {
|
|
||||||
UInt r,g,b,a;
|
UInt r,g,b,a;
|
||||||
if (wxSscanf(v.c_str(),_("rgb(%u,%u,%u)"),&r,&g,&b)) {
|
if (wxSscanf(v.c_str(),_("rgb(%u,%u,%u)"),&r,&g,&b)) {
|
||||||
return AColor(r, g, b);
|
return Color(r, g, b);
|
||||||
} else if (wxSscanf(v.c_str(),_("rgba(%u,%u,%u,%u)"),&r,&g,&b,&a)) {
|
} else if (wxSscanf(v.c_str(),_("rgba(%u,%u,%u,%u)"),&r,&g,&b,&a)) {
|
||||||
return AColor(r, g, b, a);
|
return Color(r, g, b, a);
|
||||||
} else if (v == _("transparent")) {
|
} else if (v == _("transparent")) {
|
||||||
return AColor(0,0,0,0);
|
return Color(0,0,0,0);
|
||||||
} else {
|
} else {
|
||||||
return Color(v);
|
return Color(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String format_acolor(AColor col) {
|
String format_color(Color col) {
|
||||||
if (col.alpha == 255) {
|
if (col.Alpha() == 255) {
|
||||||
return String::Format(_("rgb(%u,%u,%u)"), col.Red(), col.Green(), col.Blue());
|
return String::Format(_("rgb(%u,%u,%u)"), col.Red(), col.Green(), col.Blue());
|
||||||
} else if (col.alpha == 0) {
|
} else if (col.Alpha() == 0) {
|
||||||
return _("transparent");
|
return _("transparent");
|
||||||
} else {
|
} else {
|
||||||
return String::Format(_("rgba(%u,%u,%u,%u)"), col.Red(), col.Green(), col.Blue(), col.alpha);
|
return String::Format(_("rgba(%u,%u,%u,%u)"), col.Red(), col.Green(), col.Blue(), col.Alpha());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +49,8 @@ String format_acolor(AColor col) {
|
|||||||
Color lerp(const Color& a, const Color& b, double t) {
|
Color lerp(const Color& a, const Color& b, double t) {
|
||||||
return Color(static_cast<int>( a.Red() + (b.Red() - a.Red() ) * t ),
|
return Color(static_cast<int>( a.Red() + (b.Red() - a.Red() ) * t ),
|
||||||
static_cast<int>( a.Green() + (b.Green() - a.Green()) * t ),
|
static_cast<int>( a.Green() + (b.Green() - a.Green()) * t ),
|
||||||
static_cast<int>( a.Blue() + (b.Blue() - a.Blue() ) * t ));
|
static_cast<int>( a.Blue() + (b.Blue() - a.Blue() ) * t ),
|
||||||
|
static_cast<int>( a.Alpha() + (b.Alpha() - a.Alpha()) * t ));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-23
@@ -16,22 +16,6 @@
|
|||||||
|
|
||||||
#include <util/prec.hpp>
|
#include <util/prec.hpp>
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Color with alpha
|
|
||||||
|
|
||||||
/// Color with alpha channel
|
|
||||||
class AColor : public Color {
|
|
||||||
public:
|
|
||||||
Byte alpha; ///< The alpha value, in the range [0..255]
|
|
||||||
inline AColor() : alpha(0) {}
|
|
||||||
inline AColor(Byte r, Byte g, Byte b, Byte a = 255) : Color(r,g,b), alpha(a) {}
|
|
||||||
inline AColor(const Color& color, Byte a = 255) : Color(color), alpha(a) {}
|
|
||||||
|
|
||||||
inline bool operator == (const AColor& that) const {
|
|
||||||
return static_cast<const Color&>(*this) == static_cast<const Color&>(that) && alpha == that.alpha;
|
|
||||||
}
|
|
||||||
inline bool operator != (const AColor& that) const { return ! (*this == that); }
|
|
||||||
};
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// RGB Color, packed into 3 bytes
|
// RGB Color, packed into 3 bytes
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@@ -84,11 +68,8 @@ struct RGB {
|
|||||||
/// Parse a color
|
/// Parse a color
|
||||||
Color parse_color(const String& value);
|
Color parse_color(const String& value);
|
||||||
|
|
||||||
/// Parse a color with alpha
|
/// Convert a Color to a string
|
||||||
AColor parse_acolor(const String& value);
|
String format_color(Color col);
|
||||||
|
|
||||||
/// Convert an AColor to a string
|
|
||||||
String format_acolor(AColor col);
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Color utility functions
|
// ----------------------------------------------------------------------------- : Color utility functions
|
||||||
|
|
||||||
@@ -98,8 +79,6 @@ inline int col(int x) { return top(bot(x)); } ///< top and bottom range check fo
|
|||||||
|
|
||||||
/// Linear interpolation between colors
|
/// Linear interpolation between colors
|
||||||
Color lerp(const Color& a, const Color& b, double t);
|
Color lerp(const Color& a, const Color& b, double t);
|
||||||
/// Linear interpolation between colors
|
|
||||||
AColor lerp(const AColor& a, const AColor& b, double t);
|
|
||||||
|
|
||||||
/// convert HSL to RGB, h,s,l must be in range [0...1)
|
/// convert HSL to RGB, h,s,l must be in range [0...1)
|
||||||
Color hsl2rgb(double h, double s, double l);
|
Color hsl2rgb(double h, double s, double l);
|
||||||
|
|||||||
+1
-1
@@ -53,7 +53,7 @@ void sharp_resample_and_clip(const Image& img_in, Image& img_out, wxRect rect, i
|
|||||||
* rect = rectangle to draw in (a rectangle somewhere around pos)
|
* rect = rectangle to draw in (a rectangle somewhere around pos)
|
||||||
* stretch = amount to stretch in the direction of the text after drawing
|
* stretch = amount to stretch in the direction of the text after drawing
|
||||||
*/
|
*/
|
||||||
void draw_resampled_text(DC& dc, const RealPoint& pos, const RealRect& rect, double stretch, Radians angle, AColor color, const String& text, int blur_radius = 0, int repeat = 1);
|
void draw_resampled_text(DC& dc, const RealPoint& pos, const RealRect& rect, double stretch, Radians angle, Color color, const String& text, int blur_radius = 0, int repeat = 1);
|
||||||
|
|
||||||
// scaling factor to use when drawing resampled text
|
// scaling factor to use when drawing resampled text
|
||||||
extern const int text_scaling;
|
extern const int text_scaling;
|
||||||
|
|||||||
@@ -165,9 +165,9 @@ void blur_image_alpha(Image& img) {
|
|||||||
|
|
||||||
// Draw text by first drawing it using a larger font and then downsampling it
|
// Draw text by first drawing it using a larger font and then downsampling it
|
||||||
// optionally rotated by an angle
|
// optionally rotated by an angle
|
||||||
void draw_resampled_text(DC& dc, const RealPoint& pos, const RealRect& rect, double stretch, Radians angle, AColor color, const String& text, int blur_radius, int repeat) {
|
void draw_resampled_text(DC& dc, const RealPoint& pos, const RealRect& rect, double stretch, Radians angle, Color color, const String& text, int blur_radius, int repeat) {
|
||||||
// transparent text can be ignored
|
// transparent text can be ignored
|
||||||
if (color.alpha == 0) return;
|
if (color.Alpha() == 0) return;
|
||||||
// enlarge slightly; some fonts are larger then the GetTextExtent tells us (especially italic fonts)
|
// enlarge slightly; some fonts are larger then the GetTextExtent tells us (especially italic fonts)
|
||||||
int w = static_cast<int>(rect.width) + 3 + 2 * blur_radius, h = static_cast<int>(rect.height) + 1 + 2 * blur_radius;
|
int w = static_cast<int>(rect.width) + 3 + 2 * blur_radius, h = static_cast<int>(rect.height) + 1 + 2 * blur_radius;
|
||||||
// determine sub-pixel position
|
// determine sub-pixel position
|
||||||
@@ -194,8 +194,8 @@ void draw_resampled_text(DC& dc, const RealPoint& pos, const RealRect& rect, dou
|
|||||||
fill_image(img_small, color);
|
fill_image(img_small, color);
|
||||||
downsample_to_alpha(buffer, img_small);
|
downsample_to_alpha(buffer, img_small);
|
||||||
// multiply alpha
|
// multiply alpha
|
||||||
if (color.alpha != 255) {
|
if (color.Alpha() != 255) {
|
||||||
set_alpha(img_small, color.alpha / 255.);
|
set_alpha(img_small, color.Alpha() / 255.);
|
||||||
}
|
}
|
||||||
// blur
|
// blur
|
||||||
for (int i = 0 ; i < blur_radius ; ++i) {
|
for (int i = 0 ; i < blur_radius ; ++i) {
|
||||||
|
|||||||
@@ -510,10 +510,10 @@ void ConsolePanel::exec(String const& command) {
|
|||||||
message->bitmap = wxBitmap(image);
|
message->bitmap = wxBitmap(image);
|
||||||
} else if (type == SCRIPT_COLOR) {
|
} else if (type == SCRIPT_COLOR) {
|
||||||
message->text = result->toCode();
|
message->text = result->toCode();
|
||||||
AColor color = (AColor)*result;
|
Color color = (Color)*result;
|
||||||
wxImage image(30,20);
|
wxImage image(30,20);
|
||||||
fill_image(image,color);
|
fill_image(image,color);
|
||||||
set_alpha(image, color.alpha / 255.0);
|
set_alpha(image, color.Alpha() / 255.0);
|
||||||
message->bitmap = wxBitmap(image);
|
message->bitmap = wxBitmap(image);
|
||||||
} else {
|
} else {
|
||||||
message->text = result->toCode();
|
message->text = result->toCode();
|
||||||
|
|||||||
@@ -517,7 +517,7 @@ const Image& SymbolPartList::itemPreview(int i, const SymbolPartP& part) {
|
|||||||
}
|
}
|
||||||
const Image& SymbolPartList::symbolPreview() {
|
const Image& SymbolPartList::symbolPreview() {
|
||||||
if (!symbol_preview.up_to_date) {
|
if (!symbol_preview.up_to_date) {
|
||||||
SolidFillSymbolFilter filter(AColor(0,0,0,40), AColor(255,255,255,40));
|
SolidFillSymbolFilter filter(Color(0,0,0,40), Color(255,255,255,40));
|
||||||
Image img = render_symbol(symbol, filter, 0.06, ITEM_HEIGHT * 4);
|
Image img = render_symbol(symbol, filter, 0.06, ITEM_HEIGHT * 4);
|
||||||
resample(img, symbol_preview.image);
|
resample(img, symbol_preview.image);
|
||||||
symbol_preview.up_to_date = true;
|
symbol_preview.up_to_date = true;
|
||||||
|
|||||||
@@ -34,12 +34,12 @@ void filter_symbol(Image& symbol, const SymbolFilter& filter) {
|
|||||||
} else {
|
} else {
|
||||||
SymbolSet point = data[1] ? (data[0] ? SYMBOL_BORDER : SYMBOL_OUTSIDE) : SYMBOL_INSIDE;
|
SymbolSet point = data[1] ? (data[0] ? SYMBOL_BORDER : SYMBOL_OUTSIDE) : SYMBOL_INSIDE;
|
||||||
// Call filter
|
// Call filter
|
||||||
AColor result = filter.color((double)x / width, (double)y / height, point);
|
Color result = filter.color((double)x / width, (double)y / height, point);
|
||||||
// Store color
|
// Store color
|
||||||
data[0] = result.Red();
|
data[0] = result.Red();
|
||||||
data[1] = result.Green();
|
data[1] = result.Green();
|
||||||
data[2] = result.Blue();
|
data[2] = result.Blue();
|
||||||
alpha[0] = result.alpha;
|
alpha[0] = result.Alpha();
|
||||||
}
|
}
|
||||||
// next
|
// next
|
||||||
data += 3;
|
data += 3;
|
||||||
@@ -87,10 +87,10 @@ intrusive_ptr<SymbolFilter> read_new<SymbolFilter>(Reader& reader) {
|
|||||||
|
|
||||||
String SolidFillSymbolFilter::fillType() const { return _("solid"); }
|
String SolidFillSymbolFilter::fillType() const { return _("solid"); }
|
||||||
|
|
||||||
AColor SolidFillSymbolFilter::color(double x, double y, SymbolSet point) const {
|
Color SolidFillSymbolFilter::color(double x, double y, SymbolSet point) const {
|
||||||
if (point == SYMBOL_INSIDE) return fill_color;
|
if (point == SYMBOL_INSIDE) return fill_color;
|
||||||
else if (point == SYMBOL_BORDER) return border_color;
|
else if (point == SYMBOL_BORDER) return border_color;
|
||||||
else return AColor(0,0,0,0);
|
else return Color(0,0,0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SolidFillSymbolFilter::operator == (const SymbolFilter& that) const {
|
bool SolidFillSymbolFilter::operator == (const SymbolFilter& that) const {
|
||||||
@@ -108,10 +108,10 @@ IMPLEMENT_REFLECTION(SolidFillSymbolFilter) {
|
|||||||
// ----------------------------------------------------------------------------- : GradientSymbolFilter
|
// ----------------------------------------------------------------------------- : GradientSymbolFilter
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
AColor GradientSymbolFilter::color(double x, double y, SymbolSet point, const T* t) const {
|
Color GradientSymbolFilter::color(double x, double y, SymbolSet point, const T* t) const {
|
||||||
if (point == SYMBOL_INSIDE) return lerp(fill_color_1, fill_color_2, t->t(x,y));
|
if (point == SYMBOL_INSIDE) return lerp(fill_color_1, fill_color_2, t->t(x,y));
|
||||||
else if (point == SYMBOL_BORDER) return lerp(border_color_1, border_color_2, t->t(x,y));
|
else if (point == SYMBOL_BORDER) return lerp(border_color_1, border_color_2, t->t(x,y));
|
||||||
else return AColor(0,0,0,0);
|
else return Color(0,0,0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GradientSymbolFilter::equal(const GradientSymbolFilter& that) const {
|
bool GradientSymbolFilter::equal(const GradientSymbolFilter& that) const {
|
||||||
@@ -149,7 +149,7 @@ LinearGradientSymbolFilter::LinearGradientSymbolFilter
|
|||||||
, end_x(end_x), end_y(end_y)
|
, end_x(end_x), end_y(end_y)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
AColor LinearGradientSymbolFilter::color(double x, double y, SymbolSet point) const {
|
Color LinearGradientSymbolFilter::color(double x, double y, SymbolSet point) const {
|
||||||
len = sqr(end_x - center_x) + sqr(end_y - center_y);
|
len = sqr(end_x - center_x) + sqr(end_y - center_y);
|
||||||
if (len == 0) len = 1; // prevent div by 0
|
if (len == 0) len = 1; // prevent div by 0
|
||||||
return GradientSymbolFilter::color(x,y,point,this);
|
return GradientSymbolFilter::color(x,y,point,this);
|
||||||
@@ -177,7 +177,7 @@ IMPLEMENT_REFLECTION(LinearGradientSymbolFilter) {
|
|||||||
|
|
||||||
String RadialGradientSymbolFilter::fillType() const { return _("radial gradient"); }
|
String RadialGradientSymbolFilter::fillType() const { return _("radial gradient"); }
|
||||||
|
|
||||||
AColor RadialGradientSymbolFilter::color(double x, double y, SymbolSet point) const {
|
Color RadialGradientSymbolFilter::color(double x, double y, SymbolSet point) const {
|
||||||
return GradientSymbolFilter::color(x,y,point,this);
|
return GradientSymbolFilter::color(x,y,point,this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class SymbolFilter : public IntrusivePtrVirtualBase {
|
|||||||
virtual ~SymbolFilter() {}
|
virtual ~SymbolFilter() {}
|
||||||
/// What color should the symbol have at location (x, y)?
|
/// What color should the symbol have at location (x, y)?
|
||||||
/** x,y are in the range [0...1) */
|
/** x,y are in the range [0...1) */
|
||||||
virtual AColor color(double x, double y, SymbolSet point) const = 0;
|
virtual Color color(double x, double y, SymbolSet point) const = 0;
|
||||||
/// Name of this fill type
|
/// Name of this fill type
|
||||||
virtual String fillType() const = 0;
|
virtual String fillType() const = 0;
|
||||||
/// Comparision
|
/// Comparision
|
||||||
@@ -60,14 +60,14 @@ intrusive_ptr<SymbolFilter> read_new<SymbolFilter>(Reader& reader);
|
|||||||
class SolidFillSymbolFilter : public SymbolFilter {
|
class SolidFillSymbolFilter : public SymbolFilter {
|
||||||
public:
|
public:
|
||||||
inline SolidFillSymbolFilter() {}
|
inline SolidFillSymbolFilter() {}
|
||||||
inline SolidFillSymbolFilter(const AColor& fill_color, const AColor& border_color)
|
inline SolidFillSymbolFilter(const Color& fill_color, const Color& border_color)
|
||||||
: fill_color(fill_color), border_color(border_color)
|
: fill_color(fill_color), border_color(border_color)
|
||||||
{}
|
{}
|
||||||
virtual AColor color(double x, double y, SymbolSet point) const;
|
virtual Color color(double x, double y, SymbolSet point) const;
|
||||||
virtual String fillType() const;
|
virtual String fillType() const;
|
||||||
virtual bool operator == (const SymbolFilter& that) const;
|
virtual bool operator == (const SymbolFilter& that) const;
|
||||||
private:
|
private:
|
||||||
AColor fill_color, border_color;
|
Color fill_color, border_color;
|
||||||
DECLARE_REFLECTION();
|
DECLARE_REFLECTION();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ class GradientSymbolFilter : public SymbolFilter {
|
|||||||
Color fill_color_1, border_color_1;
|
Color fill_color_1, border_color_1;
|
||||||
Color fill_color_2, border_color_2;
|
Color fill_color_2, border_color_2;
|
||||||
template <typename T>
|
template <typename T>
|
||||||
AColor color(double x, double y, SymbolSet point, const T* t) const;
|
Color color(double x, double y, SymbolSet point, const T* t) const;
|
||||||
bool equal(const GradientSymbolFilter& that) const;
|
bool equal(const GradientSymbolFilter& that) const;
|
||||||
|
|
||||||
DECLARE_REFLECTION();
|
DECLARE_REFLECTION();
|
||||||
@@ -96,7 +96,7 @@ class LinearGradientSymbolFilter : public GradientSymbolFilter {
|
|||||||
LinearGradientSymbolFilter(const Color& fill_color_1, const Color& border_color_1, const Color& fill_color_2, const Color& border_color_2
|
LinearGradientSymbolFilter(const Color& fill_color_1, const Color& border_color_1, const Color& fill_color_2, const Color& border_color_2
|
||||||
,double center_x, double center_y, double end_x, double end_y);
|
,double center_x, double center_y, double end_x, double end_y);
|
||||||
|
|
||||||
virtual AColor color(double x, double y, SymbolSet point) const;
|
virtual Color color(double x, double y, SymbolSet point) const;
|
||||||
virtual String fillType() const;
|
virtual String fillType() const;
|
||||||
virtual bool operator == (const SymbolFilter& that) const;
|
virtual bool operator == (const SymbolFilter& that) const;
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ class RadialGradientSymbolFilter : public GradientSymbolFilter {
|
|||||||
: GradientSymbolFilter(fill_color_1, border_color_1, fill_color_2, border_color_2)
|
: GradientSymbolFilter(fill_color_1, border_color_1, fill_color_2, border_color_2)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual AColor color(double x, double y, SymbolSet point) const;
|
virtual Color color(double x, double y, SymbolSet point) const;
|
||||||
virtual String fillType() const;
|
virtual String fillType() const;
|
||||||
virtual bool operator == (const SymbolFilter& that) const;
|
virtual bool operator == (const SymbolFilter& that) const;
|
||||||
|
|
||||||
|
|||||||
@@ -60,13 +60,13 @@ double TextElements::scaleStep() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Colors for <atom-param> tags
|
// Colors for <atom-param> tags
|
||||||
AColor param_colors[] =
|
Color param_colors[] =
|
||||||
{ AColor(0,170,0)
|
{ Color(0,170,0)
|
||||||
, AColor(0,0,200)
|
, Color(0,0,200)
|
||||||
, AColor(200,0,100)
|
, Color(200,0,100)
|
||||||
, AColor(200,200,0)
|
, Color(200,200,0)
|
||||||
, AColor(0,170,170)
|
, Color(0,170,170)
|
||||||
, AColor(200,0,0)
|
, Color(200,0,0)
|
||||||
};
|
};
|
||||||
const size_t param_colors_count = sizeof(param_colors) / sizeof(param_colors[0]);
|
const size_t param_colors_count = sizeof(param_colors) / sizeof(param_colors[0]);
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ struct TextElementsFromString {
|
|||||||
int soft, kwpph, param, line, soft_line;
|
int soft, kwpph, param, line, soft_line;
|
||||||
int code, code_kw, code_string, param_ref, error;
|
int code, code_kw, code_string, param_ref, error;
|
||||||
int param_id;
|
int param_id;
|
||||||
vector<AColor> colors;
|
vector<Color> colors;
|
||||||
vector<double> sizes;
|
vector<double> sizes;
|
||||||
/// put angle brackets around the text?
|
/// put angle brackets around the text?
|
||||||
bool bracket;
|
bool bracket;
|
||||||
@@ -128,7 +128,7 @@ struct TextElementsFromString {
|
|||||||
else if (is_substr(text, tag_start, _( "<color"))) {
|
else if (is_substr(text, tag_start, _( "<color"))) {
|
||||||
size_t colon = text.find_first_of(_(">:"), tag_start);
|
size_t colon = text.find_first_of(_(">:"), tag_start);
|
||||||
if (colon < pos - 1 && text.GetChar(colon) == _(':')) {
|
if (colon < pos - 1 && text.GetChar(colon) == _(':')) {
|
||||||
AColor c = parse_acolor(text.substr(colon+1, pos-colon-2));
|
Color c = parse_color(text.substr(colon+1, pos-colon-2));
|
||||||
if (!c.Ok()) c = style.font.color;
|
if (!c.Ok()) c = style.font.color;
|
||||||
colors.push_back(c);
|
colors.push_back(c);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -556,7 +556,7 @@ void instrTernary(TernaryInstructionType i, ScriptValueP& a, const ScriptValueP&
|
|||||||
void instrQuaternary(QuaternaryInstructionType i, ScriptValueP& a, const ScriptValueP& b, const ScriptValueP& c, const ScriptValueP& d) {
|
void instrQuaternary(QuaternaryInstructionType i, ScriptValueP& a, const ScriptValueP& b, const ScriptValueP& c, const ScriptValueP& d) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case I_RGBA:
|
case I_RGBA:
|
||||||
a = to_script(AColor((int)*a, (int)*b, (int)*c, (int)*d));
|
a = to_script(Color((int)*a, (int)*b, (int)*c, (int)*d));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ SCRIPT_FUNCTION(to_int) {
|
|||||||
if (t == SCRIPT_BOOL) {
|
if (t == SCRIPT_BOOL) {
|
||||||
result = (bool)*input ? 1 : 0;
|
result = (bool)*input ? 1 : 0;
|
||||||
} else if (t == SCRIPT_COLOR) {
|
} else if (t == SCRIPT_COLOR) {
|
||||||
AColor c = (AColor)*input;
|
Color c = (Color)*input;
|
||||||
result = (c.Red() + c.Blue() + c.Green()) / 3;
|
result = (c.Red() + c.Blue() + c.Green()) / 3;
|
||||||
} else if (t == SCRIPT_STRING) {
|
} else if (t == SCRIPT_STRING) {
|
||||||
long l;
|
long l;
|
||||||
@@ -141,7 +141,7 @@ SCRIPT_FUNCTION(to_real) {
|
|||||||
if (t == SCRIPT_BOOL) {
|
if (t == SCRIPT_BOOL) {
|
||||||
result = (bool)*input ? 1.0 : 0.0;
|
result = (bool)*input ? 1.0 : 0.0;
|
||||||
} else if (t == SCRIPT_COLOR) {
|
} else if (t == SCRIPT_COLOR) {
|
||||||
AColor c = (AColor)*input;
|
Color c = (Color)*input;
|
||||||
result = (c.Red() + c.Blue() + c.Green()) / 3.0;
|
result = (c.Red() + c.Blue() + c.Green()) / 3.0;
|
||||||
} else if (t == SCRIPT_STRING) {
|
} else if (t == SCRIPT_STRING) {
|
||||||
String str = input->toString();
|
String str = input->toString();
|
||||||
@@ -166,7 +166,7 @@ SCRIPT_FUNCTION(to_number) {
|
|||||||
if (t == SCRIPT_BOOL) {
|
if (t == SCRIPT_BOOL) {
|
||||||
SCRIPT_RETURN((bool)*input ? 1 : 0);
|
SCRIPT_RETURN((bool)*input ? 1 : 0);
|
||||||
} else if (t == SCRIPT_COLOR) {
|
} else if (t == SCRIPT_COLOR) {
|
||||||
AColor c = (AColor)*input;
|
Color c = (Color)*input;
|
||||||
SCRIPT_RETURN( (c.Red() + c.Blue() + c.Green()) / 3 );
|
SCRIPT_RETURN( (c.Red() + c.Blue() + c.Green()) / 3 );
|
||||||
} else if (t == SCRIPT_DOUBLE) {
|
} else if (t == SCRIPT_DOUBLE) {
|
||||||
SCRIPT_RETURN((double)*input);
|
SCRIPT_RETURN((double)*input);
|
||||||
@@ -208,7 +208,7 @@ SCRIPT_FUNCTION(to_boolean) {
|
|||||||
|
|
||||||
SCRIPT_FUNCTION(to_color) {
|
SCRIPT_FUNCTION(to_color) {
|
||||||
try {
|
try {
|
||||||
SCRIPT_PARAM_C(AColor, input);
|
SCRIPT_PARAM_C(Color, input);
|
||||||
SCRIPT_RETURN(input);
|
SCRIPT_RETURN(input);
|
||||||
} catch (const ScriptError& e) {
|
} catch (const ScriptError& e) {
|
||||||
return delay_error(e);
|
return delay_error(e);
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ SCRIPT_FUNCTION(new_card) {
|
|||||||
} else if (PackageChoiceValue* pvalue = dynamic_cast<PackageChoiceValue*>(value)) {
|
} else if (PackageChoiceValue* pvalue = dynamic_cast<PackageChoiceValue*>(value)) {
|
||||||
pvalue->package_name = v->toString();
|
pvalue->package_name = v->toString();
|
||||||
} else if (ColorValue* cvalue = dynamic_cast<ColorValue*>(value)) {
|
} else if (ColorValue* cvalue = dynamic_cast<ColorValue*>(value)) {
|
||||||
cvalue->value = (AColor)*v;
|
cvalue->value = (Color)*v;
|
||||||
} else {
|
} else {
|
||||||
throw ScriptError(format_string(_("Can not set value '%s', it is not of the right type"),name));
|
throw ScriptError(format_string(_("Can not set value '%s', it is not of the right type"),name));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,11 +25,9 @@ void store(const ScriptValueP& val, String& var) { var = val->toStr
|
|||||||
void store(const ScriptValueP& val, int& var) { var = *val; }
|
void store(const ScriptValueP& val, int& var) { var = *val; }
|
||||||
void store(const ScriptValueP& val, double& var) { var = *val; }
|
void store(const ScriptValueP& val, double& var) { var = *val; }
|
||||||
void store(const ScriptValueP& val, bool& var) { var = *val; }
|
void store(const ScriptValueP& val, bool& var) { var = *val; }
|
||||||
void store(const ScriptValueP& val, Color& var) { var = (AColor)*val; }
|
void store(const ScriptValueP& val, Color& var) { var = *val; }
|
||||||
void store(const ScriptValueP& val, AColor& var) { var = *val; }
|
|
||||||
void store(const ScriptValueP& val, Defaultable<String>& var) { var.assign(*val); }
|
void store(const ScriptValueP& val, Defaultable<String>& var) { var.assign(*val); }
|
||||||
void store(const ScriptValueP& val, Defaultable<Color>& var) { var.assign((AColor)*val); }
|
void store(const ScriptValueP& val, Defaultable<Color>& var) { var.assign(*val); }
|
||||||
void store(const ScriptValueP& val, Defaultable<AColor>& var) { var.assign(*val); }
|
|
||||||
void store(const ScriptValueP& val, Alignment& var) { var = from_string(val->toString()); }
|
void store(const ScriptValueP& val, Alignment& var) { var = from_string(val->toString()); }
|
||||||
void store(const ScriptValueP& val, Direction& var) { parse_enum(val->toString(),var); }
|
void store(const ScriptValueP& val, Direction& var) { parse_enum(val->toString(),var); }
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
#include <script/parser.hpp>
|
#include <script/parser.hpp>
|
||||||
#include <script/to_value.hpp>
|
#include <script/to_value.hpp>
|
||||||
|
|
||||||
class AColor;
|
|
||||||
DECLARE_POINTER_TYPE(Script);
|
DECLARE_POINTER_TYPE(Script);
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Store
|
// ----------------------------------------------------------------------------- : Store
|
||||||
@@ -29,7 +28,6 @@ void store(const ScriptValueP& val, int& var);
|
|||||||
void store(const ScriptValueP& val, double& var);
|
void store(const ScriptValueP& val, double& var);
|
||||||
void store(const ScriptValueP& val, bool& var);
|
void store(const ScriptValueP& val, bool& var);
|
||||||
void store(const ScriptValueP& val, Color& var);
|
void store(const ScriptValueP& val, Color& var);
|
||||||
void store(const ScriptValueP& val, AColor& var);
|
|
||||||
void store(const ScriptValueP& val, Defaultable<String>& var);
|
void store(const ScriptValueP& val, Defaultable<String>& var);
|
||||||
void store(const ScriptValueP& val, Defaultable<Color>& var);
|
void store(const ScriptValueP& val, Defaultable<Color>& var);
|
||||||
void store(const ScriptValueP& val, Alignment& var);
|
void store(const ScriptValueP& val, Alignment& var);
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ class ScriptDelayedError : public ScriptValue {
|
|||||||
virtual operator double() const;
|
virtual operator double() const;
|
||||||
virtual operator int() const;
|
virtual operator int() const;
|
||||||
virtual operator bool() const;
|
virtual operator bool() const;
|
||||||
virtual operator AColor() const;
|
virtual operator Color() const;
|
||||||
virtual int itemCount() const;
|
virtual int itemCount() const;
|
||||||
virtual CompareWhat compareAs(String&, void const*&) const;
|
virtual CompareWhat compareAs(String&, void const*&) const;
|
||||||
// these can propagate the error
|
// these can propagate the error
|
||||||
@@ -279,7 +279,7 @@ class ScriptObject : public ScriptValue {
|
|||||||
virtual operator double() const { ScriptValueP d = getDefault(); return d ? *d : ScriptValue::operator double(); }
|
virtual operator double() const { ScriptValueP d = getDefault(); return d ? *d : ScriptValue::operator double(); }
|
||||||
virtual operator int() const { ScriptValueP d = getDefault(); return d ? *d : ScriptValue::operator int(); }
|
virtual operator int() const { ScriptValueP d = getDefault(); return d ? *d : ScriptValue::operator int(); }
|
||||||
virtual operator bool() const { ScriptValueP d = getDefault(); return d ? *d : ScriptValue::operator bool(); }
|
virtual operator bool() const { ScriptValueP d = getDefault(); return d ? *d : ScriptValue::operator bool(); }
|
||||||
virtual operator AColor() const { ScriptValueP d = getDefault(); return d ? *d : ScriptValue::operator AColor(); }
|
virtual operator Color() const { ScriptValueP d = getDefault(); return d ? *d : ScriptValue::operator Color(); }
|
||||||
virtual String toCode() const { ScriptValueP d = getDefault(); return d ? d->toCode() : to_code(*value); }
|
virtual String toCode() const { ScriptValueP d = getDefault(); return d ? d->toCode() : to_code(*value); }
|
||||||
virtual GeneratedImageP toImage(const ScriptValueP& thisP) const {
|
virtual GeneratedImageP toImage(const ScriptValueP& thisP) const {
|
||||||
ScriptValueP d = getDefault(); return d ? d->toImage(d) : ScriptValue::toImage(thisP);
|
ScriptValueP d = getDefault(); return d ? d->toImage(d) : ScriptValue::toImage(thisP);
|
||||||
@@ -399,7 +399,6 @@ inline ScriptValueP to_script(long v) { return to_script((int) v); }
|
|||||||
ScriptValueP to_script(double v);
|
ScriptValueP to_script(double v);
|
||||||
ScriptValueP to_script(const String& v);
|
ScriptValueP to_script(const String& v);
|
||||||
ScriptValueP to_script(Color v);
|
ScriptValueP to_script(Color v);
|
||||||
ScriptValueP to_script(AColor v);
|
|
||||||
ScriptValueP to_script(wxDateTime v);
|
ScriptValueP to_script(wxDateTime v);
|
||||||
inline ScriptValueP to_script(bool v) { return v ? script_true : script_false; }
|
inline ScriptValueP to_script(bool v) { return v ? script_true : script_false; }
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@@ -428,8 +427,7 @@ template <> inline String from_script<String> (const ScriptValueP& va
|
|||||||
template <> inline int from_script<int> (const ScriptValueP& value) { return *value; }
|
template <> inline int from_script<int> (const ScriptValueP& value) { return *value; }
|
||||||
template <> inline double from_script<double> (const ScriptValueP& value) { return *value; }
|
template <> inline double from_script<double> (const ScriptValueP& value) { return *value; }
|
||||||
template <> inline bool from_script<bool> (const ScriptValueP& value) { return *value; }
|
template <> inline bool from_script<bool> (const ScriptValueP& value) { return *value; }
|
||||||
template <> inline Color from_script<Color> (const ScriptValueP& value) { return (AColor)*value; }
|
template <> inline Color from_script<Color> (const ScriptValueP& value) { return *value; }
|
||||||
template <> inline AColor from_script<AColor> (const ScriptValueP& value) { return *value; }
|
|
||||||
template <> inline wxDateTime from_script<wxDateTime> (const ScriptValueP& value) { return *value; }
|
template <> inline wxDateTime from_script<wxDateTime> (const ScriptValueP& value) { return *value; }
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : EOF
|
// ----------------------------------------------------------------------------- : EOF
|
||||||
|
|||||||
+14
-17
@@ -23,7 +23,7 @@ ScriptValue::operator String() const { throw Script
|
|||||||
ScriptValue::operator int() const { throw ScriptErrorConversion(typeName(), _TYPE_("integer" )); }
|
ScriptValue::operator int() const { throw ScriptErrorConversion(typeName(), _TYPE_("integer" )); }
|
||||||
ScriptValue::operator bool() const { throw ScriptErrorConversion(typeName(), _TYPE_("boolean" )); }
|
ScriptValue::operator bool() const { throw ScriptErrorConversion(typeName(), _TYPE_("boolean" )); }
|
||||||
ScriptValue::operator double() const { throw ScriptErrorConversion(typeName(), _TYPE_("double" )); }
|
ScriptValue::operator double() const { throw ScriptErrorConversion(typeName(), _TYPE_("double" )); }
|
||||||
ScriptValue::operator AColor() const { throw ScriptErrorConversion(typeName(), _TYPE_("color" )); }
|
ScriptValue::operator Color() const { throw ScriptErrorConversion(typeName(), _TYPE_("color" )); }
|
||||||
ScriptValue::operator wxDateTime() const { throw ScriptErrorConversion(typeName(), _TYPE_("date" )); }
|
ScriptValue::operator wxDateTime() const { throw ScriptErrorConversion(typeName(), _TYPE_("date" )); }
|
||||||
ScriptValueP ScriptValue::do_eval(Context&, bool) const { return delay_error(ScriptErrorConversion(typeName(), _TYPE_("function"))); }
|
ScriptValueP ScriptValue::do_eval(Context&, bool) const { return delay_error(ScriptErrorConversion(typeName(), _TYPE_("function"))); }
|
||||||
ScriptValueP ScriptValue::next(ScriptValueP* key_out) { throw InternalError(_("Can't convert from ")+typeName()+_(" to iterator")); }
|
ScriptValueP ScriptValue::next(ScriptValueP* key_out) { throw InternalError(_("Can't convert from ")+typeName()+_(" to iterator")); }
|
||||||
@@ -108,7 +108,7 @@ ScriptDelayedError::operator String() const { throw error; }
|
|||||||
ScriptDelayedError::operator double() const { throw error; }
|
ScriptDelayedError::operator double() const { throw error; }
|
||||||
ScriptDelayedError::operator int() const { throw error; }
|
ScriptDelayedError::operator int() const { throw error; }
|
||||||
ScriptDelayedError::operator bool() const { throw error; }
|
ScriptDelayedError::operator bool() const { throw error; }
|
||||||
ScriptDelayedError::operator AColor() const { throw error; }
|
ScriptDelayedError::operator Color() const { throw error; }
|
||||||
int ScriptDelayedError::itemCount() const { throw error; }
|
int ScriptDelayedError::itemCount() const { throw error; }
|
||||||
CompareWhat ScriptDelayedError::compareAs(String&, void const*&) const { throw error; }
|
CompareWhat ScriptDelayedError::compareAs(String&, void const*&) const { throw error; }
|
||||||
ScriptValueP ScriptDelayedError::getMember(const String&) const { return intrusive(new ScriptDelayedError(error)); }
|
ScriptValueP ScriptDelayedError::getMember(const String&) const { return intrusive(new ScriptDelayedError(error)); }
|
||||||
@@ -270,8 +270,8 @@ class ScriptString : public ScriptValue {
|
|||||||
throw ScriptErrorConversion(value, typeName(), _TYPE_("boolean"));
|
throw ScriptErrorConversion(value, typeName(), _TYPE_("boolean"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
virtual operator AColor() const {
|
virtual operator Color() const {
|
||||||
AColor c = parse_acolor(value);
|
Color c = parse_color(value);
|
||||||
if (!c.Ok()) {
|
if (!c.Ok()) {
|
||||||
throw ScriptErrorConversion(value, typeName(), _TYPE_("color"));
|
throw ScriptErrorConversion(value, typeName(), _TYPE_("color"));
|
||||||
}
|
}
|
||||||
@@ -313,26 +313,23 @@ ScriptValueP to_script(const String& v) {
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Color
|
// ----------------------------------------------------------------------------- : Color
|
||||||
|
|
||||||
// AColor values
|
// Color values
|
||||||
class ScriptAColor : public ScriptValue {
|
class ScriptColor : public ScriptValue {
|
||||||
public:
|
public:
|
||||||
ScriptAColor(const AColor& v) : value(v) {}
|
ScriptColor(const Color& v) : value(v) {}
|
||||||
virtual ScriptType type() const { return SCRIPT_COLOR; }
|
virtual ScriptType type() const { return SCRIPT_COLOR; }
|
||||||
virtual String typeName() const { return _TYPE_("color"); }
|
virtual String typeName() const { return _TYPE_("color"); }
|
||||||
virtual operator AColor() const { return value; }
|
virtual operator Color() const { return value; }
|
||||||
// colors don't auto convert to int, use to_int to force
|
// colors don't auto convert to int, use to_int to force
|
||||||
virtual operator String() const {
|
virtual operator String() const {
|
||||||
return format_acolor(value);
|
return format_color(value);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
AColor value;
|
Color value;
|
||||||
};
|
};
|
||||||
|
|
||||||
ScriptValueP to_script(Color v) {
|
ScriptValueP to_script(Color v) {
|
||||||
return intrusive(new ScriptAColor(v));
|
return intrusive(new ScriptColor(v));
|
||||||
}
|
|
||||||
ScriptValueP to_script(AColor v) {
|
|
||||||
return intrusive(new ScriptAColor(v));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -368,7 +365,7 @@ public:
|
|||||||
operator double() const override { return 0.0; }
|
operator double() const override { return 0.0; }
|
||||||
operator int() const override { return 0; }
|
operator int() const override { return 0; }
|
||||||
operator bool() const override { return false; }
|
operator bool() const override { return false; }
|
||||||
operator AColor() const override { return AColor(); }
|
operator Color() const override { return wxTransparentColour; }
|
||||||
GeneratedImageP toImage(const ScriptValueP&) const {
|
GeneratedImageP toImage(const ScriptValueP&) const {
|
||||||
return intrusive(new BlankImage());
|
return intrusive(new BlankImage());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class ScriptValue : public IntrusivePtrBaseWithDelete {
|
|||||||
/// Convert this value to a boolean
|
/// Convert this value to a boolean
|
||||||
virtual operator bool() const;
|
virtual operator bool() const;
|
||||||
/// Convert this value to a color
|
/// Convert this value to a color
|
||||||
virtual operator AColor() const;
|
virtual operator Color() const;
|
||||||
/// Convert this value to a wxDateTime
|
/// Convert this value to a wxDateTime
|
||||||
virtual operator wxDateTime() const;
|
virtual operator wxDateTime() const;
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ template <> void GetDefaultMember::handle(const bool& v) { value = to_sc
|
|||||||
template <> void GetDefaultMember::handle(const tribool& v) { value = to_script((bool)v); }
|
template <> void GetDefaultMember::handle(const tribool& v) { value = to_script((bool)v); }
|
||||||
template <> void GetDefaultMember::handle(const Vector2D& v) { value = to_script(String::Format(_("(%.10lf,%.10lf)"), v.x, v.y)); }
|
template <> void GetDefaultMember::handle(const Vector2D& v) { value = to_script(String::Format(_("(%.10lf,%.10lf)"), v.x, v.y)); }
|
||||||
template <> void GetDefaultMember::handle(const Color& v) { value = to_script(v); }
|
template <> void GetDefaultMember::handle(const Color& v) { value = to_script(v); }
|
||||||
template <> void GetDefaultMember::handle(const AColor& v) { value = to_script(v); }
|
|
||||||
template <> void GetDefaultMember::handle(const wxDateTime& v) { value = to_script(v); }
|
template <> void GetDefaultMember::handle(const wxDateTime& v) { value = to_script(v); }
|
||||||
void GetDefaultMember::handle(const ScriptValueP& v) { value = v; }
|
void GetDefaultMember::handle(const ScriptValueP& v) { value = v; }
|
||||||
void GetDefaultMember::handle(const ScriptP& v) { value = v; }
|
void GetDefaultMember::handle(const ScriptP& v) { value = v; }
|
||||||
|
|||||||
@@ -130,9 +130,6 @@ template <> void Writer::handle(const wxDateTime& date) {
|
|||||||
template <> void Writer::handle(const Vector2D& vec) {
|
template <> void Writer::handle(const Vector2D& vec) {
|
||||||
handle(String::Format(_("(%.10lf,%.10lf)"), vec.x, vec.y));
|
handle(String::Format(_("(%.10lf,%.10lf)"), vec.x, vec.y));
|
||||||
}
|
}
|
||||||
template <> void Writer::handle(const Color& col) {
|
|
||||||
handle(String::Format(_("rgb(%u,%u,%u)"), col.Red(), col.Green(), col.Blue()));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <> void Writer::handle(const FileName& value) {
|
template <> void Writer::handle(const FileName& value) {
|
||||||
if (clipboard_package() && !value.empty()) {
|
if (clipboard_package() && !value.empty()) {
|
||||||
|
|||||||
@@ -186,9 +186,9 @@ void RotatedDC::DrawText (const String& text, const RealPoint& pos, int blur_ra
|
|||||||
DrawText(text, pos, dc.GetTextForeground(), blur_radius, boldness, stretch_);
|
DrawText(text, pos, dc.GetTextForeground(), blur_radius, boldness, stretch_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RotatedDC::DrawText (const String& text, const RealPoint& pos, AColor color, int blur_radius, int boldness, double stretch_) {
|
void RotatedDC::DrawText (const String& text, const RealPoint& pos, Color color, int blur_radius, int boldness, double stretch_) {
|
||||||
if (text.empty()) return;
|
if (text.empty()) return;
|
||||||
if (color.alpha == 0) return;
|
if (color.Alpha() == 0) return;
|
||||||
if (quality >= QUALITY_AA) {
|
if (quality >= QUALITY_AA) {
|
||||||
RealRect r(pos, GetTextExtent(text));
|
RealRect r(pos, GetTextExtent(text));
|
||||||
RealRect r_ext = trRectToBB(r);
|
RealRect r_ext = trRectToBB(r);
|
||||||
|
|||||||
@@ -158,8 +158,8 @@ class RotatedDC : public Rotation {
|
|||||||
// --------------------------------------------------- : Drawing
|
// --------------------------------------------------- : Drawing
|
||||||
|
|
||||||
/// Draw text
|
/// Draw text
|
||||||
void DrawText (const String& text, const RealPoint& pos, int blur_radius = 0, int boldness = 1, double stretch = 1.0);
|
void DrawText (const String& text, const RealPoint& pos, int blur_radius = 0, int boldness = 1, double stretch = 1.0);
|
||||||
void DrawText (const String& text, const RealPoint& pos, AColor color, int blur_radius = 0, int boldness = 1, double stretch = 1.0);
|
void DrawText (const String& text, const RealPoint& pos, Color color, int blur_radius = 0, int boldness = 1, double stretch = 1.0);
|
||||||
/// Draw text with the shadow and color settings of the given font
|
/// Draw text with the shadow and color settings of the given font
|
||||||
void DrawTextWithShadow(const String& text, const Font& font, const RealPoint& pos, double scale = 1.0, double stretch = 1.0);
|
void DrawTextWithShadow(const String& text, const Font& font, const RealPoint& pos, double scale = 1.0, double stretch = 1.0);
|
||||||
/// Draw abitmap, it must already be zoomed!
|
/// Draw abitmap, it must already be zoomed!
|
||||||
|
|||||||
Reference in New Issue
Block a user