Mercurial > hg > svgui
comparison view/Pane.cpp @ 551:c2ba2796cbee sv-v1.7
* Big improvements to editing behaviour in note and region models
author | Chris Cannam |
---|---|
date | Fri, 02 Oct 2009 13:56:10 +0000 |
parents | e6122e4999a3 |
children | dc511d5fee75 |
comparison
equal
deleted
inserted
replaced
550:d666f5f8b154 | 551:c2ba2796cbee |
---|---|
1556 layer->eraseDrag(this, e); | 1556 layer->eraseDrag(this, e); |
1557 } | 1557 } |
1558 | 1558 |
1559 } else if (mode == ViewManager::EditMode) { | 1559 } else if (mode == ViewManager::EditMode) { |
1560 | 1560 |
1561 if (m_editing) { | 1561 bool resist = true; |
1562 if (!editSelectionDrag(e)) { | 1562 |
1563 Layer *layer = getSelectedLayer(); | 1563 if ((e->modifiers() & Qt::ShiftModifier)) { |
1564 if (layer && layer->isLayerEditable()) { | 1564 m_shiftPressed = true; |
1565 layer->editDrag(this, e); | 1565 // ... but don't set it false if shift has been |
1566 } | 1566 // released -- we want the state when we started |
1567 } | 1567 // dragging to be used most of the time |
1568 } | 1568 } |
1569 | |
1570 if (m_shiftPressed) resist = false; | |
1571 | |
1572 m_dragMode = updateDragMode | |
1573 (m_dragMode, | |
1574 m_clickPos, | |
1575 e->pos(), | |
1576 true, // can move horiz | |
1577 true, // can move vert | |
1578 resist, // resist horiz | |
1579 resist); // resist vert | |
1569 | 1580 |
1570 if (!m_editing) { | 1581 if (!m_editing) { |
1571 | 1582 |
1572 bool resist = true; | 1583 if (m_dragMode != UnresolvedDrag) { |
1573 | |
1574 if ((e->modifiers() & Qt::ShiftModifier)) { | |
1575 m_shiftPressed = true; | |
1576 // ... but don't set it false if shift has been | |
1577 // released -- we want the state when we started | |
1578 // dragging to be used most of the time | |
1579 } | |
1580 | |
1581 if (m_shiftPressed) resist = false; | |
1582 | |
1583 DragMode newDragMode = updateDragMode | |
1584 (m_dragMode, | |
1585 m_clickPos, | |
1586 e->pos(), | |
1587 true, // can move horiz | |
1588 true, // can move vert | |
1589 resist, // resist horiz | |
1590 resist); // resist vert | |
1591 | |
1592 if (newDragMode != UnresolvedDrag) { | |
1593 | 1584 |
1594 m_editing = true; | 1585 m_editing = true; |
1595 | 1586 |
1596 QMouseEvent clickEvent(QEvent::MouseButtonPress, | 1587 QMouseEvent clickEvent(QEvent::MouseButtonPress, |
1597 m_clickPos, | 1588 m_clickPos, |
1602 if (!editSelectionStart(&clickEvent)) { | 1593 if (!editSelectionStart(&clickEvent)) { |
1603 Layer *layer = getSelectedLayer(); | 1594 Layer *layer = getSelectedLayer(); |
1604 if (layer && layer->isLayerEditable()) { | 1595 if (layer && layer->isLayerEditable()) { |
1605 layer->editStart(this, &clickEvent); | 1596 layer->editStart(this, &clickEvent); |
1606 } | 1597 } |
1598 } | |
1599 } | |
1600 | |
1601 } else { | |
1602 | |
1603 if (!editSelectionDrag(e)) { | |
1604 | |
1605 Layer *layer = getSelectedLayer(); | |
1606 | |
1607 if (layer && layer->isLayerEditable()) { | |
1608 | |
1609 int x = e->x(); | |
1610 int y = e->y(); | |
1611 if (m_dragMode == VerticalDrag) x = m_clickPos.x(); | |
1612 else if (m_dragMode == HorizontalDrag) y = m_clickPos.y(); | |
1613 | |
1614 QMouseEvent moveEvent(QEvent::MouseMove, | |
1615 QPoint(x, y), | |
1616 Qt::NoButton, | |
1617 e->buttons(), | |
1618 e->modifiers()); | |
1619 | |
1620 layer->editDrag(this, &moveEvent); | |
1607 } | 1621 } |
1608 } | 1622 } |
1609 } | 1623 } |
1610 | 1624 |
1611 } else if (mode == ViewManager::MeasureMode) { | 1625 } else if (mode == ViewManager::MeasureMode) { |
1964 float vmin, vmax, dmin, dmax; | 1978 float vmin, vmax, dmin, dmax; |
1965 if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) { | 1979 if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) { |
1966 m_dragStartMinValue = dmin; | 1980 m_dragStartMinValue = dmin; |
1967 } | 1981 } |
1968 } | 1982 } |
1983 | |
1984 m_clickedInRange = false; // in case mouseReleaseEvent is not properly called | |
1969 } | 1985 } |
1970 | 1986 |
1971 void | 1987 void |
1972 Pane::enterEvent(QEvent *) | 1988 Pane::enterEvent(QEvent *) |
1973 { | 1989 { |
2500 | 2516 |
2501 } else if (mode == ViewManager::EditMode) { | 2517 } else if (mode == ViewManager::EditMode) { |
2502 | 2518 |
2503 //!!! could call through to layer | 2519 //!!! could call through to layer |
2504 if (editable) { | 2520 if (editable) { |
2505 help = tr("Click and drag an item in the active layer to move it"); | 2521 help = tr("Click and drag an item in the active layer to move it; hold Shift to override initial resistance"); |
2506 if (pos) { | 2522 if (pos) { |
2507 bool closeToLeft = false, closeToRight = false; | 2523 bool closeToLeft = false, closeToRight = false; |
2508 Selection selection = getSelectionAt(pos->x(), closeToLeft, closeToRight); | 2524 Selection selection = getSelectionAt(pos->x(), closeToLeft, closeToRight); |
2509 if (!selection.isEmpty()) { | 2525 if (!selection.isEmpty()) { |
2510 help = tr("Click and drag to move all items in the selected range"); | 2526 help = tr("Click and drag to move all items in the selected range"); |