2 Copyright (C) 2000-2009 Paul Davis
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
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #ifndef __gtk_ardour_editor_sources_h__
20 #define __gtk_ardour_editor_sources_h__
22 #include <boost/unordered_map.hpp>
24 #include <gtkmm/scrolledwindow.h>
25 #include <gtkmm/treemodel.h>
26 #include <gtkmm/treerowreference.h>
27 #include <gtkmm/treestore.h>
29 #include "editor_component.h"
31 #include "selection.h"
33 class EditorSources : public EditorComponent, public ARDOUR::SessionHandlePtr
36 EditorSources (Editor *);
38 void set_session (ARDOUR::Session *);
40 void set_selection (Selection *sel) { _selection = sel; }
42 Gtk::Widget& widget () {
48 void remove_selected_sources ();
50 void selection_mapover (sigc::slot<void,boost::shared_ptr<ARDOUR::Region> >);
52 boost::shared_ptr<ARDOUR::Source> get_dragged_source ();
53 boost::shared_ptr<ARDOUR::Source> get_single_selection ();
55 void block_change_connection (bool b) {
56 _change_connection.block (b);
59 void unselect_all () {
60 _display.get_selection()->unselect_all ();
63 void remove_unused_regions ();
65 XMLNode& get_state () const;
66 void set_state (const XMLNode &);
70 struct Columns : public Gtk::TreeModel::ColumnRecord {
81 Gtk::TreeModelColumn<std::string> name;
82 Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Source> > source;
83 Gtk::TreeModelColumn<Gdk::Color> color_;
84 Gtk::TreeModelColumn<std::string> natural_pos;
85 Gtk::TreeModelColumn<std::string> path;
86 Gtk::TreeModelColumn<std::string> take_id;
87 Gtk::TreeModelColumn<samplepos_t> natural_s;
92 Gtk::TreeModel::RowReference last_row;
94 void freeze_tree_model ();
95 void thaw_tree_model ();
96 void source_changed (boost::shared_ptr<ARDOUR::Source>);
97 void populate_row (Gtk::TreeModel::Row row, boost::shared_ptr<ARDOUR::Source> source);
98 void selection_changed ();
100 sigc::connection _change_connection;
102 bool selection_filter (const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreeModel::Path& path, bool yn);
104 Gtk::Widget* old_focus;
106 bool key_press (GdkEventKey *);
107 bool button_press (GdkEventButton *);
109 bool focus_in (GdkEventFocus*);
110 bool focus_out (GdkEventFocus*);
111 bool enter_notify (GdkEventCrossing*);
112 bool leave_notify (GdkEventCrossing*);
114 void show_context_menu (int button, int time);
116 void format_position (ARDOUR::samplepos_t pos, char* buf, size_t bufsize, bool onoff = true);
118 void add_source (boost::shared_ptr<ARDOUR::Source>);
119 void remove_source (boost::shared_ptr<ARDOUR::Source>);
121 void clock_format_changed ();
123 void drag_data_received (
124 Glib::RefPtr<Gdk::DragContext> const &, gint, gint, Gtk::SelectionData const &, guint, guint
127 Glib::RefPtr<Gtk::Action> remove_unused_regions_action () const; //TODO: what is the equivalent?
130 Gtk::ScrolledWindow _scroller;
133 Gtkmm2ext::DnDTreeView<boost::shared_ptr<ARDOUR::Source> > _display; //TODO .. try changing this to region
135 Glib::RefPtr<Gtk::TreeStore> _model;
137 PBD::ScopedConnection source_property_connection;
139 PBD::ScopedConnection source_added_connection;
140 PBD::ScopedConnection source_removed_connection;
142 PBD::ScopedConnection editor_freeze_connection;
143 PBD::ScopedConnection editor_thaw_connection;
145 Selection* _selection;
149 #endif /* __gtk_ardour_editor_regions_h__ */