Changeset 602


Ignore:
Timestamp:
12/11/13 11:13:21 (11 years ago)
Author:
jts21
Message:

Invert the behaviour of shift-delete (now the default is to delete a single item, and shift-delete deletes all the connected items too). Also update highlighting so connected items are highlighted in accordance with the deletion behaviour. Does not currently highlight items that are being carried (adding that would be as simple as disabling a few statements that explicitly disable highlighting on carried items, but it would look kind of ugly)

Location:
trunk/src/org/expeditee/gui
Files:
4 edited

Legend:

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

    r579 r602  
    960960                if (bReparse) {
    961961                        FrameUtils.Parse(this, false, false);
    962                         FrameGraphics.requestRefresh(false);
    963962                } else {
    964963                        notifyObservers(bRecalculate);
    965964                }
     965                // always request a refresh otherwise filled shapes
     966                // that were broken by a deletion and then reconnected by the undo
     967                // don't get filled until the user otherwise causes them to redraw
     968                FrameGraphics.requestRefresh(false);
    966969                FrameGraphics.Repaint();
    967970                ItemUtils.EnclosedCheck(_body);
  • trunk/src/org/expeditee/gui/FrameGraphics.java

    r570 r602  
    2222
    2323import org.expeditee.items.Circle;
     24import org.expeditee.items.Dot;
    2425import org.expeditee.items.Item;
    2526import org.expeditee.items.ItemUtils;
     
    2728import org.expeditee.items.UserAppliedPermission;
    2829import org.expeditee.items.XRayable;
     30import org.expeditee.items.Item.HighlightMode;
    2931import org.expeditee.items.widgets.InteractiveWidget;
    3032import org.expeditee.items.widgets.WidgetEdge;
     
    740742                                i = toDisconnect;
    741743                        } else {
    742                                 Collection<Item> connected = i.getAllConnected();
    743                                 for (Item conn : connected) {
    744                                         conn.setHighlightMode(Item.HighlightMode.Connected);
    745                                 }
     744                                if(FrameMouseActions.isShiftDown()) {
     745                                for(Item j : i.getAllConnected()) {
     746                                        if(j instanceof Dot && !j.equals(i)) {
     747                                                j.setHighlightMode(HighlightMode.Connected);
     748                                        }
     749                                }
     750                        } else {
     751                                for(Item j : i.getAllConnected()) {
     752                                        if(j instanceof Dot && !j.equals(i)) {
     753                                                j.setHighlightMode(HighlightMode.None);
     754                                        }
     755                                }
     756                                l.getStartItem().setHighlightMode(HighlightMode.Connected);
     757                                l.getEndItem().setHighlightMode(HighlightMode.Connected);
     758                        }
     759//                              Collection<Item> connected = i.getAllConnected();
     760//                              for (Item conn : connected) {
     761//                                      conn.setHighlightMode(Item.HighlightMode.Connected);
     762//                              }
    746763                        }
    747764                } else if (i instanceof Circle) {
     
    749766                } else if (!i.isVisible()) {
    750767                        changeHighlightMode(i, Item.HighlightMode.Connected, null);
    751                 } else {
     768                } else if (i instanceof Dot) {
     769                        // highlight the dot
     770                        if (i.hasPermission(UserAppliedPermission.full)) {
     771                                changeHighlightMode(i, Item.HighlightMode.Normal, Item.HighlightMode.None);
     772                        } else {
     773                                changeHighlightMode(i, Item.HighlightMode.Connected, Item.HighlightMode.Connected);
     774                        }
     775                        // highlight connected dots, but only if there aren't items being carried on the cursor
     776                        if(FreeItems.getInstance().size() == 0) {
     777                        if(FrameMouseActions.isShiftDown()) {
     778                                for(Item j : i.getAllConnected()) {
     779                                        if(j instanceof Dot && !j.equals(i)) {
     780                                                j.setHighlightMode(HighlightMode.Connected);
     781                                        }
     782                                }
     783                        } else {
     784                                for(Item j : i.getAllConnected()) {
     785                                        if(j instanceof Dot && !j.equals(i)) {
     786                                                j.setHighlightMode(HighlightMode.None);
     787                                        }
     788                                }
     789                                for(Line l : i.getLines()) {
     790                                        Item j = l.getOppositeEnd(i);
     791                                        j.setHighlightMode(HighlightMode.Connected);
     792                                }
     793                        }
     794                        }
     795        } else {
    752796                        // FrameGraphics.ChangeSelectionMode(i,
    753797                        // Item.SelectedMode.Normal);
  • trunk/src/org/expeditee/gui/FrameMouseActions.java

    r599 r602  
    24212421                                _offY = getY() - anchored.getY() + anchored.getOffset().y;
    24222422                        } else {
    2423                                 // delete the entire shape attached to the line, unless shift is pressed
    2424                                 if(!isShiftDown()) {
     2423                                // delete the entire shape attached to the line, if shift is pressed
     2424                                if(isShiftDown()) {
    24252425                                List<Item> tmp = new ArrayList<Item>(FreeItems.getInstance());
    24262426                                for(Item i : tmp) {
     
    25262526                        Collection<Item> toUndo = null;
    25272527                        if (toDelete.isLineEnd()) {
    2528                                 // delete the entire connected shape unless shift is down
    2529                                 if(!isShiftDown()) {
     2528                                // delete the entire connected shape if shift is down
     2529                                if(isShiftDown()) {
    25302530                                        List<Item> tmp = new ArrayList<Item>();
    25312531                                        tmp.add(toDelete);
     
    25422542                                        toUndo = deleteLineEnd(toDelete);
    25432543                                }
    2544                                 // delete the entire connected shape unless we're hovering the end of the line, or shift is down
    2545                         } else if (toDelete instanceof Line
    2546                                         && toDelete.getHighlightMode() == Item.HighlightMode.Disconnect || isShiftDown()) {
     2544                                // delete the entire connected shape if shift is down, unless we're hovering the end of the line
     2545                        } else if (toDelete instanceof Line && !isShiftDown() ||
     2546                                        toDelete.getHighlightMode() == Item.HighlightMode.Disconnect) {
    25472547                                Line line = (Line) toDelete;
    25482548                                Item start = line.getStartItem();
     
    33263326        public static void shift(KeyEvent e) {
    33273327                _shiftDown = e.isShiftDown();
     3328                getInstance().refreshHighlights();
    33283329        }
    33293330}
  • trunk/src/org/expeditee/gui/FrameUtils.java

    r601 r602  
    4242import org.expeditee.items.UserAppliedPermission;
    4343import org.expeditee.items.XRayable;
     44import org.expeditee.items.Item.HighlightMode;
    4445import org.expeditee.items.widgets.InteractiveWidget;
    4546import org.expeditee.items.widgets.InteractiveWidgetInitialisationFailedException;
     
    11991200                List<InteractiveWidget> enclosedWidgets = new LinkedList<InteractiveWidget>();
    12001201                for (Item i : enclosed) {
    1201                         // Dont want to loose the highlighting from the current item
    1202                         if (i != currentItem && !enclosure.contains(i))
    1203                                 i.setHighlightMode(Item.HighlightMode.None);
     1202                        // Don't want to lose the highlighting from the current item
     1203                        if(i == currentItem || enclosure.contains(i)) {
     1204                                continue;
     1205                        }
     1206                        // Don't want to lose the highlighting of connected Dots
     1207                        if(i instanceof Dot && i.getHighlightMode() == HighlightMode.Connected) {
     1208                                for(Line l : i.getLines()) {
     1209                                        if(l.getOppositeEnd(i).getHighlightMode() == HighlightMode.Normal) {
     1210                                                continue;
     1211                                        }
     1212                                }
     1213                        }
    12041214                        if (i instanceof WidgetCorner) {
    12051215                                if (!enclosedWidgets.contains(((WidgetCorner) i)
     
    12071217                                        enclosedWidgets.add(((WidgetCorner) i).getWidgetSource());
    12081218                        }
     1219                        i.setHighlightMode(Item.HighlightMode.None);
    12091220                }
    12101221
Note: See TracChangeset for help on using the changeset viewer.