From d716940f7dce03b32bf85b54129c94effa837d6a Mon Sep 17 00:00:00 2001 From: jdramaix Date: Thu, 8 Aug 2013 14:23:52 +0200 Subject: [PATCH 1/2] The doCenter method doesn't center correctly the popup when the popup is hidden --- .../gwtplatform/mvp/client/PopupViewImpl.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/gwtp-core/gwtp-mvp-client/src/main/java/com/gwtplatform/mvp/client/PopupViewImpl.java b/gwtp-core/gwtp-mvp-client/src/main/java/com/gwtplatform/mvp/client/PopupViewImpl.java index 616bb51958..b7d784ef6a 100644 --- a/gwtp-core/gwtp-mvp-client/src/main/java/com/gwtplatform/mvp/client/PopupViewImpl.java +++ b/gwtp-core/gwtp-mvp-client/src/main/java/com/gwtplatform/mvp/client/PopupViewImpl.java @@ -135,22 +135,36 @@ protected PopupPanel asPopupPanel() { * This method centers the popup panel, temporarily making it visible if * needed. */ - private void doCenter() { + protected void doCenter() { // We can't use Element.center() method as it will show the popup // by default and not only centering it. This is resulting in onAttach() // being called twice when using setInSlot() or addToPopupSlot() in PresenterWidget + PopupPanel popup = asPopupPanel(); + Element elem = popup.getElement(); + + boolean isShowing = popup.isShowing(); // If left/top are set from a previous doCenter() call, and our content // has changed, we may get a bogus getOffsetWidth because our new content // is wrapping (giving a lower offset width) then it would without the // previous left. Clearing left/top to avoids this. - PopupPanel popup = asPopupPanel(); - Element elem = popup.getElement(); elem.getStyle().clearLeft(); elem.getStyle().clearTop(); + // the popup should be added to the dom in order to get correct values for offsetWidth/offsetHeight + if (!isShowing){ + popup.setVisible(false); + popup.show(); + } + int left = (Window.getClientWidth() - popup.getOffsetWidth()) >> 1; int top = (Window.getClientHeight() - popup.getOffsetHeight()) >> 1; + + if (!isShowing) { + popup.hide(); + popup.setVisible(true); + } + popup.setPopupPosition(Math.max(Window.getScrollLeft() + left, 0), Math.max( Window.getScrollTop() + top, 0)); } From d2ed86dcf71049542d09850176185e1c4e9de93d Mon Sep 17 00:00:00 2001 From: jdramaix Date: Thu, 8 Aug 2013 14:56:52 +0200 Subject: [PATCH 2/2] checkstyle --- .../src/main/java/com/gwtplatform/mvp/client/PopupViewImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gwtp-core/gwtp-mvp-client/src/main/java/com/gwtplatform/mvp/client/PopupViewImpl.java b/gwtp-core/gwtp-mvp-client/src/main/java/com/gwtplatform/mvp/client/PopupViewImpl.java index b7d784ef6a..5a6fa420b4 100644 --- a/gwtp-core/gwtp-mvp-client/src/main/java/com/gwtplatform/mvp/client/PopupViewImpl.java +++ b/gwtp-core/gwtp-mvp-client/src/main/java/com/gwtplatform/mvp/client/PopupViewImpl.java @@ -152,7 +152,7 @@ protected void doCenter() { elem.getStyle().clearTop(); // the popup should be added to the dom in order to get correct values for offsetWidth/offsetHeight - if (!isShowing){ + if (!isShowing) { popup.setVisible(false); popup.show(); }