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();
100 int press(void (CWindowCanvas::*fn)());
104 CWindowCoord *event_caller;
107 class CWindowCoord : public BC_TumbleTextBox
110 CWindowCoord(CWindowToolGUI *gui, int x, int y,
111 float value, int logincrement);
112 CWindowCoord(CWindowToolGUI *gui, int x, int y,
115 // Calls the window's handle_event
121 class CWindowCropApply : public BC_GenericButton
124 CWindowCropApply(MWindow *mwindow, CWindowCropGUI *crop_gui,
126 // Perform the cropping operation
128 int keypress_event();
130 CWindowCropGUI *crop_gui;
133 class CWindowCropOpMode : public BC_PopupMenu
135 static const char *crop_ops[CROP_MODES];
137 CWindowCropOpMode(MWindow *mwindow, CWindowCropGUI *crop_gui,
138 int mode, int x, int y);
139 ~CWindowCropOpMode();
140 void create_objects();
144 CWindowCropGUI *crop_gui;
148 class CWindowCropOpItem : public BC_MenuItem
151 CWindowCropOpItem(CWindowCropOpMode *popup, const char *text, int id);
154 CWindowCropOpMode *popup;
159 class CWindowCropGUI : public CWindowToolGUI
162 CWindowCropGUI(MWindow *mwindow, CWindowTool *thread);
164 void create_objects();
168 CWindowCoord *x1, *y1, *width, *height;
169 CWindowCropOpMode *crop_mode;
172 class CWindowMaskItem : public BC_ListBoxItem
175 CWindowMaskItem(const char *text, int id=-1, int color=-1)
176 : BC_ListBoxItem(text, color), id(id) {}
177 ~CWindowMaskItem() {}
181 class CWindowMaskItems : public ArrayList<BC_ListBoxItem*>
184 CWindowMaskItems() {}
185 ~CWindowMaskItems() { remove_all_objects(); }
188 class CWindowMaskOnTrack : public BC_PopupTextBox
191 CWindowMaskOnTrack(MWindow *mwindow, CWindowMaskGUI *gui,
192 int x, int y, int w, const char *text);
193 ~CWindowMaskOnTrack();
196 CWindowMaskItems track_items;
202 class CWindowMaskTrackTumbler : public BC_Tumbler
205 CWindowMaskTrackTumbler(MWindow *mwindow, CWindowMaskGUI *gui,
207 ~CWindowMaskTrackTumbler();
208 int handle_up_event();
209 int handle_down_event();
210 int do_event(int dir);
217 class CWindowMaskName : public BC_PopupTextBox
220 CWindowMaskName(MWindow *mwindow, CWindowMaskGUI *gui,
221 int x, int y, const char *text);
225 CWindowMaskItems mask_items;
228 void update_items(MaskAuto *keyframe);
231 class CWindowMaskUnclear : public BC_Button
234 CWindowMaskUnclear(MWindow *mwindow, CWindowMaskGUI *gui,
241 class CWindowMaskSoloTrack : public BC_CheckBox
244 CWindowMaskSoloTrack(MWindow *mwindow, CWindowMaskGUI *gui,
245 int x, int y, int v);
246 static int calculate_w(BC_WindowBase *gui);
252 class CWindowMaskDelMask : public BC_GenericButton
255 CWindowMaskDelMask(MWindow *mwindow, CWindowMaskGUI *gui,
262 class CWindowMaskClrMask : public BC_Button
265 CWindowMaskClrMask(MWindow *mwindow, CWindowMaskGUI *gui,
267 ~CWindowMaskClrMask();
268 static int calculate_w(MWindow *mwindow);
274 class CWindowMaskButton : public BC_CheckBox
277 CWindowMaskButton(MWindow *mwindow, CWindowMaskGUI *gui,
278 int x, int y, int no, int v);
279 ~CWindowMaskButton();
287 class CWindowMaskThumbler : public BC_Tumbler
290 CWindowMaskThumbler(MWindow *mwindow, CWindowMaskGUI *gui,
292 ~CWindowMaskThumbler();
293 int handle_up_event();
294 int handle_down_event();
295 int do_event(int dir);
301 class CWindowMaskEnable : public BC_CheckBox
304 CWindowMaskEnable(MWindow *mwindow, CWindowMaskGUI *gui,
305 int x, int y, int no, int v);
306 ~CWindowMaskEnable();
314 class CWindowMaskFade : public BC_TumbleTextBox
317 CWindowMaskFade(MWindow *mwindow, CWindowMaskGUI *gui,
321 int update_value(float v);
327 class CWindowMaskFadeSlider : public BC_ISlider
330 CWindowMaskFadeSlider(MWindow *mwindow, CWindowMaskGUI *gui,
331 int x, int y, int w);
332 ~CWindowMaskFadeSlider();
334 int update(int64_t v);
335 char *get_caption() { return 0; }
343 class CWindowMaskGangFader : public BC_Toggle
346 CWindowMaskGangFader(MWindow *mwindow, CWindowMaskGUI *gui,
348 ~CWindowMaskGangFader();
354 class CWindowMaskGangFocus : public BC_Toggle
357 CWindowMaskGangFocus(MWindow *mwindow, CWindowMaskGUI *gui,
359 ~CWindowMaskGangFocus();
365 class CWindowMaskGangPoint : public BC_Toggle
368 CWindowMaskGangPoint(MWindow *mwindow, CWindowMaskGUI *gui,
370 ~CWindowMaskGangPoint();
376 class CWindowMaskSmoothButton : public BC_Button
379 CWindowMaskSmoothButton(MWindow *mwindow, CWindowMaskGUI *gui,
380 const char *tip, int type, int on, int x, int y, const char *images);
387 class CWindowMaskAffectedPoint : public BC_TumbleTextBox
390 CWindowMaskAffectedPoint(MWindow *mwindow, CWindowMaskGUI *gui,
392 ~CWindowMaskAffectedPoint();
398 class CWindowMaskFocus : public BC_CheckBox
401 CWindowMaskFocus(MWindow *mwindow, CWindowMaskGUI *gui,
407 static int calculate_w(CWindowMaskGUI *gui);
410 class CWindowMaskScaleXY : public BC_Toggle
413 CWindowMaskScaleXY(MWindow *mwindow, CWindowMaskGUI *gui,
414 int x, int y, VFrame **data, int v,
415 int id, const char *tip);
416 ~CWindowMaskScaleXY();
423 class CWindowMaskHelp : public BC_CheckBox
426 CWindowMaskHelp(MWindow *mwindow, CWindowMaskGUI *gui,
434 class CWindowMaskDrawMarkers : public BC_CheckBox
437 CWindowMaskDrawMarkers(MWindow *mwindow, CWindowMaskGUI *gui,
439 ~CWindowMaskDrawMarkers();
445 class CWindowMaskDrawBoundary : public BC_CheckBox
448 CWindowMaskDrawBoundary(MWindow *mwindow, CWindowMaskGUI *gui,
450 ~CWindowMaskDrawBoundary();
456 class CWindowMaskDelPoint : public BC_GenericButton
459 CWindowMaskDelPoint(MWindow *mwindow, CWindowMaskGUI *gui,
466 class CWindowMaskFeather : public BC_TumbleTextBox
469 CWindowMaskFeather(MWindow *mwindow, CWindowMaskGUI *gui,
471 ~CWindowMaskFeather();
473 int update_value(float v);
479 class CWindowMaskFeatherSlider : public BC_FSlider
482 CWindowMaskFeatherSlider(MWindow *mwindow, CWindowMaskGUI *gui,
483 int x, int y, int w, float v);
484 ~CWindowMaskFeatherSlider();
487 int update(int r, float v, float mn, float mx);
488 char *get_caption() { return 0; }
497 class CWindowMaskGangFeather : public BC_Toggle
500 CWindowMaskGangFeather(MWindow *mwindow, CWindowMaskGUI *gui,
502 ~CWindowMaskGangFeather();
508 class CWindowMaskBeforePlugins : public BC_CheckBox
511 CWindowMaskBeforePlugins(CWindowMaskGUI *gui,
517 class CWindowMaskLoadList : public BC_ListBox
520 CWindowMaskLoadList(MWindow *mwindow, CWindowMaskGUI *gui);
521 ~CWindowMaskLoadList();
522 void create_objects();
527 CWindowMaskItems shape_items;
530 class CWindowMaskLoad : public BC_Button
533 CWindowMaskLoad(MWindow *mwindow, CWindowMaskGUI *gui,
534 int x, int y, int w);
541 class CWindowMaskSave : public BC_Button
544 CWindowMaskSave(MWindow *mwindow, CWindowMaskGUI *gui,
545 int x, int y, int w);
551 CWindowMaskPresetDialog *preset_dialog;
554 class CWindowMaskPresetDialog : public BC_DialogThread
557 CWindowMaskPresetDialog(MWindow *mwindow, CWindowMaskGUI *gui);
558 ~CWindowMaskPresetDialog();
559 void handle_close_event(int result);
560 void handle_done_event(int result);
561 BC_Window* new_gui();
562 void start_dialog(int sx, int sy, MaskAuto *keyframe);
566 CWindowMaskPresetGUI *pgui;
571 class CWindowMaskPresetGUI : public BC_Window
574 CWindowMaskPresetGUI(CWindowMaskPresetDialog *preset_dialog,
575 int x, int y, const char *title);
576 void create_objects();
578 CWindowMaskPresetDialog *preset_dialog;
579 CWindowMaskPresetText *preset_text;
582 class CWindowMaskPresetText : public BC_PopupTextBox
585 CWindowMaskPresetText(CWindowMaskPresetGUI *pgui,
586 int x, int y, int w, int h, const char *text);
590 CWindowMaskPresetGUI *pgui;
591 CWindowMaskItems mask_items;
594 class CWindowMaskDelete : public BC_Button
597 CWindowMaskDelete(MWindow *mwindow, CWindowMaskGUI *gui,
598 int x, int y, int w);
605 class CWindowMaskCenter : public BC_Button
608 CWindowMaskCenter(MWindow *mwindow, CWindowMaskGUI *gui,
609 int x, int y, int w);
616 class CWindowMaskNormal : public BC_Button
619 CWindowMaskNormal(MWindow *mwindow, CWindowMaskGUI *gui,
620 int x, int y, int w);
627 class CWindowMaskShape : public BC_Button
630 CWindowMaskShape(MWindow *mwindow, CWindowMaskGUI *gui,
631 const char *images, int shape, int x, int y, const char *tip);
633 void builtin_shape(int i, SubMask *sub_mask);
639 CWindowMaskItems shape_items;
642 class CWindowDisableOpenGLMasking : public BC_CheckBox
645 CWindowDisableOpenGLMasking(CWindowMaskGUI *gui,
651 class CWindowMaskGUI : public CWindowToolGUI
654 CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread);
656 void create_objects();
661 void set_focused(int v, float cx, float cy);
662 void update_buttons(MaskAuto *keyframe, int k);
663 void get_keyframe(Track* &track, MaskAutos* &autos, MaskAuto* &keyframe,
664 SubMask* &mask, MaskPoint* &point, int create_it);
665 void load_masks(ArrayList<SubMask *> &masks);
666 void save_masks(ArrayList<SubMask *> &masks);
667 int smooth_mask(int typ, int on);
668 int save_mask(const char *nm);
669 int del_mask(const char *nm);
673 CWindowMaskOnTrack *mask_on_track;
674 CWindowMaskTrackTumbler *mask_track_tumbler;
675 CWindowMaskName *mask_name;
676 CWindowMaskButton *mask_buttons[SUBMASKS];
677 CWindowMaskThumbler *mask_thumbler;
678 BC_Title *mask_blabels[SUBMASKS];
679 CWindowMaskEnable *mask_enables[SUBMASKS];
680 CWindowMaskSoloTrack *mask_solo_track;
681 CWindowMaskDelMask *mask_del;
682 CWindowMaskUnclear *mask_unclr;
683 CWindowMaskClrMask *mask_clr;
684 CWindowMaskShape *mask_shape_sqr;
685 CWindowMaskShape *mask_shape_crc;
686 CWindowMaskShape *mask_shape_tri;
687 CWindowMaskShape *mask_shape_ovl;
688 CWindowMaskLoadList *mask_load_list;
689 CWindowMaskLoad *mask_load;
690 CWindowMaskSave *mask_save;
691 CWindowMaskDelete *mask_delete;
692 CWindowMaskPresetDialog *preset_dialog;
693 CWindowMaskCenter *mask_center;
694 CWindowMaskNormal *mask_normal;
695 CWindowMaskFade *fade;
696 CWindowMaskFadeSlider *fade_slider;
697 CWindowMaskGangFader *gang_fader;
698 CWindowMaskAffectedPoint *active_point;
699 CWindowMaskDelPoint *del_point;
700 CWindowMaskGangPoint *gang_point;
701 CWindowMaskSmoothButton *mask_pnt_linear, *mask_pnt_smooth;
702 CWindowMaskSmoothButton *mask_crv_linear, *mask_crv_smooth;
703 CWindowMaskSmoothButton *mask_all_linear, *mask_all_smooth;
705 CWindowMaskScaleXY *mask_scale_x, *mask_scale_y, *mask_scale_xy;
707 CWindowMaskFocus *focus;
709 CWindowMaskGangFocus *gang_focus;
710 CWindowMaskHelp *help;
711 int helped, help_y, help_h;
712 CWindowMaskDrawMarkers *draw_markers;
714 CWindowMaskDrawBoundary *draw_boundary;
716 CWindowCoord *focus_x, *focus_y;
717 CWindowMaskFeather *feather;
718 CWindowMaskFeatherSlider *feather_slider;
719 CWindowMaskGangFeather *gang_feather;
720 CWindowMaskBeforePlugins *apply_before_plugins;
721 CWindowDisableOpenGLMasking *disable_opengl_masking;
725 class CWindowEyedropGUI : public CWindowToolGUI
728 CWindowEyedropGUI(MWindow *mwindow, CWindowTool *thread);
729 ~CWindowEyedropGUI();
732 void create_objects();
736 CWindowCoord *radius;
737 CWindowEyedropCheckBox *use_max;
738 BC_Title *red, *green, *blue, *y, *u, *v;
739 BC_Title *rgb_hex, *yuv_hex;
740 BC_SubWindow *sample;
744 class CWindowEyedropCheckBox : public BC_CheckBox
747 CWindowEyedropCheckBox(MWindow *mwindow,
748 CWindowEyedropGUI *gui,
754 CWindowEyedropGUI *gui;
759 class CWindowCameraGUI : public CWindowToolGUI
762 CWindowCameraGUI(MWindow *mwindow, CWindowTool *thread);
765 void create_objects();
768 CWindowCoord *x, *y, *z;
769 CWindowCameraAddKeyframe *add_keyframe;
770 CWindowCameraReset *reset;
771 CWindowCurveToggle *t_smooth, *t_linear;
774 class CWindowCameraLeft : public BC_Button
777 CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui,
781 CWindowCameraGUI *gui;
784 class CWindowCameraCenter : public BC_Button
787 CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui,
791 CWindowCameraGUI *gui;
794 class CWindowCameraRight : public BC_Button
797 CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui,
801 CWindowCameraGUI *gui;
804 class CWindowCameraTop : public BC_Button
807 CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui,
811 CWindowCameraGUI *gui;
814 class CWindowCameraMiddle : public BC_Button
817 CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui,
821 CWindowCameraGUI *gui;
824 class CWindowCameraBottom : public BC_Button
827 CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui,
831 CWindowCameraGUI *gui;
834 class CWindowCameraAddKeyframe : public BC_Button
837 CWindowCameraAddKeyframe(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
844 class CWindowCameraReset : public BC_Button
847 CWindowCameraReset(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
855 class CWindowProjectorGUI : public CWindowToolGUI
858 CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread);
859 ~CWindowProjectorGUI();
861 void create_objects();
864 CWindowCoord *x, *y, *z;
865 CWindowProjectorAddKeyframe *add_keyframe;
866 CWindowProjectorReset *reset;
867 CWindowCurveToggle *t_smooth, *t_linear;
870 class CWindowProjectorLeft : public BC_Button
873 CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui,
877 CWindowProjectorGUI *gui;
880 class CWindowProjectorCenter : public BC_Button
883 CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui,
887 CWindowProjectorGUI *gui;
890 class CWindowProjectorRight : public BC_Button
893 CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui,
897 CWindowProjectorGUI *gui;
900 class CWindowProjectorTop : public BC_Button
903 CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui,
907 CWindowProjectorGUI *gui;
910 class CWindowProjectorMiddle : public BC_Button
913 CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui,
917 CWindowProjectorGUI *gui;
920 class CWindowProjectorBottom : public BC_Button
923 CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui,
927 CWindowProjectorGUI *gui;
930 class CWindowProjectorAddKeyframe : public BC_Button
933 CWindowProjectorAddKeyframe(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
940 class CWindowProjectorReset : public BC_Button
943 CWindowProjectorReset(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
953 class CWindowRulerGUI : public CWindowToolGUI
956 CWindowRulerGUI(MWindow *mwindow, CWindowTool *thread);
958 void create_objects();
967 BC_TextBox *distance;