| 510 | } |
| 511 | |
| 512 | bool DocumentView::onClear(Context* ctx) |
| 513 | { |
| 514 | ContextWriter writer(ctx); |
| 515 | Document* document = writer.document(); |
| 516 | bool visibleMask = document->isMaskVisible(); |
| 517 | |
| 518 | if (!writer.cel()) |
| 519 | return false; |
| 520 | |
| 521 | { |
| 522 | Transaction transaction(writer.context(), "Clear"); |
| 523 | transaction.execute(new cmd::ClearMask(writer.cel())); |
| 524 | |
| 525 | // If the cel wasn't deleted by cmd::ClearMask, we trim it. |
| 526 | if (writer.cel() && |
| 527 | writer.cel()->layer()->isTransparent()) |
| 528 | transaction.execute(new cmd::TrimCel(writer.cel())); |
| 529 | |
| 530 | if (visibleMask && |
| 531 | !Preferences::instance().selection.keepSelectionAfterClear()) |
| 532 | transaction.execute(new cmd::DeselectMask(document)); |
| 533 | |
| 534 | transaction.commit(); |
| 535 | } |
| 536 | |
| 537 | if (visibleMask) |
| 538 | document->generateMaskBoundaries(); |
| 539 | |
| 540 | document->notifyGeneralUpdate(); |
| 541 | return true; |
| 542 | } |
| 543 | |
| 544 | void DocumentView::onCancel(Context* ctx) |
| 545 | { |
nothing calls this directly
no test coverage detected