using System;
using System.Collections.Generic;
using System.Text;
using Vortex.Drawing;

namespace Vortex.SceneFramework.Gui {
	/// <summary>
	/// Progress bar is display only widget for drawing progress of some operations
	/// </summary>
	public class ProgressBar : RangeWidget {

		#region Drawing Progress Bar

		/// <summary>
		/// Draws the progress bar based on styles
		/// </summary>
		/// <param name="canvas">The canvas to use for progress bar drawing.</param>
		protected override void Draw(Canvas2D canvas) {
			Rect bounds = BoundingBox;
			//first, draw background (it extends for all widget size)			
			DrawBackground(canvas, bounds);
			
			//second one, determine a deflate rect for foreground part
			Rect defRect = new Rect();
			if (Orientation == Orientation.Horizontal) {
				float offset = (1 - ValueRatio) * bounds.Width;
				if (IsReversed) {
					defRect.Left = offset;
				} else {
					defRect.Right = offset;
				}
			} else {
				float offset = (1 - ValueRatio) * bounds.Height;
				if (IsReversed) {
					defRect.Top = offset;
				} else {
					defRect.Bottom = offset;
				}
			}

			//draw forground
			DrawForeground(canvas, bounds.Deflate(defRect));
		}

		#endregion

	}
}
