Mercurial > hg > svgui
comparison view/Pane.cpp @ 259:2d891e02c5ce
* some beginnings of what will be measurement tool functionality
author | Chris Cannam |
---|---|
date | Wed, 13 Jun 2007 13:44:19 +0000 |
parents | 6732a5b8a2c4 |
children | 6d113226bb4c |
comparison
equal
deleted
inserted
replaced
258:6732a5b8a2c4 | 259:2d891e02c5ce |
---|---|
384 } | 384 } |
385 | 385 |
386 int fontHeight = paint.fontMetrics().height(); | 386 int fontHeight = paint.fontMetrics().height(); |
387 int fontAscent = paint.fontMetrics().ascent(); | 387 int fontAscent = paint.fontMetrics().ascent(); |
388 | 388 |
389 ViewManager::ToolMode toolMode = m_manager->getToolMode(); | |
390 | |
389 if (m_manager && | 391 if (m_manager && |
390 !m_manager->isPlaying() && | 392 !m_manager->isPlaying() && |
391 m_manager->getToolMode() == ViewManager::SelectMode) { | 393 toolMode == ViewManager::MeasureMode) { |
392 | 394 |
393 for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) { | 395 for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) { |
394 --vi; | 396 --vi; |
395 | 397 |
396 std::vector<QRect> crosshairExtents; | 398 std::vector<QRect> crosshairExtents; |
730 lly -= fontHeight; | 732 lly -= fontHeight; |
731 } | 733 } |
732 } | 734 } |
733 } | 735 } |
734 | 736 |
735 if (m_clickedInRange && m_shiftPressed) { | 737 if (m_clickedInRange && m_manager) { |
736 if (m_manager && (m_manager->getToolMode() == ViewManager::NavigateMode)) { | 738 if ((m_shiftPressed && toolMode == ViewManager::NavigateMode) || |
739 toolMode == ViewManager::MeasureMode) { | |
737 //!!! be nice if this looked a bit more in keeping with the | 740 //!!! be nice if this looked a bit more in keeping with the |
738 //selection block | 741 //selection block |
739 paint.setPen(Qt::blue); | 742 paint.setPen(toolMode == ViewManager::MeasureMode ? Qt::green : |
743 Qt::blue); | |
744 //!!! shouldn't use clickPos -- needs to use a clicked frame | |
740 paint.drawRect(m_clickPos.x(), m_clickPos.y(), | 745 paint.drawRect(m_clickPos.x(), m_clickPos.y(), |
741 m_mousePos.x() - m_clickPos.x(), | 746 m_mousePos.x() - m_clickPos.x(), |
742 m_mousePos.y() - m_clickPos.y()); | 747 m_mousePos.y() - m_clickPos.y()); |
743 } | 748 } |
744 } | 749 } |
1206 Layer *layer = getSelectedLayer(); | 1211 Layer *layer = getSelectedLayer(); |
1207 if (layer && layer->isLayerEditable()) { | 1212 if (layer && layer->isLayerEditable()) { |
1208 layer->editDrag(this, e); | 1213 layer->editDrag(this, e); |
1209 } | 1214 } |
1210 } | 1215 } |
1216 | |
1217 } else if (mode == ViewManager::MeasureMode) { | |
1218 | |
1219 m_mousePos = e->pos(); | |
1220 edgeScrollMaybe(e->x()); | |
1221 update(); | |
1211 } | 1222 } |
1212 } | 1223 } |
1213 | 1224 |
1214 void | 1225 void |
1215 Pane::zoomToRegion(int x0, int y0, int x1, int y1) | 1226 Pane::zoomToRegion(int x0, int y0, int x1, int y1) |
1433 if (m_manager) { | 1444 if (m_manager) { |
1434 m_manager->setInProgressSelection(Selection(min, max), | 1445 m_manager->setInProgressSelection(Selection(min, max), |
1435 !m_resizing && !m_ctrlPressed); | 1446 !m_resizing && !m_ctrlPressed); |
1436 } | 1447 } |
1437 | 1448 |
1449 edgeScrollMaybe(e->x()); | |
1450 | |
1451 update(); | |
1452 } | |
1453 | |
1454 void | |
1455 Pane::edgeScrollMaybe(int x) | |
1456 { | |
1457 int mouseFrame = getFrameForX(x); | |
1458 | |
1438 bool doScroll = false; | 1459 bool doScroll = false; |
1439 if (!m_manager) doScroll = true; | 1460 if (!m_manager) doScroll = true; |
1440 if (!m_manager->isPlaying()) doScroll = true; | 1461 if (!m_manager->isPlaying()) doScroll = true; |
1441 if (m_followPlay != PlaybackScrollContinuous) doScroll = true; | 1462 if (m_followPlay != PlaybackScrollContinuous) doScroll = true; |
1442 | 1463 |
1443 if (doScroll) { | 1464 if (doScroll) { |
1444 int offset = mouseFrame - getStartFrame(); | 1465 int offset = mouseFrame - getStartFrame(); |
1445 int available = getEndFrame() - getStartFrame(); | 1466 int available = getEndFrame() - getStartFrame(); |
1467 int move = 0; | |
1446 if (offset >= available * 0.95) { | 1468 if (offset >= available * 0.95) { |
1447 int move = int(offset - available * 0.95) + 1; | 1469 move = int(offset - available * 0.95) + 1; |
1470 } else if (offset <= available * 0.10) { | |
1471 move = int(available * 0.10 - offset) + 1; | |
1472 move = -move; | |
1473 } | |
1474 if (move != 0) { | |
1448 setCentreFrame(m_centreFrame + move); | 1475 setCentreFrame(m_centreFrame + move); |
1449 } else if (offset <= available * 0.10) { | 1476 update(); |
1450 int move = int(available * 0.10 - offset) + 1; | 1477 } |
1451 if (move < 0) { | 1478 } |
1452 setCentreFrame(m_centreFrame + (-move)); | |
1453 } else if (m_centreFrame > size_t(move)) { | |
1454 setCentreFrame(m_centreFrame - move); | |
1455 } else { | |
1456 setCentreFrame(0); | |
1457 } | |
1458 } | |
1459 } | |
1460 | |
1461 update(); | |
1462 } | 1479 } |
1463 | 1480 |
1464 void | 1481 void |
1465 Pane::mouseDoubleClickEvent(QMouseEvent *e) | 1482 Pane::mouseDoubleClickEvent(QMouseEvent *e) |
1466 { | 1483 { |