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"
41 // This common thread supports all the tool GUI's.
42 class CWindowTool : public Thread
45 CWindowTool(MWindow *mwindow, CWindowGUI *gui);
48 // Called depending on state of toggle button
49 void start_tool(int operation);
52 // Called when window is visible
58 void update_show_window();
64 CWindowToolGUI *tool_gui;
67 Condition *input_lock;
68 Condition *output_lock;
69 // Lock run and update_values
73 class CWindowToolGUI : public BC_Window
76 CWindowToolGUI(MWindow *mwindow,
83 virtual void create_objects() {};
84 // Update the keyframe from text boxes
85 virtual void handle_event() {};
86 // Update text boxes from keyframe here
87 virtual void update() {};
88 // Update EDL and preview only
89 void update_preview(int changed_edl=0);
90 void draw_preview(int changed_edl);
91 int current_operation;
92 virtual int close_event();
94 int translation_event();
98 CWindowCoord *event_caller;
101 class CWindowCoord : public BC_TumbleTextBox
104 CWindowCoord(CWindowToolGUI *gui, int x, int y,
105 float value, int logincrement);
106 CWindowCoord(CWindowToolGUI *gui, int x, int y,
109 // Calls the window's handle_event
115 class CWindowCropOK : public BC_GenericButton
118 CWindowCropOK(MWindow *mwindow, CWindowToolGUI *gui,
120 // Perform the cropping operation
122 int keypress_event();
127 class CWindowCropGUI : public CWindowToolGUI
130 CWindowCropGUI(MWindow *mwindow, CWindowTool *thread);
132 void create_objects();
136 CWindowCoord *x1, *y1, *width, *height;
139 class CWindowMaskItem : public BC_ListBoxItem
142 CWindowMaskItem(const char *text, int id=-1, int color=-1)
143 : BC_ListBoxItem(text, color), id(id) {}
144 ~CWindowMaskItem() {}
148 class CWindowMaskItems : public ArrayList<BC_ListBoxItem*>
151 CWindowMaskItems() {}
152 ~CWindowMaskItems() { remove_all_objects(); }
155 class CWindowMaskOnTrack : public BC_PopupTextBox
158 CWindowMaskOnTrack(MWindow *mwindow, CWindowMaskGUI *gui,
159 int x, int y, int w, const char *text);
160 ~CWindowMaskOnTrack();
163 CWindowMaskItems track_items;
169 class CWindowMaskTrackTumbler : public BC_Tumbler
172 CWindowMaskTrackTumbler(MWindow *mwindow, CWindowMaskGUI *gui,
174 ~CWindowMaskTrackTumbler();
175 int handle_up_event();
176 int handle_down_event();
177 int do_event(int dir);
184 class CWindowMaskName : public BC_PopupTextBox
187 CWindowMaskName(MWindow *mwindow, CWindowMaskGUI *gui,
188 int x, int y, const char *text);
192 CWindowMaskItems mask_items;
195 void update_items(MaskAuto *keyframe);
198 class CWindowMaskUnclear : public BC_Button
201 CWindowMaskUnclear(MWindow *mwindow, CWindowMaskGUI *gui,
208 class CWindowMaskSoloTrack : public BC_CheckBox
211 CWindowMaskSoloTrack(MWindow *mwindow, CWindowMaskGUI *gui,
212 int x, int y, int v);
213 static int calculate_w(BC_WindowBase *gui);
219 class CWindowMaskDelMask : public BC_GenericButton
222 CWindowMaskDelMask(MWindow *mwindow, CWindowMaskGUI *gui,
229 class CWindowMaskClrMask : public BC_Button
232 CWindowMaskClrMask(MWindow *mwindow, CWindowMaskGUI *gui,
234 ~CWindowMaskClrMask();
235 static int calculate_w(MWindow *mwindow);
241 class CWindowMaskButton : public BC_CheckBox
244 CWindowMaskButton(MWindow *mwindow, CWindowMaskGUI *gui,
245 int x, int y, int no, int v);
246 ~CWindowMaskButton();
254 class CWindowMaskThumbler : public BC_Tumbler
257 CWindowMaskThumbler(MWindow *mwindow, CWindowMaskGUI *gui,
259 ~CWindowMaskThumbler();
260 int handle_up_event();
261 int handle_down_event();
262 int do_event(int dir);
268 class CWindowMaskEnable : public BC_CheckBox
271 CWindowMaskEnable(MWindow *mwindow, CWindowMaskGUI *gui,
272 int x, int y, int no, int v);
273 ~CWindowMaskEnable();
281 class CWindowMaskFade : public BC_TumbleTextBox
284 CWindowMaskFade(MWindow *mwindow, CWindowMaskGUI *gui,
288 int update_value(float v);
294 class CWindowMaskFadeSlider : public BC_ISlider
297 CWindowMaskFadeSlider(MWindow *mwindow, CWindowMaskGUI *gui,
298 int x, int y, int w);
299 ~CWindowMaskFadeSlider();
301 int update(int64_t v);
302 char *get_caption() { return 0; }
310 class CWindowMaskGangFader : public BC_Toggle
313 CWindowMaskGangFader(MWindow *mwindow, CWindowMaskGUI *gui,
315 ~CWindowMaskGangFader();
321 class CWindowMaskGangFocus : public BC_Toggle
324 CWindowMaskGangFocus(MWindow *mwindow, CWindowMaskGUI *gui,
326 ~CWindowMaskGangFocus();
332 class CWindowMaskSmoothButton : public BC_Button
335 CWindowMaskSmoothButton(MWindow *mwindow, CWindowMaskGUI *gui,
336 const char *tip, int type, int on, int x, int y, const char *images);
343 class CWindowMaskAffectedPoint : public BC_TumbleTextBox
346 CWindowMaskAffectedPoint(MWindow *mwindow, CWindowMaskGUI *gui,
348 ~CWindowMaskAffectedPoint();
354 class CWindowMaskFocus : public BC_CheckBox
357 CWindowMaskFocus(MWindow *mwindow, CWindowMaskGUI *gui,
363 static int calculate_w(CWindowMaskGUI *gui);
366 class CWindowMaskScaleXY : public BC_Toggle
369 CWindowMaskScaleXY(MWindow *mwindow, CWindowMaskGUI *gui,
370 int x, int y, VFrame **data, int v,
371 int id, const char *tip);
372 ~CWindowMaskScaleXY();
379 class CWindowMaskHelp : public BC_CheckBox
382 CWindowMaskHelp(MWindow *mwindow, CWindowMaskGUI *gui,
390 class CWindowMaskDrawMarkers : public BC_CheckBox
393 CWindowMaskDrawMarkers(MWindow *mwindow, CWindowMaskGUI *gui,
395 ~CWindowMaskDrawMarkers();
401 class CWindowMaskDrawBoundary : public BC_CheckBox
404 CWindowMaskDrawBoundary(MWindow *mwindow, CWindowMaskGUI *gui,
406 ~CWindowMaskDrawBoundary();
412 class CWindowMaskDelPoint : public BC_GenericButton
415 CWindowMaskDelPoint(MWindow *mwindow, CWindowMaskGUI *gui,
418 int keypress_event();
423 class CWindowMaskFeather : public BC_TumbleTextBox
426 CWindowMaskFeather(MWindow *mwindow, CWindowMaskGUI *gui,
428 ~CWindowMaskFeather();
430 int update_value(float v);
436 class CWindowMaskFeatherSlider : public BC_FSlider
439 CWindowMaskFeatherSlider(MWindow *mwindow, CWindowMaskGUI *gui,
440 int x, int y, int w, float v);
441 ~CWindowMaskFeatherSlider();
444 char *get_caption() { return 0; }
452 class CWindowMaskGangFeather : public BC_Toggle
455 CWindowMaskGangFeather(MWindow *mwindow, CWindowMaskGUI *gui,
457 ~CWindowMaskGangFeather();
463 class CWindowMaskBeforePlugins : public BC_CheckBox
466 CWindowMaskBeforePlugins(CWindowMaskGUI *gui,
472 class CWindowMaskLoadList : public BC_ListBox
475 CWindowMaskLoadList(MWindow *mwindow, CWindowMaskGUI *gui);
476 ~CWindowMaskLoadList();
477 void create_objects();
482 CWindowMaskItems shape_items;
485 class CWindowMaskLoad : public BC_Button
488 CWindowMaskLoad(MWindow *mwindow, CWindowMaskGUI *gui,
489 int x, int y, int w);
496 class CWindowMaskSave : public BC_Button
499 CWindowMaskSave(MWindow *mwindow, CWindowMaskGUI *gui,
500 int x, int y, int w);
506 CWindowMaskPresetDialog *preset_dialog;
509 class CWindowMaskPresetDialog : public BC_DialogThread
512 CWindowMaskPresetDialog(MWindow *mwindow, CWindowMaskGUI *gui);
513 ~CWindowMaskPresetDialog();
514 void handle_close_event(int result);
515 void handle_done_event(int result);
516 BC_Window* new_gui();
517 void start_dialog(int sx, int sy, MaskAuto *keyframe);
521 CWindowMaskPresetGUI *pgui;
526 class CWindowMaskPresetGUI : public BC_Window
529 CWindowMaskPresetGUI(CWindowMaskPresetDialog *preset_dialog,
530 int x, int y, const char *title);
531 void create_objects();
533 CWindowMaskPresetDialog *preset_dialog;
534 CWindowMaskPresetText *preset_text;
537 class CWindowMaskPresetText : public BC_PopupTextBox
540 CWindowMaskPresetText(CWindowMaskPresetGUI *pgui,
541 int x, int y, int w, int h, const char *text);
545 CWindowMaskPresetGUI *pgui;
546 CWindowMaskItems mask_items;
549 class CWindowMaskDelete : public BC_Button
552 CWindowMaskDelete(MWindow *mwindow, CWindowMaskGUI *gui,
553 int x, int y, int w);
560 class CWindowMaskCenter : public BC_Button
563 CWindowMaskCenter(MWindow *mwindow, CWindowMaskGUI *gui,
564 int x, int y, int w);
571 class CWindowMaskNormal : public BC_Button
574 CWindowMaskNormal(MWindow *mwindow, CWindowMaskGUI *gui,
575 int x, int y, int w);
582 class CWindowMaskShape : public BC_Button
585 CWindowMaskShape(MWindow *mwindow, CWindowMaskGUI *gui,
586 const char *images, int shape, int x, int y, const char *tip);
588 void builtin_shape(int i, SubMask *sub_mask);
594 CWindowMaskItems shape_items;
597 class CWindowDisableOpenGLMasking : public BC_CheckBox
600 CWindowDisableOpenGLMasking(CWindowMaskGUI *gui,
606 class CWindowMaskGUI : public CWindowToolGUI
609 CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread);
611 void create_objects();
616 void set_focused(int v, float cx, float cy);
617 void update_buttons(MaskAuto *keyframe, int k);
618 void get_keyframe(Track* &track, MaskAutos* &autos, MaskAuto* &keyframe,
619 SubMask* &mask, MaskPoint* &point, int create_it);
620 void load_masks(ArrayList<SubMask *> &masks);
621 void save_masks(ArrayList<SubMask *> &masks);
622 int smooth_mask(int typ, int on);
623 int save_mask(const char *nm);
624 int del_mask(const char *nm);
628 CWindowMaskOnTrack *mask_on_track;
629 CWindowMaskTrackTumbler *mask_track_tumbler;
630 CWindowMaskName *mask_name;
631 CWindowMaskButton *mask_buttons[SUBMASKS];
632 CWindowMaskThumbler *mask_thumbler;
633 BC_Title *mask_blabels[SUBMASKS];
634 CWindowMaskEnable *mask_enables[SUBMASKS];
635 CWindowMaskSoloTrack *mask_solo_track;
636 CWindowMaskDelMask *mask_del;
637 CWindowMaskUnclear *mask_unclr;
638 CWindowMaskClrMask *mask_clr;
639 CWindowMaskShape *mask_shape_sqr;
640 CWindowMaskShape *mask_shape_crc;
641 CWindowMaskShape *mask_shape_tri;
642 CWindowMaskShape *mask_shape_ovl;
643 CWindowMaskLoadList *mask_load_list;
644 CWindowMaskLoad *mask_load;
645 CWindowMaskSave *mask_save;
646 CWindowMaskDelete *mask_delete;
647 CWindowMaskPresetDialog *preset_dialog;
648 CWindowMaskCenter *mask_center;
649 CWindowMaskNormal *mask_normal;
650 CWindowMaskFade *fade;
651 CWindowMaskFadeSlider *fade_slider;
652 CWindowMaskGangFader *gang_fader;
653 CWindowMaskAffectedPoint *active_point;
654 CWindowMaskDelPoint *del_point;
655 CWindowMaskSmoothButton *mask_pnt_linear, *mask_pnt_smooth;
656 CWindowMaskSmoothButton *mask_crv_linear, *mask_crv_smooth;
657 CWindowMaskSmoothButton *mask_all_linear, *mask_all_smooth;
659 CWindowMaskScaleXY *mask_scale_x, *mask_scale_y, *mask_scale_xy;
661 CWindowMaskFocus *focus;
663 CWindowMaskGangFocus *gang_focus;
664 CWindowMaskHelp *help;
665 int helped, help_y, help_h;
666 CWindowMaskDrawMarkers *draw_markers;
668 CWindowMaskDrawBoundary *draw_boundary;
670 CWindowCoord *focus_x, *focus_y;
671 CWindowMaskFeather *feather;
672 CWindowMaskFeatherSlider *feather_slider;
673 CWindowMaskGangFeather *gang_feather;
674 CWindowMaskBeforePlugins *apply_before_plugins;
675 CWindowDisableOpenGLMasking *disable_opengl_masking;
679 class CWindowEyedropGUI : public CWindowToolGUI
682 CWindowEyedropGUI(MWindow *mwindow, CWindowTool *thread);
683 ~CWindowEyedropGUI();
686 void create_objects();
690 CWindowCoord *radius;
691 CWindowEyedropCheckBox *use_max;
692 BC_Title *red, *green, *blue, *y, *u, *v;
693 BC_Title *rgb_hex, *yuv_hex;
694 BC_SubWindow *sample;
698 class CWindowEyedropCheckBox : public BC_CheckBox
701 CWindowEyedropCheckBox(MWindow *mwindow,
702 CWindowEyedropGUI *gui,
708 CWindowEyedropGUI *gui;
713 class CWindowCameraGUI : public CWindowToolGUI
716 CWindowCameraGUI(MWindow *mwindow, CWindowTool *thread);
718 void create_objects();
721 // Update the keyframe from text boxes
723 // BezierAuto* get_keyframe();
724 CWindowCoord *x, *y, *z;
726 // Toggles for keyframe curve mode (for camera automation only)
727 CWindowCurveToggle *t_smooth, *t_linear;
730 class CWindowCameraLeft : public BC_Button
733 CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui,
737 CWindowCameraGUI *gui;
740 class CWindowCameraCenter : public BC_Button
743 CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui,
747 CWindowCameraGUI *gui;
750 class CWindowCameraRight : public BC_Button
753 CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui,
757 CWindowCameraGUI *gui;
760 class CWindowCameraTop : public BC_Button
763 CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui,
767 CWindowCameraGUI *gui;
770 class CWindowCameraMiddle : public BC_Button
773 CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui,
777 CWindowCameraGUI *gui;
780 class CWindowCameraBottom : public BC_Button
783 CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui,
787 CWindowCameraGUI *gui;
790 class CWindowProjectorGUI : public CWindowToolGUI
793 CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread);
794 ~CWindowProjectorGUI();
795 void create_objects();
798 // BezierAuto* get_keyframe();
799 CWindowCoord *x, *y, *z;
801 // Toggles for keyframe curve mode (projector automation only)
802 CWindowCurveToggle *t_smooth, *t_linear;
805 class CWindowProjectorLeft : public BC_Button
808 CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui,
812 CWindowProjectorGUI *gui;
815 class CWindowProjectorCenter : public BC_Button
818 CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui,
822 CWindowProjectorGUI *gui;
825 class CWindowProjectorRight : public BC_Button
828 CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui,
832 CWindowProjectorGUI *gui;
835 class CWindowProjectorTop : public BC_Button
838 CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui,
842 CWindowProjectorGUI *gui;
845 class CWindowProjectorMiddle : public BC_Button
848 CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui,
852 CWindowProjectorGUI *gui;
855 class CWindowProjectorBottom : public BC_Button
858 CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui,
862 CWindowProjectorGUI *gui;
868 class CWindowRulerGUI : public CWindowToolGUI
871 CWindowRulerGUI(MWindow *mwindow, CWindowTool *thread);
873 void create_objects();
882 BC_TextBox *distance;