comparison view/Pane.cpp @ 136:a859b87162ca

* beginnings of drag up/down in layers as appropriate
author Chris Cannam
date Mon, 21 Aug 2006 16:26:35 +0000
parents e98130764635
children 10a82b2bbb8b
comparison
equal deleted inserted replaced
135:e98130764635 136:a859b87162ca
649 setCursor(Qt::PointingHandCursor); 649 setCursor(Qt::PointingHandCursor);
650 } 650 }
651 651
652 m_navigating = true; 652 m_navigating = true;
653 m_dragCentreFrame = m_centreFrame; 653 m_dragCentreFrame = m_centreFrame;
654
655 //!!! pull out into function to go with mouse move code
656
657 m_dragStartMinValue = 0;
658
659 Layer *layer = 0;
660 if (getLayerCount() > 0) layer = getLayer(getLayerCount() - 1);
661
662 if (layer) {
663 float min = 0.f, max = 0.f;
664 if (layer->getDisplayExtents(min, max)) {
665 m_dragStartMinValue = min;
666 }
667 }
654 668
655 } else if (mode == ViewManager::SelectMode) { 669 } else if (mode == ViewManager::SelectMode) {
656 670
657 bool closeToLeft = false, closeToRight = false; 671 bool closeToLeft = false, closeToRight = false;
658 Selection selection = getSelectionAt(e->x(), closeToLeft, closeToRight); 672 Selection selection = getSelectionAt(e->x(), closeToLeft, closeToRight);
924 } 938 }
925 939
926 if (getXForFrame(m_centreFrame) != getXForFrame(newCentreFrame)) { 940 if (getXForFrame(m_centreFrame) != getXForFrame(newCentreFrame)) {
927 setCentreFrame(newCentreFrame); 941 setCentreFrame(newCentreFrame);
928 } 942 }
943
944 //!!! For drag up/down, we need to: call getValueExtents
945 //and getDisplayExtents and see whether both return true
946 //(we can only drag up/down if they do); and check whether
947 //the ranges returned differ (likewise). Then, we know
948 //the height of the layer, so...
949
950 //!!! this should have its own function
951
952 Layer *layer = 0;
953 if (getLayerCount() > 0) layer = getLayer(getLayerCount() - 1);
954
955 if (layer) {
956
957 float vmin = 0.f, vmax = 0.f;
958 bool vlog = false;
959 QString vunit;
960
961 float dmin = 0.f, dmax = 0.f;
962
963 if (layer->getValueExtents(vmin, vmax, vlog, vunit) &&
964 layer->getDisplayExtents(dmin, dmax) &&
965 (dmin > vmin || dmax < vmax)) {
966
967 int ydiff = e->y() - m_clickPos.y();
968 std::cerr << "ydiff = " << ydiff << std::endl;
969
970 float perpix = (dmax - dmin) / height();
971 float valdiff = ydiff * perpix;
972 std::cerr << "valdiff = " << valdiff << std::endl;
973
974 float newmin = m_dragStartMinValue + valdiff;
975 float newmax = m_dragStartMinValue + (dmax - dmin) + valdiff;
976 if (newmin < vmin) {
977 newmax += vmin - newmin;
978 newmin += vmin - newmin;
979 }
980 if (newmax > vmax) {
981 newmin -= newmax - vmax;
982 newmax -= newmax - vmax;
983 }
984 std::cerr << "(" << dmin << ", " << dmax << ") -> ("
985 << newmin << ", " << newmax << ") (drag start " << m_dragStartMinValue << ")" << std::endl;
986 layer->setDisplayExtents(newmin, newmax);
987 }
988 }
929 } 989 }
930 990
931 } else if (mode == ViewManager::SelectMode) { 991 } else if (mode == ViewManager::SelectMode) {
932 992
933 int mouseFrame = getFrameForX(e->x()); 993 int mouseFrame = getFrameForX(e->x());