4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5 * Copyright (C) 2003-2016 Cinelerra CV contributors
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include "condition.inc"
27 #include "cwindowgui.inc"
28 #include "cwindowtool.inc"
30 #include "keyframe.inc"
31 #include "maskauto.inc"
32 #include "maskautos.inc"
33 #include "mwindow.inc"
47 // This common thread supports all the tool GUI's.
48 class CWindowTool : public Thread
51 CWindowTool(MWindow *mwindow, CWindowGUI *gui);
54 // Called depending on state of toggle button
55 void start_tool(int operation);
58 // Called when window is visible
64 void update_show_window();
70 CWindowToolGUI *tool_gui;
73 Condition *input_lock;
74 Condition *output_lock;
75 // Lock run and update_values
79 class CWindowToolGUI : public BC_Window
82 CWindowToolGUI(MWindow *mwindow,
89 virtual void create_objects() {};
90 // Update the keyframe from text boxes
91 virtual void handle_event() {};
92 // Update text boxes from keyframe here
93 virtual void update() {};
95 // Update EDL and preview only
96 void update_preview(int changed_edl=0);
97 void update_auto(Track *track, int idx, CWindowCoord *vp);
98 void draw_preview(int changed_edl);
99 int current_operation;
100 virtual int close_event();
101 int keypress_event();
102 int translation_event();
103 int press(void (CWindowCanvas::*fn)());
107 CWindowCoord *event_caller;
111 class CWindowCoord : public BC_TumbleTextBox
114 CWindowCoord(CWindowToolGUI *gui, int x, int y, float value, int group=-1);
115 CWindowCoord(CWindowToolGUI *gui, int x, int y, int value, int group=-1);
116 void create_objects();
117 void update_gui(float value);
118 // Calls the window's handle_event
123 CWindowToolAutoRangeTumbler *min_tumbler;
124 CWindowCoordSlider *slider;
125 CWindowToolAutoRangeTumbler *max_tumbler;
126 CWindowToolAutoRangeReset *range_reset;
127 CWindowToolAutoRangeTextBox *range_text;
128 CWindowCoordRangeTumbler *range;
131 class CWindowCoordSlider : public BC_FSlider
134 CWindowCoordSlider(CWindowCoord *coord, int x, int y, int w,
135 float mn, float mx, float value);
136 ~CWindowCoordSlider();
142 class CWindowCoordRangeTumbler : public BC_Tumbler
145 CWindowCoordRangeTumbler(CWindowCoord *coord, int x, int y);
146 ~CWindowCoordRangeTumbler();
147 int update(float scale);
148 int handle_up_event();
149 int handle_down_event();
154 class CWindowCurveAutoEdge : public BC_Toggle
157 CWindowCurveAutoEdge(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
164 class CWindowCurveAutoSpan : public BC_Toggle
167 CWindowCurveAutoSpan(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
175 class CWindowCropApply : public BC_GenericButton
178 CWindowCropApply(MWindow *mwindow, CWindowCropGUI *crop_gui,
180 // Perform the cropping operation
182 int keypress_event();
184 CWindowCropGUI *crop_gui;
187 class CWindowCropOpMode : public BC_PopupMenu
189 static const char *crop_ops[CROP_MODES];
191 CWindowCropOpMode(MWindow *mwindow, CWindowCropGUI *crop_gui,
192 int mode, int x, int y);
193 ~CWindowCropOpMode();
194 void create_objects();
198 CWindowCropGUI *crop_gui;
202 class CWindowCropOpItem : public BC_MenuItem
205 CWindowCropOpItem(CWindowCropOpMode *popup, const char *text, int id);
208 CWindowCropOpMode *popup;
213 class CWindowCropGUI : public CWindowToolGUI
216 CWindowCropGUI(MWindow *mwindow, CWindowTool *thread);
218 void create_objects();
222 CWindowCoord *x1, *y1, *width, *height;
223 CWindowCropOpMode *crop_mode;
226 class CWindowMaskItem : public BC_ListBoxItem
229 CWindowMaskItem(const char *text, int id=-1, int color=-1)
230 : BC_ListBoxItem(text, color), id(id) {}
231 ~CWindowMaskItem() {}
235 class CWindowMaskItems : public ArrayList<BC_ListBoxItem*>
238 CWindowMaskItems() {}
239 ~CWindowMaskItems() { remove_all_objects(); }
242 class CWindowMaskOnTrack : public BC_PopupTextBox
245 CWindowMaskOnTrack(MWindow *mwindow, CWindowMaskGUI *gui,
246 int x, int y, int w, const char *text);
247 ~CWindowMaskOnTrack();
250 CWindowMaskItems track_items;
256 class CWindowMaskTrackTumbler : public BC_Tumbler
259 CWindowMaskTrackTumbler(MWindow *mwindow, CWindowMaskGUI *gui,
261 ~CWindowMaskTrackTumbler();
262 int handle_up_event();
263 int handle_down_event();
264 int do_event(int dir);
271 class CWindowMaskName : public BC_PopupTextBox
274 CWindowMaskName(MWindow *mwindow, CWindowMaskGUI *gui,
275 int x, int y, const char *text);
279 CWindowMaskItems mask_items;
282 void update_items(MaskAuto *keyframe);
285 class CWindowMaskUnclear : public BC_Button
288 CWindowMaskUnclear(MWindow *mwindow, CWindowMaskGUI *gui,
295 class CWindowMaskSoloTrack : public BC_CheckBox
298 CWindowMaskSoloTrack(MWindow *mwindow, CWindowMaskGUI *gui,
299 int x, int y, int v);
300 static int calculate_w(BC_WindowBase *gui);
306 class CWindowMaskDelMask : public BC_GenericButton
309 CWindowMaskDelMask(MWindow *mwindow, CWindowMaskGUI *gui,
316 class CWindowMaskClrMask : public BC_Button
319 CWindowMaskClrMask(MWindow *mwindow, CWindowMaskGUI *gui,
321 ~CWindowMaskClrMask();
322 static int calculate_w(MWindow *mwindow);
328 class CWindowMaskButton : public BC_CheckBox
331 CWindowMaskButton(MWindow *mwindow, CWindowMaskGUI *gui,
332 int x, int y, int no, int v);
333 ~CWindowMaskButton();
341 class CWindowMaskThumbler : public BC_Tumbler
344 CWindowMaskThumbler(MWindow *mwindow, CWindowMaskGUI *gui,
346 ~CWindowMaskThumbler();
347 int handle_up_event();
348 int handle_down_event();
349 int do_event(int dir);
355 class CWindowMaskEnable : public BC_CheckBox
358 CWindowMaskEnable(MWindow *mwindow, CWindowMaskGUI *gui,
359 int x, int y, int no, int v);
360 ~CWindowMaskEnable();
368 class CWindowMaskFade : public BC_TumbleTextBox
371 CWindowMaskFade(MWindow *mwindow, CWindowMaskGUI *gui,
375 int update_value(float v);
381 class CWindowMaskFadeSlider : public BC_ISlider
384 CWindowMaskFadeSlider(MWindow *mwindow, CWindowMaskGUI *gui,
385 int x, int y, int w);
386 ~CWindowMaskFadeSlider();
388 int update(int64_t v);
389 char *get_caption() { return 0; }
397 class CWindowMaskGangFader : public BC_Toggle
400 CWindowMaskGangFader(MWindow *mwindow, CWindowMaskGUI *gui,
402 ~CWindowMaskGangFader();
408 class CWindowMaskGangFocus : public BC_Toggle
411 CWindowMaskGangFocus(MWindow *mwindow, CWindowMaskGUI *gui,
413 ~CWindowMaskGangFocus();
419 class CWindowMaskGangPoint : public BC_Toggle
422 CWindowMaskGangPoint(MWindow *mwindow, CWindowMaskGUI *gui,
424 ~CWindowMaskGangPoint();
430 class CWindowMaskSmoothButton : public BC_Button
433 CWindowMaskSmoothButton(MWindow *mwindow, CWindowMaskGUI *gui,
434 const char *tip, int type, int on, int x, int y, const char *images);
441 class CWindowMaskAffectedPoint : public BC_TumbleTextBox
444 CWindowMaskAffectedPoint(MWindow *mwindow, CWindowMaskGUI *gui,
446 ~CWindowMaskAffectedPoint();
452 class CWindowMaskFocus : public BC_CheckBox
455 CWindowMaskFocus(MWindow *mwindow, CWindowMaskGUI *gui,
461 static int calculate_w(CWindowMaskGUI *gui);
464 class CWindowMaskScaleXY : public BC_Toggle
467 CWindowMaskScaleXY(MWindow *mwindow, CWindowMaskGUI *gui,
468 int x, int y, VFrame **data, int v,
469 int id, const char *tip);
470 ~CWindowMaskScaleXY();
477 class CWindowMaskHelp : public BC_CheckBox
480 CWindowMaskHelp(MWindow *mwindow, CWindowMaskGUI *gui,
488 class CWindowMaskDrawMarkers : public BC_CheckBox
491 CWindowMaskDrawMarkers(MWindow *mwindow, CWindowMaskGUI *gui,
493 ~CWindowMaskDrawMarkers();
499 class CWindowMaskDrawBoundary : public BC_CheckBox
502 CWindowMaskDrawBoundary(MWindow *mwindow, CWindowMaskGUI *gui,
504 ~CWindowMaskDrawBoundary();
510 class CWindowMaskDelPoint : public BC_GenericButton
513 CWindowMaskDelPoint(MWindow *mwindow, CWindowMaskGUI *gui,
520 class CWindowMaskFeather : public BC_TumbleTextBox
523 CWindowMaskFeather(MWindow *mwindow, CWindowMaskGUI *gui,
525 ~CWindowMaskFeather();
527 int update_value(float v);
533 class CWindowMaskFeatherSlider : public BC_FSlider
536 CWindowMaskFeatherSlider(MWindow *mwindow, CWindowMaskGUI *gui,
537 int x, int y, int w, float v);
538 ~CWindowMaskFeatherSlider();
541 int update(int r, float v, float mn, float mx);
542 char *get_caption() { return 0; }
551 class CWindowMaskGangFeather : public BC_Toggle
554 CWindowMaskGangFeather(MWindow *mwindow, CWindowMaskGUI *gui,
556 ~CWindowMaskGangFeather();
562 class CWindowMaskBeforePlugins : public BC_CheckBox
565 CWindowMaskBeforePlugins(CWindowMaskGUI *gui,
571 class CWindowMaskLoadList : public BC_ListBox
574 CWindowMaskLoadList(MWindow *mwindow, CWindowMaskGUI *gui);
575 ~CWindowMaskLoadList();
576 void create_objects();
581 CWindowMaskItems shape_items;
584 class CWindowMaskLoad : public BC_Button
587 CWindowMaskLoad(MWindow *mwindow, CWindowMaskGUI *gui,
588 int x, int y, int w);
595 class CWindowMaskSave : public BC_Button
598 CWindowMaskSave(MWindow *mwindow, CWindowMaskGUI *gui,
599 int x, int y, int w);
605 CWindowMaskPresetDialog *preset_dialog;
608 class CWindowMaskPresetDialog : public BC_DialogThread
611 CWindowMaskPresetDialog(MWindow *mwindow, CWindowMaskGUI *gui);
612 ~CWindowMaskPresetDialog();
613 void handle_close_event(int result);
614 void handle_done_event(int result);
615 BC_Window* new_gui();
616 void start_dialog(int sx, int sy, MaskAuto *keyframe);
620 CWindowMaskPresetGUI *pgui;
625 class CWindowMaskPresetGUI : public BC_Window
628 CWindowMaskPresetGUI(CWindowMaskPresetDialog *preset_dialog,
629 int x, int y, const char *title);
630 void create_objects();
632 CWindowMaskPresetDialog *preset_dialog;
633 CWindowMaskPresetText *preset_text;
636 class CWindowMaskPresetText : public BC_PopupTextBox
639 CWindowMaskPresetText(CWindowMaskPresetGUI *pgui,
640 int x, int y, int w, int h, const char *text);
644 CWindowMaskPresetGUI *pgui;
645 CWindowMaskItems mask_items;
648 class CWindowMaskDelete : public BC_Button
651 CWindowMaskDelete(MWindow *mwindow, CWindowMaskGUI *gui,
652 int x, int y, int w);
659 class CWindowMaskCenter : public BC_Button
662 CWindowMaskCenter(MWindow *mwindow, CWindowMaskGUI *gui,
663 int x, int y, int w);
670 class CWindowMaskNormal : public BC_Button
673 CWindowMaskNormal(MWindow *mwindow, CWindowMaskGUI *gui,
674 int x, int y, int w);
681 class CWindowMaskShape : public BC_Button
684 CWindowMaskShape(MWindow *mwindow, CWindowMaskGUI *gui,
685 const char *images, int shape, int x, int y, const char *tip);
687 void builtin_shape(int i, SubMask *sub_mask);
693 CWindowMaskItems shape_items;
696 class CWindowDisableOpenGLMasking : public BC_CheckBox
699 CWindowDisableOpenGLMasking(CWindowMaskGUI *gui,
705 class CWindowMaskGUI : public CWindowToolGUI
708 CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread);
710 void create_objects();
715 void set_focused(int v, float cx, float cy);
716 void update_buttons(MaskAuto *keyframe, int k);
717 void get_keyframe(Track* &track, MaskAutos* &autos, MaskAuto* &keyframe,
718 SubMask* &mask, MaskPoint* &point, int create_it);
719 void load_masks(ArrayList<SubMask *> &masks);
720 void save_masks(ArrayList<SubMask *> &masks);
721 int smooth_mask(int typ, int on);
722 int save_mask(const char *nm);
723 int del_mask(const char *nm);
727 CWindowMaskOnTrack *mask_on_track;
728 CWindowMaskTrackTumbler *mask_track_tumbler;
729 CWindowMaskName *mask_name;
730 CWindowMaskButton *mask_buttons[SUBMASKS];
731 CWindowMaskThumbler *mask_thumbler;
732 BC_Title *mask_blabels[SUBMASKS];
733 CWindowMaskEnable *mask_enables[SUBMASKS];
734 CWindowMaskSoloTrack *mask_solo_track;
735 CWindowMaskDelMask *mask_del;
736 CWindowMaskUnclear *mask_unclr;
737 CWindowMaskClrMask *mask_clr;
738 CWindowMaskShape *mask_shape_sqr;
739 CWindowMaskShape *mask_shape_crc;
740 CWindowMaskShape *mask_shape_tri;
741 CWindowMaskShape *mask_shape_ovl;
742 CWindowMaskLoadList *mask_load_list;
743 CWindowMaskLoad *mask_load;
744 CWindowMaskSave *mask_save;
745 CWindowMaskDelete *mask_delete;
746 CWindowMaskPresetDialog *preset_dialog;
747 CWindowMaskCenter *mask_center;
748 CWindowMaskNormal *mask_normal;
749 CWindowMaskFade *fade;
750 CWindowMaskFadeSlider *fade_slider;
751 CWindowMaskGangFader *gang_fader;
752 CWindowMaskAffectedPoint *active_point;
753 CWindowMaskDelPoint *del_point;
754 CWindowMaskGangPoint *gang_point;
755 CWindowMaskSmoothButton *mask_pnt_linear, *mask_pnt_smooth;
756 CWindowMaskSmoothButton *mask_crv_linear, *mask_crv_smooth;
757 CWindowMaskSmoothButton *mask_all_linear, *mask_all_smooth;
759 CWindowMaskScaleXY *mask_scale_x, *mask_scale_y, *mask_scale_xy;
761 CWindowMaskFocus *focus;
763 CWindowMaskGangFocus *gang_focus;
764 CWindowMaskHelp *help;
765 int helped, help_y, help_h;
766 CWindowMaskDrawMarkers *draw_markers;
768 CWindowMaskDrawBoundary *draw_boundary;
770 CWindowCoord *focus_x, *focus_y;
771 CWindowMaskFeather *feather;
772 CWindowMaskFeatherSlider *feather_slider;
773 CWindowMaskGangFeather *gang_feather;
774 CWindowMaskBeforePlugins *apply_before_plugins;
775 CWindowDisableOpenGLMasking *disable_opengl_masking;
779 class CWindowEyedropGUI : public CWindowToolGUI
782 CWindowEyedropGUI(MWindow *mwindow, CWindowTool *thread);
783 ~CWindowEyedropGUI();
786 void create_objects();
790 CWindowCoord *radius;
791 CWindowEyedropCheckBox *use_max;
792 BC_Title *red, *green, *blue, *y, *u, *v;
793 BC_Title *rgb_hex, *yuv_hex;
794 BC_SubWindow *sample;
798 class CWindowEyedropCheckBox : public BC_CheckBox
801 CWindowEyedropCheckBox(MWindow *mwindow,
802 CWindowEyedropGUI *gui,
808 CWindowEyedropGUI *gui;
812 class CWindowToolAutoRangeTumbler : public BC_Tumbler
815 CWindowToolAutoRangeTumbler(CWindowCoord *coord, int x, int y,
816 int use_max, const char *tip);
817 int handle_up_event();
818 int handle_down_event();
824 class CWindowToolAutoRangeReset : public BC_Button
827 CWindowToolAutoRangeReset(CWindowCoord *coord, int x, int y);
833 class CWindowToolAutoRangeTextBox : public BC_TextBox
836 CWindowToolAutoRangeTextBox(CWindowCoord *coord, int x, int y);
837 int button_press_event();
845 class CWindowCameraGUI : public CWindowToolGUI
848 CWindowCameraGUI(MWindow *mwindow, CWindowTool *thread);
851 void create_objects();
854 BC_TitleBar *bar1, *bar2;
855 CWindowCoord *x, *y, *z;
856 CWindowCameraAddKeyframe *add_keyframe;
857 CWindowCameraReset *reset;
858 BC_TitleBar *bar3, *bar4, *bar5;
859 CWindowCurveToggle *t_smooth, *t_linear, *t_tangent, *t_free, *t_bump;
860 CWindowCurveAutoSpan *auto_span;
861 CWindowCurveAutoEdge *auto_edge;
864 class CWindowCameraLeft : public BC_Button
867 CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui,
871 CWindowCameraGUI *gui;
874 class CWindowCameraCenter : public BC_Button
877 CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui,
881 CWindowCameraGUI *gui;
884 class CWindowCameraRight : public BC_Button
887 CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui,
891 CWindowCameraGUI *gui;
894 class CWindowCameraTop : public BC_Button
897 CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui,
901 CWindowCameraGUI *gui;
904 class CWindowCameraMiddle : public BC_Button
907 CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui,
911 CWindowCameraGUI *gui;
914 class CWindowCameraBottom : public BC_Button
917 CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui,
921 CWindowCameraGUI *gui;
924 class CWindowCameraAddKeyframe : public BC_Button
927 CWindowCameraAddKeyframe(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
934 class CWindowCameraReset : public BC_Button
937 CWindowCameraReset(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
945 class CWindowProjectorGUI : public CWindowToolGUI
948 CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread);
949 ~CWindowProjectorGUI();
951 void create_objects();
954 BC_TitleBar *bar1, *bar2;
955 CWindowCoord *x, *y, *z;
956 CWindowProjectorAddKeyframe *add_keyframe;
957 CWindowProjectorReset *reset;
958 BC_TitleBar *bar3, *bar4, *bar5;
959 CWindowCurveToggle *t_smooth, *t_linear, *t_tangent, *t_free, *t_bump;
960 CWindowCurveAutoSpan *auto_span;
961 CWindowCurveAutoEdge *auto_edge;
964 class CWindowProjectorLeft : public BC_Button
967 CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui,
971 CWindowProjectorGUI *gui;
974 class CWindowProjectorCenter : public BC_Button
977 CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui,
981 CWindowProjectorGUI *gui;
984 class CWindowProjectorRight : public BC_Button
987 CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui,
991 CWindowProjectorGUI *gui;
994 class CWindowProjectorTop : public BC_Button
997 CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui,
1001 CWindowProjectorGUI *gui;
1004 class CWindowProjectorMiddle : public BC_Button
1007 CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui,
1011 CWindowProjectorGUI *gui;
1014 class CWindowProjectorBottom : public BC_Button
1017 CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui,
1021 CWindowProjectorGUI *gui;
1024 class CWindowProjectorAddKeyframe : public BC_Button
1027 CWindowProjectorAddKeyframe(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
1031 CWindowToolGUI *gui;
1034 class CWindowProjectorReset : public BC_Button
1037 CWindowProjectorReset(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
1041 CWindowToolGUI *gui;
1047 class CWindowRulerGUI : public CWindowToolGUI
1050 CWindowRulerGUI(MWindow *mwindow, CWindowTool *thread);
1052 void create_objects();
1055 void handle_event();
1057 BC_TextBox *current;
1061 BC_TextBox *distance;