- Glib::RefPtr<Gdk::Window> win (w.get_window());
-
- gint width, height;
- win->get_size (width, height);
-
- cairo_surface_t* surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, width, height);
- cairo_t* cr = cairo_create (surface);
- Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create(w.get_pango_context());
-
-
- Pango::AttrList audio_font_attributes;
- Pango::AttrList midi_font_attributes;
-
- Pango::AttrFontDesc* font_attr;
- Pango::FontDescription font;
-
- font = Pango::FontDescription (""); // use defaults
- //font = get_font_for_style("gain-fader");
- //font = w.get_style()->get_font();
-
- font.set_weight (Pango::WEIGHT_NORMAL);
- font.set_size (10.0 * PANGO_SCALE);
- font_attr = new Pango::AttrFontDesc (Pango::Attribute::create_attr_font_desc (font));
- audio_font_attributes.change (*font_attr);
- delete font_attr;
-
- font.set_weight (Pango::WEIGHT_ULTRALIGHT);
- font.set_stretch (Pango::STRETCH_ULTRA_CONDENSED);
- font.set_size (7.5 * PANGO_SCALE);
- font_attr = new Pango::AttrFontDesc (Pango::Attribute::create_attr_font_desc (font));
- midi_font_attributes.change (*font_attr);
- delete font_attr;
-
-
- cairo_move_to (cr, 0, 0);
- cairo_rectangle (cr, 0, 0, width, height);
- {
- Gdk::Color c = w.get_style()->get_bg (Gtk::STATE_NORMAL);
- cairo_set_source_rgb (cr, c.get_red_p(), c.get_green_p(), c.get_blue_p());
- }
- cairo_fill (cr);
-
- for (vector<DataType>::const_iterator i = types.begin(); i != types.end(); ++i) {
-
- Gdk::Color c;
-
- if (types.size() > 1) {
- /* we're overlaying more than 1 set of marks, so use different colours */
- Gdk::Color c;
- switch (*i) {
- case DataType::AUDIO:
- c = w.get_style()->get_fg (Gtk::STATE_NORMAL);
- cairo_set_source_rgb (cr, c.get_red_p(), c.get_green_p(), c.get_blue_p());
- break;
- case DataType::MIDI:
- c = w.get_style()->get_fg (Gtk::STATE_ACTIVE);
- cairo_set_source_rgb (cr, c.get_red_p(), c.get_green_p(), c.get_blue_p());
- break;
- }
- } else {
- c = w.get_style()->get_fg (Gtk::STATE_NORMAL);
- cairo_set_source_rgb (cr, c.get_red_p(), c.get_green_p(), c.get_blue_p());
- }
-
- vector<int> points;
-
- switch (*i) {
- case DataType::AUDIO:
- layout->set_attributes (audio_font_attributes);
- points.push_back (-50);
- points.push_back (-40);
- points.push_back (-30);
- points.push_back (-20);
- points.push_back (-10);
- points.push_back (-3);
- points.push_back (0);
- points.push_back (4);
- break;
-
- case DataType::MIDI:
- layout->set_attributes (midi_font_attributes);
- points.push_back (0);
- if (types.size() == 1) {
- points.push_back (32);
- } else {
- /* tweak so as not to overlay the -30dB mark */
- points.push_back (48);
- }
- points.push_back (64);
- points.push_back (96);
- points.push_back (127);
- break;
- }
-
- char buf[32];
-
- for (vector<int>::const_iterator j = points.begin(); j != points.end(); ++j) {
-
- float fraction = 0;
- switch (*i) {
- case DataType::AUDIO:
- fraction = log_meter (*j);
- break;
- case DataType::MIDI:
- fraction = *j / 127.0;
- break;
- }
-
- gint const pos = height - (gint) floor (height * fraction);
-
- cairo_set_line_width (cr, 1.0);
- cairo_move_to (cr, 0, pos);
- cairo_line_to (cr, 3.5, pos);
- cairo_stroke (cr);
-
- snprintf (buf, sizeof (buf), "%2d", abs (*j));
- layout->set_text(buf);
-
- /* we want logical extents, not ink extents here */
-
- int tw, th;
- layout->get_pixel_size(tw, th);
-
- int p = pos - (th / 2);
- p = min (p, height - th);
- p = max (p, 0);
-
- cairo_move_to (cr, 5, p);
- pango_cairo_show_layout (cr, layout->gobj());
- }