summaryrefslogtreecommitdiff
path: root/gtk2_ardour/big_clock_window.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2014-12-31 07:20:38 -0500
committerPaul Davis <paul@linuxaudiosystems.com>2014-12-31 07:20:48 -0500
commit9ca0ce4b7fe8dc9c11a64376114b47ca7b3d3836 (patch)
treea186eab4a284f6fc077170340da0aa827c323b34 /gtk2_ardour/big_clock_window.cc
parentd8405e2ebe4b7250fb8eaaad7166f0e81479e0d7 (diff)
use clock text scaling for big clock window
Diffstat (limited to 'gtk2_ardour/big_clock_window.cc')
-rw-r--r--gtk2_ardour/big_clock_window.cc88
1 files changed, 13 insertions, 75 deletions
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;
- }
-}
-
-void
-BigClockWindow::reset_aspect_ratio ()
-{
- Gtk::Requisition req = { 0, 0 };
-
- clock.size_request (req);
-
- float aspect = req.width/(float)req.height;
- Gdk::Geometry geom;
+ if (original_width) {
+ clock.set_scale ((double) alloc.get_width() / original_width,
+ (double) alloc.get_height() / original_height);
- 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<Gdk::Window> win = get_window();
- Pango::FontDescription fd (clock.get_style()->get_font());
- int current_size = fd.get_size ();
- int x, y, w, h, d;
+ 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;
- 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<char> buf(family.length()+16);
- snprintf (&buf[0], family.length()+16, "%s %d", family.c_str(), size);
-
- try {
- Pango::FontDescription fd (&buf[0]);
- Glib::RefPtr<Gtk::RcStyle> rcstyle = clock.get_modifier_style ();
- rcstyle->set_font (fd);
- clock.modify_style (rcstyle);
- }
-
- catch (...) {
- /* oh well, do nothing */
- }
- }
-
- return false;
}
+