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"
35 // This common thread supports all the tool GUI's.
36 class CWindowTool : public Thread
39 CWindowTool(MWindow *mwindow, CWindowGUI *gui);
42 // Called depending on state of toggle button
43 void start_tool(int operation);
46 // Called when window is visible
52 void update_show_window();
58 CWindowToolGUI *tool_gui;
61 Condition *input_lock;
62 Condition *output_lock;
63 // Lock run and update_values
67 class CWindowToolGUI : public BC_Window
70 CWindowToolGUI(MWindow *mwindow,
77 virtual void create_objects() {};
78 // Update the keyframe from text boxes
79 virtual void handle_event() {};
80 // Update text boxes from keyframe here
81 virtual void update() {};
82 // Update EDL and preview only
83 void update_preview(int changed_edl=0);
84 void draw_preview(int changed_edl);
85 int current_operation;
86 virtual int close_event();
88 int translation_event();
92 CWindowCoord *event_caller;
95 class CWindowCoord : public BC_TumbleTextBox
98 CWindowCoord(CWindowToolGUI *gui, int x, int y,
99 float value, int logincrement);
100 CWindowCoord(CWindowToolGUI *gui, int x, int y,
103 // Calls the window's handle_event
109 class CWindowCropOK : public BC_GenericButton
112 CWindowCropOK(MWindow *mwindow, CWindowToolGUI *gui,
114 // Perform the cropping operation
116 int keypress_event();
121 class CWindowCropGUI : public CWindowToolGUI
124 CWindowCropGUI(MWindow *mwindow, CWindowTool *thread);
126 void create_objects();
130 CWindowCoord *x1, *y1, *width, *height;
133 class CWindowMaskItem : public BC_ListBoxItem
136 CWindowMaskItem(const char *text, int id=-1, int color=-1)
137 : BC_ListBoxItem(text, color), id(id) {}
138 ~CWindowMaskItem() {}
142 class CWindowMaskItems : public ArrayList<BC_ListBoxItem*>
145 CWindowMaskItems() {}
146 ~CWindowMaskItems() { remove_all_objects(); }
149 class CWindowMaskOnTrack : public BC_PopupTextBox
152 CWindowMaskOnTrack(MWindow *mwindow, CWindowMaskGUI *gui,
153 int x, int y, int w, const char *text);
154 ~CWindowMaskOnTrack();
157 CWindowMaskItems track_items;
163 class CWindowMaskTrackTumbler : public BC_Tumbler
166 CWindowMaskTrackTumbler(MWindow *mwindow, CWindowMaskGUI *gui,
168 ~CWindowMaskTrackTumbler();
169 int handle_up_event();
170 int handle_down_event();
171 int do_event(int dir);
178 class CWindowMaskName : public BC_PopupTextBox
181 CWindowMaskName(MWindow *mwindow, CWindowMaskGUI *gui,
182 int x, int y, const char *text);
186 CWindowMaskItems mask_items;
189 void update_items(MaskAuto *keyframe);
192 class CWindowMaskUnclear : public BC_GenericButton
195 CWindowMaskUnclear(MWindow *mwindow, CWindowMaskGUI *gui,
196 int x, int y, int w);
202 class CWindowMaskSoloTrack : public BC_CheckBox
205 CWindowMaskSoloTrack(MWindow *mwindow, CWindowMaskGUI *gui,
206 int x, int y, int v);
207 static int calculate_w(BC_WindowBase *gui);
213 class CWindowMaskDelMask : public BC_GenericButton
216 CWindowMaskDelMask(MWindow *mwindow, CWindowMaskGUI *gui,
223 class CWindowMaskClrMask : public BC_Button
226 CWindowMaskClrMask(MWindow *mwindow, CWindowMaskGUI *gui,
228 ~CWindowMaskClrMask();
229 static int calculate_w(MWindow *mwindow);
235 class CWindowMaskButton : public BC_CheckBox
238 CWindowMaskButton(MWindow *mwindow, CWindowMaskGUI *gui,
239 int x, int y, int no, int v);
240 ~CWindowMaskButton();
248 class CWindowMaskThumbler : public BC_Tumbler
251 CWindowMaskThumbler(MWindow *mwindow, CWindowMaskGUI *gui,
253 ~CWindowMaskThumbler();
254 int handle_up_event();
255 int handle_down_event();
256 int do_event(int dir);
262 class CWindowMaskEnable : public BC_CheckBox
265 CWindowMaskEnable(MWindow *mwindow, CWindowMaskGUI *gui,
266 int x, int y, int no, int v);
267 ~CWindowMaskEnable();
275 class CWindowMaskFade : public BC_TumbleTextBox
278 CWindowMaskFade(MWindow *mwindow, CWindowMaskGUI *gui,
282 int update_value(float v);
288 class CWindowMaskFadeSlider : public BC_ISlider
291 CWindowMaskFadeSlider(MWindow *mwindow, CWindowMaskGUI *gui,
292 int x, int y, int w);
293 ~CWindowMaskFadeSlider();
295 int update(int64_t v);
296 char *get_caption() { return 0; }
304 class CWindowMaskGangFader : public BC_Toggle
307 CWindowMaskGangFader(MWindow *mwindow, CWindowMaskGUI *gui,
309 ~CWindowMaskGangFader();
315 class CWindowMaskGangFocus : public BC_Toggle
318 CWindowMaskGangFocus(MWindow *mwindow, CWindowMaskGUI *gui,
320 ~CWindowMaskGangFocus();
326 class CWindowMaskSmoothButton : public BC_Button
329 CWindowMaskSmoothButton(MWindow *mwindow, CWindowMaskGUI *gui,
330 const char *tip, int type, int on, int x, int y, const char *images);
337 class CWindowMaskAffectedPoint : public BC_TumbleTextBox
340 CWindowMaskAffectedPoint(MWindow *mwindow, CWindowMaskGUI *gui,
342 ~CWindowMaskAffectedPoint();
348 class CWindowMaskFocus : public BC_CheckBox
351 CWindowMaskFocus(MWindow *mwindow, CWindowMaskGUI *gui,
357 static int calculate_w(CWindowMaskGUI *gui);
360 class CWindowMaskScaleXY : public BC_Toggle
363 CWindowMaskScaleXY(MWindow *mwindow, CWindowMaskGUI *gui,
364 int x, int y, VFrame **data, int v,
365 int id, const char *tip);
366 ~CWindowMaskScaleXY();
373 class CWindowMaskHelp : public BC_CheckBox
376 CWindowMaskHelp(MWindow *mwindow, CWindowMaskGUI *gui,
384 class CWindowMaskDrawMarkers : public BC_CheckBox
387 CWindowMaskDrawMarkers(MWindow *mwindow, CWindowMaskGUI *gui,
389 ~CWindowMaskDrawMarkers();
395 class CWindowMaskDrawBoundary : public BC_CheckBox
398 CWindowMaskDrawBoundary(MWindow *mwindow, CWindowMaskGUI *gui,
400 ~CWindowMaskDrawBoundary();
406 class CWindowMaskDelPoint : public BC_GenericButton
409 CWindowMaskDelPoint(MWindow *mwindow, CWindowMaskGUI *gui,
412 int keypress_event();
417 class CWindowMaskFeather : public BC_TumbleTextBox
420 CWindowMaskFeather(MWindow *mwindow, CWindowMaskGUI *gui,
422 ~CWindowMaskFeather();
424 int update_value(float v);
430 class CWindowMaskFeatherSlider : public BC_FSlider
433 CWindowMaskFeatherSlider(MWindow *mwindow, CWindowMaskGUI *gui,
434 int x, int y, int w, float v);
435 ~CWindowMaskFeatherSlider();
438 char *get_caption() { return 0; }
446 class CWindowMaskGangFeather : public BC_Toggle
449 CWindowMaskGangFeather(MWindow *mwindow, CWindowMaskGUI *gui,
451 ~CWindowMaskGangFeather();
457 class CWindowMaskBeforePlugins : public BC_CheckBox
460 CWindowMaskBeforePlugins(CWindowMaskGUI *gui,
466 class CWindowMaskLoad : public BC_GenericButton
469 CWindowMaskLoad(MWindow *mwindow, CWindowMaskGUI *gui,
470 int x, int y, int w);
477 class CWindowMaskSave : public BC_GenericButton
480 CWindowMaskSave(MWindow *mwindow, CWindowMaskGUI *gui,
481 int x, int y, int w);
487 CWindowMaskPresetDialog *preset_dialog;
490 class CWindowMaskPresetDialog : public BC_DialogThread
493 CWindowMaskPresetDialog(MWindow *mwindow, CWindowMaskGUI *gui);
494 ~CWindowMaskPresetDialog();
495 void handle_close_event(int result);
496 void handle_done_event(int result);
497 BC_Window* new_gui();
498 void start_dialog(int sx, int sy, MaskAuto *keyframe);
502 CWindowMaskPresetGUI *pgui;
507 class CWindowMaskPresetGUI : public BC_Window
510 CWindowMaskPresetGUI(CWindowMaskPresetDialog *preset_dialog,
511 int x, int y, const char *title);
512 void create_objects();
514 CWindowMaskPresetDialog *preset_dialog;
515 CWindowMaskPresetText *preset_text;
518 class CWindowMaskPresetText : public BC_PopupTextBox
521 CWindowMaskPresetText(CWindowMaskPresetGUI *pgui,
522 int x, int y, int w, int h, const char *text);
526 CWindowMaskPresetGUI *pgui;
527 CWindowMaskItems mask_items;
530 class CWindowMaskDelete : public BC_GenericButton
533 CWindowMaskDelete(MWindow *mwindow, CWindowMaskGUI *gui,
534 int x, int y, int w);
541 class CWindowMaskCenter : public BC_GenericButton
544 CWindowMaskCenter(MWindow *mwindow, CWindowMaskGUI *gui,
545 int x, int y, int w);
552 class CWindowMaskNormal : public BC_GenericButton
555 CWindowMaskNormal(MWindow *mwindow, CWindowMaskGUI *gui,
556 int x, int y, int w);
563 class CWindowMaskShape : public BC_ListBox
566 enum { MASK_SHAPE_SQUARE, MASK_SHAPE_CIRCLE,
567 MASK_SHAPE_TRIANGLE, MASK_SHAPE_OVAL,
568 MASK_SHAPE_BUILTIN };
569 CWindowMaskShape(MWindow *mwindow, CWindowMaskGUI *gui);
571 void create_objects();
572 void builtin_shape(int i, SubMask *sub_mask);
573 void load_shape(int i, SubMask *sub_mask);
578 CWindowMaskItems shape_items;
581 class CWindowDisableOpenGLMasking : public BC_CheckBox
584 CWindowDisableOpenGLMasking(CWindowMaskGUI *gui,
590 class CWindowMaskGUI : public CWindowToolGUI
593 CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread);
595 void create_objects();
600 void set_focused(int v, float cx, float cy);
601 void update_buttons(MaskAuto *keyframe, int k);
602 void get_keyframe(Track* &track, MaskAutos* &autos, MaskAuto* &keyframe,
603 SubMask* &mask, MaskPoint* &point, int create_it);
604 void load_masks(ArrayList<SubMask *> &masks);
605 void save_masks(ArrayList<SubMask *> &masks);
606 int smooth_mask(int typ, int on);
607 int save_mask(const char *nm);
608 int del_mask(const char *nm);
612 CWindowMaskOnTrack *mask_on_track;
613 CWindowMaskTrackTumbler *mask_track_tumbler;
614 CWindowMaskName *mask_name;
615 CWindowMaskButton *mask_buttons[SUBMASKS];
616 CWindowMaskThumbler *mask_thumbler;
617 BC_Title *mask_blabels[SUBMASKS];
618 CWindowMaskEnable *mask_enables[SUBMASKS];
619 CWindowMaskSoloTrack *mask_solo_track;
620 CWindowMaskDelMask *mask_del;
621 CWindowMaskUnclear *mask_unclr;
622 CWindowMaskClrMask *mask_clr;
623 CWindowMaskShape *mask_shape;
624 CWindowMaskSave *mask_save;
625 CWindowMaskLoad *mask_load;
626 CWindowMaskDelete *mask_delete;
627 CWindowMaskPresetDialog *preset_dialog;
628 CWindowMaskCenter *mask_center;
629 CWindowMaskNormal *mask_normal;
630 CWindowMaskFade *fade;
631 CWindowMaskFadeSlider *fade_slider;
632 CWindowMaskGangFader *gang_fader;
633 CWindowMaskAffectedPoint *active_point;
634 CWindowMaskDelPoint *del_point;
635 CWindowMaskSmoothButton *mask_pnt_linear, *mask_pnt_smooth;
636 CWindowMaskSmoothButton *mask_crv_linear, *mask_crv_smooth;
637 CWindowMaskSmoothButton *mask_all_linear, *mask_all_smooth;
639 CWindowMaskScaleXY *mask_scale_x, *mask_scale_y, *mask_scale_xy;
641 CWindowMaskFocus *focus;
643 CWindowMaskGangFocus *gang_focus;
644 CWindowMaskHelp *help;
645 int helped, help_y, help_h;
646 CWindowMaskDrawMarkers *draw_markers;
648 CWindowMaskDrawBoundary *draw_boundary;
650 CWindowCoord *focus_x, *focus_y;
651 CWindowMaskFeather *feather;
652 CWindowMaskFeatherSlider *feather_slider;
653 CWindowMaskGangFeather *gang_feather;
654 CWindowMaskBeforePlugins *apply_before_plugins;
655 CWindowDisableOpenGLMasking *disable_opengl_masking;
659 class CWindowEyedropGUI : public CWindowToolGUI
662 CWindowEyedropGUI(MWindow *mwindow, CWindowTool *thread);
663 ~CWindowEyedropGUI();
666 void create_objects();
670 CWindowCoord *radius;
671 CWindowEyedropCheckBox *use_max;
672 BC_Title *red, *green, *blue, *y, *u, *v;
673 BC_Title *rgb_hex, *yuv_hex;
674 BC_SubWindow *sample;
678 class CWindowEyedropCheckBox : public BC_CheckBox
681 CWindowEyedropCheckBox(MWindow *mwindow,
682 CWindowEyedropGUI *gui,
688 CWindowEyedropGUI *gui;
693 class CWindowCameraGUI : public CWindowToolGUI
696 CWindowCameraGUI(MWindow *mwindow, CWindowTool *thread);
698 void create_objects();
701 // Update the keyframe from text boxes
703 // BezierAuto* get_keyframe();
704 CWindowCoord *x, *y, *z;
706 // Toggles for keyframe curve mode (for camera automation only)
707 CWindowCurveToggle *t_smooth, *t_linear;
710 class CWindowCameraLeft : public BC_Button
713 CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui,
717 CWindowCameraGUI *gui;
720 class CWindowCameraCenter : public BC_Button
723 CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui,
727 CWindowCameraGUI *gui;
730 class CWindowCameraRight : public BC_Button
733 CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui,
737 CWindowCameraGUI *gui;
740 class CWindowCameraTop : public BC_Button
743 CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui,
747 CWindowCameraGUI *gui;
750 class CWindowCameraMiddle : public BC_Button
753 CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui,
757 CWindowCameraGUI *gui;
760 class CWindowCameraBottom : public BC_Button
763 CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui,
767 CWindowCameraGUI *gui;
770 class CWindowProjectorGUI : public CWindowToolGUI
773 CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread);
774 ~CWindowProjectorGUI();
775 void create_objects();
778 // BezierAuto* get_keyframe();
779 CWindowCoord *x, *y, *z;
781 // Toggles for keyframe curve mode (projector automation only)
782 CWindowCurveToggle *t_smooth, *t_linear;
785 class CWindowProjectorLeft : public BC_Button
788 CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui,
792 CWindowProjectorGUI *gui;
795 class CWindowProjectorCenter : public BC_Button
798 CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui,
802 CWindowProjectorGUI *gui;
805 class CWindowProjectorRight : public BC_Button
808 CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui,
812 CWindowProjectorGUI *gui;
815 class CWindowProjectorTop : public BC_Button
818 CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui,
822 CWindowProjectorGUI *gui;
825 class CWindowProjectorMiddle : public BC_Button
828 CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui,
832 CWindowProjectorGUI *gui;
835 class CWindowProjectorBottom : public BC_Button
838 CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui,
842 CWindowProjectorGUI *gui;
848 class CWindowRulerGUI : public CWindowToolGUI
851 CWindowRulerGUI(MWindow *mwindow, CWindowTool *thread);
853 void create_objects();
862 BC_TextBox *distance;