2013-01-16 13:37:48 -05:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2006-2009 David Robillard <d@drobilla.net>
|
|
|
|
* Copyright (C) 2008-2017 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2015-2017 Robin Gareus <robin@gareus.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2013-01-16 13:37:48 -05:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
#ifndef __gtk2_ardour_auplugin_ui_h__
|
|
|
|
#define __gtk2_ardour_auplugin_ui_h__
|
2006-08-12 15:43:09 -04:00
|
|
|
|
2008-02-16 17:43:18 -05:00
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
|
2016-04-28 18:41:50 -04:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
#include <AppKit/AppKit.h>
|
|
|
|
#include <Carbon/Carbon.h>
|
2008-02-01 22:57:35 -05:00
|
|
|
#include <AudioUnit/AudioUnitCarbonView.h>
|
2008-01-10 16:20:59 -05:00
|
|
|
#include <AudioUnit/AudioUnit.h>
|
2006-08-12 15:43:09 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
/* fix up stupid apple macros */
|
2006-08-12 15:43:09 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
#undef check
|
|
|
|
#undef require
|
|
|
|
#undef verify
|
2006-08-12 15:43:09 -04:00
|
|
|
|
2015-03-07 15:45:52 -05:00
|
|
|
#ifdef YES
|
|
|
|
#undef YES
|
|
|
|
#endif
|
|
|
|
#ifdef NO
|
|
|
|
#undef NO
|
|
|
|
#endif
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
#include <gtkmm/box.h>
|
2015-02-27 13:43:19 -05:00
|
|
|
#include <gtkmm/eventbox.h>
|
2008-02-16 17:43:18 -05:00
|
|
|
#include <gtkmm/combobox.h>
|
|
|
|
#include <gtkmm/button.h>
|
|
|
|
#include <gtkmm/label.h>
|
|
|
|
|
2022-08-01 18:14:32 -04:00
|
|
|
#include "widgets/eventboxext.h"
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
#include "plugin_ui.h"
|
2006-08-12 15:43:09 -04:00
|
|
|
|
|
|
|
namespace ARDOUR {
|
|
|
|
class AUPlugin;
|
2022-04-04 14:48:56 -04:00
|
|
|
class PlugInsertBase;
|
2007-06-27 16:23:48 -04:00
|
|
|
class IOProcessor;
|
2006-08-12 15:43:09 -04:00
|
|
|
}
|
|
|
|
|
2010-11-13 00:14:48 -05:00
|
|
|
class AUPluginUI;
|
|
|
|
|
|
|
|
@interface NotificationObject : NSObject {
|
|
|
|
@private
|
|
|
|
AUPluginUI* plugin_ui;
|
2017-07-01 12:42:24 -04:00
|
|
|
NSWindow* cocoa_parent;
|
2010-11-13 00:14:48 -05:00
|
|
|
NSWindow* top_level_parent;
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
2016-04-27 00:02:59 -04:00
|
|
|
@interface LiveResizeNotificationObject : NSObject {
|
|
|
|
@private
|
|
|
|
AUPluginUI* plugin_ui;
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
class AUPluginUI : public PlugUIBase, public Gtk::VBox
|
2006-08-12 15:43:09 -04:00
|
|
|
{
|
2017-07-01 15:11:14 -04:00
|
|
|
public:
|
2023-02-16 18:33:28 -05:00
|
|
|
AUPluginUI (std::shared_ptr<ARDOUR::PlugInsertBase>);
|
2006-08-12 15:43:09 -04:00
|
|
|
~AUPluginUI ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2015-10-14 16:26:22 -04:00
|
|
|
gint get_preferred_width () { return req_width; }
|
|
|
|
gint get_preferred_height () { return req_height; }
|
2008-01-10 16:20:59 -05:00
|
|
|
bool start_updating(GdkEventAny*);
|
|
|
|
bool stop_updating(GdkEventAny*);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-04-11 10:06:50 -04:00
|
|
|
void activate ();
|
|
|
|
void deactivate ();
|
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
bool non_gtk_gui() const { return true; }
|
2010-11-13 00:14:48 -05:00
|
|
|
|
2008-02-16 17:43:18 -05:00
|
|
|
void lower_box_realized ();
|
2015-02-27 13:43:19 -05:00
|
|
|
bool lower_box_visibility_notify (GdkEventVisibility*);
|
|
|
|
|
2015-10-14 16:26:22 -04:00
|
|
|
void lower_box_map ();
|
|
|
|
void lower_box_unmap ();
|
|
|
|
void lower_box_size_request (GtkRequisition*);
|
|
|
|
void lower_box_size_allocate (Gtk::Allocation&);
|
|
|
|
|
2010-11-13 00:14:48 -05:00
|
|
|
void cocoa_view_resized ();
|
2008-01-10 16:20:59 -05:00
|
|
|
void on_realize ();
|
2015-02-20 21:16:04 -05:00
|
|
|
void grab_focus();
|
2010-11-13 00:14:48 -05:00
|
|
|
void forward_key_event (GdkEventKey*);
|
|
|
|
|
|
|
|
bool on_window_show (const std::string& /*title*/);
|
|
|
|
void on_window_hide ();
|
2008-01-10 16:20:59 -05:00
|
|
|
|
|
|
|
OSStatus carbon_event (EventHandlerCallRef nextHandlerRef, EventRef event);
|
|
|
|
|
2016-04-27 00:02:59 -04:00
|
|
|
void start_live_resize ();
|
|
|
|
void end_live_resize ();
|
|
|
|
|
2017-07-01 15:11:14 -04:00
|
|
|
private:
|
2006-08-12 15:43:09 -04:00
|
|
|
WindowRef wr;
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<ARDOUR::AUPlugin> au;
|
2008-01-10 16:20:59 -05:00
|
|
|
int prefheight;
|
|
|
|
int prefwidth;
|
2008-04-11 10:06:50 -04:00
|
|
|
|
2022-08-01 18:14:32 -04:00
|
|
|
Gtk::HBox top_box;
|
|
|
|
ArdourWidgets::EventBoxExt low_box;
|
2008-02-16 17:43:18 -05:00
|
|
|
Gtk::VBox vpacker;
|
|
|
|
Gtk::Label automation_mode_label;
|
|
|
|
Gtk::ComboBoxText automation_mode_selector;
|
|
|
|
Gtk::Label preset_label;
|
|
|
|
|
|
|
|
static std::vector<std::string> automation_mode_strings;
|
2008-01-10 16:20:59 -05:00
|
|
|
|
2015-10-14 16:26:22 -04:00
|
|
|
bool resizable;
|
|
|
|
int req_width;
|
|
|
|
int req_height;
|
2022-07-30 00:32:57 -04:00
|
|
|
int alloc_width;
|
|
|
|
int alloc_height;
|
2015-10-14 16:26:22 -04:00
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
/* Cocoa */
|
|
|
|
|
|
|
|
NSWindow* cocoa_window;
|
|
|
|
NSView* au_view;
|
2017-09-19 12:41:51 -04:00
|
|
|
NSRect last_au_frame;
|
2016-04-27 00:02:59 -04:00
|
|
|
bool in_live_resize;
|
|
|
|
uint32_t plugin_requested_resize;
|
2008-01-10 16:20:59 -05:00
|
|
|
|
|
|
|
/* Carbon */
|
|
|
|
|
|
|
|
NSWindow* cocoa_parent;
|
|
|
|
ComponentDescription carbon_descriptor;
|
|
|
|
AudioUnitCarbonView editView;
|
2009-10-14 12:10:01 -04:00
|
|
|
WindowRef carbon_window;
|
2016-04-27 00:02:59 -04:00
|
|
|
EventHandlerRef carbon_event_handler;
|
2008-01-19 00:06:33 -05:00
|
|
|
bool _activating_from_app;
|
2016-04-27 00:02:59 -04:00
|
|
|
|
|
|
|
/* Generic */
|
|
|
|
|
2010-11-13 00:14:48 -05:00
|
|
|
NotificationObject* _notify;
|
2016-04-27 00:02:59 -04:00
|
|
|
LiveResizeNotificationObject* _resize_notify;
|
2008-01-10 16:20:59 -05:00
|
|
|
|
|
|
|
bool test_cocoa_view_support ();
|
|
|
|
bool test_carbon_view_support ();
|
2008-02-16 17:43:18 -05:00
|
|
|
int create_carbon_view ();
|
2008-01-10 16:20:59 -05:00
|
|
|
int create_cocoa_view ();
|
|
|
|
|
|
|
|
int parent_carbon_window ();
|
|
|
|
int parent_cocoa_window ();
|
|
|
|
NSWindow* get_nswindow();
|
2006-08-12 15:43:09 -04:00
|
|
|
|
2015-10-14 16:26:22 -04:00
|
|
|
void update_view_size ();
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
bool plugin_class_valid (Class pluginClass);
|
2016-04-28 18:41:50 -04:00
|
|
|
|
2016-04-30 13:19:56 -04:00
|
|
|
friend void au_cf_timer_callback (CFRunLoopTimerRef timer, void* info);
|
|
|
|
static CFRunLoopTimerRef cf_timer;
|
|
|
|
static void cf_timer_callback ();
|
|
|
|
static int64_t last_timer;
|
|
|
|
static bool timer_needed;
|
|
|
|
static uint64_t timer_callbacks;
|
|
|
|
static uint64_t timer_out_of_range;
|
|
|
|
|
2016-05-01 14:02:09 -04:00
|
|
|
static bool timer_callback ();
|
|
|
|
static sigc::connection timer_connection;
|
|
|
|
|
2017-07-01 15:11:14 -04:00
|
|
|
public:
|
2016-04-30 13:19:56 -04:00
|
|
|
static void start_cf_timer ();
|
|
|
|
static void stop_cf_timer ();
|
2006-08-12 15:43:09 -04:00
|
|
|
};
|
|
|
|
|
2008-01-10 16:20:59 -05:00
|
|
|
#endif /* __gtk2_ardour_auplugin_ui_h__ */
|