mirror of https://github.com/buggins/dlangui.git
docks - layout priority support
This commit is contained in:
parent
7178d09630
commit
b65bc81dac
|
@ -190,6 +190,13 @@ class DockHost : WidgetGroupDefaultDrawing {
|
||||||
addChild(dockWin);
|
addChild(dockWin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DockWindow removeDockedWindow(string id) {
|
||||||
|
DockWindow res = childById!DockWindow(id);
|
||||||
|
if (res)
|
||||||
|
removeChild(id);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
protected int _resizeStartPos;
|
protected int _resizeStartPos;
|
||||||
void onResize(ResizerWidget source, ResizerEventType event, int newPosition) {
|
void onResize(ResizerWidget source, ResizerEventType event, int newPosition) {
|
||||||
layout(_pos);
|
layout(_pos);
|
||||||
|
@ -217,6 +224,13 @@ class DockHost : WidgetGroupDefaultDrawing {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected DockAlignment[4] _layoutPriority = [DockAlignment.Top, DockAlignment.Left, DockAlignment.Right, DockAlignment.Bottom];
|
||||||
|
@property DockAlignment[4] layoutPriority() { return _layoutPriority; }
|
||||||
|
@property void layoutPriority(DockAlignment[4] p) {
|
||||||
|
_layoutPriority = p;
|
||||||
|
requestLayout();
|
||||||
|
}
|
||||||
|
|
||||||
/// Set widget rectangle to specified value and layout widget contents. (Step 2 of two phase layout).
|
/// Set widget rectangle to specified value and layout widget contents. (Step 2 of two phase layout).
|
||||||
override void layout(Rect rc) {
|
override void layout(Rect rc) {
|
||||||
_needLayout = false;
|
_needLayout = false;
|
||||||
|
@ -226,14 +240,31 @@ class DockHost : WidgetGroupDefaultDrawing {
|
||||||
_pos = rc;
|
_pos = rc;
|
||||||
applyMargins(rc);
|
applyMargins(rc);
|
||||||
applyPadding(rc);
|
applyPadding(rc);
|
||||||
_topSpace.beforeLayout(rc, getDockedWindowList(DockAlignment.Top));
|
foreach(a; _layoutPriority) {
|
||||||
_leftSpace.beforeLayout(rc, getDockedWindowList(DockAlignment.Left));
|
if (a == DockAlignment.Top) _topSpace.beforeLayout(rc, getDockedWindowList(DockAlignment.Top));
|
||||||
_rightSpace.beforeLayout(rc, getDockedWindowList(DockAlignment.Right));
|
if (a == DockAlignment.Left) _leftSpace.beforeLayout(rc, getDockedWindowList(DockAlignment.Left));
|
||||||
_bottomSpace.beforeLayout(rc, getDockedWindowList(DockAlignment.Bottom));
|
if (a == DockAlignment.Right) _rightSpace.beforeLayout(rc, getDockedWindowList(DockAlignment.Right));
|
||||||
_topSpace.layout(Rect(rc.left + _leftSpace.space, rc.top, rc.right - _rightSpace.space, rc.top + _topSpace.space));
|
if (a == DockAlignment.Bottom) _bottomSpace.beforeLayout(rc, getDockedWindowList(DockAlignment.Bottom));
|
||||||
_bottomSpace.layout(Rect(rc.left + _leftSpace.space, rc.bottom - _bottomSpace.space, rc.right - _rightSpace.space, rc.bottom));
|
}
|
||||||
_leftSpace.layout(Rect(rc.left, rc.top, rc.left + _leftSpace.space, rc.bottom));
|
int topsp, bottomsp, leftsp, rightsp;
|
||||||
_rightSpace.layout(Rect(rc.right - _rightSpace.space, rc.top, rc.right, rc.bottom));
|
foreach(a; _layoutPriority) {
|
||||||
|
if (a == DockAlignment.Top) {
|
||||||
|
_topSpace.layout(Rect(rc.left + leftsp, rc.top, rc.right - rightsp, rc.top + _topSpace.space));
|
||||||
|
topsp = _topSpace.space;
|
||||||
|
}
|
||||||
|
if (a == DockAlignment.Bottom) {
|
||||||
|
_bottomSpace.layout(Rect(rc.left + leftsp, rc.bottom - _bottomSpace.space, rc.right - rightsp, rc.bottom));
|
||||||
|
bottomsp = _bottomSpace.space;
|
||||||
|
}
|
||||||
|
if (a == DockAlignment.Left) {
|
||||||
|
_leftSpace.layout(Rect(rc.left, rc.top + topsp, rc.left + _leftSpace.space, rc.bottom - bottomsp));
|
||||||
|
leftsp = _leftSpace.space;
|
||||||
|
}
|
||||||
|
if (a == DockAlignment.Right) {
|
||||||
|
_rightSpace.layout(Rect(rc.right - _rightSpace.space, rc.top + topsp, rc.right, rc.bottom - bottomsp));
|
||||||
|
rightsp = _rightSpace.space;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (_bodyWidget)
|
if (_bodyWidget)
|
||||||
_bodyWidget.layout(Rect(rc.left + _leftSpace.space, rc.top + _topSpace.space, rc.right - _rightSpace.space, rc.bottom - _bottomSpace.space));
|
_bodyWidget.layout(Rect(rc.left + _leftSpace.space, rc.top + _topSpace.space, rc.right - _rightSpace.space, rc.bottom - _bottomSpace.space));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue