diff --git a/data/gui/schema.cfg b/data/gui/schema.cfg index d78171fbc4f..21ed4c08b13 100644 --- a/data/gui/schema.cfg +++ b/data/gui/schema.cfg @@ -290,6 +290,11 @@ type="f_unsigned" default=0 [/key] + [key] + name="alpha" + type="f_unsigned" + default=255 + [/key] [/tag] [tag] name="pre_commit" diff --git a/src/gui/core/canvas.cpp b/src/gui/core/canvas.cpp index d2ba37ce049..4219dc1d731 100644 --- a/src/gui/core/canvas.cpp +++ b/src/gui/core/canvas.cpp @@ -223,7 +223,8 @@ private: tformula x1_, /**< The start x coordinate of the line. */ y1_, /**< The start y coordinate of the line. */ x2_, /**< The end x coordinate of the line. */ - y2_; /**< The end y coordinate of the line. */ + y2_, /**< The end y coordinate of the line. */ + alpha_; /**< Alpha value override computed as a formula. */ /** The color of the line. */ Uint32 color_; @@ -556,6 +557,7 @@ tline::tline(const config& cfg) , y1_(cfg["y1"]) , x2_(cfg["x2"]) , y2_(cfg["y2"]) + , alpha_(cfg["alpha"]) , color_(decode_color(cfg["color"])) , thickness_(cfg["thickness"]) { @@ -579,6 +581,12 @@ void tline::draw(surface& canvas, const unsigned y1 = y1_(variables); const unsigned x2 = x2_(variables); const unsigned y2 = y2_(variables); + const unsigned alpha = alpha_(variables); + + // Override alpha from color with formula. + const Uint32 final_color = alpha_.has_formula() + ? (color_ & 0xFFFFFF00) + (alpha & 0xFF) + : color_; DBG_GUI_D << "Line: draw from " << x1 << ',' << y1 << " to " << x2 << ',' << y2 << " canvas size " << canvas->w << ',' << canvas->h @@ -595,7 +603,7 @@ void tline::draw(surface& canvas, // lock the surface surface_lock locker(canvas); - draw_line(canvas, renderer, color_, x1, y1, x2, y2); + draw_line(canvas, renderer, final_color, x1, y1, x2, y2); } /***** ***** ***** ***** ***** Rectangle ***** ***** ***** ***** *****/