fix up file renaming code a little bit
[ArdourMidi.git] / gtk2_ardour / group_tabs.h
blob22ebd808cc5b0d202f07c812963197cdb863aa72
1 /*
2 Copyright (C) 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.
20 #include <gtkmm/menu.h>
21 #include "editor_component.h"
22 #include "cairo_widget.h"
24 namespace ARDOUR {
25 class Session;
26 class RouteGroup;
29 class Editor;
31 /** Parent class for tabs which represent route groups as coloured tabs;
32 * Currently used on the left-hand side of the editor and at the top of the mixer.
34 class GroupTabs : public CairoWidget, public ARDOUR::SessionHandlePtr
36 public:
37 GroupTabs ();
38 virtual ~GroupTabs ();
40 void set_session (ARDOUR::Session *);
42 /** @param g Route group, or 0.
43 * @return Menu to be popped up on right-click over the given route group.
45 Gtk::Menu* get_menu (ARDOUR::RouteGroup* g);
47 void run_new_group_dialog (ARDOUR::RouteList const &);
49 protected:
51 struct Tab {
52 Tab () : group (0) {}
54 double from;
55 double to;
56 Gdk::Color colour; ///< colour
57 ARDOUR::RouteGroup* group; ///< route group
60 private:
61 /** Compute all the tabs for this widget.
62 * @return Tabs.
64 virtual std::list<Tab> compute_tabs () const = 0;
66 /** Draw a tab.
67 * @param cr Cairo context.
68 * @param t Tab.
70 virtual void draw_tab (cairo_t* cr, Tab const & t) const = 0;
72 /** @param x x coordinate
73 * @param y y coordinate
74 * @return x or y, depending on which is the primary coordinate for this widget.
76 virtual double primary_coordinate (double, double) const = 0;
78 virtual ARDOUR::RouteList routes_for_tab (Tab const * t) const = 0;
80 /** @return Size of the widget along the primary axis */
81 virtual double extent () const = 0;
83 virtual void add_menu_items (Gtk::Menu *, ARDOUR::RouteGroup *) {}
84 virtual PBD::PropertyList default_properties () const = 0;
85 virtual std::string order_key () const = 0;
86 virtual ARDOUR::RouteList selected_routes () const = 0;
87 virtual void sync_order_keys () = 0;
89 void new_from_selection ();
90 void new_from_rec_enabled ();
91 void new_from_soloed ();
92 ARDOUR::RouteGroup* create_and_add_group () const;
93 void collect (ARDOUR::RouteGroup *);
94 void set_activation (ARDOUR::RouteGroup *, bool);
95 void edit_group (ARDOUR::RouteGroup *);
96 void subgroup (ARDOUR::RouteGroup *);
97 void activate_all ();
98 void disable_all ();
99 void remove_group (ARDOUR::RouteGroup *);
101 void render (cairo_t *);
102 void on_size_request (Gtk::Requisition *);
103 bool on_button_press_event (GdkEventButton *);
104 bool on_motion_notify_event (GdkEventMotion *);
105 bool on_button_release_event (GdkEventButton *);
107 Tab * click_to_tab (double, std::list<Tab>::iterator *, std::list<Tab>::iterator *);
109 Gtk::Menu* _menu;
110 std::list<Tab> _tabs; ///< current list of tabs
111 Tab* _dragging; ///< tab being dragged, or 0
112 bool _dragging_new_tab; ///< true if we're dragging a new tab
113 bool _drag_moved; ///< true if there has been movement during any current drag
114 double _drag_fixed; ///< the position of the fixed end of the tab being dragged
115 double _drag_moving; ///< the position of the moving end of the tab being dragged
116 double _drag_offset; ///< offset from the mouse to the end of the tab being dragged
117 double _drag_min; ///< minimum position for drag
118 double _drag_max; ///< maximum position for drag
119 double _drag_first; ///< first mouse pointer position during drag