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
121 CWindowCoordSlider *slider;
122 CWindowCoordRange *range;
126 class CWindowCoordSlider : public BC_FSlider
129 CWindowCoordSlider(CWindowCoord *coord, int x, int y, int w,
130 float mn, float mx, float value);
131 ~CWindowCoordSlider();
137 class CWindowCoordRange : public BC_Tumbler
140 CWindowCoordRange(CWindowCoord *coord, int x, int y);
141 ~CWindowCoordRange();
142 int update(float scale);
143 int handle_up_event();
144 int handle_down_event();
149 class CWindowCurveAutoEdge : public BC_Toggle
152 CWindowCurveAutoEdge(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
159 class CWindowCurveAutoSpan : public BC_Toggle
162 CWindowCurveAutoSpan(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
170 class CWindowCropApply : public BC_GenericButton
173 CWindowCropApply(MWindow *mwindow, CWindowCropGUI *crop_gui,
175 // Perform the cropping operation
177 int keypress_event();
179 CWindowCropGUI *crop_gui;
182 class CWindowCropOpMode : public BC_PopupMenu
184 static const char *crop_ops[CROP_MODES];
186 CWindowCropOpMode(MWindow *mwindow, CWindowCropGUI *crop_gui,
187 int mode, int x, int y);
188 ~CWindowCropOpMode();
189 void create_objects();
193 CWindowCropGUI *crop_gui;
197 class CWindowCropOpItem : public BC_MenuItem
200 CWindowCropOpItem(CWindowCropOpMode *popup, const char *text, int id);
203 CWindowCropOpMode *popup;
208 class CWindowCropGUI : public CWindowToolGUI
211 CWindowCropGUI(MWindow *mwindow, CWindowTool *thread);
213 void create_objects();
217 CWindowCoord *x1, *y1, *width, *height;
218 CWindowCropOpMode *crop_mode;
221 class CWindowMaskItem : public BC_ListBoxItem
224 CWindowMaskItem(const char *text, int id=-1, int color=-1)
225 : BC_ListBoxItem(text, color), id(id) {}
226 ~CWindowMaskItem() {}
230 class CWindowMaskItems : public ArrayList<BC_ListBoxItem*>
233 CWindowMaskItems() {}
234 ~CWindowMaskItems() { remove_all_objects(); }
237 class CWindowMaskOnTrack : public BC_PopupTextBox
240 CWindowMaskOnTrack(MWindow *mwindow, CWindowMaskGUI *gui,
241 int x, int y, int w, const char *text);
242 ~CWindowMaskOnTrack();
245 CWindowMaskItems track_items;
251 class CWindowMaskTrackTumbler : public BC_Tumbler
254 CWindowMaskTrackTumbler(MWindow *mwindow, CWindowMaskGUI *gui,
256 ~CWindowMaskTrackTumbler();
257 int handle_up_event();
258 int handle_down_event();
259 int do_event(int dir);
266 class CWindowMaskName : public BC_PopupTextBox
269 CWindowMaskName(MWindow *mwindow, CWindowMaskGUI *gui,
270 int x, int y, const char *text);
274 CWindowMaskItems mask_items;
277 void update_items(MaskAuto *keyframe);
280 class CWindowMaskUnclear : public BC_Button
283 CWindowMaskUnclear(MWindow *mwindow, CWindowMaskGUI *gui,
290 class CWindowMaskSoloTrack : public BC_CheckBox
293 CWindowMaskSoloTrack(MWindow *mwindow, CWindowMaskGUI *gui,
294 int x, int y, int v);
295 static int calculate_w(BC_WindowBase *gui);
301 class CWindowMaskDelMask : public BC_GenericButton
304 CWindowMaskDelMask(MWindow *mwindow, CWindowMaskGUI *gui,
311 class CWindowMaskClrMask : public BC_Button
314 CWindowMaskClrMask(MWindow *mwindow, CWindowMaskGUI *gui,
316 ~CWindowMaskClrMask();
317 static int calculate_w(MWindow *mwindow);
323 class CWindowMaskButton : public BC_CheckBox
326 CWindowMaskButton(MWindow *mwindow, CWindowMaskGUI *gui,
327 int x, int y, int no, int v);
328 ~CWindowMaskButton();
336 class CWindowMaskThumbler : public BC_Tumbler
339 CWindowMaskThumbler(MWindow *mwindow, CWindowMaskGUI *gui,
341 ~CWindowMaskThumbler();
342 int handle_up_event();
343 int handle_down_event();
344 int do_event(int dir);
350 class CWindowMaskEnable : public BC_CheckBox
353 CWindowMaskEnable(MWindow *mwindow, CWindowMaskGUI *gui,
354 int x, int y, int no, int v);
355 ~CWindowMaskEnable();
363 class CWindowMaskFade : public BC_TumbleTextBox
366 CWindowMaskFade(MWindow *mwindow, CWindowMaskGUI *gui,
370 int update_value(float v);
376 class CWindowMaskFadeSlider : public BC_ISlider
379 CWindowMaskFadeSlider(MWindow *mwindow, CWindowMaskGUI *gui,
380 int x, int y, int w);
381 ~CWindowMaskFadeSlider();
383 int update(int64_t v);
384 char *get_caption() { return 0; }
392 class CWindowMaskGangFader : public BC_Toggle
395 CWindowMaskGangFader(MWindow *mwindow, CWindowMaskGUI *gui,
397 ~CWindowMaskGangFader();
403 class CWindowMaskGangFocus : public BC_Toggle
406 CWindowMaskGangFocus(MWindow *mwindow, CWindowMaskGUI *gui,
408 ~CWindowMaskGangFocus();
414 class CWindowMaskGangPoint : public BC_Toggle
417 CWindowMaskGangPoint(MWindow *mwindow, CWindowMaskGUI *gui,
419 ~CWindowMaskGangPoint();
425 class CWindowMaskSmoothButton : public BC_Button
428 CWindowMaskSmoothButton(MWindow *mwindow, CWindowMaskGUI *gui,
429 const char *tip, int type, int on, int x, int y, const char *images);
436 class CWindowMaskAffectedPoint : public BC_TumbleTextBox
439 CWindowMaskAffectedPoint(MWindow *mwindow, CWindowMaskGUI *gui,
441 ~CWindowMaskAffectedPoint();
447 class CWindowMaskFocus : public BC_CheckBox
450 CWindowMaskFocus(MWindow *mwindow, CWindowMaskGUI *gui,
456 static int calculate_w(CWindowMaskGUI *gui);
459 class CWindowMaskScaleXY : public BC_Toggle
462 CWindowMaskScaleXY(MWindow *mwindow, CWindowMaskGUI *gui,
463 int x, int y, VFrame **data, int v,
464 int id, const char *tip);
465 ~CWindowMaskScaleXY();
472 class CWindowMaskHelp : public BC_CheckBox
475 CWindowMaskHelp(MWindow *mwindow, CWindowMaskGUI *gui,
483 class CWindowMaskDrawMarkers : public BC_CheckBox
486 CWindowMaskDrawMarkers(MWindow *mwindow, CWindowMaskGUI *gui,
488 ~CWindowMaskDrawMarkers();
494 class CWindowMaskDrawBoundary : public BC_CheckBox
497 CWindowMaskDrawBoundary(MWindow *mwindow, CWindowMaskGUI *gui,
499 ~CWindowMaskDrawBoundary();
505 class CWindowMaskDelPoint : public BC_GenericButton
508 CWindowMaskDelPoint(MWindow *mwindow, CWindowMaskGUI *gui,
515 class CWindowMaskFeather : public BC_TumbleTextBox
518 CWindowMaskFeather(MWindow *mwindow, CWindowMaskGUI *gui,
520 ~CWindowMaskFeather();
522 int update_value(float v);
528 class CWindowMaskFeatherSlider : public BC_FSlider
531 CWindowMaskFeatherSlider(MWindow *mwindow, CWindowMaskGUI *gui,
532 int x, int y, int w, float v);
533 ~CWindowMaskFeatherSlider();
536 int update(int r, float v, float mn, float mx);
537 char *get_caption() { return 0; }
546 class CWindowMaskGangFeather : public BC_Toggle
549 CWindowMaskGangFeather(MWindow *mwindow, CWindowMaskGUI *gui,
551 ~CWindowMaskGangFeather();
557 class CWindowMaskBeforePlugins : public BC_CheckBox
560 CWindowMaskBeforePlugins(CWindowMaskGUI *gui,
566 class CWindowMaskLoadList : public BC_ListBox
569 CWindowMaskLoadList(MWindow *mwindow, CWindowMaskGUI *gui);
570 ~CWindowMaskLoadList();
571 void create_objects();
576 CWindowMaskItems shape_items;
579 class CWindowMaskLoad : public BC_Button
582 CWindowMaskLoad(MWindow *mwindow, CWindowMaskGUI *gui,
583 int x, int y, int w);
590 class CWindowMaskSave : public BC_Button
593 CWindowMaskSave(MWindow *mwindow, CWindowMaskGUI *gui,
594 int x, int y, int w);
600 CWindowMaskPresetDialog *preset_dialog;
603 class CWindowMaskPresetDialog : public BC_DialogThread
606 CWindowMaskPresetDialog(MWindow *mwindow, CWindowMaskGUI *gui);
607 ~CWindowMaskPresetDialog();
608 void handle_close_event(int result);
609 void handle_done_event(int result);
610 BC_Window* new_gui();
611 void start_dialog(int sx, int sy, MaskAuto *keyframe);
615 CWindowMaskPresetGUI *pgui;
620 class CWindowMaskPresetGUI : public BC_Window
623 CWindowMaskPresetGUI(CWindowMaskPresetDialog *preset_dialog,
624 int x, int y, const char *title);
625 void create_objects();
627 CWindowMaskPresetDialog *preset_dialog;
628 CWindowMaskPresetText *preset_text;
631 class CWindowMaskPresetText : public BC_PopupTextBox
634 CWindowMaskPresetText(CWindowMaskPresetGUI *pgui,
635 int x, int y, int w, int h, const char *text);
639 CWindowMaskPresetGUI *pgui;
640 CWindowMaskItems mask_items;
643 class CWindowMaskDelete : public BC_Button
646 CWindowMaskDelete(MWindow *mwindow, CWindowMaskGUI *gui,
647 int x, int y, int w);
654 class CWindowMaskCenter : public BC_Button
657 CWindowMaskCenter(MWindow *mwindow, CWindowMaskGUI *gui,
658 int x, int y, int w);
665 class CWindowMaskNormal : public BC_Button
668 CWindowMaskNormal(MWindow *mwindow, CWindowMaskGUI *gui,
669 int x, int y, int w);
676 class CWindowMaskShape : public BC_Button
679 CWindowMaskShape(MWindow *mwindow, CWindowMaskGUI *gui,
680 const char *images, int shape, int x, int y, const char *tip);
682 void builtin_shape(int i, SubMask *sub_mask);
688 CWindowMaskItems shape_items;
691 class CWindowDisableOpenGLMasking : public BC_CheckBox
694 CWindowDisableOpenGLMasking(CWindowMaskGUI *gui,
700 class CWindowMaskGUI : public CWindowToolGUI
703 CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread);
705 void create_objects();
710 void set_focused(int v, float cx, float cy);
711 void update_buttons(MaskAuto *keyframe, int k);
712 void get_keyframe(Track* &track, MaskAutos* &autos, MaskAuto* &keyframe,
713 SubMask* &mask, MaskPoint* &point, int create_it);
714 void load_masks(ArrayList<SubMask *> &masks);
715 void save_masks(ArrayList<SubMask *> &masks);
716 int smooth_mask(int typ, int on);
717 int save_mask(const char *nm);
718 int del_mask(const char *nm);
722 CWindowMaskOnTrack *mask_on_track;
723 CWindowMaskTrackTumbler *mask_track_tumbler;
724 CWindowMaskName *mask_name;
725 CWindowMaskButton *mask_buttons[SUBMASKS];
726 CWindowMaskThumbler *mask_thumbler;
727 BC_Title *mask_blabels[SUBMASKS];
728 CWindowMaskEnable *mask_enables[SUBMASKS];
729 CWindowMaskSoloTrack *mask_solo_track;
730 CWindowMaskDelMask *mask_del;
731 CWindowMaskUnclear *mask_unclr;
732 CWindowMaskClrMask *mask_clr;
733 CWindowMaskShape *mask_shape_sqr;
734 CWindowMaskShape *mask_shape_crc;
735 CWindowMaskShape *mask_shape_tri;
736 CWindowMaskShape *mask_shape_ovl;
737 CWindowMaskLoadList *mask_load_list;
738 CWindowMaskLoad *mask_load;
739 CWindowMaskSave *mask_save;
740 CWindowMaskDelete *mask_delete;
741 CWindowMaskPresetDialog *preset_dialog;
742 CWindowMaskCenter *mask_center;
743 CWindowMaskNormal *mask_normal;
744 CWindowMaskFade *fade;
745 CWindowMaskFadeSlider *fade_slider;
746 CWindowMaskGangFader *gang_fader;
747 CWindowMaskAffectedPoint *active_point;
748 CWindowMaskDelPoint *del_point;
749 CWindowMaskGangPoint *gang_point;
750 CWindowMaskSmoothButton *mask_pnt_linear, *mask_pnt_smooth;
751 CWindowMaskSmoothButton *mask_crv_linear, *mask_crv_smooth;
752 CWindowMaskSmoothButton *mask_all_linear, *mask_all_smooth;
754 CWindowMaskScaleXY *mask_scale_x, *mask_scale_y, *mask_scale_xy;
756 CWindowMaskFocus *focus;
758 CWindowMaskGangFocus *gang_focus;
759 CWindowMaskHelp *help;
760 int helped, help_y, help_h;
761 CWindowMaskDrawMarkers *draw_markers;
763 CWindowMaskDrawBoundary *draw_boundary;
765 CWindowCoord *focus_x, *focus_y;
766 CWindowMaskFeather *feather;
767 CWindowMaskFeatherSlider *feather_slider;
768 CWindowMaskGangFeather *gang_feather;
769 CWindowMaskBeforePlugins *apply_before_plugins;
770 CWindowDisableOpenGLMasking *disable_opengl_masking;
774 class CWindowEyedropGUI : public CWindowToolGUI
777 CWindowEyedropGUI(MWindow *mwindow, CWindowTool *thread);
778 ~CWindowEyedropGUI();
781 void create_objects();
785 CWindowCoord *radius;
786 CWindowEyedropCheckBox *use_max;
787 BC_Title *red, *green, *blue, *y, *u, *v;
788 BC_Title *rgb_hex, *yuv_hex;
789 BC_SubWindow *sample;
793 class CWindowEyedropCheckBox : public BC_CheckBox
796 CWindowEyedropCheckBox(MWindow *mwindow,
797 CWindowEyedropGUI *gui,
803 CWindowEyedropGUI *gui;
808 class CWindowCameraGUI : public CWindowToolGUI
811 CWindowCameraGUI(MWindow *mwindow, CWindowTool *thread);
814 void create_objects();
817 CWindowCoord *x, *y, *z;
818 CWindowCameraAddKeyframe *add_keyframe;
819 CWindowCameraReset *reset;
820 CWindowCurveToggle *t_smooth, *t_linear, *t_tangent, *t_free, *t_bump;
821 CWindowCurveAutoSpan *auto_span;
822 CWindowCurveAutoEdge *auto_edge;
825 class CWindowCameraLeft : public BC_Button
828 CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui,
832 CWindowCameraGUI *gui;
835 class CWindowCameraCenter : public BC_Button
838 CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui,
842 CWindowCameraGUI *gui;
845 class CWindowCameraRight : public BC_Button
848 CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui,
852 CWindowCameraGUI *gui;
855 class CWindowCameraTop : public BC_Button
858 CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui,
862 CWindowCameraGUI *gui;
865 class CWindowCameraMiddle : public BC_Button
868 CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui,
872 CWindowCameraGUI *gui;
875 class CWindowCameraBottom : public BC_Button
878 CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui,
882 CWindowCameraGUI *gui;
885 class CWindowCameraAddKeyframe : public BC_Button
888 CWindowCameraAddKeyframe(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
895 class CWindowCameraReset : public BC_Button
898 CWindowCameraReset(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
906 class CWindowProjectorGUI : public CWindowToolGUI
909 CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread);
910 ~CWindowProjectorGUI();
912 void create_objects();
915 CWindowCoord *x, *y, *z;
916 CWindowProjectorAddKeyframe *add_keyframe;
917 CWindowProjectorReset *reset;
918 CWindowCurveToggle *t_smooth, *t_linear, *t_tangent, *t_free, *t_bump;
919 CWindowCurveAutoSpan *auto_span;
920 CWindowCurveAutoEdge *auto_edge;
923 class CWindowProjectorLeft : public BC_Button
926 CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui,
930 CWindowProjectorGUI *gui;
933 class CWindowProjectorCenter : public BC_Button
936 CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui,
940 CWindowProjectorGUI *gui;
943 class CWindowProjectorRight : public BC_Button
946 CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui,
950 CWindowProjectorGUI *gui;
953 class CWindowProjectorTop : public BC_Button
956 CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui,
960 CWindowProjectorGUI *gui;
963 class CWindowProjectorMiddle : public BC_Button
966 CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui,
970 CWindowProjectorGUI *gui;
973 class CWindowProjectorBottom : public BC_Button
976 CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui,
980 CWindowProjectorGUI *gui;
983 class CWindowProjectorAddKeyframe : public BC_Button
986 CWindowProjectorAddKeyframe(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
993 class CWindowProjectorReset : public BC_Button
996 CWindowProjectorReset(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
1000 CWindowToolGUI *gui;
1006 class CWindowRulerGUI : public CWindowToolGUI
1009 CWindowRulerGUI(MWindow *mwindow, CWindowTool *thread);
1011 void create_objects();
1014 void handle_event();
1016 BC_TextBox *current;
1020 BC_TextBox *distance;