Ardour  9.0-pre0-1230-g49ff88fd75
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 <ytkmm/liststore.h>
28 #include <ytkmm/scrolledwindow.h>
29 #include <ytkmm/treemodel.h>
30 #include <ytkmm/treeview.h>
31 
32 class EditingContext;
33 
34 class EditorSections : public ARDOUR::SessionHandlePtr, public virtual sigc::trackable
35 {
36 public:
38 
40 
42  {
43  return _scroller;
44  }
45 
47 
48 private:
49  void redisplay ();
50  void queue_redisplay ();
51  bool idle_redisplay ();
55 
60  void show_context_menu (int, int);
61 
66 
67  void drag_data_get (Glib::RefPtr<Gdk::DragContext> const&, Gtk::SelectionData&, guint, guint);
68  void drag_begin (Glib::RefPtr<Gdk::DragContext> const&);
69  bool drag_motion (Glib::RefPtr<Gdk::DragContext> const&, int, int, guint);
70  void drag_data_received (Glib::RefPtr<Gdk::DragContext> const&, int, int, Gtk::SelectionData const&, guint, guint);
71  void drag_leave (Glib::RefPtr<Gdk::DragContext> const&, guint);
72 
73  void name_edited (const std::string&, const std::string&);
74 
75  struct Section {
77  : location (NULL)
78  , start (0)
79  , end (0)
80  {
81  }
82 
83  Section (ARDOUR::Location const* const l, Temporal::timepos_t const& s, Temporal::timepos_t const& e)
84  : location (l)
85  , start (s)
86  , end (e)
87  {
88  }
89 
90  ARDOUR::Location const* const location;
93  };
94 
97  {
98  add (name);
99  add (s_start);
100  add (s_end);
101  add (location);
102  add (start);
103  add (end);
104  }
111  };
112 
113  typedef std::unordered_map<ARDOUR::Location*, Gtk::TreeModel::iterator> LocationRowMap;
114 
116  Glib::RefPtr<Gtk::ListStore> _model;
119 
123  sigc::connection _scroll_timeout;
124  sigc::connection _selection_change;
125  sigc::connection _redisplay_connection;
126 };
127 
128 #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
EditorSections(EditingContext &)
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 *)
EditingContext & editing_context
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