Inheritance: ILayout
Ejemplo n.º 1
0
			public override float get( Element context )
			{
				if( context is ILayout )
					return ( (ILayout)context ).preferredWidth;
				return context == null ? 0 : context.width;

			}
Ejemplo n.º 2
0
		public ScrollPane( Element widget, ScrollPaneStyle style )
		{
			Assert.isNotNull( style, "style cannot be null" );
			transform = true;
			_style = style;
			setWidget( widget );
			setSize( 150, 150 );
		}
Ejemplo n.º 3
0
		public SplitPane( Element firstWidget, Element secondWidget, SplitPaneStyle style, bool vertical = false )
		{
			setStyle( style );
			setFirstWidget( firstWidget );
			setSecondWidget( secondWidget );

			_vertical = vertical;
			setSize( preferredWidth, preferredHeight );
		}
Ejemplo n.º 4
0
			public override float get( Element context )
			{
				return value;
			}
Ejemplo n.º 5
0
			public override float get( Element element )
			{
				return delegateElement.height * percent;
			}
Ejemplo n.º 6
0
		/// <summary>
		/// Returns a value that is a percentage of the specified elements's height. The context element is ignored.
		/// </summary>
		static public Value percentHeight( float percent, Element delegateElement )
		{
			return new PercentHeightDelegateValue() {
				delegateElement = delegateElement,
				percent = percent
			};
		}
Ejemplo n.º 7
0
		public SplitPane setFirstWidget( Element firstWidget )
		{
			if( _firstWidget != null )
				removeElement( _firstWidget );

			_firstWidget = firstWidget;
			if( _firstWidget != null )
				addElement( _firstWidget );
			invalidate();

			return this;
		}
Ejemplo n.º 8
0
		public ScrollPane( Element widget, Skin skin, string styleName ) : this( widget, skin.get<ScrollPaneStyle>( styleName ) )
		{ }
Ejemplo n.º 9
0
		public ScrollPane( Element widget ) : this( widget, new ScrollPaneStyle() )
		{ }
Ejemplo n.º 10
0
		public override bool removeElement( Element element )
		{
			if( !base.removeElement( element ) )
				return false;
			
			var cell = getCell( element );
			if( cell != null )
				cell.element = null;
			return true;
		}
Ejemplo n.º 11
0
		/// <summary>
		/// Adds a new cell to the table with the specified element.
		/// </summary>
		/// <param name="element">element.</param>
		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;
		}
Ejemplo n.º 12
0
			public override float get( Element context )
			{
				var background = ( (Table)context )._background;
				return background == null ? 0 : background.rightWidth;
			}
Ejemplo n.º 13
0
			public override float get( Element context )
			{
				var background = ( (Table)context )._background;
				return background == null ? 0 : background.bottomHeight;
			}
Ejemplo n.º 14
0
		public SplitPane( Element firstWidget, Element secondWidget, IDrawable handle, bool vertical = false ) : this( firstWidget, secondWidget, new SplitPaneStyle( handle ), vertical )
		{}
Ejemplo n.º 15
0
		public SplitPane setSecondWidget( Element secondWidget )
		{
			if( _secondWidget != null )
				removeElement( _secondWidget );

			_secondWidget = secondWidget;
			if( _secondWidget != null )
				addElement( _secondWidget );
			invalidate();

			return this;
		}
Ejemplo n.º 16
0
			public override float get( Element context )
			{
				if( context is ILayout )
					return ( (ILayout)context ).preferredHeight;
				return context == null ? 0 : context.height;
			}
Ejemplo n.º 17
0
		/// <summary>
		/// Sets the {@link Element} embedded in this scroll pane
		/// </summary>
		/// <returns>The widget.</returns>
		/// <param name="widget">Widget.</param>
		public ScrollPane setWidget( Element widget )
		{
			if( _widget != null ) removeElement( _widget );
			_widget = widget;
			if( widget != null ) addElement( widget );

			return this;
		}
Ejemplo n.º 18
0
		/// <summary>
		/// Returns the cell for the specified element in this table, or null.
		/// </summary>
		/// <returns>The cell.</returns>
		/// <param name="element">element.</param>
		public Cell getCell( Element element )
		{
			for( int i = 0, n = _cells.Count; i < n; i++ )
			{
				var c = _cells[i];
				if( c.element == element )
					return c;
			}
			return null;
		}
Ejemplo n.º 19
0
		public ScrollPane( Element widget, Skin skin ) : this( widget, skin.get<ScrollPaneStyle>() )
		{ }
Ejemplo n.º 20
0
		/// <summary>
		/// context May be null
		/// </summary>
		/// <param name="context">Context.</param>
		abstract public float get( Element context );
Ejemplo n.º 21
0
			public override float get( Element element )
			{
				return delegateElement.width * percent;
			}
Ejemplo n.º 22
0
 /// <summary>
 /// Converts coordinates for this element to those of a parent element. The ascendant does not need to be a direct parent
 /// </summary>
 /// <returns>The to ascendant coordinates.</returns>
 /// <param name="ascendant">Ascendant.</param>
 /// <param name="localCoords">Local coords.</param>
 public Vector2 localToAscendantCoordinates( Element ascendant, Vector2 localCoords )
 {
     Element element = this;
     while( element != null )
     {
         localCoords = element.localToParentCoordinates( localCoords );
         element = element.parent;
         if( element == ascendant )
             break;
     }
     return localCoords;
 }