summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorGZharun <grygoriiz@wavesglobal.com>2014-09-26 23:43:18 +0300
committerPaul Davis <paul@linuxaudiosystems.com>2015-04-29 08:59:24 -0400
commit1a84fa3c421949f9eb5ab45bb074d8a0ae64faac (patch)
tree25a15562e76348d2ba745ad4a4119bea2e5e7560 /libs
parent80ae2bbe23a35e362d31e115d4a81ba17149426a (diff)
[Summary] Should have been committed with previous: made background fade optional and not shown by default
Diffstat (limited to 'libs')
-rw-r--r--libs/canvas/canvas/xfade_curve.h5
-rw-r--r--libs/canvas/xfade_curve.cc72
2 files changed, 46 insertions, 31 deletions
diff --git a/libs/canvas/canvas/xfade_curve.h b/libs/canvas/canvas/xfade_curve.h
index c63e47c583..3a6b7d17b0 100644
--- a/libs/canvas/canvas/xfade_curve.h
+++ b/libs/canvas/canvas/xfade_curve.h
@@ -40,7 +40,8 @@ public:
XFadeCurve (Item*, XFadePosition);
void set_fade_position (XFadePosition xfp) { _xfadeposition = xfp; }
-
+ void set_show_background_fade (bool show) { show_background_fade = show; }
+
void compute_bounding_box () const;
void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;
@@ -79,6 +80,8 @@ private:
Color _outline_color;
Color _fill_color;
+ bool show_background_fade;
+
void interpolate ();
};
diff --git a/libs/canvas/xfade_curve.cc b/libs/canvas/xfade_curve.cc
index f97cd234d2..88ae10c410 100644
--- a/libs/canvas/xfade_curve.cc
+++ b/libs/canvas/xfade_curve.cc
@@ -36,6 +36,7 @@ XFadeCurve::XFadeCurve (Canvas* c)
, _xfadeposition (Start)
, _outline_color (0x000000ff)
, _fill_color (0x22448880)
+ , show_background_fade (false)
{
}
@@ -45,6 +46,7 @@ XFadeCurve::XFadeCurve (Canvas* c, XFadePosition pos)
, _xfadeposition (pos)
, _outline_color (0x000000ff)
, _fill_color (0x22448880)
+ , show_background_fade (false)
{
}
@@ -54,6 +56,7 @@ XFadeCurve::XFadeCurve (Item* parent)
, _xfadeposition (Start)
, _outline_color (0x000000ff)
, _fill_color (0x22448880)
+ , show_background_fade (false)
{
}
@@ -63,6 +66,7 @@ XFadeCurve::XFadeCurve (Item* parent, XFadePosition pos)
, _xfadeposition (pos)
, _outline_color (0x000000ff)
, _fill_color (0x22448880)
+ , show_background_fade (false)
{
}
@@ -239,44 +243,52 @@ XFadeCurve::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) co
Color fill_shaded = _fill_color;
fill_shaded = 0.5 * (fill_shaded & 0xff) + (fill_shaded & ~0xff);
-#define IS (_xfadeposition == Start)
+#define IS_START (_xfadeposition == Start)
/* fill primary fade */
context->begin_new_path ();
- context->append_path (IS ? *path_in : *path_out);
- close_path(draw, context, IS ?_in : _out, false);
+ context->append_path (IS_START ? *path_in : *path_out);
+ close_path(draw, context, IS_START ?_in : _out, false);
set_source_rgba (context, _fill_color);
context->fill ();
- /* fill background fade */
- context->save ();
- context->begin_new_path ();
- context->append_path (IS ? *path_in : *path_out);
- close_path(draw, context, IS ? _in : _out, true);
- context->set_fill_rule (Cairo::FILL_RULE_EVEN_ODD);
- context->clip ();
- context->begin_new_path ();
- context->append_path (IS ? *path_out: *path_in);
- close_path(draw, context, IS ? _out : _in, true);
- set_source_rgba (context, fill_shaded);
- context->set_fill_rule (Cairo::FILL_RULE_WINDING);
- context->fill ();
- context->restore ();
+ if (show_background_fade) {
+ /* fill background fade */
+ context->save ();
+ context->begin_new_path ();
+ context->append_path (IS_START ? *path_in : *path_out);
+ close_path(draw, context, IS_START ? _in : _out, true);
+ context->set_fill_rule (Cairo::FILL_RULE_EVEN_ODD);
+ context->clip ();
+ context->begin_new_path ();
+ context->append_path (IS_START ? *path_out: *path_in);
+ close_path(draw, context, IS_START ? _out : _in, true);
+ set_source_rgba (context, fill_shaded);
+ context->set_fill_rule (Cairo::FILL_RULE_WINDING);
+ context->fill ();
+ context->restore ();
+ }
/* draw lines over fills */
- set_source_rgba (context, IS ? _outline_color : outline_shaded);
- context->set_line_width (IS ? 1.0 : .5);
-
- context->begin_new_path ();
- context->append_path (*path_in);
- context->stroke();
-
- set_source_rgba (context, IS ? outline_shaded :_outline_color);
- context->set_line_width (IS ? .5 : 1.0);
-
- context->begin_new_path ();
- context->append_path (*path_out);
- context->stroke();
+ /* fade in line */
+ if (IS_START || show_background_fade) {
+ set_source_rgba (context, IS_START ? _outline_color : outline_shaded);
+ context->set_line_width (IS_START ? 1.0 : .5);
+
+ context->begin_new_path ();
+ context->append_path (*path_in);
+ context->stroke();
+ }
+
+ /* fade out line */
+ if (!IS_START || show_background_fade) {
+ set_source_rgba (context, IS_START ? outline_shaded :_outline_color);
+ context->set_line_width (IS_START ? .5 : 1.0);
+
+ context->begin_new_path ();
+ context->append_path (*path_out);
+ context->stroke();
+ }
context->restore ();