/tools/XBMCLive/USplashThemes/spinner-blue/xbmc-splash.c

https://github.com/tmacreturns/XBMC_wireless_setup · C · 349 lines · 209 code · 59 blank · 81 comment · 3 complexity · dccaae6732c8ffc40c27832a0260b045 MD5 · raw file

  1. #include <usplash-theme.h>
  2. #include <usplash_backend.h>
  3. /**********************************************************************************
  4. This is a USplash based theme for the awsome XBMC Media Center for linux.
  5. Graphics were composed mainly of the official XBMC logos.
  6. Visit my blog at:
  7. http://du-duke.blogspot.com/
  8. for some more usplash, xbmc stuff.
  9. some code snippets were taken from:
  10. http://gnome-look.org/content/show.php/MacX+Usplash+Theme?content=73611
  11. ===================================================================================
  12. This program is free software: you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation, either version 3 of the License, or
  15. (at your option) any later version.
  16. This program is distributed in the hope that it will be useful,
  17. but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. GNU General Public License for more details.
  20. You should have received a copy of the GNU General Public License
  21. along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. ==================================================================================
  23. **********************************************************************************/
  24. extern struct usplash_pixmap pixmap_xbmc_1920_1200;
  25. extern struct usplash_pixmap pixmap_xbmc_1920_1080;
  26. extern struct usplash_pixmap pixmap_xbmc_1680_1050;
  27. extern struct usplash_pixmap pixmap_xbmc_1440_900;
  28. extern struct usplash_pixmap pixmap_xbmc_1280_1024;
  29. extern struct usplash_pixmap pixmap_xbmc_1366_768;
  30. extern struct usplash_pixmap pixmap_xbmc_1280_720;
  31. extern struct usplash_pixmap pixmap_xbmc_1024_768;
  32. extern struct usplash_pixmap pixmap_xbmc_800_600;
  33. extern struct usplash_pixmap pixmap_xbmc_640_480;
  34. extern struct usplash_pixmap pixmap_xbmc_spinner;
  35. extern struct usplash_font font_helvB10;
  36. void t_init(struct usplash_theme* theme);
  37. void t_clear_progressbar(struct usplash_theme* theme);
  38. void t_draw_progressbar(struct usplash_theme* theme, int percentage);
  39. void t_animate_step(struct usplash_theme* theme, int pulsating);
  40. void spinner(struct usplash_theme* theme);
  41. struct usplash_theme usplash_theme;
  42. struct usplash_theme usplash_theme_1920_1080;
  43. struct usplash_theme usplash_theme_1680_1050;
  44. struct usplash_theme usplash_theme_1440_900;
  45. struct usplash_theme usplash_theme_1280_1024;
  46. struct usplash_theme usplash_theme_1366_768;
  47. struct usplash_theme usplash_theme_1280_720;
  48. struct usplash_theme usplash_theme_1024_768;
  49. struct usplash_theme usplash_theme_800_600;
  50. struct usplash_theme usplash_theme_640_480;
  51. static int spinner_x, spinner_y, spinner_part_width, spinner_height;
  52. static int current_count = 0;
  53. static int current_step = 0;
  54. static int spinner_num_steps = 12;
  55. // spinner_speed can be between 1 and 25
  56. // there are 12 images in the spinner, so a value of 2 will make
  57. // it spin around approx. once per second
  58. static int spinner_speed = 2;
  59. /** ----------------------------------------------------------------------- **/
  60. struct usplash_theme usplash_theme = {
  61. .version = THEME_VERSION,
  62. .next = &usplash_theme_1920_1080,
  63. .ratio = USPLASH_16_9,
  64. /* Background and font */
  65. .pixmap = &pixmap_xbmc_1920_1200,
  66. .font = &font_helvB10,
  67. /* Palette indexes */
  68. .background = 0x01,
  69. .progressbar_background = 0x00,
  70. .progressbar_foreground = 0x1E,
  71. /* Functions */
  72. .init = t_init,
  73. .clear_progressbar = t_clear_progressbar,
  74. .draw_progressbar = t_draw_progressbar,
  75. .animate_step = t_animate_step,
  76. };
  77. struct usplash_theme usplash_theme_1920_1080 = {
  78. .version = THEME_VERSION,
  79. .next = &usplash_theme_1680_1050,
  80. .ratio = USPLASH_16_9,
  81. /* Background and font */
  82. .pixmap = &pixmap_xbmc_1920_1080,
  83. .font = &font_helvB10,
  84. /* Palette indexes */
  85. .background = 0x01,
  86. .progressbar_background = 0x00,
  87. .progressbar_foreground = 0x1E,
  88. /* Functions */
  89. .init = t_init,
  90. .clear_progressbar = t_clear_progressbar,
  91. .draw_progressbar = t_draw_progressbar,
  92. .animate_step = t_animate_step,
  93. };
  94. struct usplash_theme usplash_theme_1680_1050 = {
  95. .version = THEME_VERSION,
  96. .next = &usplash_theme_1440_900,
  97. .ratio = USPLASH_16_9,
  98. /* Background and font */
  99. .pixmap = &pixmap_xbmc_1680_1050,
  100. .font = &font_helvB10,
  101. /* Palette indexes */
  102. .background = 0x01,
  103. .progressbar_background = 0x00,
  104. .progressbar_foreground = 0x1E,
  105. /* Functions */
  106. .init = t_init,
  107. .clear_progressbar = t_clear_progressbar,
  108. .draw_progressbar = t_draw_progressbar,
  109. .animate_step = t_animate_step,
  110. };
  111. struct usplash_theme usplash_theme_1440_900 = {
  112. .version = THEME_VERSION,
  113. .next = &usplash_theme_1280_1024,
  114. .ratio = USPLASH_16_9,
  115. /* Background and font */
  116. .pixmap = &pixmap_xbmc_1440_900,
  117. .font = &font_helvB10,
  118. /* Palette indexes */
  119. .background = 0x01,
  120. .progressbar_background = 0x00,
  121. .progressbar_foreground = 0x1E,
  122. /* Functions */
  123. .init = t_init,
  124. .clear_progressbar = t_clear_progressbar,
  125. .draw_progressbar = t_draw_progressbar,
  126. .animate_step = t_animate_step,
  127. };
  128. struct usplash_theme usplash_theme_1280_1024 = {
  129. .version = THEME_VERSION,
  130. .next = &usplash_theme_1366_768,
  131. .ratio = USPLASH_4_3,
  132. /* Background and font */
  133. .pixmap = &pixmap_xbmc_1280_1024,
  134. .font = &font_helvB10,
  135. /* Palette indexes */
  136. .background = 0x01,
  137. .progressbar_background = 0x00,
  138. .progressbar_foreground = 0x1E,
  139. /* Functions */
  140. .init = t_init,
  141. .clear_progressbar = t_clear_progressbar,
  142. .draw_progressbar = t_draw_progressbar,
  143. .animate_step = t_animate_step,
  144. };
  145. struct usplash_theme usplash_theme_1366_768 = {
  146. .version = THEME_VERSION,
  147. .next = &usplash_theme_1280_720,
  148. .ratio = USPLASH_16_9,
  149. /* Background and font */
  150. .pixmap = &pixmap_xbmc_1366_768,
  151. .font = &font_helvB10,
  152. /* Palette indexes */
  153. .background = 0x01,
  154. .progressbar_background = 0x00,
  155. .progressbar_foreground = 0x1E,
  156. /* Functions */
  157. .init = t_init,
  158. .clear_progressbar = t_clear_progressbar,
  159. .draw_progressbar = t_draw_progressbar,
  160. .animate_step = t_animate_step,
  161. };
  162. struct usplash_theme usplash_theme_1280_720 = {
  163. .version = THEME_VERSION,
  164. .next = &usplash_theme_1024_768,
  165. .ratio = USPLASH_16_9,
  166. /* Background and font */
  167. .pixmap = &pixmap_xbmc_1280_720,
  168. .font = &font_helvB10,
  169. /* Palette indexes */
  170. .background = 0x01,
  171. .progressbar_background = 0x00,
  172. .progressbar_foreground = 0x1E,
  173. /* Functions */
  174. .init = t_init,
  175. .clear_progressbar = t_clear_progressbar,
  176. .draw_progressbar = t_draw_progressbar,
  177. .animate_step = t_animate_step,
  178. };
  179. struct usplash_theme usplash_theme_1024_768 = {
  180. .version = THEME_VERSION,
  181. .next = &usplash_theme_800_600,
  182. .ratio = USPLASH_4_3,
  183. /* Background and font */
  184. .pixmap = &pixmap_xbmc_1024_768,
  185. .font = &font_helvB10,
  186. /* Palette indexes */
  187. .background = 0x01,
  188. .progressbar_background = 0x00,
  189. .progressbar_foreground = 0x1E,
  190. /* Functions */
  191. .init = t_init,
  192. .clear_progressbar = t_clear_progressbar,
  193. .draw_progressbar = t_draw_progressbar,
  194. .animate_step = t_animate_step,
  195. };
  196. struct usplash_theme usplash_theme_800_600 = {
  197. .version = THEME_VERSION,
  198. .next = &usplash_theme_640_480,
  199. .ratio = USPLASH_4_3,
  200. /* Background and font */
  201. .pixmap = &pixmap_xbmc_800_600,
  202. .font = &font_helvB10,
  203. /* Palette indexes */
  204. .background = 0x01,
  205. .progressbar_background = 0x00,
  206. .progressbar_foreground = 0x1E,
  207. /* Functions */
  208. .init = t_init,
  209. .clear_progressbar = t_clear_progressbar,
  210. .draw_progressbar = t_draw_progressbar,
  211. .animate_step = t_animate_step,
  212. };
  213. struct usplash_theme usplash_theme_640_480 = {
  214. .version = THEME_VERSION,
  215. .next = NULL,
  216. .ratio = USPLASH_4_3,
  217. /* Background and font */
  218. .pixmap = &pixmap_xbmc_640_480,
  219. .font = &font_helvB10,
  220. /* Palette indexes */
  221. .background = 0x01,
  222. .progressbar_background = 0x00,
  223. .progressbar_foreground = 0x1E,
  224. /* Functions */
  225. .init = t_init,
  226. .clear_progressbar = t_clear_progressbar,
  227. .draw_progressbar = t_draw_progressbar,
  228. .animate_step = t_animate_step,
  229. };
  230. /** ---------------------------------------------------------- **/
  231. /* init usplash */
  232. void t_init(struct usplash_theme *theme) {
  233. // determine spinner position and dimensions
  234. spinner_height = pixmap_xbmc_spinner.height;
  235. spinner_part_width = pixmap_xbmc_spinner.width / spinner_num_steps;
  236. spinner_x = (theme->pixmap->width / 2) - (spinner_part_width / 2);
  237. spinner_y = (theme->pixmap->height / 2) + (((theme->pixmap->height / 2) / 4) / 2) - (pixmap_xbmc_spinner.height / 2);
  238. // set text box dimensions and size
  239. theme->text_width = 450;
  240. //theme->text_x = (theme->pixmap->width / 2) - (theme->text_width / 2);
  241. theme->text_x = (theme->pixmap->height * 0.65);
  242. theme->text_y = 50;
  243. theme->text_height = 40;
  244. // set theme color indexes
  245. theme->background = 0;
  246. theme->progressbar_background = 0;
  247. theme->progressbar_foreground = 254;
  248. theme->text_background = 0;
  249. theme->text_foreground = 254;
  250. theme->text_success = 254;
  251. theme->text_failure = 254;
  252. }
  253. /******
  254. * Animation callback - called 25 times per second by Usplash
  255. *
  256. * Param: struct usplash_theme* theme - theme being used
  257. * int pulsating - boolean int
  258. */
  259. void t_animate_step(struct usplash_theme* theme, int pulsating) {
  260. current_count = current_count + 1;
  261. // increase test int for slower spinning
  262. if(current_count == spinner_speed) {
  263. spinner(theme);
  264. current_count = 0;
  265. }
  266. }
  267. /********
  268. * Animate the spinner
  269. * helper function to aid in animation of spinner
  270. */
  271. void spinner(struct usplash_theme* theme) {
  272. current_step = current_step + 1;
  273. int x0 = (spinner_part_width * current_step) - spinner_part_width;
  274. int y0 = 0;
  275. // if current step > number of images in the spinner, then reset to beginning (at end or circular spinner)
  276. if(current_step >= spinner_num_steps) {
  277. current_step = 0;
  278. }
  279. // call usplash_put_part for the small or large spinner image
  280. usplash_put_part(spinner_x, spinner_y, spinner_part_width, spinner_height, &pixmap_xbmc_spinner, x0, y0);
  281. }
  282. /** not used for now **/
  283. void t_clear_progressbar(struct usplash_theme *theme) { }
  284. void t_draw_progressbar(struct usplash_theme *theme, int percentage) { }