Changeset 1051


Ignore:
Timestamp:
04/29/16 14:17:00 (8 years ago)
Author:
davidb
Message:

Code upgraded so frame zooming is an optional (experimental) feature controlled through settings. This is because it's just to easy to be trying to resize a text item, miss by a few pixels with the mouse cursor, and then zoom the entire page accidentaly

Location:
trunk/src/org/expeditee
Files:
2 edited

Legend:

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

    r977 r1051  
    5353import org.expeditee.items.widgets.WidgetCorner;
    5454import org.expeditee.items.widgets.WidgetEdge;
     55import org.expeditee.settings.experimental.ExperimentalFeatures;
    5556import org.expeditee.settings.templates.TemplateSettings;
    5657import org.expeditee.stats.Formatter;
     
    11961197                // space and return for the F keys that dont do anything in free space.
    11971198                if (on == null) {
     1199                       
     1200                        int mouse_x = FrameMouseActions.getX(), mouse_y = FrameMouseActions.getY();
     1201                       
    11981202                        switch (key) {
    11991203                        // These function keys still work in free space
     
    12051209                        case Save:
    12061210                                break;
     1211                               
    12071212                        case SizeDown:
    1208                                 zoomFrame(DisplayIO.getCurrentFrame(), 0.909090909f);
    1209                                 DisplayIO.getCurrentFrame().refreshSize();
    1210                                 FrameKeyboardActions.Refresh();
    1211                                 return;
     1213                                zoomFrameIfEnabled(DisplayIO.getCurrentFrame(), 0.909090909f, mouse_x,mouse_y);
    12121214                                // if (isControlDown) {
    12131215                                // UserSettings.ScaleFactor.set(UserSettings.ScaleFactor.get() -
     
    12161218                                // return;
    12171219                                // }
     1220                                return;
     1221                               
    12181222                        case SizeUp:
    1219                                 zoomFrame(DisplayIO.getCurrentFrame(), 1.1f);
    1220                                 DisplayIO.getCurrentFrame().refreshSize();
    1221                                 FrameKeyboardActions.Refresh();
     1223                                zoomFrameIfEnabled(DisplayIO.getCurrentFrame(), 1.1f, mouse_x,mouse_y);
     1224                                        // if (isControlDown) {
     1225                                        // UserSettings.ScaleFactor.set(UserSettings.ScaleFactor.get() +
     1226                                        // 0.05f);
     1227                                        // Misc.repaint();
     1228                                        // return;
     1229                                        // }
    12221230                                return;
    1223                                 // if (isControlDown) {
    1224                                 // UserSettings.ScaleFactor.set(UserSettings.ScaleFactor.get() +
    1225                                 // 0.05f);
    1226                                 // Misc.repaint();
    1227                                 // return;
    1228                                 // }
     1231                               
    12291232                        default:
    12301233                                MessageBay.displayMessageOnce(displayMessage);
     
    17491752        }
    17501753
    1751         public static void zoomFrame(Frame frame, double scaleFactor) {
    1752 
    1753                 int x = FrameMouseActions.getX(), y = FrameMouseActions.getY();
     1754        protected static void zoomFrame(Frame frame, double scaleFactor, int x, int y) {
    17541755
    17551756                if (frame == null) {
     
    17981799        }
    17991800
     1801        public static boolean zoomFrameIfEnabled(Frame frame, double scaleFactor, int mouse_x, int mouse_y)
     1802        {
     1803                boolean zoom_active = ExperimentalFeatures.FrameZoom.get();
     1804               
     1805                if (zoom_active) {
     1806                       
     1807                        int x, y;
     1808                        if (ExperimentalFeatures.FrameZoomAroundCursor.get()) {
     1809                                x = mouse_x;
     1810                                y = mouse_y;
     1811                        }
     1812                        else {
     1813                                x = 0;
     1814                                y = 0;
     1815                        }
     1816                       
     1817                        zoomFrame(DisplayIO.getCurrentFrame(), scaleFactor, x, y);
     1818                        DisplayIO.getCurrentFrame().refreshSize();
     1819                        FrameKeyboardActions.Refresh();
     1820                }
     1821                else {
     1822                        String frameZoomingDisabledMessage = "Frame Zooming currently disabled. "
     1823                                        + "Access Settings->Experimental->FrameZoom and set to 'true' to enable this";
     1824                        MessageBay.displayMessageOnce(frameZoomingDisabledMessage);
     1825                }
     1826               
     1827                return zoom_active;
     1828        }
     1829       
     1830        public static boolean zoomFrameTopLeftIfEnabled(Frame frame, double scaleFactor)
     1831        {
     1832                return zoomFrameIfEnabled(frame, scaleFactor, 0, 0);
     1833        }
     1834       
    18001835        /**
    18011836         * Adjusts the size of the given Item, by the given amount. Note: The amount
     
    18311866                                // scale the entire frame
    18321867                                if (diff != 0) {
    1833                                         zoomFrame(DisplayIO.getCurrentFrame(), diff > 0 ? 1.1
    1834                                                         : 0.909090909);
    1835                                         DisplayIO.getCurrentFrame().refreshSize();
    1836                                         FrameKeyboardActions.Refresh();
     1868                                        double scaleFactor = diff > 0 ? 1.1 : 0.909090909;
     1869                                        zoomFrameTopLeftIfEnabled(DisplayIO.getCurrentFrame(), scaleFactor);
    18371870                                }
    18381871                                // MessageBay.displayMessage("Can not resize the frame name");
  • trunk/src/org/expeditee/settings/experimental/ExperimentalFeatures.java

    r919 r1051  
    2525        public static final BooleanSetting AutoWrap = new BooleanSetting("Enable auto wrapping of text", false);
    2626       
     27        public static final BooleanSetting FrameZoom = new BooleanSetting("Enable zooming in and out of frame using F1/F2 or else shift with click-wheel", false);
     28       
     29        public static final BooleanSetting FrameZoomAroundCursor = new BooleanSetting("If true, Frame Zooming uses the location of the mouse cursor as the central point to zoom in/out.", false);
     30       
    2731        public static final BooleanSetting MousePan = new BooleanSetting("Enable panning of the frame by shift-click and dragging the mouse", false);
    2832       
Note: See TracChangeset for help on using the changeset viewer.