summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2012-06-02 15:56:32 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2012-06-02 15:56:32 +0000
commit8d6b9dbd474c83f59eded69c84fa55870e0d0346 (patch)
tree528a165407aa4c654a554092f9576f20314c043e /gtk2_ardour
parent3c29f2dcbe0b84588a5caf381c9f99784ff12767 (diff)
backport AU GUI plugin resizing from 3.0 (not yet tested with 2.X)
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@12544 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/au_pluginui.mm82
1 files changed, 56 insertions, 26 deletions
diff --git a/gtk2_ardour/au_pluginui.mm b/gtk2_ardour/au_pluginui.mm
index 9f9a59b233..81c065ef74 100644
--- a/gtk2_ardour/au_pluginui.mm
+++ b/gtk2_ardour/au_pluginui.mm
@@ -53,19 +53,22 @@ static const gchar* _automation_mode_strings[] = {
if (self) {
plugin_ui = apluginui;
- cocoa_parent = cp;
top_level_parent = tlp;
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(cocoaParentActivationHandler:)
- name:NSWindowDidBecomeMainNotification
- object:nil];
-
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(cocoaParentBecameKeyHandler:)
- name:NSWindowDidBecomeKeyNotification
- object:nil];
- }
+ if (cp) {
+ cocoa_parent = cp;
+
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(cocoaParentActivationHandler:)
+ name:NSWindowDidBecomeMainNotification
+ object:nil];
+
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(cocoaParentBecameKeyHandler:)
+ name:NSWindowDidBecomeKeyNotification
+ object:nil];
+ }
+ }
return self;
}
@@ -98,6 +101,7 @@ static const gchar* _automation_mode_strings[] = {
- (void)auViewResized:(NSNotification *)notification;
{
+ (void) notification;
plugin_ui->cocoa_view_resized();
}
@@ -197,9 +201,12 @@ AUPluginUI::AUPluginUI (boost::shared_ptr<PluginInsert> insert)
AUPluginUI::~AUPluginUI ()
{
+ if (_notify) {
+ [[NSNotificationCenter defaultCenter] removeObserver:_notify];
+ }
+
if (cocoa_parent) {
NSWindow* win = get_nswindow();
- [[NSNotificationCenter defaultCenter] removeObserver:_notify];
[win removeChildWindow:cocoa_parent];
}
@@ -387,16 +394,6 @@ AUPluginUI::create_cocoa_view ()
[(AUGenericView *)au_view setShowsExpertParameters:YES];
}
- // watch for size changes of the view
-
- [[NSNotificationCenter defaultCenter] addObserver:_notify
- selector:@selector(auViewResized:) name:NSViewBoundsDidChangeNotification
- object:au_view];
-
- [[NSNotificationCenter defaultCenter] addObserver:_notify
- selector:@selector(auViewResized:) name:NSViewFrameDidChangeNotification
- object:au_view];
-
// Get the size of the new AU View's frame
NSRect packFrame;
@@ -411,10 +408,35 @@ AUPluginUI::create_cocoa_view ()
void
AUPluginUI::cocoa_view_resized ()
{
- NSRect packFrame = [au_view frame];
- prefwidth = packFrame.size.width;
- prefheight = packFrame.size.height;
- low_box.set_size_request (prefwidth, prefheight);
+ GtkRequisition topsize = top_box.size_request ();
+ NSWindow* window = get_nswindow ();
+ NSSize oldContentSize= [window contentRectForFrameRect:[window frame]].size;
+ NSSize newContentSize= [au_view frame].size;
+ NSRect windowFrame= [window frame];
+
+ oldContentSize.height -= topsize.height;
+
+ float dy = oldContentSize.height - newContentSize.height;
+ float dx = oldContentSize.width - newContentSize.width;
+
+ windowFrame.origin.y += dy;
+ windowFrame.origin.x += dx;
+ windowFrame.size.height -= dy;
+ windowFrame.size.width -= dx;
+
+ [[NSNotificationCenter defaultCenter] removeObserver:_notify
+ name:NSViewFrameDidChangeNotification
+ object:au_view];
+
+ NSUInteger old_auto_resize = [au_view autoresizingMask];
+
+ [au_view setAutoresizingMask:NSViewNotSizable];
+ [window setFrame:windowFrame display:YES];
+ [au_view setAutoresizingMask:old_auto_resize];
+
+ [[NSNotificationCenter defaultCenter] addObserver:_notify
+ selector:@selector(auViewResized:) name:NSViewFrameDidChangeNotification
+ object:au_view];
}
int
@@ -596,6 +618,14 @@ AUPluginUI::parent_cocoa_window ()
[au_view setFrameOrigin:origin];
[view addSubview:au_view];
+ // watch for size changes of the view
+
+ _notify = [ [NotificationObject alloc] initWithPluginUI:this andCocoaParent:nil andTopLevelParent:win ];
+
+ [[NSNotificationCenter defaultCenter] addObserver:_notify
+ selector:@selector(auViewResized:) name:NSViewFrameDidChangeNotification
+ object:au_view];
+
return 0;
}