summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2008-04-09 21:05:58 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2008-04-09 21:05:58 +0000
commitedab5bb5239573559aaccb7ce9afffac5435f496 (patch)
tree9d1336244e6b33cd4cbb792aab3581f2263d4396
parent5a484d8f361c2ca2bb9e6efd460f4879176855eb (diff)
fixes for AU plugin GUIs, including the "hidden GUI shows up when app becomes active/focus again" bug
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@3241 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--gtk2_ardour/ardour_ui.cc5
-rw-r--r--gtk2_ardour/au_pluginui.h9
-rw-r--r--gtk2_ardour/au_pluginui.mm95
-rw-r--r--gtk2_ardour/plugin_ui.cc10
-rw-r--r--gtk2_ardour/plugin_ui.h2
5 files changed, 67 insertions, 54 deletions
diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc
index 62916e2f09..829a7df6ad 100644
--- a/gtk2_ardour/ardour_ui.cc
+++ b/gtk2_ardour/ardour_ui.cc
@@ -3359,6 +3359,11 @@ ARDOUR_UI::TransportControllable::set_id (const string& str)
void
ARDOUR_UI::setup_profile ()
{
+ cerr << "GDK screen dimensions: "
+ << gdk_screen_width() << " x "
+ << gdk_screen_height()
+ << endl;
+
if (gdk_screen_width() < 1200) {
Profile->set_small_screen ();
}
diff --git a/gtk2_ardour/au_pluginui.h b/gtk2_ardour/au_pluginui.h
index 93a446b7a2..2f7e5a1f90 100644
--- a/gtk2_ardour/au_pluginui.h
+++ b/gtk2_ardour/au_pluginui.h
@@ -39,9 +39,9 @@ class AUPluginUI : public PlugUIBase, public Gtk::VBox
bool start_updating(GdkEventAny*);
bool stop_updating(GdkEventAny*);
- virtual void activate ();
- virtual void deactivate ();
-
+ void activate ();
+ void deactivate ();
+
void lower_box_realized ();
void on_realize ();
void on_show ();
@@ -56,7 +56,7 @@ class AUPluginUI : public PlugUIBase, public Gtk::VBox
boost::shared_ptr<ARDOUR::AUPlugin> au;
int prefheight;
int prefwidth;
-
+
Gtk::HBox top_box;
Gtk::EventBox low_box;
Gtk::VBox vpacker;
@@ -80,6 +80,7 @@ class AUPluginUI : public PlugUIBase, public Gtk::VBox
WindowRef carbon_window;
EventHandlerRef carbon_event_handler;
bool _activating_from_app;
+ NSView* packView;
bool test_cocoa_view_support ();
bool test_carbon_view_support ();
diff --git a/gtk2_ardour/au_pluginui.mm b/gtk2_ardour/au_pluginui.mm
index 3f71f126f5..ab14d4aafd 100644
--- a/gtk2_ardour/au_pluginui.mm
+++ b/gtk2_ardour/au_pluginui.mm
@@ -83,6 +83,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 +109,9 @@ AUPluginUI::~AUPluginUI ()
DisposeWindow (carbon_window);
}
+ if (packView && packView != au_view) {
+ [packView release];
+ }
}
bool
@@ -260,6 +264,49 @@ AUPluginUI::create_cocoa_view ()
[(AUGenericView *)au_view setShowsExpertParameters:YES];
}
+ NSRect packFrame;
+
+ // 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;
+ }
+
+ prefwidth = packFrame.size.width;
+ prefheight = packFrame.size.height;
+
return 0;
}
@@ -353,7 +400,7 @@ AUPluginUI::activate ()
void
AUPluginUI::deactivate ()
{
- return;
+ return;
cerr << "APP DEactivated, for " << insert->name() << endl;
_activating_from_app = true;
ActivateWindow (carbon_window, FALSE);
@@ -465,7 +512,6 @@ int
AUPluginUI::parent_cocoa_window ()
{
NSWindow* win = get_nswindow ();
- NSView* packView = 0;
NSRect packFrame;
if (!win) {
@@ -481,40 +527,6 @@ 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());
@@ -559,17 +571,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;
}
diff --git a/gtk2_ardour/plugin_ui.cc b/gtk2_ardour/plugin_ui.cc
index ce81f486d7..3c34593c87 100644
--- a/gtk2_ardour/plugin_ui.cc
+++ b/gtk2_ardour/plugin_ui.cc
@@ -66,6 +66,7 @@ PluginUIWindow::PluginUIWindow (Gtk::Window* win, boost::shared_ptr<PluginInsert
{
bool have_gui = false;
non_gtk_gui = false;
+ was_visible = false;
if (insert->plugin()->has_editor()) {
switch (insert->type()) {
@@ -156,7 +157,6 @@ PluginUIWindow::on_show ()
Window::on_show ();
if (parent) {
- cerr << "plugin becomes transient for " << parent << endl;
// set_transient_for (*parent);
}
}
@@ -218,9 +218,13 @@ PluginUIWindow::app_activated (bool yn)
cerr << "APP activated ? " << yn << endl;
if (_pluginui) {
if (yn) {
- _pluginui->activate ();
- present ();
+ if (was_visible) {
+ _pluginui->activate ();
+ present ();
+ was_visible = true;
+ }
} else {
+ was_visible = is_visible();
hide ();
_pluginui->deactivate ();
}
diff --git a/gtk2_ardour/plugin_ui.h b/gtk2_ardour/plugin_ui.h
index b612f4dcdf..d60d3fae22 100644
--- a/gtk2_ardour/plugin_ui.h
+++ b/gtk2_ardour/plugin_ui.h
@@ -220,6 +220,8 @@ class PluginUIWindow : public Gtk::Window
Gtk::Window* parent;
Gtk::VBox vbox;
bool non_gtk_gui;
+ bool was_visible;
+
void app_activated (bool);
void plugin_going_away ();