Remove confusing track / group members in TimeSelection struct; time selection
[ardour.git] / gtk2_ardour / au_pluginui.mm
index 4dfa62275af98d7a6a39bc4b01b5ce4bb0f14530..cb58f67f6fb616bb2dc379f0324c43440deeda45 100644 (file)
@@ -1,6 +1,9 @@
-#include <pbd/error.h>
-#include <ardour/audio_unit.h>
-#include <ardour/insert.h>
+#undef  Marker
+#define Marker FuckYouAppleAndYourLackOfNameSpaces
+
+#include "pbd/error.h"
+#include "ardour/audio_unit.h"
+#include "ardour/insert.h"
 
 #undef check // stupid gtk, stupid apple
 
 #import <AudioUnit/AUCocoaUIView.h>
 #import <CoreAudioKit/AUGenericView.h>
 
+#undef Marker
+
+#include "keyboard.h"
+#include "utils.h"
+#include "public_editor.h"
 #include "i18n.h"
 
 using namespace ARDOUR;
@@ -57,15 +65,27 @@ AUPluginUI::AUPluginUI (boost::shared_ptr<PluginInsert> insert)
 
        /* stuff some stuff into the top of the window */
 
+       HBox* smaller_hbox = manage (new HBox);
+
+       smaller_hbox->pack_start (preset_label, false, false, 10);
+       smaller_hbox->pack_start (preset_combo, false, false);
+       smaller_hbox->pack_start (save_button, false, false);
+       smaller_hbox->pack_start (automation_mode_label, false, false);
+       smaller_hbox->pack_start (automation_mode_selector, false, false);
+       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);
        top_box.set_spacing (6);
        top_box.set_border_width (6);
 
-       top_box.pack_end (bypass_button, false, true);
-       top_box.pack_end (automation_mode_selector, false, false);
-       top_box.pack_end (automation_mode_label, false, false);
-       top_box.pack_end (save_button, false, false);
-       top_box.pack_end (preset_combo, false, false);
-       top_box.pack_end (preset_label, false, false);
+       top_box.pack_end (*v2_box, false, false);
+       top_box.pack_end (*v1_box, false, false);
 
        set_spacing (6);
        pack_start (top_box, false, false);
@@ -83,6 +103,7 @@ AUPluginUI::AUPluginUI (boost::shared_ptr<PluginInsert> insert)
        cocoa_parent = 0;
        cocoa_window = 0;
        au_view = 0;
+       packView = 0;
 
        /* prefer cocoa, fall back to cocoa, but use carbon if its there */
 
@@ -108,6 +129,13 @@ AUPluginUI::~AUPluginUI ()
                DisposeWindow (carbon_window);
        }
 
+       if (packView) {
+               /* remove whatever we packed into low_box so that GTK doesn't
+                  mess with it.
+               */
+
+               [packView removeFromSuperview];
+       }
 }
 
 bool
@@ -260,6 +288,14 @@ AUPluginUI::create_cocoa_view ()
                [(AUGenericView *)au_view setShowsExpertParameters:YES];
        }
 
+       packView = au_view;
+       
+       // Get the size of the new AU View's frame 
+       NSRect packFrame;
+       packFrame = [au_view frame];
+       prefwidth = packFrame.size.width;
+       prefheight = packFrame.size.height;
+
        return 0;
 }
 
@@ -341,8 +377,6 @@ AUPluginUI::get_nswindow ()
 void
 AUPluginUI::activate ()
 {
-       cerr << "AUPluginUI:: activate!\n";
-       return;
        if (carbon_window && cocoa_parent) {
                cerr << "APP activated, activate carbon window " << insert->name() << endl;
                _activating_from_app = true;
@@ -355,7 +389,7 @@ AUPluginUI::activate ()
 void
 AUPluginUI::deactivate ()
 {
-       return;
+       return;
        cerr << "APP DEactivated, for " << insert->name() << endl;
        _activating_from_app = true;
        ActivateWindow (carbon_window, FALSE);
@@ -392,7 +426,7 @@ AUPluginUI::carbon_event (EventHandlerCallRef nextHandlerRef, EventRef event)
                break;
 
        case kEventWindowHandleDeactivate:
-               cerr << "carbon window for " << insert->name() << " deactivated\n";
+               cerr << "carbon window for " << insert->name() << " would have been deactivated\n";
                // never deactivate the carbon window
                return noErr;
                break;
@@ -467,13 +501,14 @@ int
 AUPluginUI::parent_cocoa_window ()
 {
        NSWindow* win = get_nswindow ();
-       NSView* packView = 0;
        NSRect packFrame;
 
        if (!win) {
                return -1;
        }
 
+       [win setAutodisplay:YES]; // turn of GTK stuff for this window
+
        Gtk::Container* toplevel = get_toplevel();
 
        if (!toplevel || !toplevel->is_toplevel()) {
@@ -483,43 +518,10 @@ AUPluginUI::parent_cocoa_window ()
        
        // Get the size of the new AU View's frame 
        packFrame = [au_view frame];
-       packFrame.origin.x = 0;
-       packFrame.origin.y = 0;
-
-       if (packFrame.size.width > 500 || packFrame.size.height > 500) {
-               
-               /* its too big - use a scrollview */
-
-               NSRect frameRect = [[cocoa_window contentView] frame];
-               scroll_view = [[[NSScrollView alloc] initWithFrame:frameRect] autorelease];
-               [scroll_view setDrawsBackground:NO];
-               [scroll_view setHasHorizontalScroller:YES];
-               [scroll_view setHasVerticalScroller:YES];
-
-               packFrame.size = [NSScrollView  frameSizeForContentSize:packFrame.size
-                                   hasHorizontalScroller:[scroll_view hasHorizontalScroller]
-                                   hasVerticalScroller:[scroll_view hasVerticalScroller]
-                                   borderType:[scroll_view borderType]];
-               
-               // Create a new frame with same origin as current
-               // frame but size equal to the size of the new view
-               NSRect newFrame;
-               newFrame.origin = [scroll_view frame].origin;
-               newFrame.size = packFrame.size;
-               
-               // Set the new frame and document views on the scroll view
-               [scroll_view setFrame:newFrame];
-               [scroll_view setDocumentView:au_view];
-               
-               packView = scroll_view;
-
-       } else {
-
-               packView = au_view;
-       }
 
        NSView* view = gdk_quartz_window_get_nsview (low_box.get_window()->gobj());
        
+
        [view setFrame:packFrame];
        [view addSubview:packView]; 
 
@@ -561,17 +563,6 @@ AUPluginUI::on_hide ()
 bool
 AUPluginUI::on_map_event (GdkEventAny* ev)
 {
-       cerr << "AU plugin map event\n";
-
-       if (carbon_window) {
-
-               // move top level GTK window to the correct level
-               // to keep the stack together and not be sliceable
-               
-               NSWindow* win = get_nswindow ();
-               // [win setLevel:NSFloatingWindowLevel];
-       }
-
        return false;
 }
 
@@ -615,14 +606,16 @@ create_au_gui (boost::shared_ptr<PluginInsert> plugin_insert, VBox** box)
 bool
 AUPluginUI::on_focus_in_event (GdkEventFocus* ev)
 {
-       cerr << "au plugin focus in\n";
+       //cerr << "au plugin focus in\n";
+       //Keyboard::magic_widget_grab_focus ();
        return false;
 }
 
 bool
 AUPluginUI::on_focus_out_event (GdkEventFocus* ev)
 {
-       cerr << "au plugin focus out\n";
+       //cerr << "au plugin focus out\n";
+       //Keyboard::magic_widget_drop_focus ();
        return false;
 }