Ardour  9.0-pre0-582-g084a23a80d
editor_sections.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Robin Gareus <robin@gareus.org>
3  *
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.
8  *
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.
13  *
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.
17  */
18 
19 #ifndef _gtk_ardour_editor_sections_h_
20 #define _gtk_ardour_editor_sections_h_
21 
22 #include <unordered_map>
23 
24 #include "ardour/location.h"
25 #include "ardour/session_handle.h"
26 
27 #include <gtkmm/liststore.h>
28 #include <gtkmm/scrolledwindow.h>
29 #include <gtkmm/treemodel.h>
30 #include <gtkmm/treeview.h>
31 
32 class EditorSections : public ARDOUR::SessionHandlePtr, public virtual sigc::trackable
33 {
34 public:
36 
38 
40  {
41  return _scroller;
42  }
43 
45 
46 private:
47  void redisplay ();
48  void queue_redisplay ();
49  bool idle_redisplay ();
53 
58  void show_context_menu (int, int);
59 
64 
65  void drag_data_get (Glib::RefPtr<Gdk::DragContext> const&, Gtk::SelectionData&, guint, guint);
66  void drag_begin (Glib::RefPtr<Gdk::DragContext> const&);
67  bool drag_motion (Glib::RefPtr<Gdk::DragContext> const&, int, int, guint);
68  void drag_data_received (Glib::RefPtr<Gdk::DragContext> const&, int, int, Gtk::SelectionData const&, guint, guint);
69  void drag_leave (Glib::RefPtr<Gdk::DragContext> const&, guint);
70 
71  void name_edited (const std::string&, const std::string&);
72 
73  struct Section {
75  : location (NULL)
76  , start (0)
77  , end (0)
78  {
79  }
80 
81  Section (ARDOUR::Location const* const l, Temporal::timepos_t const& s, Temporal::timepos_t const& e)
82  : location (l)
83  , start (s)
84  , end (e)
85  {
86  }
87 
88  ARDOUR::Location const* const location;
91  };
92 
95  {
96  add (name);
97  add (s_start);
98  add (s_end);
99  add (location);
100  add (start);
101  add (end);
102  }
109  };
110 
111  typedef std::unordered_map<ARDOUR::Location*, Gtk::TreeModel::iterator> LocationRowMap;
112 
114  Glib::RefPtr<Gtk::ListStore> _model;
117 
120  sigc::connection _scroll_timeout;
121  sigc::connection _selection_change;
122  sigc::connection _redisplay_connection;
123 };
124 
125 #endif
bool idle_redisplay()
sigc::connection _redisplay_connection
bool button_press(GdkEventButton *)
bool rename_selected_section()
LocationRowMap _location_row_map
sigc::connection _scroll_timeout
std::unordered_map< ARDOUR::Location *, Gtk::TreeModel::iterator > LocationRowMap
void drag_data_received(Glib::RefPtr< Gdk::DragContext > const &, int, int, Gtk::SelectionData const &, guint, guint)
void name_edited(const std::string &, const std::string &)
void show_context_menu(int, int)
void location_changed(ARDOUR::Location *)
void queue_redisplay()
bool leave_notify(GdkEventCrossing *)
void select(ARDOUR::Location *)
Glib::RefPtr< Gtk::ListStore > _model
void update_time_selection()
bool key_press(GdkEventKey *)
Gtk::ScrolledWindow _scroller
void set_session(ARDOUR::Session *)
void drag_data_get(Glib::RefPtr< Gdk::DragContext > const &, Gtk::SelectionData &, guint, guint)
bool drag_motion(Glib::RefPtr< Gdk::DragContext > const &, int, int, guint)
bool delete_selected_section()
Gtk::TreeView _view
void clock_format_changed()
void selection_changed()
void drag_leave(Glib::RefPtr< Gdk::DragContext > const &, guint)
Gtk::Widget & widget()
bool scroll_row_timeout()
bool enter_notify(GdkEventCrossing *)
void drag_begin(Glib::RefPtr< Gdk::DragContext > const &)
sigc::connection _selection_change
void add(TreeModelColumnBase &column)
Gtk::TreeModelColumn< Temporal::timepos_t > end
Gtk::TreeModelColumn< std::string > s_end
Gtk::TreeModelColumn< std::string > name
Gtk::TreeModelColumn< std::string > s_start
Gtk::TreeModelColumn< ARDOUR::Location * > location
Gtk::TreeModelColumn< Temporal::timepos_t > start
Section(ARDOUR::Location const *const l, Temporal::timepos_t const &s, Temporal::timepos_t const &e)
Temporal::timepos_t const end
Temporal::timepos_t const start
ARDOUR::Location const *const location