4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
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
25 #include "condition.inc"
26 #include "cwindowgui.inc"
27 #include "cwindowtool.inc"
29 #include "keyframe.inc"
30 #include "maskauto.inc"
31 #include "maskautos.inc"
32 #include "mwindow.inc"
35 // This common thread supports all the tool GUI's.
36 class CWindowTool : public Thread
39 CWindowTool(MWindow *mwindow, CWindowGUI *gui);
42 // Called depending on state of toggle button
43 void start_tool(int operation);
46 // Called when window is visible
52 void update_show_window();
58 CWindowToolGUI *tool_gui;
61 Condition *input_lock;
62 Condition *output_lock;
63 // Lock run and update_values
67 class CWindowToolGUI : public BC_Window
70 CWindowToolGUI(MWindow *mwindow,
77 virtual void create_objects() {};
78 // Update the keyframe from text boxes
79 virtual void handle_event() {};
80 // Update text boxes from keyframe here
81 virtual void update() {};
82 // Update EDL and preview only
83 void update_preview(int changed_edl=0);
84 void draw_preview(int changed_edl);
85 int current_operation;
86 virtual int close_event();
88 int translation_event();
92 CWindowCoord *event_caller;
95 class CWindowCoord : public BC_TumbleTextBox
98 CWindowCoord(CWindowToolGUI *gui, int x, int y,
99 float value, int logincrement);
100 CWindowCoord(CWindowToolGUI *gui, int x, int y,
103 // Calls the window's handle_event
109 class CWindowCropOK : public BC_GenericButton
112 CWindowCropOK(MWindow *mwindow, CWindowToolGUI *gui,
114 // Perform the cropping operation
116 int keypress_event();
121 class CWindowCropGUI : public CWindowToolGUI
124 CWindowCropGUI(MWindow *mwindow, CWindowTool *thread);
126 void create_objects();
130 CWindowCoord *x1, *y1, *width, *height;
133 class CWindowMaskItem : public BC_ListBoxItem
136 CWindowMaskItem(const char *text, int id=-1, int color=-1)
137 : BC_ListBoxItem(text, color), id(id) {}
138 ~CWindowMaskItem() {}
142 class CWindowMaskItems : public ArrayList<BC_ListBoxItem*>
145 CWindowMaskItems() {}
146 ~CWindowMaskItems() { remove_all_objects(); }
149 class CWindowMaskOnTrack : public BC_PopupTextBox
152 CWindowMaskOnTrack(MWindow *mwindow, CWindowMaskGUI *gui,
153 int x, int y, int w, const char *text);
154 ~CWindowMaskOnTrack();
157 CWindowMaskItems track_items;
163 class CWindowMaskTrackTumbler : public BC_Tumbler
166 CWindowMaskTrackTumbler(MWindow *mwindow, CWindowMaskGUI *gui,
168 ~CWindowMaskTrackTumbler();
169 int handle_up_event();
170 int handle_down_event();
171 int do_event(int dir);
178 class CWindowMaskName : public BC_PopupTextBox
181 CWindowMaskName(MWindow *mwindow, CWindowMaskGUI *gui,
182 int x, int y, const char *text);
186 CWindowMaskItems mask_items;
189 void update_items(MaskAuto *keyframe);
192 class CWindowMaskUnclear : public BC_GenericButton
195 CWindowMaskUnclear(MWindow *mwindow, CWindowMaskGUI *gui,
196 int x, int y, int w);
202 class CWindowMaskSoloTrack : public BC_CheckBox
205 CWindowMaskSoloTrack(MWindow *mwindow, CWindowMaskGUI *gui,
206 int x, int y, int v);
207 static int calculate_w(BC_WindowBase *gui);
213 class CWindowMaskDelMask : public BC_GenericButton
216 CWindowMaskDelMask(MWindow *mwindow, CWindowMaskGUI *gui,
223 class CWindowMaskClrMask : public BC_Button
226 CWindowMaskClrMask(MWindow *mwindow, CWindowMaskGUI *gui,
228 ~CWindowMaskClrMask();
229 static int calculate_w(MWindow *mwindow);
235 class CWindowMaskButton : public BC_CheckBox
238 CWindowMaskButton(MWindow *mwindow, CWindowMaskGUI *gui,
239 int x, int y, int no, int v);
240 ~CWindowMaskButton();
248 class CWindowMaskThumbler : public BC_Tumbler
251 CWindowMaskThumbler(MWindow *mwindow, CWindowMaskGUI *gui,
253 ~CWindowMaskThumbler();
254 int handle_up_event();
255 int handle_down_event();
256 int do_event(int dir);
262 class CWindowMaskEnable : public BC_CheckBox
265 CWindowMaskEnable(MWindow *mwindow, CWindowMaskGUI *gui,
266 int x, int y, int no, int v);
267 ~CWindowMaskEnable();
275 class CWindowMaskFade : public BC_TumbleTextBox
278 CWindowMaskFade(MWindow *mwindow, CWindowMaskGUI *gui,
282 int update_value(float v);
288 class CWindowMaskFadeSlider : public BC_ISlider
291 CWindowMaskFadeSlider(MWindow *mwindow, CWindowMaskGUI *gui,
292 int x, int y, int w);
293 ~CWindowMaskFadeSlider();
295 int update(int64_t v);
296 char *get_caption() { return 0; }
304 class CWindowMaskGangFader : public BC_Toggle
307 CWindowMaskGangFader(MWindow *mwindow, CWindowMaskGUI *gui,
309 ~CWindowMaskGangFader();
315 class CWindowMaskGangFocus : public BC_Toggle
318 CWindowMaskGangFocus(MWindow *mwindow, CWindowMaskGUI *gui,
320 ~CWindowMaskGangFocus();
326 class CWindowMaskSmoothButton : public BC_Button
329 CWindowMaskSmoothButton(MWindow *mwindow, CWindowMaskGUI *gui,
330 const char *tip, int type, int on, int x, int y, const char *images);
337 class CWindowMaskAffectedPoint : public BC_TumbleTextBox
340 CWindowMaskAffectedPoint(MWindow *mwindow, CWindowMaskGUI *gui,
342 ~CWindowMaskAffectedPoint();
348 class CWindowMaskFocus : public BC_CheckBox
351 CWindowMaskFocus(MWindow *mwindow, CWindowMaskGUI *gui,
359 class CWindowMaskHelp : public BC_CheckBox
362 CWindowMaskHelp(MWindow *mwindow, CWindowMaskGUI *gui,
370 class CWindowMaskDrawMarkers : public BC_CheckBox
373 CWindowMaskDrawMarkers(MWindow *mwindow, CWindowMaskGUI *gui,
375 ~CWindowMaskDrawMarkers();
381 class CWindowMaskDrawBoundary : public BC_CheckBox
384 CWindowMaskDrawBoundary(MWindow *mwindow, CWindowMaskGUI *gui,
386 ~CWindowMaskDrawBoundary();
392 class CWindowMaskDelPoint : public BC_GenericButton
395 CWindowMaskDelPoint(MWindow *mwindow, CWindowMaskGUI *gui,
398 int keypress_event();
403 class CWindowMaskFeather : public BC_TumbleTextBox
406 CWindowMaskFeather(MWindow *mwindow, CWindowMaskGUI *gui,
408 ~CWindowMaskFeather();
410 int update_value(float v);
416 class CWindowMaskFeatherSlider : public BC_FSlider
419 CWindowMaskFeatherSlider(MWindow *mwindow, CWindowMaskGUI *gui,
420 int x, int y, int w, float v);
421 ~CWindowMaskFeatherSlider();
424 char *get_caption() { return 0; }
432 class CWindowMaskGangFeather : public BC_Toggle
435 CWindowMaskGangFeather(MWindow *mwindow, CWindowMaskGUI *gui,
437 ~CWindowMaskGangFeather();
443 class CWindowMaskBeforePlugins : public BC_CheckBox
446 CWindowMaskBeforePlugins(CWindowMaskGUI *gui,
452 class CWindowMaskLoad : public BC_GenericButton
455 CWindowMaskLoad(MWindow *mwindow, CWindowMaskGUI *gui,
456 int x, int y, int w);
463 class CWindowMaskSave : public BC_GenericButton
466 CWindowMaskSave(MWindow *mwindow, CWindowMaskGUI *gui,
467 int x, int y, int w);
473 CWindowMaskPresetDialog *preset_dialog;
476 class CWindowMaskPresetDialog : public BC_DialogThread
479 CWindowMaskPresetDialog(MWindow *mwindow, CWindowMaskGUI *gui);
480 ~CWindowMaskPresetDialog();
481 void handle_close_event(int result);
482 void handle_done_event(int result);
483 BC_Window* new_gui();
484 void start_dialog(int sx, int sy, MaskAuto *keyframe);
488 CWindowMaskPresetGUI *pgui;
493 class CWindowMaskPresetGUI : public BC_Window
496 CWindowMaskPresetGUI(CWindowMaskPresetDialog *preset_dialog,
497 int x, int y, const char *title);
498 void create_objects();
500 CWindowMaskPresetDialog *preset_dialog;
501 CWindowMaskPresetText *preset_text;
504 class CWindowMaskPresetText : public BC_PopupTextBox
507 CWindowMaskPresetText(CWindowMaskPresetGUI *pgui,
508 int x, int y, int w, int h, const char *text);
512 CWindowMaskPresetGUI *pgui;
513 CWindowMaskItems mask_items;
516 class CWindowMaskDelete : public BC_GenericButton
519 CWindowMaskDelete(MWindow *mwindow, CWindowMaskGUI *gui,
520 int x, int y, int w);
527 class CWindowMaskCenter : public BC_GenericButton
530 CWindowMaskCenter(MWindow *mwindow, CWindowMaskGUI *gui,
531 int x, int y, int w);
538 class CWindowMaskNormal : public BC_GenericButton
541 CWindowMaskNormal(MWindow *mwindow, CWindowMaskGUI *gui,
542 int x, int y, int w);
549 class CWindowMaskShape : public BC_ListBox
552 CWindowMaskShape(MWindow *mwindow, CWindowMaskGUI *gui);
554 void create_objects();
555 void builtin_shape(int i, SubMask *sub_mask);
556 void load_shape(int i, SubMask *sub_mask);
561 CWindowMaskItems shape_items;
564 class CWindowDisableOpenGLMasking : public BC_CheckBox
567 CWindowDisableOpenGLMasking(CWindowMaskGUI *gui,
573 class CWindowMaskGUI : public CWindowToolGUI
576 CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread);
578 void create_objects();
583 void set_focused(int v, float cx, float cy);
584 void update_buttons(MaskAuto *keyframe, int k);
585 void get_keyframe(Track* &track, MaskAutos* &autos, MaskAuto* &keyframe,
586 SubMask* &mask, MaskPoint* &point, int create_it);
587 void load_masks(ArrayList<SubMask *> &masks);
588 void save_masks(ArrayList<SubMask *> &masks);
589 int smooth_mask(int typ, int on);
590 int save_mask(const char *nm);
591 int del_mask(const char *nm);
595 CWindowMaskOnTrack *mask_on_track;
596 CWindowMaskTrackTumbler *mask_track_tumbler;
597 CWindowMaskName *mask_name;
598 CWindowMaskButton *mask_buttons[SUBMASKS];
599 CWindowMaskThumbler *mask_thumbler;
600 BC_Title *mask_blabels[SUBMASKS];
601 CWindowMaskEnable *mask_enables[SUBMASKS];
602 CWindowMaskSoloTrack *mask_solo_track;
603 CWindowMaskDelMask *mask_del;
604 CWindowMaskUnclear *mask_unclr;
605 CWindowMaskClrMask *mask_clr;
606 CWindowMaskShape *mask_shape;
607 CWindowMaskSave *mask_save;
608 CWindowMaskLoad *mask_load;
609 CWindowMaskDelete *mask_delete;
610 CWindowMaskPresetDialog *preset_dialog;
611 CWindowMaskCenter *mask_center;
612 CWindowMaskNormal *mask_normal;
613 CWindowMaskFade *fade;
614 CWindowMaskFadeSlider *fade_slider;
615 CWindowMaskGangFader *gang_fader;
616 CWindowMaskAffectedPoint *active_point;
617 CWindowMaskDelPoint *del_point;
618 CWindowMaskSmoothButton *mask_pnt_linear, *mask_pnt_smooth;
619 CWindowMaskSmoothButton *mask_crv_linear, *mask_crv_smooth;
620 CWindowMaskSmoothButton *mask_all_linear, *mask_all_smooth;
622 CWindowMaskFocus *focus;
624 CWindowMaskGangFocus *gang_focus;
625 CWindowMaskHelp *help;
626 int helped, help_y, help_h;
627 CWindowMaskDrawMarkers *draw_markers;
629 CWindowMaskDrawBoundary *draw_boundary;
631 CWindowCoord *focus_x, *focus_y;
632 CWindowMaskFeather *feather;
633 CWindowMaskFeatherSlider *feather_slider;
634 CWindowMaskGangFeather *gang_feather;
635 CWindowMaskBeforePlugins *apply_before_plugins;
636 CWindowDisableOpenGLMasking *disable_opengl_masking;
640 class CWindowEyedropGUI : public CWindowToolGUI
643 CWindowEyedropGUI(MWindow *mwindow, CWindowTool *thread);
644 ~CWindowEyedropGUI();
647 void create_objects();
651 CWindowCoord *radius;
652 CWindowEyedropCheckBox *use_max;
653 BC_Title *red, *green, *blue, *y, *u, *v;
654 BC_Title *rgb_hex, *yuv_hex;
655 BC_SubWindow *sample;
659 class CWindowEyedropCheckBox : public BC_CheckBox
662 CWindowEyedropCheckBox(MWindow *mwindow,
663 CWindowEyedropGUI *gui,
669 CWindowEyedropGUI *gui;
674 class CWindowCameraGUI : public CWindowToolGUI
677 CWindowCameraGUI(MWindow *mwindow, CWindowTool *thread);
679 void create_objects();
682 // Update the keyframe from text boxes
684 // BezierAuto* get_keyframe();
685 CWindowCoord *x, *y, *z;
687 // Toggles for keyframe curve mode (for camera automation only)
688 CWindowCurveToggle *t_smooth, *t_linear;
691 class CWindowCameraLeft : public BC_Button
694 CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui,
698 CWindowCameraGUI *gui;
701 class CWindowCameraCenter : public BC_Button
704 CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui,
708 CWindowCameraGUI *gui;
711 class CWindowCameraRight : public BC_Button
714 CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui,
718 CWindowCameraGUI *gui;
721 class CWindowCameraTop : public BC_Button
724 CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui,
728 CWindowCameraGUI *gui;
731 class CWindowCameraMiddle : public BC_Button
734 CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui,
738 CWindowCameraGUI *gui;
741 class CWindowCameraBottom : public BC_Button
744 CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui,
748 CWindowCameraGUI *gui;
751 class CWindowProjectorGUI : public CWindowToolGUI
754 CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread);
755 ~CWindowProjectorGUI();
756 void create_objects();
759 // BezierAuto* get_keyframe();
760 CWindowCoord *x, *y, *z;
762 // Toggles for keyframe curve mode (projector automation only)
763 CWindowCurveToggle *t_smooth, *t_linear;
766 class CWindowProjectorLeft : public BC_Button
769 CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui,
773 CWindowProjectorGUI *gui;
776 class CWindowProjectorCenter : public BC_Button
779 CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui,
783 CWindowProjectorGUI *gui;
786 class CWindowProjectorRight : public BC_Button
789 CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui,
793 CWindowProjectorGUI *gui;
796 class CWindowProjectorTop : public BC_Button
799 CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui,
803 CWindowProjectorGUI *gui;
806 class CWindowProjectorMiddle : public BC_Button
809 CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui,
813 CWindowProjectorGUI *gui;
816 class CWindowProjectorBottom : public BC_Button
819 CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui,
823 CWindowProjectorGUI *gui;
829 class CWindowRulerGUI : public CWindowToolGUI
832 CWindowRulerGUI(MWindow *mwindow, CWindowTool *thread);
834 void create_objects();
843 BC_TextBox *distance;