import "ecere" class SplitWindow : Window { bool sliding; int startPos, startX; background = activeBorder, borderStyle = bevel; anchor = { top = -2, bottom = -2 }, stayOnTop = true, inactive = true; size = { w = 6 }; cursor = ((GuiApplication)__thisModule).GetCursor(sizeWE); Window leftPane, rightPane; double scaleSplit; int split; bool scale; property double scaleSplit { set { scaleSplit = value; property::split = (int)(parent.clientSize.w * (value) + 0.5); scale = true; } } property int split { set { int w = size.w; int pw = parent.clientSize.w; int x = value; split = value; if(leftPane && !rightPane) leftPane.anchor.right = 0; else if(rightPane && !leftPane) rightPane.anchor.left = 0; else { if(leftPane) leftPane.anchor.right = pw - x; if(rightPane) rightPane.anchor.left = x + w / 2; } anchor.left = x; scale = false; } } void OnResize(int width, int height) { //if(visible) { if(scale) property::scaleSplit = scaleSplit; else property::split = split; } } bool OnLeftButtonDown(int x, int y, Modifiers mods) { sliding = true; startPos = x + absPosition.x; startX = position.x; Capture(); return true; } bool OnMouseLeave(Modifiers mods) { parent.cursor = null; return true; } bool OnMouseMove(int x, int y, Modifiers mods) { parent.cursor = cursor; if(sliding) { bool oldScale = scale; x += absPosition.x; x -= startPos; x += startX; x = Max(x, 20); x = Min(x, parent.clientSize.w - 20); property::split = x; scale = oldScale; } return true; } bool OnLeftButtonUp(int x, int y, Modifiers mods) { if(sliding) { ReleaseCapture(); parent.cursor = null; sliding = false; } return true; } }