13
0

remember big clock window scaling, or rather, recompute it accurately

This commit is contained in:
Paul Davis 2015-01-02 08:23:56 -05:00
parent 884cc6f90c
commit 9ef350cb90
2 changed files with 10 additions and 15 deletions

View File

@ -36,8 +36,6 @@ using namespace ARDOUR_UI_UTILS;
BigClockWindow::BigClockWindow (AudioClock& c) BigClockWindow::BigClockWindow (AudioClock& c)
: ArdourWindow (_("Big Clock")) : ArdourWindow (_("Big Clock"))
, clock (c) , clock (c)
, original_height (0)
, original_width (0)
{ {
ARDOUR_UI::Clock.connect (sigc::mem_fun (clock, &AudioClock::set)); ARDOUR_UI::Clock.connect (sigc::mem_fun (clock, &AudioClock::set));
@ -47,6 +45,9 @@ BigClockWindow::BigClockWindow (AudioClock& c)
set_border_width (0); set_border_width (0);
add (clock); add (clock);
clock.show_all (); clock.show_all ();
clock.size_request (default_size);
clock.signal_size_allocate().connect (sigc::mem_fun (*this, &BigClockWindow::clock_size_reallocated));
} }
void void
@ -67,21 +68,16 @@ void
BigClockWindow::on_realize () BigClockWindow::on_realize ()
{ {
ArdourWindow::on_realize (); ArdourWindow::on_realize ();
/* (try to) ensure that resizing is possible.
*/
get_window()->set_decorations (Gdk::DECOR_BORDER|Gdk::DECOR_RESIZEH); get_window()->set_decorations (Gdk::DECOR_BORDER|Gdk::DECOR_RESIZEH);
int x, y, d;
get_window()->get_geometry (x, y, original_width, original_height, d);
} }
void void
BigClockWindow::on_size_allocate (Gtk::Allocation& alloc) BigClockWindow::clock_size_reallocated (Gtk::Allocation& alloc)
{ {
ArdourWindow::on_size_allocate (alloc); clock.set_scale ((double) alloc.get_width() / default_size.width,
(double) alloc.get_height() / default_size.height);
if (original_width) {
clock.set_scale ((double) alloc.get_width() / original_width,
(double) alloc.get_height() / original_height);
}
} }

View File

@ -31,10 +31,9 @@ class BigClockWindow : public ArdourWindow
private: private:
AudioClock& clock; AudioClock& clock;
int original_height; Gtk::Requisition default_size;
int original_width;
void on_size_allocate (Gtk::Allocation&); void clock_size_reallocated (Gtk::Allocation&);
void on_realize (); void on_realize ();
void on_unmap (); void on_unmap ();
bool on_key_press_event (GdkEventKey*); bool on_key_press_event (GdkEventKey*);