asset drag/drop to viewers, bluebanana bug, listbox fontlist highlight
[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         int x1 = preroll->get_x() + preroll->get_w() + 20;
104         BC_Title *smp_title = new BC_Title(x1, y + 5, _("Project SMP cpus:"));
105         add_subwindow(smp_title);
106         int x2 = x1 + smp_title->get_w() + 5;
107         PrefsProjectSMP *proj_smp = new PrefsProjectSMP(pwindow, this, x2, y);
108         proj_smp->create_objects();
109
110         y += 30;
111         PrefsForceUniprocessor *force_1cpu = new PrefsForceUniprocessor(pwindow, x, y);
112         add_subwindow(force_1cpu);
113
114         x1 = force_1cpu->get_x() + force_1cpu->get_w() + 120;
115
116         PrefsTrapSigSEGV *trap_segv = new PrefsTrapSigSEGV(this, x1, y);
117         add_subwindow(trap_segv);
118         x2 = x1 + trap_segv->get_w() + 10;
119         add_subwindow(new BC_Title(x2, y, _("(must be root)"), MEDIUMFONT, RED));
120         y += 30;
121
122         PrefsTrapSigINTR *trap_intr = new PrefsTrapSigINTR(this, x1, y);
123         add_subwindow(trap_intr);
124         add_subwindow(new BC_Title(x2, y, _("(must be root)"), MEDIUMFONT, RED));
125         ffmpeg_marker_indexes = new PrefsFFMPEGMarkerIndecies(this, x, y);
126         add_subwindow(ffmpeg_marker_indexes);
127         y += 30;
128
129         ffmpeg_early_probe = new PrefsFFMPEGEarlyProbe(this, x, y);
130         add_subwindow(ffmpeg_early_probe);
131
132         yuv420p_dvdlace = new PrefsYUV420P_DVDlace(pwindow, this, x1, y);
133         add_subwindow(yuv420p_dvdlace);
134         y += 30;
135
136 // Background rendering
137         add_subwindow(new BC_Bar(5, y,  get_w() - 10));
138         y += 5;
139
140
141         add_subwindow(new BC_Title(x, y, _("Background Rendering (Video only)"), LARGEFONT, resources->text_default));
142         y1 = y += 30;
143
144         win = add_subwindow(new PrefsUseBRender(pwindow,
145                 x,
146                 y));
147
148         y += win->get_h() + 10;
149         win = add_subwindow(new BC_Title(x, y, _("Frames per background rendering job:")));
150         y += win->get_h() + 5;
151         PrefsBRenderFragment *brender_fragment = new PrefsBRenderFragment(pwindow,
152                 this,
153                 x + xmargin3,
154                 y);
155         brender_fragment->create_objects();
156         y += brender_fragment->get_h() + 5;
157         win = add_subwindow(new BC_Title(x, y, _("Frames to preroll background:")));
158         y += win->get_h() + 5;
159         PrefsBRenderPreroll *bpreroll = new PrefsBRenderPreroll(pwindow,
160                 this,
161                 x + xmargin3,
162                 y + 5);
163         bpreroll->create_objects();
164         y += bpreroll->get_h() + 20;
165
166
167         x += xmargin4;
168         add_subwindow(new BC_Title(x, y1, _("Output for background rendering:")));
169         y1 += 20;
170         brender_tools =
171                 new FormatTools(mwindow,
172                         this,
173                         pwindow->thread->preferences->brender_asset);
174         brender_tools->create_objects(x,
175                 y1,
176                 0,  // Include tools for audio
177                 1,  // Include tools for video
178                 0,  // Include checkbox for audio
179                 0,  // Include checkbox for video
180                 0,
181                 1,
182                 0,  // Select compressors to be offered
183                 0,  // Prompt for recording options
184                 0,  // If nonzero, prompt for insertion strategy
185                 1); // Supply file formats for background rendering
186         x = xmargin1;
187
188
189 // Renderfarm
190         add_subwindow(new BC_Bar(5, y, get_w() - 10));
191         y += 5;
192         add_subwindow(new BC_Title(x, y, _("Render Farm"), LARGEFONT, resources->text_default));
193         x1 = x + xmargin4;
194         BC_Title *node_title = new BC_Title(x1, y, _("Nodes:"));
195         add_subwindow(node_title);
196         x1 += node_title->get_w() + 25;
197         sprintf(string, _(MASTER_NODE_FRAMERATE_TEXT),
198                 pwindow->thread->preferences->local_rate);
199         add_subwindow(master_rate = new BC_Title(x1, y, string));
200         y += 25;
201         add_subwindow(node_list = new PrefsRenderFarmNodes(pwindow,
202                 this,
203                 x + xmargin4,
204                 y));
205         y += 5;
206         add_subwindow(new PrefsRenderFarm(pwindow, x, y));
207         y += 30;
208         add_subwindow(new BC_Title(x, y, _("Hostname:")));
209         add_subwindow(new BC_Title(x + xmargin3, y, _("Port:")));
210
211         y += 25;
212         add_subwindow(edit_node = new PrefsRenderFarmEditNode(pwindow,
213                 this,
214                 x,
215                 y));
216         edit_port = new PrefsRenderFarmPort(pwindow,
217                 this,
218                 x + xmargin3,
219                 y);
220         edit_port->create_objects();
221
222         y += 30;
223
224
225         add_subwindow(new PrefsRenderFarmReplaceNode(pwindow,
226                 this,
227                 x,
228                 y));
229         add_subwindow(new PrefsRenderFarmNewNode(pwindow,
230                 this,
231                 x + xmargin2,
232                 y));
233         y += 30;
234         add_subwindow(new PrefsRenderFarmDelNode(pwindow,
235                 this,
236                 x + xmargin2,
237                 y));
238         add_subwindow(new PrefsRenderFarmSortNodes(pwindow,
239                 this,
240                 x,
241                 y));
242         y += 30;
243         add_subwindow(new PrefsRenderFarmReset(pwindow,
244                 this,
245                 x,
246                 y));
247         y += 35;
248         add_subwindow(new BC_Title(x,
249                 y,
250                 _("Total jobs to create:")));
251         add_subwindow(new BC_Title(x,
252                 y + 30,
253                 _("(overridden if new file at each label is checked)")));
254         PrefsRenderFarmJobs *jobs = new PrefsRenderFarmJobs(pwindow,
255                 this,
256                 x + xmargin3,
257                 y);
258         jobs->create_objects();
259         y += 55;
260 //      add_subwindow(new PrefsRenderFarmVFS(pwindow,
261 //              this,
262 //              x,
263 //              y));
264 //      add_subwindow(new BC_Title(x,
265 //              y,
266 //              _("Filesystem prefix on remote nodes:")));
267 //      add_subwindow(new PrefsRenderFarmMountpoint(pwindow,
268 //              this,
269 //              x + xmargin3,
270 //              y));
271 //      y += 30;
272 }
273
274 void PerformancePrefs::generate_node_list()
275 {
276         int selected_row = node_list ? node_list->get_selection_number(0, 0) : -1;
277
278         for(int i = 0; i < TOTAL_COLUMNS; i++)
279                 nodes[i].remove_all_objects();
280
281         for(int i = 0;
282                 i < pwindow->thread->preferences->renderfarm_nodes.size();
283                 i++)
284         {
285                 BC_ListBoxItem *item;
286                 nodes[ENABLED_COLUMN].append(item = new BC_ListBoxItem(
287                         (char*)(pwindow->thread->preferences->renderfarm_enabled.get(i) ? "X" : " ")));
288                 if(i == selected_row) item->set_selected(1);
289
290                 nodes[HOSTNAME_COLUMN].append(item = new BC_ListBoxItem(
291                         pwindow->thread->preferences->renderfarm_nodes.get(i)));
292                 if(i == selected_row) item->set_selected(1);
293
294                 char string[BCTEXTLEN];
295                 sprintf(string, "%d", pwindow->thread->preferences->renderfarm_ports.get(i));
296                 nodes[PORT_COLUMN].append(item = new BC_ListBoxItem(string));
297                 if(i == selected_row) item->set_selected(1);
298
299                 sprintf(string, "%0.3f", pwindow->thread->preferences->renderfarm_rate.get(i));
300                 nodes[RATE_COLUMN].append(item = new BC_ListBoxItem(string));
301                 if(i == selected_row) item->set_selected(1);
302         }
303 }
304
305 static const char *titles[] =
306 {
307         N_("On"),
308         N_("Hostname"),
309         N_("Port"),
310         N_("Framerate")
311 };
312
313 static int widths[] =
314 {
315         30,
316         150,
317         50,
318         50
319 };
320
321
322 void PerformancePrefs::update_node_list()
323 {
324         node_list->update(nodes,
325                                                 titles,
326                                                 widths,
327                                                 TOTAL_COLUMNS,
328                                                 node_list->get_xposition(),
329                                                 node_list->get_yposition(),
330                                                 node_list->get_selection_number(0, 0));
331 }
332
333
334 void PerformancePrefs::update_rates()
335 {
336 //printf("PerformancePrefs::update_rates %d\n", __LINE__);
337         char string[BCTEXTLEN];
338         for(int i = 0;
339                 i < mwindow->preferences->renderfarm_rate.size();
340                 i++)
341         {
342                 if(i < nodes[RATE_COLUMN].size())
343                 {
344                         sprintf(string, "%0.3f", mwindow->preferences->renderfarm_rate.get(i));
345                         nodes[RATE_COLUMN].get(i)->set_text(string);
346                 }
347         }
348
349         sprintf(string, _(MASTER_NODE_FRAMERATE_TEXT),
350                 mwindow->preferences->local_rate);
351         master_rate->update(string);
352
353         update_node_list();
354 }
355
356
357 PrefsUseBRender::PrefsUseBRender(PreferencesWindow *pwindow,
358         int x,
359         int y)
360  : BC_CheckBox(x,
361         y,
362         pwindow->thread->preferences->use_brender,
363         _("Use background rendering"))
364 {
365         this->pwindow = pwindow;
366 }
367
368 int PrefsUseBRender::handle_event()
369 {
370         pwindow->thread->redraw_overlays = 1;
371         pwindow->thread->redraw_times = 1;
372         pwindow->thread->preferences->use_brender = get_value();
373         return 1;
374 }
375
376
377
378
379
380
381 PrefsBRenderFragment::PrefsBRenderFragment(PreferencesWindow *pwindow,
382         PerformancePrefs *subwindow,
383         int x,
384         int y)
385  : BC_TumbleTextBox(subwindow,
386         (int64_t)pwindow->thread->preferences->brender_fragment,
387         (int64_t)1,
388         (int64_t)65535,
389         x,
390         y,
391         100)
392 {
393         this->pwindow = pwindow;
394 }
395 int PrefsBRenderFragment::handle_event()
396 {
397         pwindow->thread->preferences->brender_fragment = atol(get_text());
398         return 1;
399 }
400
401
402
403
404
405
406
407
408
409
410
411 CICacheSize::CICacheSize(int x,
412         int y,
413         PreferencesWindow *pwindow,
414         PerformancePrefs *subwindow)
415  : BC_TumbleTextBox(subwindow,
416         (int64_t)pwindow->thread->preferences->cache_size / 0x100000,
417         (int64_t)MIN_CACHE_SIZE / 0x100000,
418         (int64_t)MAX_CACHE_SIZE / 0x100000,
419         x,
420         y,
421         100)
422 {
423         this->pwindow = pwindow;
424         set_increment(1);
425 }
426
427 int CICacheSize::handle_event()
428 {
429         int64_t result;
430         result = (int64_t)atol(get_text()) * 0x100000;
431         CLAMP(result, MIN_CACHE_SIZE, MAX_CACHE_SIZE);
432         pwindow->thread->preferences->cache_size = result;
433         return 0;
434 }
435
436
437 PrefsRenderPreroll::PrefsRenderPreroll(PreferencesWindow *pwindow,
438                 PerformancePrefs *subwindow,
439                 int x,
440                 int y)
441  : BC_TumbleTextBox(subwindow,
442         (float)pwindow->thread->preferences->render_preroll,
443         (float)0,
444         (float)100,
445         x,
446         y,
447         100)
448 {
449         this->pwindow = pwindow;
450         set_increment(0.1);
451 }
452 PrefsRenderPreroll::~PrefsRenderPreroll()
453 {
454 }
455 int PrefsRenderPreroll::handle_event()
456 {
457         pwindow->thread->preferences->render_preroll = atof(get_text());
458         return 1;
459 }
460
461
462 PrefsBRenderPreroll::PrefsBRenderPreroll(PreferencesWindow *pwindow,
463                 PerformancePrefs *subwindow,
464                 int x,
465                 int y)
466  : BC_TumbleTextBox(subwindow,
467         (int64_t)pwindow->thread->preferences->brender_preroll,
468         (int64_t)0,
469         (int64_t)100,
470         x,
471         y,
472         100)
473 {
474         this->pwindow = pwindow;
475 }
476 int PrefsBRenderPreroll::handle_event()
477 {
478         pwindow->thread->preferences->brender_preroll = atol(get_text());
479         return 1;
480 }
481
482
483
484
485
486
487
488
489
490
491
492 PrefsRenderFarm::PrefsRenderFarm(PreferencesWindow *pwindow, int x, int y)
493  : BC_CheckBox(x,
494         y,
495         pwindow->thread->preferences->use_renderfarm,
496         _("Use render farm"))
497 {
498         this->pwindow = pwindow;
499 }
500 PrefsRenderFarm::~PrefsRenderFarm()
501 {
502 }
503 int PrefsRenderFarm::handle_event()
504 {
505         pwindow->thread->preferences->use_renderfarm = get_value();
506         return 1;
507 }
508
509
510
511
512 PrefsForceUniprocessor::PrefsForceUniprocessor(PreferencesWindow *pwindow, int x, int y)
513  : BC_CheckBox(x,
514         y,
515         pwindow->thread->preferences->force_uniprocessor,
516         _("Force single processor use"))
517 {
518         this->pwindow = pwindow;
519 }
520 PrefsForceUniprocessor::~PrefsForceUniprocessor()
521 {
522 }
523 int PrefsForceUniprocessor::handle_event()
524 {
525         pwindow->thread->preferences->force_uniprocessor = get_value();
526         return 1;
527 }
528
529 PrefsTrapSigSEGV::PrefsTrapSigSEGV(PerformancePrefs *perf_prefs, int x, int y)
530  : BC_CheckBox(x, y,
531         perf_prefs->pwindow->thread->preferences->trap_sigsegv,
532         _("trap sigSEGV"))
533 {
534         this->perf_prefs = perf_prefs;
535 }
536 PrefsTrapSigSEGV::~PrefsTrapSigSEGV()
537 {
538 }
539 int PrefsTrapSigSEGV::handle_event()
540 {
541         perf_prefs->pwindow->thread->preferences->trap_sigsegv = get_value();
542         return 1;
543 }
544
545 PrefsTrapSigINTR::PrefsTrapSigINTR(PerformancePrefs *perf_prefs, int x, int y)
546  : BC_CheckBox(x, y,
547         perf_prefs->pwindow->thread->preferences->trap_sigintr,
548         _("trap sigINT"))
549 {
550         this->perf_prefs = perf_prefs;
551 }
552 PrefsTrapSigINTR::~PrefsTrapSigINTR()
553 {
554 }
555 int PrefsTrapSigINTR::handle_event()
556 {
557         perf_prefs->pwindow->thread->preferences->trap_sigintr = get_value();
558         return 1;
559 }
560
561
562 PrefsFFMPEGEarlyProbe::PrefsFFMPEGEarlyProbe(PerformancePrefs *perf_prefs, int x, int y)
563  : BC_CheckBox(x, y,
564         perf_prefs->pwindow->thread->preferences->ffmpeg_early_probe,
565         _("On file open, ffmpeg probes early"))
566 {
567         this->perf_prefs = perf_prefs;
568 }
569 PrefsFFMPEGEarlyProbe::~PrefsFFMPEGEarlyProbe()
570 {
571 }
572
573 int PrefsFFMPEGEarlyProbe::handle_event()
574 {
575         perf_prefs->pwindow->thread->preferences->ffmpeg_early_probe = get_value();
576         return 1;
577 }
578
579
580 PrefsFFMPEGMarkerIndecies::PrefsFFMPEGMarkerIndecies(PerformancePrefs *perf_prefs, int x, int y)
581  : BC_CheckBox(x, y,
582         perf_prefs->pwindow->thread->preferences->ffmpeg_marker_indexes,
583         _("build ffmpeg marker indexes"))
584 {
585         this->perf_prefs = perf_prefs;
586 }
587 PrefsFFMPEGMarkerIndecies::~PrefsFFMPEGMarkerIndecies()
588 {
589 }
590
591 int PrefsFFMPEGMarkerIndecies::handle_event()
592 {
593         perf_prefs->pwindow->thread->preferences->ffmpeg_marker_indexes = get_value();
594         return 1;
595 }
596
597
598
599
600
601
602 PrefsRenderFarmConsolidate::PrefsRenderFarmConsolidate(PreferencesWindow *pwindow, int x, int y)
603  : BC_CheckBox(x,
604         y,
605         pwindow->thread->preferences->renderfarm_consolidate,
606         _("Consolidate output files on completion"))
607 {
608         this->pwindow = pwindow;
609 }
610 PrefsRenderFarmConsolidate::~PrefsRenderFarmConsolidate()
611 {
612 }
613 int PrefsRenderFarmConsolidate::handle_event()
614 {
615         pwindow->thread->preferences->renderfarm_consolidate = get_value();
616         return 1;
617 }
618
619
620
621
622
623 PrefsRenderFarmPort::PrefsRenderFarmPort(PreferencesWindow *pwindow,
624         PerformancePrefs *subwindow,
625         int x,
626         int y)
627  : BC_TumbleTextBox(subwindow,
628         (int64_t)pwindow->thread->preferences->renderfarm_port,
629         (int64_t)1,
630         (int64_t)65535,
631         x,
632         y,
633         100)
634 {
635         this->pwindow = pwindow;
636 }
637
638 PrefsRenderFarmPort::~PrefsRenderFarmPort()
639 {
640 }
641
642 int PrefsRenderFarmPort::handle_event()
643 {
644         pwindow->thread->preferences->renderfarm_port = atol(get_text());
645         return 1;
646 }
647
648
649
650 PrefsRenderFarmNodes::PrefsRenderFarmNodes(PreferencesWindow *pwindow,
651         PerformancePrefs *subwindow,
652         int x,
653         int y)
654  : BC_ListBox(x,
655                 y,
656                 340,
657                 230,
658                 LISTBOX_TEXT,                         // Display text list or icons
659                 subwindow->nodes,
660                 titles,
661                 widths,
662                 4)
663 {
664         this->subwindow = subwindow;
665         this->pwindow = pwindow;
666 }
667 PrefsRenderFarmNodes::~PrefsRenderFarmNodes()
668 {
669 }
670
671 int PrefsRenderFarmNodes::column_resize_event()
672 {
673         for(int i = 0; i < 3; i++)
674                 widths[i] = get_column_width(i);
675         return 1;
676 }
677
678 int PrefsRenderFarmNodes::handle_event()
679 {
680 SET_TRACE
681         if(get_selection_number(0, 0) >= 0)
682         {
683                 subwindow->hot_node = get_selection_number(1, 0);
684                 subwindow->edit_node->update(get_selection(1, 0)->get_text());
685                 subwindow->edit_port->update(get_selection(2, 0)->get_text());
686                 if(get_cursor_x() < widths[0])
687                 {
688                         pwindow->thread->preferences->renderfarm_enabled.values[subwindow->hot_node] =
689                                 !pwindow->thread->preferences->renderfarm_enabled.values[subwindow->hot_node];
690                         subwindow->generate_node_list();
691                         subwindow->update_node_list();
692                 }
693         }
694         else
695         {
696                 subwindow->hot_node = -1;
697                 subwindow->edit_node->update("");
698         }
699 SET_TRACE
700         return 1;
701 }
702 int PrefsRenderFarmNodes::selection_changed()
703 {
704         handle_event();
705         return 1;
706 }
707
708
709
710
711
712
713
714 PrefsRenderFarmEditNode::PrefsRenderFarmEditNode(PreferencesWindow *pwindow, PerformancePrefs *subwindow, int x, int y)
715  : BC_TextBox(x, y, 240, 1, "")
716 {
717         this->pwindow = pwindow;
718         this->subwindow = subwindow;
719 }
720
721 PrefsRenderFarmEditNode::~PrefsRenderFarmEditNode()
722 {
723 }
724
725 int PrefsRenderFarmEditNode::handle_event()
726 {
727         return 1;
728 }
729
730
731
732
733
734
735 PrefsRenderFarmNewNode::PrefsRenderFarmNewNode(PreferencesWindow *pwindow, PerformancePrefs *subwindow, int x, int y)
736  : BC_GenericButton(x, y, _("Add Node"))
737 {
738         this->pwindow = pwindow;
739         this->subwindow = subwindow;
740 }
741 PrefsRenderFarmNewNode::~PrefsRenderFarmNewNode()
742 {
743 }
744 int PrefsRenderFarmNewNode::handle_event()
745 {
746         pwindow->thread->preferences->add_node(subwindow->edit_node->get_text(),
747                 pwindow->thread->preferences->renderfarm_port,
748                 1,
749                 0.0);
750         pwindow->thread->preferences->reset_rates();
751         subwindow->generate_node_list();
752         subwindow->update_node_list();
753         subwindow->hot_node = -1;
754         return 1;
755 }
756
757
758
759
760
761
762
763 PrefsRenderFarmReplaceNode::PrefsRenderFarmReplaceNode(PreferencesWindow *pwindow, PerformancePrefs *subwindow, int x, int y)
764  : BC_GenericButton(x, y, _("Apply Changes"))
765 {
766         this->pwindow = pwindow;
767         this->subwindow = subwindow;
768 }
769 PrefsRenderFarmReplaceNode::~PrefsRenderFarmReplaceNode()
770 {
771 }
772 int PrefsRenderFarmReplaceNode::handle_event()
773 {
774         if(subwindow->hot_node >= 0)
775         {
776                 pwindow->thread->preferences->edit_node(subwindow->hot_node,
777                         subwindow->edit_node->get_text(),
778                         pwindow->thread->preferences->renderfarm_port,
779                         pwindow->thread->preferences->renderfarm_enabled.values[subwindow->hot_node]);
780                 subwindow->generate_node_list();
781                 subwindow->update_node_list();
782         }
783         return 1;
784 }
785
786
787
788
789
790 PrefsRenderFarmDelNode::PrefsRenderFarmDelNode(PreferencesWindow *pwindow, PerformancePrefs *subwindow, int x, int y)
791  : BC_GenericButton(x, y, _("Delete Node"))
792 {
793         this->pwindow = pwindow;
794         this->subwindow = subwindow;
795 }
796 PrefsRenderFarmDelNode::~PrefsRenderFarmDelNode()
797 {
798 }
799 int PrefsRenderFarmDelNode::handle_event()
800 {
801         if( subwindow->hot_node >= 0 ) {
802                 pwindow->thread->preferences->delete_node(subwindow->hot_node);
803
804                 subwindow->generate_node_list();
805                 subwindow->update_node_list();
806                 subwindow->hot_node = -1;
807         }
808         return 1;
809 }
810
811
812
813
814
815 PrefsRenderFarmSortNodes::PrefsRenderFarmSortNodes(PreferencesWindow *pwindow,
816         PerformancePrefs *subwindow,
817         int x,
818         int y)
819  : BC_GenericButton(x, y, _("Sort nodes"))
820 {
821         this->pwindow = pwindow;
822         this->subwindow = subwindow;
823 }
824
825 PrefsRenderFarmSortNodes::~PrefsRenderFarmSortNodes()
826 {
827 }
828
829 int PrefsRenderFarmSortNodes::handle_event()
830 {
831         pwindow->thread->preferences->sort_nodes();
832         subwindow->generate_node_list();
833         subwindow->update_node_list();
834         subwindow->hot_node = -1;
835         return 1;
836 }
837
838
839
840
841
842 PrefsRenderFarmReset::PrefsRenderFarmReset(PreferencesWindow *pwindow,
843         PerformancePrefs *subwindow,
844         int x,
845         int y)
846  : BC_GenericButton(x, y, _("Reset rates"))
847 {
848         this->pwindow = pwindow;
849         this->subwindow = subwindow;
850 }
851
852 int PrefsRenderFarmReset::handle_event()
853 {
854         pwindow->thread->preferences->reset_rates();
855         subwindow->generate_node_list();
856         subwindow->update_node_list();
857
858         char string[BCTEXTLEN];
859         sprintf(string,
860                 MASTER_NODE_FRAMERATE_TEXT,
861                 pwindow->thread->preferences->local_rate);
862         subwindow->master_rate->update(string);
863         subwindow->hot_node = -1;
864         return 1;
865 }
866
867
868
869
870
871 PrefsProjectSMP::PrefsProjectSMP(PreferencesWindow *pwindow,
872                 PerformancePrefs *subwindow, int x, int y)
873  : BC_TumbleTextBox(subwindow,
874         (int64_t)pwindow->thread->preferences->project_smp,
875         (int64_t)1, (int64_t)100, x, y, 100)
876 {
877         this->pwindow = pwindow;
878 }
879 PrefsProjectSMP::~PrefsProjectSMP()
880 {
881 }
882 int PrefsProjectSMP::handle_event()
883 {
884         pwindow->thread->preferences->project_smp = atol(get_text());
885         return 1;
886 }
887
888
889
890
891
892 PrefsRenderFarmJobs::PrefsRenderFarmJobs(PreferencesWindow *pwindow,
893                 PerformancePrefs *subwindow,
894                 int x,
895                 int y)
896  : BC_TumbleTextBox(subwindow,
897         (int64_t)pwindow->thread->preferences->renderfarm_job_count,
898         (int64_t)1,
899         (int64_t)100,
900         x,
901         y,
902         100)
903 {
904         this->pwindow = pwindow;
905 }
906 PrefsRenderFarmJobs::~PrefsRenderFarmJobs()
907 {
908 }
909 int PrefsRenderFarmJobs::handle_event()
910 {
911         pwindow->thread->preferences->renderfarm_job_count = atol(get_text());
912         return 1;
913 }
914
915
916
917 PrefsRenderFarmMountpoint::PrefsRenderFarmMountpoint(PreferencesWindow *pwindow,
918                 PerformancePrefs *subwindow,
919                 int x,
920                 int y)
921  : BC_TextBox(x,
922         y,
923         100,
924         1,
925         pwindow->thread->preferences->renderfarm_mountpoint)
926 {
927         this->pwindow = pwindow;
928         this->subwindow = subwindow;
929 }
930 PrefsRenderFarmMountpoint::~PrefsRenderFarmMountpoint()
931 {
932 }
933 int PrefsRenderFarmMountpoint::handle_event()
934 {
935         strcpy(pwindow->thread->preferences->renderfarm_mountpoint, get_text());
936         return 1;
937 }
938
939
940
941
942 PrefsRenderFarmVFS::PrefsRenderFarmVFS(PreferencesWindow *pwindow,
943         PerformancePrefs *subwindow, int x, int y)
944  : BC_CheckBox(x, y, pwindow->thread->preferences->renderfarm_vfs,
945         _("Use virtual filesystem"))
946 {
947         this->pwindow = pwindow;
948         this->subwindow = subwindow;
949 }
950
951 int PrefsRenderFarmVFS::handle_event()
952 {
953         pwindow->thread->preferences->renderfarm_vfs = get_value();
954         return 1;
955 }
956
957
958 PrefsYUV420P_DVDlace::PrefsYUV420P_DVDlace(PreferencesWindow *pwindow,
959         PerformancePrefs *subwindow, int x, int y)
960  : BC_CheckBox(x, y, pwindow->thread->preferences->dvd_yuv420p_interlace,
961         _("Use yuv420p dvd interlace format"))
962 {
963         this->pwindow = pwindow;
964         this->subwindow = subwindow;
965 }
966
967 int PrefsYUV420P_DVDlace::handle_event()
968 {
969         pwindow->thread->preferences->dvd_yuv420p_interlace = get_value();
970         return 1;
971 }
972