hack up AU GUI support to handle AUSampler resizing better. Note that this is still...
[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         void forward_key_event (GdkEventKey*);
80
81         bool on_window_show (const std::string& /*title*/);
82         void on_window_hide ();
83
84         OSStatus carbon_event (EventHandlerCallRef nextHandlerRef, EventRef event);
85
86   private:
87         WindowRef wr;
88         boost::shared_ptr<ARDOUR::AUPlugin> au;
89         int prefheight;
90         int prefwidth;
91
92         Gtk::HBox     top_box;
93         Gtk::HBox low_box;
94         Gtk::VBox vpacker;
95         Gtk::Label automation_mode_label;
96         Gtk::ComboBoxText automation_mode_selector;
97         Gtk::Label preset_label;
98
99         static std::vector<std::string> automation_mode_strings;
100
101         /* Cocoa */
102
103         NSWindow*           cocoa_window;
104         NSView*             au_view;
105         NSRect              last_au_frame;
106
107         /* Carbon */
108
109         NSWindow*            cocoa_parent;
110         ComponentDescription carbon_descriptor;
111         AudioUnitCarbonView  editView;
112         WindowRef            carbon_window;
113         EventHandlerRef      carbon_event_handler;
114         bool                 _activating_from_app;
115         NotificationObject* _notify;
116
117         bool test_cocoa_view_support ();
118         bool test_carbon_view_support ();
119         int  create_carbon_view ();
120         int  create_cocoa_view ();
121
122         int parent_carbon_window ();
123         int parent_cocoa_window ();
124         NSWindow* get_nswindow();
125
126         bool plugin_class_valid (Class pluginClass);
127 };
128
129 #endif /* __gtk2_ardour_auplugin_ui_h__  */