./vdo_pause_header_mini.lua

  1. ---------------------------------------------------------------------------  
  2. -- Vdo_pause_header_mini 
  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_mini = Vdo_base_object:new_base() 
  10.  
  11. --Colors -  
  12. COLOR_PAUSE_HEADER = {R = 218/255, G = 226/255; B = 230/255} 
  13.  
  14. --Standard Init 
  15. function Vdo_pause_header_mini_init() 
  16. 	--Hide the object from displaying crap on the first frame 
  17. 	local text = vint_object_find("text") 
  18. 	vint_set_property(text, "text_tag", "") 
  19. end 
  20.  
  21. --Standard Cleanup 
  22. function Vdo_pause_header_mini_cleanup() 
  23. end 
  24.  
  25. ---------------------------------------------------------------------------  
  26. -- Initializes VDO Object 
  27. --------------------------------------------------------------------------- 
  28. function Vdo_pause_header_mini:init() 
  29. 	--Reset color to script value 
  30. 	local text_obj = Vdo_base_object:new("text", self.handle) 
  31. 	--text_obj:set_color(COLOR_PAUSE_HEADER.R, COLOR_PAUSE_HEADER.G, COLOR_PAUSE_HEADER.B) 
  32. 	 
  33. 	--Store off fill height... 
  34. 	local fill_h = vint_object_find("fill", self.handle, self.doc_handle) 
  35. 	local w, h = element_get_actual_size(fill_h) 
  36. 	self.fill_height = h 
  37. 	 
  38. 	--Bottom Line is always the same length of the screen. 
  39. 	local bot_line_h = vint_object_find("bot_line", self.handle, self.doc_handle) 
  40. 	 
  41. 	 
  42. 	if vint_is_std_res() then 
  43. 		--Standard Def 
  44. 		self.max_width = 587 
  45. 	else 
  46. 		--Widescreen 
  47. 		self.max_width = 678 
  48. 		 
  49. 	end 
  50. 	 
  51. 	--Set width of bottom line, this never changes. 
  52. 	element_set_actual_size(bot_line_h, self.max_width, 2) 
  53. end 
  54.  
  55. ---------------------------------------------------------------------------  
  56. -- Sets the text of the header and causes 
  57. -- 
  58. -- @param new_text_string	Text string for header 
  59. --------------------------------------------------------------------------- 
  60. function Vdo_pause_header_mini:set_text(new_text_string) 
  61. 	local text_h = vint_object_find("header_txt", self.handle) 
  62. 	 
  63. 	--Set text 
  64. 	vint_set_property(text_h, "text_tag", new_text_string) 
  65. 	 
  66. 	--Reset text scale 
  67. 	vint_set_property(text_h, "scale", 1, 1) 
  68. 	 
  69. 	--Get text size 
  70. 	local text_width, text_height = element_get_actual_size(text_h) 
  71. 	 
  72. 	--leave room for padding 
  73. 	local max_width = 10000 
  74. 	if self.max_width ~= nil then 
  75. 		max_width = self.max_width - 100 
  76. 	end 
  77. 	 
  78. 	local move_grp_h = vint_object_find("adjust_grp", self.handle, self.doc_handle) 
  79. 	local bot_line_h = vint_object_find("bot_line", self.handle, self.doc_handle) 
  80. 	 
  81. 	--This is standard width of the box... 
  82. 	local new_width = (text_width + 23) 
  83. 	 
  84. 	--Check if the text width is larger than max width... 
  85. 	if max_width ~= nil and text_width > max_width then 
  86. 		local text_scale = max_width / text_width  
  87. 		vint_set_property(text_h, "scale", text_scale, text_scale) 
  88. 		 
  89. 		--Scale down the width by our new text scale... 
  90. 		new_width = (text_width * text_scale) + 23 
  91. 	end 
  92.  
  93. 	--Set bg box 
  94. 	local top_line_h = vint_object_find("top_line", self.handle, self.doc_handle) 
  95. 	local right_line_h = vint_object_find("right_line", self.handle, self.doc_handle) 
  96. 	local fill_h = vint_object_find("fill", self.handle, self.doc_handle) 
  97.  
  98. 	element_set_actual_size(top_line_h, new_width + 2, 2) 
  99. 	element_set_actual_size(fill_h, new_width, self.fill_height) 
  100. 	vint_set_property(right_line_h, "anchor", new_width, 2) 
  101. end