#textdomain wesnoth-lib
###
### Definition of a slider.
###

#define _GUI_STATE IMAGE_SUFFIX GROOVE_COLOUR TEXT_COLOUR RIGHT_OFFSET TEXT_OFFSET TEXT_WIDTH FONT_SIZE
	[draw]

		#
		# Groove
		#

		[line]
			x1 = 0
			y1 = "(height / 2)"
			x2 = "(width - ({RIGHT_OFFSET} + 1))"
			y2 = "(height / 2)"

			colour = {GROOVE_COLOUR}
			thickness = 1
		[/line]

		#
		# Text
		#

		[text]
			x = "(width - {TEXT_OFFSET})"
			y = {GUI__TEXT_VERTICALLY_CENTRED}
			w = "{TEXT_WIDTH}"
			h = "(height)"

			font_size = {FONT_SIZE}
			colour = {TEXT_COLOUR}
			text = "(text)"
		[/text]

		#
		# Slider
		#

		[image]
			x = "(positioner_offset)"
			y = "(if (image_height < height, (height - image_height) / 2, 0))"
			name = "buttons/slider{IMAGE_SUFFIX}.png"
		[/image]

	[/draw]
#enddef

#define _GUI_RESOLUTION RESOLUTION MIN_WIDTH DEFAULT_WIDTH HEIGHT POSITIONER_LENGTH RIGHT_OFFSET TEXT_OFFSET TEXT_WIDTH FONT_SIZE 

	[resolution]

		{RESOLUTION}

		min_width = {MIN_WIDTH}
		min_height = {HEIGHT}

		default_width = {DEFAULT_WIDTH}
		default_height = {HEIGHT}

		max_width = 0
		max_height = {HEIGHT}

		minimum_positioner_length = {POSITIONER_LENGTH}
		maximum_positioner_length = {POSITIONER_LENGTH}

		left_offset = 0
		right_offset = {RIGHT_OFFSET}

		text_font_size = {FONT_SIZE}

		[state_enabled]
			{_GUI_STATE 
				()
				({GUI__FONT_COLOUR_ENABLED__DEFAULT})
				({GUI__FONT_COLOUR_ENABLED__DEFAULT})
				({RIGHT_OFFSET})
				({TEXT_OFFSET})
				({TEXT_WIDTH})
				({FONT_SIZE})
			}
		[/state_enabled]

		[state_disabled]
			{_GUI_STATE 
				"-disabled" 
				({GUI__FONT_COLOUR_DISABLED__DEFAULT})
				({GUI__FONT_COLOUR_DISABLED__DEFAULT})
				({RIGHT_OFFSET})
				({TEXT_OFFSET})
				({TEXT_WIDTH})
				({FONT_SIZE})
			}
		[/state_disabled]

		[state_pressed]
			{_GUI_STATE 
				"-selected" 
				({GUI__FONT_COLOUR_ENABLED__DEFAULT})
				({GUI__FONT_COLOUR_ENABLED__DEFAULT})
				({RIGHT_OFFSET})
				({TEXT_OFFSET})
				({TEXT_WIDTH})
				({FONT_SIZE})
			}
		[/state_pressed]
		
		[state_focussed]
			{_GUI_STATE 
				"-active" 
				({GUI__FONT_COLOUR_ENABLED__DEFAULT})
				({GUI__FONT_COLOUR_ENABLED__DEFAULT})
				({RIGHT_OFFSET})
				({TEXT_OFFSET})
				({TEXT_WIDTH})
				({FONT_SIZE})
			}
		[/state_focussed]

	[/resolution]
#enddef

[slider_definition]
	id = "default"
	description = "A slider with it's value on the right hand side."

	# Tiny gui sizes haven't been tested yet so might need some tuning.
	{_GUI_RESOLUTION ({GUI_TINY__RESOLUTION})  75 125 11  8  68  65 15 ({GUI_TINY__FONT_SIZE__DEFAULT})   }
	{_GUI_RESOLUTION ()                       150 250 22 16 135 130 30 ({GUI_NORMAL__FONT_SIZE__DEFAULT}) }

[/slider_definition]

#undef _GUI_STATE
#undef _GUI_RESOLUTION 

