#textdomain wesnoth-lib
###
### Definition of the window to show the debug_clock for testing the drawing
### timer.
###


#define _GUI_TICK_MARK ANGLE TEXT
[text]
	x = "(round(125 + (100.0 * sin({ANGLE}))))"
	y = "(round(125 - (100.0 * cos({ANGLE}))))"
	h = 20
	w = 30
	font_size = 10
	color = "255,255,255,255"
	text = "{TEXT}"
[/text]
#enddef

[window]
	id = "debug_clock"
	description = "Clock dialog to test the drawing timer."

	[resolution]
		definition = "default"

		click_dismiss = "true"

		automatic_placement = "true"
		vertical_placement = "top"
		horizontal_placement = "left"

		[tooltip]
			id = "tooltip_large"
		[/tooltip]

		[helptip]
			id = "tooltip_large"
		[/helptip]

		[grid]

			[row]

				[column]
					border = "all"
					border_size = 5
					horizontal_alignment = "left"

					[label]
						definition = "title"

						label = "Debug drawing clock"
					[/label]

				[/column]

			[/row]

			[row]
				grow_factor = 1

				[column]
					border = "all"
					border_size = 5
					horizontal_grow = "true"
					vertical_grow = "true"

					[progress_bar]
						id = "hour_percentage"

						tooltip = "Hours in percent."
						help = "The full range of the bar is 24 hours."
					[/progress_bar]

				[/column]

			[/row]

			[row]
				grow_factor = 1

				[column]
					border = "all"
					border_size = 5
					horizontal_grow = "true"
					vertical_grow = "true"

					[progress_bar]
						id = "minute_percentage"
					[/progress_bar]

				[/column]

			[/row]

			[row]
				grow_factor = 1

				[column]
					border = "all"
					border_size = 5
					horizontal_grow = "true"
					vertical_grow = "true"

					[progress_bar]
						id = "second_percentage"
					[/progress_bar]

				[/column]

			[/row]

			[row]
				grow_factor = 1

				[column]
					border = "all"
					border_size = 5
					horizontal_grow = "true"
					vertical_grow = "true"

					[slider]
						id = "hour"
						definition = "clock"

						minimum_value = 0
						maximum_value = 86399
						step_size = 1
					[/slider]

				[/column]

			[/row]

			[row]
				grow_factor = 1

				[column]
					border = "all"
					border_size = 5
					horizontal_grow = "true"
					vertical_grow = "true"

					[slider]
						id = "minute"
						definition = "clock"

						minimum_value = 0
						maximum_value = 3599
						step_size = 1
						label = 3599
					[/slider]

				[/column]

			[/row]

			[row]
				grow_factor = 1

				[column]
					border = "all"
					border_size = 5
					horizontal_grow = "true"
					vertical_grow = "true"

					[slider]
						id = "second"
						definition = "clock"

						minimum_value = 0
						maximum_value = 59
						step_size = 1
						label = 59
					[/slider]

				[/column]

			[/row]

			[row]

				[column]
					border = "all"
					border_size = 5
					horizontal_alignment = "center"
					vertical_alignment = "center"

					[drawing]
						id = "clock"
						definition = "default"

						width = 250
						height = 280

						[draw]
							# Add hour ticks.

							{_GUI_TICK_MARK  15.0 1 }
							{_GUI_TICK_MARK  30.0 2 }
							{_GUI_TICK_MARK  45.0 3 }
							{_GUI_TICK_MARK  60.0 4 }
							{_GUI_TICK_MARK  75.0 5 }
							{_GUI_TICK_MARK  90.0 6 }
							{_GUI_TICK_MARK 105.0 7 }
							{_GUI_TICK_MARK 120.0 8 }
							{_GUI_TICK_MARK 135.0 9 }
							{_GUI_TICK_MARK 150.0 10}
							{_GUI_TICK_MARK 165.0 11}
							{_GUI_TICK_MARK 180.0 12}
							{_GUI_TICK_MARK 195.0 13}
							{_GUI_TICK_MARK 210.0 14}
							{_GUI_TICK_MARK 225.0 15}
							{_GUI_TICK_MARK 240.0 16}
							{_GUI_TICK_MARK 255.0 17}
							{_GUI_TICK_MARK 270.0 18}
							{_GUI_TICK_MARK 285.0 19}
							{_GUI_TICK_MARK 300.0 20}
							{_GUI_TICK_MARK 315.0 21}
							{_GUI_TICK_MARK 330.0 22}
							{_GUI_TICK_MARK 345.0 23}
							{_GUI_TICK_MARK 360.0 24}

							# Add outer circle.

							[circle]
								x = 125
								y = 125
								radius = 115
								color = "255,255,255,255"
							[/circle]

							# TODO

							# Add the hands.

							[line]
								x1 = 125
								y1 = 125
								x2 = "(round(125 + (90.0 * sin(360.0 * second / 60.0))))"
								y2 = "(round(125 - (90.0 * cos(360.0 * second / 60.0))))"
								color = "255,255,255,255"
							[/line]

							[line]
								x1 = 125
								y1 = 125
								x2 = "(round(125 + (70.0 * sin(360.0 * minute / (60.0 * 60.0)))))"
								y2 = "(round(125 - (70.0 * cos(360.0 * minute / (60.0 * 60.0)))))"
								color = "128,128,128,255"
							[/line]

							[line]
								x1 = 125
								y1 = 125
								x2 = "(round(125 + (40.0 * sin(360.0 * hour / (60.0 * 60.0 * 24.0)))))"
								y2 = "(round(125 - (40.0 * cos(360.0 * hour / (60.0 * 60.0 * 24.0)))))"
								color = "64,64,64,255"
							[/line]

							# Show the time as string.

							[text]
								x = 0
								y = 250
								w = "(width)"
								h = 30
								font_size = 20
								maximum_width = "(width)"
								text_alignment = "center"
								color = "128,128,128,255"
								text = "(concatenate(
									  substring(concatenate(0, 0, (hour / (60 * 60))), -2)
									, ':'
									, substring(concatenate(0, 0, (minute / 60)), -2)
									, ':'
									, substring(concatenate(0, 0, second), -2)))"
							[/text]

						[/draw]

					[/drawing]

				[/column]

			[/row]

		[/grid]

	[/resolution]

[/window]

[slider_definition]
	id = "clock"
	description = "Specialized slider to test the clock dialog."

	[resolution]

		min_width = 150
		min_height = 22

		default_width = 250
		default_height = 22

		max_width = 0
		max_height = 22

		minimum_positioner_length = 16
		maximum_positioner_length = 16

		left_offset = 0
		right_offset = 0

		text_font_size = 1

		[state_enabled]
			[draw]
			[/draw]
		[/state_enabled]

		[state_disabled]
			[draw]

			#
			# Groove
			#

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

				color = {GUI__FONT_COLOR_ENABLED__DEFAULT}
				thickness = 1
			[/line]

			#
			# Slider
			#

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

			[/draw]
		[/state_disabled]

		[state_pressed]
			[draw]
			[/draw]
		[/state_pressed]

		[state_focussed]
			[draw]
			[/draw]
		[/state_focussed]

	[/resolution]

[/slider_definition]
