void TileGrid2D::Resize(Vector2i newSize) { std::cout<<"\nTileGrid2D::Resize"; Deallocate(); size = newSize; /// Space in X between the columns, use for creating hexagonal grids, since the distance between each tile should always be 1.0 if possible. float spaceX = 0; /// Offset in Y, used for creating hexagonal grids. Vector2f eachOtherRowOffset; Vector2f rowSpacing(1,1); if (gridType == GridType::HEXAGONS) { eachOtherRowOffset = Vector2f(0.5f, 0); rowSpacing = Vector2f(1, 0.86602540378f); } for (int y = 0; y < size[1]; ++y) { List<Tile*> * list = new List<Tile*>(); for (int x = 0; x < size[0]; ++x) { Tile * tile = new Tile(); tile->position = rowSpacing.ElementMultiplication(Vector2f(x,y)); if (y % 2 == 0) tile->position += eachOtherRowOffset; list->Add(tile); } tiles.Add(list); } }
int MSLayout::idealHeight(void) const { int offset=highlightThickness()+shadowThickness()+margin(); return (vectorHeight()+innerHeight()+(rows()-1)*rowSpacing()+2*offset); }
int MSLayout::realHeight(void) const { int offset=highlightThickness()+shadowThickness()+margin(); return (height()-innerHeight()-(rows()-1)*rowSpacing()-2*offset); }