2008-12-12 09:43:24 -05:00
|
|
|
#undef Marker
|
|
|
|
#define Marker FuckYouAppleAndYourLackOfNameSpaces
|
|
|
|
|
2014-10-07 08:48:08 -04:00
|
|
|
#include <gtkmm/button.h>
|
|
|
|
#include <gdk/gdkquartz.h>
|
|
|
|
|
2010-11-13 00:14:48 -05:00
|
|
|
#include "pbd/convert.h"
|
2009-10-29 20:21:40 -04:00
|
|
|
#include "pbd/error.h"
|
2011-11-09 20:32:34 -05:00
|
|
|
|
2009-10-29 20:21:40 -04:00
|
|
|
#include "ardour/audio_unit.h"
|
2011-11-09 20:32:34 -05:00
|
|
|
#include "ardour/debug.h"
|
2010-11-13 00:14:48 -05:00
|
|
|
#include "ardour/plugin_insert.h"
|
2008-01-10 16:20:59 -05:00
|
|
|
|
2008-02-16 17:43:18 -05:00
|
|
|
#undef check // stupid gtk, stupid apple
|
|
|
|
|
|
|
|
#include <gtkmm2ext/utils.h>
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
#include "au_pluginui.h"
|
|
|
|
#include "gui_thread.h"
|
|
|
|
|
2015-10-18 16:17:31 -04:00
|
|
|
#include "CAAudioUnit.h"
|
|
|
|
#include "CAComponent.h"
|
2008-01-10 16:20:59 -05:00
|
|
|
|
|
|
|
#import <AudioUnit/AUCocoaUIView.h>
|
|
|
|
#import <CoreAudioKit/AUGenericView.h>
|
|
|
|
|
2008-12-12 09:43:24 -05:00
|
|
|
#undef Marker
|
|
|
|
|
|
|
|
#include "keyboard.h"
|
|
|
|
#include "utils.h"
|
|
|
|
#include "public_editor.h"
|
2008-01-10 16:20:59 -05:00
|
|
|
#include "i18n.h"
|
|
|
|
|
2015-10-18 17:29:58 -04:00
|
|
|
#ifdef COREAUDIO105
|
|
|
|
#define ArdourCloseComponent CloseComponent
|
|
|
|
#else
|
|
|
|
#define ArdourCloseComponent AudioComponentInstanceDispose
|
|
|
|
#endif
|
2008-01-10 16:20:59 -05:00
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace Gtk;
|
2008-02-16 17:43:18 -05:00
|
|
|
using namespace Gtkmm2ext;
|
2008-01-10 16:20:59 -05:00
|
|
|
using namespace std;
|
|
|
|
using namespace PBD;
|
|
|
|
|
2008-02-16 17:43:18 -05:00
|
|
|
vector<string> AUPluginUI::automation_mode_strings;
|
|
|
|
|
|
|
|
static const gchar* _automation_mode_strings[] = {
|
|
|
|
X_("Manual"),
|
|
|
|
X_("Play"),
|
|
|
|
X_("Write"),
|
|
|
|
X_("Touch"),
|
|
|
|
0
|
|
|
|
};
|
2008-01-10 16:20:59 -05:00
|
|
|
|
2013-05-01 18:41:28 -04:00
|
|
|
static void
|
2015-10-14 16:26:22 -04:00
|
|
|
dump_view_tree (NSView* view, int depth, int maxdepth)
|
2013-05-01 18:41:28 -04:00
|
|
|
{
|
|
|
|
NSArray* subviews = [view subviews];
|
|
|
|
unsigned long cnt = [subviews count];
|
|
|
|
|
|
|
|
for (int d = 0; d < depth; d++) {
|
|
|
|
cerr << '\t';
|
|
|
|
}
|
2015-10-14 16:26:22 -04:00
|
|
|
NSRect frame = [view frame];
|
2013-05-01 18:41:28 -04:00
|
|
|
cerr << " view @ " << frame.origin.x << ", " << frame.origin.y
|
2015-10-14 16:26:22 -04:00
|
|
|
<< ' ' << frame.size.width << " x " << frame.size.height
|
|
|
|
<< endl;
|
|
|
|
|
|
|
|
if (depth >= maxdepth) {
|
|
|
|
return;
|
|
|
|
}
|
2013-05-01 18:41:28 -04:00
|
|
|
for (unsigned long i = 0; i < cnt; ++i) {
|
|
|
|
NSView* subview = [subviews objectAtIndex:i];
|
2015-10-14 16:26:22 -04:00
|
|
|
dump_view_tree (subview, depth+1, maxdepth);
|
2013-05-01 18:41:28 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-13 00:14:48 -05:00
|
|
|
@implementation NotificationObject
|
|
|
|
|
|
|
|
- (NotificationObject*) initWithPluginUI: (AUPluginUI*) apluginui andCocoaParent: (NSWindow*) cp andTopLevelParent: (NSWindow*) tlp
|
|
|
|
{
|
|
|
|
self = [ super init ];
|
|
|
|
|
|
|
|
if (self) {
|
2015-10-14 16:26:22 -04:00
|
|
|
plugin_ui = apluginui;
|
2010-11-13 00:14:48 -05:00
|
|
|
top_level_parent = tlp;
|
2015-10-14 16:26:22 -04:00
|
|
|
|
|
|
|
if (cp) {
|
|
|
|
cocoa_parent = cp;
|
|
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter]
|
|
|
|
addObserver:self
|
|
|
|
selector:@selector(cocoaParentActivationHandler:)
|
|
|
|
name:NSWindowDidBecomeMainNotification
|
|
|
|
object:NULL];
|
|
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter]
|
|
|
|
addObserver:self
|
|
|
|
selector:@selector(cocoaParentBecameKeyHandler:)
|
|
|
|
name:NSWindowDidBecomeKeyNotification
|
|
|
|
object:NULL];
|
|
|
|
}
|
|
|
|
}
|
2010-11-13 00:14:48 -05:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
2015-10-14 16:26:22 -04:00
|
|
|
|
2010-11-13 00:14:48 -05:00
|
|
|
- (void)cocoaParentActivationHandler:(NSNotification *)notification
|
|
|
|
{
|
|
|
|
NSWindow* notification_window = (NSWindow *)[notification object];
|
|
|
|
|
|
|
|
if (top_level_parent == notification_window || cocoa_parent == notification_window) {
|
|
|
|
if ([notification_window isMainWindow]) {
|
|
|
|
plugin_ui->activate();
|
|
|
|
} else {
|
|
|
|
plugin_ui->deactivate();
|
|
|
|
}
|
2015-10-14 16:26:22 -04:00
|
|
|
}
|
2010-11-13 00:14:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)cocoaParentBecameKeyHandler:(NSNotification *)notification
|
|
|
|
{
|
|
|
|
NSWindow* notification_window = (NSWindow *)[notification object];
|
|
|
|
|
|
|
|
if (top_level_parent == notification_window || cocoa_parent == notification_window) {
|
|
|
|
if ([notification_window isKeyWindow]) {
|
|
|
|
plugin_ui->activate();
|
|
|
|
} else {
|
|
|
|
plugin_ui->deactivate();
|
|
|
|
}
|
2015-10-14 16:26:22 -04:00
|
|
|
}
|
2010-11-13 00:14:48 -05:00
|
|
|
}
|
|
|
|
|
2014-12-25 13:50:00 -05:00
|
|
|
- (void)auViewResized:(NSNotification *)notification
|
2010-11-13 00:14:48 -05:00
|
|
|
{
|
2015-10-14 16:26:22 -04:00
|
|
|
(void) notification; // stop complaints about unusued argument
|
2010-11-13 00:14:48 -05:00
|
|
|
plugin_ui->cocoa_view_resized();
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
AUPluginUI::AUPluginUI (boost::shared_ptr<PluginInsert> insert)
|
|
|
|
: PlugUIBase (insert)
|
2008-02-16 17:43:18 -05:00
|
|
|
, automation_mode_label (_("Automation"))
|
|
|
|
, preset_label (_("Presets"))
|
2015-10-14 16:26:22 -04:00
|
|
|
, mapped (false)
|
|
|
|
, resizable (false)
|
|
|
|
, min_width (0)
|
|
|
|
, min_height (0)
|
|
|
|
, req_width (0)
|
|
|
|
, req_height (0)
|
|
|
|
, alo_width (0)
|
|
|
|
, alo_height (0)
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
{
|
2008-02-16 17:43:18 -05:00
|
|
|
if (automation_mode_strings.empty()) {
|
|
|
|
automation_mode_strings = I18N (_automation_mode_strings);
|
|
|
|
}
|
2015-10-14 16:26:22 -04:00
|
|
|
|
2008-02-16 17:43:18 -05:00
|
|
|
set_popdown_strings (automation_mode_selector, automation_mode_strings);
|
|
|
|
automation_mode_selector.set_active_text (automation_mode_strings.front());
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
if ((au = boost::dynamic_pointer_cast<AUPlugin> (insert->plugin())) == 0) {
|
|
|
|
error << _("unknown type of editor-supplying plugin (note: no AudioUnit support in this version of ardour)") << endmsg;
|
|
|
|
throw failed_constructor ();
|
|
|
|
}
|
|
|
|
|
2008-02-16 17:43:18 -05:00
|
|
|
/* stuff some stuff into the top of the window */
|
|
|
|
|
2008-12-12 09:43:24 -05:00
|
|
|
HBox* smaller_hbox = manage (new HBox);
|
|
|
|
|
2010-11-13 00:14:48 -05:00
|
|
|
smaller_hbox->set_spacing (6);
|
|
|
|
smaller_hbox->pack_start (preset_label, false, false, 4);
|
2015-02-28 02:04:14 -05:00
|
|
|
smaller_hbox->pack_start (_preset_modified, false, false);
|
2011-12-02 15:42:27 -05:00
|
|
|
smaller_hbox->pack_start (_preset_combo, false, false);
|
2015-02-28 02:04:14 -05:00
|
|
|
smaller_hbox->pack_start (add_button, false, false);
|
|
|
|
#if 0
|
|
|
|
/* Ardour does not currently allow to overwrite existing presets
|
|
|
|
* see save_property_list() in audio_unit.cc
|
|
|
|
*/
|
2008-12-12 09:43:24 -05:00
|
|
|
smaller_hbox->pack_start (save_button, false, false);
|
2015-02-28 02:04:14 -05:00
|
|
|
#endif
|
2010-11-13 00:14:48 -05:00
|
|
|
#if 0
|
|
|
|
/* one day these might be useful with an AU plugin, but not yet */
|
2008-12-12 09:43:24 -05:00
|
|
|
smaller_hbox->pack_start (automation_mode_label, false, false);
|
|
|
|
smaller_hbox->pack_start (automation_mode_selector, false, false);
|
2010-11-13 00:14:48 -05:00
|
|
|
#endif
|
2015-05-04 14:52:48 -04:00
|
|
|
smaller_hbox->pack_start (reset_button, false, false);
|
2008-12-12 09:43:24 -05:00
|
|
|
smaller_hbox->pack_start (bypass_button, false, true);
|
|
|
|
|
|
|
|
VBox* v1_box = manage (new VBox);
|
|
|
|
VBox* v2_box = manage (new VBox);
|
|
|
|
|
|
|
|
v1_box->pack_start (*smaller_hbox, false, true);
|
|
|
|
v2_box->pack_start (focus_button, false, true);
|
|
|
|
|
|
|
|
top_box.set_homogeneous (false);
|
2008-02-16 17:43:18 -05:00
|
|
|
top_box.set_spacing (6);
|
|
|
|
top_box.set_border_width (6);
|
|
|
|
|
2008-12-12 09:43:24 -05:00
|
|
|
top_box.pack_end (*v2_box, false, false);
|
|
|
|
top_box.pack_end (*v1_box, false, false);
|
2008-02-16 17:43:18 -05:00
|
|
|
|
|
|
|
set_spacing (6);
|
|
|
|
pack_start (top_box, false, false);
|
2015-10-14 16:26:22 -04:00
|
|
|
pack_start (low_box, true, true);
|
2008-02-16 17:43:18 -05:00
|
|
|
|
|
|
|
preset_label.show ();
|
2011-09-30 13:55:14 -04:00
|
|
|
_preset_combo.show ();
|
2008-02-16 17:43:18 -05:00
|
|
|
automation_mode_label.show ();
|
|
|
|
automation_mode_selector.show ();
|
|
|
|
bypass_button.show ();
|
|
|
|
top_box.show ();
|
|
|
|
low_box.show ();
|
2008-01-10 16:20:59 -05:00
|
|
|
|
|
|
|
cocoa_parent = 0;
|
|
|
|
cocoa_window = 0;
|
2013-04-30 11:15:23 -04:00
|
|
|
|
2015-02-26 13:50:51 -05:00
|
|
|
#ifdef WITH_CARBON
|
2013-04-30 11:15:23 -04:00
|
|
|
_activating_from_app = false;
|
|
|
|
_notify = 0;
|
2008-01-19 00:06:33 -05:00
|
|
|
au_view = 0;
|
2010-11-13 00:14:48 -05:00
|
|
|
editView = 0;
|
2013-04-30 11:15:23 -04:00
|
|
|
carbon_window = 0;
|
|
|
|
#endif
|
2008-01-10 16:20:59 -05:00
|
|
|
|
2008-02-16 17:43:18 -05:00
|
|
|
/* prefer cocoa, fall back to cocoa, but use carbon if its there */
|
2008-01-10 16:20:59 -05:00
|
|
|
|
2008-02-16 17:43:18 -05:00
|
|
|
if (test_cocoa_view_support()) {
|
2008-01-10 16:20:59 -05:00
|
|
|
create_cocoa_view ();
|
2011-12-02 15:42:27 -05:00
|
|
|
#ifdef WITH_CARBON
|
2008-02-16 17:43:18 -05:00
|
|
|
} else if (test_carbon_view_support()) {
|
|
|
|
create_carbon_view ();
|
2011-12-02 15:42:27 -05:00
|
|
|
#endif
|
2008-01-10 16:20:59 -05:00
|
|
|
} else {
|
|
|
|
create_cocoa_view ();
|
|
|
|
}
|
|
|
|
|
2015-10-14 16:26:22 -04:00
|
|
|
low_box.add_events (Gdk::VISIBILITY_NOTIFY_MASK | Gdk::EXPOSURE_MASK);
|
2015-02-27 13:43:19 -05:00
|
|
|
|
2008-02-16 17:43:18 -05:00
|
|
|
low_box.signal_realize().connect (mem_fun (this, &AUPluginUI::lower_box_realized));
|
2015-02-27 13:43:19 -05:00
|
|
|
low_box.signal_visibility_notify_event ().connect (mem_fun (this, &AUPluginUI::lower_box_visibility_notify));
|
2015-10-28 09:09:13 -04:00
|
|
|
if (au_view) {
|
|
|
|
low_box.signal_size_request ().connect (mem_fun (this, &AUPluginUI::lower_box_size_request));
|
|
|
|
low_box.signal_size_allocate ().connect (mem_fun (this, &AUPluginUI::lower_box_size_allocate));
|
|
|
|
low_box.signal_map ().connect (mem_fun (this, &AUPluginUI::lower_box_map));
|
|
|
|
low_box.signal_unmap ().connect (mem_fun (this, &AUPluginUI::lower_box_unmap));
|
|
|
|
low_box.signal_expose_event ().connect (mem_fun (this, &AUPluginUI::lower_box_expose));
|
|
|
|
}
|
2008-02-16 17:43:18 -05:00
|
|
|
}
|
2008-01-10 16:20:59 -05:00
|
|
|
|
|
|
|
AUPluginUI::~AUPluginUI ()
|
|
|
|
{
|
2015-10-14 16:26:22 -04:00
|
|
|
if (_notify) {
|
|
|
|
[[NSNotificationCenter defaultCenter] removeObserver:_notify];
|
|
|
|
}
|
2012-06-02 12:01:18 -04:00
|
|
|
|
2008-02-16 17:43:18 -05:00
|
|
|
if (cocoa_parent) {
|
2008-01-10 16:20:59 -05:00
|
|
|
NSWindow* win = get_nswindow();
|
|
|
|
[win removeChildWindow:cocoa_parent];
|
2015-10-14 16:26:22 -04:00
|
|
|
}
|
2010-11-13 00:14:48 -05:00
|
|
|
|
2011-12-02 15:42:27 -05:00
|
|
|
#ifdef WITH_CARBON
|
2010-11-13 00:14:48 -05:00
|
|
|
if (carbon_window) {
|
|
|
|
/* not parented, just overlaid on top of our window */
|
2008-02-16 17:43:18 -05:00
|
|
|
DisposeWindow (carbon_window);
|
2008-01-10 16:20:59 -05:00
|
|
|
}
|
2011-12-02 15:42:27 -05:00
|
|
|
#endif
|
2008-01-10 16:20:59 -05:00
|
|
|
|
2010-11-13 00:14:48 -05:00
|
|
|
if (editView) {
|
2015-10-18 17:29:58 -04:00
|
|
|
ArdourCloseComponent (editView);
|
2010-11-13 00:14:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (au_view) {
|
2009-07-12 20:26:28 -04:00
|
|
|
/* remove whatever we packed into low_box so that GTK doesn't
|
|
|
|
mess with it.
|
2015-10-14 16:26:22 -04:00
|
|
|
*/
|
2009-07-12 20:26:28 -04:00
|
|
|
|
2010-11-13 00:14:48 -05:00
|
|
|
[au_view removeFromSuperview];
|
2008-04-11 10:06:50 -04:00
|
|
|
}
|
2008-01-10 16:20:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
AUPluginUI::test_carbon_view_support ()
|
|
|
|
{
|
2013-04-30 11:15:23 -04:00
|
|
|
#ifdef WITH_CARBON
|
2008-01-10 16:20:59 -05:00
|
|
|
bool ret = false;
|
2015-10-14 16:26:22 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
carbon_descriptor.componentType = kAudioUnitCarbonViewComponentType;
|
|
|
|
carbon_descriptor.componentSubType = 'gnrc';
|
|
|
|
carbon_descriptor.componentManufacturer = 'appl';
|
|
|
|
carbon_descriptor.componentFlags = 0;
|
|
|
|
carbon_descriptor.componentFlagsMask = 0;
|
2015-10-14 16:26:22 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
OSStatus err;
|
|
|
|
|
|
|
|
// ask the AU for its first editor component
|
|
|
|
UInt32 propertySize;
|
|
|
|
err = AudioUnitGetPropertyInfo(*au->get_au(), kAudioUnitProperty_GetUIComponentList, kAudioUnitScope_Global, 0, &propertySize, NULL);
|
|
|
|
if (!err) {
|
|
|
|
int nEditors = propertySize / sizeof(ComponentDescription);
|
|
|
|
ComponentDescription *editors = new ComponentDescription[nEditors];
|
|
|
|
err = AudioUnitGetProperty(*au->get_au(), kAudioUnitProperty_GetUIComponentList, kAudioUnitScope_Global, 0, editors, &propertySize);
|
|
|
|
if (!err) {
|
|
|
|
// just pick the first one for now
|
|
|
|
carbon_descriptor = editors[0];
|
|
|
|
ret = true;
|
|
|
|
}
|
|
|
|
delete[] editors;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2013-04-30 11:15:23 -04:00
|
|
|
#else
|
2015-10-14 16:26:22 -04:00
|
|
|
return false;
|
2013-04-30 11:15:23 -04:00
|
|
|
#endif
|
2008-01-10 16:20:59 -05:00
|
|
|
}
|
2015-10-14 16:26:22 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
bool
|
|
|
|
AUPluginUI::test_cocoa_view_support ()
|
|
|
|
{
|
|
|
|
UInt32 dataSize = 0;
|
|
|
|
Boolean isWritable = 0;
|
|
|
|
OSStatus err = AudioUnitGetPropertyInfo(*au->get_au(),
|
|
|
|
kAudioUnitProperty_CocoaUI, kAudioUnitScope_Global,
|
|
|
|
0, &dataSize, &isWritable);
|
2015-10-14 16:26:22 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
return dataSize > 0 && err == noErr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
AUPluginUI::plugin_class_valid (Class pluginClass)
|
|
|
|
{
|
|
|
|
if([pluginClass conformsToProtocol: @protocol(AUCocoaUIBase)]) {
|
|
|
|
if([pluginClass instancesRespondToSelector: @selector(interfaceVersion)] &&
|
|
|
|
[pluginClass instancesRespondToSelector: @selector(uiViewForAudioUnit:withSize:)]) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
AUPluginUI::create_cocoa_view ()
|
|
|
|
{
|
2013-04-30 11:15:23 -04:00
|
|
|
bool wasAbleToLoadCustomView = false;
|
2008-01-10 16:20:59 -05:00
|
|
|
AudioUnitCocoaViewInfo* cocoaViewInfo = NULL;
|
|
|
|
UInt32 numberOfClasses = 0;
|
|
|
|
UInt32 dataSize;
|
|
|
|
Boolean isWritable;
|
|
|
|
NSString* factoryClassName = 0;
|
2011-09-30 13:55:14 -04:00
|
|
|
NSURL* CocoaViewBundlePath = NULL;
|
2008-01-10 16:20:59 -05:00
|
|
|
|
|
|
|
OSStatus result = AudioUnitGetPropertyInfo (*au->get_au(),
|
|
|
|
kAudioUnitProperty_CocoaUI,
|
2015-10-14 16:26:22 -04:00
|
|
|
kAudioUnitScope_Global,
|
2008-01-10 16:20:59 -05:00
|
|
|
0,
|
|
|
|
&dataSize,
|
|
|
|
&isWritable );
|
|
|
|
|
|
|
|
numberOfClasses = (dataSize - sizeof(CFURLRef)) / sizeof(CFStringRef);
|
2011-11-09 20:32:34 -05:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
// Does view have custom Cocoa UI?
|
2015-10-14 16:26:22 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
if ((result == noErr) && (numberOfClasses > 0) ) {
|
2011-11-09 20:32:34 -05:00
|
|
|
|
|
|
|
DEBUG_TRACE(DEBUG::AudioUnits,
|
|
|
|
string_compose ( "based on %1, there are %2 cocoa UI classes\n", dataSize, numberOfClasses));
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
cocoaViewInfo = (AudioUnitCocoaViewInfo *)malloc(dataSize);
|
2012-06-01 18:27:10 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
if(AudioUnitGetProperty(*au->get_au(),
|
|
|
|
kAudioUnitProperty_CocoaUI,
|
|
|
|
kAudioUnitScope_Global,
|
|
|
|
0,
|
|
|
|
cocoaViewInfo,
|
|
|
|
&dataSize) == noErr) {
|
|
|
|
|
|
|
|
CocoaViewBundlePath = (NSURL *)cocoaViewInfo->mCocoaAUViewBundleLocation;
|
2015-10-14 16:26:22 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
// we only take the first view in this example.
|
|
|
|
factoryClassName = (NSString *)cocoaViewInfo->mCocoaAUViewClass[0];
|
2015-10-14 16:26:22 -04:00
|
|
|
|
2011-11-09 20:32:34 -05:00
|
|
|
DEBUG_TRACE (DEBUG::AudioUnits, string_compose ("the factory name is %1 bundle is %2\n",
|
2012-06-01 18:27:10 -04:00
|
|
|
[factoryClassName UTF8String], CocoaViewBundlePath));
|
2015-10-14 16:26:22 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
} else {
|
|
|
|
|
2011-11-09 20:32:34 -05:00
|
|
|
DEBUG_TRACE (DEBUG::AudioUnits, string_compose ("No cocoaUI property cocoaViewInfo = %1\n", cocoaViewInfo));
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
if (cocoaViewInfo != NULL) {
|
|
|
|
free (cocoaViewInfo);
|
|
|
|
cocoaViewInfo = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// [A] Show custom UI if view has it
|
|
|
|
|
|
|
|
if (CocoaViewBundlePath && factoryClassName) {
|
|
|
|
NSBundle *viewBundle = [NSBundle bundleWithPath:[CocoaViewBundlePath path]];
|
2011-11-09 20:32:34 -05:00
|
|
|
|
|
|
|
DEBUG_TRACE (DEBUG::AudioUnits, string_compose ("tried to create bundle, result = %1\n", viewBundle));
|
|
|
|
|
2014-10-07 08:48:08 -04:00
|
|
|
if (viewBundle == NULL) {
|
2008-01-10 16:20:59 -05:00
|
|
|
error << _("AUPluginUI: error loading AU view's bundle") << endmsg;
|
|
|
|
return -1;
|
|
|
|
} else {
|
|
|
|
Class factoryClass = [viewBundle classNamed:factoryClassName];
|
2011-11-09 20:32:34 -05:00
|
|
|
DEBUG_TRACE (DEBUG::AudioUnits, string_compose ("tried to create factory class, result = %1\n", factoryClass));
|
2008-01-10 16:20:59 -05:00
|
|
|
if (!factoryClass) {
|
|
|
|
error << _("AUPluginUI: error getting AU view's factory class from bundle") << endmsg;
|
|
|
|
return -1;
|
|
|
|
}
|
2015-10-14 16:26:22 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
// make sure 'factoryClass' implements the AUCocoaUIBase protocol
|
|
|
|
if (!plugin_class_valid (factoryClass)) {
|
|
|
|
error << _("AUPluginUI: U view's factory class does not properly implement the AUCocoaUIBase protocol") << endmsg;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
// make a factory
|
2012-06-01 18:27:10 -04:00
|
|
|
id factory = [[[factoryClass alloc] init] autorelease];
|
2014-10-07 08:48:08 -04:00
|
|
|
if (factory == NULL) {
|
2008-01-10 16:20:59 -05:00
|
|
|
error << _("AUPluginUI: Could not create an instance of the AU view factory") << endmsg;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-11-09 20:32:34 -05:00
|
|
|
DEBUG_TRACE (DEBUG::AudioUnits, "got a factory instance\n");
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
// make a view
|
2012-06-01 18:27:10 -04:00
|
|
|
au_view = [factory uiViewForAudioUnit:*au->get_au() withSize:NSZeroSize];
|
2011-11-09 20:32:34 -05:00
|
|
|
|
|
|
|
DEBUG_TRACE (DEBUG::AudioUnits, string_compose ("view created @ %1\n", au_view));
|
2015-10-14 16:26:22 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
// cleanup
|
|
|
|
[CocoaViewBundlePath release];
|
|
|
|
if (cocoaViewInfo) {
|
|
|
|
UInt32 i;
|
|
|
|
for (i = 0; i < numberOfClasses; i++)
|
|
|
|
CFRelease(cocoaViewInfo->mCocoaAUViewClass[i]);
|
2015-10-14 16:26:22 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
free (cocoaViewInfo);
|
|
|
|
}
|
2013-04-30 11:15:23 -04:00
|
|
|
wasAbleToLoadCustomView = true;
|
2008-01-10 16:20:59 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!wasAbleToLoadCustomView) {
|
2008-02-16 17:43:18 -05:00
|
|
|
// load generic Cocoa view
|
2011-11-09 20:32:34 -05:00
|
|
|
DEBUG_TRACE (DEBUG::AudioUnits, string_compose ("Loading generic view using %1 -> %2\n", au,
|
|
|
|
au->get_au()));
|
2008-01-10 16:20:59 -05:00
|
|
|
au_view = [[AUGenericView alloc] initWithAudioUnit:*au->get_au()];
|
2011-11-09 20:32:34 -05:00
|
|
|
DEBUG_TRACE (DEBUG::AudioUnits, string_compose ("view created @ %1\n", au_view));
|
2013-04-30 11:15:23 -04:00
|
|
|
[(AUGenericView *)au_view setShowsExpertParameters:1];
|
2008-01-10 16:20:59 -05:00
|
|
|
}
|
|
|
|
|
2015-10-14 16:26:22 -04:00
|
|
|
// Get the initial size of the new AU View's frame
|
|
|
|
NSRect frame = [au_view frame];
|
|
|
|
min_width = req_width = CGRectGetWidth(NSRectToCGRect(frame));
|
|
|
|
min_height = req_height = CGRectGetHeight(NSRectToCGRect(frame));
|
|
|
|
resizable = [au_view autoresizingMask];
|
|
|
|
|
|
|
|
low_box.queue_resize ();
|
2013-04-30 11:15:23 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-11-13 00:14:48 -05:00
|
|
|
void
|
|
|
|
AUPluginUI::cocoa_view_resized ()
|
|
|
|
{
|
2015-10-14 16:26:22 -04:00
|
|
|
if (!mapped || alo_width == 0 || alo_height == 0 || !resizable) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* check for self-resizing plugins (e.g expand settings in AUSampler)
|
|
|
|
* if the widget expands it moves its y-offset (cocoa y-axis points towards the top)
|
|
|
|
*/
|
|
|
|
NSRect new_au_frame = [au_view frame];
|
2012-06-01 18:27:10 -04:00
|
|
|
|
2015-10-14 16:26:22 -04:00
|
|
|
//float dx = last_au_frame.origin.x - new_au_frame.origin.x;
|
|
|
|
float dy = last_au_frame.origin.y - new_au_frame.origin.y;
|
|
|
|
//req_width += dx;
|
|
|
|
req_height += dy;
|
|
|
|
if (req_width < min_width) req_width = min_width;
|
|
|
|
if (req_height < min_height) req_height = min_height;
|
2013-05-01 18:41:28 -04:00
|
|
|
|
2015-10-14 16:26:22 -04:00
|
|
|
last_au_frame = new_au_frame;
|
|
|
|
low_box.queue_resize ();
|
2010-11-13 00:14:48 -05:00
|
|
|
}
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
int
|
2008-02-16 17:43:18 -05:00
|
|
|
AUPluginUI::create_carbon_view ()
|
2008-01-10 16:20:59 -05:00
|
|
|
{
|
2011-12-02 15:42:27 -05:00
|
|
|
#ifdef WITH_CARBON
|
2008-01-10 16:20:59 -05:00
|
|
|
OSStatus err;
|
|
|
|
ControlRef root_control;
|
|
|
|
|
|
|
|
Component editComponent = FindNextComponent(NULL, &carbon_descriptor);
|
2015-10-14 16:26:22 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
OpenAComponent(editComponent, &editView);
|
|
|
|
if (!editView) {
|
|
|
|
error << _("AU Carbon view: cannot open AU Component") << endmsg;
|
|
|
|
return -1;
|
|
|
|
}
|
2015-10-14 16:26:22 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
Rect r = { 100, 100, 100, 100 };
|
|
|
|
WindowAttributes attr = WindowAttributes (kWindowStandardHandlerAttribute |
|
|
|
|
kWindowCompositingAttribute|
|
|
|
|
kWindowNoShadowAttribute|
|
|
|
|
kWindowNoTitleBarAttribute);
|
|
|
|
|
2015-02-27 13:43:19 -05:00
|
|
|
if ((err = CreateNewWindow(kUtilityWindowClass, attr, &r, &carbon_window)) != noErr) {
|
2008-01-10 16:20:59 -05:00
|
|
|
error << string_compose (_("AUPluginUI: cannot create carbon window (err: %1)"), err) << endmsg;
|
2015-10-18 17:29:58 -04:00
|
|
|
ArdourCloseComponent (editView);
|
2008-01-10 16:20:59 -05:00
|
|
|
return -1;
|
|
|
|
}
|
2015-10-14 16:26:22 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
if ((err = GetRootControl(carbon_window, &root_control)) != noErr) {
|
|
|
|
error << string_compose (_("AUPlugin: cannot get root control of carbon window (err: %1)"), err) << endmsg;
|
2010-11-13 00:14:48 -05:00
|
|
|
DisposeWindow (carbon_window);
|
2015-10-18 17:29:58 -04:00
|
|
|
ArdourCloseComponent (editView);
|
2008-01-10 16:20:59 -05:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ControlRef viewPane;
|
|
|
|
Float32Point location = { 0.0, 0.0 };
|
|
|
|
Float32Point size = { 0.0, 0.0 } ;
|
|
|
|
|
|
|
|
if ((err = AudioUnitCarbonViewCreate (editView, *au->get_au(), carbon_window, root_control, &location, &size, &viewPane)) != noErr) {
|
|
|
|
error << string_compose (_("AUPluginUI: cannot create carbon plugin view (err: %1)"), err) << endmsg;
|
2010-11-13 00:14:48 -05:00
|
|
|
DisposeWindow (carbon_window);
|
2015-10-18 17:29:58 -04:00
|
|
|
ArdourCloseComponent (editView);
|
2008-01-10 16:20:59 -05:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// resize window
|
|
|
|
|
|
|
|
Rect bounds;
|
|
|
|
GetControlBounds(viewPane, &bounds);
|
|
|
|
size.x = bounds.right-bounds.left;
|
|
|
|
size.y = bounds.bottom-bounds.top;
|
|
|
|
|
2015-10-14 16:26:22 -04:00
|
|
|
req_width = (int) (size.x + 0.5);
|
|
|
|
req_height = (int) (size.y + 0.5);
|
2008-01-10 16:20:59 -05:00
|
|
|
|
2015-10-28 09:09:13 -04:00
|
|
|
SizeWindow (carbon_window, req_width, req_height, true);
|
|
|
|
low_box.set_size_request (req_width, req_height);
|
2008-02-16 17:43:18 -05:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
return 0;
|
2011-12-02 15:42:27 -05:00
|
|
|
#else
|
|
|
|
error << _("AU Carbon GUI is not supported.") << endmsg;
|
|
|
|
return -1;
|
|
|
|
#endif
|
2008-01-10 16:20:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
NSWindow*
|
|
|
|
AUPluginUI::get_nswindow ()
|
|
|
|
{
|
|
|
|
Gtk::Container* toplevel = get_toplevel();
|
|
|
|
|
|
|
|
if (!toplevel || !toplevel->is_toplevel()) {
|
|
|
|
error << _("AUPluginUI: no top level window!") << endmsg;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
NSWindow* true_parent = gdk_quartz_window_get_nswindow (toplevel->get_window()->gobj());
|
|
|
|
|
|
|
|
if (!true_parent) {
|
|
|
|
error << _("AUPluginUI: no top level window!") << endmsg;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true_parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AUPluginUI::activate ()
|
|
|
|
{
|
2011-12-02 15:42:27 -05:00
|
|
|
#ifdef WITH_CARBON
|
2010-11-13 00:14:48 -05:00
|
|
|
ActivateWindow (carbon_window, TRUE);
|
2011-12-02 15:42:27 -05:00
|
|
|
#endif
|
2008-01-10 16:20:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AUPluginUI::deactivate ()
|
|
|
|
{
|
2011-12-02 15:42:27 -05:00
|
|
|
#ifdef WITH_CARBON
|
2008-02-16 17:43:18 -05:00
|
|
|
ActivateWindow (carbon_window, FALSE);
|
2011-12-02 15:42:27 -05:00
|
|
|
#endif
|
2008-01-10 16:20:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
AUPluginUI::parent_carbon_window ()
|
|
|
|
{
|
2011-12-02 15:42:27 -05:00
|
|
|
#ifdef WITH_CARBON
|
2008-01-10 16:20:59 -05:00
|
|
|
NSWindow* win = get_nswindow ();
|
2012-07-23 10:22:27 -04:00
|
|
|
Rect windowStructureBoundsRect;
|
2008-01-10 16:20:59 -05:00
|
|
|
|
|
|
|
if (!win) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-07-23 10:22:27 -04:00
|
|
|
/* figure out where the cocoa parent window is in carbon-coordinate space, which
|
|
|
|
differs from both cocoa-coordinate space and GTK-coordinate space
|
|
|
|
*/
|
|
|
|
|
|
|
|
GetWindowBounds((WindowRef) [win windowRef], kWindowStructureRgn, &windowStructureBoundsRect);
|
2008-01-10 16:20:59 -05:00
|
|
|
|
|
|
|
/* compute how tall the title bar is, because we have to offset the position of the carbon window
|
|
|
|
by that much.
|
|
|
|
*/
|
|
|
|
|
|
|
|
NSRect content_frame = [NSWindow contentRectForFrameRect:[win frame] styleMask:[win styleMask]];
|
|
|
|
NSRect wm_frame = [NSWindow frameRectForContentRect:content_frame styleMask:[win styleMask]];
|
|
|
|
|
|
|
|
int titlebar_height = wm_frame.size.height - content_frame.size.height;
|
|
|
|
|
2008-02-16 17:43:18 -05:00
|
|
|
int packing_extra = 6; // this is the total vertical packing in our top level window
|
|
|
|
|
2012-07-23 10:22:27 -04:00
|
|
|
/* move into position, based on parent window position */
|
2015-10-14 16:26:22 -04:00
|
|
|
MoveWindow (carbon_window,
|
|
|
|
windowStructureBoundsRect.left,
|
|
|
|
windowStructureBoundsRect.top + titlebar_height + top_box.get_height() + packing_extra,
|
2012-07-23 10:22:27 -04:00
|
|
|
false);
|
|
|
|
ShowWindow (carbon_window);
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
// create the cocoa window for the carbon one and make it visible
|
|
|
|
cocoa_parent = [[NSWindow alloc] initWithWindowRef: carbon_window];
|
|
|
|
|
2010-11-13 00:14:48 -05:00
|
|
|
SetWindowActivationScope (carbon_window, kWindowActivationScopeNone);
|
|
|
|
|
2015-10-14 16:26:22 -04:00
|
|
|
_notify = [ [NotificationObject alloc] initWithPluginUI:this andCocoaParent:cocoa_parent andTopLevelParent:win ];
|
2008-01-10 16:20:59 -05:00
|
|
|
|
|
|
|
[win addChildWindow:cocoa_parent ordered:NSWindowAbove];
|
2015-02-27 13:43:19 -05:00
|
|
|
[win setAutodisplay:1]; // turn of GTK stuff for this window
|
2008-01-10 16:20:59 -05:00
|
|
|
|
|
|
|
return 0;
|
2011-12-02 15:42:27 -05:00
|
|
|
#else
|
|
|
|
return -1;
|
|
|
|
#endif
|
2015-10-14 16:26:22 -04:00
|
|
|
}
|
2008-01-10 16:20:59 -05:00
|
|
|
|
|
|
|
int
|
|
|
|
AUPluginUI::parent_cocoa_window ()
|
|
|
|
{
|
|
|
|
NSWindow* win = get_nswindow ();
|
|
|
|
|
|
|
|
if (!win) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2015-10-14 16:26:22 -04:00
|
|
|
//[win setAutodisplay:1]; // turn off GTK stuff for this window
|
2010-11-13 00:14:48 -05:00
|
|
|
|
2015-10-14 16:26:22 -04:00
|
|
|
NSView* view = gdk_quartz_window_get_nsview (low_box.get_window()->gobj());
|
|
|
|
[view addSubview:au_view];
|
2012-06-01 18:27:10 -04:00
|
|
|
|
2015-10-14 16:26:22 -04:00
|
|
|
gint xx, yy;
|
|
|
|
gtk_widget_translate_coordinates(
|
|
|
|
GTK_WIDGET(low_box.gobj()),
|
|
|
|
GTK_WIDGET(low_box.get_parent()->gobj()),
|
|
|
|
8, 6, &xx, &yy);
|
|
|
|
[au_view setFrame:NSMakeRect(xx, yy, req_width, req_height)];
|
2013-05-01 18:41:28 -04:00
|
|
|
|
2015-10-14 16:26:22 -04:00
|
|
|
last_au_frame = [au_view frame];
|
2012-06-01 18:27:10 -04:00
|
|
|
// watch for size changes of the view
|
2014-10-07 08:48:08 -04:00
|
|
|
_notify = [ [NotificationObject alloc] initWithPluginUI:this andCocoaParent:NULL andTopLevelParent:win ];
|
2012-06-01 18:27:10 -04:00
|
|
|
|
2015-10-14 16:26:22 -04:00
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:_notify
|
|
|
|
selector:@selector(auViewResized:) name:NSViewFrameDidChangeNotification
|
|
|
|
object:au_view];
|
2008-01-10 16:20:59 -05:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-02-20 21:16:04 -05:00
|
|
|
void
|
|
|
|
AUPluginUI::grab_focus()
|
|
|
|
{
|
|
|
|
if (au_view) {
|
|
|
|
[au_view becomeFirstResponder];
|
|
|
|
}
|
|
|
|
}
|
2010-11-13 00:14:48 -05:00
|
|
|
void
|
|
|
|
AUPluginUI::forward_key_event (GdkEventKey* ev)
|
|
|
|
{
|
|
|
|
NSEvent* nsevent = gdk_quartz_event_get_nsevent ((GdkEvent*)ev);
|
|
|
|
|
|
|
|
if (au_view && nsevent) {
|
|
|
|
|
|
|
|
/* filter on nsevent type here because GDK massages FlagsChanged
|
|
|
|
messages into GDK_KEY_{PRESS,RELEASE} but Cocoa won't
|
|
|
|
handle a FlagsChanged message as a keyDown or keyUp
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ([nsevent type] == NSKeyDown) {
|
|
|
|
[[[au_view window] firstResponder] keyDown:nsevent];
|
|
|
|
} else if ([nsevent type] == NSKeyUp) {
|
|
|
|
[[[au_view window] firstResponder] keyUp:nsevent];
|
|
|
|
} else if ([nsevent type] == NSFlagsChanged) {
|
|
|
|
[[[au_view window] firstResponder] flagsChanged:nsevent];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
void
|
|
|
|
AUPluginUI::on_realize ()
|
|
|
|
{
|
|
|
|
VBox::on_realize ();
|
|
|
|
|
2008-02-16 17:43:18 -05:00
|
|
|
/* our windows should not have that resize indicator */
|
2008-01-10 16:20:59 -05:00
|
|
|
|
2008-02-16 17:43:18 -05:00
|
|
|
NSWindow* win = get_nswindow ();
|
|
|
|
if (win) {
|
2013-04-30 11:15:23 -04:00
|
|
|
[win setShowsResizeIndicator:0];
|
2008-02-16 17:43:18 -05:00
|
|
|
}
|
|
|
|
}
|
2008-01-10 16:20:59 -05:00
|
|
|
|
2008-02-16 17:43:18 -05:00
|
|
|
void
|
|
|
|
AUPluginUI::lower_box_realized ()
|
|
|
|
{
|
|
|
|
if (au_view) {
|
|
|
|
parent_cocoa_window ();
|
|
|
|
} else if (carbon_window) {
|
|
|
|
parent_carbon_window ();
|
2008-01-10 16:20:59 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-27 13:43:19 -05:00
|
|
|
bool
|
|
|
|
AUPluginUI::lower_box_visibility_notify (GdkEventVisibility* ev)
|
|
|
|
{
|
|
|
|
#ifdef WITH_CARBON
|
|
|
|
if (carbon_window && ev->state != GDK_VISIBILITY_UNOBSCURED) {
|
|
|
|
ShowWindow (carbon_window);
|
|
|
|
ActivateWindow (carbon_window, TRUE);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-10-14 16:26:22 -04:00
|
|
|
void
|
|
|
|
AUPluginUI::update_view_size ()
|
|
|
|
{
|
|
|
|
if (!mapped || alo_width == 0 || alo_height == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
gint xx, yy;
|
|
|
|
gtk_widget_translate_coordinates(
|
|
|
|
GTK_WIDGET(low_box.gobj()),
|
|
|
|
GTK_WIDGET(low_box.get_parent()->gobj()),
|
|
|
|
8, 6, &xx, &yy);
|
|
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter] removeObserver:_notify
|
|
|
|
name:NSViewFrameDidChangeNotification
|
|
|
|
object:au_view];
|
|
|
|
|
|
|
|
if (!resizable) {
|
|
|
|
xx += (alo_width - req_width) * .5;
|
|
|
|
[au_view setFrame:NSMakeRect(xx, yy, req_width, req_height)];
|
|
|
|
} else {
|
|
|
|
/* this mitigates issues with plugins that resize themselves
|
|
|
|
* depending on visible options (e.g AUSampler)
|
|
|
|
* since the OSX y-axis points upwards, the plugin adjusts its
|
|
|
|
* own y-offset if the view expands to the bottom to accomodate
|
|
|
|
* subviews inside the main view.
|
|
|
|
*/
|
|
|
|
[au_view setAutoresizesSubviews:0];
|
|
|
|
[au_view setFrame:NSMakeRect(xx, yy, alo_width, alo_height)];
|
|
|
|
[au_view setAutoresizesSubviews:1];
|
|
|
|
[au_view setNeedsDisplay:1];
|
|
|
|
}
|
|
|
|
|
|
|
|
last_au_frame = [au_view frame];
|
|
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter]
|
|
|
|
addObserver:_notify
|
|
|
|
selector:@selector(auViewResized:) name:NSViewFrameDidChangeNotification
|
|
|
|
object:au_view];
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AUPluginUI::lower_box_map ()
|
|
|
|
{
|
|
|
|
mapped = true;
|
|
|
|
[au_view setHidden:0];
|
|
|
|
update_view_size ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AUPluginUI::lower_box_unmap ()
|
|
|
|
{
|
|
|
|
mapped = false;
|
|
|
|
[au_view setHidden:1];
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AUPluginUI::lower_box_size_request (GtkRequisition* requisition)
|
|
|
|
{
|
|
|
|
requisition->width = req_width;
|
|
|
|
requisition->height = req_height;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AUPluginUI::lower_box_size_allocate (Gtk::Allocation& allocation)
|
|
|
|
{
|
|
|
|
alo_width = allocation.get_width ();
|
|
|
|
alo_height = allocation.get_height ();
|
|
|
|
update_view_size ();
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
AUPluginUI::lower_box_expose (GdkEventExpose* event)
|
|
|
|
{
|
2015-10-28 09:02:57 -04:00
|
|
|
#if 0 // AU view magically redraws by itself
|
2015-10-14 16:26:22 -04:00
|
|
|
[au_view drawRect:NSMakeRect(event->area.x,
|
|
|
|
event->area.y,
|
|
|
|
event->area.width,
|
|
|
|
event->area.height)];
|
2015-10-28 09:02:57 -04:00
|
|
|
#endif
|
2015-10-20 13:14:14 -04:00
|
|
|
/* hack to keep ardour responsive
|
|
|
|
* some UIs (e.g Addictive Drums) completely hog the CPU
|
|
|
|
*/
|
|
|
|
ARDOUR::GUIIdle();
|
|
|
|
|
2015-10-14 16:26:22 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
void
|
2010-11-13 00:14:48 -05:00
|
|
|
AUPluginUI::on_window_hide ()
|
2008-01-10 16:20:59 -05:00
|
|
|
{
|
2011-12-02 15:42:27 -05:00
|
|
|
#ifdef WITH_CARBON
|
2010-11-13 00:14:48 -05:00
|
|
|
if (carbon_window) {
|
|
|
|
HideWindow (carbon_window);
|
|
|
|
ActivateWindow (carbon_window, FALSE);
|
|
|
|
}
|
2011-12-02 15:42:27 -05:00
|
|
|
#endif
|
2010-11-13 00:14:48 -05:00
|
|
|
hide_all ();
|
2015-10-14 16:26:22 -04:00
|
|
|
|
2013-05-01 18:41:28 -04:00
|
|
|
#if 0
|
2015-10-14 16:26:22 -04:00
|
|
|
NSArray* wins = [NSApp windows];
|
|
|
|
for (uint32_t i = 0; i < [wins count]; i++) {
|
|
|
|
id win = [wins objectAtIndex:i];
|
|
|
|
}
|
2013-05-01 18:41:28 -04:00
|
|
|
#endif
|
2010-11-13 00:14:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
AUPluginUI::on_window_show (const string& /*title*/)
|
|
|
|
{
|
|
|
|
/* this is idempotent so just call it every time we show the window */
|
2008-01-10 16:20:59 -05:00
|
|
|
|
2008-02-16 17:43:18 -05:00
|
|
|
gtk_widget_realize (GTK_WIDGET(low_box.gobj()));
|
|
|
|
|
2010-11-13 00:14:48 -05:00
|
|
|
show_all ();
|
|
|
|
|
2011-12-02 15:42:27 -05:00
|
|
|
#ifdef WITH_CARBON
|
2010-11-13 00:14:48 -05:00
|
|
|
if (carbon_window) {
|
2008-01-19 00:06:33 -05:00
|
|
|
ShowWindow (carbon_window);
|
2010-11-13 00:14:48 -05:00
|
|
|
ActivateWindow (carbon_window, TRUE);
|
2008-01-10 16:20:59 -05:00
|
|
|
}
|
2011-12-02 15:42:27 -05:00
|
|
|
#endif
|
2010-11-13 00:14:48 -05:00
|
|
|
|
|
|
|
return true;
|
2008-01-10 16:20:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-11-13 00:14:48 -05:00
|
|
|
AUPluginUI::start_updating (GdkEventAny*)
|
2008-01-10 16:20:59 -05:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-11-13 00:14:48 -05:00
|
|
|
AUPluginUI::stop_updating (GdkEventAny*)
|
2008-01-10 16:20:59 -05:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
PlugUIBase*
|
|
|
|
create_au_gui (boost::shared_ptr<PluginInsert> plugin_insert, VBox** box)
|
|
|
|
{
|
|
|
|
AUPluginUI* aup = new AUPluginUI (plugin_insert);
|
|
|
|
(*box) = aup;
|
|
|
|
return aup;
|
|
|
|
}
|
2008-01-19 00:06:33 -05:00
|
|
|
|
2008-02-16 17:43:18 -05:00
|
|
|
|