This repository has been archived on 2023-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
MyGameFramework/lib/gwen/controls/layout/gwen_tile.h
Gered c5cdddbeaa initial commit
current versions of all of my basic framework sources, build configurations/scripts, and supporting assets
2013-01-31 12:53:05 -05:00

66 lines
1.1 KiB
C++

/*
GWEN
Copyright (c) 2012 Facepunch Studios
See license in Gwen.h
*/
#pragma once
#ifndef GWEN_CONTROLS_LAYOUT_TILE_H
#define GWEN_CONTROLS_LAYOUT_TILE_H
#include "../gwen_base.h"
namespace Gwen
{
namespace Controls
{
namespace Layout
{
class GWEN_EXPORT Tile : public Base
{
public:
GWEN_CONTROL_INLINE( Tile, Base )
{
Dock( Pos::Fill );
SetTileSize( 22, 22 );
}
void PostLayout( Skin::Base* skin )
{
Gwen::Rect bounds = GetInnerBounds();
Gwen::Point pos = Point( bounds.x, bounds.y );
for ( Base::List::iterator it = Children.begin(); it != Children.end(); ++it )
{
Base* pChild = *it;
if ( pChild->GetDock() != Pos::None ) continue;
pChild->SetPos( pos.x + (m_TileSize.x/2) - (pChild->Width()/2), pos.y + (m_TileSize.y/2) - (pChild->Height()/2) );
pos.x = pos.x + m_TileSize.x;
if ( pos.x + m_TileSize.x > bounds.x + bounds.w )
{
pos.x = bounds.x;
pos.y += m_TileSize.y;
}
}
}
void SetTileSize( int x, int y )
{
m_TileSize = Point( x, y );
}
private:
Point m_TileSize;
};
}
}
}
#endif