traverso-commit
[Top][All Lists]
Advanced

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

[Traverso-commit] traverso/src/traverso/songcanvas AudioClipView....


From: Remon Sijrier
Subject: [Traverso-commit] traverso/src/traverso/songcanvas AudioClipView....
Date: Tue, 22 May 2007 19:52:43 +0000

CVSROOT:        /sources/traverso
Module name:    traverso
Changes by:     Remon Sijrier <r_sijrier>       07/05/22 19:52:43

Modified files:
        src/traverso/songcanvas: AudioClipView.cpp FadeView.cpp 

Log message:
        * Merge fadeout into waveform, fixing dragging beyond left edge of 
clipview bug

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/songcanvas/AudioClipView.cpp?cvsroot=traverso&r1=1.67&r2=1.68
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/songcanvas/FadeView.cpp?cvsroot=traverso&r1=1.15&r2=1.16

Patches:
Index: AudioClipView.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/songcanvas/AudioClipView.cpp,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -b -r1.67 -r1.68
--- AudioClipView.cpp   17 May 2007 06:55:43 -0000      1.67
+++ AudioClipView.cpp   22 May 2007 19:52:43 -0000      1.68
@@ -308,14 +308,14 @@
        float fademixdown[pixelcount];
        for (int i = 0; i < m_fadeViews.size(); ++i) {
                FadeView* view = m_fadeViews.at(i);
-               int fademix;
+               int fademix = 0;
                if (mixcurvedata) {
                        fademix = view->get_vector(xstart, pixelcount, 
fademixdown);
                } else {
                        fademix = view->get_vector(xstart, pixelcount, 
curvemixdown);
                }
                
-               if (mixcurvedata && fademix && view->get_fade()->get_range() > 
m_sv->scalefactor) {
+               if (mixcurvedata && fademix) {
                        for (int j=0; j<pixelcount; ++j) {
                                curvemixdown[j] *= fademixdown[j];
                        }
@@ -633,7 +633,7 @@
 Command * AudioClipView::fade_range()
 {
        Q_ASSERT(m_song);
-       int x = (int) cpointer().on_first_input_event_scene_x() - 
scenePos().x();
+       int x = (int) (cpointer().on_first_input_event_scene_x() - 
scenePos().x());
 
        if (x < (m_boundingRect.width() / 2)) {
                return m_clip->clip_fade_in();
@@ -647,7 +647,7 @@
 Command * AudioClipView::reset_fade()
 {
        Q_ASSERT(m_song);
-       int x = (int) cpointer().on_first_input_event_scene_x() - 
scenePos().x();
+       int x = (int) (cpointer().on_first_input_event_scene_x() - 
scenePos().x());
 
        if (x < (m_boundingRect.width() / 2)) {
                return m_clip->reset_fade_in();

Index: FadeView.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/songcanvas/FadeView.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- FadeView.cpp        17 May 2007 06:55:43 -0000      1.15
+++ FadeView.cpp        22 May 2007 19:52:43 -0000      1.16
@@ -17,7 +17,7 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
 
-$Id: FadeView.cpp,v 1.15 2007/05/17 06:55:43 benjie Exp $
+$Id: FadeView.cpp,v 1.16 2007/05/22 19:52:43 r_sijrier Exp $
 */
 
 #include "FadeView.h"
@@ -95,7 +95,7 @@
        float vector[pixelcount];
        
        if (m_fadeCurve->get_fade_type() == FadeCurve::FadeOut && 
m_guicurve->get_range() > m_parentViewItem->boundingRect().width()) {
-               vector_start += (int) m_guicurve->get_range() - 
m_parentViewItem->boundingRect().width();
+               vector_start += (int) (m_guicurve->get_range() - 
m_parentViewItem->boundingRect().width());
        }
        
        m_guicurve->get_vector(vector_start, vector_start + pixelcount, vector, 
pixelcount);
@@ -162,38 +162,57 @@
 
 int FadeView::get_vector(int xstart, int pixelcount, float * arg)
 {
-       if (m_fadeCurve->get_fade_type() == FadeCurve::FadeOut) {
-               int mappedx = - (int) mapFromParent(0, 0).x();
-               // CurveView adjusts xstart with -1 and pixelcount with +2
-               // compensate for this!
-               if (false) {
-                       m_guicurve->get_vector(mappedx, mappedx + pixelcount, 
arg, pixelcount);
-                       return 1;
-               } else {
+       // If boundingrect width is smaller then a pixel, don't even try
+       if (m_boundingRect.width() < 1.0) {
                        return 0;
                }
+       
+       if (m_fadeCurve->get_fade_type() == FadeCurve::FadeOut) {
+               
+               // If the fade widt is larger the the clipview, add the 
difference,
+               // since the 'start' of the fadeview lies beyond the left edge 
of the clip!
+               if (m_boundingRect.width() > 
m_parentViewItem->boundingRect().width()) {
+                       xstart += (int)(m_boundingRect.width() - 
m_parentViewItem->boundingRect().width());
+               }
+               
+               // map the xstart position to the fadeviews x position
+               int mappedx = (int)mapFromParent(QPoint(xstart, 0)).x();
+               int x = mappedx;
+               float* p = arg;
+               
+               // check if the xstart lies before 'our' first pixel
+               if (mappedx < 0) {
+                       x = 0;
+                       // substract the difference from the pixelcount
+                       pixelcount += mappedx;
+                       
+                       // point to the mapped location of the buffer.
+                       p = arg - mappedx;
+                       
+                       // and if pixelcount is 0, there is nothing to do!
+                       if (pixelcount <= 0) {
+                               return 0;
        }
        
-       if (xstart < m_boundingRect.width()) {
-               m_guicurve->get_vector(xstart, xstart + pixelcount, arg, 
pixelcount);
-               return 1;
+                       // Any pixels outside of our range shouldn't alter the 
waveform,
+                       // so let's assign 1 to them!
+                       for (int i=0; i < - mappedx; ++i) {
+                               arg[i] = 1;
+                       }
        }
        
-       return 0;
-}
+               m_guicurve->get_vector(x, x + pixelcount, p, pixelcount);
 
-/*
-Command* FadeView::edit_properties()
-{
-       if (!m_dialog) {
-               m_dialog = new FadeContextDialog(m_fadeCurve);
+               return 1;
        }
        
-       m_dialog->show();
+       if (xstart < m_boundingRect.width()) {
+               m_guicurve->get_vector(xstart, xstart + pixelcount, arg, 
pixelcount);
+               return 1;
+       }
        
        return 0;
 }
-*/
 
 void FadeView::calculate_bounding_rect()
 {
@@ -205,12 +224,15 @@
                guinode->set_when_and_value(node->get_when() / 
m_sv->scalefactor, node->get_value());
        }
        
-       m_boundingRect = QRectF( 0, 0,
-                               (m_guicurve->get_range() <= 
m_parentViewItem->boundingRect().width()) ? m_guicurve->get_range() : 
m_parentViewItem->boundingRect().width(), 
-                               m_parentViewItem->get_height() );
+       double range = m_guicurve->get_range();
+       m_boundingRect = QRectF( 0, 0, range, m_parentViewItem->get_height() );
        
        if (m_fadeCurve->get_fade_type() == FadeCurve::FadeOut) {
-               setPos(m_parentViewItem->boundingRect().width() - 
m_boundingRect.width(), 
+               int diff = 0;
+               if (m_boundingRect.width() > 
m_parentViewItem->boundingRect().width()) {
+                       diff = (int)(m_boundingRect.width() - 
m_parentViewItem->boundingRect().width());
+               }
+               setPos(m_parentViewItem->boundingRect().width() - 
m_boundingRect.width() + diff, 
                       m_parentViewItem->get_childview_y_offset());
        } else {
                setPos(0, m_parentViewItem->get_childview_y_offset());




reply via email to

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