Ardour  9.0-pre0-582-g084a23a80d
au_pluginui.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2009 David Robillard <d@drobilla.net>
3  * Copyright (C) 2008-2017 Paul Davis <paul@linuxaudiosystems.com>
4  * Copyright (C) 2015-2017 Robin Gareus <robin@gareus.org>
5  *
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.
10  *
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.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #ifndef __gtk2_ardour_auplugin_ui_h__
22 #define __gtk2_ardour_auplugin_ui_h__
23 
24 #include <vector>
25 #include <string>
26 
27 #include <stdint.h>
28 
29 #include <AppKit/AppKit.h>
30 #include <Carbon/Carbon.h>
31 #include <AudioUnit/AudioUnitCarbonView.h>
32 #include <AudioUnit/AudioUnit.h>
33 
34 /* fix up stupid apple macros */
35 
36 #undef check
37 #undef require
38 #undef verify
39 
40 #ifdef YES
41 #undef YES
42 #endif
43 #ifdef NO
44 #undef NO
45 #endif
46 
47 #include <gtkmm/box.h>
48 #include <gtkmm/eventbox.h>
49 #include <gtkmm/combobox.h>
50 #include <gtkmm/button.h>
51 #include <gtkmm/label.h>
52 
53 #include "widgets/eventboxext.h"
54 
55 #include "plugin_ui.h"
56 
57 namespace ARDOUR {
58  class AUPlugin;
59  class PlugInsertBase;
60  class IOProcessor;
61 }
62 
63 class AUPluginUI;
64 
65 @interface NotificationObject : NSObject {
66  @private
68  NSWindow* cocoa_parent;
69  NSWindow* top_level_parent;
70 }
71 @end
72 
73 @interface LiveResizeNotificationObject : NSObject {
74  @private
76 }
77 @end
78 
79 class AUPluginUI : public PlugUIBase, public Gtk::VBox
80 {
81 public:
82  AUPluginUI (std::shared_ptr<ARDOUR::PlugInsertBase>);
84 
85  gint get_preferred_width () { return req_width; }
86  gint get_preferred_height () { return req_height; }
89 
90  void activate ();
91  void deactivate ();
92 
93  bool non_gtk_gui() const { return true; }
94 
97 
98  void lower_box_map ();
99  void lower_box_unmap ();
102 
104  void on_realize ();
105  void grab_focus();
107 
108  bool on_window_show (const std::string& /*title*/);
109  void on_window_hide ();
110 
111  OSStatus carbon_event (EventHandlerCallRef nextHandlerRef, EventRef event);
112 
115 
116 private:
117  WindowRef wr;
118  std::shared_ptr<ARDOUR::AUPlugin> au;
121 
128 
129  static std::vector<std::string> automation_mode_strings;
130 
131  bool resizable;
136 
137  /* Cocoa */
138 
139  NSWindow* cocoa_window;
140  NSView* au_view;
144 
145  /* Carbon */
146 
147  NSWindow* cocoa_parent;
148  ComponentDescription carbon_descriptor;
149  AudioUnitCarbonView editView;
150  WindowRef carbon_window;
151  EventHandlerRef carbon_event_handler;
153 
154  /* Generic */
155 
158 
163 
166  NSWindow* get_nswindow();
167 
169 
170  bool plugin_class_valid (Class pluginClass);
171 
172  friend void au_cf_timer_callback (CFRunLoopTimerRef timer, void* info);
173  static CFRunLoopTimerRef cf_timer;
174  static void cf_timer_callback ();
175  static int64_t last_timer;
176  static bool timer_needed;
177  static uint64_t timer_callbacks;
178  static uint64_t timer_out_of_range;
179 
180  static bool timer_callback ();
181  static sigc::connection timer_connection;
182 
183 public:
184  static void start_cf_timer ();
185  static void stop_cf_timer ();
186 };
187 
188 #endif /* __gtk2_ardour_auplugin_ui_h__ */
uint32_t plugin_requested_resize
Definition: au_pluginui.h:143
bool in_live_resize
Definition: au_pluginui.h:142
static void stop_cf_timer()
int parent_cocoa_window()
Gtk::Label automation_mode_label
Definition: au_pluginui.h:125
void grab_focus()
void lower_box_map()
int create_carbon_view()
bool stop_updating(GdkEventAny *)
NSWindow * cocoa_window
Definition: au_pluginui.h:139
AudioUnitCarbonView editView
Definition: au_pluginui.h:149
gint get_preferred_width()
Definition: au_pluginui.h:85
Gtk::Label preset_label
Definition: au_pluginui.h:127
int create_cocoa_view()
void on_window_hide()
bool test_carbon_view_support()
OSStatus carbon_event(EventHandlerCallRef nextHandlerRef, EventRef event)
int alloc_height
Definition: au_pluginui.h:135
void deactivate()
Gtk::ComboBoxText automation_mode_selector
Definition: au_pluginui.h:126
bool non_gtk_gui() const
Definition: au_pluginui.h:93
bool on_window_show(const std::string &)
gint get_preferred_height()
Definition: au_pluginui.h:86
void activate()
int prefheight
Definition: au_pluginui.h:119
bool test_cocoa_view_support()
static int64_t last_timer
Definition: au_pluginui.h:175
LiveResizeNotificationObject * _resize_notify
Definition: au_pluginui.h:157
NSWindow * get_nswindow()
static CFRunLoopTimerRef cf_timer
Definition: au_pluginui.h:173
void end_live_resize()
NSView * au_view
Definition: au_pluginui.h:140
Gtk::VBox vpacker
Definition: au_pluginui.h:124
NSRect last_au_frame
Definition: au_pluginui.h:141
AUPluginUI(std::shared_ptr< ARDOUR::PlugInsertBase >)
static uint64_t timer_callbacks
Definition: au_pluginui.h:177
NotificationObject * _notify
Definition: au_pluginui.h:156
void lower_box_size_request(GtkRequisition *)
bool plugin_class_valid(Class pluginClass)
void start_live_resize()
static uint64_t timer_out_of_range
Definition: au_pluginui.h:178
bool _activating_from_app
Definition: au_pluginui.h:152
void cocoa_view_resized()
Gtk::HBox top_box
Definition: au_pluginui.h:122
static void start_cf_timer()
NSWindow * cocoa_parent
Definition: au_pluginui.h:147
void lower_box_realized()
static bool timer_callback()
bool lower_box_visibility_notify(GdkEventVisibility *)
void lower_box_unmap()
void update_view_size()
static void cf_timer_callback()
ComponentDescription carbon_descriptor
Definition: au_pluginui.h:148
bool resizable
Definition: au_pluginui.h:131
ArdourWidgets::EventBoxExt low_box
Definition: au_pluginui.h:123
WindowRef carbon_window
Definition: au_pluginui.h:150
void lower_box_size_allocate(Gtk::Allocation &)
void forward_key_event(GdkEventKey *)
std::shared_ptr< ARDOUR::AUPlugin > au
Definition: au_pluginui.h:118
int parent_carbon_window()
friend void au_cf_timer_callback(CFRunLoopTimerRef timer, void *info)
void on_realize()
This is a default handler for the signal signal_realize().
static bool timer_needed
Definition: au_pluginui.h:176
static std::vector< std::string > automation_mode_strings
Definition: au_pluginui.h:129
int alloc_width
Definition: au_pluginui.h:134
int req_height
Definition: au_pluginui.h:133
EventHandlerRef carbon_event_handler
Definition: au_pluginui.h:151
static sigc::connection timer_connection
Definition: au_pluginui.h:181
WindowRef wr
Definition: au_pluginui.h:117
bool start_updating(GdkEventAny *)
bool event(GdkEvent *event)
NSWindow * top_level_parent
Definition: au_pluginui.h:69
NSWindow * cocoa_parent
Definition: au_pluginui.h:68
AUPluginUI * plugin_ui
Definition: au_pluginui.h:67
Transmitter info