add ffmpeg image2 formats, fix segv when quit with render menu active
[goodguy/history.git] / cinelerra-5.1 / cinelerra / performanceprefs.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #include "bcsignals.h"
23 #include "clip.h"
24 #include "edl.h"
25 #include "edlsession.h"
26 #include "formattools.h"
27 #include "language.h"
28 #include "mwindow.h"
29 #include "performanceprefs.h"
30 #include "preferences.h"
31 #include <string.h>
32 #include "theme.h"
33
34 #define MASTER_NODE_FRAMERATE_TEXT "Master node framerate: %0.3f"
35 #if 0
36 N_(MASTER_NODE_FRAMERATE_TEXT)
37 #endif
38
39 PerformancePrefs::PerformancePrefs(MWindow *mwindow, PreferencesWindow *pwindow)
40  : PreferencesDialog(mwindow, pwindow)
41 {
42         hot_node = -1;
43 }
44
45 PerformancePrefs::~PerformancePrefs()
46 {
47         delete brender_tools;
48         nodes[0].remove_all_objects();
49         nodes[1].remove_all_objects();
50         nodes[2].remove_all_objects();
51         nodes[3].remove_all_objects();
52 }
53
54 void PerformancePrefs::create_objects()
55 {
56         int x, y;
57         int xmargin1;
58         int xmargin2 = 170;
59         int xmargin3 = 250;
60         int xmargin4 = 380;
61         char string[BCTEXTLEN];
62         BC_Resources *resources = BC_WindowBase::get_resources();
63         BC_WindowBase *win;
64         int maxw, curw, y1;
65
66         node_list = 0;
67         generate_node_list();
68
69         xmargin1 = x = mwindow->theme->preferencesoptions_x;
70         y = mwindow->theme->preferencesoptions_y;
71
72 //      add_subwindow(new BC_Title(x,
73 //              y,
74 //              _("Time Format"),
75 //              LARGEFONT,
76 //              resources->text_default));
77 //
78 //      y += get_text_height(LARGEFONT) + 5;
79
80         int ybx[2];
81         ybx[0] = y;
82
83         win = add_subwindow(new BC_Title(x, y + 5, _("Cache size (MB):"), MEDIUMFONT, resources->text_default));
84         maxw = win->get_w();
85
86         ybx[1] = y += 30;
87         win = add_subwindow(new BC_Title(x, y + 5, _("Seconds to preroll renders:")));
88         if((curw = win->get_w()) > maxw)
89                 maxw = curw;
90         maxw += x + 5;
91
92         cache_size = new CICacheSize(maxw,
93                 ybx[0],
94                 pwindow,
95                 this);
96         cache_size->create_objects();
97         add_subwindow(new BC_Title(x, y + 5, _("Seconds to preroll renders:")));
98         PrefsRenderPreroll *preroll = new PrefsRenderPreroll(pwindow,
99                 this,
100                 maxw,
101                 ybx[1]);
102         preroll->create_objects();
103         y += 30;
104         PrefsForceUniprocessor *force_1cpu = new PrefsForceUniprocessor(pwindow, x, y);
105         add_subwindow(force_1cpu);
106
107         int x1 = force_1cpu->get_x() + force_1cpu->get_w() + 50;
108
109         PrefsTrapSigSEGV *trap_segv = new PrefsTrapSigSEGV(this, x1, y);
110         add_subwindow(trap_segv);
111         int x2 = x1 + trap_segv->get_w() + 10;
112         add_subwindow(new BC_Title(x2, y, _("(must be root)"), MEDIUMFONT, RED));
113         y += 30;
114
115         PrefsTrapSigINTR *trap_intr = new PrefsTrapSigINTR(this, x1, y);
116         add_subwindow(trap_intr);
117         add_subwindow(new BC_Title(x2, y, _("(must be root)"), MEDIUMFONT, RED));
118         ffmpeg_marker_indexes = new PrefsFFMPEGMarkerIndecies(this, x, y);
119         add_subwindow(ffmpeg_marker_indexes);
120         y += 30;
121
122         ffmpeg_early_probe = new PrefsFFMPEGEarlyProbe(this, x, y);
123         add_subwindow(ffmpeg_early_probe);
124         y += 30;
125
126
127
128
129 // Background rendering
130         add_subwindow(new BC_Bar(5, y,  get_w() - 10));
131         y += 5;
132
133
134         add_subwindow(new BC_Title(x, y, _("Background Rendering (Video only)"), LARGEFONT, resources->text_default));
135         y1 = y += 30;
136
137         win = add_subwindow(new PrefsUseBRender(pwindow,
138                 x,
139                 y));
140
141         y += win->get_h() + 10;
142         win = add_subwindow(new BC_Title(x, y, _("Frames per background rendering job:")));
143         y += win->get_h() + 5;
144         PrefsBRenderFragment *brender_fragment = new PrefsBRenderFragment(pwindow,
145                 this,
146                 x + xmargin3,
147                 y);
148         brender_fragment->create_objects();
149         y += brender_fragment->get_h() + 5;
150         win = add_subwindow(new BC_Title(x, y, _("Frames to preroll background:")));
151         y += win->get_h() + 5;
152         PrefsBRenderPreroll *bpreroll = new PrefsBRenderPreroll(pwindow,
153                 this,
154                 x + xmargin3,
155                 y + 5);
156         bpreroll->create_objects();
157         y += bpreroll->get_h() + 20;
158
159
160         x += xmargin4;
161         add_subwindow(new BC_Title(x, y1, _("Output for background rendering:")));
162         y1 += 20;
163         brender_tools =
164                 new FormatTools(mwindow,
165                         this,
166                         pwindow->thread->preferences->brender_asset);
167         brender_tools->create_objects(x,
168                 y1,
169                 0,  // Include tools for audio
170                 1,  // Include tools for video
171                 0,  // Include checkbox for audio
172                 0,  // Include checkbox for video
173                 0,
174                 1,
175                 0,  // Select compressors to be offered
176                 0,  // Prompt for recording options
177                 0,  // If nonzero, prompt for insertion strategy
178                 1); // Supply file formats for background rendering
179         x = xmargin1;
180
181
182 // Renderfarm
183         add_subwindow(new BC_Bar(5, y, get_w() - 10));
184         y += 5;
185         add_subwindow(new BC_Title(x, y, _("Render Farm"), LARGEFONT, resources->text_default));
186         x1 = x + xmargin4;
187         BC_Title *node_title = new BC_Title(x1, y, _("Nodes:"));
188         add_subwindow(node_title);
189         x1 += node_title->get_w() + 25;
190         sprintf(string, _(MASTER_NODE_FRAMERATE_TEXT),
191                 pwindow->thread->preferences->local_rate);
192         add_subwindow(master_rate = new BC_Title(x1, y, string));
193         y += 25;
194         add_subwindow(node_list = new PrefsRenderFarmNodes(pwindow,
195                 this,
196                 x + xmargin4,
197                 y));
198         y += 5;
199         add_subwindow(new PrefsRenderFarm(pwindow, x, y));
200         y += 30;
201         add_subwindow(new BC_Title(x, y, _("Hostname:")));
202         add_subwindow(new BC_Title(x + xmargin3, y, _("Port:")));
203
204         y += 25;
205         add_subwindow(edit_node = new PrefsRenderFarmEditNode(pwindow,
206                 this,
207                 x,
208                 y));
209         edit_port = new PrefsRenderFarmPort(pwindow,
210                 this,
211                 x + xmargin3,
212                 y);
213         edit_port->create_objects();
214
215         y += 30;
216
217
218         add_subwindow(new PrefsRenderFarmReplaceNode(pwindow,
219                 this,
220                 x,
221                 y));
222         add_subwindow(new PrefsRenderFarmNewNode(pwindow,
223                 this,
224                 x + xmargin2,
225                 y));
226         y += 30;
227         add_subwindow(new PrefsRenderFarmDelNode(pwindow,
228                 this,
229                 x + xmargin2,
230                 y));
231         add_subwindow(new PrefsRenderFarmSortNodes(pwindow,
232                 this,
233                 x,
234                 y));
235         y += 30;
236         add_subwindow(new PrefsRenderFarmReset(pwindow,
237                 this,
238                 x,
239                 y));
240         y += 35;
241         add_subwindow(new BC_Title(x,
242                 y,
243                 _("Total jobs to create:")));
244         add_subwindow(new BC_Title(x,
245                 y + 30,
246                 _("(overridden if new file at each label is checked)")));
247         PrefsRenderFarmJobs *jobs = new PrefsRenderFarmJobs(pwindow,
248                 this,
249                 x + xmargin3,
250                 y);
251         jobs->create_objects();
252         y += 55;
253 //      add_subwindow(new PrefsRenderFarmVFS(pwindow,
254 //              this,
255 //              x,
256 //              y));
257 //      add_subwindow(new BC_Title(x,
258 //              y,
259 //              _("Filesystem prefix on remote nodes:")));
260 //      add_subwindow(new PrefsRenderFarmMountpoint(pwindow,
261 //              this,
262 //              x + xmargin3,
263 //              y));
264 //      y += 30;
265 }
266
267 void PerformancePrefs::generate_node_list()
268 {
269         int selected_row = node_list ? node_list->get_selection_number(0, 0) : -1;
270
271         for(int i = 0; i < TOTAL_COLUMNS; i++)
272                 nodes[i].remove_all_objects();
273
274         for(int i = 0;
275                 i < pwindow->thread->preferences->renderfarm_nodes.size();
276                 i++)
277         {
278                 BC_ListBoxItem *item;
279                 nodes[ENABLED_COLUMN].append(item = new BC_ListBoxItem(
280                         (char*)(pwindow->thread->preferences->renderfarm_enabled.get(i) ? "X" : " ")));
281                 if(i == selected_row) item->set_selected(1);
282
283                 nodes[HOSTNAME_COLUMN].append(item = new BC_ListBoxItem(
284                         pwindow->thread->preferences->renderfarm_nodes.get(i)));
285                 if(i == selected_row) item->set_selected(1);
286
287                 char string[BCTEXTLEN];
288                 sprintf(string, "%d", pwindow->thread->preferences->renderfarm_ports.get(i));
289                 nodes[PORT_COLUMN].append(item = new BC_ListBoxItem(string));
290                 if(i == selected_row) item->set_selected(1);
291
292                 sprintf(string, "%0.3f", pwindow->thread->preferences->renderfarm_rate.get(i));
293                 nodes[RATE_COLUMN].append(item = new BC_ListBoxItem(string));
294                 if(i == selected_row) item->set_selected(1);
295         }
296 }
297
298 static const char *titles[] =
299 {
300         N_("On"),
301         N_("Hostname"),
302         N_("Port"),
303         N_("Framerate")
304 };
305
306 static int widths[] =
307 {
308         30,
309         150,
310         50,
311         50
312 };
313
314
315 void PerformancePrefs::update_node_list()
316 {
317         node_list->update(nodes,
318                                                 titles,
319                                                 widths,
320                                                 TOTAL_COLUMNS,
321                                                 node_list->get_xposition(),
322                                                 node_list->get_yposition(),
323                                                 node_list->get_selection_number(0, 0));
324 }
325
326
327 void PerformancePrefs::update_rates()
328 {
329 //printf("PerformancePrefs::update_rates %d\n", __LINE__);
330         char string[BCTEXTLEN];
331         for(int i = 0;
332                 i < mwindow->preferences->renderfarm_rate.size();
333                 i++)
334         {
335                 if(i < nodes[RATE_COLUMN].size())
336                 {
337                         sprintf(string, "%0.3f", mwindow->preferences->renderfarm_rate.get(i));
338                         nodes[RATE_COLUMN].get(i)->set_text(string);
339                 }
340         }
341
342         sprintf(string, _(MASTER_NODE_FRAMERATE_TEXT),
343                 mwindow->preferences->local_rate);
344         master_rate->update(string);
345
346         update_node_list();
347 }
348
349
350 PrefsUseBRender::PrefsUseBRender(PreferencesWindow *pwindow,
351         int x,
352         int y)
353  : BC_CheckBox(x,
354         y,
355         pwindow->thread->preferences->use_brender,
356         _("Use background rendering"))
357 {
358         this->pwindow = pwindow;
359 }
360
361 int PrefsUseBRender::handle_event()
362 {
363         pwindow->thread->redraw_overlays = 1;
364         pwindow->thread->redraw_times = 1;
365         pwindow->thread->preferences->use_brender = get_value();
366         return 1;
367 }
368
369
370
371
372
373
374 PrefsBRenderFragment::PrefsBRenderFragment(PreferencesWindow *pwindow,
375         PerformancePrefs *subwindow,
376         int x,
377         int y)
378  : BC_TumbleTextBox(subwindow,
379         (int64_t)pwindow->thread->preferences->brender_fragment,
380         (int64_t)1,
381         (int64_t)65535,
382         x,
383         y,
384         100)
385 {
386         this->pwindow = pwindow;
387 }
388 int PrefsBRenderFragment::handle_event()
389 {
390         pwindow->thread->preferences->brender_fragment = atol(get_text());
391         return 1;
392 }
393
394
395
396
397
398
399
400
401
402
403
404 CICacheSize::CICacheSize(int x,
405         int y,
406         PreferencesWindow *pwindow,
407         PerformancePrefs *subwindow)
408  : BC_TumbleTextBox(subwindow,
409         (int64_t)pwindow->thread->preferences->cache_size / 0x100000,
410         (int64_t)MIN_CACHE_SIZE / 0x100000,
411         (int64_t)MAX_CACHE_SIZE / 0x100000,
412         x,
413         y,
414         100)
415 {
416         this->pwindow = pwindow;
417         set_increment(1);
418 }
419
420 int CICacheSize::handle_event()
421 {
422         int64_t result;
423         result = (int64_t)atol(get_text()) * 0x100000;
424         CLAMP(result, MIN_CACHE_SIZE, MAX_CACHE_SIZE);
425         pwindow->thread->preferences->cache_size = result;
426         return 0;
427 }
428
429
430 PrefsRenderPreroll::PrefsRenderPreroll(PreferencesWindow *pwindow,
431                 PerformancePrefs *subwindow,
432                 int x,
433                 int y)
434  : BC_TumbleTextBox(subwindow,
435         (float)pwindow->thread->preferences->render_preroll,
436         (float)0,
437         (float)100,
438         x,
439         y,
440         100)
441 {
442         this->pwindow = pwindow;
443         set_increment(0.1);
444 }
445 PrefsRenderPreroll::~PrefsRenderPreroll()
446 {
447 }
448 int PrefsRenderPreroll::handle_event()
449 {
450         pwindow->thread->preferences->render_preroll = atof(get_text());
451         return 1;
452 }
453
454
455 PrefsBRenderPreroll::PrefsBRenderPreroll(PreferencesWindow *pwindow,
456                 PerformancePrefs *subwindow,
457                 int x,
458                 int y)
459  : BC_TumbleTextBox(subwindow,
460         (int64_t)pwindow->thread->preferences->brender_preroll,
461         (int64_t)0,
462         (int64_t)100,
463         x,
464         y,
465         100)
466 {
467         this->pwindow = pwindow;
468 }
469 int PrefsBRenderPreroll::handle_event()
470 {
471         pwindow->thread->preferences->brender_preroll = atol(get_text());
472         return 1;
473 }
474
475
476
477
478
479
480
481
482
483
484
485 PrefsRenderFarm::PrefsRenderFarm(PreferencesWindow *pwindow, int x, int y)
486  : BC_CheckBox(x,
487         y,
488         pwindow->thread->preferences->use_renderfarm,
489         _("Use render farm"))
490 {
491         this->pwindow = pwindow;
492 }
493 PrefsRenderFarm::~PrefsRenderFarm()
494 {
495 }
496 int PrefsRenderFarm::handle_event()
497 {
498         pwindow->thread->preferences->use_renderfarm = get_value();
499         return 1;
500 }
501
502
503
504
505 PrefsForceUniprocessor::PrefsForceUniprocessor(PreferencesWindow *pwindow, int x, int y)
506  : BC_CheckBox(x,
507         y,
508         pwindow->thread->preferences->force_uniprocessor,
509         _("Force single processor use"))
510 {
511         this->pwindow = pwindow;
512 }
513 PrefsForceUniprocessor::~PrefsForceUniprocessor()
514 {
515 }
516 int PrefsForceUniprocessor::handle_event()
517 {
518         pwindow->thread->preferences->force_uniprocessor = get_value();
519         return 1;
520 }
521
522 PrefsTrapSigSEGV::PrefsTrapSigSEGV(PerformancePrefs *perf_prefs, int x, int y)
523  : BC_CheckBox(x, y,
524         perf_prefs->pwindow->thread->preferences->trap_sigsegv,
525         _("trap sigSEGV"))
526 {
527         this->perf_prefs = perf_prefs;
528 }
529 PrefsTrapSigSEGV::~PrefsTrapSigSEGV()
530 {
531 }
532 int PrefsTrapSigSEGV::handle_event()
533 {
534         perf_prefs->pwindow->thread->preferences->trap_sigsegv = get_value();
535         return 1;
536 }
537
538 PrefsTrapSigINTR::PrefsTrapSigINTR(PerformancePrefs *perf_prefs, int x, int y)
539  : BC_CheckBox(x, y,
540         perf_prefs->pwindow->thread->preferences->trap_sigintr,
541         _("trap sigINT"))
542 {
543         this->perf_prefs = perf_prefs;
544 }
545 PrefsTrapSigINTR::~PrefsTrapSigINTR()
546 {
547 }
548 int PrefsTrapSigINTR::handle_event()
549 {
550         perf_prefs->pwindow->thread->preferences->trap_sigintr = get_value();
551         return 1;
552 }
553
554
555 PrefsFFMPEGEarlyProbe::PrefsFFMPEGEarlyProbe(PerformancePrefs *perf_prefs, int x, int y)
556  : BC_CheckBox(x, y,
557         perf_prefs->pwindow->thread->preferences->ffmpeg_early_probe,
558         _("On file open, ffmpeg probes early"))
559 {
560         this->perf_prefs = perf_prefs;
561 }
562 PrefsFFMPEGEarlyProbe::~PrefsFFMPEGEarlyProbe()
563 {
564 }
565
566 int PrefsFFMPEGEarlyProbe::handle_event()
567 {
568         perf_prefs->pwindow->thread->preferences->ffmpeg_early_probe = get_value();
569         return 1;
570 }
571
572
573 PrefsFFMPEGMarkerIndecies::PrefsFFMPEGMarkerIndecies(PerformancePrefs *perf_prefs, int x, int y)
574  : BC_CheckBox(x, y,
575         perf_prefs->pwindow->thread->preferences->ffmpeg_marker_indexes,
576         _("build ffmpeg marker indexes"))
577 {
578         this->perf_prefs = perf_prefs;
579 }
580 PrefsFFMPEGMarkerIndecies::~PrefsFFMPEGMarkerIndecies()
581 {
582 }
583
584 int PrefsFFMPEGMarkerIndecies::handle_event()
585 {
586         perf_prefs->pwindow->thread->preferences->ffmpeg_marker_indexes = get_value();
587         return 1;
588 }
589
590
591
592
593
594
595 PrefsRenderFarmConsolidate::PrefsRenderFarmConsolidate(PreferencesWindow *pwindow, int x, int y)
596  : BC_CheckBox(x,
597         y,
598         pwindow->thread->preferences->renderfarm_consolidate,
599         _("Consolidate output files on completion"))
600 {
601         this->pwindow = pwindow;
602 }
603 PrefsRenderFarmConsolidate::~PrefsRenderFarmConsolidate()
604 {
605 }
606 int PrefsRenderFarmConsolidate::handle_event()
607 {
608         pwindow->thread->preferences->renderfarm_consolidate = get_value();
609         return 1;
610 }
611
612
613
614
615
616 PrefsRenderFarmPort::PrefsRenderFarmPort(PreferencesWindow *pwindow,
617         PerformancePrefs *subwindow,
618         int x,
619         int y)
620  : BC_TumbleTextBox(subwindow,
621         (int64_t)pwindow->thread->preferences->renderfarm_port,
622         (int64_t)1,
623         (int64_t)65535,
624         x,
625         y,
626         100)
627 {
628         this->pwindow = pwindow;
629 }
630
631 PrefsRenderFarmPort::~PrefsRenderFarmPort()
632 {
633 }
634
635 int PrefsRenderFarmPort::handle_event()
636 {
637         pwindow->thread->preferences->renderfarm_port = atol(get_text());
638         return 1;
639 }
640
641
642
643 PrefsRenderFarmNodes::PrefsRenderFarmNodes(PreferencesWindow *pwindow,
644         PerformancePrefs *subwindow,
645         int x,
646         int y)
647  : BC_ListBox(x,
648                 y,
649                 340,
650                 230,
651                 LISTBOX_TEXT,                         // Display text list or icons
652                 subwindow->nodes,
653                 titles,
654                 widths,
655                 4)
656 {
657         this->subwindow = subwindow;
658         this->pwindow = pwindow;
659 }
660 PrefsRenderFarmNodes::~PrefsRenderFarmNodes()
661 {
662 }
663
664 int PrefsRenderFarmNodes::column_resize_event()
665 {
666         for(int i = 0; i < 3; i++)
667                 widths[i] = get_column_width(i);
668         return 1;
669 }
670
671 int PrefsRenderFarmNodes::handle_event()
672 {
673 SET_TRACE
674         if(get_selection_number(0, 0) >= 0)
675         {
676                 subwindow->hot_node = get_selection_number(1, 0);
677                 subwindow->edit_node->update(get_selection(1, 0)->get_text());
678                 subwindow->edit_port->update(get_selection(2, 0)->get_text());
679                 if(get_cursor_x() < widths[0])
680                 {
681                         pwindow->thread->preferences->renderfarm_enabled.values[subwindow->hot_node] =
682                                 !pwindow->thread->preferences->renderfarm_enabled.values[subwindow->hot_node];
683                         subwindow->generate_node_list();
684                         subwindow->update_node_list();
685                 }
686         }
687         else
688         {
689                 subwindow->hot_node = -1;
690                 subwindow->edit_node->update("");
691         }
692 SET_TRACE
693         return 1;
694 }
695 int PrefsRenderFarmNodes::selection_changed()
696 {
697         handle_event();
698         return 1;
699 }
700
701
702
703
704
705
706
707 PrefsRenderFarmEditNode::PrefsRenderFarmEditNode(PreferencesWindow *pwindow, PerformancePrefs *subwindow, int x, int y)
708  : BC_TextBox(x, y, 240, 1, "")
709 {
710         this->pwindow = pwindow;
711         this->subwindow = subwindow;
712 }
713
714 PrefsRenderFarmEditNode::~PrefsRenderFarmEditNode()
715 {
716 }
717
718 int PrefsRenderFarmEditNode::handle_event()
719 {
720         return 1;
721 }
722
723
724
725
726
727
728 PrefsRenderFarmNewNode::PrefsRenderFarmNewNode(PreferencesWindow *pwindow, PerformancePrefs *subwindow, int x, int y)
729  : BC_GenericButton(x, y, _("Add Node"))
730 {
731         this->pwindow = pwindow;
732         this->subwindow = subwindow;
733 }
734 PrefsRenderFarmNewNode::~PrefsRenderFarmNewNode()
735 {
736 }
737 int PrefsRenderFarmNewNode::handle_event()
738 {
739         pwindow->thread->preferences->add_node(subwindow->edit_node->get_text(),
740                 pwindow->thread->preferences->renderfarm_port,
741                 1,
742                 0.0);
743         pwindow->thread->preferences->reset_rates();
744         subwindow->generate_node_list();
745         subwindow->update_node_list();
746         subwindow->hot_node = -1;
747         return 1;
748 }
749
750
751
752
753
754
755
756 PrefsRenderFarmReplaceNode::PrefsRenderFarmReplaceNode(PreferencesWindow *pwindow, PerformancePrefs *subwindow, int x, int y)
757  : BC_GenericButton(x, y, _("Apply Changes"))
758 {
759         this->pwindow = pwindow;
760         this->subwindow = subwindow;
761 }
762 PrefsRenderFarmReplaceNode::~PrefsRenderFarmReplaceNode()
763 {
764 }
765 int PrefsRenderFarmReplaceNode::handle_event()
766 {
767         if(subwindow->hot_node >= 0)
768         {
769                 pwindow->thread->preferences->edit_node(subwindow->hot_node,
770                         subwindow->edit_node->get_text(),
771                         pwindow->thread->preferences->renderfarm_port,
772                         pwindow->thread->preferences->renderfarm_enabled.values[subwindow->hot_node]);
773                 subwindow->generate_node_list();
774                 subwindow->update_node_list();
775         }
776         return 1;
777 }
778
779
780
781
782
783 PrefsRenderFarmDelNode::PrefsRenderFarmDelNode(PreferencesWindow *pwindow, PerformancePrefs *subwindow, int x, int y)
784  : BC_GenericButton(x, y, _("Delete Node"))
785 {
786         this->pwindow = pwindow;
787         this->subwindow = subwindow;
788 }
789 PrefsRenderFarmDelNode::~PrefsRenderFarmDelNode()
790 {
791 }
792 int PrefsRenderFarmDelNode::handle_event()
793 {
794         if( subwindow->hot_node >= 0 ) {
795                 pwindow->thread->preferences->delete_node(subwindow->hot_node);
796
797                 subwindow->generate_node_list();
798                 subwindow->update_node_list();
799                 subwindow->hot_node = -1;
800         }
801         return 1;
802 }
803
804
805
806
807
808 PrefsRenderFarmSortNodes::PrefsRenderFarmSortNodes(PreferencesWindow *pwindow,
809         PerformancePrefs *subwindow,
810         int x,
811         int y)
812  : BC_GenericButton(x, y, _("Sort nodes"))
813 {
814         this->pwindow = pwindow;
815         this->subwindow = subwindow;
816 }
817
818 PrefsRenderFarmSortNodes::~PrefsRenderFarmSortNodes()
819 {
820 }
821
822 int PrefsRenderFarmSortNodes::handle_event()
823 {
824         pwindow->thread->preferences->sort_nodes();
825         subwindow->generate_node_list();
826         subwindow->update_node_list();
827         subwindow->hot_node = -1;
828         return 1;
829 }
830
831
832
833
834
835 PrefsRenderFarmReset::PrefsRenderFarmReset(PreferencesWindow *pwindow,
836         PerformancePrefs *subwindow,
837         int x,
838         int y)
839  : BC_GenericButton(x, y, _("Reset rates"))
840 {
841         this->pwindow = pwindow;
842         this->subwindow = subwindow;
843 }
844
845 int PrefsRenderFarmReset::handle_event()
846 {
847         pwindow->thread->preferences->reset_rates();
848         subwindow->generate_node_list();
849         subwindow->update_node_list();
850
851         char string[BCTEXTLEN];
852         sprintf(string,
853                 MASTER_NODE_FRAMERATE_TEXT,
854                 pwindow->thread->preferences->local_rate);
855         subwindow->master_rate->update(string);
856         subwindow->hot_node = -1;
857         return 1;
858 }
859
860
861
862
863
864
865
866 PrefsRenderFarmJobs::PrefsRenderFarmJobs(PreferencesWindow *pwindow,
867                 PerformancePrefs *subwindow,
868                 int x,
869                 int y)
870  : BC_TumbleTextBox(subwindow,
871         (int64_t)pwindow->thread->preferences->renderfarm_job_count,
872         (int64_t)1,
873         (int64_t)100,
874         x,
875         y,
876         100)
877 {
878         this->pwindow = pwindow;
879 }
880 PrefsRenderFarmJobs::~PrefsRenderFarmJobs()
881 {
882 }
883 int PrefsRenderFarmJobs::handle_event()
884 {
885         pwindow->thread->preferences->renderfarm_job_count = atol(get_text());
886         return 1;
887 }
888
889
890
891 PrefsRenderFarmMountpoint::PrefsRenderFarmMountpoint(PreferencesWindow *pwindow,
892                 PerformancePrefs *subwindow,
893                 int x,
894                 int y)
895  : BC_TextBox(x,
896         y,
897         100,
898         1,
899         pwindow->thread->preferences->renderfarm_mountpoint)
900 {
901         this->pwindow = pwindow;
902         this->subwindow = subwindow;
903 }
904 PrefsRenderFarmMountpoint::~PrefsRenderFarmMountpoint()
905 {
906 }
907 int PrefsRenderFarmMountpoint::handle_event()
908 {
909         strcpy(pwindow->thread->preferences->renderfarm_mountpoint, get_text());
910         return 1;
911 }
912
913
914
915
916 PrefsRenderFarmVFS::PrefsRenderFarmVFS(PreferencesWindow *pwindow,
917         PerformancePrefs *subwindow,
918         int x,
919         int y)
920  : BC_CheckBox(x, y, pwindow->thread->preferences->renderfarm_vfs, _("Use virtual filesystem"))
921 {
922         this->pwindow = pwindow;
923         this->subwindow = subwindow;
924 }
925
926 int PrefsRenderFarmVFS::handle_event()
927 {
928         pwindow->thread->preferences->renderfarm_vfs = get_value();
929         return 1;
930 }
931