public static boolean isVisible(Element e) { //vp = viewPort, b = bottom, l = left, t = top, r = right int vpWidth = Window.getClientWidth(); int vpHeight = Window.getClientHeight(); boolean tViz = ( e.getAbsoluteTop() >= 0 && e.getAbsoluteTop()< vpHeight); boolean bViz = (e.getAbsoluteBottom() > 0 && e.getAbsoluteBottom() <= vpHeight); boolean lViz = (e.getAbsoluteLeft() >= 0 && e.getAbsoluteLeft() < vpWidth); boolean rViz = (e.getAbsoluteRight() > 0 && e.getAbsoluteRight() <= vpWidth); boolean vVisible = tViz && bViz; boolean hVisible = lViz && rViz; return hVisible && vVisible; }
void resize() { if( fakeDiv == null ) { fakeDiv = DOM.createDiv(); fakeDiv.getStyle().setPosition( Position.FIXED ); fakeDiv.getStyle().setLeft( -10000, Unit.PX ); getElement().getParentElement().insertAfter( fakeDiv, getElement() ); applyStyle( fakeDiv ); } int width = getElement().getAbsoluteRight() - getElement().getAbsoluteLeft(); fakeDiv.getStyle().setWidth( width - 10 - 2, Unit.PX ); fakeDiv.setInnerText( getText() ); int height = getElement().getClientHeight(); int newHeight = fakeDiv.getClientHeight() + 25; if( height < newHeight ) getElement().getStyle().setHeight( newHeight, Unit.PX ); }
void resize() { if( fakeDiv == null ) { fakeDiv = DOM.createDiv(); fakeDiv.getStyle().setPosition( Position.FIXED ); fakeDiv.getStyle().setLeft( -10000, Unit.PX ); getElement().getParentElement().insertAfter( fakeDiv, getElement() ); applyStyle( fakeDiv ); } int width = getElement().getAbsoluteRight() - getElement().getAbsoluteLeft(); fakeDiv.getStyle().setWidth( width - 10 - 2, Unit.PX ); fakeDiv.setInnerText( getText() ); int height = getElement().getClientHeight(); int newHeight = fakeDiv.getClientHeight() + 25; if( height < newHeight ) getElement().getStyle().setHeight( newHeight, Unit.PX ); }
private void attachAutoCloseHandler() { removeAutoCloseHandler(); autoCloseHandler = RootPanel.get().addDomHandler(e -> { if (isVisible()) { int top = content.asWidget().getElement().getAbsoluteTop(); int left = content.asWidget().getElement().getAbsoluteLeft(); int right = content.asWidget().getElement().getAbsoluteRight(); int bottom = content.asWidget().getElement().getAbsoluteBottom(); if (e.getY() < top || e.getY() > bottom || e.getX() < left || e.getX() > right) { hide(); } } }, ClickEvent.getType()); }
private void show(final DragContext context) { //Get centre of DropTarget final Widget dropTargetParent = context.dropController.getDropTarget(); int cxmin = dropTargetParent.getElement().getAbsoluteLeft(); int cymin = dropTargetParent.getElement().getAbsoluteTop(); int cxmax = dropTargetParent.getElement().getAbsoluteRight(); int cymax = dropTargetParent.getElement().getAbsoluteBottom(); final CoordinateArea ca = new CoordinateArea(cxmin, cymin, cxmax, cymax); //Display Compass if not already visible if (!popup.isAttached()) { popup.setPopupPositionAndShow(new PopupPanel.PositionCallback() { @Override public void setPosition(int offsetWidth, int offsetHeight) { popup.setPopupPosition(ca.getCenter().getLeft() - (offsetWidth / 2), ca.getCenter().getTop() - (offsetHeight / 2)); } }); } else { popup.setPopupPosition(ca.getCenter().getLeft() - (popup.getOffsetWidth() / 2), ca.getCenter().getTop() - (popup.getOffsetHeight() / 2)); } }
private void show( final DragContext context ) { //Get centre of DropTarget final Widget dropTargetParent = context.dropController.getDropTarget(); int cxmin = dropTargetParent.getElement().getAbsoluteLeft(); int cymin = dropTargetParent.getElement().getAbsoluteTop(); int cxmax = dropTargetParent.getElement().getAbsoluteRight(); int cymax = dropTargetParent.getElement().getAbsoluteBottom(); final CoordinateArea ca = new CoordinateArea( cxmin, cymin, cxmax, cymax ); //Display Compass if not already visible if ( !isAttached() ) { setPopupPositionAndShow( new PositionCallback() { @Override public void setPosition( int offsetWidth, int offsetHeight ) { setPopupPosition( ca.getCenter().getLeft() - ( offsetWidth / 2 ), ca.getCenter().getTop() - ( offsetHeight / 2 ) ); } } ); } else { setPopupPosition( ca.getCenter().getLeft() - ( getOffsetWidth() / 2 ), ca.getCenter().getTop() - ( getOffsetHeight() / 2 ) ); } }
private void show(final DragContext context) { //Get centre of DropTarget final Widget dropTargetParent = context.dropController.getDropTarget(); int cxmin = dropTargetParent.getElement().getAbsoluteLeft(); int cymin = dropTargetParent.getElement().getAbsoluteTop(); int cxmax = dropTargetParent.getElement().getAbsoluteRight(); int cymax = dropTargetParent.getElement().getAbsoluteBottom(); final CoordinateArea ca = new CoordinateArea(cxmin, cymin, cxmax, cymax); //Display Compass if not already visible if (!popup.isAttached()) { popup.setPopupPositionAndShow(new PopupPanel.PositionCallback() { @Override public void setPosition(int offsetWidth, int offsetHeight) { popup.setPopupPosition(ca.getCenter().getLeft() - (offsetWidth / 2), ca.getCenter().getTop() - (offsetHeight / 2)); } }); } else { popup.setPopupPosition(ca.getCenter().getLeft() - (popup.getOffsetWidth() / 2), ca.getCenter().getTop() - (popup.getOffsetHeight() / 2)); } }