Ejemplo n.º 1
0
Size DockWindow::CtrlBestSize(const Ctrl &c, bool restrict) const
{
	Size mn = c.GetMinSize();
	Size mx = c.GetMaxSize();
	Size std = c.GetStdSize();
	if (restrict)
		mx = minmax(GetSize()/2, mn, mx);
	return minmax(std, mn, mx);
}
Ejemplo n.º 2
0
int DockPane::GetMinPos(int notix)
{
	int n = 0;
	int msz = 0;
	for (Ctrl *c = GetFirstChild(); c; c = c->GetNext()) {
		if (n != notix) msz += ClientToPos(c->GetMinSize());
		n++;
	}
	return msz;
}
Ejemplo n.º 3
0
void DockPane::SmartRepos(int ix, int inc)
{
	int cnt = pos.GetCount();
	if (cnt == 1) {
		pos[0] = 10000;
		return;
	}

	for (int i = cnt-1; i > 0; i--)
		pos[i] -= pos[i-1];

	int n = 0;
	int msz = 0;
	int tsz = 0;
	Vector<int>minpos;
	minpos.SetCount(cnt);

	for (Ctrl *c = GetFirstChild(); c; c = c->GetNext()) {
		if (n != ix) {
			minpos[n] = min(ClientToPos(c->GetMinSize()), pos[n]);
			msz += minpos[n];
			tsz += pos[n];
		}
		n++;
	}
	int dif = tsz - inc - msz;
	tsz -= msz;

	pos[ix] += inc;
	if (tsz != 0 && dif != 0) {
		if (tsz <= 0) dif = -dif;
		int isz = pos[ix];
		for (int i = 0; i < cnt; i++) {
			if (i != ix)
				pos[i] = minpos[i] + (dif * (pos[i] - minpos[i])) / tsz;
		}
	}
	for (int i = 1; i < cnt; i++)
		pos[i] += pos[i-1];
}