protected void adjustWeights(List<SashRect> sashes, int curX, int curY) { for (SashRect sr : sashes) { int totalWeight = getWeight(sr.left) + getWeight(sr.right); int minSashValue = (int) (((totalWeight / 100.0) * minSashPercent) + 0.5); Rectangle leftRect = getRectangle(sr.left); Rectangle rightRect = getRectangle(sr.right); if (leftRect == null || rightRect == null) continue; setWeight(sr.left, leftWeight); setWeight(sr.right, rightWeight);
public void mouseDown(MouseEvent e) { if (e.button != 1) return; sashesToDrag = getSashRects(e.x, e.y); if (sashesToDrag.size() > 0) { draggingSashes = true; host.setCapture(true); } }
@Override protected void layout(Composite composite, boolean flushCache) { if (root == null) return; Rectangle bounds = composite.getBounds(); if (composite instanceof Shell) bounds = ((Shell) composite).getClientArea(); else { bounds.x = 0; bounds.y = 0; } bounds.width -= (marginLeft + marginRight); bounds.height -= (marginTop + marginBottom); bounds.x += marginLeft; bounds.y += marginTop; sashes.clear(); tileSubNodes(bounds, root); }
private void tileSubNodes(Rectangle bounds, MUIElement node) { if (node != root) setRectangle(node, bounds); List<MUIElement> visibleChildren = getVisibleChildren(sashContainer); int childCount = visibleChildren.size(); double totalWeight = totalWeight(sashContainer); int tilePos = sashContainer.isHorizontal() ? bounds.x : bounds.y; double ratio = getWeight(subNode) / totalWeight; int newSize = (int) ((availableWidth * ratio) + 0.5); tilePos += newSize; tileSubNodes(subBounds, subNode); prev = subNode;
public void mouseMove(MouseEvent e) { if (!draggingSashes) { // Set the cursor feedback List<SashRect> sashList = getSashRects(e.x, e.y); if (sashList.size() == 0) { host.setCursor(host.getDisplay().getSystemCursor( SWT.CURSOR_ARROW)); } else if (sashList.size() == 1) { if (sashList.get(0).container.isHorizontal()) host.setCursor(host.getDisplay().getSystemCursor( SWT.CURSOR_SIZEWE)); else host.setCursor(host.getDisplay().getSystemCursor( SWT.CURSOR_SIZENS)); } else { host.setCursor(host.getDisplay().getSystemCursor( SWT.CURSOR_SIZEALL)); } } else { adjustWeights(sashesToDrag, e.x, e.y); host.layout(); host.update(); } } });
sashComposite.setLayout(new SashLayout(sashComposite, element));
private int totalWeight(MGenericTile<?> node) { int total = 0; for (MUIElement subNode : node.getChildren()) { if (subNode.isToBeRendered() && subNode.isVisible()) total += getWeight(subNode); } return total; }
private void tileSubNodes(Rectangle bounds, MUIElement node) { if (node != root) setRectangle(node, bounds); List<MUIElement> visibleChildren = getVisibleChildren(sashContainer); int childCount = visibleChildren.size(); double totalWeight = totalWeight(sashContainer); int tilePos = sashContainer.isHorizontal() ? bounds.x : bounds.y; double ratio = getWeight(subNode) / totalWeight; int newSize = (int) ((availableWidth * ratio) + 0.5); tilePos += newSize; tileSubNodes(subBounds, subNode); prev = subNode;
if (!draggingSashes) { List<SashRect> sashList = getSashRects(e.x, e.y); if (sashList.isEmpty()) { host.setCursor(host.getDisplay().getSystemCursor(SWT.CURSOR_ARROW)); try { layoutUpdateInProgress = true; adjustWeights(sashesToDrag, e.x, e.y); try { host.setRedraw(false);
Object tmp = theChild.getWidget(); theChild.setWidget(theComp); theComp.setLayout(new SashLayout(theComp, theChild)); theComp.setData(AbstractPartRenderer.OWNING_ME, theChild); container.setWidget(tmp);
private int totalWeight(MGenericTile<?> node) { int total = 0; for (MUIElement subNode : node.getChildren()) { if (subNode.isToBeRendered() && subNode.isVisible()) total += getWeight(subNode); } return total; }
protected void adjustWeights(List<SashRect> sashes, int curX, int curY) { for (SashRect sr : sashes) { int totalWeight = getWeight(sr.left) + getWeight(sr.right); int minSashValue = (int) (((totalWeight / 100.0) * minSashPercent) + 0.5); Rectangle leftRect = getRectangle(sr.left); Rectangle rightRect = getRectangle(sr.right); if (leftRect == null || rightRect == null) continue; setWeight(sr.left, leftWeight); setWeight(sr.right, rightWeight);
sashComposite = new Composite((Composite) parent, SWT.NONE); sashComposite.setLayout(new SashLayout(sashComposite, element));
@Override public void mouseDown(MouseEvent e) { if (e.button != 1) { return; } sashesToDrag = getSashRects(e.x, e.y); if (sashesToDrag.size() > 0) { draggingSashes = true; host.setCapture(true); } } });
@Override protected void layout(Composite composite, boolean flushCache) { if (root == null) return; Rectangle bounds = composite.getBounds(); if (composite instanceof Shell) bounds = ((Shell) composite).getClientArea(); else { bounds.x = 0; bounds.y = 0; } bounds.width -= (marginLeft + marginRight); bounds.height -= (marginTop + marginBottom); bounds.x += marginLeft; bounds.y += marginTop; sashes.clear(); tileSubNodes(bounds, root); }