./vdo_slider.lua

  1. function vdo_slider_init() 
  2. end 
  3.  
  4. function vdo_slider_cleanup() 
  5. end 
  6.  
  7. -- Inherited from Vdo_base_object 
  8. Vdo_slider = Vdo_base_object:new_base() 
  9.  
  10. PAUSE_COLOR_SLIDER_FILL_SELECTED = {R = 58/255, G = 20/255, B = 41/255} 
  11. PAUSE_COLOR_SLIDER_FILL_UNSELECTED = {R = 59/255, G = 54/255, B = 58/255} 
  12.  
  13. local VDO_SLIDER_WIDTH		=	231 
  14. local VDO_SLIDER_INTERNAL_WIDTH	=	201 	--size of slider without arrows... 
  15. local VDO_SLIDER_HEIGHT		=	24 
  16.  
  17. -- Sets the value of the slider object 
  18. function Vdo_slider:set_value(new_value,min_value,max_value,display,mapping) 
  19. 	 
  20. 	--Find Slider objects 
  21. 	local slider_bg = Vdo_base_object:new("slider_bg", self.handle, self.doc_handle) 
  22. 	local meter_left = Vdo_base_object:new("slider_bg_left", self.handle, self.doc_handle) 
  23. 	local meter_right = Vdo_base_object:new("slider_bg_right", self.handle, self.doc_handle) 
  24. 	local slider_value = Vdo_base_object:new("slider_value", self.handle, self.doc_handle) 
  25.  
  26. 	--	local x, y = meter:get_anchor() 
  27. 	--	local meter_max, bogus_height = meter:get_property("screen_size") 
  28. 	 
  29. 		--local bg = Vdo_base_object:new("slider_meter_bg_2", self.handle, self.doc_handle) 
  30. 	--	local value_grp = Vdo_base_object:new("slider_value_group", self.handle, self.doc_handle) 
  31. 	--	local value = Vdo_base_object:new("slider_value", self.handle, self.doc_handle) 
  32. 		 
  33. 	min_value = min_value or 0 
  34. 	max_value = max_value or 100 
  35. 	 
  36. 	local new_value_pct = (new_value - min_value) / (max_value - min_value) 
  37. 	 
  38. 	-- special case adjustment for 0-1.0 % sliders (show whole numbers) 
  39. 	if min_value < 1 and max_value <= 1 then 
  40. 		new_value = floor((new_value * 100) + .5) 
  41. 	end 
  42. 	 
  43. 	--Position Text 
  44. 	-- Min is position of text for 0 on left side of bar 
  45. 	-- Max is position of text for 100 on right side of bar 
  46. 	local x_min = 35 
  47. 	local x_max = 194 
  48. 	local pos_x = (x_max - x_min) * new_value_pct + x_min 
  49. 	slider_value:set_anchor(pos_x,0) 
  50.  
  51. 	--Resize and position bars 
  52. 	 
  53. 	--Left Bar 
  54. 	local width_min 	= 0.01 
  55. 	local width_max	= 156 
  56. 	local size_x = (width_max - width_min) * new_value_pct + width_min  
  57. 	local t_x, t_y = meter_left:get_actual_size() 
  58. 	meter_left:set_actual_size(size_x, t_y) 
  59. 	 
  60. 	--Right Bar 
  61. 	local width_min	= 156 
  62. 	local width_max 	= 0.01 
  63. 	local size_x = (width_max - width_min) * new_value_pct + width_min  
  64. 	meter_right:set_actual_size(size_x, t_y) 
  65.  
  66. 	if mapping ~= nil then 
  67. 		if mapping[new_value] ~= nil then 
  68. 			new_value = mapping[new_value] 
  69. 		end 
  70. 	end 
  71. 	 
  72. 	slider_value:set_property("text_tag", new_value) 
  73. end 
  74.  
  75. -- Sets the highlighted state of the slider to on or off (will eventually have grayed out here too) 
  76. function Vdo_slider:set_highlight(is_highlighted) 
  77. 	local meter_left = Vdo_base_object:new("slider_bg_left", self.handle, self.doc_handle) 
  78. 	local meter_right = Vdo_base_object:new("slider_bg_right", self.handle, self.doc_handle) 
  79. 	local arrow_left = Vdo_base_object:new("arrow_left", self.handle, self.doc_handle) 
  80. 	local arrow_right = Vdo_base_object:new("arrow_right", self.handle, self.doc_handle) 
  81. 	local slider_bg = Vdo_base_object:new("slider_bg", self.handle, self.doc_handle) 
  82.  
  83. 	if is_highlighted then 
  84. 		meter_left:set_color(self.highlight_color.R, self.highlight_color.G, self.highlight_color.B) 
  85. 		meter_right:set_color(self.highlight_color.R, self.highlight_color.G, self.highlight_color.B) 
  86. 		arrow_left:set_visible(true) 
  87. 		arrow_right:set_visible(true) 
  88. 		slider_bg:set_visible(true) 
  89. 	else 
  90. 		meter_left:set_color(self.highlight_color.R, self.highlight_color.G, self.highlight_color.B) 
  91. 		meter_right:set_color(self.highlight_color.R, self.highlight_color.G, self.highlight_color.B)	 
  92. 		--meter_left:set_color(PAUSE_COLOR_SLIDER_FILL_UNSELECTED.R, PAUSE_COLOR_SLIDER_FILL_UNSELECTED.G, PAUSE_COLOR_SLIDER_FILL_UNSELECTED.B) 
  93. 		--meter_right:set_color(PAUSE_COLOR_SLIDER_FILL_UNSELECTED.R, PAUSE_COLOR_SLIDER_FILL_UNSELECTED.G, PAUSE_COLOR_SLIDER_FILL_UNSELECTED.B) 
  94. 		arrow_left:set_visible(false) 
  95. 		arrow_right:set_visible(false) 
  96. 		slider_bg:set_visible(false) 
  97. 	end 
  98. end 
  99.  
  100. -- Sets the enabled state of the slider to on or off 
  101. function Vdo_slider:set_enabled(enabled) 
  102. end 
  103.  
  104. -- Sets the width of the slider object 
  105. function Vdo_slider:set_width(width) 
  106. end 
  107.  
  108. -- This is a hacky function to display the button icon next to the text without highlighting.  It mainly 
  109. -- exists for early test screens where we needed to have a back button image with text for descriptive 
  110. -- purposes only. 
  111. function Vdo_slider:show_button(button_icon) 
  112. end 
  113.  
  114. function Vdo_slider:set_highlight_color(new_color) 
  115. 	self.highlight_color = new_color 
  116. end 
  117.  
  118. function Vdo_slider:get_size() 
  119. 	return VDO_SLIDER_WIDTH, VDO_SLIDER_HEIGHT 
  120. end 
  121. function Vdo_slider:get_internal_width() 
  122. 	return VDO_SLIDER_INTERNAL_WIDTH 
  123. end 
  124.  
  125. function Vdo_slider:set_disabled(is_disabled) 
  126. 		 
  127. 	--Hide Arrows 
  128. 	if is_disabled == true then 
  129. 		vint_set_property(self.handle, 		"alpha", 0.5) 
  130. 	else 
  131. 		vint_set_property(self.handle, 		"alpha", 1.0) 
  132. 	end 
  133. end