Assists music production by grouping standalone programs into sessions. Community version of "Non Session Manager".
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

888 lines
21KB

  1. /*******************************************************************************/
  2. /* Copyright (C) 2009 Jonathan Moore Liles */
  3. /* */
  4. /* This program is free software; you can redistribute it and/or modify it */
  5. /* under the terms of the GNU General Public License as published by the */
  6. /* Free Software Foundation; either version 2 of the License, or (at your */
  7. /* option) any later version. */
  8. /* */
  9. /* This program is distributed in the hope that it will be useful, but WITHOUT */
  10. /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
  11. /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
  12. /* more details. */
  13. /* */
  14. /* You should have received a copy of the GNU General Public License along */
  15. /* with This program; see the file COPYING. If not,write to the Free Software */
  16. /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  17. /*******************************************************************************/
  18. #include "Module.H"
  19. #include <FL/fl_draw.H>
  20. #include <FL/fl_ask.H>
  21. #include <stdlib.h>
  22. #include <string.h>
  23. #include <stdio.h>
  24. #include "Module_Parameter_Editor.H"
  25. #include "Chain.H"
  26. #include "JACK_Module.H"
  27. #include "Gain_Module.H"
  28. #include "Mono_Pan_Module.H"
  29. #include "Meter_Module.H"
  30. #include "Plugin_Module.H"
  31. #include <FL/Fl_Menu_Button.H>
  32. #include "FL/test_press.H"
  33. #include "FL/menu_popup.H"
  34. #include "Mixer.H"
  35. #include "Plugin_Chooser.H"
  36. #include "OSC/Endpoint.H"
  37. #include "string_util.h"
  38. Module *Module::_copied_module_empty = 0;
  39. char *Module::_copied_module_settings = 0;
  40. Module::Module ( int W, int H, const char *L ) : Fl_Group( 0, 0, W, H, L )
  41. {
  42. init();
  43. }
  44. Module::Module ( bool is_default, int W, int H, const char *L ) : Fl_Group( 0, 0, W, H, L ), Loggable( !is_default )
  45. {
  46. init();
  47. this->is_default( is_default );
  48. }
  49. Module::Module ( ) : Fl_Group( 0, 0, 50, 50, "Unnamed" )
  50. {
  51. init();
  52. }
  53. Module::~Module ( )
  54. {
  55. /* we assume that the engine for this chain is already locked */
  56. if ( _editor )
  57. {
  58. delete _editor;
  59. _editor = NULL;
  60. }
  61. for ( unsigned int i = 0; i < audio_input.size(); ++i )
  62. audio_input[i].disconnect();
  63. for ( unsigned int i = 0; i < audio_output.size(); ++i )
  64. audio_output[i].disconnect();
  65. for ( unsigned int i = 0; i < control_input.size(); ++i )
  66. {
  67. /* destroy connected Controller_Module */
  68. if ( control_input[i].connected() )
  69. {
  70. Module *o = (Module*)control_input[i].connected_port()->module();
  71. if ( ! o->is_default() )
  72. {
  73. control_input[i].disconnect();
  74. DMESSAGE( "Deleting connected module %s", o->label() );
  75. delete o;
  76. }
  77. else
  78. {
  79. control_input[i].disconnect();
  80. }
  81. }
  82. control_input[i].destroy_osc_port();
  83. }
  84. for ( unsigned int i = 0; i < control_output.size(); ++i )
  85. control_output[i].disconnect();
  86. audio_input.clear();
  87. audio_output.clear();
  88. control_input.clear();
  89. control_output.clear();
  90. if ( parent() )
  91. parent()->remove( this );
  92. }
  93. void
  94. Module::init ( void )
  95. {
  96. _is_default = false;
  97. _editor = 0;
  98. _chain = 0;
  99. _instances = 1;
  100. _bypass = 0;
  101. box( FL_UP_BOX );
  102. labeltype( FL_NO_LABEL );
  103. set_visible_focus();
  104. selection_color( FL_RED );
  105. color( fl_color_average( FL_WHITE, FL_CYAN, 0.40 ) );
  106. }
  107. void
  108. Module::get ( Log_Entry &e ) const
  109. {
  110. // e.add( ":name", label() );
  111. // e.add( ":color", (unsigned long)color());
  112. {
  113. char *s = get_parameters();
  114. if ( strlen( s ) )
  115. e.add( ":parameter_values", s );
  116. delete[] s;
  117. }
  118. e.add( ":is_default", is_default() );
  119. e.add( ":chain", chain() );
  120. e.add( ":active", ! bypass() );
  121. }
  122. void
  123. Module::copy ( void ) const
  124. {
  125. Module *m = clone_empty();
  126. if ( ! m )
  127. {
  128. DMESSAGE( "Module \"%s\" doesn't support cloning", name() );
  129. }
  130. Log_Entry *ne = new Log_Entry();
  131. _copied_module_empty = m;
  132. {
  133. Log_Entry e;
  134. get( e );
  135. for ( int i = 0; i < e.size(); ++i )
  136. {
  137. const char *s, *v;
  138. e.get( i, &s, &v );
  139. /* we don't want this module to get added to the current
  140. chain... */
  141. if ( !( !strcmp( s, ":chain" ) ||
  142. !strcmp( s, ":is_default" ) ) )
  143. {
  144. DMESSAGE( "%s = %s", s, v );
  145. ne->add_raw( s, v );
  146. }
  147. }
  148. }
  149. _copied_module_settings = ne->print();
  150. }
  151. void
  152. Module::paste_before ( void )
  153. {
  154. Module *m = _copied_module_empty;
  155. Log_Entry le( _copied_module_settings );
  156. le.remove( ":chain" );
  157. char *print = le.print();
  158. DMESSAGE( "Pasting settings: %s", print );
  159. free( print );
  160. m->set( le );
  161. if ( ! chain()->insert( this, m ) )
  162. {
  163. fl_alert( "Copied module cannot be inserted at this point in the chain" );
  164. }
  165. free( _copied_module_settings );
  166. _copied_module_settings = NULL;
  167. _copied_module_empty = NULL;
  168. /* set up for another paste */
  169. m->copy();
  170. }
  171. void
  172. Module::handle_control_changed ( Port *p )
  173. {
  174. if ( _editor )
  175. _editor->handle_control_changed ( p );
  176. }
  177. bool
  178. Module::Port::connected_osc ( void ) const
  179. {
  180. return _scaled_signal->connected();
  181. }
  182. char *
  183. Module::Port::generate_osc_path ()
  184. {
  185. const Port *p = this;
  186. char *path = NULL;
  187. // /strip/STRIPNAME/MODULENAME/CONTROLNAME
  188. if ( ! p->hints.visible )
  189. {
  190. return NULL;
  191. }
  192. int n = module()->chain()->get_module_instance_number( module() );
  193. if ( n > 0 )
  194. asprintf( &path, "/strip/%s/%s.%i/%s", module()->chain()->name(), p->module()->label(), n, p->name() );
  195. else
  196. asprintf( &path, "/strip/%s/%s/%s", module()->chain()->name(), p->module()->label(), p->name() );
  197. char *s = escape_url( path );
  198. free( path );
  199. path = s;
  200. return path;
  201. }
  202. void
  203. Module::Port::handle_signal_connection_state_changed ( OSC::Signal *, void *o )
  204. {
  205. ((Module::Port*)o)->module()->redraw();
  206. }
  207. void
  208. Module::Port::change_osc_path ( char *path )
  209. {
  210. if ( path )
  211. {
  212. char *scaled_path = path;
  213. char *unscaled_path = NULL;
  214. asprintf( &unscaled_path, "%s/unscaled", path );
  215. if ( NULL == _scaled_signal )
  216. {
  217. float scaled_default = 0.5f;
  218. if ( hints.ranged )
  219. {
  220. float scale = hints.maximum - hints.minimum;
  221. float offset = hints.minimum;
  222. scaled_default = ( hints.default_value - offset ) / scale;
  223. }
  224. _scaled_signal = mixer->osc_endpoint->add_signal( scaled_path,
  225. OSC::Signal::Input,
  226. 0.0, 1.0, scaled_default,
  227. &Module::Port::osc_control_change_cv, this );
  228. _scaled_signal->connection_state_callback( handle_signal_connection_state_changed, this );
  229. _unscaled_signal = mixer->osc_endpoint->add_signal( unscaled_path,
  230. OSC::Signal::Input,
  231. hints.minimum, hints.maximum, hints.default_value,
  232. &Module::Port::osc_control_change_exact, this );
  233. }
  234. else
  235. {
  236. DMESSAGE( "Renaming OSC signals" );
  237. _scaled_signal->rename( scaled_path );
  238. _unscaled_signal->rename( unscaled_path );
  239. }
  240. free( unscaled_path );
  241. /* this was path, it's ok to free because it was malloc()'d in generate_osc_path */
  242. free( scaled_path );
  243. }
  244. }
  245. int
  246. Module::Port::osc_control_change_exact ( float v, void *user_data )
  247. {
  248. Module::Port *p = (Module::Port*)user_data;
  249. Fl::lock();
  250. float f = v;
  251. if ( p->hints.ranged )
  252. {
  253. if ( f > p->hints.maximum )
  254. f = p->hints.maximum;
  255. else if ( f < p->hints.minimum )
  256. f = p->hints.minimum;
  257. }
  258. p->control_value( f );
  259. Fl::unlock();
  260. // mixer->osc_endpoint->send( lo_message_get_source( msg ), "/reply", path, f );
  261. return 0;
  262. }
  263. int
  264. Module::Port::osc_control_change_cv ( float v, void *user_data )
  265. {
  266. Module::Port *p = (Module::Port*)user_data;
  267. float f = v;
  268. Fl::lock();
  269. // clamp value to control voltage range.
  270. if ( f > 1.0 )
  271. f = 1.0;
  272. else if ( f < 0.0 )
  273. f = 0.0;
  274. if ( p->hints.ranged )
  275. {
  276. // scale value to range.
  277. float scale = p->hints.maximum - p->hints.minimum;
  278. float offset = p->hints.minimum;
  279. f = ( f * scale ) + offset;
  280. }
  281. p->control_value( f );
  282. Fl::unlock();
  283. // mixer->osc_endpoint->send( lo_message_get_source( msg ), "/reply", path, f );
  284. return 0;
  285. }
  286. void
  287. Module::set ( Log_Entry &e )
  288. {
  289. for ( int i = 0; i < e.size(); ++i )
  290. {
  291. const char *s, *v;
  292. e.get( i, &s, &v );
  293. if ( ! strcmp( s, ":chain" ) )
  294. {
  295. /* This trickiness is because we may need to know the name of
  296. our chain before we actually get added to it. */
  297. int i;
  298. sscanf( v, "%X", &i );
  299. Chain *t = (Chain*)Loggable::find( i );
  300. assert( t );
  301. chain( t );
  302. }
  303. }
  304. for ( int i = 0; i < e.size(); ++i )
  305. {
  306. const char *s, *v;
  307. e.get( i, &s, &v );
  308. /* if ( ! strcmp( s, ":name" ) ) */
  309. /* label( v ); */
  310. if ( ! strcmp( s, ":parameter_values" ) )
  311. {
  312. set_parameters( v );
  313. }
  314. else if ( ! ( strcmp( s, ":is_default" ) ) )
  315. {
  316. is_default( atoi( v ) );
  317. }
  318. else if ( ! ( strcmp( s, ":active" ) ) )
  319. {
  320. bypass( ! atoi( v ) );
  321. }
  322. else if ( ! strcmp( s, ":chain" ) )
  323. {
  324. int i;
  325. sscanf( v, "%X", &i );
  326. Chain *t = (Chain*)Loggable::find( i );
  327. assert( t );
  328. t->add( this );
  329. }
  330. }
  331. }
  332. void
  333. Module::chain ( Chain *v )
  334. {
  335. if ( _chain != v )
  336. {
  337. DMESSAGE( "Adding module %s in to chain %s", label(), v ? v->name() : "NULL" );
  338. _chain = v;
  339. for ( int i = 0; i < ncontrol_inputs(); ++i )
  340. {
  341. control_input[i].update_osc_port();
  342. }
  343. }
  344. else
  345. {
  346. DMESSAGE( "Module %s already belongs to chain %s", label(), v ? v->name() : "NULL" );
  347. }
  348. }
  349. /* return a string serializing this module's parameter settings. The
  350. format is 1.0:2.0:... Where 1.0 is the value of the first control
  351. input, 2.0 is the value of the second control input etc.
  352. */
  353. char *
  354. Module::get_parameters ( void ) const
  355. {
  356. char *s = new char[1024];
  357. s[0] = 0;
  358. char *sp = s;
  359. if ( control_input.size() )
  360. {
  361. for ( unsigned int i = 0; i < control_input.size(); ++i )
  362. sp += snprintf( sp, 1024 - (sp - s),"%f:", control_input[i].control_value() );
  363. *(sp - 1) = '\0';
  364. }
  365. return s;
  366. }
  367. void
  368. Module::set_parameters ( const char *parameters )
  369. {
  370. char *s = strdup( parameters );
  371. char *start = s;
  372. unsigned int i = 0;
  373. for ( char *sp = s; ; ++sp )
  374. {
  375. if ( ':' == *sp || '\0' == *sp )
  376. {
  377. char was = *sp;
  378. *sp = '\0';
  379. DMESSAGE( start );
  380. if ( i < control_input.size() )
  381. control_input[i].control_value( atof( start ) );
  382. else
  383. {
  384. WARNING( "Module has no parameter at index %i", i );
  385. break;
  386. }
  387. i++;
  388. if ( '\0' == was )
  389. break;
  390. start = sp + 1;
  391. }
  392. }
  393. free( s );
  394. }
  395. void
  396. Module::draw_box ( void )
  397. {
  398. fl_color( fl_contrast( FL_FOREGROUND_COLOR, color() ) );
  399. int tw, th, tx, ty;
  400. tw = w();
  401. th = h();
  402. ty = y();
  403. tx = x();
  404. fl_push_clip( tx, ty, tw, th );
  405. Fl_Color c = color();
  406. c = active() && ! bypass() ? c : FL_GRAY;
  407. int spacing = w() / instances();
  408. for ( int i = instances(); i--; )
  409. {
  410. fl_draw_box( box(), tx + (spacing * i), ty, tw / instances(), th, c );
  411. }
  412. if ( this == Fl::focus() )
  413. {
  414. fl_draw_box( FL_UP_FRAME, x(), y(), w(), h(), selection_color() );
  415. }
  416. if ( audio_input.size() && audio_output.size() )
  417. {
  418. /* maybe draw control indicators */
  419. if ( control_input.size() )
  420. {
  421. fl_draw_box( FL_ROUNDED_BOX, tx + 4, ty + 4, 5, 5, is_being_controlled() ? FL_YELLOW : fl_inactive( FL_YELLOW ) );
  422. fl_draw_box( FL_ROUNDED_BOX, tx + 4, ty + th - 8, 5, 5, is_being_controlled_osc() ? FL_YELLOW : fl_inactive( FL_YELLOW ) );
  423. }
  424. if ( control_output.size() )
  425. fl_draw_box( FL_ROUNDED_BOX, tx + tw - 8, ty + 4, 5, 5, is_controlling() ? FL_YELLOW : fl_inactive( FL_YELLOW ) );
  426. }
  427. Fl_Group::draw_children();
  428. fl_pop_clip();
  429. }
  430. void
  431. Module::draw_label ( void )
  432. {
  433. int tw, th, tx, ty;
  434. bbox( tx, ty, tw, th );
  435. const char *lp = label();
  436. fl_color( fl_contrast( FL_FOREGROUND_COLOR, bypass() ? FL_BLACK : color() ) );
  437. fl_font( FL_HELVETICA, 12 );
  438. int LW = fl_width( lp );
  439. char *s = NULL;
  440. if ( LW > tw )
  441. {
  442. s = new char[strlen(lp)];
  443. char *sp = s;
  444. for ( ; *lp; ++lp )
  445. switch ( *lp )
  446. {
  447. case 'i': case 'e': case 'o': case 'u': case 'a':
  448. break;
  449. default:
  450. *(sp++) = *lp;
  451. }
  452. *sp = '\0';
  453. }
  454. fl_draw( s ? s : lp, tx, ty, tw, th, (Fl_Align)(FL_ALIGN_CENTER | FL_ALIGN_INSIDE | FL_ALIGN_CLIP ) );
  455. if ( s )
  456. delete[] s;
  457. }
  458. void
  459. Module::insert_menu_cb ( const Fl_Menu_ *m )
  460. {
  461. unsigned long id = Plugin_Chooser::plugin_chooser( this->ninputs() );
  462. Module *mod = NULL;
  463. switch ( id )
  464. {
  465. case 0:
  466. return;
  467. case 1:
  468. mod = new JACK_Module();
  469. break;
  470. case 2:
  471. mod = new Gain_Module();
  472. break;
  473. case 3:
  474. mod = new Meter_Module();
  475. break;
  476. case 4:
  477. mod = new Mono_Pan_Module();
  478. break;
  479. default:
  480. {
  481. Plugin_Module *m = new Plugin_Module();
  482. m->load( id );
  483. mod = m;
  484. }
  485. }
  486. if ( mod )
  487. {
  488. if ( !strcmp( mod->name(), "JACK" ) )
  489. {
  490. DMESSAGE( "Special casing JACK module" );
  491. JACK_Module *jm = (JACK_Module*)mod;
  492. jm->chain( chain() );
  493. jm->configure_inputs( ninputs() );
  494. jm->configure_outputs( ninputs() );
  495. }
  496. if ( ! chain()->insert( this, mod ) )
  497. {
  498. fl_alert( "Cannot insert this module at this point in the chain" );
  499. delete mod;
  500. return;
  501. }
  502. redraw();
  503. }
  504. }
  505. void
  506. Module::insert_menu_cb ( Fl_Widget *w, void *v )
  507. {
  508. ((Module*)v)->insert_menu_cb( (Fl_Menu_*) w );
  509. }
  510. void
  511. Module::menu_cb ( const Fl_Menu_ *m )
  512. {
  513. char picked[256];
  514. if ( ! m->mvalue() || m->mvalue()->flags & FL_SUBMENU_POINTER || m->mvalue()->flags & FL_SUBMENU )
  515. return;
  516. strncpy( picked, m->mvalue()->label(), sizeof( picked ) );
  517. // m->item_pathname( picked, sizeof( picked ) );
  518. DMESSAGE( "%s", picked );
  519. Logger log( this );
  520. if ( ! strcmp( picked, "Edit Parameters" ) )
  521. command_open_parameter_editor();
  522. else if ( ! strcmp( picked, "Bypass" ) )
  523. if ( ! bypassable() )
  524. {
  525. fl_alert( "Due to its channel configuration, this module cannot be bypassed." );
  526. }
  527. else
  528. {
  529. bypass( ! ( m->mvalue()->flags & FL_MENU_VALUE ) );
  530. }
  531. else if ( ! strcmp( picked, "Cut" ) )
  532. {
  533. copy();
  534. chain()->remove( this );
  535. Fl::delete_widget( this );
  536. }
  537. else if ( ! strcmp( picked, "Copy" ) )
  538. {
  539. copy();
  540. }
  541. else if ( ! strcmp( picked, "Paste" ) )
  542. {
  543. paste_before();
  544. }
  545. else if ( ! strcmp( picked, "Remove" ) )
  546. command_remove();
  547. }
  548. void
  549. Module::menu_cb ( Fl_Widget *w, void *v )
  550. {
  551. ((Module*)v)->menu_cb( (Fl_Menu_*) w );
  552. }
  553. /** build the context menu */
  554. Fl_Menu_Button &
  555. Module::menu ( void ) const
  556. {
  557. static Fl_Menu_Button m( 0, 0, 0, 0, "Module" );
  558. static Fl_Menu_Button *insert_menu = NULL;
  559. if ( ! insert_menu )
  560. {
  561. insert_menu = new Fl_Menu_Button( 0, 0, 0, 0 );
  562. insert_menu->add( "Gain", 0, 0, new unsigned long(2) );
  563. insert_menu->add( "Meter", 0, 0, new unsigned long(3) );
  564. insert_menu->add( "Mono Pan", 0, 0, new unsigned long(4) );
  565. insert_menu->add( "Plugin", 0, 0, new unsigned long(4) );
  566. /* Plugin_Module::add_plugins_to_menu( insert_menu ); */
  567. // menu_set_callback( insert_menu, &Module::insert_menu_cb, (void*)this );
  568. insert_menu->callback( &Module::insert_menu_cb, (void*)this );
  569. }
  570. m.clear();
  571. m.add( "Insert", 0, &Module::menu_cb, (void*)this, 0);
  572. m.add( "Insert", 0, &Module::menu_cb, const_cast< Fl_Menu_Item *>( insert_menu->menu() ), FL_SUBMENU_POINTER );
  573. m.add( "Edit Parameters", ' ', &Module::menu_cb, (void*)this, 0 );
  574. m.add( "Bypass", 'b', &Module::menu_cb, (void*)this, FL_MENU_TOGGLE | ( bypass() ? FL_MENU_VALUE : 0 ) );
  575. m.add( "Cut", FL_CTRL + 'x', &Module::menu_cb, (void*)this, is_default() ? FL_MENU_INACTIVE : 0 );
  576. m.add( "Copy", FL_CTRL + 'c', &Module::menu_cb, (void*)this, is_default() ? FL_MENU_INACTIVE : 0 );
  577. m.add( "Paste", FL_CTRL + 'v', &Module::menu_cb, (void*)this, _copied_module_empty ? 0 : FL_MENU_INACTIVE );
  578. m.add( "Remove", FL_Delete, &Module::menu_cb, (void*)this );
  579. // menu_set_callback( menu, &Module::menu_cb, (void*)this );
  580. m.callback( &Module::insert_menu_cb, (void*)this );
  581. return m;
  582. }
  583. void
  584. Module::handle_chain_name_changed ( )
  585. {
  586. // pass it along to our connected Controller_Modules, if any.
  587. for ( int i = 0; i < ncontrol_inputs(); ++i )
  588. {
  589. if ( control_input[i].connected() )
  590. control_input[i].connected_port()->module()->handle_chain_name_changed();
  591. control_input[i].update_osc_port();
  592. }
  593. }
  594. int
  595. Module::handle ( int m )
  596. {
  597. switch ( m )
  598. {
  599. case FL_KEYBOARD:
  600. {
  601. if ( Fl_Group::handle( m ) )
  602. return 1;
  603. if ( Fl::event_key() == FL_Menu )
  604. {
  605. menu_popup( &menu(), x(), y() );
  606. return 1;
  607. }
  608. else
  609. return menu().test_shortcut() != 0;
  610. }
  611. case FL_PUSH:
  612. {
  613. take_focus();
  614. if ( Fl_Group::handle( m ) )
  615. return 1;
  616. else if ( test_press( FL_BUTTON3 ) )
  617. {
  618. menu_popup( &menu() );
  619. return 1;
  620. }
  621. else if ( test_press( FL_BUTTON1 ) )
  622. {
  623. command_open_parameter_editor();
  624. return 1;
  625. }
  626. else if ( test_press( FL_BUTTON3 | FL_CTRL ) )
  627. {
  628. command_remove();
  629. return 1;
  630. }
  631. else if ( test_press( FL_BUTTON2 ) )
  632. {
  633. if ( !bypassable() )
  634. {
  635. fl_alert( "Due to its channel configuration, this module cannot be bypassed." );
  636. }
  637. else
  638. {
  639. bypass( !bypass() );
  640. redraw();
  641. }
  642. return 1;
  643. }
  644. return 0;
  645. }
  646. case FL_FOCUS:
  647. case FL_UNFOCUS:
  648. redraw();
  649. return 1;
  650. }
  651. return Fl_Group::handle( m );
  652. }
  653. /************/
  654. /* Commands */
  655. /************/
  656. void
  657. Module::command_open_parameter_editor ( void )
  658. {
  659. if ( _editor )
  660. {
  661. _editor->show();
  662. }
  663. else if ( ncontrol_inputs() && nvisible_control_inputs() )
  664. {
  665. DMESSAGE( "Opening module parameters for \"%s\"", label() );
  666. _editor = new Module_Parameter_Editor( this );
  667. _editor->show();
  668. }
  669. }
  670. void
  671. Module::command_activate ( void )
  672. {
  673. bypass( false );
  674. }
  675. void
  676. Module::command_deactivate ( void )
  677. {
  678. bypass( true );
  679. }
  680. void
  681. Module::command_remove ( void )
  682. {
  683. if ( is_default() )
  684. fl_alert( "Default modules may not be deleted." );
  685. else
  686. {
  687. chain()->remove( this );
  688. Fl::delete_widget( this );
  689. }
  690. }