// ------------------------------------------------------------------------
/*
	\author: Jaap Suter
   
	Copyright (C) Electronic Arts Canada Inc. 2002.  All rights reserved.	
*/
// ------------------------------------------------------------------------

/*! \file */

#include "reveal/impl/gui_metrics.h"
#include "reveal/reveal.h"

namespace Reveal {
	namespace Impl {

// ------------------------------------------------------------------------

int  GuiMetrics::BAR_HEIGHT;

int  GuiMetrics::ROW_HEIGHT_;
int  GuiMetrics::CHAR_WIDTH_;
int  GuiMetrics::ITEM_SIZE_;
int  GuiMetrics::ARROW_BOX_SIZE_;
int  GuiMetrics::SLIDER_SIZE_;
int  GuiMetrics::WIDGET_WIDTH_;

int  GuiMetrics::COLOR_NUMBER_WIDTH;

int  GuiMetrics::PAUSE_ITEM_SIZE;
int  GuiMetrics::PAUSE_BUTTON_X;
int  GuiMetrics::PAUSE_BUTTON_Y;

int  GuiMetrics::AUX_BUTTON_HEIGHT;
int  GuiMetrics::AUX_BUTTON_WIDTH;
int  GuiMetrics::AUX_BUTTON_SPACING;
int  GuiMetrics::AUX_BUTTON_RIGHT_MOST_X;
int  GuiMetrics::AUX_BUTTON_Y;

int  GuiMetrics::MRU_FORWARD_LOCK_X;
int  GuiMetrics::MRU_FORWARD_LOCK_Y;

int GuiMetrics::TEXT_HEIGHT;

GuiMetrics::MetricVariables * GuiMetrics::GetMetricVariables( MetricVariables * v )
{
	v->mCharWidth   = CHAR_WIDTH_;
	v->mTextHeight  = TEXT_HEIGHT;
	return v;
}

void GuiMetrics::SetMetricVariables( MetricVariables const& v )
{
	static const int WIDGET_WIDTH_IN_CHARACTERS = 18;

	CHAR_WIDTH_              = v.mCharWidth;
	TEXT_HEIGHT             = v.mTextHeight;

	WIDGET_WIDTH_            = CHAR_WIDTH_ * WIDGET_WIDTH_IN_CHARACTERS + 2 * BORDER_WIDTH; 
	ROW_HEIGHT_              = TEXT_HEIGHT + 2 * BORDER_HEIGHT;

	BAR_HEIGHT	            = ROW_HEIGHT_;

	ITEM_SIZE_		        = ROW_HEIGHT_ - 2 * BORDER_HEIGHT;
	ARROW_BOX_SIZE_	        = ITEM_SIZE_ / 2;
	SLIDER_SIZE_  	        = ITEM_SIZE_ / 4;

	COLOR_NUMBER_WIDTH      = 4 * CHAR_WIDTH_;

	PAUSE_ITEM_SIZE	        = 80;
	PAUSE_BUTTON_X	        = SCREEN_WIDTH  - (BAR_HEIGHT / 2) - PAUSE_ITEM_SIZE;
	PAUSE_BUTTON_Y	        = SCREEN_HEIGHT - (BAR_HEIGHT / 2) - PAUSE_ITEM_SIZE;

	AUX_BUTTON_HEIGHT		= ROW_HEIGHT_;
	AUX_BUTTON_WIDTH		= (SCREEN_WIDTH / NUM_AUXILLARY_BUTTONS) - 16;
	AUX_BUTTON_RIGHT_MOST_X	= PAUSE_BUTTON_X - AUX_BUTTON_WIDTH - AUX_BUTTON_SPACING;
	AUX_BUTTON_Y			= PAUSE_BUTTON_Y;

	MRU_FORWARD_LOCK_X		= WIDGET_WIDTH_  - BORDER_WIDTH - ITEM_SIZE_;
	MRU_FORWARD_LOCK_Y		= BAR_HEIGHT - BORDER_HEIGHT - ITEM_SIZE_;

	Reveal::GetTweaker().RepositionMrus( WIDGET_WIDTH_ );
}
	
int& GuiMetrics::GetItemSize()
{
	return ITEM_SIZE_;
}

int& GuiMetrics::GetArrowBoxSize()
{
	return ARROW_BOX_SIZE_;
}

int& GuiMetrics::GetCharacterWidth()
{
	return CHAR_WIDTH_;
}

int& GuiMetrics::GetRowHeight()
{
	return ROW_HEIGHT_;
}

int& GuiMetrics::GetSliderSize()
{
	return SLIDER_SIZE_;
}

int& GuiMetrics::GetWidgetWidth()
{
	return WIDGET_WIDTH_;
}

// ------------------------------------------------------------------------

	} // Namespace Impl;
} // Namespace Reveal;
