lv_theme_oboo.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779
  1. /**
  2. * @file lv_theme_oboo.c
  3. *
  4. */
  5. /*********************
  6. * INCLUDES
  7. *********************/
  8. #include "lvgl/lvgl.h"
  9. #include "config.h"
  10. #if USE_OB_THEME_OBOO
  11. /*********************
  12. * DEFINES
  13. *********************/
  14. /**********************
  15. * TYPEDEFS
  16. **********************/
  17. /**********************
  18. * STATIC PROTOTYPES
  19. **********************/
  20. /**********************
  21. * STATIC VARIABLES
  22. **********************/
  23. static lv_theme_t theme;
  24. static lv_style_t def;
  25. /*Static style definitions*/
  26. static lv_style_t sb;
  27. /*Saved input parameters*/
  28. static uint16_t _hue;
  29. static lv_font_t * _font;
  30. /**********************
  31. * MACROS
  32. **********************/
  33. /**********************
  34. * STATIC FUNCTIONS
  35. **********************/
  36. static void basic_init(void)
  37. {
  38. static lv_style_t bg;
  39. static lv_style_t panel;
  40. lv_style_copy(&def, &lv_style_pretty); /*Initialize the default style*/
  41. def.body.border.opa = LV_OPA_COVER;
  42. def.text.font = _font;
  43. //def.text.color = LV_COLOR_HEX3(0x444);
  44. def.text.color = LV_COLOR_HEX(0xefefef);
  45. lv_style_copy(&bg, &def);
  46. // bg.body.main_color = LV_COLOR_WHITE;
  47. bg.body.main_color = LV_COLOR_BLACK;
  48. // bg.body.grad_color = LV_COLOR_WHITE;
  49. bg.body.grad_color = LV_COLOR_BLACK;
  50. bg.body.radius = 0;
  51. bg.body.border.width = 0;
  52. bg.body.shadow.width = 0;
  53. lv_style_copy(&panel, &bg);
  54. panel.body.radius = LV_DPI / 10;
  55. panel.body.border.width = 2;
  56. panel.body.border.color = lv_color_hsv_to_rgb(_hue, 30, 90);
  57. panel.body.border.opa = LV_OPA_COVER;
  58. // panel.body.shadow.width = 4;
  59. // panel.body.shadow.color = LV_COLOR_HEX3(0xddd);
  60. // panel.body.padding.hor = LV_DPI / 6;
  61. panel.body.padding.hor = 0;
  62. // panel.body.padding.ver = LV_DPI / 8;
  63. panel.body.padding.ver = 0;
  64. // panel.body.padding.inner = LV_DPI / 10;
  65. panel.body.padding.inner = LV_DPI / 10;
  66. lv_style_copy(&sb, &def);
  67. sb.body.main_color = lv_color_hsv_to_rgb(_hue, 30, 90);
  68. sb.body.grad_color = sb.body.main_color;
  69. sb.body.border.width = 0;
  70. sb.body.radius = LV_RADIUS_CIRCLE;
  71. sb.body.padding.inner = LV_DPI / 10;
  72. theme.bg = &bg;
  73. theme.panel = &panel;
  74. }
  75. static void cont_init(void)
  76. {
  77. #if USE_LV_CONT != 0
  78. theme.cont = theme.panel;
  79. #endif
  80. }
  81. static void btn_init(void)
  82. {
  83. #if USE_LV_BTN != 0
  84. static lv_style_t rel, pr, tgl_pr, ina;
  85. lv_style_copy(&rel, &def);
  86. rel.body.empty = 1;
  87. rel.body.radius = LV_RADIUS_CIRCLE;
  88. rel.body.border.width = 2;
  89. rel.body.border.color = lv_color_hsv_to_rgb(_hue, 40, 90);
  90. rel.body.border.opa = LV_OPA_COVER;
  91. // rel.body.shadow.width = 4;
  92. // rel.body.shadow.color = LV_COLOR_HEX3(0xddd);
  93. rel.body.padding.hor = LV_DPI / 4;
  94. rel.body.padding.ver = LV_DPI / 8;
  95. rel.text.color = lv_color_hsv_to_rgb(_hue, 40, 90);
  96. lv_style_copy(&pr, &rel);
  97. pr.body.border.color = lv_color_hsv_to_rgb(_hue, 40, 60);
  98. pr.text.color = lv_color_hsv_to_rgb(_hue, 40, 60);
  99. pr.body.shadow.width = 0;
  100. lv_style_copy(&tgl_pr, &pr);
  101. tgl_pr.body.border.color = lv_color_hsv_to_rgb(_hue, 40, 50);
  102. tgl_pr.text.color = lv_color_hsv_to_rgb(_hue, 40, 50);
  103. lv_style_copy(&ina, &tgl_pr);
  104. ina.body.border.color = LV_COLOR_HEX3(0xbbb);
  105. ina.text.color = LV_COLOR_HEX3(0xbbb);
  106. theme.btn.rel = &rel;
  107. theme.btn.pr = ≺
  108. theme.btn.tgl_rel = ≺
  109. theme.btn.tgl_pr = &tgl_pr;
  110. theme.btn.ina = &ina;
  111. #endif
  112. }
  113. static void label_init(void)
  114. {
  115. #if USE_LV_LABEL != 0
  116. static lv_style_t prim, sec, hint;
  117. lv_style_copy(&prim, &def);
  118. lv_style_copy(&sec, &def);
  119. lv_style_copy(&hint, &def);
  120. prim.text.color = LV_COLOR_HEX3(0x555);
  121. sec.text.color = lv_color_hsv_to_rgb(_hue, 50, 80);
  122. hint.text.color = lv_color_hsv_to_rgb(_hue, 25, 85);
  123. theme.label.prim = &prim;
  124. theme.label.sec = &sec;
  125. theme.label.hint = &hint;
  126. #endif
  127. }
  128. static void img_init(void)
  129. {
  130. #if USE_LV_IMG != 0
  131. static lv_style_t img_light, img_dark;
  132. lv_style_copy(&img_light, &def);
  133. img_light.image.color = lv_color_hsv_to_rgb(_hue, 15, 85);
  134. img_light.image.intense = LV_OPA_80;
  135. lv_style_copy(&img_dark, &def);
  136. img_light.image.color = lv_color_hsv_to_rgb(_hue, 85, 55);
  137. img_light.image.intense = LV_OPA_80;
  138. theme.img.light = &img_light;
  139. theme.img.dark = &img_dark;
  140. #endif
  141. }
  142. static void line_init(void)
  143. {
  144. #if USE_LV_LINE != 0
  145. theme.line.decor = &def;
  146. #endif
  147. }
  148. static void led_init(void)
  149. {
  150. #if USE_LV_LED != 0
  151. static lv_style_t led;
  152. lv_style_copy(&led, &lv_style_pretty_color);
  153. led.body.shadow.width = LV_DPI / 10;
  154. led.body.radius = LV_RADIUS_CIRCLE;
  155. led.body.border.width= LV_DPI / 30;
  156. led.body.border.opa = LV_OPA_30;
  157. led.body.main_color = lv_color_hsv_to_rgb(_hue, 60, 100);
  158. led.body.grad_color = lv_color_hsv_to_rgb(_hue, 60, 40);
  159. led.body.border.color = lv_color_hsv_to_rgb(_hue, 60, 60);
  160. led.body.shadow.color = lv_color_hsv_to_rgb(_hue, 80, 100);
  161. theme.led = &led;
  162. #endif
  163. }
  164. static void bar_init(void)
  165. {
  166. #if USE_LV_BAR
  167. static lv_style_t bg, indic;
  168. lv_style_copy(&bg, &def);
  169. bg.body.empty = 1;
  170. bg.body.radius = LV_RADIUS_CIRCLE;
  171. bg.body.border.width = 2;
  172. bg.body.border.opa = LV_OPA_COVER;
  173. bg.body.border.color = lv_color_hsv_to_rgb(_hue, 40, 90);
  174. lv_style_copy(&indic, &def);
  175. indic.body.radius = LV_RADIUS_CIRCLE;
  176. indic.body.main_color = lv_color_hsv_to_rgb(_hue, 40, 90);
  177. indic.body.grad_color = indic.body.main_color;
  178. indic.body.border.width = 0;
  179. indic.body.padding.hor = LV_DPI / 20;
  180. indic.body.padding.ver = LV_DPI / 20;
  181. theme.bar.bg = &bg;
  182. theme.bar.indic = &indic;
  183. #endif
  184. }
  185. static void slider_init(void)
  186. {
  187. #if USE_LV_SLIDER != 0
  188. static lv_style_t knob;
  189. lv_style_copy(&knob, &def);
  190. knob.body.main_color = theme.bar.indic->body.main_color;
  191. knob.body.grad_color = knob.body.main_color;
  192. knob.body.radius = LV_RADIUS_CIRCLE;
  193. knob.body.border.width = 0;
  194. theme.slider.bg = theme.bar.bg;
  195. theme.slider.indic = theme.bar.indic;
  196. theme.slider.knob = &knob;
  197. #endif
  198. }
  199. static void sw_init(void)
  200. {
  201. #if USE_LV_SW != 0
  202. static lv_style_t indic;
  203. lv_style_copy(&indic, theme.slider.indic);
  204. indic.body.radius = LV_RADIUS_CIRCLE;
  205. indic.body.main_color = lv_color_hsv_to_rgb(_hue, 15, 95);
  206. indic.body.grad_color = indic.body.main_color;
  207. indic.body.border.width = theme.slider.bg->body.border.width;
  208. indic.body.border.color = theme.slider.bg->body.border.color;
  209. indic.body.border.opa = theme.slider.bg->body.border.opa;
  210. indic.body.padding.hor = 0;
  211. indic.body.padding.ver = 0;
  212. theme.sw.bg = theme.slider.bg;
  213. theme.sw.indic = &indic;
  214. theme.sw.knob_off = theme.slider.knob;
  215. theme.sw.knob_on = theme.slider.knob;
  216. #endif
  217. }
  218. static void lmeter_init(void)
  219. {
  220. #if USE_LV_LMETER != 0
  221. static lv_style_t lmeter;
  222. lv_style_copy(&lmeter, &def);
  223. lmeter.line.color = LV_COLOR_HEX3(0xddd);
  224. lmeter.line.width = 2;
  225. lmeter.body.main_color = lv_color_hsv_to_rgb(_hue, 80, 70);
  226. lmeter.body.grad_color = lmeter.body.main_color;
  227. lmeter.body.padding.hor = LV_DPI / 8;
  228. theme.lmeter = &lmeter;
  229. #endif
  230. }
  231. static void gauge_init(void)
  232. {
  233. #if USE_LV_GAUGE != 0
  234. static lv_style_t gauge;
  235. lv_style_copy(&gauge, &def);
  236. gauge.line.color = lv_color_hsv_to_rgb(_hue, 50, 70);
  237. gauge.line.width = 2;
  238. gauge.body.main_color = LV_COLOR_HEX3(0x999);
  239. gauge.body.grad_color = gauge.body.main_color;
  240. gauge.body.padding.hor = LV_DPI / 12;
  241. gauge.body.border.color = LV_COLOR_HEX3(0x666); /*Needle middle color*/
  242. theme.gauge = &gauge;
  243. #endif
  244. }
  245. static void chart_init(void)
  246. {
  247. #if USE_LV_CHART
  248. theme.chart = theme.panel;
  249. #endif
  250. }
  251. static void cb_init(void)
  252. {
  253. #if USE_LV_CB != 0
  254. static lv_style_t rel ,pr, tgl_rel, tgl_pr, ina;
  255. lv_style_copy(&rel, &def);
  256. rel.body.radius = LV_DPI / 20;
  257. rel.body.shadow.width = 0;
  258. rel.body.border.width = 3;
  259. rel.body.border.opa = LV_OPA_COVER;
  260. rel.body.border.color = lv_color_hsv_to_rgb(_hue, 35, 80);
  261. rel.body.main_color = LV_COLOR_HEX3(0xfff);
  262. rel.body.grad_color = rel.body.main_color;
  263. lv_style_copy(&pr, &rel);
  264. pr.body.border.color = lv_color_hsv_to_rgb(_hue, 35, 70);
  265. lv_style_copy(&tgl_rel, &rel);
  266. tgl_rel.body.border.color = lv_color_hsv_to_rgb(_hue, 45, 80);
  267. tgl_rel.body.main_color = lv_color_hsv_to_rgb(_hue, 40, 90);
  268. tgl_rel.body.grad_color = tgl_rel.body.main_color;
  269. lv_style_copy(&tgl_pr, &rel);
  270. tgl_pr.body.border.color = lv_color_hsv_to_rgb(_hue, 45, 70);
  271. tgl_pr.body.main_color = lv_color_hsv_to_rgb(_hue, 40, 80);
  272. tgl_pr.body.grad_color = tgl_pr.body.main_color;
  273. lv_style_copy(&ina, &rel);
  274. ina.body.border.color = LV_COLOR_HEX3(0xaaa);
  275. theme.cb.bg = &lv_style_transp;
  276. theme.cb.box.rel = &rel;
  277. theme.cb.box.pr = ≺
  278. theme.cb.box.tgl_rel = &tgl_rel;
  279. theme.cb.box.tgl_pr = &tgl_pr;
  280. theme.cb.box.ina = &ina;
  281. #endif
  282. }
  283. static void btnm_init(void)
  284. {
  285. #if USE_LV_BTNM
  286. static lv_style_t bg, rel ,pr, tgl_rel, tgl_pr, ina;
  287. lv_style_copy(&bg, &lv_style_transp);
  288. bg.glass = 0;
  289. bg.body.padding.hor = 0;
  290. bg.body.padding.ver = 0;
  291. bg.body.padding.inner = LV_DPI / 15;
  292. bg.text.font = _font;
  293. lv_style_copy(&rel, &def);
  294. rel.body.empty = 1;
  295. rel.body.border.width = 0;
  296. lv_style_copy(&pr, &def);
  297. pr.body.empty = 1;
  298. pr.body.radius = LV_DPI / 1;
  299. pr.body.border.width = 2;
  300. pr.body.border.color = lv_color_hsv_to_rgb(_hue, 40, 60);
  301. pr.body.border.opa = LV_OPA_COVER;
  302. pr.text.color = lv_color_hsv_to_rgb(_hue, 40, 60);
  303. lv_style_copy(&tgl_rel, &pr);
  304. tgl_rel.body.empty = 0;
  305. tgl_rel.body.main_color = lv_color_hsv_to_rgb(_hue, 15, 95);
  306. tgl_rel.body.grad_color = tgl_rel.body.main_color;
  307. tgl_rel.body.border.width = 0;
  308. tgl_rel.text.color = lv_color_hsv_to_rgb(_hue, 60, 40);
  309. lv_style_copy(&tgl_pr, &tgl_rel);
  310. tgl_pr.body.main_color = lv_color_hsv_to_rgb(_hue, 30, 70);
  311. tgl_pr.body.grad_color = tgl_pr.body.main_color;
  312. lv_style_copy(&ina, &pr);
  313. ina.body.main_color = LV_COLOR_HEX3(0x888);
  314. ina.body.grad_color = tgl_pr.body.main_color;
  315. ina.text.color = LV_COLOR_HEX3(0x888);;
  316. theme.btnm.bg = &bg;
  317. theme.btnm.btn.rel = &rel;
  318. theme.btnm.btn.pr = ≺
  319. theme.btnm.btn.tgl_rel = &tgl_rel;
  320. theme.btnm.btn.tgl_pr = &tgl_pr;
  321. theme.btnm.btn.ina = &ina;
  322. #endif
  323. }
  324. static void kb_init(void)
  325. {
  326. #if USE_LV_KB
  327. static lv_style_t bg, rel ,pr, tgl_rel, tgl_pr, ina;
  328. lv_style_copy(&bg, &def);
  329. bg.body.main_color = LV_COLOR_HEX3(0x666);
  330. bg.body.grad_color = bg.body.main_color;
  331. bg.body.padding.hor = 0;
  332. bg.body.padding.ver = 0;
  333. bg.body.padding.inner = 0;
  334. bg.body.radius = 0;
  335. bg.body.border.width = 0;
  336. lv_style_copy(&rel, &def);
  337. rel.body.empty = 1;
  338. rel.body.radius = 0;
  339. rel.body.border.width = 1;
  340. rel.body.border.color = LV_COLOR_HEX3(0x888);
  341. rel.body.border.opa = LV_OPA_COVER;
  342. rel.text.color = LV_COLOR_WHITE;
  343. lv_style_copy(&pr, &def);
  344. pr.body.main_color = LV_COLOR_HEX3(0xeee);
  345. pr.body.grad_color = pr.body.main_color;
  346. pr.body.border.color = LV_COLOR_HEX3(0x888);
  347. pr.body.border.width = 1;
  348. pr.body.border.opa = LV_OPA_COVER;
  349. pr.body.radius = 0;
  350. pr.text.color = LV_COLOR_HEX3(0x666);
  351. lv_style_copy(&tgl_rel, &pr);
  352. tgl_rel.body.main_color = LV_COLOR_HEX3(0x999);
  353. tgl_rel.body.grad_color = tgl_rel.body.main_color;
  354. tgl_rel.text.color = LV_COLOR_WHITE;
  355. lv_style_copy(&tgl_pr, &pr);
  356. tgl_pr.body.main_color = LV_COLOR_HEX3(0xbbb);
  357. tgl_pr.body.grad_color = tgl_pr.body.main_color;
  358. tgl_pr.text.color = LV_COLOR_HEX3(0xddd);
  359. lv_style_copy(&ina, &pr);
  360. ina.body.main_color = LV_COLOR_HEX3(0x777);
  361. ina.body.grad_color = ina.body.main_color;
  362. ina.text.color = LV_COLOR_HEX3(0xbbb);
  363. theme.kb.bg = &bg;
  364. theme.kb.btn.rel = &rel;
  365. theme.kb.btn.pr = ≺
  366. theme.kb.btn.tgl_rel = &tgl_rel;
  367. theme.kb.btn.tgl_pr = &tgl_pr;
  368. theme.kb.btn.ina = &ina;
  369. #endif
  370. }
  371. static void mbox_init(void)
  372. {
  373. #if USE_LV_MBOX
  374. static lv_style_t bg, rel, pr;
  375. lv_style_copy(&bg, theme.panel);
  376. bg.body.main_color = lv_color_hsv_to_rgb(_hue, 10, 95);
  377. bg.body.grad_color = bg.body.main_color;
  378. bg.text.color = lv_color_hsv_to_rgb(_hue, 40, 25);
  379. lv_style_copy(&rel, &def);
  380. rel.body.main_color = lv_color_hsv_to_rgb(_hue, 25, 85);
  381. rel.body.grad_color = rel.body.main_color;
  382. rel.body.radius = LV_RADIUS_CIRCLE;
  383. rel.body.border.width = 2;
  384. rel.body.border.color = lv_color_hsv_to_rgb(_hue, 30, 70);
  385. rel.body.padding.hor = LV_DPI / 4;
  386. rel.body.padding.ver = LV_DPI / 8;
  387. rel.text.color = bg.text.color;
  388. lv_style_copy(&pr, &rel);
  389. pr.body.border.color = lv_color_hsv_to_rgb(_hue, 30, 90);
  390. pr.text.color = lv_color_hsv_to_rgb(_hue, 40, 40);
  391. pr.body.main_color = lv_color_hsv_to_rgb(_hue, 20, 85);
  392. pr.body.grad_color = pr.body.main_color;
  393. theme.mbox.bg = &bg;
  394. theme.mbox.btn.bg = &lv_style_transp;
  395. theme.mbox.btn.rel = &rel;
  396. theme.mbox.btn.pr = ≺
  397. #endif
  398. }
  399. static void page_init(void)
  400. {
  401. #if USE_LV_PAGE
  402. theme.page.bg = theme.panel;
  403. theme.page.scrl = &lv_style_transp;
  404. theme.page.sb = &sb;
  405. #endif
  406. }
  407. static void ta_init(void)
  408. {
  409. #if USE_LV_TA
  410. static lv_style_t oneline;
  411. lv_style_copy(&oneline, theme.panel);
  412. oneline.body.radius = LV_RADIUS_CIRCLE;
  413. // oneline.body.padding.ver = LV_DPI / 10;
  414. oneline.body.padding.ver = 0;
  415. oneline.body.shadow.width = 0;
  416. theme.ta.area = theme.panel;
  417. theme.ta.oneline = &oneline;
  418. theme.ta.cursor = NULL; /*Let library to calculate the cursor's style*/
  419. theme.ta.sb = &def;
  420. #endif
  421. }
  422. static void list_init(void)
  423. {
  424. #if USE_LV_LIST != 0
  425. static lv_style_t bg, rel, pr, tgl_rel, tgl_pr, ina;
  426. lv_style_copy(&bg, theme.panel);
  427. bg.body.padding.hor = 0;
  428. bg.body.padding.ver = 0;
  429. lv_style_copy(&rel, &def);
  430. rel.body.empty = 1;
  431. rel.body.border.width = 0;
  432. rel.body.padding.hor = LV_DPI / 8;
  433. rel.body.padding.ver = LV_DPI / 8;
  434. rel.text.color = LV_COLOR_HEX3(0x666);
  435. lv_style_copy(&pr, &rel);
  436. pr.text.color = theme.btn.pr->text.color;
  437. lv_style_copy(&tgl_rel, &rel);
  438. tgl_rel.text.color = lv_color_hsv_to_rgb(_hue, 50, 90);
  439. lv_style_copy(&tgl_pr, &rel);
  440. tgl_pr.text.color = theme.btn.tgl_pr->text.color;
  441. lv_style_copy(&ina, &rel);
  442. ina.text.color = theme.btn.ina->text.color;
  443. theme.list.sb = &sb;
  444. theme.list.bg = &bg;
  445. theme.list.scrl = &lv_style_transp_tight;
  446. theme.list.btn.rel = &rel;
  447. theme.list.btn.pr = ≺
  448. theme.list.btn.tgl_rel = &tgl_rel;
  449. theme.list.btn.tgl_pr = &tgl_pr;
  450. theme.list.btn.ina = &ina;
  451. #endif
  452. }
  453. static void ddlist_init(void)
  454. {
  455. #if USE_LV_DDLIST != 0
  456. static lv_style_t bg, sel;
  457. lv_style_copy(&bg, theme.panel);
  458. bg.text.line_space = LV_DPI / 8;
  459. bg.body.padding.hor = LV_DPI / 6;
  460. bg.body.padding.ver = LV_DPI / 8;
  461. bg.text.color = LV_COLOR_HEX3(0x666);
  462. lv_style_copy(&sel, &def);
  463. sel.body.empty = 1;
  464. sel.body.border.width = 0;
  465. sel.text.color = lv_color_hsv_to_rgb(_hue, 50, 80);
  466. theme.ddlist.bg = &bg;
  467. theme.ddlist.sel = &sel;
  468. theme.ddlist.sb = &def;
  469. #endif
  470. }
  471. static void roller_init(void)
  472. {
  473. #if USE_LV_ROLLER != 0
  474. static lv_style_t bg, sel;
  475. lv_style_copy(&bg, &def);
  476. bg.body.border.width = 0;
  477. bg.body.empty = 1;
  478. bg.text.line_space = LV_DPI / 6;
  479. bg.text.color = LV_COLOR_HEX3(0x999);
  480. lv_style_copy(&sel, theme.panel);
  481. sel.body.radius = LV_RADIUS_CIRCLE;
  482. sel.body.empty = 1;
  483. theme.roller.bg = &bg;
  484. theme.roller.sel = &sel;
  485. #endif
  486. }
  487. static void tabview_init(void)
  488. {
  489. #if USE_LV_TABVIEW != 0
  490. static lv_style_t btn_bg, indic, rel, pr, tgl_rel, tgl_pr;
  491. lv_style_copy(&btn_bg, &def);
  492. // btn_bg.body.empty = 1;
  493. btn_bg.body.empty = 1;
  494. btn_bg.body.border.width = 0;
  495. // btn_bg.body.border.width = 2;
  496. // btn_bg.body.border.part = LV_BORDER_BOTTOM;
  497. // btn_bg.body.border.color = lv_color_hsv_to_rgb(_hue, 10, 90);
  498. lv_style_copy(&indic, &def);
  499. // indic.body.padding.inner = LV_DPI / 16;
  500. indic.body.border.width = 0;
  501. indic.body.radius = LV_RADIUS_CIRCLE;
  502. indic.body.main_color = lv_color_hsv_to_rgb(_hue, 50, 80);
  503. indic.body.grad_color = indic.body.main_color;
  504. lv_style_copy(&rel, &def);
  505. rel.body.empty = 1;
  506. rel.body.border.width = 0;
  507. rel.text.color = LV_COLOR_HEX3(0x999);
  508. lv_style_copy(&pr, &rel);
  509. pr.text.color = LV_COLOR_HEX3(0x777);
  510. lv_style_copy(&tgl_rel, &rel);
  511. tgl_rel.text.color = lv_color_hsv_to_rgb(_hue, 50, 80);
  512. lv_style_copy(&tgl_pr, &rel);
  513. tgl_pr.text.color = lv_color_hsv_to_rgb(_hue, 50, 70);
  514. theme.tabview.bg = theme.bg;
  515. theme.tabview.indic = &indic;
  516. theme.tabview.btn.bg = &btn_bg;
  517. theme.tabview.btn.rel = &rel;
  518. theme.tabview.btn.pr = ≺
  519. theme.tabview.btn.tgl_rel = &tgl_rel;
  520. theme.tabview.btn.tgl_pr = &tgl_pr;
  521. #endif
  522. }
  523. static void cardview_init(void)
  524. {
  525. #if USE_OB_CARDVIEW != 0
  526. static lv_style_t btn_bg, bullet_act, bullet_ina;
  527. lv_style_copy(&btn_bg, &def);
  528. // btn_bg.body.empty = 1;
  529. btn_bg.body.empty = 1;
  530. btn_bg.body.border.width = 0;
  531. // btn_bg.body.border.width = 2;
  532. // btn_bg.body.border.part = LV_BORDER_BOTTOM;
  533. // btn_bg.body.border.color = lv_color_hsv_to_rgb(_hue, 10, 90);
  534. lv_style_copy(&bullet_ina, &lv_style_plain);
  535. bullet_ina.body.radius = LV_RADIUS_CIRCLE;
  536. bullet_ina.body.main_color = LV_COLOR_HEX3(0xaaa);
  537. bullet_ina.body.grad_color = LV_COLOR_HEX3(0xaaa);
  538. bullet_ina.body.padding.ver = - LV_DPI / 8; /*Vertical position of the bullets. < 0: bottom, > 0: top*/
  539. bullet_ina.body.padding.hor = LV_DPI / 3; /*The distance between the center of the bullets*/
  540. lv_style_copy(&bullet_act, &bullet_ina);
  541. bullet_act.body.main_color = LV_COLOR_HEX3(0xfff);
  542. bullet_act.body.grad_color = LV_COLOR_HEX3(0xfff);
  543. theme.cardview.bg = theme.bg;
  544. theme.cardview.bullet.ina = &bullet_ina;
  545. theme.cardview.bullet.act = &bullet_act;
  546. #endif
  547. }
  548. static void win_init(void)
  549. {
  550. #if USE_LV_WIN != 0
  551. static lv_style_t header, rel, pr;
  552. lv_style_copy(&header, &def);
  553. header.body.empty = 1;
  554. header.body.border.width = 2;
  555. header.body.border.part = LV_BORDER_BOTTOM;
  556. header.body.border.color = lv_color_hsv_to_rgb(_hue, 10, 90);
  557. header.text.color = LV_COLOR_HEX3(0x666);
  558. lv_style_copy(&rel, &def);
  559. rel.body.empty = 1;
  560. rel.body.border.width = 0;
  561. rel.text.color = LV_COLOR_HEX3(0x666);
  562. lv_style_copy(&pr, &rel);
  563. pr.text.color = LV_COLOR_HEX3(0x333);
  564. theme.win.bg = theme.panel;
  565. theme.win.sb = &sb;
  566. theme.win.header = &header;
  567. theme.win.content.bg = &lv_style_transp;
  568. theme.win.content.scrl = &lv_style_transp;
  569. theme.win.btn.rel = &rel;
  570. theme.win.btn.pr = &pr;
  571. #endif
  572. }
  573. /**********************
  574. * GLOBAL FUNCTIONS
  575. **********************/
  576. /**
  577. * Initialize the oboo theme
  578. * @param hue [0..360] hue value from HSV color space to define the theme's base color
  579. * @param font pointer to a font (NULL to use the default)
  580. * @return pointer to the initialized theme
  581. */
  582. lv_theme_t * lv_theme_oboo_init(uint16_t hue, lv_font_t *font)
  583. {
  584. if(font == NULL) font = LV_FONT_DEFAULT;
  585. _hue = hue;
  586. _font = font;
  587. /*For backward compatibility initialize all theme elements with a default style */
  588. uint16_t i;
  589. lv_style_t **style_p = (lv_style_t**) &theme;
  590. for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t*); i++) {
  591. *style_p = &def;
  592. style_p++;
  593. }
  594. basic_init();
  595. cont_init();
  596. btn_init();
  597. label_init();
  598. img_init();
  599. line_init();
  600. led_init();
  601. bar_init();
  602. slider_init();
  603. sw_init();
  604. lmeter_init();
  605. gauge_init();
  606. chart_init();
  607. cb_init();
  608. btnm_init();
  609. kb_init();
  610. mbox_init();
  611. page_init();
  612. ta_init();
  613. list_init();
  614. ddlist_init();
  615. roller_init();
  616. tabview_init();
  617. cardview_init();
  618. win_init();
  619. return &theme;
  620. }
  621. /**
  622. * Get a pointer to the theme
  623. * @return pointer to the theme
  624. */
  625. lv_theme_t * lv_theme_get_oboo(void)
  626. {
  627. return &theme;
  628. }
  629. /**********************
  630. * STATIC FUNCTIONS
  631. **********************/
  632. #endif