Summary: | remove points in curve by dragging them out of the area | ||
---|---|---|---|
Product: | [Applications] krita | Reporter: | Thomas Zander <zander> |
Component: | General | Assignee: | Camilla Boemann <cbo> |
Status: | RESOLVED FIXED | ||
Severity: | wishlist | ||
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
Thomas Zander
2006-10-22 11:00:08 UTC
I like that suggestion and will implement it soon SVN commit 598084 by boemann: When hitting escape during dragging a point the drag will be canceled When dragging a point more than 15 pixels outside the widget the point is deleted (unless you drag it back inside) hitting exacpe while dragging outside will probably crash at the moment Can't test it as krita is not working at the moment CCBUG: 136125 M +54 -12 kcurve.cc M +4 -0 kcurve.h --- trunk/koffice/krita/ui/kcurve.cc #598083:598084 @@ -118,6 +118,18 @@ } repaint(); } + else if(e->key() == Qt::Key_Escape) + { + if(m_dragging) + { + m_points[m_grab_point_index].first = m_grabOriginalX; + m_points[m_grab_point_index].second = m_grabOriginalY; + setCursor( KCursor::arrowCursor() ); + m_dragging = false; + repaint(); + emit modified(); + } + } else QWidget::keyPressEvent(e); } @@ -250,11 +262,14 @@ m_grab_point_index = closest_point_index; } + m_grabOriginalX = m_points[m_grab_point_index].first; + m_grabOriginalY = m_points[m_grab_point_index].second; m_grabOffsetX = m_points[m_grab_point_index].first - x; m_grabOffsetY = m_points[m_grab_point_index].second - y; m_points[m_grab_point_index].first = x + m_grabOffsetX; m_points[m_grab_point_index].second = y + m_grabOffsetY; m_dragging = true; + m_draggedawaypointindex = -1; setCursor( KCursor::crossCursor() ); repaint(); @@ -291,35 +306,54 @@ } else // Else, drag the selected point { + bool removepoint = e->pos().x() - width() >15 || e->pos().x()< -15 || e->pos().y() - height() >15 || e->pos().y()< -15; + + if (removepoint == false && m_draggedawaypointindex != -1) + { + // point is no longer dragged away so reinsert it + QPair<double,double> newPoint(m_draggedawaypoint); + m_points.insert(m_draggedawaypointindex, newPoint); + m_grab_point_index = m_draggedawaypointindex; + m_draggedawaypointindex = -1; + } + + if (removepoint == true && m_draggedawaypointindex != -1) + return; + setCursor( KCursor::crossCursor() ); x += m_grabOffsetX; y += m_grabOffsetY; + double leftX; + double rightX; if (m_grab_point_index == 0) { - x = 0; + leftX = 0.0; + rightX = m_points[m_grab_point_index + 1].first + 1E-4; } else if (m_grab_point_index == m_points.count() - 1) { - x = 1; + leftX = m_points[m_grab_point_index - 1].first + 1E-4; + rightX = 0.0; } else { Q_ASSERT(m_grab_point_index > 0 && m_grab_point_index < m_points.count() - 1); - double leftX = m_points[m_grab_point_index - 1].first; - double rightX = m_points[m_grab_point_index + 1].first; + // the 1E-4 addition so we can grab the dot later. + leftX = m_points[m_grab_point_index - 1].first + 1E-4; + rightX = m_points[m_grab_point_index + 1].first + 1E-4; + } - if (x <= leftX) - { - x = leftX + 1E-4; // the addition so we can grab the dot later. - } - else if (x >= rightX) - { - x = rightX - 1E-4; - } + if (x <= leftX) + { + x = leftX; } + else if (x >= rightX) + { + x = rightX; + } if(y > 1.0) y = 1.0; @@ -330,6 +364,14 @@ m_points[m_grab_point_index].first = x; m_points[m_grab_point_index].second = y; + if (removepoint) + { + m_draggedawaypoint.first = m_points[m_grab_point_index].first; + m_draggedawaypoint.second = m_points[m_grab_point_index].second; + m_draggedawaypointindex = m_grab_point_index; + m_points.removeAt(m_grab_point_index); + } + emit modified(); } --- trunk/koffice/krita/ui/kcurve.h #598083:598084 @@ -74,6 +74,10 @@ bool m_dragging; double m_grabOffsetX; double m_grabOffsetY; + double m_grabOriginalX; + double m_grabOriginalY; + QPair<double,double>m_draggedawaypoint; + int m_draggedawaypointindex; bool m_readOnlyMode; bool m_guideVisible; Implemented and tested (will be part of koffice 2.0) |