Changeset 1216 for trunk/src


Ignore:
Timestamp:
01/30/19 13:02:05 (5 years ago)
Author:
bln4
Message:

DisplayController.java -> Ability to Enter and check if the MailBay is currently shown. When a message is received in the MessageBay, it gets screen

File:
1 edited

Legend:

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

    r1182 r1216  
    2828import java.util.function.BooleanSupplier;
    2929
     30import org.expeditee.auth.gui.MailBay;
    3031import org.expeditee.core.Clip;
    3132import org.expeditee.core.Colour;
     
    117118        private static boolean _audienceMode = false;
    118119       
     120        /** Whether we are currently displaying mail mode whilst not in audience mode */
     121        private static boolean _mailMode = false;
     122       
    119123        /** Whether we are currently displaying in x-ray mode. */
    120124        private static boolean _xrayMode = false;
     
    232236        public static void setTextCursor(Text text, int cursorMovement,
    233237                        boolean newSize, boolean isShiftDown, boolean isCtrlDown,
    234                         boolean allowClearSelection)
    235         {
     238                        boolean allowClearSelection) {
    236239
    237240                int size = Math.round(text.getSize());
     
    243246                Point newMouse = text.moveCursor(cursorMovement, DisplayController.getFloatMouseX(), EcosystemManager.getInputManager().getCursorPosition().getY(), isShiftDown, isCtrlDown);
    244247                                               
    245                 if(             isCtrlDown ||
    246                                 (DisplayController.getFloatMouseX() <= newMouse.getX() && newMouse.getX() <= DisplayController.getFloatMouseX() + 1) ||
    247                                 (DisplayController.getFloatMouseX() > newMouse.getX() && cursorMovement == Text.RIGHT))
     248                if( isCtrlDown ||
     249                        (DisplayController.getFloatMouseX() <= newMouse.getX() && newMouse.getX() <= DisplayController.getFloatMouseX() + 1) ||
     250                        (DisplayController.getFloatMouseX() > newMouse.getX() && cursorMovement == Text.RIGHT))
    248251                {
    249252                        if(cursorMovement == Text.RIGHT && !MagneticConstraints.getInstance().rightBorderHit(text)) {
     
    11521155                requestRefresh(false);
    11531156        }
     1157       
     1158        /**
     1159         * If Mail Mode is on, this method will toggle it to be off, or vice-versa.
     1160         * This results in the Frame being re-parsed and repainted.
     1161         */
     1162        public static void ToggleMailMode() {
     1163                Frame current = DisplayController.getCurrentFrame();
     1164               
     1165                // Turn off x-ray mode if it's on
     1166                if (_xrayMode) {
     1167                        ToggleXRayMode();
     1168                }
     1169               
     1170                _mailMode = !_mailMode;
     1171               
     1172                refreshPaintAreas();
     1173                FrameUtils.Parse(current);
     1174                updateTitle();
     1175                requestRefresh(false);
     1176        }
     1177       
     1178        /**
     1179         * Turns Mail Mode off.
     1180         * This results in the Frame being re-parsed and repainted.
     1181         */
     1182        public static void DisableMailMode() {
     1183                Frame current = DisplayController.getCurrentFrame();
     1184               
     1185                // Turn off x-ray mode if it's on
     1186                if (_xrayMode) {
     1187                        ToggleXRayMode();
     1188                }
     1189               
     1190                _mailMode = false;
     1191               
     1192                refreshPaintAreas();
     1193                FrameUtils.Parse(current);
     1194                updateTitle();
     1195                requestRefresh(false);
     1196        }
    11541197
    11551198        /**
     
    11841227                return _audienceMode;
    11851228        }
     1229               
     1230        /** Whether mail mode is currently on. */
     1231        public static boolean isMailMode() {
     1232                return _mailMode;
     1233        }
    11861234
    11871235        /** Whether x-ray mode is currently on. */
     
    12581306                if (ItemUtils.isVisible(damagedItem)) {
    12591307                        invalidateArea(AxisAlignedBoxBounds.getEnclosing(toRepaint));
    1260                 } else if (MessageBay.isMessageItem(damagedItem)) {
     1308                } else if (!_mailMode && MessageBay.isMessageItem(damagedItem)) {
     1309                        invalidateArea(AxisAlignedBoxBounds.getEnclosing(toRepaint).translate(0, getMessageBayPaintArea().getMinY()));
     1310                } else if (_mailMode && MailBay.isPreviewMailItem(damagedItem)) {
    12611311                        invalidateArea(AxisAlignedBoxBounds.getEnclosing(toRepaint).translate(0, getMessageBayPaintArea().getMinY()));
    12621312                }
     
    13431393                }
    13441394
    1345                 // Paint message bay
    13461395                if (!isAudienceMode()) {
    1347                         Clip messageBayClip = null;
    1348                        
    1349                         AxisAlignedBoxBounds messageBayPaintArea = getMessageBayPaintArea();
    1350                         if (useInvalidation) {
    1351                                 messageBayClip = clip.clone().intersectWith(messageBayPaintArea);
    1352                                 if (!messageBayClip.isFullyClipped()) {
    1353                                         messageBayClip = new Clip(messageBayClip.getBounds().translate(0, -messageBayPaintArea.getMinY()));
    1354                                 }
    1355                         }
    1356                        
    1357                         Image image = null;
    1358                         if (!useInvalidation || !messageBayClip.isFullyClipped()) {
    1359                                 image = MessageBay.getImage(messageBayClip, messageBayPaintArea.getSize());
    1360                         }
    1361                        
    1362                         if (image != null) {
    1363                                 g.drawImage(image, messageBayPaintArea.getTopLeft(), messageBayPaintArea.getSize());
     1396                        if (!isMailMode()) {
     1397                                // Paint message bay
     1398                                paintMessageBay(useInvalidation, clip, g);
     1399                        } else {
     1400                                // Paint mail bay
     1401                                paintMailBay(useInvalidation, clip, g);
    13641402                        }
    13651403                }
     
    13781416                return true;
    13791417        }
    1380        
     1418
     1419        private static void paintMessageBay(boolean useInvalidation, Clip clip, GraphicsManager g) {
     1420                Clip messageBayClip = null;
     1421               
     1422                AxisAlignedBoxBounds messageBayPaintArea = getMessageBayPaintArea();
     1423                if (useInvalidation) {
     1424                        messageBayClip = clip.clone().intersectWith(messageBayPaintArea);
     1425                        if (!messageBayClip.isFullyClipped()) {
     1426                                messageBayClip = new Clip(messageBayClip.getBounds().translate(0, -messageBayPaintArea.getMinY()));
     1427                        }
     1428                }
     1429               
     1430                Image image = null;
     1431                if (!useInvalidation || !messageBayClip.isFullyClipped()) {
     1432                        image = MessageBay.getImage(messageBayClip, messageBayPaintArea.getSize());
     1433                }
     1434               
     1435                if (image != null) {
     1436                        g.drawImage(image, messageBayPaintArea.getTopLeft(), messageBayPaintArea.getSize());
     1437                }
     1438        }
     1439       
     1440        private static void paintMailBay(boolean useInvalidation, Clip clip, GraphicsManager g) {
     1441                Clip mailBayClip = null;
     1442               
     1443                AxisAlignedBoxBounds mailBayPaintArea = getMessageBayPaintArea();
     1444                if (useInvalidation) {
     1445                        mailBayClip = clip.clone().intersectWith(mailBayPaintArea);
     1446                        if (!mailBayClip.isFullyClipped()) {
     1447                                mailBayClip = new Clip(mailBayClip.getBounds().translate(0, -mailBayPaintArea.getMinY()));
     1448                        }
     1449                }
     1450               
     1451                Image image = null;
     1452                if (!useInvalidation || !mailBayClip.isFullyClipped()) {
     1453                        image = MailBay.getImage(mailBayClip, mailBayPaintArea.getSize());
     1454                }
     1455               
     1456                if (image != null) {
     1457                        g.drawImage(image, mailBayPaintArea.getTopLeft(), mailBayPaintArea.getSize());
     1458                }
     1459        }
     1460
    13811461        /** Draws the two frame images to the display and puts the separator line between them. */
    13821462        private static void paintTwinFrames(Image leftFrameImage, Image rightFrameImage)
Note: See TracChangeset for help on using the changeset viewer.