from ableton.v2.control_surface import Component
from ableton.v2.control_surface.components import TransportComponent

from ..color import Color, FX

class TempoModeComponent(Component):
	"A component that handles the Up and Down buttons of the Exquis in most non-Notes modes"

	def __init__(self, *a, **k):
		super(TempoModeComponent, self).__init__(*a, **k)

		self.transport = TransportComponent(
			name="TempoTransport",
		)
		
	def set_up_button(self, button):
		self.transport._metronome_toggle.view_transform = lambda value: Color(127 if value else 3, FX.pulsate)
		self.transport.set_metronome_button(button)
	
	def set_down_button(self, button):
		self.transport.tap_tempo_button.color = Color(127, FX.darker(50))
		self.transport.tap_tempo_button.pressed_color = Color(127)
		self.transport.tap_tempo_button.set_control_element(button)
