Nez.UI.Table.add C# (CSharp) Method

add() public method

Adds a new cell to the table with the specified element.
public add ( Element element ) : Cell
element Element element.
return Cell
		public Cell add( Element element )
		{
			var cell = obtainCell();
			cell.element = element;

			// the row was ended for layout, not by the user, so revert it.
			if( _implicitEndRow )
			{
				_implicitEndRow = false;
				_rows--;
				_cells.Last().endRow = false;
			}
				
			var cellCount = _cells.Count;
			if( cellCount > 0 )
			{
				// Set cell column and row.
				var lastCell = _cells.Last();
				if( !lastCell.endRow )
				{
					cell.column = lastCell.column + lastCell.colspan.Value;
					cell.row = lastCell.row;
				}
				else
				{
					cell.column = 0;
					cell.row = lastCell.row + 1;
				}

				// set the index of the cell above.
				if( cell.row > 0 )
				{
					for( var i = cellCount - 1; i >= 0; i-- )
					{
						var other = _cells[i];
						for( int column = other.column, nn = column + other.colspan.Value; column < nn; column++ )
						{
							if( column == cell.column )
							{
								cell.cellAboveIndex = i;
								goto outer;
							}
						}
					}
					outer:
					{}
				}
			}
			else
			{
				cell.column = 0;
				cell.row = 0;
			}
			_cells.Add( cell );

			cell.set( _cellDefaults );
			if( cell.column < _columnDefaults.Count )
			{
				var columnCell = _columnDefaults[cell.column];
				if( columnCell != null )
					cell.merge( columnCell );
			}
			cell.merge( _rowDefaults );

			if( element != null )
				addElement( element );

			return cell;
		}

Same methods

Table::add ( ) : Cell
Table::add ( string text ) : Cell

Usage Example

コード例 #1
0
ファイル: InspectorList.cs プロジェクト: RastaCow/Nez
		public void initialize( Table table, Skin skin )
		{
			table.getRowDefaults().setPadTop( 10 );
			table.add( name.Replace( "PostProcessor", string.Empty ) ).getElement<Label>().setFontScale( 1f ).setFontColor( new Color( 241, 156, 0 ) );

			// if we have a component, stick a bool for enabled here
			if( target != null )
			{
				_enabledCheckbox = new CheckBox( string.Empty, skin );
				_enabledCheckbox.programmaticChangeEvents = false;

				if( target is Component )
					_enabledCheckbox.isChecked = ( (Component)target ).enabled;
				else if( target is PostProcessor )
					_enabledCheckbox.isChecked = ((PostProcessor)target ).enabled;
				
				_enabledCheckbox.onChanged += newValue =>
				{
					if( target is Component )
						((Component)target).enabled = newValue;
					else if( target is PostProcessor )
						( (PostProcessor)target ).enabled = newValue;
				};

				table.add( _enabledCheckbox ).right();
			}
			table.row();

			foreach( var i in _inspectors )
			{
				i.initialize( table, skin );
				table.row();
			}
		}
All Usage Examples Of Nez.UI.Table::add