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 int update(int r, float v, float mn, float mx);
460 char *get_caption() { return 0; }
469 class CWindowMaskGangFeather : public BC_Toggle
472 CWindowMaskGangFeather(MWindow *mwindow, CWindowMaskGUI *gui,
474 ~CWindowMaskGangFeather();
480 class CWindowMaskBeforePlugins : public BC_CheckBox
483 CWindowMaskBeforePlugins(CWindowMaskGUI *gui,
489 class CWindowMaskLoadList : public BC_ListBox
492 CWindowMaskLoadList(MWindow *mwindow, CWindowMaskGUI *gui);
493 ~CWindowMaskLoadList();
494 void create_objects();
499 CWindowMaskItems shape_items;
502 class CWindowMaskLoad : public BC_Button
505 CWindowMaskLoad(MWindow *mwindow, CWindowMaskGUI *gui,
506 int x, int y, int w);
513 class CWindowMaskSave : public BC_Button
516 CWindowMaskSave(MWindow *mwindow, CWindowMaskGUI *gui,
517 int x, int y, int w);
523 CWindowMaskPresetDialog *preset_dialog;
526 class CWindowMaskPresetDialog : public BC_DialogThread
529 CWindowMaskPresetDialog(MWindow *mwindow, CWindowMaskGUI *gui);
530 ~CWindowMaskPresetDialog();
531 void handle_close_event(int result);
532 void handle_done_event(int result);
533 BC_Window* new_gui();
534 void start_dialog(int sx, int sy, MaskAuto *keyframe);
538 CWindowMaskPresetGUI *pgui;
543 class CWindowMaskPresetGUI : public BC_Window
546 CWindowMaskPresetGUI(CWindowMaskPresetDialog *preset_dialog,
547 int x, int y, const char *title);
548 void create_objects();
550 CWindowMaskPresetDialog *preset_dialog;
551 CWindowMaskPresetText *preset_text;
554 class CWindowMaskPresetText : public BC_PopupTextBox
557 CWindowMaskPresetText(CWindowMaskPresetGUI *pgui,
558 int x, int y, int w, int h, const char *text);
562 CWindowMaskPresetGUI *pgui;
563 CWindowMaskItems mask_items;
566 class CWindowMaskDelete : public BC_Button
569 CWindowMaskDelete(MWindow *mwindow, CWindowMaskGUI *gui,
570 int x, int y, int w);
577 class CWindowMaskCenter : public BC_Button
580 CWindowMaskCenter(MWindow *mwindow, CWindowMaskGUI *gui,
581 int x, int y, int w);
588 class CWindowMaskNormal : public BC_Button
591 CWindowMaskNormal(MWindow *mwindow, CWindowMaskGUI *gui,
592 int x, int y, int w);
599 class CWindowMaskShape : public BC_Button
602 CWindowMaskShape(MWindow *mwindow, CWindowMaskGUI *gui,
603 const char *images, int shape, int x, int y, const char *tip);
605 void builtin_shape(int i, SubMask *sub_mask);
611 CWindowMaskItems shape_items;
614 class CWindowDisableOpenGLMasking : public BC_CheckBox
617 CWindowDisableOpenGLMasking(CWindowMaskGUI *gui,
623 class CWindowMaskGUI : public CWindowToolGUI
626 CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread);
628 void create_objects();
633 void set_focused(int v, float cx, float cy);
634 void update_buttons(MaskAuto *keyframe, int k);
635 void get_keyframe(Track* &track, MaskAutos* &autos, MaskAuto* &keyframe,
636 SubMask* &mask, MaskPoint* &point, int create_it);
637 void load_masks(ArrayList<SubMask *> &masks);
638 void save_masks(ArrayList<SubMask *> &masks);
639 int smooth_mask(int typ, int on);
640 int save_mask(const char *nm);
641 int del_mask(const char *nm);
645 CWindowMaskOnTrack *mask_on_track;
646 CWindowMaskTrackTumbler *mask_track_tumbler;
647 CWindowMaskName *mask_name;
648 CWindowMaskButton *mask_buttons[SUBMASKS];
649 CWindowMaskThumbler *mask_thumbler;
650 BC_Title *mask_blabels[SUBMASKS];
651 CWindowMaskEnable *mask_enables[SUBMASKS];
652 CWindowMaskSoloTrack *mask_solo_track;
653 CWindowMaskDelMask *mask_del;
654 CWindowMaskUnclear *mask_unclr;
655 CWindowMaskClrMask *mask_clr;
656 CWindowMaskShape *mask_shape_sqr;
657 CWindowMaskShape *mask_shape_crc;
658 CWindowMaskShape *mask_shape_tri;
659 CWindowMaskShape *mask_shape_ovl;
660 CWindowMaskLoadList *mask_load_list;
661 CWindowMaskLoad *mask_load;
662 CWindowMaskSave *mask_save;
663 CWindowMaskDelete *mask_delete;
664 CWindowMaskPresetDialog *preset_dialog;
665 CWindowMaskCenter *mask_center;
666 CWindowMaskNormal *mask_normal;
667 CWindowMaskFade *fade;
668 CWindowMaskFadeSlider *fade_slider;
669 CWindowMaskGangFader *gang_fader;
670 CWindowMaskAffectedPoint *active_point;
671 CWindowMaskDelPoint *del_point;
672 CWindowMaskGangPoint *gang_point;
673 CWindowMaskSmoothButton *mask_pnt_linear, *mask_pnt_smooth;
674 CWindowMaskSmoothButton *mask_crv_linear, *mask_crv_smooth;
675 CWindowMaskSmoothButton *mask_all_linear, *mask_all_smooth;
677 CWindowMaskScaleXY *mask_scale_x, *mask_scale_y, *mask_scale_xy;
679 CWindowMaskFocus *focus;
681 CWindowMaskGangFocus *gang_focus;
682 CWindowMaskHelp *help;
683 int helped, help_y, help_h;
684 CWindowMaskDrawMarkers *draw_markers;
686 CWindowMaskDrawBoundary *draw_boundary;
688 CWindowCoord *focus_x, *focus_y;
689 CWindowMaskFeather *feather;
690 CWindowMaskFeatherSlider *feather_slider;
691 CWindowMaskGangFeather *gang_feather;
692 CWindowMaskBeforePlugins *apply_before_plugins;
693 CWindowDisableOpenGLMasking *disable_opengl_masking;
697 class CWindowEyedropGUI : public CWindowToolGUI
700 CWindowEyedropGUI(MWindow *mwindow, CWindowTool *thread);
701 ~CWindowEyedropGUI();
704 void create_objects();
708 CWindowCoord *radius;
709 CWindowEyedropCheckBox *use_max;
710 BC_Title *red, *green, *blue, *y, *u, *v;
711 BC_Title *rgb_hex, *yuv_hex;
712 BC_SubWindow *sample;
716 class CWindowEyedropCheckBox : public BC_CheckBox
719 CWindowEyedropCheckBox(MWindow *mwindow,
720 CWindowEyedropGUI *gui,
726 CWindowEyedropGUI *gui;
731 class CWindowCameraGUI : public CWindowToolGUI
734 CWindowCameraGUI(MWindow *mwindow, CWindowTool *thread);
736 void create_objects();
739 // Update the keyframe from text boxes
741 // BezierAuto* get_keyframe();
742 CWindowCoord *x, *y, *z;
744 // Toggles for keyframe curve mode (for camera automation only)
745 CWindowCurveToggle *t_smooth, *t_linear;
748 class CWindowCameraLeft : public BC_Button
751 CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui,
755 CWindowCameraGUI *gui;
758 class CWindowCameraCenter : public BC_Button
761 CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui,
765 CWindowCameraGUI *gui;
768 class CWindowCameraRight : public BC_Button
771 CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui,
775 CWindowCameraGUI *gui;
778 class CWindowCameraTop : public BC_Button
781 CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui,
785 CWindowCameraGUI *gui;
788 class CWindowCameraMiddle : public BC_Button
791 CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui,
795 CWindowCameraGUI *gui;
798 class CWindowCameraBottom : public BC_Button
801 CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui,
805 CWindowCameraGUI *gui;
808 class CWindowProjectorGUI : public CWindowToolGUI
811 CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread);
812 ~CWindowProjectorGUI();
813 void create_objects();
816 // BezierAuto* get_keyframe();
817 CWindowCoord *x, *y, *z;
819 // Toggles for keyframe curve mode (projector automation only)
820 CWindowCurveToggle *t_smooth, *t_linear;
823 class CWindowProjectorLeft : public BC_Button
826 CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui,
830 CWindowProjectorGUI *gui;
833 class CWindowProjectorCenter : public BC_Button
836 CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui,
840 CWindowProjectorGUI *gui;
843 class CWindowProjectorRight : public BC_Button
846 CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui,
850 CWindowProjectorGUI *gui;
853 class CWindowProjectorTop : public BC_Button
856 CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui,
860 CWindowProjectorGUI *gui;
863 class CWindowProjectorMiddle : public BC_Button
866 CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui,
870 CWindowProjectorGUI *gui;
873 class CWindowProjectorBottom : public BC_Button
876 CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui,
880 CWindowProjectorGUI *gui;
886 class CWindowRulerGUI : public CWindowToolGUI
889 CWindowRulerGUI(MWindow *mwindow, CWindowTool *thread);
891 void create_objects();
900 BC_TextBox *distance;