Changeset 895
- Timestamp:
- 08/15/07 06:42:30 (1 year ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/jahwidgets/src/qt3/widgets/timelineSlider.cpp
r894 r895 126 126 struct TimelineSlider::PrivateTimeline 127 127 { 128 enum Tracking { NONE, VALUE, IN, OUT };128 enum Tracking { NONE, VALUE, IN, OUT, THUMB }; 129 129 130 130 PrivateTimeline( TimelineSlider* p ) … … 152 152 } 153 153 154 int markerClamp( int i ) const 155 { 156 return std::max( std::min( i, activeRange->out ), activeRange->in ); 157 } 158 154 159 int inClamp( int i ) const 155 160 { … … 277 282 bool hitInRect( QPoint pos ) const 278 283 { 279 // We've got to be in the thumb rect and outside the currentMarkerRect region284 // We've got to be in the thumb rect and outside the currentMarkerRect/thumbnailMarkerRect region 280 285 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 ) ); 282 291 } 283 292 284 293 bool hitOutRect( QPoint pos ) const 285 294 { 286 // We've got to be in the thumb rect and outside the currentMarkerRect region295 // We've got to be in the thumb rect and outside the currentMarkerRect/thumbnailMarkerRect region 287 296 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 ) ); 289 302 } 290 303 … … 569 582 } 570 583 584 // Insert an in/out range and return range id 571 585 int TimelineSlider::insertRange( int in, int out ) 572 586 { … … 582 596 } 583 597 598 // Remove an in/out range 584 599 void TimelineSlider::removeRangeWithId( int id ) 585 600 { … … 608 623 } 609 624 625 // Return an array containing all in/out ranges 610 626 TimelineSlider::RangeArray TimelineSlider::allRanges() const 611 627 { … … 622 638 } 623 639 640 // Returns a range specified by a range id 624 641 boost::optional<TimelineSlider::Range> TimelineSlider::rangeWithId( int id ) const 625 642 { … … 679 696 } 680 697 698 // Returns currently active in/out range id 681 699 int TimelineSlider::activeRangeId() const 682 700 { … … 684 702 } 685 703 704 // Sets a range id to active 686 705 void TimelineSlider::setActiveRangeId( int id ) 687 706 { … … 836 855 setMouseTracking( !m_impl->thumb.active.isNull() 837 856 || !m_impl->inThumb.active.isNull() 838 || !m_impl->outThumb.active.isNull() ); 857 || !m_impl->outThumb.active.isNull() 858 || !m_impl->thumbnailMarker.active.isNull() ); 839 859 update(); 840 860 } … … 894 914 setMouseTracking( !m_impl->thumb.active.isNull() 895 915 || !m_impl->inThumb.active.isNull() 896 || !m_impl->outThumb.active.isNull() ); 916 || !m_impl->outThumb.active.isNull() 917 || !m_impl->thumbnailMarker.active.isNull() ); 897 918 update(); 898 919 } … … 930 951 setMouseTracking( !m_impl->thumb.active.isNull() 931 952 || !m_impl->inThumb.active.isNull() 932 || !m_impl->outThumb.active.isNull() ); 953 || !m_impl->outThumb.active.isNull() 954 || !m_impl->thumbnailMarker.active.isNull() ); 933 955 update(); 934 956 } … … 953 975 { 954 976 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() ); 958 981 update(); 959 982 } … … 967 990 { 968 991 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() 971 995 || !m_impl->thumbnailMarker.active.isNull() ); 972 996 update(); … … 989 1013 emit thumbnailFrameChanged( m_impl->thumbnailFrame ); 990 1014 emit thumbnailFrame_changed(); 1015 1016 update(); 991 1017 } 992 1018 … … 1067 1093 1068 1094 // Prioritise the marker 1095 // Marker rect is selected 1069 1096 if ( m_impl->currentMarkerRect().contains( e->pos() ) ) 1070 1097 { … … 1072 1099 m_impl->tracking = PrivateTimeline::VALUE; 1073 1100 } 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() ) ) 1075 1103 { 1076 1104 m_impl->mouseDownValue = activeInValue(); 1077 1105 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() ) ) 1081 1110 { 1082 1111 m_impl->mouseDownValue = activeOutValue(); 1083 1112 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 1086 1122 else 1087 1123 { … … 1135 1171 e->accept(); 1136 1172 } 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 { 1140 1180 // Avoid an update unless we need one 1141 1181 bool needsUpdate = false; … … 1146 1186 needsUpdate |= m_impl->inThumb.setActive( m_impl->hitInRect( e->pos() ) && !markerActive ); 1147 1187 needsUpdate |= m_impl->outThumb.setActive( m_impl->hitOutRect( e->pos() ) && !markerActive ); 1188 needsUpdate |= m_impl->thumbnailMarker.setActive( m_impl->thumbnailMarkerRect().contains( e->pos() ) && !markerActive ); 1148 1189 if ( needsUpdate ) 1149 1190 update(); … … 1157 1198 m_impl->inThumb.setActive( false ); 1158 1199 m_impl->outThumb.setActive( false ); 1200 m_impl->thumbnailMarker.setActive( false ); 1159 1201 update(); 1160 1202 }
