private void commitPosition(int pos) { lastElementX_ = pos; // check to see if we're overlapping with another tab for (int i = 0; i < dragTabsHost_.getChildCount(); i++) { // skip non-element DOM nodes Node node = dragTabsHost_.getChild(i); if (node.getNodeType() != Node.ELEMENT_NODE) { continue; } // skip the current candidate (no point in testing it for swap) if (i == candidatePos_) { continue; } // skip the element we're dragging and elements that are not tabs Element ele = (Element) node; if (ele == dragElement_ || ele.getClassName().indexOf("gwt-TabLayoutPanelTab") < 0) { continue; } int left = DomUtils.leftRelativeTo(dragTabsHost_, ele); int right = left + ele.getClientWidth(); int minOverlap = Math.min(initDragWidth_ / 2, ele.getClientWidth() / 2); // a little complicated: compute the number of overlapping pixels // with this element; if the overlap is more than half of our width // (or the width of the candidate), it's swapping time if (Math.min(lastElementX_ + initDragWidth_, right) - Math.max(lastElementX_, left) >= minOverlap) { dragTabsHost_.removeChild(dragPlaceholder_); if (candidatePos_ > i) { dragTabsHost_.insertBefore(dragPlaceholder_, ele); } else { dragTabsHost_.insertAfter(dragPlaceholder_, ele); } candidatePos_ = i; // account for the extra element when moving to the right of the // original location if (dragElement_ != null && startPos_ != null) { destPos_ = startPos_ <= candidatePos_ ? candidatePos_ - 1 : candidatePos_; } else { destPos_ = candidatePos_; } } } }
public void resize(int durationMilli, int newWidth) { this.newWidth = newWidth; this.initWidth = element.getClientWidth(); cancel(); currentOp = IabakoAnimation.RESIZE; run(durationMilli); }
/** * Send new dimensions to the server. * * <p>For internal use only. May be removed or replaced in the future. */ public void sendClientResized() { Profiler.enter("VUI.sendClientResized"); Element parentElement = getElement().getParentElement(); int viewHeight = parentElement.getClientHeight(); int viewWidth = parentElement.getClientWidth(); ResizeEvent.fire(this, viewWidth, viewHeight); Profiler.leave("VUI.sendClientResized"); }
private int computeNewValue(DragEvent e) { Element ele = getElement(); int offset = (int) e.X - ele.getAbsoluteLeft(); int width = ele.getClientWidth(); int value = offset * 100 / width; if (value > 100) { value = 100; } else if (value < 0) { value = 0; } return value; }
/** * Called when the window or parent div might have been resized. * * <p>This immediately checks the sizes of the window and the parent div (if monitoring it) and * triggers layout recalculation if they have changed. * * @param newWindowWidth The new width of the window * @param newWindowHeight The new height of the window * @deprecated use {@link #performSizeCheck()} */ @Deprecated protected void windowSizeMaybeChanged(int newWindowWidth, int newWindowHeight) { if (connection == null) { // Connection is null if the timer fires before the first UIDL // update return; } boolean changed = false; ComponentConnector connector = ConnectorMap.get(connection).getConnector(this); if (windowWidth != newWindowWidth) { windowWidth = newWindowWidth; changed = true; connector.getLayoutManager().reportOuterWidth(connector, newWindowWidth); VConsole.log("New window width: " + windowWidth); } if (windowHeight != newWindowHeight) { windowHeight = newWindowHeight; changed = true; connector.getLayoutManager().reportOuterHeight(connector, newWindowHeight); VConsole.log("New window height: " + windowHeight); } Element parentElement = getElement().getParentElement(); if (isMonitoringParentSize() && parentElement != null) { // check also for parent size changes int newParentWidth = parentElement.getClientWidth(); int newParentHeight = parentElement.getClientHeight(); if (parentWidth != newParentWidth) { parentWidth = newParentWidth; changed = true; VConsole.log("New parent width: " + parentWidth); } if (parentHeight != newParentHeight) { parentHeight = newParentHeight; changed = true; VConsole.log("New parent height: " + parentHeight); } } if (changed) { /* * If the window size has changed, layout the VView again and send * new size to the server if the size changed. (Just checking VView * size would cause us to ignore cases when a relatively sized VView * should shrink as the content's size is fixed and would thus not * automatically shrink.) */ VConsole.log("Running layout functions due to window or parent resize"); // update size to avoid (most) redundant re-layout passes // there can still be an extra layout recalculation if webkit // overflow fix updates the size in a deferred block if (isMonitoringParentSize() && parentElement != null) { parentWidth = parentElement.getClientWidth(); parentHeight = parentElement.getClientHeight(); } sendClientResized(); LayoutManager layoutManager = connector.getLayoutManager(); if (layoutManager.isLayoutRunning()) { layoutManager.layoutLater(); } else { layoutManager.layoutNow(); } } }