Skip to content

Commit

Permalink
UX: improved delete action
Browse files Browse the repository at this point in the history
No need to be in transform mode to delete selected.
  • Loading branch information
rodlie committed Oct 13, 2024
1 parent ac00a7c commit d9230af
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
14 changes: 12 additions & 2 deletions src/core/canvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -841,10 +841,20 @@ bool Canvas::handleTransormationInputKeyEvent(const eKeyEvent &e)

void Canvas::deleteAction()
{
if (mCurrentMode == CanvasMode::pointTransform) {
switch(mCurrentMode) {
case CanvasMode::pointTransform:
removeSelectedPointsAndClearList();
} else if (mCurrentMode == CanvasMode::boxTransform) {
break;
case CanvasMode::boxTransform:
case CanvasMode::circleCreate:
case CanvasMode::rectCreate:
case CanvasMode::textCreate:
case CanvasMode::nullCreate:
case CanvasMode::drawPath:
case CanvasMode::pathCreate:
removeSelectedBoxesAndClearList();
break;
default:;
}
}

Expand Down
12 changes: 9 additions & 3 deletions src/core/canvasselectedpointsactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,9 @@ void Canvas::removePointFromSelection(MovablePoint * const point) {
schedulePivotUpdate();
}

void Canvas::removeSelectedPointsAndClearList() {
if(mPressedPoint && mPressedPoint->isCtrlPoint()) {
void Canvas::removeSelectedPointsAndClearList()
{
if (mPressedPoint && mPressedPoint->isCtrlPoint()) {
mPressedPoint->finishTransform();
removePointFromSelection(mPressedPoint);
mPressedPoint->remove();
Expand All @@ -239,7 +240,12 @@ void Canvas::removeSelectedPointsAndClearList() {
}

const auto selected = mSelectedPoints_d;
for(const auto& point : selected) {
if (selected.count() < 1) {
removeSelectedBoxesAndClearList();
return;
}

for (const auto& point : selected) {
point->setSelected(false);
point->remove();
}
Expand Down

0 comments on commit d9230af

Please sign in to comment.