Ignore:
Timestamp:
12/17/13 15:52:27 (11 years ago)
Author:
jts21
Message:

Add panning action

  • Use by shift-left-click and dragging the mouse, or by adding a "Pan" action
  • Mouse binding is disabled by default, enable via "MousePan" setting in in settings/experimental (also "AutoWrap" setting was moved to experimental too)
  • Frames now save all visible items instead of deleting items that have negative position values, this change was made so items would not be lost by panning the frame.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/actions/Misc.java

    r625 r632  
    3030import org.expeditee.gui.FrameGraphics;
    3131import org.expeditee.gui.FrameIO;
     32import org.expeditee.gui.FrameKeyboardActions;
    3233import org.expeditee.gui.FrameMouseActions;
    3334import org.expeditee.gui.FrameUtils;
     
    14691470                }).start();
    14701471        }
     1472       
     1473        public static void pan(Frame frame, int x, int y) {
     1474                for(Item i : frame.getAllItems()) {
     1475                        i.setXY(i.getX() + x, i.getY() + y);
     1476                        // update the polygon, otherwise stuff moves but leaves it's outline behind
     1477                        // (maybe this should use setPosition() instead?)
     1478                        i.updatePolygon();
     1479                }
     1480                // make sure we save the panning of the frame
     1481                frame.change();
     1482                // redraw everything
     1483                FrameKeyboardActions.Refresh();
     1484        }
     1485       
     1486        public static void pan(Frame frame, String pan) {
     1487                String[] split = pan.split("\\s+");
     1488                int x = 0;
     1489                int y = 0;
     1490                try {
     1491                        if(split.length != 2) throw new Exception();
     1492                        x = Integer.parseInt(split[0]);
     1493                        y = Integer.parseInt(split[1]);
     1494                } catch(Exception e) {
     1495                        MessageBay.errorMessage("Panning takes 2 integer arguments");
     1496                        return;
     1497                }
     1498                pan(frame, x, y);
     1499        }
     1500       
     1501        public static void pan(Frame frame, Text pan) {
     1502                pan(frame, pan.getText());
     1503        }
    14711504}
Note: See TracChangeset for help on using the changeset viewer.