./vdo_pause_header.lua

  1. ---------------------------------------------------------------------------  
  2. -- Vdo_pause_header 
  3. -- 
  4. -- The header for each screen in the pause menu. This object gets included 
  5. -- manually in those documents that need a header. 
  6. --------------------------------------------------------------------------- 
  7.  
  8. -- Inherited from Vdo_base_object 
  9. Vdo_pause_header = Vdo_base_object:new_base() 
  10.  
  11. --Colors -  
  12. COLOR_PAUSE_HEADER = {R = 218/255, G = 226/255; B = 230/255} 
  13. local PAUSE_PADDING = 23 
  14.  
  15. PAUSE_PADDING = 23 
  16.  
  17. --Standard Init 
  18. function Vdo_pause_header_init() 
  19. 	--Hide the object from displaying crap on the first frame 
  20. 	local text = vint_object_find("text") 
  21. 	vint_set_property(text, "text_tag", "") 
  22. end 
  23.  
  24. --Standard Cleanup 
  25. function Vdo_pause_header_cleanup() 
  26. end 
  27.  
  28. ---------------------------------------------------------------------------  
  29. -- Initializes VDO Object 
  30. --------------------------------------------------------------------------- 
  31. function Vdo_pause_header:init() 
  32. 	--Reset color to script value 
  33. 	local text_obj = Vdo_base_object:new("text", self.handle) 
  34. 	--text_obj:set_color(COLOR_PAUSE_HEADER.R, COLOR_PAUSE_HEADER.G, COLOR_PAUSE_HEADER.B) 
  35. 	 
  36. end 
  37.  
  38. ---------------------------------------------------------------------------  
  39. -- Sets the text of the header and causes 
  40. -- 
  41. -- @param new_text_string	Text string for header 
  42. --------------------------------------------------------------------------- 
  43. function Vdo_pause_header:set_text(new_text_string, max_width) 
  44. 	local text_obj = Vdo_base_object:new("text", self.handle) 
  45. 	text_obj:set_text(new_text_string) 
  46. 	--text_obj:set_scale(.95,.95) 
  47. 	 
  48. 	local text_width,text_height = self:get_size()  
  49. 	--leave room for padding 
  50. 	 
  51. 	local move_grp_h = vint_object_find("adjust_grp", self.handle, self.doc_handle) 
  52. 	local bot_line_h = vint_object_find("bot_line", self.handle, self.doc_handle) 
  53. 	 
  54. 	if max_width ~= nil and text_width > max_width then 
  55. 		local text_scale = (max_width/(text_width+PAUSE_PADDING)) 
  56. 		vint_set_property(move_grp_h, "scale", text_scale,text_scale) 
  57. 		text_width,text_height = self:get_size() 
  58. 		local new_width_scaled = (text_width + PAUSE_PADDING) 
  59. 		element_set_actual_size(bot_line_h, -max_width, 2/text_scale) 
  60. 	else 
  61. 		vint_set_property(move_grp_h, "scale", 1,1) 
  62. 		if max_width ~= nil then 
  63. 			local line_corner = Vdo_base_object:new("line_corner", self.handle) 
  64. 			local corner_size_w, corner_size_h = line_corner:get_actual_size() 
  65. 			element_set_actual_size(bot_line_h, -max_width - corner_size_w, 6) 
  66. 		end 
  67. 	end 
  68. 	 
  69. 	text_obj:set_alpha(1.0) 
  70. 	text_obj:set_anchor(-6,4) 
  71. 	 
  72. 	local crumb_obj = Vdo_base_object:new("text_crumb", self.handle) 
  73. 	crumb_obj:set_visible(false) 
  74. 	 
  75. 	--local bot_line_width, bot_line_height = element_get_actual_size(bot_line_h) 
  76. 	--element_set_actual_size(bot_line_h, bot_line_width, 2) 
  77. 	 
  78. 	--set bg box 
  79. 	local top_line_h = vint_object_find("top_line", self.handle, self.doc_handle) 
  80. 	local right_line_h = vint_object_find("right_line", self.handle, self.doc_handle) 
  81. 	local fill_h = vint_object_find("fill", self.handle, self.doc_handle) 
  82. 	 
  83. 	text_width,text_height = self:get_size() 
  84. 	 
  85. 	local new_width = (text_width + PAUSE_PADDING) 
  86. 	element_set_actual_size(top_line_h, -new_width, 2) 
  87. 	element_set_actual_size(fill_h, -new_width, 81) 
  88. 	vint_set_property(right_line_h, "anchor", -new_width, 0) 
  89. 	 
  90. end 
  91.  
  92. function Vdo_pause_header:set_crumb(new_text_string) 
  93. 	local crumb_obj = Vdo_base_object:new("text_crumb", self.handle) 
  94. 	if new_text_string ~= nil or new_text_string ~= "" then 
  95. 		crumb_obj:set_visible(true) 
  96. 		crumb_obj:set_text(new_text_string) 
  97. 	else 
  98. 		crumb_obj:set_visible(false) 
  99. 		crumb_obj:set_text("") 
  100. 	end 
  101.  
  102. end 
  103.  
  104. function Vdo_pause_header:reset_width() 
  105. 	local bot_line_h = vint_object_find("bot_line", self.handle, self.doc_handle) 
  106. 	if vint_is_std_res() then 
  107. 		element_set_actual_size(bot_line_h, -750, 6) 
  108. 	else 
  109. 		element_set_actual_size(bot_line_h, -840, 6) 
  110. 	end 
  111. end 
  112.  
  113. function Vdo_pause_header:set_alignment(alignment) 
  114. 	local text_obj_h = vint_object_find("text", self.handle) 
  115. 	vint_set_property(text_obj_h, "auto_offset", alignment) 
  116. end 
  117.  
  118. function Vdo_pause_header:set_text_scale(scale) 
  119. 	local text_obj_h = vint_object_find("text", self.handle) 
  120. 	vint_set_property(text_obj_h, "text_scale", scale, scale) 
  121. end 
  122.  
  123. function Vdo_pause_header:get_size() 
  124. 	local text_obj_h = vint_object_find("text", self.handle) 
  125. 	return element_get_actual_size(text_obj_h) 
  126. end 
  127. ------------------------------------------------------------------------------- 
  128. -- Function to hide this object... used by the silverlink menu... 
  129. function Vdo_pause_header:show_me(is_visible) 
  130. 	local move_grp_h = vint_object_find("adjust_grp", self.handle, self.doc_handle) 
  131. 	vint_set_property(move_grp_h, "visible", is_visible) 
  132. end