3 define defaultToolSize = 6;
5 public class PaneSplitter : Window
9 background = formColor, borderStyle = bevel;
10 anchor = { top = -2, bottom = -2 }, stayOnTop = true, inactive = true;
11 size = { w = defaultToolSize };
12 cursor = ((GuiApplication)__thisModule.application).GetCursor(sizeWE);
14 Window leftPane, rightPane;
18 ScrollDirection orientation;
19 int toolSize, toolGap;
21 orientation = (ScrollDirection)-1;
22 toolSize = defaultToolSize;
25 void OnResize(int width, int height)
27 if(leftPane || rightPane)
29 if(orientation == (ScrollDirection)-1) orientation = vertical;
31 property::scaleSplit = scaleSplit;
33 property::split = split;
37 bool OnLeftButtonDown(int x, int y, Modifiers mods)
40 if(orientation == vertical)
42 startPos = x + absPosition.x;
47 startPos = y + absPosition.y;
55 bool OnMouseLeave(Modifiers mods)
60 bool OnMouseMove(int x, int y, Modifiers mods)
62 parent.cursor = cursor;
65 bool oldScale = scale;
67 if(orientation == vertical)
72 x = Max(x, leftPane ? leftPane.minClientSize.w : 20);
73 x = Min(x, parent.clientSize.w - (rightPane ? rightPane.minClientSize.w : 20) - toolGap - toolSize);
77 scaleSplit = (double) x / (double) parent.clientSize.w;
84 y = Max(y, leftPane ? leftPane.minClientSize.h : 20);
85 y = Min(y, parent.clientSize.h - (rightPane ? rightPane.minClientSize.h : 20) - toolGap - toolSize);
89 scaleSplit = (double) y / (double)parent.clientSize.h;
92 NotifyResized(master, this);
97 bool OnLeftButtonUp(int x, int y, Modifiers mods)
102 parent.cursor = null;
104 NotifyResized(master, this);
110 property int toolSize
112 set { toolSize = value; } get { return toolSize; }
116 set { toolGap = value; } get { return toolGap; }
118 property Window leftPane
120 set { leftPane = value; property::split = split; } get { return leftPane; }
122 property Window rightPane
124 set { rightPane = value; property::split = split; } get { return rightPane; }
126 property Window topPane
128 set { leftPane = value; property::split = split; } get { return leftPane; }
130 property Window bottomPane
132 set { rightPane = value; property::split = split; } get { return rightPane; }
134 property double scaleSplit
139 property::split = (int)(((orientation == vertical) ? parent.clientSize.w : parent.clientSize.h) * (value) + 0.5);
142 get { return scaleSplit; }
144 property ScrollDirection orientation
149 if(orientation == vertical)
151 size = { w = toolSize };
152 anchor = { top = -2, bottom = -2 };
153 cursor = ((GuiApplication)__thisModule.application).GetCursor(sizeWE);
158 size = { h = toolSize };
159 anchor = { left = -2, right = -2 };
160 cursor = ((GuiApplication)__thisModule.application).GetCursor(sizeNS);
163 get { return orientation; }
170 if(orientation == vertical)
173 int pw = parent.clientSize.w;
175 x = Max(x, leftPane ? leftPane.minClientSize.w : 20);
176 x = Min(x, parent.clientSize.w - (rightPane ? rightPane.minClientSize.w : 20) - toolGap - toolSize);
178 if(leftPane) leftPane.anchor.right = pw - x + toolGap;
179 if(rightPane) rightPane.anchor.left = x + w + toolGap;
184 else if(orientation == horizontal)
187 int ph = parent.clientSize.h;
189 y = Max(y, leftPane ? leftPane.minClientSize.h : 20);
190 y = Min(y, parent.clientSize.h - (rightPane ? rightPane.minClientSize.h : 20) - toolGap - toolSize);
192 if(leftPane) leftPane.anchor.bottom = ph - y + toolGap;
193 if(rightPane) rightPane.anchor.top = y + h + toolGap;
199 get { return split; }
202 virtual bool Window::NotifyResized(PaneSplitter splitter);