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,
434 int keypress_event();
439 class CWindowMaskFeather : public BC_TumbleTextBox
442 CWindowMaskFeather(MWindow *mwindow, CWindowMaskGUI *gui,
444 ~CWindowMaskFeather();
446 int update_value(float v);
452 class CWindowMaskFeatherSlider : public BC_FSlider
455 CWindowMaskFeatherSlider(MWindow *mwindow, CWindowMaskGUI *gui,
456 int x, int y, int w, float v);
457 ~CWindowMaskFeatherSlider();
460 char *get_caption() { return 0; }
468 class CWindowMaskGangFeather : public BC_Toggle
471 CWindowMaskGangFeather(MWindow *mwindow, CWindowMaskGUI *gui,
473 ~CWindowMaskGangFeather();
479 class CWindowMaskBeforePlugins : public BC_CheckBox
482 CWindowMaskBeforePlugins(CWindowMaskGUI *gui,
488 class CWindowMaskLoadList : public BC_ListBox
491 CWindowMaskLoadList(MWindow *mwindow, CWindowMaskGUI *gui);
492 ~CWindowMaskLoadList();
493 void create_objects();
498 CWindowMaskItems shape_items;
501 class CWindowMaskLoad : public BC_Button
504 CWindowMaskLoad(MWindow *mwindow, CWindowMaskGUI *gui,
505 int x, int y, int w);
512 class CWindowMaskSave : public BC_Button
515 CWindowMaskSave(MWindow *mwindow, CWindowMaskGUI *gui,
516 int x, int y, int w);
522 CWindowMaskPresetDialog *preset_dialog;
525 class CWindowMaskPresetDialog : public BC_DialogThread
528 CWindowMaskPresetDialog(MWindow *mwindow, CWindowMaskGUI *gui);
529 ~CWindowMaskPresetDialog();
530 void handle_close_event(int result);
531 void handle_done_event(int result);
532 BC_Window* new_gui();
533 void start_dialog(int sx, int sy, MaskAuto *keyframe);
537 CWindowMaskPresetGUI *pgui;
542 class CWindowMaskPresetGUI : public BC_Window
545 CWindowMaskPresetGUI(CWindowMaskPresetDialog *preset_dialog,
546 int x, int y, const char *title);
547 void create_objects();
549 CWindowMaskPresetDialog *preset_dialog;
550 CWindowMaskPresetText *preset_text;
553 class CWindowMaskPresetText : public BC_PopupTextBox
556 CWindowMaskPresetText(CWindowMaskPresetGUI *pgui,
557 int x, int y, int w, int h, const char *text);
561 CWindowMaskPresetGUI *pgui;
562 CWindowMaskItems mask_items;
565 class CWindowMaskDelete : public BC_Button
568 CWindowMaskDelete(MWindow *mwindow, CWindowMaskGUI *gui,
569 int x, int y, int w);
576 class CWindowMaskCenter : public BC_Button
579 CWindowMaskCenter(MWindow *mwindow, CWindowMaskGUI *gui,
580 int x, int y, int w);
587 class CWindowMaskNormal : public BC_Button
590 CWindowMaskNormal(MWindow *mwindow, CWindowMaskGUI *gui,
591 int x, int y, int w);
598 class CWindowMaskShape : public BC_Button
601 CWindowMaskShape(MWindow *mwindow, CWindowMaskGUI *gui,
602 const char *images, int shape, int x, int y, const char *tip);
604 void builtin_shape(int i, SubMask *sub_mask);
610 CWindowMaskItems shape_items;
613 class CWindowDisableOpenGLMasking : public BC_CheckBox
616 CWindowDisableOpenGLMasking(CWindowMaskGUI *gui,
622 class CWindowMaskGUI : public CWindowToolGUI
625 CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread);
627 void create_objects();
632 void set_focused(int v, float cx, float cy);
633 void update_buttons(MaskAuto *keyframe, int k);
634 void get_keyframe(Track* &track, MaskAutos* &autos, MaskAuto* &keyframe,
635 SubMask* &mask, MaskPoint* &point, int create_it);
636 void load_masks(ArrayList<SubMask *> &masks);
637 void save_masks(ArrayList<SubMask *> &masks);
638 int smooth_mask(int typ, int on);
639 int save_mask(const char *nm);
640 int del_mask(const char *nm);
644 CWindowMaskOnTrack *mask_on_track;
645 CWindowMaskTrackTumbler *mask_track_tumbler;
646 CWindowMaskName *mask_name;
647 CWindowMaskButton *mask_buttons[SUBMASKS];
648 CWindowMaskThumbler *mask_thumbler;
649 BC_Title *mask_blabels[SUBMASKS];
650 CWindowMaskEnable *mask_enables[SUBMASKS];
651 CWindowMaskSoloTrack *mask_solo_track;
652 CWindowMaskDelMask *mask_del;
653 CWindowMaskUnclear *mask_unclr;
654 CWindowMaskClrMask *mask_clr;
655 CWindowMaskShape *mask_shape_sqr;
656 CWindowMaskShape *mask_shape_crc;
657 CWindowMaskShape *mask_shape_tri;
658 CWindowMaskShape *mask_shape_ovl;
659 CWindowMaskLoadList *mask_load_list;
660 CWindowMaskLoad *mask_load;
661 CWindowMaskSave *mask_save;
662 CWindowMaskDelete *mask_delete;
663 CWindowMaskPresetDialog *preset_dialog;
664 CWindowMaskCenter *mask_center;
665 CWindowMaskNormal *mask_normal;
666 CWindowMaskFade *fade;
667 CWindowMaskFadeSlider *fade_slider;
668 CWindowMaskGangFader *gang_fader;
669 CWindowMaskAffectedPoint *active_point;
670 CWindowMaskDelPoint *del_point;
671 CWindowMaskGangPoint *gang_point;
672 CWindowMaskSmoothButton *mask_pnt_linear, *mask_pnt_smooth;
673 CWindowMaskSmoothButton *mask_crv_linear, *mask_crv_smooth;
674 CWindowMaskSmoothButton *mask_all_linear, *mask_all_smooth;
676 CWindowMaskScaleXY *mask_scale_x, *mask_scale_y, *mask_scale_xy;
678 CWindowMaskFocus *focus;
680 CWindowMaskGangFocus *gang_focus;
681 CWindowMaskHelp *help;
682 int helped, help_y, help_h;
683 CWindowMaskDrawMarkers *draw_markers;
685 CWindowMaskDrawBoundary *draw_boundary;
687 CWindowCoord *focus_x, *focus_y;
688 CWindowMaskFeather *feather;
689 CWindowMaskFeatherSlider *feather_slider;
690 CWindowMaskGangFeather *gang_feather;
691 CWindowMaskBeforePlugins *apply_before_plugins;
692 CWindowDisableOpenGLMasking *disable_opengl_masking;
696 class CWindowEyedropGUI : public CWindowToolGUI
699 CWindowEyedropGUI(MWindow *mwindow, CWindowTool *thread);
700 ~CWindowEyedropGUI();
703 void create_objects();
707 CWindowCoord *radius;
708 CWindowEyedropCheckBox *use_max;
709 BC_Title *red, *green, *blue, *y, *u, *v;
710 BC_Title *rgb_hex, *yuv_hex;
711 BC_SubWindow *sample;
715 class CWindowEyedropCheckBox : public BC_CheckBox
718 CWindowEyedropCheckBox(MWindow *mwindow,
719 CWindowEyedropGUI *gui,
725 CWindowEyedropGUI *gui;
730 class CWindowCameraGUI : public CWindowToolGUI
733 CWindowCameraGUI(MWindow *mwindow, CWindowTool *thread);
735 void create_objects();
738 // Update the keyframe from text boxes
740 // BezierAuto* get_keyframe();
741 CWindowCoord *x, *y, *z;
743 // Toggles for keyframe curve mode (for camera automation only)
744 CWindowCurveToggle *t_smooth, *t_linear;
747 class CWindowCameraLeft : public BC_Button
750 CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui,
754 CWindowCameraGUI *gui;
757 class CWindowCameraCenter : public BC_Button
760 CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui,
764 CWindowCameraGUI *gui;
767 class CWindowCameraRight : public BC_Button
770 CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui,
774 CWindowCameraGUI *gui;
777 class CWindowCameraTop : public BC_Button
780 CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui,
784 CWindowCameraGUI *gui;
787 class CWindowCameraMiddle : public BC_Button
790 CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui,
794 CWindowCameraGUI *gui;
797 class CWindowCameraBottom : public BC_Button
800 CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui,
804 CWindowCameraGUI *gui;
807 class CWindowProjectorGUI : public CWindowToolGUI
810 CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread);
811 ~CWindowProjectorGUI();
812 void create_objects();
815 // BezierAuto* get_keyframe();
816 CWindowCoord *x, *y, *z;
818 // Toggles for keyframe curve mode (projector automation only)
819 CWindowCurveToggle *t_smooth, *t_linear;
822 class CWindowProjectorLeft : public BC_Button
825 CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui,
829 CWindowProjectorGUI *gui;
832 class CWindowProjectorCenter : public BC_Button
835 CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui,
839 CWindowProjectorGUI *gui;
842 class CWindowProjectorRight : public BC_Button
845 CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui,
849 CWindowProjectorGUI *gui;
852 class CWindowProjectorTop : public BC_Button
855 CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui,
859 CWindowProjectorGUI *gui;
862 class CWindowProjectorMiddle : public BC_Button
865 CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui,
869 CWindowProjectorGUI *gui;
872 class CWindowProjectorBottom : public BC_Button
875 CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui,
879 CWindowProjectorGUI *gui;
885 class CWindowRulerGUI : public CWindowToolGUI
888 CWindowRulerGUI(MWindow *mwindow, CWindowTool *thread);
890 void create_objects();
899 BC_TextBox *distance;