List of usage examples for com.google.gwt.user.client Window getScrollTop
public static int getScrollTop()
From source file:cc.alcina.framework.gwt.client.util.WidgetUtils.java
License:Apache License
public static void scrollIntoViewWhileKeepingRect(Rect bounds, Widget widget, int pad) { // assume widget is below bounds int scrollTop = Window.getScrollTop(); int clientHeight = Window.getClientHeight(); int widgetTop = widget.getAbsoluteTop(); int widgetHeight = widget.getOffsetHeight(); if (widgetTop + widgetHeight + pad > scrollTop + clientHeight) { int bestDeltaDown = widgetTop + widgetHeight + pad - (scrollTop + clientHeight); int delta = Math.min(bounds.y1 - scrollTop, bestDeltaDown); delta = Math.max(0, delta); smoothScrollTo(scrollTop + delta, widget); }//from w w w . j av a 2s . c o m }
From source file:cc.alcina.framework.gwt.client.util.WidgetUtils.java
License:Apache License
private static void debugScroll(String message) { if (debugScroll) { ClientNotifications.get()//from w w w . j av a 2 s . c om .log(CommonUtils.formatJ("scroll from: %s,%s", Window.getScrollLeft(), Window.getScrollTop())); ClientNotifications.get().log(message); } }
From source file:cc.alcina.framework.gwt.client.widget.complex.SliderBar.java
License:Apache License
/** * Slide the knob to a new location./*from w ww .j a v a 2 s . c o m*/ * * @param event * the mouse event */ private void slideKnob(Event event) { int d = vertical ? DOM.eventGetClientY(event) + Window.getScrollTop() : DOM.eventGetClientX(event) + Window.getScrollLeft(); if (d > 0) { int lineMajorDimension = getLineMajorDimension(); int linePreOffset = vertical ? DOM.getAbsoluteTop(lineElement) : DOM.getAbsoluteLeft(lineElement); double percent = (double) (d - linePreOffset) / lineMajorDimension * 1.0; setCurrentValue(getTotalRange() * percent + minValue, true); } }
From source file:cc.alcina.framework.gwt.client.widget.dialog.GlassDialogBox.java
License:Apache License
@Override public void show() { if (!isGlassHidden()) { glass.show(true);//from ww w . j a v a 2 s .c o m } scrollLeft = Window.getScrollLeft(); scrollTop = Window.getScrollTop(); if (this.handlerRegistration == null && !BrowserMod.isMobile()) { this.handlerRegistration = Window.addWindowScrollHandler(scrollHandler); } super.show(); }
From source file:cc.alcina.framework.gwt.client.widget.dialog.RelativePopupPanel.java
License:Apache License
/** * Centers the popup in the browser window and shows it. If the popup was * already showing, then the popup is centered. *///from www . ja v a 2 s.c o m public void center() { boolean initiallyShowing = showing; boolean initiallyAnimated = isAnimationEnabled; if (!initiallyShowing) { setVisible(false); setAnimationEnabled(false); show(); } int left = (Window.getClientWidth() - getOffsetWidth()) >> 1; int top = (Window.getClientHeight() - getOffsetHeight()) >> 1; setPopupPosition(Math.max(Window.getScrollLeft() + left, 0), Math.max(Window.getScrollTop() + top, 0)); if (!initiallyShowing) { setAnimationEnabled(initiallyAnimated); // Run the animation. The popup is already visible, so we can skip // the // call to setState. if (initiallyAnimated) { impl.setClip(getElement(), "rect(0px, 0px, 0px, 0px)"); setVisible(true); resizeAnimation.run(ANIMATION_DURATION); } else { setVisible(true); } } }
From source file:cc.alcina.framework.gwt.client.widget.dialog.RelativePopupPanel.java
License:Apache License
/** * Positions the popup, called after the offset width and height of the * popup are known./* ww w. ja v a2s . c om*/ * * @param relativeObject * the ui object to position relative to * @param offsetWidth * the drop down's offset width * @param offsetHeight * the drop down's offset height */ private void position(final UIObject relativeObject, int offsetWidth, int offsetHeight) { // Calculate left position for the popup. The computation for // the left position is bidi-sensitive. int textBoxOffsetWidth = relativeObject.getOffsetWidth(); // Compute the difference between the popup's width and the // textbox's width int offsetWidthDiff = offsetWidth - textBoxOffsetWidth; int left; if (LocaleInfo.getCurrentLocale().isRTL()) { // RTL case int textBoxAbsoluteLeft = relativeObject.getAbsoluteLeft(); // Right-align the popup. Note that this computation is // valid in the case where offsetWidthDiff is negative. left = textBoxAbsoluteLeft - offsetWidthDiff; // If the suggestion popup is not as wide as the text box, always // align to the right edge of the text box. Otherwise, figure out // whether // to right-align or left-align the popup. if (offsetWidthDiff > 0) { // Make sure scrolling is taken into account, since // box.getAbsoluteLeft() takes scrolling into account. int windowRight = Window.getClientWidth() + Window.getScrollLeft(); int windowLeft = Window.getScrollLeft(); // Compute the left value for the right edge of the textbox int textBoxLeftValForRightEdge = textBoxAbsoluteLeft + textBoxOffsetWidth; // Distance from the right edge of the text box to the right // edge // of the window int distanceToWindowRight = windowRight - textBoxLeftValForRightEdge; // Distance from the right edge of the text box to the left edge // of the // window int distanceFromWindowLeft = textBoxLeftValForRightEdge - windowLeft; // If there is not enough space for the overflow of the popup's // width to the right of the text box and there IS enough space // for the // overflow to the right of the text box, then left-align the // popup. // However, if there is not enough space on either side, stick // with // right-alignment. if (distanceFromWindowLeft < offsetWidth && distanceToWindowRight >= offsetWidthDiff) { // Align with the left edge of the text box. left = textBoxAbsoluteLeft; } } } else { // LTR case // Left-align the popup. left = relativeObject.getAbsoluteLeft(); // If the suggestion popup is not as wide as the text box, always // align to // the left edge of the text box. Otherwise, figure out whether to // left-align or right-align the popup. if (offsetWidthDiff > 0) { // Make sure scrolling is taken into account, since // box.getAbsoluteLeft() takes scrolling into account. int windowRight = Window.getClientWidth() + Window.getScrollLeft(); int windowLeft = Window.getScrollLeft(); // Distance from the left edge of the text box to the right edge // of the window int distanceToWindowRight = windowRight - left; // Distance from the left edge of the text box to the left edge // of the // window int distanceFromWindowLeft = left - windowLeft; // If there is not enough space for the overflow of the popup's // width to the right of hte text box, and there IS enough space // for the // overflow to the left of the text box, then right-align the // popup. // However, if there is not enough space on either side, then // stick with // left-alignment. if (distanceToWindowRight < offsetWidth && distanceFromWindowLeft >= offsetWidthDiff) { // Align with the right edge of the text box. left -= offsetWidthDiff; } } } // Calculate top position for the popup int top = relativeObject.getAbsoluteTop(); // Make sure scrolling is taken into account, since // box.getAbsoluteTop() takes scrolling into account. int windowTop = Window.getScrollTop(); int windowBottom = Window.getScrollTop() + Window.getClientHeight(); // Distance from the top edge of the window to the top edge of the // text box int distanceFromWindowTop = top - windowTop; // Distance from the bottom edge of the window to the bottom edge of // the text box int distanceToWindowBottom = windowBottom - (top + relativeObject.getOffsetHeight()); // If there is not enough space for the popup's height below the text // box and there IS enough space for the popup's height above the text // box, then then position the popup above the text box. However, if // there // is not enough space on either side, then stick with displaying the // popup below the text box. if (distanceToWindowBottom < offsetHeight && distanceFromWindowTop >= offsetHeight) { top -= offsetHeight; } else { // Position above the text box top += relativeObject.getOffsetHeight(); } setPopupPosition(left, top); }
From source file:ch.sebastienzurfluh.swissmuseum.core.client.view.animations.ScrollToTheTop.java
License:Open Source License
private ScrollToTheTop() { origin = Window.getScrollTop(); }
From source file:ch.sebastienzurfluh.swissmuseum.core.client.view.eventbushooks.ScrollToPanelOnEvent.java
License:Open Source License
@Override public void notify(AbstractEvent e) { origin = Window.getScrollTop(); destination = panel.getElement().getAbsoluteTop(); run(400); }
From source file:ch.unifr.pai.twice.multipointer.client.MouseCursor.java
License:Apache License
/** * Reposition the mouse pointer to x and y coordinates * /* www. ja v a 2 s .c o m*/ * @param x * @param y */ private void move(int x, int y) { this.x = x; this.y = y; Element e = getElementFromPoint(x, y); int shrinkX = x + image.getOffsetWidth() - Window.getClientWidth() - Window.getScrollLeft(); int shrinkY = y + image.getOffsetHeight() - Window.getClientHeight() - Window.getScrollTop(); setWidth(Math.max(0, (image.getOffsetWidth() - (shrinkX > 0 ? shrinkX : 0))) + "px"); setHeight(Math.max(0, (image.getOffsetHeight() - (shrinkY > 0 ? shrinkY : 0))) + "px"); int clientX = x + Window.getScrollLeft(); int clientY = y + Window.getScrollTop(); if (!e.equals(oldElement)) { if (oldElement != null) fireMouseEvent("mouseout", uuid, color, oldElement, clientX, clientY); fireMouseEvent("mouseover", uuid, color, e, clientX, clientY); } fireMouseEvent("mousemove", uuid, color, e, clientX, clientY); oldElement = e; getElement().getStyle().setLeft(x, Unit.PX); getElement().getStyle().setTop(y, Unit.PX); if (storage != null) { storage.setItem("ch.unifr.pai.mice.multicursor.position." + fileName + ".x", String.valueOf(x)); storage.setItem("ch.unifr.pai.mice.multicursor.position." + fileName + ".y", String.valueOf(y)); } }
From source file:ch.unifr.pai.twice.multipointer.provider.client.MouseCursor.java
License:Apache License
/** * Reposition the mouse pointer to x and y coordinates * /* w ww .j a v a2 s . com*/ * @param event */ void move(RemoteMouseMoveEvent event) { genericEventHandling(event); this.x = event.x; this.y = event.y; Element e = getElementFromPoint(x, y); int shrinkX = x + image.getOffsetWidth() - Window.getClientWidth() - Window.getScrollLeft(); int shrinkY = y + image.getOffsetHeight() - Window.getClientHeight() - Window.getScrollTop(); setWidth(Math.max(0, (image.getOffsetWidth() - (shrinkX > 0 ? shrinkX : 0))) + "px"); setHeight(Math.max(0, (image.getOffsetHeight() - (shrinkY > 0 ? shrinkY : 0))) + "px"); int clientX = x + Window.getScrollLeft(); int clientY = y + Window.getScrollTop(); if (!e.equals(oldElement)) { if (oldElement != null) fireMouseEvent("mouseout", uuid, color, oldElement, clientX, clientY); fireMouseEvent("mouseover", uuid, color, e, clientX, clientY); } fireMouseEvent("mousemove", uuid, color, e, clientX, clientY); oldElement = e; getElement().getStyle().setLeft(x, Unit.PX); getElement().getStyle().setTop(y, Unit.PX); if (storage != null) { storage.setItem("ch.unifr.pai.mice.multicursor.position." + fileName + ".x", String.valueOf(x)); //old version mice storage.setItem("ch.unifr.pai.mice.multicursor.position." + fileName + ".y", String.valueOf(y)); //old version mice } show(); }