Merge branch 'license-fix' of https://github.com/adiknoth/ardour
[ardour.git] / gtk2_ardour / au_pluginui.h
1 /*
2     Copyright (C) 2012 Paul Davis 
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __gtk2_ardour_auplugin_ui_h__
21 #define __gtk2_ardour_auplugin_ui_h__
22
23 #include <vector>
24 #include <string>
25
26 #include <AppKit/AppKit.h>
27 #include <Carbon/Carbon.h>
28 #include <AudioUnit/AudioUnitCarbonView.h>
29 #include <AudioUnit/AudioUnit.h>
30
31 /* fix up stupid apple macros */
32
33 #undef check
34 #undef require
35 #undef verify
36
37 #include <gtkmm/box.h>
38 #include <gtkmm/combobox.h>
39 #include <gtkmm/button.h>
40 #include <gtkmm/label.h>
41
42 #include "plugin_ui.h"
43
44 namespace ARDOUR {
45         class AUPlugin;
46         class PluginInsert;
47         class IOProcessor;
48 }
49
50 class AUPluginUI;
51
52 @interface NotificationObject : NSObject {
53         @private
54                 AUPluginUI* plugin_ui;
55                 NSWindow* cocoa_parent;
56                 NSWindow* top_level_parent;
57 }
58 @end
59
60 class AUPluginUI : public PlugUIBase, public Gtk::VBox
61 {
62   public:
63         AUPluginUI (boost::shared_ptr<ARDOUR::PluginInsert>);
64         ~AUPluginUI ();
65
66         gint get_preferred_height () { return prefheight; }
67         gint get_preferred_width () { return prefwidth; }
68         bool start_updating(GdkEventAny*);
69         bool stop_updating(GdkEventAny*);
70
71         void activate ();
72         void deactivate ();
73
74         bool non_gtk_gui() const { return true; }
75
76         void lower_box_realized ();
77         void cocoa_view_resized ();
78         void on_realize ();
79         bool on_map_event (GdkEventAny*);
80         bool on_focus_in_event (GdkEventFocus*);
81         bool on_focus_out_event (GdkEventFocus*);
82         void forward_key_event (GdkEventKey*);
83
84         bool on_window_show (const std::string& /*title*/);
85         void on_window_hide ();
86
87         OSStatus carbon_event (EventHandlerCallRef nextHandlerRef, EventRef event);
88
89   private:
90         WindowRef wr;
91         boost::shared_ptr<ARDOUR::AUPlugin> au;
92         int prefheight;
93         int prefwidth;
94
95         Gtk::HBox     top_box;
96         Gtk::HBox low_box;
97         Gtk::VBox vpacker;
98         Gtk::Label automation_mode_label;
99         Gtk::ComboBoxText automation_mode_selector;
100         Gtk::Label preset_label;
101
102         static std::vector<std::string> automation_mode_strings;
103
104         /* Cocoa */
105
106         NSWindow*           cocoa_window;
107         NSView*             au_view;
108
109         /* Carbon */
110
111         NSWindow*            cocoa_parent;
112         ComponentDescription carbon_descriptor;
113         AudioUnitCarbonView  editView;
114         WindowRef            carbon_window;
115         EventHandlerRef      carbon_event_handler;
116         bool                 _activating_from_app;
117         NotificationObject* _notify;
118
119         bool test_cocoa_view_support ();
120         bool test_carbon_view_support ();
121         int  create_carbon_view ();
122         int  create_cocoa_view ();
123
124         int parent_carbon_window ();
125         int parent_cocoa_window ();
126         NSWindow* get_nswindow();
127
128         bool plugin_class_valid (Class pluginClass);
129 };
130
131 #endif /* __gtk2_ardour_auplugin_ui_h__  */