1 /*
2  * Copyright (C) 2021 Robin Gareus <robin@gareus.org>
3  * Copyright (C) 2021 Ben Loftis <ben@harrisonconsoles.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef _rec_info_box_h_
21 #define _rec_info_box_h_
22 
23 #include "ardour/session_handle.h"
24 
25 #include "gtkmm2ext/cairo_widget.h"
26 
27 namespace ARDOUR {
28 	class Route;
29 }
30 
31 class RecInfoBox : public CairoWidget, public ARDOUR::SessionHandlePtr
32 {
33 public:
34 	RecInfoBox ();
35 
36 	virtual void set_session (ARDOUR::Session*);
37 
38 protected:
39 	virtual void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*) = 0;
dpi_reset()40 	virtual void dpi_reset () {}
41 
42 	void on_size_request (Gtk::Requisition*);
43 	void on_size_allocate (Gtk::Allocation&);
44 	virtual void update ();
45 
46 	Glib::RefPtr<Pango::Layout> _layout_label;
47 	Glib::RefPtr<Pango::Layout> _layout_value;
48 	int                         _width;
49 	int                         _height;
50 };
51 
52 class DurationInfoBox : public RecInfoBox
53 {
54 public:
55 	virtual void set_session (ARDOUR::Session*);
56 
57 protected:
58 	void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*);
59 	void dpi_reset ();
60 	virtual void update ();
61 
62 private:
63 	void rec_state_changed ();
64 	sigc::connection _rectime_connection;
65 };
66 
67 class XrunInfoBox : public RecInfoBox
68 {
69 public:
70 	virtual void set_session (ARDOUR::Session*);
71 	virtual void update ();
72 
73 protected:
74 	void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*);
75 	void dpi_reset ();
76 };
77 
78 class RemainInfoBox : public RecInfoBox
79 {
80 public:
81 	virtual void set_session (ARDOUR::Session*);
82 
83 protected:
84 	void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*);
85 	void dpi_reset ();
86 	virtual void update ();
87 
88 private:
89 	void count_recenabled_streams (ARDOUR::Route&);
90 	uint32_t         _rec_enabled_streams;
91 	sigc::connection _diskspace_connection;
92 };
93 
94 #endif
95