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"
46 // This common thread supports all the tool GUI's.
47 class CWindowTool : public Thread
50 CWindowTool(MWindow *mwindow, CWindowGUI *gui);
53 // Called depending on state of toggle button
54 void start_tool(int operation);
57 // Called when window is visible
63 void update_show_window();
69 CWindowToolGUI *tool_gui;
72 Condition *input_lock;
73 Condition *output_lock;
74 // Lock run and update_values
78 class CWindowToolGUI : public BC_Window
81 CWindowToolGUI(MWindow *mwindow,
88 virtual void create_objects() {};
89 // Update the keyframe from text boxes
90 virtual void handle_event() {};
91 // Update text boxes from keyframe here
92 virtual void update() {};
93 // Update EDL and preview only
94 void update_preview(int changed_edl=0);
95 void draw_preview(int changed_edl);
96 int current_operation;
97 virtual int close_event();
99 int translation_event();
103 CWindowCoord *event_caller;
106 class CWindowCoord : public BC_TumbleTextBox
109 CWindowCoord(CWindowToolGUI *gui, int x, int y,
110 float value, int logincrement);
111 CWindowCoord(CWindowToolGUI *gui, int x, int y,
114 // Calls the window's handle_event
120 class CWindowCropApply : public BC_GenericButton
123 CWindowCropApply(MWindow *mwindow, CWindowCropGUI *crop_gui,
125 // Perform the cropping operation
127 int keypress_event();
129 CWindowCropGUI *crop_gui;
132 class CWindowCropOpMode : public BC_PopupMenu
134 static const char *crop_ops[CROP_MODES];
136 CWindowCropOpMode(MWindow *mwindow, CWindowCropGUI *crop_gui,
137 int mode, int x, int y);
138 ~CWindowCropOpMode();
139 void create_objects();
143 CWindowCropGUI *crop_gui;
147 class CWindowCropOpItem : public BC_MenuItem
150 CWindowCropOpItem(CWindowCropOpMode *popup, const char *text, int id);
153 CWindowCropOpMode *popup;
158 class CWindowCropGUI : public CWindowToolGUI
161 CWindowCropGUI(MWindow *mwindow, CWindowTool *thread);
163 void create_objects();
167 CWindowCoord *x1, *y1, *width, *height;
168 CWindowCropOpMode *crop_mode;
171 class CWindowMaskItem : public BC_ListBoxItem
174 CWindowMaskItem(const char *text, int id=-1, int color=-1)
175 : BC_ListBoxItem(text, color), id(id) {}
176 ~CWindowMaskItem() {}
180 class CWindowMaskItems : public ArrayList<BC_ListBoxItem*>
183 CWindowMaskItems() {}
184 ~CWindowMaskItems() { remove_all_objects(); }
187 class CWindowMaskOnTrack : public BC_PopupTextBox
190 CWindowMaskOnTrack(MWindow *mwindow, CWindowMaskGUI *gui,
191 int x, int y, int w, const char *text);
192 ~CWindowMaskOnTrack();
195 CWindowMaskItems track_items;
201 class CWindowMaskTrackTumbler : public BC_Tumbler
204 CWindowMaskTrackTumbler(MWindow *mwindow, CWindowMaskGUI *gui,
206 ~CWindowMaskTrackTumbler();
207 int handle_up_event();
208 int handle_down_event();
209 int do_event(int dir);
216 class CWindowMaskName : public BC_PopupTextBox
219 CWindowMaskName(MWindow *mwindow, CWindowMaskGUI *gui,
220 int x, int y, const char *text);
224 CWindowMaskItems mask_items;
227 void update_items(MaskAuto *keyframe);
230 class CWindowMaskUnclear : public BC_Button
233 CWindowMaskUnclear(MWindow *mwindow, CWindowMaskGUI *gui,
240 class CWindowMaskSoloTrack : public BC_CheckBox
243 CWindowMaskSoloTrack(MWindow *mwindow, CWindowMaskGUI *gui,
244 int x, int y, int v);
245 static int calculate_w(BC_WindowBase *gui);
251 class CWindowMaskDelMask : public BC_GenericButton
254 CWindowMaskDelMask(MWindow *mwindow, CWindowMaskGUI *gui,
261 class CWindowMaskClrMask : public BC_Button
264 CWindowMaskClrMask(MWindow *mwindow, CWindowMaskGUI *gui,
266 ~CWindowMaskClrMask();
267 static int calculate_w(MWindow *mwindow);
273 class CWindowMaskButton : public BC_CheckBox
276 CWindowMaskButton(MWindow *mwindow, CWindowMaskGUI *gui,
277 int x, int y, int no, int v);
278 ~CWindowMaskButton();
286 class CWindowMaskThumbler : public BC_Tumbler
289 CWindowMaskThumbler(MWindow *mwindow, CWindowMaskGUI *gui,
291 ~CWindowMaskThumbler();
292 int handle_up_event();
293 int handle_down_event();
294 int do_event(int dir);
300 class CWindowMaskEnable : public BC_CheckBox
303 CWindowMaskEnable(MWindow *mwindow, CWindowMaskGUI *gui,
304 int x, int y, int no, int v);
305 ~CWindowMaskEnable();
313 class CWindowMaskFade : public BC_TumbleTextBox
316 CWindowMaskFade(MWindow *mwindow, CWindowMaskGUI *gui,
320 int update_value(float v);
326 class CWindowMaskFadeSlider : public BC_ISlider
329 CWindowMaskFadeSlider(MWindow *mwindow, CWindowMaskGUI *gui,
330 int x, int y, int w);
331 ~CWindowMaskFadeSlider();
333 int update(int64_t v);
334 char *get_caption() { return 0; }
342 class CWindowMaskGangFader : public BC_Toggle
345 CWindowMaskGangFader(MWindow *mwindow, CWindowMaskGUI *gui,
347 ~CWindowMaskGangFader();
353 class CWindowMaskGangFocus : public BC_Toggle
356 CWindowMaskGangFocus(MWindow *mwindow, CWindowMaskGUI *gui,
358 ~CWindowMaskGangFocus();
364 class CWindowMaskGangPoint : public BC_Toggle
367 CWindowMaskGangPoint(MWindow *mwindow, CWindowMaskGUI *gui,
369 ~CWindowMaskGangPoint();
375 class CWindowMaskSmoothButton : public BC_Button
378 CWindowMaskSmoothButton(MWindow *mwindow, CWindowMaskGUI *gui,
379 const char *tip, int type, int on, int x, int y, const char *images);
386 class CWindowMaskAffectedPoint : public BC_TumbleTextBox
389 CWindowMaskAffectedPoint(MWindow *mwindow, CWindowMaskGUI *gui,
391 ~CWindowMaskAffectedPoint();
397 class CWindowMaskFocus : public BC_CheckBox
400 CWindowMaskFocus(MWindow *mwindow, CWindowMaskGUI *gui,
406 static int calculate_w(CWindowMaskGUI *gui);
409 class CWindowMaskScaleXY : public BC_Toggle
412 CWindowMaskScaleXY(MWindow *mwindow, CWindowMaskGUI *gui,
413 int x, int y, VFrame **data, int v,
414 int id, const char *tip);
415 ~CWindowMaskScaleXY();
422 class CWindowMaskHelp : public BC_CheckBox
425 CWindowMaskHelp(MWindow *mwindow, CWindowMaskGUI *gui,
433 class CWindowMaskDrawMarkers : public BC_CheckBox
436 CWindowMaskDrawMarkers(MWindow *mwindow, CWindowMaskGUI *gui,
438 ~CWindowMaskDrawMarkers();
444 class CWindowMaskDrawBoundary : public BC_CheckBox
447 CWindowMaskDrawBoundary(MWindow *mwindow, CWindowMaskGUI *gui,
449 ~CWindowMaskDrawBoundary();
455 class CWindowMaskDelPoint : public BC_GenericButton
458 CWindowMaskDelPoint(MWindow *mwindow, CWindowMaskGUI *gui,
465 class CWindowMaskFeather : public BC_TumbleTextBox
468 CWindowMaskFeather(MWindow *mwindow, CWindowMaskGUI *gui,
470 ~CWindowMaskFeather();
472 int update_value(float v);
478 class CWindowMaskFeatherSlider : public BC_FSlider
481 CWindowMaskFeatherSlider(MWindow *mwindow, CWindowMaskGUI *gui,
482 int x, int y, int w, float v);
483 ~CWindowMaskFeatherSlider();
486 int update(int r, float v, float mn, float mx);
487 char *get_caption() { return 0; }
496 class CWindowMaskGangFeather : public BC_Toggle
499 CWindowMaskGangFeather(MWindow *mwindow, CWindowMaskGUI *gui,
501 ~CWindowMaskGangFeather();
507 class CWindowMaskBeforePlugins : public BC_CheckBox
510 CWindowMaskBeforePlugins(CWindowMaskGUI *gui,
516 class CWindowMaskLoadList : public BC_ListBox
519 CWindowMaskLoadList(MWindow *mwindow, CWindowMaskGUI *gui);
520 ~CWindowMaskLoadList();
521 void create_objects();
526 CWindowMaskItems shape_items;
529 class CWindowMaskLoad : public BC_Button
532 CWindowMaskLoad(MWindow *mwindow, CWindowMaskGUI *gui,
533 int x, int y, int w);
540 class CWindowMaskSave : public BC_Button
543 CWindowMaskSave(MWindow *mwindow, CWindowMaskGUI *gui,
544 int x, int y, int w);
550 CWindowMaskPresetDialog *preset_dialog;
553 class CWindowMaskPresetDialog : public BC_DialogThread
556 CWindowMaskPresetDialog(MWindow *mwindow, CWindowMaskGUI *gui);
557 ~CWindowMaskPresetDialog();
558 void handle_close_event(int result);
559 void handle_done_event(int result);
560 BC_Window* new_gui();
561 void start_dialog(int sx, int sy, MaskAuto *keyframe);
565 CWindowMaskPresetGUI *pgui;
570 class CWindowMaskPresetGUI : public BC_Window
573 CWindowMaskPresetGUI(CWindowMaskPresetDialog *preset_dialog,
574 int x, int y, const char *title);
575 void create_objects();
577 CWindowMaskPresetDialog *preset_dialog;
578 CWindowMaskPresetText *preset_text;
581 class CWindowMaskPresetText : public BC_PopupTextBox
584 CWindowMaskPresetText(CWindowMaskPresetGUI *pgui,
585 int x, int y, int w, int h, const char *text);
589 CWindowMaskPresetGUI *pgui;
590 CWindowMaskItems mask_items;
593 class CWindowMaskDelete : public BC_Button
596 CWindowMaskDelete(MWindow *mwindow, CWindowMaskGUI *gui,
597 int x, int y, int w);
604 class CWindowMaskCenter : public BC_Button
607 CWindowMaskCenter(MWindow *mwindow, CWindowMaskGUI *gui,
608 int x, int y, int w);
615 class CWindowMaskNormal : public BC_Button
618 CWindowMaskNormal(MWindow *mwindow, CWindowMaskGUI *gui,
619 int x, int y, int w);
626 class CWindowMaskShape : public BC_Button
629 CWindowMaskShape(MWindow *mwindow, CWindowMaskGUI *gui,
630 const char *images, int shape, int x, int y, const char *tip);
632 void builtin_shape(int i, SubMask *sub_mask);
638 CWindowMaskItems shape_items;
641 class CWindowDisableOpenGLMasking : public BC_CheckBox
644 CWindowDisableOpenGLMasking(CWindowMaskGUI *gui,
650 class CWindowMaskGUI : public CWindowToolGUI
653 CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread);
655 void create_objects();
660 void set_focused(int v, float cx, float cy);
661 void update_buttons(MaskAuto *keyframe, int k);
662 void get_keyframe(Track* &track, MaskAutos* &autos, MaskAuto* &keyframe,
663 SubMask* &mask, MaskPoint* &point, int create_it);
664 void load_masks(ArrayList<SubMask *> &masks);
665 void save_masks(ArrayList<SubMask *> &masks);
666 int smooth_mask(int typ, int on);
667 int save_mask(const char *nm);
668 int del_mask(const char *nm);
672 CWindowMaskOnTrack *mask_on_track;
673 CWindowMaskTrackTumbler *mask_track_tumbler;
674 CWindowMaskName *mask_name;
675 CWindowMaskButton *mask_buttons[SUBMASKS];
676 CWindowMaskThumbler *mask_thumbler;
677 BC_Title *mask_blabels[SUBMASKS];
678 CWindowMaskEnable *mask_enables[SUBMASKS];
679 CWindowMaskSoloTrack *mask_solo_track;
680 CWindowMaskDelMask *mask_del;
681 CWindowMaskUnclear *mask_unclr;
682 CWindowMaskClrMask *mask_clr;
683 CWindowMaskShape *mask_shape_sqr;
684 CWindowMaskShape *mask_shape_crc;
685 CWindowMaskShape *mask_shape_tri;
686 CWindowMaskShape *mask_shape_ovl;
687 CWindowMaskLoadList *mask_load_list;
688 CWindowMaskLoad *mask_load;
689 CWindowMaskSave *mask_save;
690 CWindowMaskDelete *mask_delete;
691 CWindowMaskPresetDialog *preset_dialog;
692 CWindowMaskCenter *mask_center;
693 CWindowMaskNormal *mask_normal;
694 CWindowMaskFade *fade;
695 CWindowMaskFadeSlider *fade_slider;
696 CWindowMaskGangFader *gang_fader;
697 CWindowMaskAffectedPoint *active_point;
698 CWindowMaskDelPoint *del_point;
699 CWindowMaskGangPoint *gang_point;
700 CWindowMaskSmoothButton *mask_pnt_linear, *mask_pnt_smooth;
701 CWindowMaskSmoothButton *mask_crv_linear, *mask_crv_smooth;
702 CWindowMaskSmoothButton *mask_all_linear, *mask_all_smooth;
704 CWindowMaskScaleXY *mask_scale_x, *mask_scale_y, *mask_scale_xy;
706 CWindowMaskFocus *focus;
708 CWindowMaskGangFocus *gang_focus;
709 CWindowMaskHelp *help;
710 int helped, help_y, help_h;
711 CWindowMaskDrawMarkers *draw_markers;
713 CWindowMaskDrawBoundary *draw_boundary;
715 CWindowCoord *focus_x, *focus_y;
716 CWindowMaskFeather *feather;
717 CWindowMaskFeatherSlider *feather_slider;
718 CWindowMaskGangFeather *gang_feather;
719 CWindowMaskBeforePlugins *apply_before_plugins;
720 CWindowDisableOpenGLMasking *disable_opengl_masking;
724 class CWindowEyedropGUI : public CWindowToolGUI
727 CWindowEyedropGUI(MWindow *mwindow, CWindowTool *thread);
728 ~CWindowEyedropGUI();
731 void create_objects();
735 CWindowCoord *radius;
736 CWindowEyedropCheckBox *use_max;
737 BC_Title *red, *green, *blue, *y, *u, *v;
738 BC_Title *rgb_hex, *yuv_hex;
739 BC_SubWindow *sample;
743 class CWindowEyedropCheckBox : public BC_CheckBox
746 CWindowEyedropCheckBox(MWindow *mwindow,
747 CWindowEyedropGUI *gui,
753 CWindowEyedropGUI *gui;
758 class CWindowCameraGUI : public CWindowToolGUI
761 CWindowCameraGUI(MWindow *mwindow, CWindowTool *thread);
763 void create_objects();
766 // Update the keyframe from text boxes
768 // BezierAuto* get_keyframe();
769 CWindowCoord *x, *y, *z;
771 // Toggles for keyframe curve mode (for camera automation only)
772 CWindowCurveToggle *t_smooth, *t_linear;
775 class CWindowCameraLeft : public BC_Button
778 CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui,
782 CWindowCameraGUI *gui;
785 class CWindowCameraCenter : public BC_Button
788 CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui,
792 CWindowCameraGUI *gui;
795 class CWindowCameraRight : public BC_Button
798 CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui,
802 CWindowCameraGUI *gui;
805 class CWindowCameraTop : public BC_Button
808 CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui,
812 CWindowCameraGUI *gui;
815 class CWindowCameraMiddle : public BC_Button
818 CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui,
822 CWindowCameraGUI *gui;
825 class CWindowCameraBottom : public BC_Button
828 CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui,
832 CWindowCameraGUI *gui;
835 class CWindowProjectorGUI : public CWindowToolGUI
838 CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread);
839 ~CWindowProjectorGUI();
840 void create_objects();
843 // BezierAuto* get_keyframe();
844 CWindowCoord *x, *y, *z;
846 // Toggles for keyframe curve mode (projector automation only)
847 CWindowCurveToggle *t_smooth, *t_linear;
850 class CWindowProjectorLeft : public BC_Button
853 CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui,
857 CWindowProjectorGUI *gui;
860 class CWindowProjectorCenter : public BC_Button
863 CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui,
867 CWindowProjectorGUI *gui;
870 class CWindowProjectorRight : public BC_Button
873 CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui,
877 CWindowProjectorGUI *gui;
880 class CWindowProjectorTop : public BC_Button
883 CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui,
887 CWindowProjectorGUI *gui;
890 class CWindowProjectorMiddle : public BC_Button
893 CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui,
897 CWindowProjectorGUI *gui;
900 class CWindowProjectorBottom : public BC_Button
903 CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui,
907 CWindowProjectorGUI *gui;
913 class CWindowRulerGUI : public CWindowToolGUI
916 CWindowRulerGUI(MWindow *mwindow, CWindowTool *thread);
918 void create_objects();
927 BC_TextBox *distance;