hard edges rework, add hard edge in gwdw, config.ac nv/cuda tweaks, message log warn...
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / crikey / crikeywindow.C
1 /*
2  * CINELERRA
3  * Copyright (C) 2014 Adam Williams <broadcast at earthling dot net>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  *
19  */
20
21 #include "automation.h"
22 #include "bcdisplayinfo.h"
23 #include "clip.h"
24 #include "crikey.h"
25 #include "crikeywindow.h"
26 #include "cstrdup.h"
27 #include "cwindow.h"
28 #include "cwindowgui.h"
29 #include "edl.h"
30 #include "edlsession.h"
31 #include "language.h"
32 #include "mainerror.h"
33 #include "mwindow.h"
34 #include "plugin.h"
35 #include "pluginserver.h"
36 #include "theme.h"
37 #include "track.h"
38
39 #define COLOR_W 50
40 #define COLOR_H 30
41
42 CriKeyNum::CriKeyNum(CriKeyWindow *gui, int x, int y, float output)
43  : BC_TumbleTextBox(gui, output, -32767.0f, 32767.0f, x, y, 120)
44 {
45         this->gui = gui;
46         set_increment(1);
47         set_precision(1);
48 }
49
50 CriKeyNum::~CriKeyNum()
51 {
52 }
53
54 int CriKeyPointX::handle_event()
55 {
56         if( !CriKeyNum::handle_event() ) return 0;
57         CriKeyPointList *point_list = gui->point_list;
58         int hot_point = point_list->get_selection_number(0, 0);
59         CriKeyPoints &points = gui->plugin->config.points;
60         int sz = points.size();
61         if( hot_point >= 0 && hot_point < sz ) {
62                 float v = atof(get_text());
63                 points[hot_point]->x = v;
64                 point_list->set_point(hot_point, PT_X, v);
65         }
66         point_list->update_list(hot_point);
67         gui->send_configure_change();
68         return 1;
69 }
70 int CriKeyPointY::handle_event()
71 {
72         if( !CriKeyNum::handle_event() ) return 0;
73         CriKeyPointList *point_list = gui->point_list;
74         int hot_point = point_list->get_selection_number(0, 0);
75         CriKeyPoints &points = gui->plugin->config.points;
76         int sz = points.size();
77         if( hot_point >= 0 && hot_point < sz ) {
78                 float v = atof(get_text());
79                 points[hot_point]->y = v;
80                 point_list->set_point(hot_point, PT_Y, v);
81         }
82         point_list->update_list(hot_point);
83         gui->send_configure_change();
84         return 1;
85 }
86
87 int CriKeyDrawModeItem::handle_event()
88 {
89         ((CriKeyDrawMode *)get_popup_menu())->update(id);
90         return 1;
91 }
92 CriKeyDrawMode::CriKeyDrawMode(CriKeyWindow *gui, int x, int y)
93  : BC_PopupMenu(x, y, 100, "", 1)
94 {
95         this->gui = gui;
96         draw_modes[DRAW_ALPHA]     = _("Alpha");
97         draw_modes[DRAW_EDGE]      = _("Edge");
98         draw_modes[DRAW_MASK]      = _("Mask");
99         mode = -1;
100 }
101 void CriKeyDrawMode::create_objects()
102 {
103         for( int i=0; i<DRAW_MODES; ++i )
104                 add_item(new CriKeyDrawModeItem(draw_modes[i], i));
105         update(gui->plugin->config.draw_mode, 0);
106 }
107 void CriKeyDrawMode::update(int mode, int send)
108 {
109         if( this->mode == mode ) return;
110         this->mode = mode;
111         set_text(draw_modes[mode]);
112         gui->plugin->config.draw_mode = mode;
113         if( send ) gui->send_configure_change();
114 }
115
116
117 CriKeyWindow::CriKeyWindow(CriKey *plugin)
118  : PluginClientWindow(plugin, 380, 400, 380, 400, 0)
119 {
120         this->plugin = plugin;
121         this->title_x = 0;    this->point_x = 0;
122         this->title_y = 0;    this->point_y = 0;
123         this->new_point = 0;  this->del_point = 0;
124         this->point_up = 0;   this->point_dn = 0;
125         this->drag = 0;       this->dragging = 0;
126         this->last_x = 0;     this->last_y = 0;
127         this->point_list = 0; this->pending_config = 0;
128 }
129
130 CriKeyWindow::~CriKeyWindow()
131 {
132         delete point_x;
133         delete point_y;
134 }
135
136 void CriKeyWindow::create_objects()
137 {
138         int x = 10, y = 10;
139         int margin = plugin->get_theme()->widget_border;
140         BC_Title *title;
141         add_subwindow(title = new BC_Title(x, y+5, _("Draw mode:")));
142         int x1 = x + title->get_w() + 10 + margin;
143         add_subwindow(draw_mode = new CriKeyDrawMode(this, x1, y));
144         draw_mode->create_objects();
145         y += draw_mode->get_h() + 10 + margin;
146
147         CriKeyPoint *pt = plugin->config.points[plugin->config.selected];
148         add_subwindow(title_x = new BC_Title(x, y, _("X:")));
149         x1 = x + title_x->get_w() + margin;
150         point_x = new CriKeyPointX(this, x1, y, pt->x);
151         point_x->create_objects();
152         x1 += point_x->get_w() + margin;
153         add_subwindow(new_point = new CriKeyNewPoint(this, plugin, x1, y));
154         x1 += new_point->get_w() + margin;
155         add_subwindow(point_up = new CriKeyPointUp(this, x1, y));
156         y += point_x->get_h() + margin;
157         add_subwindow(title_y = new BC_Title(x, y, _("Y:")));
158         x1 = x + title_y->get_w() + margin;
159         point_y = new CriKeyPointY(this, x1, y, pt->y);
160         point_y->create_objects();
161         x1 += point_y->get_w() + margin;
162         add_subwindow(del_point = new CriKeyDelPoint(this, plugin, x1, y));
163         x1 += del_point->get_w() + margin;
164         add_subwindow(point_dn = new CriKeyPointDn(this, x1, y));
165         y += point_y->get_h() + margin + 10;
166         add_subwindow(title = new BC_Title(x, y, _("Threshold:")));
167         y += title->get_h() + margin;
168         add_subwindow(threshold = new CriKeyThreshold(this, x, y, get_w() - x * 2));
169         y += threshold->get_h() + margin;
170
171         add_subwindow(drag = new CriKeyDrag(this, x, y));
172         if( plugin->config.drag ) {
173                 if( !grab(plugin->server->mwindow->cwindow->gui) )
174                         eprintf("drag enabled, but compositor already grabbed\n");
175         }
176         x1 = x + drag->get_w() + margin + 32;
177         add_subwindow(reset = new CriKeyReset(this, plugin, x1, y+3));
178         y += drag->get_h() + margin;
179
180         add_subwindow(point_list = new CriKeyPointList(this, plugin, x, y));
181         point_list->update(plugin->config.selected);
182
183         y += point_list->get_h() + 10;
184         add_subwindow(notes = new BC_Title(x, y,
185                  _("Right click in composer: create new point\n"
186                    "Shift-left click in Enable field:\n"
187                    "  if any off, turns all on\n"
188                    "  if all on, turns rest off.")));
189         show_window(1);
190 }
191
192 void CriKeyWindow::send_configure_change()
193 {
194         pending_config = 0;
195         plugin->send_configure_change();
196 }
197
198 int CriKeyWindow::grab_event(XEvent *event)
199 {
200         int ret = do_grab_event(event);
201         if( pending_config && !grab_event_count() )
202                 send_configure_change();
203         return ret;
204 }
205
206 int CriKeyWindow::do_grab_event(XEvent *event)
207 {
208         switch( event->type ) {
209         case ButtonPress: break;
210         case ButtonRelease: break;
211         case MotionNotify: break;
212         default:
213                 return 0;
214         }
215
216         MWindow *mwindow = plugin->server->mwindow;
217         CWindowGUI *cwindow_gui = mwindow->cwindow->gui;
218         CWindowCanvas *canvas = cwindow_gui->canvas;
219         int cursor_x, cursor_y;
220         cwindow_gui->get_relative_cursor(cursor_x, cursor_y);
221         float output_x = cursor_x - canvas->view_x;
222         float output_y = cursor_y - canvas->view_y;
223
224         if( !dragging ) {
225                 if( output_x < 0 || output_x >= canvas->view_w ||
226                     output_y < 0 || output_y >= canvas->view_h )
227                         return 0;
228         }
229
230         switch( event->type ) {
231         case ButtonPress:
232                 if( dragging ) return 0;
233                 if( event->xbutton.button == WHEEL_UP )  return threshold->wheel_event(1);
234                 if( event->xbutton.button == WHEEL_DOWN ) return threshold->wheel_event(-1);
235                 dragging = event->xbutton.state & ShiftMask ? -1 : 1;
236                 break;
237         case ButtonRelease:
238                 if( !dragging ) return 0;
239                 dragging = 0;
240                 return 1;
241         case MotionNotify:
242                 if( !dragging ) return 0;
243                 break;
244         default:
245                 return 0;
246         }
247
248         float track_x, track_y;
249         canvas->canvas_to_output(mwindow->edl, 0, output_x, output_y);
250         plugin->output_to_track(output_x, output_y, track_x, track_y);
251         point_x->update((int64_t)track_x);
252         point_y->update((int64_t)track_y);
253         CriKeyPoints &points = plugin->config.points;
254
255         if( dragging > 0 ) {
256                 switch( event->type ) {
257                 case ButtonPress: {
258                         int button_no = event->xbutton.button;
259                         int hot_point = -1;
260                         if( button_no == RIGHT_BUTTON ) {
261                                 hot_point = plugin->new_point();
262                                 CriKeyPoint *pt = points[hot_point];
263                                 pt->x = track_x;  pt->y = track_y;
264                                 point_list->update(hot_point);
265                                 break;
266                         }
267                         int sz = points.size();
268                         if( hot_point < 0 && sz > 0 ) {
269                                 CriKeyPoint *pt = points[hot_point=0];
270                                 double dist = DISTANCE(track_x,track_y, pt->x,pt->y);
271                                 for( int i=1; i<sz; ++i ) {
272                                         pt = points[i];
273                                         double d = DISTANCE(track_x,track_y, pt->x,pt->y);
274                                         if( d >= dist ) continue;
275                                         dist = d;  hot_point = i;
276                                 }
277                                 pt = points[hot_point];
278                                 float cx, cy;
279                                 plugin->track_to_output(pt->x, pt->y, cx, cy);
280                                 canvas->output_to_canvas(mwindow->edl, 0, cx, cy);
281                                 cx += canvas->view_x;  cy += canvas->view_y;
282                                 dist = DISTANCE(cx,cy, cursor_x,cursor_y);
283                                 if( dist >= HANDLE_W )
284                                         hot_point = -1;
285                         }
286                         if( hot_point >= 0 && sz > 0 ) {
287                                 CriKeyPoint *pt = points[hot_point];
288                                 point_list->set_point(hot_point, PT_X, pt->x = track_x);
289                                 point_list->set_point(hot_point, PT_Y, pt->y = track_y);
290                                 for( int i=0; i<sz; ++i ) {
291                                         pt = points[i];
292                                         pt->e = i==hot_point ? !pt->e : 0;
293                                         point_list->set_point(i, PT_E, pt->e ? "*" : "");
294                                 }
295                                 point_list->update_list(hot_point);
296                         }
297                         break; }
298                 case MotionNotify: {
299                         int hot_point = point_list->get_selection_number(0, 0);
300                         if( hot_point >= 0 && hot_point < points.size() ) {
301                                 CriKeyPoint *pt = points[hot_point];
302                                 if( pt->x == track_x && pt->y == track_y ) break;
303                                 point_list->set_point(hot_point, PT_X, pt->x = track_x);
304                                 point_list->set_point(hot_point, PT_Y, pt->y = track_y);
305                                 point_x->update(pt->x);
306                                 point_y->update(pt->y);
307                                 point_list->update_list(hot_point);
308                         }
309                         break; }
310                 }
311         }
312         else {
313                 switch( event->type ) {
314                 case MotionNotify: {
315                         float dx = track_x - last_x, dy = track_y - last_y;
316                         int sz = points.size();
317                         for( int i=0; i<sz; ++i ) {
318                                 CriKeyPoint *pt = points[i];
319                                 point_list->set_point(i, PT_X, pt->x += dx);
320                                 point_list->set_point(i, PT_Y, pt->y += dy);
321                         }
322                         int hot_point = point_list->get_selection_number(0, 0);
323                         if( hot_point >= 0 && hot_point < sz ) {
324                                 CriKeyPoint *pt = points[hot_point];
325                                 point_x->update(pt->x);
326                                 point_y->update(pt->y);
327                                 point_list->update_list(hot_point);
328                         }
329                         break; }
330                 }
331         }
332
333         last_x = track_x;  last_y = track_y;
334         pending_config = 1;
335         return 1;
336 }
337
338 void CriKeyWindow::done_event(int result)
339 {
340         ungrab(client->server->mwindow->cwindow->gui);
341 }
342
343 CriKeyPointList::CriKeyPointList(CriKeyWindow *gui, CriKey *plugin, int x, int y)
344  : BC_ListBox(x, y, 360, 130, LISTBOX_TEXT)
345 {
346         this->gui = gui;
347         this->plugin = plugin;
348         titles[PT_E] = _("E");    widths[PT_E] = 50;
349         titles[PT_X] = _("X");    widths[PT_X] = 90;
350         titles[PT_Y] = _("Y");    widths[PT_Y] = 90;
351         titles[PT_T] = _("T");    widths[PT_T] = 70;
352         titles[PT_TAG] = _("Tag");  widths[PT_TAG] = 50;
353 }
354 CriKeyPointList::~CriKeyPointList()
355 {
356         clear();
357 }
358 void CriKeyPointList::clear()
359 {
360         for( int i=PT_SZ; --i>=0; )
361                 cols[i].remove_all_objects();
362 }
363
364 int CriKeyPointList::column_resize_event()
365 {
366         for( int i=PT_SZ; --i>=0; )
367                 widths[i] = get_column_width(i);
368         return 1;
369 }
370
371 int CriKeyPointList::handle_event()
372 {
373         int hot_point = get_selection_number(0, 0);
374         const char *x_text = "", *y_text = "";
375         float t = plugin->config.threshold;
376         CriKeyPoints &points = plugin->config.points;
377
378         int sz = points.size();
379         if( hot_point >= 0 && sz > 0 ) {
380                 if( get_cursor_x() < widths[0] ) {
381                         if( shift_down() ) {
382                                 int all_on = points[0]->e;
383                                 for( int i=1; i<sz && all_on; ++i ) all_on = points[i]->e;
384                                 int e = !all_on ? 1 : 0;
385                                 for( int i=0; i<sz; ++i ) points[i]->e = e;
386                                 points[hot_point]->e = 1;
387                         }
388                         else
389                                 points[hot_point]->e = !points[hot_point]->e;
390                 }
391                 x_text = gui->point_list->cols[PT_X].get(hot_point)->get_text();
392                 y_text = gui->point_list->cols[PT_Y].get(hot_point)->get_text();
393                 t = points[hot_point]->t;
394         }
395         gui->point_x->update(x_text);
396         gui->point_y->update(y_text);
397         gui->threshold->update(t);
398         update(hot_point);
399         gui->send_configure_change();
400         return 1;
401 }
402
403 int CriKeyPointList::selection_changed()
404 {
405         handle_event();
406         return 1;
407 }
408
409 void CriKeyPointList::new_point(const char *ep, const char *xp, const char *yp,
410                 const char *tp, const char *tag)
411 {
412         cols[PT_E].append(new BC_ListBoxItem(ep));
413         cols[PT_X].append(new BC_ListBoxItem(xp));
414         cols[PT_Y].append(new BC_ListBoxItem(yp));
415         cols[PT_T].append(new BC_ListBoxItem(tp));
416         cols[PT_TAG].append(new BC_ListBoxItem(tag));
417 }
418
419 void CriKeyPointList::del_point(int i)
420 {
421         for( int sz1=cols[0].size()-1, c=PT_SZ; --c>=0; )
422                 cols[c].remove_object_number(sz1-i);
423 }
424
425 void CriKeyPointList::set_point(int i, int c, float v)
426 {
427         char s[BCSTRLEN]; sprintf(s,"%0.4f",v);
428         set_point(i,c,s);
429 }
430 void CriKeyPointList::set_point(int i, int c, const char *cp)
431 {
432         cols[c].get(i)->set_text(cp);
433 }
434
435 int CriKeyPointList::set_selected(int k)
436 {
437         CriKeyPoints &points = plugin->config.points;
438         int sz = points.size();
439         if( !sz ) return -1;
440         bclamp(k, 0, sz-1);
441         for( int i=0; i<sz; ++i ) points[i]->e = 0;
442         points[k]->e = 1;
443         update_selection(&cols[0], k);
444         return k;
445 }
446 void CriKeyPointList::update_list(int k)
447 {
448         int xpos = get_xposition(), ypos = get_yposition();
449         if( k < 0 ) k = get_selection_number(0, 0);
450         update_selection(&cols[0], k);
451         BC_ListBox::update(&cols[0], &titles[0],&widths[0],PT_SZ, xpos,ypos,k);
452         center_selection();
453 }
454 void CriKeyPointList::update(int k)
455 {
456         clear();
457         CriKeyPoints &points = plugin->config.points;
458         int sz = points.size();
459         for( int i=0; i<sz; ++i ) {
460                 CriKeyPoint *pt = points[i];
461                 char etxt[BCSTRLEN];  sprintf(etxt,"%s", pt->e ? "*" : "");
462                 char xtxt[BCSTRLEN];  sprintf(xtxt,"%0.4f", pt->x);
463                 char ytxt[BCSTRLEN];  sprintf(ytxt,"%0.4f", pt->y);
464                 char ttxt[BCSTRLEN];  sprintf(ttxt,"%0.4f", pt->t);
465                 char ttag[BCSTRLEN];  sprintf(ttag,"%d", pt->tag);
466                 new_point(etxt, xtxt, ytxt, ttxt, ttag);
467         }
468         if( k >= 0 && k < sz ) {
469                 gui->point_x->update(gui->point_list->cols[PT_X].get(k)->get_text());
470                 gui->point_y->update(gui->point_list->cols[PT_Y].get(k)->get_text());
471                 plugin->config.selected = k;
472         }
473
474         update_list(k);
475 }
476
477 void CriKeyWindow::update_gui()
478 {
479         draw_mode->update(plugin->config.draw_mode);
480         threshold->update(plugin->config.threshold);
481         drag->update(plugin->config.drag);
482         point_list->update(-1);
483 }
484
485
486 CriKeyThreshold::CriKeyThreshold(CriKeyWindow *gui, int x, int y, int w)
487  : BC_FSlider(x, y, 0, w, w, 0, 1, gui->plugin->config.threshold, 0)
488 {
489         this->gui = gui;
490         set_precision(0.005);
491         set_pagination(0.01, 0.1);
492 }
493
494 int CriKeyThreshold::wheel_event(int v)
495 {
496         if( v > 0 ) increase_value();
497         else if( v < 0 ) decrease_value();
498         handle_event();
499         enable();
500         return 1;
501 }
502
503 int CriKeyThreshold::handle_event()
504 {
505         float v = get_value();
506         gui->plugin->config.threshold = v;
507         int hot_point = gui->point_list->get_selection_number(0, 0);
508         if( hot_point >= 0 ) {
509                 CriKeyPoints &points = gui->plugin->config.points;
510                 CriKeyPoint *pt = points[hot_point];
511                 pt->t = v;  pt->e = 1;
512                 gui->point_list->update(hot_point);
513         }
514         gui->send_configure_change();
515         return 1;
516 }
517
518
519 CriKeyPointUp::CriKeyPointUp(CriKeyWindow *gui, int x, int y)
520  : BC_GenericButton(x, y, _("Up"))
521 {
522         this->gui = gui;
523 }
524 CriKeyPointUp::~CriKeyPointUp()
525 {
526 }
527
528 int CriKeyPointUp::handle_event()
529 {
530         CriKeyPoints &points = gui->plugin->config.points;
531         int sz = points.size();
532         int hot_point = gui->point_list->get_selection_number(0, 0);
533
534         if( sz > 1 && hot_point > 0 ) {
535                 CriKeyPoint *&pt0 = points[hot_point];
536                 CriKeyPoint *&pt1 = points[--hot_point];
537                 CriKeyPoint *t = pt0;  pt0 = pt1;  pt1 = t;
538                 gui->point_list->update(hot_point);
539         }
540         gui->send_configure_change();
541         return 1;
542 }
543
544 CriKeyPointDn::CriKeyPointDn(CriKeyWindow *gui, int x, int y)
545  : BC_GenericButton(x, y, _("Dn"))
546 {
547         this->gui = gui;
548 }
549 CriKeyPointDn::~CriKeyPointDn()
550 {
551 }
552
553 int CriKeyPointDn::handle_event()
554 {
555         CriKeyPoints &points = gui->plugin->config.points;
556         int sz = points.size();
557         int hot_point = gui->point_list->get_selection_number(0, 0);
558         if( sz > 1 && hot_point < sz-1 ) {
559                 CriKeyPoint *&pt0 = points[hot_point];
560                 CriKeyPoint *&pt1 = points[++hot_point];
561                 CriKeyPoint *t = pt0;  pt0 = pt1;  pt1 = t;
562                 gui->point_list->update(hot_point);
563         }
564         gui->send_configure_change();
565         return 1;
566 }
567
568 CriKeyDrag::CriKeyDrag(CriKeyWindow *gui, int x, int y)
569  : BC_CheckBox(x, y, gui->plugin->config.drag, _("Drag"))
570 {
571         this->gui = gui;
572 }
573 int CriKeyDrag::handle_event()
574 {
575         CWindowGUI *cwindow_gui = gui->plugin->server->mwindow->cwindow->gui;
576         int value = get_value();
577         if( value ) {
578                 if( !gui->grab(cwindow_gui) ) {
579                         update(value = 0);
580                         flicker(10,50);
581                 }
582         }
583         else
584                 gui->ungrab(cwindow_gui);
585         gui->plugin->config.drag = value;
586         gui->send_configure_change();
587         return 1;
588 }
589
590 CriKeyNewPoint::CriKeyNewPoint(CriKeyWindow *gui, CriKey *plugin, int x, int y)
591  : BC_GenericButton(x, y, 80, _("New"))
592 {
593         this->gui = gui;
594         this->plugin = plugin;
595 }
596 CriKeyNewPoint::~CriKeyNewPoint()
597 {
598 }
599 int CriKeyNewPoint::handle_event()
600 {
601         int k = plugin->new_point();
602         gui->point_list->update(k);
603         gui->send_configure_change();
604         return 1;
605 }
606
607 CriKeyDelPoint::CriKeyDelPoint(CriKeyWindow *gui, CriKey *plugin, int x, int y)
608  : BC_GenericButton(x, y, 80, C_("Del"))
609 {
610         this->gui = gui;
611         this->plugin = plugin;
612 }
613 CriKeyDelPoint::~CriKeyDelPoint()
614 {
615 }
616 int CriKeyDelPoint::handle_event()
617 {
618         int hot_point = gui->point_list->get_selection_number(0, 0);
619         CriKeyPoints &points = plugin->config.points;
620         if( hot_point >= 0 && hot_point < points.size() ) {
621                 plugin->config.del_point(hot_point);
622                 if( !points.size() ) plugin->new_point();
623                 int sz = points.size();
624                 if( hot_point >= sz && hot_point > 0 ) --hot_point;
625                 gui->point_list->update(hot_point);
626                 gui->send_configure_change();
627         }
628         return 1;
629 }
630
631 CriKeyReset::CriKeyReset(CriKeyWindow *gui, CriKey *plugin, int x, int y)
632  : BC_GenericButton(x, y, _("Reset"))
633 {
634         this->gui = gui;
635         this->plugin = plugin;
636 }
637 CriKeyReset::~CriKeyReset()
638 {
639 }
640 int CriKeyReset::handle_event()
641 {
642         CriKeyPoints &points = plugin->config.points;
643         points.remove_all_objects();
644         plugin->new_point();
645         gui->point_list->update(0);
646         gui->send_configure_change();
647         return 1;
648 }
649