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