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() {};
94 // Update EDL and preview only
95 void update_preview(int changed_edl=0);
96 void draw_preview(int changed_edl);
97 int current_operation;
98 virtual int close_event();
100 int translation_event();
101 int press(void (CWindowCanvas::*fn)());
105 CWindowCoord *event_caller;
108 class CWindowCoord : public BC_TumbleTextBox
111 CWindowCoord(CWindowToolGUI *gui, int x, int y, float value, int group=-1);
112 CWindowCoord(CWindowToolGUI *gui, int x, int y, int value, int group=-1);
113 void create_objects();
114 void update_gui(float value);
115 // Calls the window's handle_event
119 CWindowCoordSlider *slider;
120 CWindowCoordRange *range;
124 class CWindowCoordSlider : public BC_FSlider
127 CWindowCoordSlider(CWindowCoord *coord, int x, int y, int w,
128 float mn, float mx, float value);
129 ~CWindowCoordSlider();
135 class CWindowCoordRange : public BC_Tumbler
138 CWindowCoordRange(CWindowCoord *coord, int x, int y);
139 ~CWindowCoordRange();
140 int update(float scale);
141 int handle_up_event();
142 int handle_down_event();
148 class CWindowCropApply : public BC_GenericButton
151 CWindowCropApply(MWindow *mwindow, CWindowCropGUI *crop_gui,
153 // Perform the cropping operation
155 int keypress_event();
157 CWindowCropGUI *crop_gui;
160 class CWindowCropOpMode : public BC_PopupMenu
162 static const char *crop_ops[CROP_MODES];
164 CWindowCropOpMode(MWindow *mwindow, CWindowCropGUI *crop_gui,
165 int mode, int x, int y);
166 ~CWindowCropOpMode();
167 void create_objects();
171 CWindowCropGUI *crop_gui;
175 class CWindowCropOpItem : public BC_MenuItem
178 CWindowCropOpItem(CWindowCropOpMode *popup, const char *text, int id);
181 CWindowCropOpMode *popup;
186 class CWindowCropGUI : public CWindowToolGUI
189 CWindowCropGUI(MWindow *mwindow, CWindowTool *thread);
191 void create_objects();
195 CWindowCoord *x1, *y1, *width, *height;
196 CWindowCropOpMode *crop_mode;
199 class CWindowMaskItem : public BC_ListBoxItem
202 CWindowMaskItem(const char *text, int id=-1, int color=-1)
203 : BC_ListBoxItem(text, color), id(id) {}
204 ~CWindowMaskItem() {}
208 class CWindowMaskItems : public ArrayList<BC_ListBoxItem*>
211 CWindowMaskItems() {}
212 ~CWindowMaskItems() { remove_all_objects(); }
215 class CWindowMaskOnTrack : public BC_PopupTextBox
218 CWindowMaskOnTrack(MWindow *mwindow, CWindowMaskGUI *gui,
219 int x, int y, int w, const char *text);
220 ~CWindowMaskOnTrack();
223 CWindowMaskItems track_items;
229 class CWindowMaskTrackTumbler : public BC_Tumbler
232 CWindowMaskTrackTumbler(MWindow *mwindow, CWindowMaskGUI *gui,
234 ~CWindowMaskTrackTumbler();
235 int handle_up_event();
236 int handle_down_event();
237 int do_event(int dir);
244 class CWindowMaskName : public BC_PopupTextBox
247 CWindowMaskName(MWindow *mwindow, CWindowMaskGUI *gui,
248 int x, int y, const char *text);
252 CWindowMaskItems mask_items;
255 void update_items(MaskAuto *keyframe);
258 class CWindowMaskUnclear : public BC_Button
261 CWindowMaskUnclear(MWindow *mwindow, CWindowMaskGUI *gui,
268 class CWindowMaskSoloTrack : public BC_CheckBox
271 CWindowMaskSoloTrack(MWindow *mwindow, CWindowMaskGUI *gui,
272 int x, int y, int v);
273 static int calculate_w(BC_WindowBase *gui);
279 class CWindowMaskDelMask : public BC_GenericButton
282 CWindowMaskDelMask(MWindow *mwindow, CWindowMaskGUI *gui,
289 class CWindowMaskClrMask : public BC_Button
292 CWindowMaskClrMask(MWindow *mwindow, CWindowMaskGUI *gui,
294 ~CWindowMaskClrMask();
295 static int calculate_w(MWindow *mwindow);
301 class CWindowMaskButton : public BC_CheckBox
304 CWindowMaskButton(MWindow *mwindow, CWindowMaskGUI *gui,
305 int x, int y, int no, int v);
306 ~CWindowMaskButton();
314 class CWindowMaskThumbler : public BC_Tumbler
317 CWindowMaskThumbler(MWindow *mwindow, CWindowMaskGUI *gui,
319 ~CWindowMaskThumbler();
320 int handle_up_event();
321 int handle_down_event();
322 int do_event(int dir);
328 class CWindowMaskEnable : public BC_CheckBox
331 CWindowMaskEnable(MWindow *mwindow, CWindowMaskGUI *gui,
332 int x, int y, int no, int v);
333 ~CWindowMaskEnable();
341 class CWindowMaskFade : public BC_TumbleTextBox
344 CWindowMaskFade(MWindow *mwindow, CWindowMaskGUI *gui,
348 int update_value(float v);
354 class CWindowMaskFadeSlider : public BC_ISlider
357 CWindowMaskFadeSlider(MWindow *mwindow, CWindowMaskGUI *gui,
358 int x, int y, int w);
359 ~CWindowMaskFadeSlider();
361 int update(int64_t v);
362 char *get_caption() { return 0; }
370 class CWindowMaskGangFader : public BC_Toggle
373 CWindowMaskGangFader(MWindow *mwindow, CWindowMaskGUI *gui,
375 ~CWindowMaskGangFader();
381 class CWindowMaskGangFocus : public BC_Toggle
384 CWindowMaskGangFocus(MWindow *mwindow, CWindowMaskGUI *gui,
386 ~CWindowMaskGangFocus();
392 class CWindowMaskGangPoint : public BC_Toggle
395 CWindowMaskGangPoint(MWindow *mwindow, CWindowMaskGUI *gui,
397 ~CWindowMaskGangPoint();
403 class CWindowMaskSmoothButton : public BC_Button
406 CWindowMaskSmoothButton(MWindow *mwindow, CWindowMaskGUI *gui,
407 const char *tip, int type, int on, int x, int y, const char *images);
414 class CWindowMaskAffectedPoint : public BC_TumbleTextBox
417 CWindowMaskAffectedPoint(MWindow *mwindow, CWindowMaskGUI *gui,
419 ~CWindowMaskAffectedPoint();
425 class CWindowMaskFocus : public BC_CheckBox
428 CWindowMaskFocus(MWindow *mwindow, CWindowMaskGUI *gui,
434 static int calculate_w(CWindowMaskGUI *gui);
437 class CWindowMaskScaleXY : public BC_Toggle
440 CWindowMaskScaleXY(MWindow *mwindow, CWindowMaskGUI *gui,
441 int x, int y, VFrame **data, int v,
442 int id, const char *tip);
443 ~CWindowMaskScaleXY();
450 class CWindowMaskHelp : public BC_CheckBox
453 CWindowMaskHelp(MWindow *mwindow, CWindowMaskGUI *gui,
461 class CWindowMaskDrawMarkers : public BC_CheckBox
464 CWindowMaskDrawMarkers(MWindow *mwindow, CWindowMaskGUI *gui,
466 ~CWindowMaskDrawMarkers();
472 class CWindowMaskDrawBoundary : public BC_CheckBox
475 CWindowMaskDrawBoundary(MWindow *mwindow, CWindowMaskGUI *gui,
477 ~CWindowMaskDrawBoundary();
483 class CWindowMaskDelPoint : public BC_GenericButton
486 CWindowMaskDelPoint(MWindow *mwindow, CWindowMaskGUI *gui,
493 class CWindowMaskFeather : public BC_TumbleTextBox
496 CWindowMaskFeather(MWindow *mwindow, CWindowMaskGUI *gui,
498 ~CWindowMaskFeather();
500 int update_value(float v);
506 class CWindowMaskFeatherSlider : public BC_FSlider
509 CWindowMaskFeatherSlider(MWindow *mwindow, CWindowMaskGUI *gui,
510 int x, int y, int w, float v);
511 ~CWindowMaskFeatherSlider();
514 int update(int r, float v, float mn, float mx);
515 char *get_caption() { return 0; }
524 class CWindowMaskGangFeather : public BC_Toggle
527 CWindowMaskGangFeather(MWindow *mwindow, CWindowMaskGUI *gui,
529 ~CWindowMaskGangFeather();
535 class CWindowMaskBeforePlugins : public BC_CheckBox
538 CWindowMaskBeforePlugins(CWindowMaskGUI *gui,
544 class CWindowMaskLoadList : public BC_ListBox
547 CWindowMaskLoadList(MWindow *mwindow, CWindowMaskGUI *gui);
548 ~CWindowMaskLoadList();
549 void create_objects();
554 CWindowMaskItems shape_items;
557 class CWindowMaskLoad : public BC_Button
560 CWindowMaskLoad(MWindow *mwindow, CWindowMaskGUI *gui,
561 int x, int y, int w);
568 class CWindowMaskSave : public BC_Button
571 CWindowMaskSave(MWindow *mwindow, CWindowMaskGUI *gui,
572 int x, int y, int w);
578 CWindowMaskPresetDialog *preset_dialog;
581 class CWindowMaskPresetDialog : public BC_DialogThread
584 CWindowMaskPresetDialog(MWindow *mwindow, CWindowMaskGUI *gui);
585 ~CWindowMaskPresetDialog();
586 void handle_close_event(int result);
587 void handle_done_event(int result);
588 BC_Window* new_gui();
589 void start_dialog(int sx, int sy, MaskAuto *keyframe);
593 CWindowMaskPresetGUI *pgui;
598 class CWindowMaskPresetGUI : public BC_Window
601 CWindowMaskPresetGUI(CWindowMaskPresetDialog *preset_dialog,
602 int x, int y, const char *title);
603 void create_objects();
605 CWindowMaskPresetDialog *preset_dialog;
606 CWindowMaskPresetText *preset_text;
609 class CWindowMaskPresetText : public BC_PopupTextBox
612 CWindowMaskPresetText(CWindowMaskPresetGUI *pgui,
613 int x, int y, int w, int h, const char *text);
617 CWindowMaskPresetGUI *pgui;
618 CWindowMaskItems mask_items;
621 class CWindowMaskDelete : public BC_Button
624 CWindowMaskDelete(MWindow *mwindow, CWindowMaskGUI *gui,
625 int x, int y, int w);
632 class CWindowMaskCenter : public BC_Button
635 CWindowMaskCenter(MWindow *mwindow, CWindowMaskGUI *gui,
636 int x, int y, int w);
643 class CWindowMaskNormal : public BC_Button
646 CWindowMaskNormal(MWindow *mwindow, CWindowMaskGUI *gui,
647 int x, int y, int w);
654 class CWindowMaskShape : public BC_Button
657 CWindowMaskShape(MWindow *mwindow, CWindowMaskGUI *gui,
658 const char *images, int shape, int x, int y, const char *tip);
660 void builtin_shape(int i, SubMask *sub_mask);
666 CWindowMaskItems shape_items;
669 class CWindowDisableOpenGLMasking : public BC_CheckBox
672 CWindowDisableOpenGLMasking(CWindowMaskGUI *gui,
678 class CWindowMaskGUI : public CWindowToolGUI
681 CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread);
683 void create_objects();
688 void set_focused(int v, float cx, float cy);
689 void update_buttons(MaskAuto *keyframe, int k);
690 void get_keyframe(Track* &track, MaskAutos* &autos, MaskAuto* &keyframe,
691 SubMask* &mask, MaskPoint* &point, int create_it);
692 void load_masks(ArrayList<SubMask *> &masks);
693 void save_masks(ArrayList<SubMask *> &masks);
694 int smooth_mask(int typ, int on);
695 int save_mask(const char *nm);
696 int del_mask(const char *nm);
700 CWindowMaskOnTrack *mask_on_track;
701 CWindowMaskTrackTumbler *mask_track_tumbler;
702 CWindowMaskName *mask_name;
703 CWindowMaskButton *mask_buttons[SUBMASKS];
704 CWindowMaskThumbler *mask_thumbler;
705 BC_Title *mask_blabels[SUBMASKS];
706 CWindowMaskEnable *mask_enables[SUBMASKS];
707 CWindowMaskSoloTrack *mask_solo_track;
708 CWindowMaskDelMask *mask_del;
709 CWindowMaskUnclear *mask_unclr;
710 CWindowMaskClrMask *mask_clr;
711 CWindowMaskShape *mask_shape_sqr;
712 CWindowMaskShape *mask_shape_crc;
713 CWindowMaskShape *mask_shape_tri;
714 CWindowMaskShape *mask_shape_ovl;
715 CWindowMaskLoadList *mask_load_list;
716 CWindowMaskLoad *mask_load;
717 CWindowMaskSave *mask_save;
718 CWindowMaskDelete *mask_delete;
719 CWindowMaskPresetDialog *preset_dialog;
720 CWindowMaskCenter *mask_center;
721 CWindowMaskNormal *mask_normal;
722 CWindowMaskFade *fade;
723 CWindowMaskFadeSlider *fade_slider;
724 CWindowMaskGangFader *gang_fader;
725 CWindowMaskAffectedPoint *active_point;
726 CWindowMaskDelPoint *del_point;
727 CWindowMaskGangPoint *gang_point;
728 CWindowMaskSmoothButton *mask_pnt_linear, *mask_pnt_smooth;
729 CWindowMaskSmoothButton *mask_crv_linear, *mask_crv_smooth;
730 CWindowMaskSmoothButton *mask_all_linear, *mask_all_smooth;
732 CWindowMaskScaleXY *mask_scale_x, *mask_scale_y, *mask_scale_xy;
734 CWindowMaskFocus *focus;
736 CWindowMaskGangFocus *gang_focus;
737 CWindowMaskHelp *help;
738 int helped, help_y, help_h;
739 CWindowMaskDrawMarkers *draw_markers;
741 CWindowMaskDrawBoundary *draw_boundary;
743 CWindowCoord *focus_x, *focus_y;
744 CWindowMaskFeather *feather;
745 CWindowMaskFeatherSlider *feather_slider;
746 CWindowMaskGangFeather *gang_feather;
747 CWindowMaskBeforePlugins *apply_before_plugins;
748 CWindowDisableOpenGLMasking *disable_opengl_masking;
752 class CWindowEyedropGUI : public CWindowToolGUI
755 CWindowEyedropGUI(MWindow *mwindow, CWindowTool *thread);
756 ~CWindowEyedropGUI();
759 void create_objects();
763 CWindowCoord *radius;
764 CWindowEyedropCheckBox *use_max;
765 BC_Title *red, *green, *blue, *y, *u, *v;
766 BC_Title *rgb_hex, *yuv_hex;
767 BC_SubWindow *sample;
771 class CWindowEyedropCheckBox : public BC_CheckBox
774 CWindowEyedropCheckBox(MWindow *mwindow,
775 CWindowEyedropGUI *gui,
781 CWindowEyedropGUI *gui;
786 class CWindowCameraGUI : public CWindowToolGUI
789 CWindowCameraGUI(MWindow *mwindow, CWindowTool *thread);
792 void create_objects();
795 CWindowCoord *x, *y, *z;
796 CWindowCameraAddKeyframe *add_keyframe;
797 CWindowCameraReset *reset;
798 CWindowCurveToggle *t_smooth, *t_linear;
801 class CWindowCameraLeft : public BC_Button
804 CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui,
808 CWindowCameraGUI *gui;
811 class CWindowCameraCenter : public BC_Button
814 CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui,
818 CWindowCameraGUI *gui;
821 class CWindowCameraRight : public BC_Button
824 CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui,
828 CWindowCameraGUI *gui;
831 class CWindowCameraTop : public BC_Button
834 CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui,
838 CWindowCameraGUI *gui;
841 class CWindowCameraMiddle : public BC_Button
844 CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui,
848 CWindowCameraGUI *gui;
851 class CWindowCameraBottom : public BC_Button
854 CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui,
858 CWindowCameraGUI *gui;
861 class CWindowCameraAddKeyframe : public BC_Button
864 CWindowCameraAddKeyframe(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
871 class CWindowCameraReset : public BC_Button
874 CWindowCameraReset(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
882 class CWindowProjectorGUI : public CWindowToolGUI
885 CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread);
886 ~CWindowProjectorGUI();
888 void create_objects();
891 CWindowCoord *x, *y, *z;
892 CWindowProjectorAddKeyframe *add_keyframe;
893 CWindowProjectorReset *reset;
894 CWindowCurveToggle *t_smooth, *t_linear;
897 class CWindowProjectorLeft : public BC_Button
900 CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui,
904 CWindowProjectorGUI *gui;
907 class CWindowProjectorCenter : public BC_Button
910 CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui,
914 CWindowProjectorGUI *gui;
917 class CWindowProjectorRight : public BC_Button
920 CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui,
924 CWindowProjectorGUI *gui;
927 class CWindowProjectorTop : public BC_Button
930 CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui,
934 CWindowProjectorGUI *gui;
937 class CWindowProjectorMiddle : public BC_Button
940 CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui,
944 CWindowProjectorGUI *gui;
947 class CWindowProjectorBottom : public BC_Button
950 CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui,
954 CWindowProjectorGUI *gui;
957 class CWindowProjectorAddKeyframe : public BC_Button
960 CWindowProjectorAddKeyframe(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
967 class CWindowProjectorReset : public BC_Button
970 CWindowProjectorReset(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
980 class CWindowRulerGUI : public CWindowToolGUI
983 CWindowRulerGUI(MWindow *mwindow, CWindowTool *thread);
985 void create_objects();
994 BC_TextBox *distance;