Example #1
0
UIListCell *ComboBox::CellAtIndex(UIList *forList, int32 index)
{
    UIListCell *c = forList->GetReusableCell("Combo cell");
    if (!c) 
    {
        c = new UIListCell(Rect(0, 0, listWidth, size.y), "Combo cell");
    }
    ControlsFactory::CustomizeButton(c, StringToWString(items[index]));
    if (index == selectionIndex) 
    {
        c->SetSelected(true);
    }
    else 
    {
        c->SetSelected(false);
    }

    return c;
}
	UIListCell *EditorListDelegate::CellAtIndex(UIList *forList, int32 index)
	{
    	// Try to get cell from the reusable cells store
    	UIListCell *cell = forList->GetReusableCell("Cell");
		if (!cell)
		{
			cell = new UIListCell(Rect(0.0f, 0.0f, cellSize.x, cellSize.y), "Cell");
		}
		else
		{
			cell->SetSize(Vector2(cellSize.x, cellSize.y));
			// Reset reusable cells relative positions - new proper positions will be calculated at UIList::AddCellAtPost() method
			cell->SetPosition(Vector2(0.0f, 0.0f));
		}
	
		cell->RemoveAllControls();
		// Get aggregator control
		UIControl *aggregatorControl = GetCurrentAggregatorControl();
		if (aggregatorControl)
		{
			UIAggregatorControl* control = new UIAggregatorControl();
			control->CopyDataFrom(aggregatorControl);
			// DF-1770 - Reset aggregator's background draw type
			control->GetBackground()->SetDrawType(UIControlBackground::DRAW_ALIGNED);
			cell->AddControl(control);
            SafeRelease(control);
		}
		else
		{			
			cell->SetStateFont(UIControl::STATE_NORMAL, EditorFontManager::Instance()->GetDefaultFont());
			cell->SetStateText(UIControl::STATE_NORMAL, StringToWString(Format("Cell %d",index)));
			cell->SetSelected(true);
		}
   
    	return cell;
	}
UIListCell *MaterialEditor::CellAtIndex(UIList *forList, int32 index)
{
    UIListCell *c = forList->GetReusableCell("Material name cell");
    if (!c) 
    {
        c = new UIListCell(Rect(0, 0, forList->GetRect().dx, 20), "Material name cell");

        float32 boxSize = 16;
        float32 y = (CellHeight(forList, index) - boxSize) / 2;
        float32 x = forList->GetRect().dx - boxSize;
        
        
        //Temporary fix for loading of UI Interface to avoid reloading of texrures to different formates.
        // 1. Reset default format before loading of UI
        // 2. Restore default format after loading of UI from stored settings.
        Texture::SetDefaultFileFormat(NOT_FILE);
        
        Rect r = Rect(x, y, boxSize, boxSize);
        UIControl *sceneFlagBox = new UIControl(r);
        sceneFlagBox->SetName("flagBox");
        sceneFlagBox->GetBackground()->SetDrawType(UIControlBackground::DRAW_SCALE_TO_RECT);
        sceneFlagBox->SetSprite("~res:/Gfx/UI/marker", 1);
        sceneFlagBox->SetInputEnabled(false);
        c->AddControl(sceneFlagBox);
        SafeRelease(sceneFlagBox);
        
        Texture::SetDefaultFileFormat((ImageFileFormat)EditorSettings::Instance()->GetTextureViewFileFormat());
    }

    Material *mat = GetMaterial(index);
    bool found = false;
    if(EDM_ALL == displayMode)
    {
        for (int32 i = 0; i < (int32)workingNodeMaterials.size(); ++i)
        {
            if(workingNodeMaterials[i] == mat)
            {
                found = true;
                break;
            }
        }
    }
    else
    {
        found = true;
    }
    
    ControlsFactory::CustomizeListCell(c, StringToWString(mat->GetName()), false);
    UIControl *sceneFlagBox = c->FindByName("flagBox");
    sceneFlagBox->SetVisible(found, false);
    
    if (index == selectedMaterial) 
    {
        c->SetSelected(true, false);
        lastSelection = c;
    }
    else
    {
        c->SetSelected(false, false);
    }
    
    return c;
}