13
0
livetrax/gtk2_ardour/recorder_ui.h

282 lines
8.8 KiB
C
Raw Normal View History

2020-10-26 17:55:00 -04:00
/*
* Copyright (C) 2020 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.
*/
#ifndef __gtk_ardour_recorder_ui_h__
#define __gtk_ardour_recorder_ui_h__
2020-12-06 16:05:09 -05:00
#include <list>
#include <memory>
2020-12-06 16:05:09 -05:00
#include <vector>
#include <gtkmm/alignment.h>
2020-10-26 17:55:00 -04:00
#include <gtkmm/box.h>
2020-12-06 16:05:09 -05:00
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/sizegroup.h>
#include <gtkmm/table.h>
#include "pbd/natsort.h"
2020-10-26 17:55:00 -04:00
#include "ardour/session_handle.h"
2020-12-06 16:05:09 -05:00
#include "ardour/circular_buffer.h"
#include "ardour/types.h"
2020-10-26 17:55:00 -04:00
#include "gtkmm2ext/bindings.h"
2020-12-06 16:05:09 -05:00
#include "gtkmm2ext/cairo_widget.h"
#include "widgets/ardour_button.h"
#include "widgets/ardour_spacer.h"
#include "widgets/frame.h"
#include "widgets/pane.h"
2020-10-26 17:55:00 -04:00
#include "widgets/tabbable.h"
2020-12-06 16:05:09 -05:00
#include "input_port_monitor.h"
#include "rec_info_box.h"
#include "shuttle_control.h"
#include "transport_control_ui.h"
2020-12-06 16:05:09 -05:00
2021-02-23 07:10:05 -05:00
namespace ARDOUR {
class SoloMuteRelease;
2022-05-16 20:25:58 -04:00
class IOPlug;
2021-02-23 07:10:05 -05:00
}
2020-12-06 16:05:09 -05:00
class TrackRecordAxis;
class RecorderGroupTabs;
2020-10-26 17:55:00 -04:00
class RecorderUI : public ArdourWidgets::Tabbable, public ARDOUR::SessionHandlePtr, public PBD::ScopedConnectionList
{
public:
RecorderUI ();
~RecorderUI ();
void set_session (ARDOUR::Session*);
void cleanup ();
XMLNode& get_state () const;
2020-10-26 17:55:00 -04:00
int set_state (const XMLNode&, int /* version */);
Gtk::Window* use_own_window (bool and_fill_it);
2020-12-06 16:05:09 -05:00
void spill_port (std::string const&);
void add_track (std::string const&);
2020-10-26 17:55:00 -04:00
private:
void load_bindings ();
void register_actions ();
void update_title ();
void session_going_away ();
void parameter_changed (std::string const&);
2020-12-06 16:05:09 -05:00
void presentation_info_changed (PBD::PropertyChange const&);
void gui_extents_changed ();
void regions_changed (std::shared_ptr<ARDOUR::RegionList>, PBD::PropertyChange const&);
2020-12-06 16:05:09 -05:00
void start_updating ();
void stop_updating ();
bool update_meters ();
void add_or_remove_io (ARDOUR::DataType, std::vector<std::string>, bool);
2022-05-16 20:25:58 -04:00
void io_plugins_changed ();
void io_plugin_add (std::shared_ptr<ARDOUR::IOPlug>);
void io_plugin_going_away (std::weak_ptr<ARDOUR::IOPlug>);
2022-05-16 20:25:58 -04:00
void post_add_remove (bool);
2020-12-06 16:05:09 -05:00
void update_io_widget_labels ();
void initial_track_display ();
void add_routes (ARDOUR::RouteList&);
void remove_route (TrackRecordAxis*);
2021-02-15 18:27:29 -05:00
void tra_name_edit (TrackRecordAxis*, bool);
2020-12-06 16:05:09 -05:00
void update_rec_table_layout ();
void update_spacer_width (Gtk::Allocation&, TrackRecordAxis*);
void tabbed_changed (bool);
2020-12-06 16:05:09 -05:00
void set_connections (std::string const&);
void port_connected_or_disconnected (std::string, std::string);
void port_pretty_name_changed (std::string);
void meter_area_size_allocate (Gtk::Allocation&);
void meter_area_size_request (GtkRequisition*);
void meter_area_layout ();
bool scroller_button_event (GdkEventButton*);
2020-12-06 16:05:09 -05:00
void rec_undo ();
void rec_redo ();
2020-12-06 16:05:09 -05:00
void peak_reset ();
void update_sensitivity ();
void update_recordstate ();
2021-02-23 07:10:05 -05:00
void update_monitorstate (std::string, bool);
2020-12-06 16:05:09 -05:00
void new_track_for_port (ARDOUR::DataType, std::string const&);
static int calc_columns (int child_width, int parent_width);
Gtkmm2ext::Bindings* bindings;
Gtk::VBox _content;
Gtk::HBox _toolbar;
Gtk::Table _button_table;
ArdourWidgets::VPane _pane;
Gtk::ScrolledWindow _rec_scroller;
Gtk::VBox _rec_container;
Gtk::HBox _rec_groups;
Gtk::VBox _rec_area;
Gtk::ScrolledWindow _meter_scroller;
Gtk::VBox _meter_area;
Gtk::Table _meter_table;
Gtk::EventBox _scroller_base;
ArdourWidgets::ArdourHSpacer _toolbar_sep;
Gtk::Label _recs_label;
ArdourWidgets::ArdourButton _btn_rec_all;
ArdourWidgets::ArdourButton _btn_rec_none;
ArdourWidgets::ArdourButton _btn_rec_forget;
ArdourWidgets::ArdourButton _btn_peak_reset;
ArdourWidgets::ArdourButton _monitor_in_button;
ArdourWidgets::ArdourButton _monitor_disk_button;
ArdourWidgets::ArdourButton _btn_new_plist;
ArdourWidgets::ArdourButton _btn_new_plist_rec;
2020-12-06 16:05:09 -05:00
ArdourWidgets::ArdourButton _auto_input_button;
DurationInfoBox _duration_info_box;
XrunInfoBox _xrun_info_box;
RemainInfoBox _remain_info_box;
TransportControlUI _transport_ctrl;
2020-12-06 16:05:09 -05:00
Glib::RefPtr<Gtk::SizeGroup> _toolbar_button_height;
Glib::RefPtr<Gtk::SizeGroup> _toolbar_recarm_width;
Glib::RefPtr<Gtk::SizeGroup> _toolbar_monitoring_width;
int _meter_box_width;
int _meter_area_cols;
bool _vertical;
2020-10-26 17:55:00 -04:00
2020-12-06 16:05:09 -05:00
std::set<std::string> _spill_port_names;
2020-10-26 17:55:00 -04:00
2020-12-06 16:05:09 -05:00
class RecRuler : public CairoWidget , public ARDOUR::SessionHandlePtr
{
public:
RecRuler ();
void playhead_position_changed (ARDOUR::samplepos_t);
void set_gui_extents (samplepos_t, samplepos_t);
void set_right_edge (int);
protected:
void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*);
void on_size_request (Gtk::Requisition*);
bool on_button_press_event (GdkEventButton*);
private:
Glib::RefPtr<Pango::Layout> _layout;
int _time_width;
int _time_height;
int _width;
ARDOUR::samplecnt_t _left;
ARDOUR::samplecnt_t _right;
};
class InputPort : public Gtk::EventBox
{
public:
2022-05-16 20:25:58 -04:00
InputPort (std::string const&, ARDOUR::DataType, RecorderUI*, bool vertical = false, bool ioplug = false);
2020-12-06 16:05:09 -05:00
~InputPort ();
void set_frame_label (std::string const&);
void set_connections (ARDOUR::WeakRouteList);
void setup_name ();
bool spill (bool);
bool spilled () const;
2021-02-23 07:10:05 -05:00
void allow_monitoring (bool);
void update_monitorstate (bool);
2020-12-06 16:05:09 -05:00
void update_rec_stat ();
ARDOUR::DataType data_type () const;
2022-05-16 20:25:58 -04:00
bool ioplug () const { return _ioplug; }
2020-12-06 16:05:09 -05:00
std::string const& name () const;
void update (float, float); // FastMeter
void update (float const*); // EventMeter
void update (ARDOUR::CircularSampleBuffer&); // InputScope
void update (ARDOUR::CircularEventBuffer&); // EventMonitor
void clear ();
bool operator< (InputPort const& o) const {
2022-05-16 20:25:58 -04:00
if (_ioplug != o._ioplug) {
return !_ioplug;
}
2020-12-06 16:05:09 -05:00
if (_dt == o._dt) {
return PBD::naturally_less (_port_name.c_str (), o._port_name.c_str ());
}
return _dt < (uint32_t) o._dt;
}
private:
void rename_port ();
2021-02-23 07:10:05 -05:00
bool monitor_press (GdkEventButton*);
bool monitor_release (GdkEventButton*);
2020-12-06 16:05:09 -05:00
ARDOUR::DataType _dt;
InputPortMonitor _monitor;
Gtk::Alignment _alignment;
ArdourWidgets::Frame _frame;
ArdourWidgets::ArdourButton _spill_button;
2021-02-23 07:10:05 -05:00
ArdourWidgets::ArdourButton _monitor_button;
2020-12-06 16:05:09 -05:00
ArdourWidgets::ArdourButton _name_button;
Gtk::Label _name_label;
ArdourWidgets::ArdourButton _add_button;
std::string _port_name;
2022-05-16 20:25:58 -04:00
bool _ioplug;
2020-12-06 16:05:09 -05:00
ARDOUR::WeakRouteList _connected_routes;
2021-02-23 07:10:05 -05:00
ARDOUR::SoloMuteRelease* _solo_release;
2020-12-06 16:05:09 -05:00
static bool _size_groups_initialized;
static Glib::RefPtr<Gtk::SizeGroup> _name_size_group;
2021-02-23 07:10:05 -05:00
static Glib::RefPtr<Gtk::SizeGroup> _ctrl_size_group;
2020-12-06 16:05:09 -05:00
static Glib::RefPtr<Gtk::SizeGroup> _monitor_size_group;
};
struct InputPortPtrSort {
bool operator() (std::shared_ptr<InputPort> const& a, std::shared_ptr<InputPort> const& b) const {
2020-12-06 16:05:09 -05:00
return *a < *b;
}
};
typedef std::map<std::string, std::shared_ptr<InputPort> > InputPortMap;
typedef std::set<std::shared_ptr<InputPort>, InputPortPtrSort> InputPortSet;
typedef std::set<std::shared_ptr<ARDOUR::IOPlug>> IOPlugSet;
2020-12-06 16:05:09 -05:00
RecRuler _ruler;
Gtk::EventBox _space;
Gtk::HBox _ruler_box;
ArdourWidgets::ArdourHSpacer _ruler_sep;
RecorderGroupTabs* _rec_group_tabs;
InputPortMap _input_ports;
std::list<TrackRecordAxis*> _recorders;
std::list<TrackRecordAxis*> _visible_recorders;
2022-05-16 20:25:58 -04:00
IOPlugSet _ioplugins;
sigc::connection _fast_screen_update_connection;
sigc::connection _ruler_width_update_connection;
PBD::ScopedConnectionList _engine_connections;
PBD::ScopedConnection _monitor_connection;
PBD::ScopedConnectionList _going_away_connections;
2020-12-06 16:05:09 -05:00
public:
/* only for RecorderGroupTab */
std::list<TrackRecordAxis*> visible_recorders () const;
2020-10-26 17:55:00 -04:00
};
#endif /* __gtk_ardour_recorder_ui_h__ */