Skip to content

Commit bda76c8

Browse files
committed
Added wire property for the tk::Envelope
1 parent 4d44393 commit bda76c8

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

include/lsp-plug.in/tk/widgets/specific/AudioEnvelope.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ namespace lsp
5555
prop::Boolean sBreak; // Enable slope time point
5656
prop::Boolean sQuadPoint; // Use quad point instead of circle
5757
prop::Boolean sFill; // Use fill color for drawing
58+
prop::Boolean sWire; // Draw line
5859
prop::Boolean sInvertMouseVScroll; // Invert mouse vertical scroll
5960
prop::Boolean sEditable; // Editable flag
6061

@@ -144,6 +145,7 @@ namespace lsp
144145
prop::Boolean sBreak; // Enable slope time point
145146
prop::Boolean sQuadPoint; // Use quad point instead of circle
146147
prop::Boolean sFill; // Use fill color for drawing
148+
prop::Boolean sWire; // Draw line
147149
prop::Boolean sInvertMouseVScroll; // Invert mouse vertical scroll
148150
prop::Boolean sEditable; // Editable flag
149151

@@ -221,6 +223,7 @@ namespace lsp
221223
LSP_TK_PROPERTY(Boolean, break_enabled, &sBreak);
222224
LSP_TK_PROPERTY(Boolean, quad_point, &sQuadPoint);
223225
LSP_TK_PROPERTY(Boolean, fill, &sFill);
226+
LSP_TK_PROPERTY(Boolean, wire, &sWire);
224227
LSP_TK_PROPERTY(Boolean, invert_mouse_vscroll, &sInvertMouseVScroll)
225228
LSP_TK_PROPERTY(Boolean, editable, &sEditable)
226229

src/main/widgets/specific/AudioEnvelope.cpp

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ namespace lsp
5252
sBreak.bind("break.enabled", this);
5353
sQuadPoint.bind("point.quadratic", this);
5454
sFill.bind("fill", this);
55+
sWire.bind("wire", this);
5556
sInvertMouseVScroll.bind("mouse.vscroll.invert", this);
5657
sEditable.bind("editable", this);
5758

@@ -136,6 +137,7 @@ namespace lsp
136137
sBreak(&sProperties),
137138
sQuadPoint(&sProperties),
138139
sFill(&sProperties),
140+
sWire(&sProperties),
139141
sInvertMouseVScroll(&sProperties),
140142
sEditable(&sProperties),
141143
sLineWidth(&sProperties),
@@ -269,6 +271,7 @@ namespace lsp
269271
sBreak.bind("break.enabled", &sStyle);
270272
sQuadPoint.bind("point.quadratic", &sStyle);
271273
sFill.bind("fill", &sStyle);
274+
sWire.bind("wire", &sStyle);
272275
sInvertMouseVScroll.bind("mouse.vscroll.invert", &sStyle);
273276
sEditable.bind("editable", &sStyle);
274277

@@ -330,7 +333,7 @@ namespace lsp
330333
query_draw();
331334
}
332335

333-
if (prop->one_of(sQuadPoint, sFill, sEditable))
336+
if (prop->one_of(sQuadPoint, sFill, sWire, sEditable))
334337
query_draw();
335338

336339
if (prop->one_of(sLineWidth, sLineColor, sFillColor, sPointSize, sPointColor, sPointHoverColor,
@@ -558,19 +561,27 @@ namespace lsp
558561
// Draw curve
559562
if ((x != NULL) && (y != NULL) && (points > 0))
560563
{
561-
const float l_width = lsp_max(1.0f, sLineWidth.get() * scaling);
564+
const bool use_fill = sFill.get();
565+
const bool use_wire = sWire.get();
562566

563-
lsp::Color fill(sFillColor);
564-
lsp::Color wire(sLineColor);
565-
fill.scale_lch_luminance(bright);
566-
wire.scale_hsl_lightness(bright);
567-
568-
dsp::mul_k2(x, dx, points);
569-
dsp::add_k2(x, ox, points);
570-
dsp::mul_k2(y, dy, points);
571-
dsp::add_k2(y, oy, points);
572-
573-
surface->draw_poly(fill, wire, l_width, x, y, points);
567+
if (use_fill || use_wire)
568+
{
569+
const float l_width = lsp_max(1.0f, sLineWidth.get() * scaling);
570+
lsp::Color fill(sFillColor);
571+
lsp::Color wire(sLineColor);
572+
fill.scale_lch_luminance(bright);
573+
wire.scale_hsl_lightness(bright);
574+
575+
dsp::mul_k2(x, dx, points);
576+
dsp::add_k2(x, ox, points);
577+
dsp::mul_k2(y, dy, points);
578+
dsp::add_k2(y, oy, points);
579+
580+
if (use_fill)
581+
surface->draw_poly(fill, wire, (use_wire) ? l_width : 0.0f, x, y, points);
582+
else if (use_wire)
583+
surface->wire_poly(wire, l_width, x, y, points);
584+
}
574585
}
575586

576587
// Draw points

0 commit comments

Comments
 (0)