@@ -54,6 +54,8 @@ namespace lsp
5454
5555 for (size_t i=0 ; i<meta::trigger_metadata::SAMPLE_FILES ; ++i)
5656 wSampleListen[i] = NULL ;
57+ for (size_t i=0 ; i<meta::trigger_metadata::SAMPLE_FILES ; ++i)
58+ wSampleStop[i] = NULL ;
5759 }
5860
5961 trigger::~trigger ()
@@ -110,12 +112,29 @@ namespace lsp
110112 if (listen != NULL )
111113 listen->slots ()->bind (tk::SLOT_CHANGE , slot_submit_listen_sample, this );
112114
115+ tk::Button * const stop = w->get_widgetf <tk::Button>(" trg_stop_sample_%d" , int (i));
116+ if (stop != NULL )
117+ stop->slots ()->bind (tk::SLOT_CHANGE , slot_submit_stop_sample, this );
118+
113119 wSampleListen[i] = listen;
120+ wSampleStop[i] = stop;
114121 }
115122
116123 return STATUS_OK ;
117124 }
118125
126+ status_t trigger::show_sample (size_t index)
127+ {
128+ if (pCurrentSample == NULL )
129+ return STATUS_OK ;
130+
131+ pCurrentSample->begin_edit ();
132+ pCurrentSample->set_value (index);
133+ pCurrentSample->notify_all (ui::PORT_USER_EDIT );
134+ pCurrentSample->end_edit ();
135+ return STATUS_OK ;
136+ }
137+
119138 status_t trigger::slot_submit_listen_sample (tk::Widget *sender, void *ptr, void *data)
120139 {
121140 trigger * const self = static_cast <trigger *>(ptr);
@@ -135,13 +154,32 @@ namespace lsp
135154 for (size_t i=0 ; i<meta::trigger_metadata::SAMPLE_FILES ; ++i)
136155 {
137156 if (sender == self->wSampleListen [i])
138- {
139- self->pCurrentSample ->begin_edit ();
140- self->pCurrentSample ->set_value (i);
141- self->pCurrentSample ->notify_all (ui::PORT_USER_EDIT );
142- self->pCurrentSample ->end_edit ();
143- return STATUS_OK ;
144- }
157+ return self->show_sample (i);
158+ }
159+
160+ return STATUS_OK ;
161+ }
162+
163+ status_t trigger::slot_submit_stop_sample (tk::Widget *sender, void *ptr, void *data)
164+ {
165+ trigger * const self = static_cast <trigger *>(ptr);
166+ if (self == NULL )
167+ return STATUS_OK ;
168+ if (self->pCurrentSample == NULL )
169+ return STATUS_OK ;
170+ if ((self->pRevealSampleOnListen == NULL ) || (self->pRevealSampleOnListen ->value () < 0 .5f ))
171+ return STATUS_OK ;
172+
173+ // Ensure that button has been pushed down
174+ tk::Button * const btn = tk::widget_cast<tk::Button>(sender);
175+ if ((btn == NULL ) || (!btn->down ()->get ()))
176+ return STATUS_OK ;
177+
178+ // Find the related sample and activate it
179+ for (size_t i=0 ; i<meta::trigger_metadata::SAMPLE_FILES ; ++i)
180+ {
181+ if (sender == self->wSampleStop [i])
182+ return self->show_sample (i);
145183 }
146184
147185 return STATUS_OK ;
0 commit comments