Make Carbon GUI support for AU's optional at compile time (from Robin)

git-svn-id: svn://localhost/ardour2/branches/3.0@10872 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2011-12-02 20:42:27 +00:00
parent 639bb7dc5d
commit 34909f79ad
2 changed files with 30 additions and 1 deletions

View File

@ -133,7 +133,7 @@ AUPluginUI::AUPluginUI (boost::shared_ptr<PluginInsert> insert)
smaller_hbox->set_spacing (6); smaller_hbox->set_spacing (6);
smaller_hbox->pack_start (preset_label, false, false, 4); smaller_hbox->pack_start (preset_label, false, false, 4);
smaller_hbox->pack_start (_preset_box, false, false); smaller_hbox->pack_start (_preset_combo, false, false);
smaller_hbox->pack_start (save_button, false, false); smaller_hbox->pack_start (save_button, false, false);
#if 0 #if 0
/* one day these might be useful with an AU plugin, but not yet */ /* one day these might be useful with an AU plugin, but not yet */
@ -171,6 +171,7 @@ AUPluginUI::AUPluginUI (boost::shared_ptr<PluginInsert> insert)
cocoa_parent = 0; cocoa_parent = 0;
_notify = 0; _notify = 0;
cocoa_window = 0; cocoa_window = 0;
carbon_window = 0;
au_view = 0; au_view = 0;
editView = 0; editView = 0;
@ -178,8 +179,10 @@ AUPluginUI::AUPluginUI (boost::shared_ptr<PluginInsert> insert)
if (test_cocoa_view_support()) { if (test_cocoa_view_support()) {
create_cocoa_view (); create_cocoa_view ();
#ifdef WITH_CARBON
} else if (test_carbon_view_support()) { } else if (test_carbon_view_support()) {
create_carbon_view (); create_carbon_view ();
#endif
} else { } else {
create_cocoa_view (); create_cocoa_view ();
} }
@ -196,10 +199,12 @@ AUPluginUI::~AUPluginUI ()
} }
#ifdef WITH_CARBON
if (carbon_window) { if (carbon_window) {
/* not parented, just overlaid on top of our window */ /* not parented, just overlaid on top of our window */
DisposeWindow (carbon_window); DisposeWindow (carbon_window);
} }
#endif
if (editView) { if (editView) {
CloseComponent (editView); CloseComponent (editView);
@ -410,6 +415,7 @@ AUPluginUI::cocoa_view_resized ()
int int
AUPluginUI::create_carbon_view () AUPluginUI::create_carbon_view ()
{ {
#ifdef WITH_CARBON
OSStatus err; OSStatus err;
ControlRef root_control; ControlRef root_control;
@ -465,6 +471,10 @@ AUPluginUI::create_carbon_view ()
low_box.set_size_request (prefwidth, prefheight); low_box.set_size_request (prefwidth, prefheight);
return 0; return 0;
#else
error << _("AU Carbon GUI is not supported.") << endmsg;
return -1;
#endif
} }
NSWindow* NSWindow*
@ -490,19 +500,24 @@ AUPluginUI::get_nswindow ()
void void
AUPluginUI::activate () AUPluginUI::activate ()
{ {
#ifdef WITH_CARBON
ActivateWindow (carbon_window, TRUE); ActivateWindow (carbon_window, TRUE);
#endif
// [cocoa_parent makeKeyAndOrderFront:nil]; // [cocoa_parent makeKeyAndOrderFront:nil];
} }
void void
AUPluginUI::deactivate () AUPluginUI::deactivate ()
{ {
#ifdef WITH_CARBON
ActivateWindow (carbon_window, FALSE); ActivateWindow (carbon_window, FALSE);
#endif
} }
int int
AUPluginUI::parent_carbon_window () AUPluginUI::parent_carbon_window ()
{ {
#ifdef WITH_CARBON
NSWindow* win = get_nswindow (); NSWindow* win = get_nswindow ();
int x, y; int x, y;
@ -543,6 +558,9 @@ AUPluginUI::parent_carbon_window ()
[win addChildWindow:cocoa_parent ordered:NSWindowAbove]; [win addChildWindow:cocoa_parent ordered:NSWindowAbove];
return 0; return 0;
#else
return -1;
#endif
} }
int int
@ -647,10 +665,12 @@ AUPluginUI::on_map_event (GdkEventAny*)
void void
AUPluginUI::on_window_hide () AUPluginUI::on_window_hide ()
{ {
#ifdef WITH_CARBON
if (carbon_window) { if (carbon_window) {
HideWindow (carbon_window); HideWindow (carbon_window);
ActivateWindow (carbon_window, FALSE); ActivateWindow (carbon_window, FALSE);
} }
#endif
hide_all (); hide_all ();
} }
@ -664,10 +684,12 @@ AUPluginUI::on_window_show (const string& /*title*/)
show_all (); show_all ();
#ifdef WITH_CARBON
if (carbon_window) { if (carbon_window) {
ShowWindow (carbon_window); ShowWindow (carbon_window);
ActivateWindow (carbon_window, TRUE); ActivateWindow (carbon_window, TRUE);
} }
#endif
return true; return true;
} }

View File

@ -54,6 +54,9 @@
#include <CoreServices/CoreServices.h> #include <CoreServices/CoreServices.h>
#include <AudioUnit/AudioUnit.h> #include <AudioUnit/AudioUnit.h>
#include <AudioToolbox/AudioUnitUtilities.h> #include <AudioToolbox/AudioUnitUtilities.h>
#ifdef WITH_CARBON
#include <Carbon/Carbon.h>
#endif
#include "i18n.h" #include "i18n.h"
@ -2677,7 +2680,11 @@ AUPlugin::set_info (PluginInfoPtr info)
int int
AUPlugin::create_parameter_listener (AUEventListenerProc cb, void* arg, float interval_secs) AUPlugin::create_parameter_listener (AUEventListenerProc cb, void* arg, float interval_secs)
{ {
#ifdef WITH_CARBON
CFRunLoopRef run_loop = (CFRunLoopRef) GetCFRunLoopFromEventLoop(GetCurrentEventLoop()); CFRunLoopRef run_loop = (CFRunLoopRef) GetCFRunLoopFromEventLoop(GetCurrentEventLoop());
#else
CFRunLoopRef run_loop = CFRunLoopGetCurrent();
#endif
CFStringRef loop_mode = kCFRunLoopDefaultMode; CFStringRef loop_mode = kCFRunLoopDefaultMode;
if (AUEventListenerCreate (cb, arg, run_loop, loop_mode, interval_secs, interval_secs, &_parameter_listener) != noErr) { if (AUEventListenerCreate (cb, arg, run_loop, loop_mode, interval_secs, interval_secs, &_parameter_listener) != noErr) {