Ignore:
Timestamp:
01/22/14 16:45:34 (10 years ago)
Author:
jts21
Message:

Modify the undo stack to use a stack of List rather than a stack of connected items (easier to understand, and since we have to parse it linearly anyways it's not any slower)
Also started making other stuff undo-able, so far vertical auto-format can be undone, probably pretty inefficient (every time I add to the list of items modified by the vertical format I have to walk the entire list of modified items to make sure I don't add it multiple times).
I think it might be a good idea to add a redo functionality as well (simple enough to do, but we need a key/mouse binding for it)
Also modified copy/pasting to fix a bug where cutting a point on a shape would leave the rest of the shape on the screen (and broken). Now it just takes the whole shape (again, this is done inefficiently since for every item we walk the entire list of known items to see if we've seen it before. IDK if that will need to be rewritten to speed it up somehow).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/agents/Format.java

    r427 r740  
    5151                // same box as the cursor
    5252                Collection<Text> itemsToFormat = getItemsToFormat(start);
     53               
     54                List<Item> changedItems = new ArrayList<Item>();
    5355
    5456                ArrayList<Item> columnHeads = new ArrayList<Item>();
     
    129131
    130132                        if (xCheck < FrameGraphics.getMaxSize().width) {
    131                                 if (columnHeads.get(i + 1).getX() < maxX
    132                                                 && columnHeads.get(i + 1).getY() < maxY)
    133                                         columnHeads.get(i + 1).setX(maxX);
    134 
    135                                 for (Item it : columns.get(i + 1))
    136                                         if (it.getX() < maxX && it.getY() < maxY)
     133                                Item columnHead = columnHeads.get(i + 1);
     134                                if (columnHead.getX() < maxX && columnHead.getY() < maxY) {
     135                                        if(columnHead.getX() != maxX && !changedItems.contains(columnHead)) {
     136                                                Item copy = columnHead.copy();
     137                                                copy.setID(columnHead.getID());
     138                                                changedItems.add(copy);
     139                                        }
     140                                        columnHead.setX(maxX);
     141                                }
     142
     143                                for (Item it : columns.get(i + 1)) {
     144                                        if (it.getX() < maxX && it.getY() < maxY) {
     145                                        if(it.getX() != maxX && !changedItems.contains(it)) {
     146                                                Item copy = it.copy();
     147                                                copy.setID(it.getID());
     148                                                changedItems.add(copy);
     149                                        }
    137150                                                it.setX(maxX);
    138                         }
    139 
    140                         res = FrameUtils.Align(columns.get(i + 1), true, _adjust);
     151                                        }
     152                                }
     153                        }
     154                       
     155                        res = FrameUtils.Align(columns.get(i + 1), true, _adjust, changedItems);
    141156                        _success = _success && (res >= 0);
    142157                }
     
    148163                 */
    149164                start.setChanged(true);
     165                start.addToUndo(changedItems);
    150166                FrameGraphics.requestRefresh(true);
    151167                return null;
Note: See TracChangeset for help on using the changeset viewer.