diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2011-11-19 14:27:05 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2011-11-19 14:27:05 +0000 |
commit | eb1d3e48c822b4235e8dbf58e645ea733e4523b0 (patch) | |
tree | de2142c9bc722bffe48d81ca76fd26090e9c9d6d /gtk2_ardour | |
parent | 7e5dea02fb0b67828097a0378ffc31bc47302edd (diff) |
fix up big clock aspect ratio; fix color handling in audio clocks
git-svn-id: svn://localhost/ardour2/branches/3.0@10704 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/ardour_ui_ed.cc | 12 | ||||
-rw-r--r-- | gtk2_ardour/audio_clock.cc | 92 | ||||
-rw-r--r-- | gtk2_ardour/audio_clock.h | 4 |
3 files changed, 89 insertions, 19 deletions
diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc index e661f05fe6..c47f2023ae 100644 --- a/gtk2_ardour/ardour_ui_ed.cc +++ b/gtk2_ardour/ardour_ui_ed.cc @@ -641,6 +641,8 @@ ARDOUR_UI::setup_clock () { ARDOUR_UI::Clock.connect (sigc::mem_fun (big_clock, &AudioClock::set)); + big_clock->set_corner_radius (0.0); + big_clock_window->set (new Window (WINDOW_TOPLEVEL), false); big_clock_window->get()->set_keep_above (true); @@ -666,6 +668,16 @@ ARDOUR_UI::big_clock_realized () set_decoration (big_clock_window->get(), (Gdk::DECOR_BORDER|Gdk::DECOR_RESIZEH)); big_clock_window->get()->get_window()->get_geometry (x, y, w, big_clock_height, d); + Gtk::Requisition req; + big_clock->size_request (req); + float aspect = req.width/(float)req.height; + Gdk::Geometry geom; + + geom.min_aspect = aspect; + geom.max_aspect = aspect; + + big_clock_window->get()->set_geometry_hints (*big_clock, geom, Gdk::HINT_ASPECT); + original_big_clock_height = big_clock_height; original_big_clock_width = w; diff --git a/gtk2_ardour/audio_clock.cc b/gtk2_ardour/audio_clock.cc index 3dbdfa8598..b8e6cd0ac8 100644 --- a/gtk2_ardour/audio_clock.cc +++ b/gtk2_ardour/audio_clock.cc @@ -68,7 +68,14 @@ AudioClock::AudioClock (const string& clock_name, bool transient, const string& , ops_menu (0) , editing_attr (0) , foreground_attr (0) + , first_height (0) + , first_width (0) + , layout_height (0) + , layout_width (0) + , info_height (0) + , upper_height (0) , mode_based_info_ratio (1.0) + , corner_radius (9) , editing (false) , bbt_reference_time (-1) , last_when(0) @@ -189,24 +196,28 @@ AudioClock::set_colors () /* store for bg in render() */ UINT_TO_RGBA (bg_color, &r, &g, &b, &a); - r = lrint ((r/256.0) * 65535.0); - g = lrint ((g/256.0) * 65535.0); - b = lrint ((b/256.0) * 65535.0); - bg_r = r/256.0; - bg_g = g/256.0; - bg_b = b/256.0; - bg_a = a/256.0; + + bg_r = r/255.0; + bg_g = g/255.0; + bg_b = b/255.0; + bg_a = a/255.0; + + /* rescale for Pango colors ... sigh */ + + r = lrint (r * 65535.0); + g = lrint (g * 65535.0); + b = lrint (b * 65535.0); UINT_TO_RGBA (text_color, &r, &g, &b, &a); - r = lrint ((r/256.0) * 65535.0); - g = lrint ((g/256.0) * 65535.0); - b = lrint ((b/256.0) * 65535.0); + r = lrint ((r/255.0) * 65535.0); + g = lrint ((g/255.0) * 65535.0); + b = lrint ((b/255.0) * 65535.0); foreground_attr = new Pango::AttrColor (Pango::Attribute::create_attr_foreground (r, g, b)); UINT_TO_RGBA (editing_color, &r, &g, &b, &a); - r = lrint ((r/256.0) * 65535.0); - g = lrint ((g/256.0) * 65535.0); - b = lrint ((b/256.0) * 65535.0); + r = lrint ((r/255.0) * 65535.0); + g = lrint ((g/255.0) * 65535.0); + b = lrint ((b/255.0) * 65535.0); editing_attr = new Pango::AttrColor (Pango::Attribute::create_attr_foreground (r, g, b)); normal_attributes.change (*foreground_attr); @@ -235,11 +246,20 @@ AudioClock::render (cairo_t* cr) if (_need_bg) { cairo_set_source_rgba (cr, bg_r, bg_g, bg_b, bg_a); - Gtkmm2ext::rounded_rectangle (cr, 0, 0, get_width(), upper_height, 9); + if (corner_radius) { + Gtkmm2ext::rounded_rectangle (cr, 0, 0, get_width(), upper_height, corner_radius); + } else { + cairo_rectangle (cr, 0, 0, get_width(), upper_height); + } cairo_fill (cr); } - cairo_move_to (cr, x_leading_padding, (upper_height - layout_height) / 2.0); + if (corner_radius) { + cairo_move_to (cr, x_leading_padding, (upper_height - layout_height) / 2.0); + } else { + cairo_move_to (cr, x_leading_padding, 0); + } + pango_cairo_show_layout (cr, _layout->gobj()); if (_left_layout) { @@ -255,7 +275,11 @@ AudioClock::render (cairo_t* cr) double left_rect_width = round (((get_width() - separator_height) * mode_based_info_ratio) + 0.5); if (_need_bg) { - Gtkmm2ext::rounded_rectangle (cr, 0, upper_height + separator_height, left_rect_width, h, 9); + if (corner_radius) { + Gtkmm2ext::rounded_rectangle (cr, 0, upper_height + separator_height, left_rect_width, h, corner_radius); + } else { + cairo_rectangle (cr, 0, upper_height + separator_height, left_rect_width, h); + } cairo_fill (cr); } @@ -263,8 +287,14 @@ AudioClock::render (cairo_t* cr) pango_cairo_show_layout (cr, _left_layout->gobj()); if (_need_bg) { - Gtkmm2ext::rounded_rectangle (cr, left_rect_width + separator_height, upper_height + separator_height, - get_width() - separator_height - left_rect_width, h, 9); + if (corner_radius) { + Gtkmm2ext::rounded_rectangle (cr, left_rect_width + separator_height, upper_height + separator_height, + get_width() - separator_height - left_rect_width, h, + corner_radius); + } else { + cairo_rectangle (cr, left_rect_width + separator_height, upper_height + separator_height, + get_width() - separator_height - left_rect_width, h); + } cairo_fill (cr); } @@ -275,7 +305,11 @@ AudioClock::render (cairo_t* cr) /* no info to display, or just one */ if (_need_bg) { - Gtkmm2ext::rounded_rectangle (cr, 0, upper_height + separator_height, get_width(), h, 9); + if (corner_radius) { + Gtkmm2ext::rounded_rectangle (cr, 0, upper_height + separator_height, get_width(), h, corner_radius); + } else { + cairo_rectangle (cr, 0, upper_height + separator_height, get_width(), h); + } cairo_fill (cr); } } @@ -321,10 +355,21 @@ AudioClock::on_size_allocate (Gtk::Allocation& alloc) void AudioClock::on_size_request (Gtk::Requisition* req) { + /* our size never changes, so once we've computed it, + just return it + */ + + if (first_width) { + req->width = first_width; + req->height = first_height; + return; + } + Glib::RefPtr<Pango::Layout> tmp; Glib::RefPtr<Gtk::Style> style = get_style (); Pango::FontDescription font; + tmp = Pango::Layout::create (get_pango_context()); if (!is_realized()) { @@ -376,6 +421,9 @@ AudioClock::on_size_request (Gtk::Requisition* req) req->height += info_height; req->height += separator_height; } + + first_height = req->height; + first_width = req->width; } void @@ -1842,3 +1890,9 @@ AudioClock::focus () } +void +AudioClock::set_corner_radius (double r) +{ + corner_radius = r; + queue_draw (); +} diff --git a/gtk2_ardour/audio_clock.h b/gtk2_ardour/audio_clock.h index f4681c279c..a5705da022 100644 --- a/gtk2_ardour/audio_clock.h +++ b/gtk2_ardour/audio_clock.h @@ -59,6 +59,7 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr void set_widget_name (const std::string& name); void set_active_state (Gtkmm2ext::ActiveState s); void set_editable (bool yn); + void set_corner_radius (double); void focus (); @@ -108,11 +109,14 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr Pango::AttrList editing_attributes; Pango::AttrList info_attributes; + int first_height; + int first_width; int layout_height; int layout_width; int info_height; int upper_height; double mode_based_info_ratio; + double corner_radius; static const double info_font_scale_factor; static const double separator_height; |