コード例 #1
0
	void EditorListDelegate::UpdateCellSize(UIList *forList)
	{		
		if (isElementsCountNeedUpdate && forList)
		{
			isElementsCountNeedUpdate = false;
			// Change cell size only if aggregator control is available
			UIControl *aggregatorControl = GetCurrentAggregatorControl();
			if (aggregatorControl)
			{
				Vector2 aggregatorSize = aggregatorControl->GetSize();
				SetCellSize(aggregatorSize);
			}
			
			Vector2 listSize = forList->GetSize();
			if(forList->GetOrientation() == UIList::ORIENTATION_HORIZONTAL)
			{
				DVASSERT(cellSize.x > 0);
				cellsCount =  ceilf( listSize.x / cellSize.x );
			}
			else
			{
				DVASSERT(cellSize.y > 0);
				cellsCount =  ceilf( listSize.y / cellSize.y );
			}
		}
	}
コード例 #2
0
void FormatsTest::LoadResources()
{
    GetBackground()->SetColor(Color(0.0f, 1.0f, 0.0f, 1.0f));

    int32 columnCount = 6;
    int32 rowCount = (FORMAT_COUNT-1) / columnCount;
    if(0 != FORMAT_COUNT % columnCount)
    {
        ++rowCount;
    }

    float32 size = Min(GetSize().x / columnCount, GetSize().y / rowCount);
    
    Font *font = FTFont::Create("~res:/Fonts/korinna.ttf");
    DVASSERT(font);
	font->SetSize(20);


    for(int32 i = FORMAT_RGBA8888; i < FORMAT_COUNT; ++i)
    {
        int32 y = (i-1) / columnCount;
        int32 x = (i-1) % columnCount;
        
        String formatName = Texture::GetPixelFormatString((PixelFormat)i);
        
        UIControl *c = new UIControl(Rect(x*size, y*size, size - 2, size - 2));
        c->SetSprite(Format("~res:/TestData/FormatTest/%s/number_0", formatName.c_str()), 0);
        c->GetBackground()->SetDrawType(UIControlBackground::DRAW_SCALE_TO_RECT);
        
        UIStaticText *text = new UIStaticText(Rect(0, c->GetSize().y - 30, c->GetSize().x, 30));

        text->SetText(StringToWString(formatName));
        text->SetFont(font);
        text->SetTextColor(Color(1.0f, 1.0f, 1.0f, 1.0f));

        
        c->AddControl(text);
        AddControl(c);

        SafeRelease(text);
        SafeRelease(c);
    }
    
    SafeRelease(font);
}