traverso-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Traverso-commit] traverso/src/traverso/songcanvas TimeLineView.cpp


From: Remon Sijrier
Subject: [Traverso-commit] traverso/src/traverso/songcanvas TimeLineView.cpp
Date: Wed, 09 May 2007 13:48:04 +0000

CVSROOT:        /sources/traverso
Module name:    traverso
Changes by:     Remon Sijrier <r_sijrier>       07/05/09 13:48:04

Modified files:
        src/traverso/songcanvas: TimeLineView.cpp 

Log message:
        * QPainter::drawText() has an x position limit which can be easily 
reached on the timeline view at high zoomlevels. 
        The limit isn't documented afaiks, and the mapping by the items matrix 
seems to be done 
        after the 'painting' 
        Fixed by not using the items matrix, but calculating the offset 
ourselves.... 
        * Double paint events due item rect. are grown by 1 pixel, temp fix to 
check if there is  
        really need to repaint the text (which is the most expensive part..) 

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/songcanvas/TimeLineView.cpp?cvsroot=traverso&r1=1.30&r2=1.31

Patches:
Index: TimeLineView.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/songcanvas/TimeLineView.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- TimeLineView.cpp    8 May 2007 22:13:40 -0000       1.30
+++ TimeLineView.cpp    9 May 2007 13:48:04 -0000       1.31
@@ -237,17 +237,25 @@
 
 void TimeLineView::paint(QPainter* painter, const QStyleOptionGraphicsItem* 
option, QWidget* widget)
 {
-       PENTER3;
+       PENTER;
        Q_UNUSED(widget);
        
+       painter->save();
+       
        // When the scrollarea moves by a small value, the text
        // can be screwed up, so give it some room, 100 pixels should do!
        int xstart = (int) option->exposedRect.x() - 100;
        int pixelcount = (int) option->exposedRect.width() + 100;
+       int expheight = (int) option->exposedRect.height();
+       int top = (int) option->exposedRect.top();
+       bool paintText = top > 28 &&  expheight < 2 ? false : true;
+       
        if (xstart < 0) {
                xstart = 0;
        }
        
+       painter->setClipRect(m_boundingRect);
+       
        int height = TIMELINE_HEIGHT;
        
        painter->fillRect(xstart, 0,  pixelcount, height, 
themer()->get_color("Timeline:background") );
@@ -269,18 +277,26 @@
 
        nframes_t firstFrame = xstart * m_sv->scalefactor;
        nframes_t lastFrame = xstart * m_sv->scalefactor + pixelcount * 
m_sv->scalefactor;
+       int xstartoffset = m_sv->hscrollbar_value();
+       
+       painter->setMatrixEnabled(false);
 
        // Draw minor ticks
        for (int i = 0; i < (lastFrame-firstFrame+major) / minor; i++ ) {
                int x = (int)(((int)(firstFrame/major))*major + i * 
minor)/m_sv->scalefactor;
-               painter->drawLine(x, height - 5, x, height - 1);
+               painter->drawLine(x - xstartoffset, height - 5, x - 
xstartoffset, height - 1);
        }
        
        // Draw major ticks
        for (nframes_t frame = ((int)(firstFrame/major))*major; frame < 
lastFrame; frame += major ) {
-               painter->drawLine(frame/m_sv->scalefactor, height - 13, 
frame/m_sv->scalefactor, height - 1);
-               painter->drawText(frame/m_sv->scalefactor + 4, height - 8, 
frame_to_text(frame, m_samplerate, m_sv->scalefactor));
+               int x = frame/m_sv->scalefactor - xstartoffset;
+               painter->drawLine(x, height - 13, x, height - 1);
+               if (paintText) {
+                       painter->drawText(x + 4, height - 8, 
frame_to_text(frame, m_samplerate, m_sv->scalefactor));
+               }
        }
+       
+       painter->restore();
 }
 
 void TimeLineView::calculate_bounding_rect()




reply via email to

[Prev in Thread] Current Thread [Next in Thread]