public void init(HorizontalSplitPanel panel) { this.panel = panel; DOM.setStyleAttribute(panel.getElement(), "position", "relative"); expandToFitParentHorizontally(panel.getElement(LEFT)); expandToFitParentHorizontally(panel.getElement(RIGHT)); expandToFitParentHorizontally(panel.getSplitElement()); expandToFitParentUsingCssOffsets(panel.container); // Right now, both panes are stacked on top of each other // on either the left side or the right side of the containing // panel. This happens because both panes have position:absolute // and no left/top values. The panes will be on the left side // if the directionality is LTR, and on the right side if the // directionality is RTL. In the LTR case, we need to snap the // right pane to the right of the container, and in the RTL case, // we need to snap the left pane to the left of the container. if (LocaleInfo.getCurrentLocale().isRTL()) { setLeft(panel.getElement(LEFT), "0px"); } else { setRight(panel.getElement(RIGHT), "0px"); } }
@Override public void init(HorizontalSplitPanel panel) { this.panel = panel; final String fullSize = "100%"; super.init(panel); setHeight(panel.container, fullSize); setHeight(panel.getElement(LEFT), fullSize); setHeight(panel.getElement(RIGHT), fullSize); setHeight(panel.getSplitElement(), fullSize); }
/** * Set the splitter's position in units of pixels. * * <p>px represents the splitter's position as a distance of px pixels from the left edge of the * container. This is true even in a bidi environment. Callers of this method must be aware of * this constraint. */ public void setSplitPositionUsingPixels(int px) { final Element splitElem = panel.getSplitElement(); final int rootElemWidth = getOffsetWidth(panel.container); final int splitElemWidth = getOffsetWidth(splitElem); // This represents an invalid state where layout is incomplete. This // typically happens before DOM attachment, but I leave it here as a // precaution because negative width/height style attributes produce // errors on IE. if (rootElemWidth < splitElemWidth) { return; } // Compute the new right side width. int newRightWidth = rootElemWidth - px - splitElemWidth; // Constrain the dragging to the physical size of the panel. if (px < 0) { px = 0; newRightWidth = rootElemWidth - splitElemWidth; } else if (newRightWidth < 0) { px = rootElemWidth - splitElemWidth; newRightWidth = 0; } final Element rightElem = panel.getElement(RIGHT); // Set the width of the left side. setWidth(panel.getElement(LEFT), px + "px"); // Move the splitter to the right edge of the left element. setLeft(splitElem, px + "px"); // Move the right element to the right of the splitter. setLeft(rightElem, (px + splitElemWidth) + "px"); updateRightWidth(rightElem, newRightWidth); }
@Override public void init(HorizontalSplitPanel panel) { this.panel = panel; final Element elem = panel.getElement(); // Prevents inherited text-align settings from interfering with the // panel's layout. The setting we choose must be bidi-sensitive, // as left-alignment is the default with LTR directionality, and // right-alignment is the default with RTL directionality. if (LocaleInfo.getCurrentLocale().isRTL()) { elem.getStyle().setTextAlign(TextAlign.RIGHT); } else { elem.getStyle().setTextAlign(TextAlign.LEFT); } DOM.setStyleAttribute(elem, "position", "relative"); /* * Technically, these are snapped to the top and bottom, but IE doesn't * provide a reliable way to make that happen, so a resize listener is * wired up to control the height of these elements. */ addAbsolutePositoning(panel.getElement(LEFT)); addAbsolutePositoning(panel.getElement(RIGHT)); addAbsolutePositoning(panel.getSplitElement()); expandToFitParentUsingPercentages(panel.container); if (LocaleInfo.getCurrentLocale().isRTL()) { // Snap the left pane to the left edge of the container. We // only need to do this when layout is RTL; if we don't, the // left pane will overlap the right pane. setLeft(panel.getElement(LEFT), "0px"); } }
public void setSplitPosition(String pos) { final Element leftElem = panel.getElement(LEFT); setWidth(leftElem, pos); setSplitPositionUsingPixels(getOffsetWidth(leftElem)); }