2 Copyright (C) 2012 Paul Davis
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.
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.
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.
19 #ifndef __gtk2_ardour_auplugin_ui_h__
20 #define __gtk2_ardour_auplugin_ui_h__
27 #include <AppKit/AppKit.h>
28 #include <Carbon/Carbon.h>
29 #include <AudioUnit/AudioUnitCarbonView.h>
30 #include <AudioUnit/AudioUnit.h>
32 /* fix up stupid apple macros */
45 #include <gtkmm/box.h>
46 #include <gtkmm/eventbox.h>
47 #include <gtkmm/combobox.h>
48 #include <gtkmm/button.h>
49 #include <gtkmm/label.h>
51 #include "plugin_ui.h"
61 @interface NotificationObject : NSObject {
63 AUPluginUI* plugin_ui;
64 NSWindow* cocoa_parent;
65 NSWindow* top_level_parent;
69 @interface LiveResizeNotificationObject : NSObject {
71 AUPluginUI* plugin_ui;
75 class AUPluginUI : public PlugUIBase, public Gtk::VBox
78 AUPluginUI (boost::shared_ptr<ARDOUR::PluginInsert>);
81 gint get_preferred_width () { return req_width; }
82 gint get_preferred_height () { return req_height; }
83 bool start_updating(GdkEventAny*);
84 bool stop_updating(GdkEventAny*);
89 bool non_gtk_gui() const { return true; }
91 void lower_box_realized ();
92 bool lower_box_visibility_notify (GdkEventVisibility*);
94 void lower_box_map ();
95 void lower_box_unmap ();
96 void lower_box_size_request (GtkRequisition*);
97 void lower_box_size_allocate (Gtk::Allocation&);
99 void cocoa_view_resized ();
102 void forward_key_event (GdkEventKey*);
104 bool on_window_show (const std::string& /*title*/);
105 void on_window_hide ();
107 OSStatus carbon_event (EventHandlerCallRef nextHandlerRef, EventRef event);
109 void start_live_resize ();
110 void end_live_resize ();
114 boost::shared_ptr<ARDOUR::AUPlugin> au;
119 Gtk::EventBox low_box;
121 Gtk::Label automation_mode_label;
122 Gtk::ComboBoxText automation_mode_selector;
123 Gtk::Label preset_label;
125 static std::vector<std::string> automation_mode_strings;
133 NSWindow* cocoa_window;
135 NSRect last_au_frame;
137 uint32_t plugin_requested_resize;
141 NSWindow* cocoa_parent;
142 ComponentDescription carbon_descriptor;
143 AudioUnitCarbonView editView;
144 WindowRef carbon_window;
145 EventHandlerRef carbon_event_handler;
146 bool _activating_from_app;
150 NotificationObject* _notify;
151 LiveResizeNotificationObject* _resize_notify;
153 bool test_cocoa_view_support ();
154 bool test_carbon_view_support ();
155 int create_carbon_view ();
156 int create_cocoa_view ();
158 int parent_carbon_window ();
159 int parent_cocoa_window ();
160 NSWindow* get_nswindow();
162 void update_view_size ();
164 bool plugin_class_valid (Class pluginClass);
166 friend void au_cf_timer_callback (CFRunLoopTimerRef timer, void* info);
167 static CFRunLoopTimerRef cf_timer;
168 static void cf_timer_callback ();
169 static int64_t last_timer;
170 static bool timer_needed;
171 static uint64_t timer_callbacks;
172 static uint64_t timer_out_of_range;
174 static bool timer_callback ();
175 static sigc::connection timer_connection;
178 static void start_cf_timer ();
179 static void stop_cf_timer ();
182 #endif /* __gtk2_ardour_auplugin_ui_h__ */