Skip to content

Commit e913132

Browse files
committed
Updated widgets for sending BEGIN_EDIT and END_EDIT events
1 parent 053e766 commit e913132

File tree

6 files changed

+57
-3
lines changed

6 files changed

+57
-3
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ namespace lsp
174174
size_t nBufCapacity; // Drawing buffer capacity in floats
175175

176176
protected:
177+
static status_t slot_begin_edit(Widget *sender, void *ptr, void *data);
177178
static status_t slot_on_change(Widget *sender, void *ptr, void *data);
179+
static status_t slot_end_edit(Widget *sender, void *ptr, void *data);
178180

179181
protected:
180182
void do_destroy();
@@ -258,7 +260,9 @@ namespace lsp
258260
virtual status_t on_mouse_scroll(const ws::event_t *e) override;
259261

260262
public:
263+
virtual status_t on_begin_edit();
261264
virtual status_t on_change();
265+
virtual status_t on_end_edit();
262266
};
263267
} /* namespace tk */
264268
} /* namespace lsp */

src/main/widgets/graph/GraphDot.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,11 @@ namespace lsp
582582
float old = sZValue.sValue.get();
583583
sZValue.sValue.add(delta);
584584
if (old != sZValue.sValue.get())
585+
{
586+
sSlots.execute(SLOT_BEGIN_EDIT, this);
585587
sSlots.execute(SLOT_CHANGE, this);
588+
sSlots.execute(SLOT_END_EDIT, this);
589+
}
586590

587591
return STATUS_OK;
588592
}

src/main/widgets/simple/Fader.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ namespace lsp
529529
if (sInvertMouseVScroll.get())
530530
step = -step;
531531

532-
// Update value
532+
// Compute delta
533533
float delta = 0.0;
534534
if (e->nCode == ws::MCD_UP)
535535
delta = step;
@@ -538,7 +538,10 @@ namespace lsp
538538
else
539539
return STATUS_OK;
540540

541+
// Update value
542+
sSlots.execute(SLOT_BEGIN_EDIT, this);
541543
update_value(sValue.get() + delta);
544+
sSlots.execute(SLOT_END_EDIT, this);
542545

543546
return STATUS_OK;
544547
}

src/main/widgets/simple/Knob.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ namespace lsp
460460
if (sInvertMouseVScroll.get())
461461
step = -step;
462462

463-
// Update value
463+
// Compute delta
464464
float delta = 0.0;
465465
if (e->nCode == ws::MCD_UP)
466466
delta = step;
@@ -469,7 +469,10 @@ namespace lsp
469469
else
470470
return STATUS_OK;
471471

472+
// Update value
473+
sSlots.execute(SLOT_BEGIN_EDIT, this);
472474
update_value(delta);
475+
sSlots.execute(SLOT_END_EDIT, this);
473476

474477
return STATUS_OK;
475478
}

src/main/widgets/simple/RangeSlider.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,9 +584,13 @@ namespace lsp
584584
if (old_max != max)
585585
flags |= CHANGE_MAX;
586586

587-
sValues.set(min, max);
588587
if (flags != 0)
588+
{
589+
sValues.set(min, max);
590+
sSlots.execute(SLOT_BEGIN_EDIT, this, &flags);
589591
sSlots.execute(SLOT_CHANGE, this, &flags);
592+
sSlots.execute(SLOT_END_EDIT, this, &flags);
593+
}
590594
}
591595

592596
ssize_t RangeSlider::find_button(const ws::event_t *e)

src/main/widgets/specific/AudioEnvelope.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,8 @@ namespace lsp
293293

294294
// Add slots
295295
handler_id_t id = sSlots.add(SLOT_CHANGE, slot_on_change, self());
296+
if (id >= 0) id = sSlots.add(SLOT_BEGIN_EDIT, slot_begin_edit, self());
297+
if (id >= 0) id = sSlots.add(SLOT_END_EDIT, slot_end_edit, self());
296298

297299
return (id >= 0) ? STATUS_OK : -id;
298300
}
@@ -681,6 +683,16 @@ namespace lsp
681683
return STATUS_OK;
682684
}
683685

686+
status_t AudioEnvelope::on_begin_edit()
687+
{
688+
return STATUS_OK;
689+
}
690+
691+
status_t AudioEnvelope::on_end_edit()
692+
{
693+
return STATUS_OK;
694+
}
695+
684696
void AudioEnvelope::sync_handler(const ws::event_t *e)
685697
{
686698
point_t *point = find_point(e->nLeft, e->nTop);
@@ -717,6 +729,9 @@ namespace lsp
717729

718730
nLastX = e->nLeft;
719731
nLastY = e->nTop;
732+
733+
if (pHandler != NULL)
734+
sSlots.execute(SLOT_BEGIN_EDIT, this);
720735
}
721736

722737
nBMask |= size_t(1) << e->nCode;
@@ -727,6 +742,11 @@ namespace lsp
727742
status_t AudioEnvelope::on_mouse_up(const ws::event_t *e)
728743
{
729744
nBMask &= ~(size_t(1) << e->nCode);
745+
if (nBMask == 0)
746+
{
747+
if (pHandler != NULL)
748+
sSlots.execute(SLOT_END_EDIT, this);
749+
}
730750

731751
return STATUS_OK;
732752
}
@@ -816,7 +836,11 @@ namespace lsp
816836
const float old = pHandler->pZ->get();
817837
pHandler->pZ->add(delta);
818838
if (old != pHandler->pZ->get())
839+
{
840+
sSlots.execute(SLOT_BEGIN_EDIT, this);
819841
sSlots.execute(SLOT_CHANGE, this);
842+
sSlots.execute(SLOT_END_EDIT, this);
843+
}
820844

821845
return STATUS_OK;
822846
}
@@ -827,6 +851,18 @@ namespace lsp
827851
return (self != NULL) ? self->on_change() : STATUS_BAD_ARGUMENTS;
828852
}
829853

854+
status_t AudioEnvelope::slot_begin_edit(Widget *sender, void *ptr, void *data)
855+
{
856+
AudioEnvelope *self = widget_ptrcast<AudioEnvelope>(ptr);
857+
return (self != NULL) ? self->on_begin_edit() : STATUS_BAD_ARGUMENTS;
858+
}
859+
860+
status_t AudioEnvelope::slot_end_edit(Widget *sender, void *ptr, void *data)
861+
{
862+
AudioEnvelope *self = widget_ptrcast<AudioEnvelope>(ptr);
863+
return (self != NULL) ? self->on_end_edit() : STATUS_BAD_ARGUMENTS;
864+
}
865+
830866
void AudioEnvelope::set_curve_function(curve_function_t function, void *data)
831867
{
832868
pFunction = function;

0 commit comments

Comments
 (0)