diff --git a/gtk2_ardour/big_clock_window.cc b/gtk2_ardour/big_clock_window.cc index d625b87dec..033e87f238 100644 --- a/gtk2_ardour/big_clock_window.cc +++ b/gtk2_ardour/big_clock_window.cc @@ -36,15 +36,12 @@ using namespace ARDOUR_UI_UTILS; BigClockWindow::BigClockWindow (AudioClock& c) : ArdourWindow (_("Big Clock")) , clock (c) - , resize_in_progress (false) , original_height (0) , original_width (0) - , original_font_size (0) { ARDOUR_UI::Clock.connect (sigc::mem_fun (clock, &AudioClock::set)); clock.set_corner_radius (0.0); - clock.mode_changed.connect (sigc::mem_fun (*this, &BigClockWindow::reset_aspect_ratio)); set_keep_above (true); set_border_width (0); @@ -69,24 +66,11 @@ BigClockWindow::on_key_press_event (GdkEventKey* ev) void BigClockWindow::on_realize () { - int x, y, w, d, h; - ArdourWindow::on_realize (); - get_window()->set_decorations (Gdk::DECOR_BORDER|Gdk::DECOR_RESIZEH); - get_window()->get_geometry (x, y, w, h, d); - reset_aspect_ratio (); - - original_height = h; - original_width = w; - - Pango::FontDescription fd (clock.get_style()->get_font()); - original_font_size = fd.get_size (); - - if (!fd.get_size_is_absolute ()) { - original_font_size /= PANGO_SCALE; - } + int x, y, d; + get_window()->get_geometry (x, y, original_width, original_height, d); } void @@ -94,67 +78,21 @@ BigClockWindow::on_size_allocate (Gtk::Allocation& alloc) { ArdourWindow::on_size_allocate (alloc); - if (!resize_in_progress) { - Glib::signal_idle().connect (sigc::bind (sigc::mem_fun (*this, &BigClockWindow::text_resizer), 0, 0)); - resize_in_progress = true; + if (original_width) { + clock.set_scale ((double) alloc.get_width() / original_width, + (double) alloc.get_height() / original_height); + + + + std::cerr << "Rescale to " + << (double) alloc.get_width() / original_width + << " x " + << (double) alloc.get_height() / original_height + << " using " << alloc.get_width() << " vs. " << original_width + << " and " << alloc.get_height() << " vs. " << original_height + << std::endl; + } } -void -BigClockWindow::reset_aspect_ratio () -{ - Gtk::Requisition req = { 0, 0 }; - - clock.size_request (req); - - float aspect = req.width/(float)req.height; - Gdk::Geometry geom; - - geom.min_aspect = aspect; - geom.max_aspect = aspect; - - set_geometry_hints (clock, geom, Gdk::HINT_ASPECT); -} - -bool -BigClockWindow::text_resizer (int, int) -{ - resize_in_progress = false; - - Glib::RefPtr win = get_window(); - Pango::FontDescription fd (clock.get_style()->get_font()); - int current_size = fd.get_size (); - int x, y, w, h, d; - - if (!fd.get_size_is_absolute ()) { - current_size /= PANGO_SCALE; - } - - win->get_geometry (x, y, w, h, d); - - double scale = min (((double) w / (double) original_width), - ((double) h / (double) original_height)); - - int size = (int) lrintf (original_font_size * scale); - - if (size != current_size) { - - string family = fd.get_family(); - std::vector buf(family.length()+16); - snprintf (&buf[0], family.length()+16, "%s %d", family.c_str(), size); - - try { - Pango::FontDescription fd (&buf[0]); - Glib::RefPtr rcstyle = clock.get_modifier_style (); - rcstyle->set_font (fd); - clock.modify_style (rcstyle); - } - - catch (...) { - /* oh well, do nothing */ - } - } - - return false; -} diff --git a/gtk2_ardour/big_clock_window.h b/gtk2_ardour/big_clock_window.h index c1a5b0ebee..c83f61b054 100644 --- a/gtk2_ardour/big_clock_window.h +++ b/gtk2_ardour/big_clock_window.h @@ -26,23 +26,18 @@ class AudioClock; class BigClockWindow : public ArdourWindow { - public: - BigClockWindow (AudioClock&); - - private: - AudioClock& clock; - bool resize_in_progress; - int original_height; - int original_width; - int original_font_size; - - void on_size_allocate (Gtk::Allocation&); - void on_realize (); - void on_unmap (); - bool on_key_press_event (GdkEventKey*); - - bool text_resizer (int, int); - void reset_aspect_ratio (); + public: + BigClockWindow (AudioClock&); + + private: + AudioClock& clock; + int original_height; + int original_width; + + void on_size_allocate (Gtk::Allocation&); + void on_realize (); + void on_unmap (); + bool on_key_press_event (GdkEventKey*); }; #endif // __ardour_window_h__