Ignore:
Timestamp:
02/19/20 10:44:38 (4 years ago)
Author:
bnemhaus
Message:

Frame::Parse has been updated to include a new boolean parameter. When true, widgets that are created as a result of the parse send not only notify the widget framework that they have been added, but are also visible. When false, they only notify they have been added.

The widget framework now distinguishes between added and visible widgets, this fixes a bug. Bug: when programmatically adding a widget to not the current frame, it never gets properly removed and therefore still catches click events from users. By distinguishing between adding and making visible this is avoided.


Another bug has been fixed. Bug: When setting a text item to have a right anchor, and then subsequently reducing the size of the window, this text item would get a width of zero assigned. This was caused by some issues with the logic of how right margins for items were calculated.

File:
1 edited

Legend:

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

    r1508 r1511  
    7171import org.expeditee.items.Item;
    7272import org.expeditee.items.Item.HighlightMode;
     73import org.expeditee.items.ItemParentStateChangedEvent;
    7374import org.expeditee.items.ItemUtils;
    7475import org.expeditee.items.JSItem;
     
    680681         * @param txt
    681682         *            Text to create the widget from. Must not be null.
     683         * @param userEdit True if createWidget is being called because a user has made a edit, false otherwise.
    682684         *
    683685         * @return True if created/added. False if could not create.
     
    685687         * @author Brook Novak
    686688         */
    687         private static boolean createWidget(Frame frame, Text txt, ItemsList list) {
     689        private static boolean createWidget(Frame frame, Text txt, ItemsList list, boolean userEdit) {
    688690
    689691                if (frame == null) {
     
    723725
    724726                frame.addAllItems(iw.getItems(), list);
     727               
     728                if (userEdit) {
     729                        iw.onParentStateChanged(new ItemParentStateChangedEvent(frame, ItemParentStateChangedEvent.EVENT_TYPE_SHOWN));
     730                }
    725731
    726732                return true;
     
    728734       
    729735        private static boolean createWidgetInBody(Frame frame, Text txt) {
    730                 return createWidget(frame, txt, frame.getBody(false));
     736                return createWidget(frame, txt, frame.getBody(false), false);
    731737        }
    732738
     
    889895        }
    890896       
    891         private static void transformOutOfPlaceItems(Frame toParse, ItemsList toTransform) {
     897        private static void transformOutOfPlaceItems(Frame toParse, ItemsList toTransform, boolean sendWidgetVisible) {
    892898                // Get all items from toTransform that have not been marked as deleted.
    893899                List<Item> items = toParse.getItems(false, toTransform);
     
    988994                                                        // Check for interactive widgets
    989995                                                } else if (ItemUtils.startsWithTag(i, ItemUtils.TAG_IWIDGET)) {
    990                                                         createWidget(toParse, (Text) i, toTransform);
     996                                                        createWidget(toParse, (Text) i, toTransform, sendWidgetVisible);
    991997                                                }
    992998
     
    11491155         */
    11501156        public static void Parse(Frame toParse, boolean firstParse) {
    1151                 Parse(toParse, firstParse, false);
     1157                Parse(toParse, firstParse, false, false);
    11521158        }
    11531159
     
    11601166         *            an ao tag linked to a frame with an frameImage of a frame which
    11611167         *            also has an ao tag on it.
     1168         * @param userEdit TODO
    11621169         */     
    1163         public static void Parse(Frame toParse, boolean firstParse, boolean ignoreAnnotations) {
     1170        public static void Parse(Frame toParse, boolean firstParse, boolean ignoreAnnotations, boolean userEdit) {
    11641171                List<String> accessList = Label.getAccessibleLabelsNames(toParse.getPrimaryBody());
    11651172               
     
    11671174                ItemsList surrogates = toParse.getSurrogateBody();
    11681175               
    1169                 transformOutOfPlaceItems(toParse, primaries);
    1170                 transformOutOfPlaceItems(toParse, surrogates);
     1176                transformOutOfPlaceItems(toParse, primaries, userEdit);
     1177                transformOutOfPlaceItems(toParse, surrogates, userEdit);
    11711178               
    11721179                toParse.getInteractableItems().clear();
     
    18011808                if (!DisplayController.isXRayMode()) {
    18021809                        if (toReparse != null) {
    1803                                 Parse(toReparse, false, false);
     1810                                Parse(toReparse, false, false, true);
    18041811                        } else {
    18051812                                if (toRecalculate != null) {
Note: See TracChangeset for help on using the changeset viewer.