diff --git a/src/goptions.cxx b/src/goptions.cxx index 573cd31..ca2ee61 100644 --- a/src/goptions.cxx +++ b/src/goptions.cxx @@ -17,7 +17,10 @@ static void addControllerUiDsp(OptionsWindow* self, Controller* c) int x, y, w, h; self->tabs->client_area( x, y, w, h, 25 ); self->controllers.push_back( new ControllerUI( x, y, w, h, c->getName().c_str(), c->getID() ) ); - + + // store the pointer to the options window: needed to make remove button work + self->controllers.back()->optionsWindow = self; + LUPPP_NOTE("Added controller %s, ID %i", c->getName().c_str(), c->getID() ); // add widget before "add" button, but after existing controllers @@ -46,13 +49,14 @@ static void removeControllerCB(Fl_Widget* w, void* data) // Remove UI tab for that controller // should return "tabs" from OptionsWindow - // self->widget->parent(); + self->optionsWindow->tabs->remove( self->widget ); // FIXME: confirm action here? LUPPP_NOTE("Removing controllerID %i", self->controllerID ); EventControllerInstanceRemove e( self->controllerID ); writeToDspRingbuffer( &e ); + delete self; } static void addNewController(Fl_Widget* w, void* ud) diff --git a/src/goptions.hxx b/src/goptions.hxx index 8c39146..89751e7 100644 --- a/src/goptions.hxx +++ b/src/goptions.hxx @@ -16,6 +16,7 @@ #include "avtk/avtk_light_button.h" class Binding; +class OptionsWindow; /// contains UI elements to represent one controller class ControllerUI @@ -36,6 +37,8 @@ class ControllerUI Fl_Group* widget; char* name; + + OptionsWindow* optionsWindow; private: // bindings