summaryrefslogtreecommitdiff
path: root/gtk2_ardour/meterbridge.h
blob: 2e231861c7594eb74a67b2bc65be67391e13021b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
    Copyright (C) 2012 Paul Davis
    Author: Robin Gareus

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

*/
#ifndef __ardour_meterbridge_h__
#define __ardour_meterbridge_h__

#include <gtkmm/box.h>
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/label.h>
#include <gtkmm/window.h>

#include "ardour/ardour.h"
#include "ardour/types.h"
#include "ardour/session_handle.h"

#include "pbd/stateful.h"
#include "pbd/signals.h"

#include "gtkmm2ext/visibility_tracker.h"

#include "meter_strip.h"

class Meterbridge :
	public Gtk::Window,
	public PBD::ScopedConnectionList,
	public ARDOUR::SessionHandlePtr,
	public Gtkmm2ext::VisibilityTracker
{
  public:
	static Meterbridge* instance();
	~Meterbridge();

	void set_session (ARDOUR::Session *);

	XMLNode& get_state (void);
	int set_state (const XMLNode& );

	void show_window ();
	bool hide_window (GdkEventAny *ev);

  private:
	Meterbridge ();
	static Meterbridge* _instance;

	bool _visible;
	bool _show_busses;
	bool _show_master;
	bool _show_midi;

	Gtk::ScrolledWindow scroller;
	Gtk::HBox meterarea;
	Gtk::HBox global_hpacker;
	Gtk::VBox global_vpacker;

	gint start_updating ();
	gint stop_updating ();

	sigc::connection fast_screen_update_connection;
	void fast_update_strips ();

	void add_strips (ARDOUR::RouteList&);
	void remove_strip (MeterStrip *);
	void update_metrics ();

	void session_going_away ();
	void sync_order_keys (ARDOUR::RouteSortOrderKey src);
	void resync_order ();

	std::list<MeterStrip *> strips;

	MeterStrip metrics_left;
	MeterStrip metrics_right;

	Gtk::VBox metrics_vpacker_left;
	Gtk::VBox metrics_vpacker_right;
	Gtk::HBox metrics_spacer_left;
	Gtk::HBox metrics_spacer_right;

	static const int32_t default_width = 600;
	static const int32_t default_height = 400;
	static const int max_height = 1200; // == 1024 + 148 + 16 + 12 see meter_strip.cc
	int cur_max_width;

	void update_title ();

	// for restoring window geometry.
	int m_root_x, m_root_y, m_width, m_height;

	void set_window_pos_and_size ();
	void get_window_pos_and_size ();

	bool on_key_press_event (GdkEventKey*);
	bool on_key_release_event (GdkEventKey*);

	void on_size_allocate (Gtk::Allocation&);
	void on_size_request (Gtk::Requisition*);

	void parameter_changed (std::string const & p);
};

#endif