From d293d53136fa7e6e7eda510847145edf4d3d7f55 Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Tue, 1 Dec 2009 12:26:59 +0100 Subject: Add hover text to the graph. When the graph display is paused, leaving the mouse stationary over the graph will display the data point under the pointer. * grapher/CairoWidget.hxx (CairoTextBox): new class (CairoWidget, CairoPlayButton): refector some play button-specific things from CairoWidget to CairoPlayButton. * grapher/CairoWidget.cxx (CairoTextBox::draw): new function. * grapher/GraphWidget.hxx (GraphWidget): new members for supporting hover text. * grapher/GraphWidget.cxx (on_motion_notify_event): Set up hover text box. (establishHoverTimeout, onHoverTimeout, getGraphUnderPoint): new functions. --- grapher/CairoWidget.cxx | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'grapher/CairoWidget.cxx') diff --git a/grapher/CairoWidget.cxx b/grapher/CairoWidget.cxx index 86498a4f..f627dfaa 100644 --- a/grapher/CairoWidget.cxx +++ b/grapher/CairoWidget.cxx @@ -39,4 +39,25 @@ namespace systemtap else return false; } + + void CairoTextBox::draw(Cairo::RefPtr cr) + { + if (!_visible) + return; + cr->save(); + Cairo::TextExtents extents; + cr->get_text_extents(contents, extents); + double width = extents.width, height = extents.height; + cr->move_to(_x0 - 2, _y0 - 2); + cr->line_to(_x0 + width + 2, _y0 - 2); + cr->line_to(_x0 + width + 2, _y0 + height + 2); + cr->line_to(_x0 - 2, _y0 + height + 2); + cr->close_path(); + cr->set_source_rgba(1.0, 1.0, 1.0, .8); + cr->fill(); + cr->set_source_rgba(0.0, 0.0, 0.0, 1.0); + cr->move_to(_x0, _y0 + height); + cr->show_text(contents); + cr->restore(); + } } -- cgit