From 6d71d7f35344d6b0115e047be4071e044c4c15aa Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Sun, 4 Sep 2011 21:29:12 +1000 Subject: [PATCH] Confine barchart tooltip to graph area --- Graphs/gBarChart.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Graphs/gBarChart.cpp b/Graphs/gBarChart.cpp index 1a4c8362..23f61aa1 100644 --- a/Graphs/gBarChart.cpp +++ b/Graphs/gBarChart.cpp @@ -183,8 +183,13 @@ bool gBarChart::mouseMoveEvent(QMouseEvent *event) int x=event->x()-10; int w=90; int h=32; - int y=rtop+event->y()-42; + int y=event->y()-42; + if (x<41+w/2) x=41+w/2; + if (y<1) y=1; + if (x>39+l_width-w/2) x=39+l_width-w/2; + if (y>l_height-h+1) y=l_height-h+1; + y+=rtop; //TODO: Convert this to a ToolTip class graph->quads()->add(x,y,x,y+h,col); @@ -201,10 +206,10 @@ bool gBarChart::mouseMoveEvent(QMouseEvent *event) QDateTime dt=QDateTime::fromTime_t(hl_day*86400); QString z=dt.date().toString(Qt::SystemLocaleShortDate); - graph->renderText(z,event->x(),y+11); + graph->renderText(z,x+10,y+11); z=m_label+"="+QString::number(d.value()[0],'f',2); qstatus2->setText(z); - graph->renderText(z,event->x(),y+26); + graph->renderText(z,x+10,y+26); return true; }