Changeset 1511


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.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/gio/gesture/StandardGestureActions.java

    r1503 r1511  
    12081208                }
    12091209                if (bReparse) {
    1210                         FrameUtils.Parse(currentFrame, false, false);
     1210                        FrameUtils.Parse(currentFrame, false, false, false);
    12111211                } else {
    12121212                        currentFrame.notifyObservers(bRecalculate);
     
    19331933                Frame currentFrame = DisplayController.getCurrentFrame();
    19341934                if (bReparse) {
    1935                         FrameUtils.Parse(currentFrame, false, false);
     1935                        FrameUtils.Parse(currentFrame, false, false, false);
    19361936                } else {
    19371937                        currentFrame.notifyObservers(bRecalculate);
     
    20132013                itemList.clear();
    20142014                if (bReparse) {
    2015                         FrameUtils.Parse(currentFrame, false, false);
     2015                        FrameUtils.Parse(currentFrame, false, false, false);
    20162016                        /*
    20172017                         * TODO check if I need to recalculate even if reparse occurs, here and in
     
    33443344                        }
    33453345                        if (toDelete.hasOverlay()) {
    3346                                 FrameUtils.Parse(parent, false, false);
     3346                                FrameUtils.Parse(parent, false, false, false);
    33473347                                DisplayController.requestRefresh(false);
    33483348                        }
  • trunk/src/org/expeditee/gui/Frame.java

    r1509 r1511  
    11961196               
    11971197                if (reparse) {
    1198                         FrameUtils.Parse(this, false, false);
     1198                        FrameUtils.Parse(this, false, false, false);
    11991199                } else {
    12001200                        notifyObservers(recalculate);
     
    12581258               
    12591259                if (bReparse) {
    1260                         FrameUtils.Parse(this, false, false);
     1260                        FrameUtils.Parse(this, false, false, false);
    12611261                } else {
    12621262                        notifyObservers(bRecalculate);
  • 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) {
  • trunk/src/org/expeditee/items/Item.java

    r1509 r1511  
    27402740        }
    27412741
    2742         public void setRightMargin(int i, boolean fixWidth)
    2743         {
    2744                 int newWidth = i - getX() - Item.MARGIN_LEFT;
    2745                 if (newWidth < 0) newWidth = 0;
    2746                
    2747                 if (!fixWidth) {
    2748                         newWidth *= -1;
    2749                 }
    2750 
    2751                 setWidth(newWidth);
     2742        public void setRightMargin(int rightEdgeToFitTo, boolean fixWidth)
     2743        {
     2744                int itemXLeft = getX();
     2745                int adjustedRightEdgeToFitTo = rightEdgeToFitTo - Item.MARGIN_LEFT;
     2746               
     2747                if (itemXLeft < adjustedRightEdgeToFitTo) {
     2748                        int newWidth = adjustedRightEdgeToFitTo - itemXLeft;
     2749
     2750                        if (!fixWidth) {
     2751                                newWidth *= -1;
     2752                        }
     2753
     2754                        setWidth(newWidth);
     2755                } else if (fixWidth) {
     2756                        System.err.println(
     2757                                        "Item::setRightMargin() called to set right margin outside of writable area but with fixWidth set to true.");
     2758                        System.err.println(this);
     2759                }
    27522760        }
    27532761
     
    36553663                if (anchor != null) {
    36563664                        anchorConstraints();
    3657                         setX(DisplayController.getFramePaintArea().getMaxX() - anchor - getBoundsWidth());
     3665                        int width = Math.abs(getBoundsWidth());
     3666                        //System.err.println("Item::setAnchorRight::Text Content= " + getText() + "; width=" + width);
     3667                        setX(DisplayController.getFramePaintArea().getMaxX() - anchor - width);
    36583668                }
    36593669               
  • trunk/src/org/expeditee/items/Text.java

    r1416 r1511  
    393393        @Override
    394394        public void setWidth(Integer width) {
     395                System.err.println("Text::setWidth::Text content=" + getText() + ", new width=" + width);
    395396                invalidateAll();
    396397
     
    400401                        return;
    401402                }
    402 
     403               
     404                if (width == 0) {
     405                        System.err.println("Width of Zero: " + getText());
     406                }
     407               
    403408                _width = width;
    404409                rebuild(true);
     
    17831788
    17841789                if (this.getMinWidth() != null && getTextLayouts().size() == 0 && this.getFont() != null) {
     1790                        // could use any text, 'p' is used simply to get some text in correct font.
    17851791                        getTextLayouts().add(TextLayout.getManager().layoutStringSimple("p", this.getFont()));
    17861792                        isFakeLayout = true;
     
    29102916                        if (anchor != null) {
    29112917                                setX(DisplayController.getFramePaintAreaWidth() - anchor - getBoundsWidth() + getLeftMargin());
     2918                                //System.err.println("Text::setAnchorRight::boundsWidth=" + getBoundsWidth());
    29122919                        }
    29132920                        return;
  • trunk/src/org/expeditee/items/widgets/SampleWidget1.java

    r1191 r1511  
    5050                        c.setFocusable(true);
    5151                }
     52                System.err.println("SampleWidget1::setting light weight popup enabled to false.");
     53                cmboOptions.setLightWeightPopupEnabled(false);
    5254        }
    5355               
  • trunk/src/org/expeditee/items/widgets/SampleWidget2.java

    r1178 r1511  
    7474                cmboPrepend.setFont(BIG_FONT);
    7575                cmboPrepend.addActionListener(new PrependManager(cmboPrepend, utxt));
     76                cmboPrepend.setLightWeightPopupEnabled(false);
    7677               
    7778                controls.add(lblTitle);
  • trunk/src/org/expeditee/items/widgets/SwingWidget.java

    r1191 r1511  
    1515
    1616import javax.swing.JComponent;
    17 import javax.swing.JPopupMenu;
    1817
    1918import org.expeditee.core.bounds.AxisAlignedBoxBounds;
     
    5251                onBoundsChanged();
    5352               
    54                 JPopupMenu.setDefaultLightWeightPopupEnabled(false);
     53                System.err.println("SwingWidget::Suppressed static setDefaultLightWeightPopupEnabled to false.");
     54                //JPopupMenu.setDefaultLightWeightPopupEnabled(false);
    5555        }
    5656
  • trunk/src/org/expeditee/items/widgets/Widget.java

    r1258 r1511  
    11131113                        case ItemParentStateChangedEvent.EVENT_TYPE_ADDED:
    11141114                        case ItemParentStateChangedEvent.EVENT_TYPE_ADDED_VIA_OVERLAY:
     1115                                System.err.println("Widget::onParentStateChanged: Added but not yet shown widget.");
     1116                                break;
    11151117                        case ItemParentStateChangedEvent.EVENT_TYPE_SHOWN:
    11161118                        case ItemParentStateChangedEvent.EVENT_TYPE_SHOWN_VIA_OVERLAY:
     1119                                System.err.println("Widget::onParentStateChanged: Shown widget.");
    11171120                                EcosystemManager.addInteractiveWidget(this);
    11181121                                addWidgetContent(e);
Note: See TracChangeset for help on using the changeset viewer.