Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8115852

PopupWindow with content with Shadow Effect, wrong position

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 8
    • Fix Version/s: 8
    • Component/s: javafx
    • Labels:
      None

      Description

      When a menu's content has a shadow effect or similar that draws outside of layout bounds. We move the node down so that the whole node is inside the popup window and we do not get clipping of the shadow. The problem with this is a shadow on a menu offsets the menu so that it no longer aligns with the menu bar. See the attached screenshots.

      What should happen is the popup should be moved from the user set X,Y so that the layout bounds 0,0 is positioned at the user requested screenX, screenY.

      I did a simple patch for this:

      diff -r 649ecc9fc736 javafx-ui-common/src/javafx/stage/PopupWindow.java
      --- a/javafx-ui-common/src/javafx/stage/PopupWindow.java Mon Mar 04 15:17:00 2013 -0800
      +++ b/javafx-ui-common/src/javafx/stage/PopupWindow.java Mon Mar 04 16:57:25 2013 -0800
      @@ -341,7 +341,11 @@
               if (ownerNode != null) {
                   ownerNode.visibleProperty().addListener(ownerNodeListener);
               }
      -
      +
      + Bounds sceneRootBounds = getScene().getRoot().getBoundsInLocal();
      + if (sceneRootBounds.getMinX() < 0) screenX += sceneRootBounds.getMinX();
      + if (sceneRootBounds.getMinY() < 0) screenY += sceneRootBounds.getMinY();
      +
               setX(screenX);
               setY(screenY);
               showImpl(newOwnerWindow);

      I am not sure this is the right place for this fix and looked a bit deeper. It seems like we have very similar code:

                  if (!isAutoFix()) {
                      final Parent rootNode = getScene().getRoot();
                      if (rootNode != null) {
                          final Bounds _bounds = rootNode.getLayoutBounds();
                          setX(this.getX() + _bounds.getMinX());
                          setY(this.getY() + _bounds.getMinY());
                      }
                  }

      At line 403 of PopupWindow.java but its not running because isAutoFix() is true. Looking at the history it looks like this code used to always be run but got moved behind this if statement with a fix for RT-19437 by Lubomir in change 424:b5bafe2e6c6e. So I am not sure why this got removed. So I am unsure if me putting something similar back in place is a good idea or not. Was this removed for a reason or by accident?

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                lnerad Ľubomír Nerád
                Reporter:
                jasper Jasper Potts
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported: