示例#1
0
void Grid::Arrange(const Rect finalRect) {
    Cell* cell;
    Control* el;

    for (Grid::CellData& d : els) {
        cell = GetCell(d.row, d.col);
        el = d.el;
        Point pos(GetCellPos(d.row, d.col));
        int elDx = el->DesiredSize().Width;
        int containerDx = 0;
        for (int i = d.col; i < d.col + d.colSpan; i++) {
            containerDx += maxColWidth[i];
        }

        int xOff = d.horizAlign.CalcOffset(elDx, containerDx);
        pos.X += xOff;
        int elDy = el->DesiredSize().Height;
        int containerDy = maxRowHeight[d.row];
        int yOff = d.vertAlign.CalcOffset(elDy, containerDy);
        pos.Y += yOff;
        Rect r(pos, cell->desiredSize);
        el->Arrange(r);
    }
    SetPosition(finalRect);
}
示例#2
0
	void TileMap::CreateTiles()
	{
		Rect TempTagetRect;

		for (int CurrFrame = 0; CurrFrame < m_FrameCount; ++CurrFrame)
		{
			GetCellPos(CurrFrame, &TempTagetRect);

			Rect *tempRect = new Rect;
			tempRect->SetRect(TempTagetRect.left, TempTagetRect.top, TempTagetRect.right, TempTagetRect.bottom);
			m_TileSet.push_back(tempRect);
		}
	}
示例#3
0
Rect Grid::GetCellBbox(Grid::CellData* d) {
    Rect r;
    // TODO: probably add Grid's border to X
    Point p(GetCellPos(d->row, d->col));
    r.X = p.X;
    r.Y = p.Y;
    r.Height = maxRowHeight[d->row];
    int totalDx = 0;
    for (int i = d->col; i < d->col + d->colSpan; i++) {
        totalDx += maxColWidth[i];
    }
    r.Width = totalDx;
    return r;
}