Changeset 895

Show
Ignore:
Timestamp:
08/15/07 06:42:30 (1 year ago)
Author:
nikhilsharma
Message:

- included support for thumb-nailing (thumbnail selection)
- debugged the in/out point selection and playback

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/jahwidgets/src/qt3/widgets/timelineSlider.cpp

    r894 r895  
    126126struct TimelineSlider::PrivateTimeline 
    127127{ 
    128         enum Tracking { NONE, VALUE, IN, OUT }; 
     128        enum Tracking { NONE, VALUE, IN, OUT, THUMB }; 
    129129 
    130130        PrivateTimeline( TimelineSlider* p ) 
     
    152152        } 
    153153 
     154        int markerClamp( int i ) const 
     155        { 
     156                return std::max( std::min( i, activeRange->out ), activeRange->in ); 
     157        } 
     158 
    154159        int inClamp( int i ) const 
    155160        { 
     
    277282        bool hitInRect( QPoint pos ) const 
    278283        { 
    279                 // We've got to be in the thumb rect and outside the currentMarkerRect region 
     284                // We've got to be in the thumb rect and outside the currentMarkerRect/thumbnailMarkerRect region 
    280285                if ( inRect().contains( pos ) == false ) return false; 
    281                 return true; 
     286 
     287                // else check the marker/thumbnail rect 
     288                QRect markerRect = currentMarkerRect(); 
     289                QRect thumbnailRect = thumbnailMarkerRect(); 
     290                return !( markerRect.contains( pos ) && thumbnailRect.contains( pos ) ); 
    282291        } 
    283292 
    284293        bool hitOutRect( QPoint pos ) const 
    285294        { 
    286                 // We've got to be in the thumb rect and outside the currentMarkerRect region 
     295                // We've got to be in the thumb rect and outside the currentMarkerRect/thumbnailMarkerRect region 
    287296                if ( outRect().contains( pos ) == false ) return false; 
    288                 return true; 
     297 
     298                // else check the marker/thumbnail rect 
     299                QRect markerRect = currentMarkerRect(); 
     300                QRect thumbnailRect = thumbnailMarkerRect(); 
     301                return !( markerRect.contains( pos ) && thumbnailRect.contains( pos ) ); 
    289302        } 
    290303 
     
    569582} 
    570583 
     584// Insert an in/out range and return range id 
    571585int TimelineSlider::insertRange( int in, int out ) 
    572586{ 
     
    582596} 
    583597 
     598// Remove an in/out range 
    584599void TimelineSlider::removeRangeWithId( int id )  
    585600{ 
     
    608623} 
    609624 
     625// Return an array containing all in/out ranges 
    610626TimelineSlider::RangeArray TimelineSlider::allRanges() const 
    611627{ 
     
    622638} 
    623639 
     640// Returns a range specified by a range id 
    624641boost::optional<TimelineSlider::Range> TimelineSlider::rangeWithId( int id ) const 
    625642{ 
     
    679696} 
    680697 
     698// Returns currently active in/out range id 
    681699int TimelineSlider::activeRangeId() const 
    682700{ 
     
    684702} 
    685703 
     704// Sets a range id to active 
    686705void TimelineSlider::setActiveRangeId( int id ) 
    687706{ 
     
    836855        setMouseTracking( !m_impl->thumb.active.isNull()  
    837856                                          || !m_impl->inThumb.active.isNull()  
    838                                           || !m_impl->outThumb.active.isNull() ); 
     857                                          || !m_impl->outThumb.active.isNull() 
     858                                          || !m_impl->thumbnailMarker.active.isNull() ); 
    839859        update(); 
    840860} 
     
    894914        setMouseTracking( !m_impl->thumb.active.isNull()  
    895915                                          || !m_impl->inThumb.active.isNull()  
    896                                           || !m_impl->outThumb.active.isNull() ); 
     916                                          || !m_impl->outThumb.active.isNull() 
     917                                          || !m_impl->thumbnailMarker.active.isNull() ); 
    897918        update(); 
    898919} 
     
    930951        setMouseTracking( !m_impl->thumb.active.isNull()  
    931952                                          || !m_impl->inThumb.active.isNull()  
    932                                           || !m_impl->outThumb.active.isNull() ); 
     953                                          || !m_impl->outThumb.active.isNull() 
     954                                          || !m_impl->thumbnailMarker.active.isNull() ); 
    933955        update(); 
    934956} 
     
    953975{ 
    954976        m_impl->thumbnailMarker.normal = p; 
    955         setMouseTracking( !m_impl->thumbnailMarker.normal.isNull()  
    956                                           || !m_impl->thumbnailMarker.normal.isNull()  
    957                                           || !m_impl->thumbnailMarker.normal.isNull() ); 
     977        setMouseTracking( !m_impl->thumb.active.isNull()  
     978                                          || !m_impl->inThumb.active.isNull()  
     979                                          || !m_impl->outThumb.active.isNull() 
     980                                          || !m_impl->thumbnailMarker.active.isNull() ); 
    958981        update(); 
    959982} 
     
    967990{ 
    968991        m_impl->thumbnailMarker.active = p; 
    969         setMouseTracking( !m_impl->thumbnailMarker.active.isNull()  
    970                                           || !m_impl->thumbnailMarker.active.isNull()  
     992        setMouseTracking( !m_impl->thumb.active.isNull()  
     993                                          || !m_impl->inThumb.active.isNull()  
     994                                          || !m_impl->outThumb.active.isNull() 
    971995                                          || !m_impl->thumbnailMarker.active.isNull() ); 
    972996        update(); 
     
    9891013        emit thumbnailFrameChanged( m_impl->thumbnailFrame ); 
    9901014        emit thumbnailFrame_changed(); 
     1015 
     1016        update(); 
    9911017} 
    9921018 
     
    10671093 
    10681094        // Prioritise the marker 
     1095        // Marker rect is selected 
    10691096        if ( m_impl->currentMarkerRect().contains( e->pos() ) ) 
    10701097        { 
     
    10721099                m_impl->tracking = PrivateTimeline::VALUE; 
    10731100        } 
    1074         else if ( m_impl->inRect().contains( e->pos() ) )       // hitInRect -> InRect 
     1101        // An in point is selected 
     1102        else if ( m_impl->hitInRect( e->pos() ) ) 
    10751103        { 
    10761104                m_impl->mouseDownValue = activeInValue(); 
    10771105                m_impl->tracking = PrivateTimeline::IN; 
    1078                 setSelectedPoint( m_impl->activeRange->in ); 
    1079         } 
    1080         else if ( m_impl->outRect().contains( e->pos() ) )      // hitOutRect -> OutRect 
     1106                setSelectedPoint( m_impl->activeRange->in );    // Change the active In point range 
     1107        } 
     1108        // An out point is selected 
     1109        else if ( m_impl->hitOutRect( e->pos() ) ) 
    10811110        { 
    10821111                m_impl->mouseDownValue = activeOutValue(); 
    10831112                m_impl->tracking = PrivateTimeline::OUT; 
    1084                 setSelectedPoint( m_impl->activeRange->out ); 
    1085         } 
     1113                setSelectedPoint( m_impl->activeRange->out );   // Change the active Out point range 
     1114        } 
     1115        // Thumbnail marker rect is selected 
     1116        else if ( m_impl->thumbnailMarkerRect().contains( e->pos() ) ) 
     1117        { 
     1118                m_impl->mouseDownValue = thumbnailFrame(); 
     1119                m_impl->tracking = PrivateTimeline::THUMB; 
     1120        } 
     1121        // Move marker rect to the the spot hit on the private timeline 
    10861122        else 
    10871123        { 
     
    11351171                e->accept(); 
    11361172        }                
    1137         // else hit test the in/out points (and marker) and re-paint if necessary 
    1138         else  
    1139         { 
     1173        else if ( m_impl->tracking == PrivateTimeline::THUMB ) 
     1174        { 
     1175                setThumbnailFrame( m_impl->convertToValue( m_impl->convertToPixel( m_impl->mouseDownValue ) + delta ) ); 
     1176                e->accept(); 
     1177        } 
     1178        // else hit test the in/out points (and marker/thumbnail) and re-paint if necessary 
     1179        else { 
    11401180                // Avoid an update unless we need one 
    11411181                bool needsUpdate = false; 
     
    11461186                needsUpdate |= m_impl->inThumb.setActive( m_impl->hitInRect( e->pos() ) && !markerActive ); 
    11471187                needsUpdate |= m_impl->outThumb.setActive( m_impl->hitOutRect( e->pos() ) && !markerActive ); 
     1188                needsUpdate |= m_impl->thumbnailMarker.setActive( m_impl->thumbnailMarkerRect().contains( e->pos() ) && !markerActive ); 
    11481189                if ( needsUpdate )  
    11491190                        update(); 
     
    11571198        m_impl->inThumb.setActive( false ); 
    11581199        m_impl->outThumb.setActive( false ); 
     1200        m_impl->thumbnailMarker.setActive( false ); 
    11591201        update(); 
    11601202}