2 * Copyright (C) 2018-2019 Ben Loftis <ben@harrisonconsoles.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 #ifndef __gtk_ardour_editor_sources_h__
19 #define __gtk_ardour_editor_sources_h__
21 #include <boost/unordered_map.hpp>
23 #include <gtkmm/scrolledwindow.h>
24 #include <gtkmm/treemodel.h>
25 #include <gtkmm/treerowreference.h>
26 #include <gtkmm/treestore.h>
28 #include "editor_component.h"
30 #include "selection.h"
32 class EditorSources : public EditorComponent, public ARDOUR::SessionHandlePtr
35 EditorSources (Editor *);
37 void set_session (ARDOUR::Session *);
39 void set_selection (Selection *sel) { _selection = sel; }
41 Gtk::Widget& widget () {
47 void selection_mapover (sigc::slot<void,boost::shared_ptr<ARDOUR::Region> >);
49 boost::shared_ptr<ARDOUR::Region> get_dragged_region ();
50 boost::shared_ptr<ARDOUR::Region> get_single_selection ();
52 void block_change_connection (bool b) {
53 _change_connection.block (b);
56 void unselect_all () {
57 _display.get_selection()->unselect_all ();
61 void remove_selected_sources ();
62 void recover_selected_sources();
64 XMLNode& get_state () const;
65 void set_state (const XMLNode &);
69 struct Columns : public Gtk::TreeModel::ColumnRecord {
81 Gtk::TreeModelColumn<std::string> name;
82 Gtk::TreeModelColumn<std::string> tags;
83 Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Region> > region;
84 Gtk::TreeModelColumn<Gdk::Color> color_;
85 Gtk::TreeModelColumn<std::string> natural_pos;
86 Gtk::TreeModelColumn<std::string> path;
87 Gtk::TreeModelColumn<std::string> take_id;
88 Gtk::TreeModelColumn<samplepos_t> natural_s;
93 Gtk::TreeModel::RowReference last_row;
95 void freeze_tree_model ();
96 void thaw_tree_model ();
97 void source_changed (boost::shared_ptr<ARDOUR::Region>);
98 void populate_row (Gtk::TreeModel::Row row, boost::shared_ptr<ARDOUR::Region> region);
99 void selection_changed ();
101 sigc::connection _change_connection;
103 Gtk::Widget* old_focus;
105 Gtk::CellEditable* tags_editable;
106 void tag_editing_started (Gtk::CellEditable*, const Glib::ustring&);
107 void tag_edit (const std::string&, const std::string&);
109 bool key_press (GdkEventKey *);
110 bool button_press (GdkEventButton *);
112 bool focus_in (GdkEventFocus*);
113 bool focus_out (GdkEventFocus*);
114 bool enter_notify (GdkEventCrossing*);
115 bool leave_notify (GdkEventCrossing*);
117 void show_context_menu (int button, int time);
119 void format_position (ARDOUR::samplepos_t pos, char* buf, size_t bufsize, bool onoff = true);
121 void add_source (boost::shared_ptr<ARDOUR::Region>);
122 void remove_source (boost::shared_ptr<ARDOUR::Source>);
123 void remove_weak_source (boost::weak_ptr<ARDOUR::Source>);
125 void clock_format_changed ();
129 void suspend_redisplay () {
130 _no_redisplay = true;
133 void resume_redisplay () {
134 _no_redisplay = false;
138 void drag_data_received (
139 Glib::RefPtr<Gdk::DragContext> const &, gint, gint, Gtk::SelectionData const &, guint, guint
143 Gtk::ScrolledWindow _scroller;
146 Gtkmm2ext::DnDTreeView<boost::shared_ptr<ARDOUR::Region> > _display;
148 Glib::RefPtr<Gtk::TreeStore> _model;
150 PBD::ScopedConnection source_property_connection;
151 PBD::ScopedConnection add_source_connection;
152 PBD::ScopedConnection remove_source_connection;
154 PBD::ScopedConnection editor_freeze_connection;
155 PBD::ScopedConnection editor_thaw_connection;
157 Selection* _selection;
162 #endif /* __gtk_ardour_editor_regions_h__ */