Changeset 580


Ignore:
Timestamp:
12/06/13 14:08:52 (11 years ago)
Author:
jts21
Message:

Add functionality to ignore items when a mouse button is pressed if shift is down:

  • rectangles and arrows can be created on top of existing items by holding shift when clicking
  • deleting shapes will ignore enclosed shapes if shift is down
  • deleting a Dot now deletes the entire shape by default
  • deleting Dots/Lines will ignore other Dots/Lines connected by more than 1 join if shift is down
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/gui/FrameMouseActions.java

    r570 r580  
    10091009                                return;
    10101010                        }
    1011                         // otherwise if the user is pointing at something,pick it up
    1012                 } else if (clicked != null) {
     1011                        // otherwise if the user is pointing at something, pick it up unless shift is down
     1012                } else if (clicked != null && !isShiftDown) {
     1013                       
    10131014                        // check permissions
    10141015                        if (!clicked.hasPermission(UserAppliedPermission.full)) {
     
    10991100                                pickup(clicked);
    11001101                        }
    1101                         // otherwise create a line
    1102                 } else if (clickedIn != null) {
     1102                        // if we're inside a shape, pick it up unless shift is down
     1103                } else if (clickedIn != null && !isShiftDown) {
    11031104                        ArrayList<Item> toPickup = new ArrayList<Item>(clickedIn.size());
    11041105                        for (Item ip : clickedIn)
     
    14241425                        }
    14251426                } else {
    1426                         // if the user is pointing at something, this is a copy
    1427                         if (clicked != null) {
     1427                        // if the user is pointing at something and shift isn't down, make a copy
     1428                        if (clicked != null && !isShiftDown()) {
    14281429                                // check permissions
    14291430                                if (clicked.isLineEnd()) {
     
    14721473                                pickup(copies);
    14731474                        } else {
    1474                                 // if user is pointing in a closed shape, copy the items inside
    1475                                 if (clickedIn != null) {
     1475                                // if user is pointing in a closed shape and shift isn't down, make a copy of the items inside
     1476                                if (clickedIn != null && !isShiftDown()) {
    14761477                                        // Set the selection mode for the items that were clicked in
    14771478                                        Collection<Item> enclosed = getFullyEnclosedItems(clickedIn);
     
    24112412                                _offY = getY() - anchored.getY() + anchored.getOffset().y;
    24122413                        } else {
     2414                                // delete the entire shape attached to the line, unless shift is pressed
     2415                                if(!isShiftDown()) {
     2416                                List<Item> tmp = new ArrayList<Item>(FreeItems.getInstance());
     2417                                for(Item i : tmp) {
     2418                                        // remove entire rectangles instead of just the corner
     2419                                        if(i instanceof Dot) {
     2420                                                FreeItems.getInstance().addAll(i.getAllConnected());
     2421                                                for(Item j : i.getAllConnected()) {
     2422                                                        if(j instanceof Dot) {
     2423                                                                FreeItems.getInstance().addAll(j.getLines());
     2424                                                        }
     2425                                                }
     2426                                        }
     2427                                }
     2428                                }
    24132429                                deleteItems(FreeItems.getInstance());
    24142430                        }
     
    24172433                        // the user is not pointing at an item
    24182434                } else if (toDelete == null) {
    2419 
    2420                         // if the user is pointing inside a closed shape, delete all
    2421                         // items inside it
    2422                         Collection<Item> items = FrameUtils.getCurrentItems(null);
    2423 
     2435               
     2436                        // if the user is pointing inside a closed shape, delete it
     2437                       
     2438                        Collection<Item> items = null;
     2439                        // if shift is down, only delete the enclosing shape (ignore the items inside)
     2440                        if(isShiftDown()) {
     2441                                Collection<Item> tmp = FrameUtils.getEnclosingLineEnds();
     2442                                if(tmp != null) {
     2443                                        items = new ArrayList<Item>();
     2444                                        items.addAll(tmp);
     2445                                for(Item i : tmp) {
     2446                                        if(i instanceof Dot) {
     2447                                                items.addAll(((Dot)i).getLines());
     2448                                        }
     2449                                }
     2450                                }
     2451                        } else {
     2452                                items = FrameUtils.getCurrentItems(null);
     2453                        }
     2454                       
    24242455                        if (items != null) {
    24252456                                Collection<Item> toRemove = new LinkedHashSet<Item>(items
     
    24862517                        Collection<Item> toUndo = null;
    24872518                        if (toDelete.isLineEnd()) {
    2488                                 toUndo = deleteLineEnd(toDelete);
     2519                                // delete the entire connected shape unless shift is down
     2520                                if(!isShiftDown()) {
     2521                                        List<Item> tmp = new ArrayList<Item>();
     2522                                        tmp.add(toDelete);
     2523                                        // remove entire shape instead of just the corner
     2524                                        tmp.addAll(toDelete.getAllConnected());
     2525                                        for(Item j : toDelete.getAllConnected()) {
     2526                                                if(j instanceof Dot) {
     2527                                                        tmp.addAll(j.getLines());
     2528                                                }
     2529                                        }
     2530                                        deleteItems(tmp);
     2531                                        return;
     2532                                } else {
     2533                                        toUndo = deleteLineEnd(toDelete);
     2534                                }
     2535                                // delete the entire connected shape unless we're hovering the end of the line, or shift is down
    24892536                        } else if (toDelete instanceof Line
    2490                                         && toDelete.getHighlightMode() == Item.HighlightMode.Disconnect) {
     2537                                        && toDelete.getHighlightMode() == Item.HighlightMode.Disconnect || isShiftDown()) {
    24912538                                Line line = (Line) toDelete;
    24922539                                Item start = line.getStartItem();
Note: See TracChangeset for help on using the changeset viewer.