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 update_auto(Track *track, int idx, CWindowCoord *vp);
97 void draw_preview(int changed_edl);
98 int current_operation;
99 virtual int close_event();
100 int keypress_event();
101 int translation_event();
102 int press(void (CWindowCanvas::*fn)());
106 CWindowCoord *event_caller;
110 class CWindowCoord : public BC_TumbleTextBox
113 CWindowCoord(CWindowToolGUI *gui, int x, int y, float value, int group=-1);
114 CWindowCoord(CWindowToolGUI *gui, int x, int y, int value, int group=-1);
115 void create_objects();
116 void update_gui(float value);
117 // Calls the window's handle_event
122 CWindowToolAutoRangeTumbler *min_tumbler;
123 CWindowCoordSlider *slider;
124 CWindowToolAutoRangeTumbler *max_tumbler;
125 CWindowToolAutoRangeReset *range_reset;
126 CWindowToolAutoRangeTextBox *range_text;
127 CWindowCoordRangeTumbler *range;
130 class CWindowCoordSlider : public BC_FSlider
133 CWindowCoordSlider(CWindowCoord *coord, int x, int y, int w,
134 float mn, float mx, float value);
135 ~CWindowCoordSlider();
141 class CWindowCoordRangeTumbler : public BC_Tumbler
144 CWindowCoordRangeTumbler(CWindowCoord *coord, int x, int y);
145 ~CWindowCoordRangeTumbler();
146 int update(float scale);
147 int handle_up_event();
148 int handle_down_event();
153 class CWindowCurveAutoEdge : public BC_Toggle
156 CWindowCurveAutoEdge(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
163 class CWindowCurveAutoSpan : public BC_Toggle
166 CWindowCurveAutoSpan(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
174 class CWindowCropApply : public BC_GenericButton
177 CWindowCropApply(MWindow *mwindow, CWindowCropGUI *crop_gui,
179 // Perform the cropping operation
181 int keypress_event();
183 CWindowCropGUI *crop_gui;
186 class CWindowCropOpMode : public BC_PopupMenu
188 static const char *crop_ops[CROP_MODES];
190 CWindowCropOpMode(MWindow *mwindow, CWindowCropGUI *crop_gui,
191 int mode, int x, int y);
192 ~CWindowCropOpMode();
193 void create_objects();
197 CWindowCropGUI *crop_gui;
201 class CWindowCropOpItem : public BC_MenuItem
204 CWindowCropOpItem(CWindowCropOpMode *popup, const char *text, int id);
207 CWindowCropOpMode *popup;
212 class CWindowCropGUI : public CWindowToolGUI
215 CWindowCropGUI(MWindow *mwindow, CWindowTool *thread);
217 void create_objects();
221 CWindowCoord *x1, *y1, *width, *height;
222 CWindowCropOpMode *crop_mode;
225 class CWindowMaskItem : public BC_ListBoxItem
228 CWindowMaskItem(const char *text, int id=-1, int color=-1)
229 : BC_ListBoxItem(text, color), id(id) {}
230 ~CWindowMaskItem() {}
234 class CWindowMaskItems : public ArrayList<BC_ListBoxItem*>
237 CWindowMaskItems() {}
238 ~CWindowMaskItems() { remove_all_objects(); }
241 class CWindowMaskOnTrack : public BC_PopupTextBox
244 CWindowMaskOnTrack(MWindow *mwindow, CWindowMaskGUI *gui,
245 int x, int y, int w, const char *text);
246 ~CWindowMaskOnTrack();
249 CWindowMaskItems track_items;
255 class CWindowMaskTrackTumbler : public BC_Tumbler
258 CWindowMaskTrackTumbler(MWindow *mwindow, CWindowMaskGUI *gui,
260 ~CWindowMaskTrackTumbler();
261 int handle_up_event();
262 int handle_down_event();
263 int do_event(int dir);
270 class CWindowMaskName : public BC_PopupTextBox
273 CWindowMaskName(MWindow *mwindow, CWindowMaskGUI *gui,
274 int x, int y, const char *text);
278 CWindowMaskItems mask_items;
281 void update_items(MaskAuto *keyframe);
284 class CWindowMaskUnclear : public BC_Button
287 CWindowMaskUnclear(MWindow *mwindow, CWindowMaskGUI *gui,
294 class CWindowMaskSoloTrack : public BC_CheckBox
297 CWindowMaskSoloTrack(MWindow *mwindow, CWindowMaskGUI *gui,
298 int x, int y, int v);
299 static int calculate_w(BC_WindowBase *gui);
305 class CWindowMaskDelMask : public BC_GenericButton
308 CWindowMaskDelMask(MWindow *mwindow, CWindowMaskGUI *gui,
315 class CWindowMaskClrMask : public BC_Button
318 CWindowMaskClrMask(MWindow *mwindow, CWindowMaskGUI *gui,
320 ~CWindowMaskClrMask();
321 static int calculate_w(MWindow *mwindow);
327 class CWindowMaskButton : public BC_CheckBox
330 CWindowMaskButton(MWindow *mwindow, CWindowMaskGUI *gui,
331 int x, int y, int no, int v);
332 ~CWindowMaskButton();
340 class CWindowMaskThumbler : public BC_Tumbler
343 CWindowMaskThumbler(MWindow *mwindow, CWindowMaskGUI *gui,
345 ~CWindowMaskThumbler();
346 int handle_up_event();
347 int handle_down_event();
348 int do_event(int dir);
354 class CWindowMaskEnable : public BC_CheckBox
357 CWindowMaskEnable(MWindow *mwindow, CWindowMaskGUI *gui,
358 int x, int y, int no, int v);
359 ~CWindowMaskEnable();
367 class CWindowMaskFade : public BC_TumbleTextBox
370 CWindowMaskFade(MWindow *mwindow, CWindowMaskGUI *gui,
374 int update_value(float v);
380 class CWindowMaskFadeSlider : public BC_ISlider
383 CWindowMaskFadeSlider(MWindow *mwindow, CWindowMaskGUI *gui,
384 int x, int y, int w);
385 ~CWindowMaskFadeSlider();
387 int update(int64_t v);
388 char *get_caption() { return 0; }
396 class CWindowMaskGangFader : public BC_Toggle
399 CWindowMaskGangFader(MWindow *mwindow, CWindowMaskGUI *gui,
401 ~CWindowMaskGangFader();
407 class CWindowMaskGangFocus : public BC_Toggle
410 CWindowMaskGangFocus(MWindow *mwindow, CWindowMaskGUI *gui,
412 ~CWindowMaskGangFocus();
418 class CWindowMaskGangPoint : public BC_Toggle
421 CWindowMaskGangPoint(MWindow *mwindow, CWindowMaskGUI *gui,
423 ~CWindowMaskGangPoint();
429 class CWindowMaskSmoothButton : public BC_Button
432 CWindowMaskSmoothButton(MWindow *mwindow, CWindowMaskGUI *gui,
433 const char *tip, int type, int on, int x, int y, const char *images);
440 class CWindowMaskAffectedPoint : public BC_TumbleTextBox
443 CWindowMaskAffectedPoint(MWindow *mwindow, CWindowMaskGUI *gui,
445 ~CWindowMaskAffectedPoint();
451 class CWindowMaskFocus : public BC_CheckBox
454 CWindowMaskFocus(MWindow *mwindow, CWindowMaskGUI *gui,
460 static int calculate_w(CWindowMaskGUI *gui);
463 class CWindowMaskScaleXY : public BC_Toggle
466 CWindowMaskScaleXY(MWindow *mwindow, CWindowMaskGUI *gui,
467 int x, int y, VFrame **data, int v,
468 int id, const char *tip);
469 ~CWindowMaskScaleXY();
476 class CWindowMaskHelp : public BC_CheckBox
479 CWindowMaskHelp(MWindow *mwindow, CWindowMaskGUI *gui,
487 class CWindowMaskDrawMarkers : public BC_CheckBox
490 CWindowMaskDrawMarkers(MWindow *mwindow, CWindowMaskGUI *gui,
492 ~CWindowMaskDrawMarkers();
498 class CWindowMaskDrawBoundary : public BC_CheckBox
501 CWindowMaskDrawBoundary(MWindow *mwindow, CWindowMaskGUI *gui,
503 ~CWindowMaskDrawBoundary();
509 class CWindowMaskDelPoint : public BC_GenericButton
512 CWindowMaskDelPoint(MWindow *mwindow, CWindowMaskGUI *gui,
519 class CWindowMaskFeather : public BC_TumbleTextBox
522 CWindowMaskFeather(MWindow *mwindow, CWindowMaskGUI *gui,
524 ~CWindowMaskFeather();
526 int update_value(float v);
532 class CWindowMaskFeatherSlider : public BC_FSlider
535 CWindowMaskFeatherSlider(MWindow *mwindow, CWindowMaskGUI *gui,
536 int x, int y, int w, float v);
537 ~CWindowMaskFeatherSlider();
540 int update(int r, float v, float mn, float mx);
541 char *get_caption() { return 0; }
550 class CWindowMaskGangFeather : public BC_Toggle
553 CWindowMaskGangFeather(MWindow *mwindow, CWindowMaskGUI *gui,
555 ~CWindowMaskGangFeather();
561 class CWindowMaskBeforePlugins : public BC_CheckBox
564 CWindowMaskBeforePlugins(CWindowMaskGUI *gui,
570 class CWindowMaskLoadList : public BC_ListBox
573 CWindowMaskLoadList(MWindow *mwindow, CWindowMaskGUI *gui);
574 ~CWindowMaskLoadList();
575 void create_objects();
580 CWindowMaskItems shape_items;
583 class CWindowMaskLoad : public BC_Button
586 CWindowMaskLoad(MWindow *mwindow, CWindowMaskGUI *gui,
587 int x, int y, int w);
594 class CWindowMaskSave : public BC_Button
597 CWindowMaskSave(MWindow *mwindow, CWindowMaskGUI *gui,
598 int x, int y, int w);
604 CWindowMaskPresetDialog *preset_dialog;
607 class CWindowMaskPresetDialog : public BC_DialogThread
610 CWindowMaskPresetDialog(MWindow *mwindow, CWindowMaskGUI *gui);
611 ~CWindowMaskPresetDialog();
612 void handle_close_event(int result);
613 void handle_done_event(int result);
614 BC_Window* new_gui();
615 void start_dialog(int sx, int sy, MaskAuto *keyframe);
619 CWindowMaskPresetGUI *pgui;
624 class CWindowMaskPresetGUI : public BC_Window
627 CWindowMaskPresetGUI(CWindowMaskPresetDialog *preset_dialog,
628 int x, int y, const char *title);
629 void create_objects();
631 CWindowMaskPresetDialog *preset_dialog;
632 CWindowMaskPresetText *preset_text;
635 class CWindowMaskPresetText : public BC_PopupTextBox
638 CWindowMaskPresetText(CWindowMaskPresetGUI *pgui,
639 int x, int y, int w, int h, const char *text);
643 CWindowMaskPresetGUI *pgui;
644 CWindowMaskItems mask_items;
647 class CWindowMaskDelete : public BC_Button
650 CWindowMaskDelete(MWindow *mwindow, CWindowMaskGUI *gui,
651 int x, int y, int w);
658 class CWindowMaskCenter : public BC_Button
661 CWindowMaskCenter(MWindow *mwindow, CWindowMaskGUI *gui,
662 int x, int y, int w);
669 class CWindowMaskNormal : public BC_Button
672 CWindowMaskNormal(MWindow *mwindow, CWindowMaskGUI *gui,
673 int x, int y, int w);
680 class CWindowMaskShape : public BC_Button
683 CWindowMaskShape(MWindow *mwindow, CWindowMaskGUI *gui,
684 const char *images, int shape, int x, int y, const char *tip);
686 void builtin_shape(int i, SubMask *sub_mask);
692 CWindowMaskItems shape_items;
695 class CWindowDisableOpenGLMasking : public BC_CheckBox
698 CWindowDisableOpenGLMasking(CWindowMaskGUI *gui,
704 class CWindowMaskGUI : public CWindowToolGUI
707 CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread);
709 void create_objects();
714 void set_focused(int v, float cx, float cy);
715 void update_buttons(MaskAuto *keyframe, int k);
716 void get_keyframe(Track* &track, MaskAutos* &autos, MaskAuto* &keyframe,
717 SubMask* &mask, MaskPoint* &point, int create_it);
718 void load_masks(ArrayList<SubMask *> &masks);
719 void save_masks(ArrayList<SubMask *> &masks);
720 int smooth_mask(int typ, int on);
721 int save_mask(const char *nm);
722 int del_mask(const char *nm);
726 CWindowMaskOnTrack *mask_on_track;
727 CWindowMaskTrackTumbler *mask_track_tumbler;
728 CWindowMaskName *mask_name;
729 CWindowMaskButton *mask_buttons[SUBMASKS];
730 CWindowMaskThumbler *mask_thumbler;
731 BC_Title *mask_blabels[SUBMASKS];
732 CWindowMaskEnable *mask_enables[SUBMASKS];
733 CWindowMaskSoloTrack *mask_solo_track;
734 CWindowMaskDelMask *mask_del;
735 CWindowMaskUnclear *mask_unclr;
736 CWindowMaskClrMask *mask_clr;
737 CWindowMaskShape *mask_shape_sqr;
738 CWindowMaskShape *mask_shape_crc;
739 CWindowMaskShape *mask_shape_tri;
740 CWindowMaskShape *mask_shape_ovl;
741 CWindowMaskLoadList *mask_load_list;
742 CWindowMaskLoad *mask_load;
743 CWindowMaskSave *mask_save;
744 CWindowMaskDelete *mask_delete;
745 CWindowMaskPresetDialog *preset_dialog;
746 CWindowMaskCenter *mask_center;
747 CWindowMaskNormal *mask_normal;
748 CWindowMaskFade *fade;
749 CWindowMaskFadeSlider *fade_slider;
750 CWindowMaskGangFader *gang_fader;
751 CWindowMaskAffectedPoint *active_point;
752 CWindowMaskDelPoint *del_point;
753 CWindowMaskGangPoint *gang_point;
754 CWindowMaskSmoothButton *mask_pnt_linear, *mask_pnt_smooth;
755 CWindowMaskSmoothButton *mask_crv_linear, *mask_crv_smooth;
756 CWindowMaskSmoothButton *mask_all_linear, *mask_all_smooth;
758 CWindowMaskScaleXY *mask_scale_x, *mask_scale_y, *mask_scale_xy;
760 CWindowMaskFocus *focus;
762 CWindowMaskGangFocus *gang_focus;
763 CWindowMaskHelp *help;
764 int helped, help_y, help_h;
765 CWindowMaskDrawMarkers *draw_markers;
767 CWindowMaskDrawBoundary *draw_boundary;
769 CWindowCoord *focus_x, *focus_y;
770 CWindowMaskFeather *feather;
771 CWindowMaskFeatherSlider *feather_slider;
772 CWindowMaskGangFeather *gang_feather;
773 CWindowMaskBeforePlugins *apply_before_plugins;
774 CWindowDisableOpenGLMasking *disable_opengl_masking;
778 class CWindowEyedropGUI : public CWindowToolGUI
781 CWindowEyedropGUI(MWindow *mwindow, CWindowTool *thread);
782 ~CWindowEyedropGUI();
785 void create_objects();
789 CWindowCoord *radius;
790 CWindowEyedropCheckBox *use_max;
791 BC_Title *red, *green, *blue, *y, *u, *v;
792 BC_Title *rgb_hex, *yuv_hex;
793 BC_SubWindow *sample;
797 class CWindowEyedropCheckBox : public BC_CheckBox
800 CWindowEyedropCheckBox(MWindow *mwindow,
801 CWindowEyedropGUI *gui,
807 CWindowEyedropGUI *gui;
811 class CWindowToolAutoRangeTumbler : public BC_Tumbler
814 CWindowToolAutoRangeTumbler(CWindowCoord *coord, int x, int y,
815 int use_max, const char *tip);
816 int handle_up_event();
817 int handle_down_event();
823 class CWindowToolAutoRangeReset : public BC_Button
826 CWindowToolAutoRangeReset(CWindowCoord *coord, int x, int y);
832 class CWindowToolAutoRangeTextBox : public BC_TextBox
835 CWindowToolAutoRangeTextBox(CWindowCoord *coord, int x, int y);
836 int button_press_event();
844 class CWindowCameraGUI : public CWindowToolGUI
847 CWindowCameraGUI(MWindow *mwindow, CWindowTool *thread);
850 void create_objects();
853 BC_TitleBar *bar1, *bar2;
854 CWindowCoord *x, *y, *z;
855 CWindowCameraAddKeyframe *add_keyframe;
856 CWindowCameraReset *reset;
857 BC_TitleBar *bar3, *bar4, *bar5;
858 CWindowCurveToggle *t_smooth, *t_linear, *t_tangent, *t_free, *t_bump;
859 CWindowCurveAutoSpan *auto_span;
860 CWindowCurveAutoEdge *auto_edge;
863 class CWindowCameraLeft : public BC_Button
866 CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui,
870 CWindowCameraGUI *gui;
873 class CWindowCameraCenter : public BC_Button
876 CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui,
880 CWindowCameraGUI *gui;
883 class CWindowCameraRight : public BC_Button
886 CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui,
890 CWindowCameraGUI *gui;
893 class CWindowCameraTop : public BC_Button
896 CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui,
900 CWindowCameraGUI *gui;
903 class CWindowCameraMiddle : public BC_Button
906 CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui,
910 CWindowCameraGUI *gui;
913 class CWindowCameraBottom : public BC_Button
916 CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui,
920 CWindowCameraGUI *gui;
923 class CWindowCameraAddKeyframe : public BC_Button
926 CWindowCameraAddKeyframe(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
933 class CWindowCameraReset : public BC_Button
936 CWindowCameraReset(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
944 class CWindowProjectorGUI : public CWindowToolGUI
947 CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread);
948 ~CWindowProjectorGUI();
950 void create_objects();
953 BC_TitleBar *bar1, *bar2;
954 CWindowCoord *x, *y, *z;
955 CWindowProjectorAddKeyframe *add_keyframe;
956 CWindowProjectorReset *reset;
957 BC_TitleBar *bar3, *bar4, *bar5;
958 CWindowCurveToggle *t_smooth, *t_linear, *t_tangent, *t_free, *t_bump;
959 CWindowCurveAutoSpan *auto_span;
960 CWindowCurveAutoEdge *auto_edge;
963 class CWindowProjectorLeft : public BC_Button
966 CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui,
970 CWindowProjectorGUI *gui;
973 class CWindowProjectorCenter : public BC_Button
976 CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui,
980 CWindowProjectorGUI *gui;
983 class CWindowProjectorRight : public BC_Button
986 CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui,
990 CWindowProjectorGUI *gui;
993 class CWindowProjectorTop : public BC_Button
996 CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui,
1000 CWindowProjectorGUI *gui;
1003 class CWindowProjectorMiddle : public BC_Button
1006 CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui,
1010 CWindowProjectorGUI *gui;
1013 class CWindowProjectorBottom : public BC_Button
1016 CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui,
1020 CWindowProjectorGUI *gui;
1023 class CWindowProjectorAddKeyframe : public BC_Button
1026 CWindowProjectorAddKeyframe(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
1030 CWindowToolGUI *gui;
1033 class CWindowProjectorReset : public BC_Button
1036 CWindowProjectorReset(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
1040 CWindowToolGUI *gui;
1046 class CWindowRulerGUI : public CWindowToolGUI
1049 CWindowRulerGUI(MWindow *mwindow, CWindowTool *thread);
1051 void create_objects();
1054 void handle_event();
1056 BC_TextBox *current;
1060 BC_TextBox *distance;