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 CWindowCropOK : public BC_GenericButton
123 CWindowCropOK(MWindow *mwindow, CWindowToolGUI *gui,
125 // Perform the cropping operation
127 int keypress_event();
132 class CWindowCropGUI : public CWindowToolGUI
135 CWindowCropGUI(MWindow *mwindow, CWindowTool *thread);
137 void create_objects();
141 CWindowCoord *x1, *y1, *width, *height;
144 class CWindowMaskItem : public BC_ListBoxItem
147 CWindowMaskItem(const char *text, int id=-1, int color=-1)
148 : BC_ListBoxItem(text, color), id(id) {}
149 ~CWindowMaskItem() {}
153 class CWindowMaskItems : public ArrayList<BC_ListBoxItem*>
156 CWindowMaskItems() {}
157 ~CWindowMaskItems() { remove_all_objects(); }
160 class CWindowMaskOnTrack : public BC_PopupTextBox
163 CWindowMaskOnTrack(MWindow *mwindow, CWindowMaskGUI *gui,
164 int x, int y, int w, const char *text);
165 ~CWindowMaskOnTrack();
168 CWindowMaskItems track_items;
174 class CWindowMaskTrackTumbler : public BC_Tumbler
177 CWindowMaskTrackTumbler(MWindow *mwindow, CWindowMaskGUI *gui,
179 ~CWindowMaskTrackTumbler();
180 int handle_up_event();
181 int handle_down_event();
182 int do_event(int dir);
189 class CWindowMaskName : public BC_PopupTextBox
192 CWindowMaskName(MWindow *mwindow, CWindowMaskGUI *gui,
193 int x, int y, const char *text);
197 CWindowMaskItems mask_items;
200 void update_items(MaskAuto *keyframe);
203 class CWindowMaskUnclear : public BC_Button
206 CWindowMaskUnclear(MWindow *mwindow, CWindowMaskGUI *gui,
213 class CWindowMaskSoloTrack : public BC_CheckBox
216 CWindowMaskSoloTrack(MWindow *mwindow, CWindowMaskGUI *gui,
217 int x, int y, int v);
218 static int calculate_w(BC_WindowBase *gui);
224 class CWindowMaskDelMask : public BC_GenericButton
227 CWindowMaskDelMask(MWindow *mwindow, CWindowMaskGUI *gui,
234 class CWindowMaskClrMask : public BC_Button
237 CWindowMaskClrMask(MWindow *mwindow, CWindowMaskGUI *gui,
239 ~CWindowMaskClrMask();
240 static int calculate_w(MWindow *mwindow);
246 class CWindowMaskButton : public BC_CheckBox
249 CWindowMaskButton(MWindow *mwindow, CWindowMaskGUI *gui,
250 int x, int y, int no, int v);
251 ~CWindowMaskButton();
259 class CWindowMaskThumbler : public BC_Tumbler
262 CWindowMaskThumbler(MWindow *mwindow, CWindowMaskGUI *gui,
264 ~CWindowMaskThumbler();
265 int handle_up_event();
266 int handle_down_event();
267 int do_event(int dir);
273 class CWindowMaskEnable : public BC_CheckBox
276 CWindowMaskEnable(MWindow *mwindow, CWindowMaskGUI *gui,
277 int x, int y, int no, int v);
278 ~CWindowMaskEnable();
286 class CWindowMaskFade : public BC_TumbleTextBox
289 CWindowMaskFade(MWindow *mwindow, CWindowMaskGUI *gui,
293 int update_value(float v);
299 class CWindowMaskFadeSlider : public BC_ISlider
302 CWindowMaskFadeSlider(MWindow *mwindow, CWindowMaskGUI *gui,
303 int x, int y, int w);
304 ~CWindowMaskFadeSlider();
306 int update(int64_t v);
307 char *get_caption() { return 0; }
315 class CWindowMaskGangFader : public BC_Toggle
318 CWindowMaskGangFader(MWindow *mwindow, CWindowMaskGUI *gui,
320 ~CWindowMaskGangFader();
326 class CWindowMaskGangFocus : public BC_Toggle
329 CWindowMaskGangFocus(MWindow *mwindow, CWindowMaskGUI *gui,
331 ~CWindowMaskGangFocus();
337 class CWindowMaskGangPoint : public BC_Toggle
340 CWindowMaskGangPoint(MWindow *mwindow, CWindowMaskGUI *gui,
342 ~CWindowMaskGangPoint();
348 class CWindowMaskSmoothButton : public BC_Button
351 CWindowMaskSmoothButton(MWindow *mwindow, CWindowMaskGUI *gui,
352 const char *tip, int type, int on, int x, int y, const char *images);
359 class CWindowMaskAffectedPoint : public BC_TumbleTextBox
362 CWindowMaskAffectedPoint(MWindow *mwindow, CWindowMaskGUI *gui,
364 ~CWindowMaskAffectedPoint();
370 class CWindowMaskFocus : public BC_CheckBox
373 CWindowMaskFocus(MWindow *mwindow, CWindowMaskGUI *gui,
379 static int calculate_w(CWindowMaskGUI *gui);
382 class CWindowMaskScaleXY : public BC_Toggle
385 CWindowMaskScaleXY(MWindow *mwindow, CWindowMaskGUI *gui,
386 int x, int y, VFrame **data, int v,
387 int id, const char *tip);
388 ~CWindowMaskScaleXY();
395 class CWindowMaskHelp : public BC_CheckBox
398 CWindowMaskHelp(MWindow *mwindow, CWindowMaskGUI *gui,
406 class CWindowMaskDrawMarkers : public BC_CheckBox
409 CWindowMaskDrawMarkers(MWindow *mwindow, CWindowMaskGUI *gui,
411 ~CWindowMaskDrawMarkers();
417 class CWindowMaskDrawBoundary : public BC_CheckBox
420 CWindowMaskDrawBoundary(MWindow *mwindow, CWindowMaskGUI *gui,
422 ~CWindowMaskDrawBoundary();
428 class CWindowMaskDelPoint : public BC_GenericButton
431 CWindowMaskDelPoint(MWindow *mwindow, CWindowMaskGUI *gui,
438 class CWindowMaskFeather : public BC_TumbleTextBox
441 CWindowMaskFeather(MWindow *mwindow, CWindowMaskGUI *gui,
443 ~CWindowMaskFeather();
445 int update_value(float v);
451 class CWindowMaskFeatherSlider : public BC_FSlider
454 CWindowMaskFeatherSlider(MWindow *mwindow, CWindowMaskGUI *gui,
455 int x, int y, int w, float v);
456 ~CWindowMaskFeatherSlider();
459 char *get_caption() { return 0; }
467 class CWindowMaskGangFeather : public BC_Toggle
470 CWindowMaskGangFeather(MWindow *mwindow, CWindowMaskGUI *gui,
472 ~CWindowMaskGangFeather();
478 class CWindowMaskBeforePlugins : public BC_CheckBox
481 CWindowMaskBeforePlugins(CWindowMaskGUI *gui,
487 class CWindowMaskLoadList : public BC_ListBox
490 CWindowMaskLoadList(MWindow *mwindow, CWindowMaskGUI *gui);
491 ~CWindowMaskLoadList();
492 void create_objects();
497 CWindowMaskItems shape_items;
500 class CWindowMaskLoad : public BC_Button
503 CWindowMaskLoad(MWindow *mwindow, CWindowMaskGUI *gui,
504 int x, int y, int w);
511 class CWindowMaskSave : public BC_Button
514 CWindowMaskSave(MWindow *mwindow, CWindowMaskGUI *gui,
515 int x, int y, int w);
521 CWindowMaskPresetDialog *preset_dialog;
524 class CWindowMaskPresetDialog : public BC_DialogThread
527 CWindowMaskPresetDialog(MWindow *mwindow, CWindowMaskGUI *gui);
528 ~CWindowMaskPresetDialog();
529 void handle_close_event(int result);
530 void handle_done_event(int result);
531 BC_Window* new_gui();
532 void start_dialog(int sx, int sy, MaskAuto *keyframe);
536 CWindowMaskPresetGUI *pgui;
541 class CWindowMaskPresetGUI : public BC_Window
544 CWindowMaskPresetGUI(CWindowMaskPresetDialog *preset_dialog,
545 int x, int y, const char *title);
546 void create_objects();
548 CWindowMaskPresetDialog *preset_dialog;
549 CWindowMaskPresetText *preset_text;
552 class CWindowMaskPresetText : public BC_PopupTextBox
555 CWindowMaskPresetText(CWindowMaskPresetGUI *pgui,
556 int x, int y, int w, int h, const char *text);
560 CWindowMaskPresetGUI *pgui;
561 CWindowMaskItems mask_items;
564 class CWindowMaskDelete : public BC_Button
567 CWindowMaskDelete(MWindow *mwindow, CWindowMaskGUI *gui,
568 int x, int y, int w);
575 class CWindowMaskCenter : public BC_Button
578 CWindowMaskCenter(MWindow *mwindow, CWindowMaskGUI *gui,
579 int x, int y, int w);
586 class CWindowMaskNormal : public BC_Button
589 CWindowMaskNormal(MWindow *mwindow, CWindowMaskGUI *gui,
590 int x, int y, int w);
597 class CWindowMaskShape : public BC_Button
600 CWindowMaskShape(MWindow *mwindow, CWindowMaskGUI *gui,
601 const char *images, int shape, int x, int y, const char *tip);
603 void builtin_shape(int i, SubMask *sub_mask);
609 CWindowMaskItems shape_items;
612 class CWindowDisableOpenGLMasking : public BC_CheckBox
615 CWindowDisableOpenGLMasking(CWindowMaskGUI *gui,
621 class CWindowMaskGUI : public CWindowToolGUI
624 CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread);
626 void create_objects();
631 void set_focused(int v, float cx, float cy);
632 void update_buttons(MaskAuto *keyframe, int k);
633 void get_keyframe(Track* &track, MaskAutos* &autos, MaskAuto* &keyframe,
634 SubMask* &mask, MaskPoint* &point, int create_it);
635 void load_masks(ArrayList<SubMask *> &masks);
636 void save_masks(ArrayList<SubMask *> &masks);
637 int smooth_mask(int typ, int on);
638 int save_mask(const char *nm);
639 int del_mask(const char *nm);
643 CWindowMaskOnTrack *mask_on_track;
644 CWindowMaskTrackTumbler *mask_track_tumbler;
645 CWindowMaskName *mask_name;
646 CWindowMaskButton *mask_buttons[SUBMASKS];
647 CWindowMaskThumbler *mask_thumbler;
648 BC_Title *mask_blabels[SUBMASKS];
649 CWindowMaskEnable *mask_enables[SUBMASKS];
650 CWindowMaskSoloTrack *mask_solo_track;
651 CWindowMaskDelMask *mask_del;
652 CWindowMaskUnclear *mask_unclr;
653 CWindowMaskClrMask *mask_clr;
654 CWindowMaskShape *mask_shape_sqr;
655 CWindowMaskShape *mask_shape_crc;
656 CWindowMaskShape *mask_shape_tri;
657 CWindowMaskShape *mask_shape_ovl;
658 CWindowMaskLoadList *mask_load_list;
659 CWindowMaskLoad *mask_load;
660 CWindowMaskSave *mask_save;
661 CWindowMaskDelete *mask_delete;
662 CWindowMaskPresetDialog *preset_dialog;
663 CWindowMaskCenter *mask_center;
664 CWindowMaskNormal *mask_normal;
665 CWindowMaskFade *fade;
666 CWindowMaskFadeSlider *fade_slider;
667 CWindowMaskGangFader *gang_fader;
668 CWindowMaskAffectedPoint *active_point;
669 CWindowMaskDelPoint *del_point;
670 CWindowMaskGangPoint *gang_point;
671 CWindowMaskSmoothButton *mask_pnt_linear, *mask_pnt_smooth;
672 CWindowMaskSmoothButton *mask_crv_linear, *mask_crv_smooth;
673 CWindowMaskSmoothButton *mask_all_linear, *mask_all_smooth;
675 CWindowMaskScaleXY *mask_scale_x, *mask_scale_y, *mask_scale_xy;
677 CWindowMaskFocus *focus;
679 CWindowMaskGangFocus *gang_focus;
680 CWindowMaskHelp *help;
681 int helped, help_y, help_h;
682 CWindowMaskDrawMarkers *draw_markers;
684 CWindowMaskDrawBoundary *draw_boundary;
686 CWindowCoord *focus_x, *focus_y;
687 CWindowMaskFeather *feather;
688 CWindowMaskFeatherSlider *feather_slider;
689 CWindowMaskGangFeather *gang_feather;
690 CWindowMaskBeforePlugins *apply_before_plugins;
691 CWindowDisableOpenGLMasking *disable_opengl_masking;
695 class CWindowEyedropGUI : public CWindowToolGUI
698 CWindowEyedropGUI(MWindow *mwindow, CWindowTool *thread);
699 ~CWindowEyedropGUI();
702 void create_objects();
706 CWindowCoord *radius;
707 CWindowEyedropCheckBox *use_max;
708 BC_Title *red, *green, *blue, *y, *u, *v;
709 BC_Title *rgb_hex, *yuv_hex;
710 BC_SubWindow *sample;
714 class CWindowEyedropCheckBox : public BC_CheckBox
717 CWindowEyedropCheckBox(MWindow *mwindow,
718 CWindowEyedropGUI *gui,
724 CWindowEyedropGUI *gui;
729 class CWindowCameraGUI : public CWindowToolGUI
732 CWindowCameraGUI(MWindow *mwindow, CWindowTool *thread);
734 void create_objects();
737 // Update the keyframe from text boxes
739 // BezierAuto* get_keyframe();
740 CWindowCoord *x, *y, *z;
742 // Toggles for keyframe curve mode (for camera automation only)
743 CWindowCurveToggle *t_smooth, *t_linear;
746 class CWindowCameraLeft : public BC_Button
749 CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui,
753 CWindowCameraGUI *gui;
756 class CWindowCameraCenter : public BC_Button
759 CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui,
763 CWindowCameraGUI *gui;
766 class CWindowCameraRight : public BC_Button
769 CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui,
773 CWindowCameraGUI *gui;
776 class CWindowCameraTop : public BC_Button
779 CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui,
783 CWindowCameraGUI *gui;
786 class CWindowCameraMiddle : public BC_Button
789 CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui,
793 CWindowCameraGUI *gui;
796 class CWindowCameraBottom : public BC_Button
799 CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui,
803 CWindowCameraGUI *gui;
806 class CWindowProjectorGUI : public CWindowToolGUI
809 CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread);
810 ~CWindowProjectorGUI();
811 void create_objects();
814 // BezierAuto* get_keyframe();
815 CWindowCoord *x, *y, *z;
817 // Toggles for keyframe curve mode (projector automation only)
818 CWindowCurveToggle *t_smooth, *t_linear;
821 class CWindowProjectorLeft : public BC_Button
824 CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui,
828 CWindowProjectorGUI *gui;
831 class CWindowProjectorCenter : public BC_Button
834 CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui,
838 CWindowProjectorGUI *gui;
841 class CWindowProjectorRight : public BC_Button
844 CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui,
848 CWindowProjectorGUI *gui;
851 class CWindowProjectorTop : public BC_Button
854 CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui,
858 CWindowProjectorGUI *gui;
861 class CWindowProjectorMiddle : public BC_Button
864 CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui,
868 CWindowProjectorGUI *gui;
871 class CWindowProjectorBottom : public BC_Button
874 CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui,
878 CWindowProjectorGUI *gui;
884 class CWindowRulerGUI : public CWindowToolGUI
887 CWindowRulerGUI(MWindow *mwindow, CWindowTool *thread);
889 void create_objects();
898 BC_TextBox *distance;