use new action map API instead of ActionManager::get_action
[ardour.git] / gtk2_ardour / big_clock_window.cc
1 /*
2     Copyright (C) 20002-2013 Paul Davis
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
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include <algorithm>
21 #include <string>
22 #include <vector>
23
24 #include "gtkmm2ext/utils.h"
25
26 #include "ardour_ui.h"
27 #include "audio_clock.h"
28 #include "big_clock_window.h"
29 #include "public_editor.h"
30 #include "utils.h"
31
32 #include "pbd/i18n.h"
33
34 using std::min;
35 using std::string;
36 using namespace ARDOUR_UI_UTILS;
37
38 BigClockWindow::BigClockWindow (AudioClock& c)
39         : ArdourWindow (_("Big Clock"))
40         , clock (c)
41 {
42         ARDOUR_UI::Clock.connect (sigc::bind (sigc::mem_fun (clock, &AudioClock::set), false, 0));
43
44         clock.set_corner_radius (0.0);
45
46         set_keep_above (true);
47         set_border_width (0);
48         add (clock);
49         clock.show_all ();
50
51         clock.size_request (default_size);
52
53         clock.signal_size_allocate().connect (sigc::mem_fun (*this, &BigClockWindow::clock_size_reallocated));
54 }
55
56 void
57 BigClockWindow::on_unmap ()
58 {
59         ArdourWindow::on_unmap ();
60         ARDOUR_UI::instance()->reset_focus (this);
61 }
62
63 bool
64 BigClockWindow::on_key_press_event (GdkEventKey* ev)
65 {
66         return relay_key_press (ev, this);
67 }
68
69 void
70 BigClockWindow::on_realize ()
71 {
72         ArdourWindow::on_realize ();
73         /* (try to) ensure that resizing is possible and the window can be moved (and closed) */
74         get_window()->set_decorations (Gdk::DECOR_BORDER | Gdk::DECOR_RESIZEH | Gdk::DECOR_TITLE | Gdk::DECOR_MENU);
75
76         /* try to force a fixed aspect ratio so that we don't distort the font */
77         float aspect = default_size.width/(float)default_size.height;
78         Gdk::Geometry geom;
79
80         geom.min_aspect = aspect;
81         geom.max_aspect = aspect;
82         geom.min_width = -1; /* use requisition */
83         geom.min_height = -1; /* use requisition */
84
85         get_window()->set_geometry_hints (geom, Gdk::WindowHints (Gdk::HINT_ASPECT|Gdk::HINT_MIN_SIZE));
86 }
87
88 void
89 BigClockWindow::clock_size_reallocated (Gtk::Allocation& alloc)
90 {
91         clock.set_scale ((double) alloc.get_width() / default_size.width,
92                          (double)  alloc.get_height() / default_size.height);
93 }
94
95