2013-05-04 22:01:13 -04:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2013-2016 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2014-2017 Robin Gareus <robin@gareus.org>
|
|
|
|
*
|
|
|
|
* 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.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2013-05-04 22:01:13 -04:00
|
|
|
|
2013-05-04 22:02:05 -04:00
|
|
|
#include <algorithm>
|
|
|
|
#include <string>
|
2013-10-03 04:12:02 -04:00
|
|
|
#include <vector>
|
2013-05-04 22:01:13 -04:00
|
|
|
|
2016-09-06 16:17:39 -04:00
|
|
|
#include "gtkmm2ext/utils.h"
|
|
|
|
|
2013-05-04 22:02:05 -04:00
|
|
|
#include "ardour_ui.h"
|
2013-05-04 22:01:13 -04:00
|
|
|
#include "audio_clock.h"
|
2013-05-04 22:02:05 -04:00
|
|
|
#include "big_clock_window.h"
|
|
|
|
#include "public_editor.h"
|
|
|
|
#include "utils.h"
|
2013-05-04 22:01:13 -04:00
|
|
|
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2013-05-04 22:01:13 -04:00
|
|
|
|
2013-05-04 22:02:05 -04:00
|
|
|
using std::min;
|
|
|
|
using std::string;
|
2014-06-25 15:27:37 -04:00
|
|
|
using namespace ARDOUR_UI_UTILS;
|
2013-05-04 22:01:13 -04:00
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
BigClockWindow::BigClockWindow (AudioClock& c)
|
2013-05-04 22:01:13 -04:00
|
|
|
: ArdourWindow (_("Big Clock"))
|
|
|
|
, clock (c)
|
|
|
|
{
|
2020-10-01 12:32:06 -04:00
|
|
|
ARDOUR_UI::Clock.connect (sigc::bind (sigc::mem_fun (clock, &AudioClock::set), false, Temporal::timecnt_t()));
|
2013-05-04 22:01:13 -04:00
|
|
|
|
|
|
|
clock.set_corner_radius (0.0);
|
|
|
|
|
2013-05-04 22:02:05 -04:00
|
|
|
set_keep_above (true);
|
|
|
|
set_border_width (0);
|
|
|
|
add (clock);
|
|
|
|
clock.show_all ();
|
2015-01-02 08:23:56 -05:00
|
|
|
|
2022-01-26 16:00:02 -05:00
|
|
|
default_size = clock.size_request ();
|
2015-01-02 09:01:11 -05:00
|
|
|
|
2015-01-02 08:23:56 -05:00
|
|
|
clock.signal_size_allocate().connect (sigc::mem_fun (*this, &BigClockWindow::clock_size_reallocated));
|
2013-05-04 22:01:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
BigClockWindow::on_unmap ()
|
|
|
|
{
|
2013-05-05 15:07:52 -04:00
|
|
|
ArdourWindow::on_unmap ();
|
2016-09-06 16:17:39 -04:00
|
|
|
ARDOUR_UI::instance()->reset_focus (this);
|
2013-05-04 22:01:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
BigClockWindow::on_key_press_event (GdkEventKey* ev)
|
|
|
|
{
|
2013-05-04 22:02:05 -04:00
|
|
|
return relay_key_press (ev, this);
|
2013-05-04 22:01:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
BigClockWindow::on_realize ()
|
|
|
|
{
|
|
|
|
ArdourWindow::on_realize ();
|
2015-01-12 16:34:08 -05:00
|
|
|
/* (try to) ensure that resizing is possible and the window can be moved (and closed) */
|
|
|
|
get_window()->set_decorations (Gdk::DECOR_BORDER | Gdk::DECOR_RESIZEH | Gdk::DECOR_TITLE | Gdk::DECOR_MENU);
|
2015-01-02 09:01:11 -05:00
|
|
|
|
2015-01-12 16:34:08 -05:00
|
|
|
/* try to force a fixed aspect ratio so that we don't distort the font */
|
2015-01-02 09:01:11 -05:00
|
|
|
float aspect = default_size.width/(float)default_size.height;
|
|
|
|
Gdk::Geometry geom;
|
|
|
|
|
|
|
|
geom.min_aspect = aspect;
|
|
|
|
geom.max_aspect = aspect;
|
|
|
|
geom.min_width = -1; /* use requisition */
|
|
|
|
geom.min_height = -1; /* use requisition */
|
|
|
|
|
|
|
|
get_window()->set_geometry_hints (geom, Gdk::WindowHints (Gdk::HINT_ASPECT|Gdk::HINT_MIN_SIZE));
|
2013-05-04 22:01:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-01-02 08:23:56 -05:00
|
|
|
BigClockWindow::clock_size_reallocated (Gtk::Allocation& alloc)
|
2013-05-04 22:01:13 -04:00
|
|
|
{
|
2015-01-02 08:23:56 -05:00
|
|
|
clock.set_scale ((double) alloc.get_width() / default_size.width,
|
|
|
|
(double) alloc.get_height() / default_size.height);
|
2013-05-04 22:01:13 -04:00
|
|
|
}
|
|
|
|
|
2014-12-31 07:20:38 -05:00
|
|
|
|