ardour
big_clock_window.cc
Go to the documentation of this file.
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 "ardour_ui.h"
25 #include "audio_clock.h"
26 #include "big_clock_window.h"
27 #include "public_editor.h"
28 #include "utils.h"
29 
30 #include "i18n.h"
31 
32 using std::min;
33 using std::string;
34 using namespace ARDOUR_UI_UTILS;
35 
37  : ArdourWindow (_("Big Clock"))
38  , clock (c)
39 {
40  ARDOUR_UI::Clock.connect (sigc::mem_fun (clock, &AudioClock::set));
41 
43 
44  set_keep_above (true);
45  set_border_width (0);
46  add (clock);
47  clock.show_all ();
48 
49  clock.size_request (default_size);
50 
51  clock.signal_size_allocate().connect (sigc::mem_fun (*this, &BigClockWindow::clock_size_reallocated));
52 }
53 
54 void
56 {
58 
60 }
61 
62 bool
64 {
65  return relay_key_press (ev, this);
66 }
67 
68 void
70 {
71  ArdourWindow::on_realize ();
72  /* (try to) ensure that resizing is possible and the window can be moved (and closed) */
73  get_window()->set_decorations (Gdk::DECOR_BORDER | Gdk::DECOR_RESIZEH | Gdk::DECOR_TITLE | Gdk::DECOR_MENU);
74 
75  /* try to force a fixed aspect ratio so that we don't distort the font */
76  float aspect = default_size.width/(float)default_size.height;
77  Gdk::Geometry geom;
78 
79  geom.min_aspect = aspect;
80  geom.max_aspect = aspect;
81  geom.min_width = -1; /* use requisition */
82  geom.min_height = -1; /* use requisition */
83 
84  get_window()->set_geometry_hints (geom, Gdk::WindowHints (Gdk::HINT_ASPECT|Gdk::HINT_MIN_SIZE));
85 }
86 
87 void
89 {
90  clock.set_scale ((double) alloc.get_width() / default_size.width,
91  (double) alloc.get_height() / default_size.height);
92 }
93 
94 
bool relay_key_press(GdkEventKey *ev, Gtk::Window *win)
Definition: utils.cc:301
void set(framepos_t, bool force=false, ARDOUR::framecnt_t offset=0)
Definition: audio_clock.cc:956
AudioClock & clock
bool on_key_press_event(GdkEventKey *)
void set_scale(double x, double y)
Definition: audio_clock.cc:284
BigClockWindow(AudioClock &)
#define _(Text)
Definition: i18n.h:11
void clock_size_reallocated(Gtk::Allocation &)
Gtk::Requisition default_size
static PublicEditor & instance()
void set_corner_radius(double)
static sigc::signal< void, framepos_t, bool, framepos_t > Clock
Definition: ardour_ui.h:210
virtual void reset_focus()=0