-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Expand file tree
/
Copy pathmaterialui.c
More file actions
12358 lines (11177 loc) · 461 KB
/
materialui.c
File metadata and controls
12358 lines (11177 loc) · 461 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2014-2017 - Jean-André Santoni
* Copyright (C) 2016-2019 - Brad Parker
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <limits.h>
#include <compat/posix_string.h>
#include <compat/strcasestr.h>
#include <compat/strl.h>
#include <file/file_path.h>
#include <formats/image.h>
#include <gfx/math/matrix_4x4.h>
#include <string/stdstring.h>
#include <lists/string_list.h>
#include <encodings/utf.h>
#include <retro_inline.h>
#include <retro_math.h>
#ifdef HAVE_CONFIG_H
#include "../../config.h"
#endif
#include "../../frontend/frontend_driver.h"
#include "../../ui/ui_companion_driver.h"
#include "../menu_driver.h"
#include "../menu_screensaver.h"
#include "../../gfx/gfx_animation.h"
#include "../../gfx/gfx_thumbnail.h"
#include "../../msg_hash_lbl_str.h"
#include "../../core_info.h"
#include "../../configuration.h"
#include "../../runtime_file.h"
#include "../../file_path_special.h"
#include "../../input/input_osk.h"
#include "../../list_special.h"
#include "../../tasks/tasks_internal.h"
#ifdef HAVE_AUDIOMIXER
#include "../../audio/audio_driver.h"
#endif
#ifdef HAVE_CHEEVOS
#include "../../cheevos/cheevos_menu.h"
#endif
/* Defines the 'device independent pixel' base
* unit reference size for all UI elements.
* 212 px corresponds to the the baseline standard
* 22 inch, 96 DPI display */
#define MUI_DIP_BASE_UNIT_SIZE (212.0f)
/* Spacer for left scrolling ticker text */
#if defined(__APPLE__)
/* UTF-8 support is currently broken on Apple devices... */
#define MUI_TICKER_SPACER TICKER_SPACER_DEFAULT
#else
/* <EM SPACE><BULLET><EM SPACE>
* UCN equivalent: "\u2003\u2022\u2003" */
#define MUI_TICKER_SPACER "\xE2\x80\x83\xE2\x80\xA2\xE2\x80\x83"
#endif
/* Specifies minimum period (in usec) between
* tab switch events when input repeat is
* active (i.e. when navigating between top level
* menu categories by *holding* left/right on
* RetroPad or keyboard)
* > Note: We want to set a value of 300 ms
* here, but doing so leads to bad pacing when
* running at 60 Hz (due to random frame time
* deviations - input repeat cycles always take
* slightly more or less than 300 ms, so tab
* switches occur every n or (n + 1) frames,
* which gives the appearance of stuttering).
* Reducing the delay by 1 ms accommodates
* any timing fluctuations, resulting in
* smooth motion */
#define MUI_TAB_SWITCH_REPEAT_DELAY (299000)
/* Animation defines */
#define MUI_ANIM_DURATION_SCROLL (166.66667f)
#define MUI_ANIM_DURATION_SCROLL_RESET (83.333333f)
#define MUI_OVERSCROLL_RESISTANCE 0.35f
#define MUI_OVERSCROLL_MAX_FRACTION 0.25f
#define MUI_OVERSCROLL_SPRING_STIFFNESS 70.0f
#define MUI_OVERSCROLL_SPRING_DAMPING 14.0f
#define MUI_OVERSCROLL_STOP_DISTANCE 0.5f
#define MUI_OVERSCROLL_STOP_VELOCITY 5.0f
/* According to Material UI specifications, animations
* that affect a large portion of the screen should
* have a duration of between 250ms and 300ms. This
* should therefore be the value used for menu
* transitions - but even 250ms feels too slow...
* We compromise by setting a time of 200ms, which
* is the same as the 'short press' duration.
* This is reasonably fast, without making slide
* animations too 'jarring'... */
#define MUI_ANIM_DURATION_MENU_TRANSITION 200.0f
/* Set a baseline aspect ratio of 4:3 for thumbnail
* images */
#define MUI_THUMBNAIL_DEFAULT_ASPECT_RATIO 1.3333333f
/* Default thumbnail type to select when force-enabling
* secondary thumbnails
* > 1 == Named_Snaps */
#define MUI_DEFAULT_SECONDARY_THUMBNAIL_TYPE 1
/* Default thumbnail type to select when force-enabling
* secondary thumbnails *if* primary thumbnail is
* already set to MUI_DEFAULT_SECONDARY_THUMBNAIL_TYPE
* > 3 == Named_Boxarts */
#define MUI_DEFAULT_SECONDARY_THUMBNAIL_FALLBACK_TYPE 3
/* Thumbnail stream delay when performing standard
* menu navigation */
#define MUI_THUMBNAIL_STREAM_DELAY_DEFAULT (16.66667f * 3)
/* Thumbnail stream delay when performing 'fast'
* navigation by dragging the scrollbar
* > Must increase stream delay, otherwise it's
* too easy to enqueue vast numbers of image
* requests... */
#define MUI_THUMBNAIL_STREAM_DELAY_SCROLLBAR_DRAG MUI_ANIM_DURATION_SCROLL
/* Thumbnail stream delay when viewing
* 'desktop'-layout playlists
* > In this case, thumbnails are loaded
* as the entry selection is changed. We
* therefore want the stream delay to match
* the scroll animation duration */
#define MUI_THUMBNAIL_STREAM_DELAY_PLAYLIST_DESKTOP MUI_ANIM_DURATION_SCROLL
/* Maximum number of menu tabs that can be shown on
* the navigation bar */
#define MUI_NAV_BAR_NUM_MENU_TABS_MAX 3
/* Number of action tabs shown on the navigation bar */
#define MUI_NAV_BAR_NUM_ACTION_TABS 2
#define MUI_BATTERY_PERCENT_MAX_LENGTH 12
#define MUI_TIMEDATE_MAX_LENGTH 255
/* Allow force enabling secondary thumbnail */
#define MUI_FORCE_ENABLE_SECONDARY 0
/* Forward declarations */
extern int action_switch_thumbnail(const char *path, const char *label, unsigned type, size_t idx);
/* Defines the various types of supported menu
* list views
* - MUI_LIST_VIEW_DEFAULT is the standard for
* all non-playlist views
* - MUI_LIST_VIEW_PLAYLIST is for playlists
* without thumbnails
* - Everything else is for playlists with fancy
* thumbnail-based layouts */
enum materialui_list_view_type
{
MUI_LIST_VIEW_DEFAULT = 0,
MUI_LIST_VIEW_SAVESTATE,
MUI_LIST_VIEW_PLAYLIST,
MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_SMALL,
MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_MEDIUM,
MUI_LIST_VIEW_PLAYLIST_THUMB_LIST_LARGE,
MUI_LIST_VIEW_PLAYLIST_THUMB_DUAL_ICON,
MUI_LIST_VIEW_PLAYLIST_THUMB_DESKTOP
};
/* Defines the various types of icon that
* can be associated with menu entries */
enum materialui_node_icon_type
{
MUI_ICON_TYPE_NONE = 0,
MUI_ICON_TYPE_INTERNAL,
MUI_ICON_TYPE_MENU_EXPLORE,
MUI_ICON_TYPE_PLAYLIST,
MUI_ICON_TYPE_MENU_CONTENTLESS_CORE,
MUI_ICON_TYPE_ACHIEVEMENT,
MUI_ICON_TYPE_APPICON
};
/* Defines all standard menu textures */
enum
{
MUI_TEXTURE_POINTER = 0,
MUI_TEXTURE_BACK,
MUI_TEXTURE_SWITCH_ON,
MUI_TEXTURE_SWITCH_OFF,
MUI_TEXTURE_SWITCH_BG,
MUI_TEXTURE_TAB_MAIN,
MUI_TEXTURE_TAB_PLAYLISTS,
MUI_TEXTURE_TAB_SETTINGS,
MUI_TEXTURE_TAB_BACK,
MUI_TEXTURE_TAB_RESUME,
MUI_TEXTURE_KEY,
MUI_TEXTURE_KEY_HOVER,
MUI_TEXTURE_FOLDER,
MUI_TEXTURE_PARENT_DIRECTORY,
MUI_TEXTURE_ARCHIVE,
MUI_TEXTURE_IMAGE,
MUI_TEXTURE_MUSIC,
MUI_TEXTURE_VIDEO,
MUI_TEXTURE_QUIT,
MUI_TEXTURE_HELP,
MUI_TEXTURE_HISTORY,
MUI_TEXTURE_INFO,
MUI_TEXTURE_ADD,
MUI_TEXTURE_SETTINGS,
MUI_TEXTURE_FILE,
MUI_TEXTURE_PLAYLIST,
MUI_TEXTURE_UPDATER,
MUI_TEXTURE_QUICKMENU,
MUI_TEXTURE_NETPLAY,
MUI_TEXTURE_CORES,
MUI_TEXTURE_SHADERS,
MUI_TEXTURE_CONTROLS,
MUI_TEXTURE_CLOSE,
MUI_TEXTURE_CORE_OPTIONS,
MUI_TEXTURE_CORE_CHEAT_OPTIONS,
MUI_TEXTURE_RESUME,
MUI_TEXTURE_RESTART,
MUI_TEXTURE_ADD_TO_FAVORITES,
MUI_TEXTURE_RUN,
MUI_TEXTURE_RENAME,
MUI_TEXTURE_DATABASE,
MUI_TEXTURE_ADD_TO_MIXER,
MUI_TEXTURE_SCAN,
MUI_TEXTURE_REMOVE,
MUI_TEXTURE_START_CORE,
MUI_TEXTURE_LOAD_STATE,
MUI_TEXTURE_SAVE_STATE,
MUI_TEXTURE_UNDO_LOAD_STATE,
MUI_TEXTURE_UNDO_SAVE_STATE,
MUI_TEXTURE_STATE_SLOT,
MUI_TEXTURE_PLAY_REPLAY,
MUI_TEXTURE_RECORD_REPLAY,
MUI_TEXTURE_HALT_REPLAY,
MUI_TEXTURE_REPLAY_SLOT,
MUI_TEXTURE_TAKE_SCREENSHOT,
MUI_TEXTURE_CONFIGURATIONS,
MUI_TEXTURE_LOAD_CONTENT,
MUI_TEXTURE_DISK,
MUI_TEXTURE_EJECT,
MUI_TEXTURE_CHECKMARK,
MUI_TEXTURE_SEARCH,
MUI_TEXTURE_BATTERY_CRITICAL,
MUI_TEXTURE_BATTERY_20,
MUI_TEXTURE_BATTERY_30,
MUI_TEXTURE_BATTERY_50,
MUI_TEXTURE_BATTERY_60,
MUI_TEXTURE_BATTERY_80,
MUI_TEXTURE_BATTERY_90,
MUI_TEXTURE_BATTERY_100,
MUI_TEXTURE_BATTERY_CHARGING,
MUI_TEXTURE_SWITCH_VIEW,
MUI_TEXTURE_LAST
};
/* Defines the various types of menu tab that can
* be shown on the navigation bar */
enum materialui_nav_bar_menu_tab_type
{
MUI_NAV_BAR_MENU_TAB_NONE = 0,
MUI_NAV_BAR_MENU_TAB_MAIN,
MUI_NAV_BAR_MENU_TAB_PLAYLISTS,
MUI_NAV_BAR_MENU_TAB_SETTINGS
};
/* Defines the various types of action tab that can
* be shown on the navigation bar */
enum materialui_nav_bar_action_tab_type
{
MUI_NAV_BAR_ACTION_TAB_NONE = 0,
MUI_NAV_BAR_ACTION_TAB_BACK,
MUI_NAV_BAR_ACTION_TAB_RESUME
};
/* Defines navigation bar draw locations
* Note: Only bottom, right and 'hidden'
* are supported at present... */
enum materialui_nav_bar_location_type
{
MUI_NAV_BAR_LOCATION_BOTTOM = 0,
MUI_NAV_BAR_LOCATION_RIGHT,
MUI_NAV_BAR_LOCATION_HIDDEN
};
/* Defines all possible entry value types
* > Note: These are not necessarily 'values',
* but they correspond to the object drawn in
* the 'value' location when rendering
* menu lists */
enum materialui_entry_value_type
{
MUI_ENTRY_VALUE_NONE = 0,
MUI_ENTRY_VALUE_TEXT,
MUI_ENTRY_VALUE_SWITCH_ON,
MUI_ENTRY_VALUE_SWITCH_OFF,
MUI_ENTRY_VALUE_CHECKMARK
};
/* Defines common positions when referencing
* the list of currently on screen menu entries
* > Used to specify a target when the current
* selection is off screen, and we wish to
* automatically move the selection marker
* to a specific on screen location */
enum materialui_onscreen_entry_position_type
{
MUI_ONSCREEN_ENTRY_FIRST = 0,
MUI_ONSCREEN_ENTRY_LAST,
MUI_ONSCREEN_ENTRY_CENTRE
};
/* Theme colours */
typedef struct
{
/* Text (& small inline icon) colours */
uint32_t on_sys_bar;
uint32_t on_header;
uint32_t list_text;
uint32_t list_text_highlighted;
uint32_t list_hint_text;
uint32_t list_hint_text_highlighted;
uint32_t status_bar_text;
/* Background colours */
uint32_t sys_bar_background;
uint32_t title_bar_background;
uint32_t list_background;
uint32_t list_highlighted_background;
uint32_t nav_bar_background;
uint32_t surface_background;
uint32_t thumbnail_background;
uint32_t side_bar_background;
uint32_t status_bar_background;
/* List icon colours */
uint32_t list_icon;
uint32_t list_switch_on;
uint32_t list_switch_on_background;
uint32_t list_switch_off;
uint32_t list_switch_off_background;
/* Navigation bar icon colours */
uint32_t nav_bar_icon_active;
uint32_t nav_bar_icon_passive;
uint32_t nav_bar_icon_disabled;
/* Screensaver */
uint32_t screensaver_tint;
/* Misc. colours */
uint32_t header_shadow;
uint32_t landscape_border_shadow;
uint32_t status_bar_shadow;
uint32_t selection_marker_shadow;
uint32_t scrollbar;
uint32_t divider;
uint32_t screen_fade;
uint32_t missing_thumbnail_icon;
float header_shadow_opacity;
float landscape_border_shadow_opacity;
float status_bar_shadow_opacity;
float selection_marker_shadow_opacity;
float screen_fade_opacity;
} materialui_theme_t;
typedef struct
{
/* Text */
uint32_t sys_bar_text;
uint32_t header_text;
uint32_t list_text;
uint32_t list_text_highlighted;
uint32_t list_hint_text;
uint32_t list_hint_text_highlighted;
uint32_t status_bar_text;
uint32_t disabled_text;
/* Screensaver */
uint32_t screensaver_tint;
/* Background colours */
float sys_bar_background[16];
float title_bar_background[16];
float list_background[16];
float list_highlighted_background[16];
float nav_bar_background[16];
float surface_background[16];
float thumbnail_background[16];
float side_bar_background[16];
float status_bar_background[16];
/* System bar + header icon colours */
float sys_bar_icon[16];
float header_icon[16];
/* List icon colours */
float list_icon[16];
float list_switch_on[16];
float list_switch_on_background[16];
float list_switch_off[16];
float list_switch_off_background[16];
/* Navigation bar icon colours */
float nav_bar_icon_active[16];
float nav_bar_icon_passive[16];
float nav_bar_icon_disabled[16];
/* Misc. colours */
float header_shadow[16];
float landscape_border_shadow_left[16];
float landscape_border_shadow_right[16];
float status_bar_shadow[16];
float selection_marker_shadow_top[16];
float selection_marker_shadow_bottom[16];
float scrollbar[16];
float divider[16];
float entry_divider[16];
float screen_fade[16];
float missing_thumbnail_icon[16];
float landscape_border_shadow_opacity;
float status_bar_shadow_opacity;
float selection_marker_shadow_opacity;
float screen_fade_opacity;
} materialui_colors_t;
/* This structure holds auxiliary information for
* each menu entry (physical on-screen size/position,
* icon data, thumbnail data, etc.) */
typedef struct
{
/* Thumbnail containers */
struct
{
gfx_thumbnail_t primary; /* uintptr_t alignment */
gfx_thumbnail_t secondary; /* uintptr_t alignment */
} thumbnails;
unsigned icon_texture_index;
float entry_width;
float entry_height;
float text_height;
float x;
float y;
enum materialui_node_icon_type icon_type;
} materialui_node_t;
/* This structure holds all runtime parameters
* associated with landscape optimisation
* (enable state, border width, nominal
* additional horizontal margin/padding for
* menu entries) */
typedef struct
{
unsigned border_width;
unsigned entry_margin;
bool enabled;
} materialui_landscape_optimization_t;
/* This structure holds all runtime parameters
* associated with a navigation bar menu tab */
typedef struct
{
unsigned texture_index;
enum materialui_nav_bar_menu_tab_type type;
bool active;
} materialui_nav_bar_menu_tab_t;
/* This structure holds all runtime parameters
* associated with a navigation bar action tab */
typedef struct
{
unsigned texture_index;
enum materialui_nav_bar_action_tab_type type;
bool enabled;
} materialui_nav_bar_action_tab_t;
/* This structure holds all runtime parameters for
* the navigation bar */
typedef struct
{
unsigned width;
unsigned divider_width;
unsigned selection_marker_width;
size_t active_menu_tab_index;
size_t last_active_menu_tab_index;
size_t num_menu_tabs;
materialui_nav_bar_action_tab_t back_tab; /* unsigned alignment */
materialui_nav_bar_action_tab_t resume_tab; /* unsigned alignment */
materialui_nav_bar_menu_tab_t menu_tabs[MUI_NAV_BAR_NUM_MENU_TABS_MAX]; /* unsigned alignment */
enum materialui_nav_bar_location_type location;
} materialui_nav_bar_t;
/* This structure holds all runtime parameters for
* the scrollbar */
typedef struct
{
int x;
int y;
unsigned width;
unsigned height;
} materialui_scrollbar_t;
/* This structure is used to cache system bar
* string data (+ metadata) to improve rendering
* performance */
typedef struct
{
int battery_percent_width;
int timedate_width;
char battery_percent_str[MUI_BATTERY_PERCENT_MAX_LENGTH];
char timedate_str[MUI_TIMEDATE_MAX_LENGTH];
} materialui_sys_bar_cache_t;
/* This structure holds all runtime parameters
* for the status bar (used to display auxiliary
* information at the bottom of the current list
* view). At present, this enables metadata for
* the currently selected playlist entry to be
* shown when using the 'desktop'-layout */
typedef struct
{
size_t last_selected;
unsigned height;
float delay_timer;
float alpha;
char str[MENU_LABEL_MAX_LENGTH];
char runtime_fallback_str[NAME_MAX_LENGTH];
char last_played_fallback_str[NAME_MAX_LENGTH];
} materialui_status_bar_t;
/* Contains the file path(s) and texture pointer
* of a single playlist icon */
typedef struct
{
char *playlist_file;
char *image_file;
uintptr_t image;
} materialui_playlist_icon_t;
/* Contains icon data for all installed
* playlists */
typedef struct
{
materialui_playlist_icon_t *icons;
size_t size;
} materialui_playlist_icons_t;
enum materialui_handle_flags
{
MUI_FLAG_IS_PORTRAIT = (1 << 0),
MUI_FLAG_NEED_COMPUTE = (1 << 1),
MUI_FLAG_SHOW_MOUSE = (1 << 2),
MUI_FLAG_SHOW_SCREENSAVER = (1 << 3),
MUI_FLAG_IS_PLAYLISTS_TAB = (1 << 4),
MUI_FLAG_IS_PLAYLIST = (1 << 5),
MUI_FLAG_IS_EXPLORE_LIST = (1 << 6),
MUI_FLAG_IS_FILE_LIST = (1 << 7),
MUI_FLAG_IS_DROPDOWN_LIST = (1 << 8),
MUI_FLAG_IS_CORE_UPDATER_LIST = (1 << 9),
MUI_FLAG_IS_SAVESTATE_LIST = (1 << 10),
MUI_FLAG_LAST_SHOW_NAVBAR = (1 << 11),
MUI_FLAG_LAST_AUTO_ROTATE_NAVBAR = (1 << 12),
MUI_FLAG_MENU_STACK_FLUSHED = (1 << 13),
/* Used to track scroll animations */
MUI_FLAG_SCROLL_ANIMATION_ACTIVE = (1 << 14),
MUI_FLAG_USE_SMOOTH_TICKER = (1 << 15),
MUI_FLAG_TOUCH_FEEDBACK_UPDATE_SELECTION = (1 << 16),
MUI_FLAG_PRIMARY_THUMBNAIL_AVAILABLE = (1 << 17),
MUI_FLAG_SECONDARY_THUMBNAIL_ENABLED = (1 << 18),
MUI_FLAG_PRIMARY_THUMBNAIL_BLOCKED = (1 << 19),
MUI_FLAG_SECONDARY_THUMBNAIL_BLOCKED = (1 << 20),
MUI_FLAG_SHOW_FULLSCREEN_THUMBNAILS = (1 << 21),
MUI_FLAG_SHOW_SELECTION_MARKER_SHADOW = (1 << 22),
MUI_FLAG_STATUSBAR_ENABLED = (1 << 23),
MUI_FLAG_STATUSBAR_CACHED = (1 << 24),
MUI_FLAG_SCROLLBAR_ACTIVE = (1 << 25),
MUI_FLAG_SCROLLBAR_DRAGGED = (1 << 26),
MUI_FLAG_NAVBAR_MENU_NAVIGATION_WRAPPED = (1 << 27),
MUI_FLAG_COL_DIVIDER_IS_LIST_BG = (1 << 28),
MUI_FLAG_OVERSCROLL_ACTIVE = (1 << 29)
};
typedef struct materialui_handle
{
/* Pointer info */
menu_input_pointer_t pointer; /* int64_t alignment */
/* Use common tickers for all text
* > Simplifies configuration and
* improves performance */
gfx_animation_ctx_ticker_t ticker; /* uint64_t alignment */
gfx_animation_ctx_ticker_smooth_t ticker_smooth; /* uint64_t alignment */
/* Keeps track of the last time tabs were switched
* via a MENU_ACTION_LEFT/MENU_ACTION_RIGHT event */
retro_time_t last_tab_switch_time; /* uint64_t alignment */
playlist_t *playlist; /* ptr alignment */
/* Font data */
struct
{
font_data_impl_t title; /* ptr alignment */
font_data_impl_t list; /* ptr alignment */
font_data_impl_t hint; /* ptr alignment */
} font_data;
struct
{
gfx_thumbnail_t savestate; /* uintptr_t alignment */
} thumbnails;
size_t (*word_wrap)(
char *s, size_t len,
const char *src, size_t src_len,
int line_width, int wideglyph_width, unsigned max_lines);
struct
{
materialui_playlist_icons_t playlist; /* ptr alignment */
uintptr_t bg;
uintptr_t list[MUI_TEXTURE_LAST];
} textures;
menu_screensaver_t *screensaver;
/* Status bar */
materialui_status_bar_t status_bar; /* size_t alignment */
size_t last_stack_size;
size_t first_onscreen_entry;
size_t last_onscreen_entry;
/* Used to track scroll animations */
size_t scroll_animation_selection;
size_t fullscreen_thumbnail_selection;
/* > When viewing 'desktop'-layout playlists,
* need to cache the index of the last
* selected entry so we can keep displaying
* its thumbnails while waiting for next
* to load after the selection has changed */
size_t desktop_thumbnail_last_selection;
unsigned last_width;
unsigned last_height;
unsigned sys_bar_height;
unsigned title_bar_height;
unsigned header_shadow_height;
unsigned selection_marker_shadow_height;
unsigned icon_size;
unsigned sys_bar_icon_size;
unsigned margin;
unsigned sys_bar_margin;
unsigned entry_divider_width;
unsigned sublabel_gap;
unsigned sublabel_padding;
/* Navigation bar parameters
* Note: layout width and height are convenience
* variables used when determining usable width/
* height for all other menu elements - e.g. when
* navigation bar is at the bottom of the screen
* nav_bar_screen_width is zero */
unsigned nav_bar_layout_width;
unsigned nav_bar_layout_height;
unsigned ticker_x_offset;
unsigned ticker_str_width;
unsigned draw_entry_delay;
/* Touch feedback animation parameters */
unsigned touch_feedback_selection;
unsigned thumbnail_width_max;
unsigned thumbnail_height_max;
materialui_landscape_optimization_t
landscape_optimization; /* unsigned alignment */
materialui_nav_bar_t nav_bar; /* unsigned alignment */
/* Colour theme parameters */
materialui_colors_t colors; /* uint32_t alignment */
uint32_t flags;
uint32_t context_generation;
size_t playlist_selection[NAME_MAX_LENGTH];
size_t playlist_selection_ptr;
uint8_t mainmenu_selection_ptr;
uint8_t settings_selection_ptr;
/* Scrollbar parameters */
materialui_scrollbar_t scrollbar; /* int alignment */
int cursor_size;
/* Cached system bar data */
materialui_sys_bar_cache_t sys_bar_cache; /* int alignment */
float last_scale_factor;
float dip_base_unit_size;
/* Y position of the vertical scroll */
float scroll_y;
float content_height;
float pointer_start_scroll_y;
float transition_alpha;
float transition_x_offset;
float thumbnail_stream_delay;
float fullscreen_thumbnail_alpha;
float touch_feedback_alpha;
float overscroll_velocity;
float overscroll_target;
int16_t pointer_start_x;
int16_t pointer_start_y;
bool transition_alpha_lock;
/* Colour theme parameters */
enum materialui_color_theme color_theme;
enum materialui_landscape_layout_optimization_type
last_landscape_layout_optimization;
enum materialui_list_view_type list_view_type;
char msgbox[1024];
char menu_title[NAME_MAX_LENGTH];
char fullscreen_thumbnail_label[NAME_MAX_LENGTH];
char sysicons_path[PATH_MAX_LENGTH];
char icons_path[PATH_MAX_LENGTH];
char savestate_thumbnail_file_path[PATH_MAX_LENGTH];
} materialui_handle_t;
static void hex32_to_rgba_normalized(uint32_t hex, float* rgba, float alpha)
{
rgba[0] = rgba[4] = rgba[8] = rgba[12] = ((hex >> 16) & 0xFF) * (1.0f / 255.0f); /* r */
rgba[1] = rgba[5] = rgba[9] = rgba[13] = ((hex >> 8 ) & 0xFF) * (1.0f / 255.0f); /* g */
rgba[2] = rgba[6] = rgba[10] = rgba[14] = ((hex >> 0 ) & 0xFF) * (1.0f / 255.0f); /* b */
rgba[3] = rgba[7] = rgba[11] = rgba[15] = alpha;
}
static const materialui_theme_t *materialui_get_theme(enum materialui_color_theme color_theme)
{
static const materialui_theme_t materialui_theme_cutie_blue = {
/* Text (& small inline icon) colours */
0xC4C4C4, /* on_sys_bar */
0xFFFFFF, /* on_header */
0xFFFFFF, /* list_text */
0xFFFFFF, /* list_text_highlighted */
0xDADADA, /* list_hint_text */
0xEEEEEE, /* list_hint_text_highlighted */
0xDADADA, /* status_bar_text */
/* Background colours */
0x000000, /* sys_bar_background */
0x353535, /* title_bar_background */
0x191919, /* list_background */
0x3399FF, /* list_highlighted_background */
0x282828, /* nav_bar_background */
0x333333, /* surface_background */
0x000000, /* thumbnail_background */
0x333333, /* side_bar_background */
0x0E0E0E, /* status_bar_background */
/* List icon colours */
0xFFFFFF, /* list_icon */
0x3399FF, /* list_switch_on */
0x454545, /* list_switch_on_background */
0x454545, /* list_switch_off */
0x414141, /* list_switch_off_background */
/* Navigation bar icon colours */
0x3399FF, /* nav_bar_icon_active */
0xDADADA, /* nav_bar_icon_passive */
0x000000, /* nav_bar_icon_disabled */
/* Screensaver */
0xFFFFFF, /* screensaver_tint */
/* Misc. colours */
0x000000, /* header_shadow */
0x000000, /* landscape_border_shadow */
0x000000, /* status_bar_shadow */
0x000000, /* selection_marker_shadow */
0x727272, /* scrollbar */
0x727272, /* divider */
0x000000, /* screen_fade */
0xDADADA, /* missing_thumbnail_icon */
0.3f, /* header_shadow_opacity */
0.45f, /* landscape_border_shadow_opacity */
0.9f, /* status_bar_shadow_opacity */
0.1f, /* selection_marker_shadow_opacity */
0.75f /* screen_fade_opacity */
};
static const materialui_theme_t materialui_theme_cutie_cyan = {
/* Text (& small inline icon) colours */
0xC4C4C4, /* on_sys_bar */
0xFFFFFF, /* on_header */
0xFFFFFF, /* list_text */
0xFFFFFF, /* list_text_highlighted */
0xDADADA, /* list_hint_text */
0xEEEEEE, /* list_hint_text_highlighted */
0xDADADA, /* status_bar_text */
/* Background colours */
0x000000, /* sys_bar_background */
0x353535, /* title_bar_background */
0x191919, /* list_background */
0x39859A, /* list_highlighted_background */
0x282828, /* nav_bar_background */
0x333333, /* surface_background */
0x000000, /* thumbnail_background */
0x333333, /* side_bar_background */
0x0E0E0E, /* status_bar_background */
/* List icon colours */
0xFFFFFF, /* list_icon */
0x39859A, /* list_switch_on */
0x454545, /* list_switch_on_background */
0x454545, /* list_switch_off */
0x414141, /* list_switch_off_background */
/* Navigation bar icon colours */
0x39859A, /* nav_bar_icon_active */
0xDADADA, /* nav_bar_icon_passive */
0x000000, /* nav_bar_icon_disabled */
/* Screensaver */
0xFFFFFF, /* screensaver_tint */
/* Misc. colours */
0x000000, /* header_shadow */
0x000000, /* landscape_border_shadow */
0x000000, /* status_bar_shadow */
0x000000, /* selection_marker_shadow */
0x727272, /* scrollbar */
0x727272, /* divider */
0x000000, /* screen_fade */
0xDADADA, /* missing_thumbnail_icon */
0.3f, /* header_shadow_opacity */
0.45f, /* landscape_border_shadow_opacity */
0.9f, /* status_bar_shadow_opacity */
0.1f, /* selection_marker_shadow_opacity */
0.75f /* screen_fade_opacity */
};
static const materialui_theme_t materialui_theme_blue = {
/* Text (& small inline icon) colours */
0xDEDEDE, /* on_sys_bar */
0xFFFFFF, /* on_header */
0x212121, /* list_text */
0x000000, /* list_text_highlighted */
0x666666, /* list_hint_text */
0x212121, /* list_hint_text_highlighted */
0x000000, /* status_bar_text */
/* Background colours */
0x0069c0, /* sys_bar_background */
0x2196f3, /* title_bar_background */
0xF5F5F6, /* list_background */
0xc1d5e0, /* list_highlighted_background */
0xE1E2E1, /* nav_bar_background */
0xFFFFFF, /* surface_background */
0x242424, /* thumbnail_background */
0xc1d5e0, /* side_bar_background */
0x9F9FA0, /* status_bar_background */
/* List icon colours */
0x0069c0, /* list_icon */
0x2196f3, /* list_switch_on */
0x6ec6ff, /* list_switch_on_background */
0x808e95, /* list_switch_off */
0xbabdbe, /* list_switch_off_background */
/* Navigation bar icon colours */
0x0069c0, /* nav_bar_icon_active */
0x9ea7aa, /* nav_bar_icon_passive */
0xffffff, /* nav_bar_icon_disabled */
/* Screensaver */
0xF5F5F6, /* screensaver_tint */
/* Misc. colours */
0x000000, /* header_shadow */
0x000000, /* landscape_border_shadow */
0x000000, /* status_bar_shadow */
0x000000, /* selection_marker_shadow */
0x0069c0, /* scrollbar */
0x9ea7aa, /* divider */
0x000000, /* screen_fade */
0xF5F5F6, /* missing_thumbnail_icon */
0.3f, /* header_shadow_opacity */
0.35f, /* landscape_border_shadow_opacity */
0.45f, /* status_bar_shadow_opacity */
0.1f, /* selection_marker_shadow_opacity */
0.75f /* screen_fade_opacity */
};
static const materialui_theme_t materialui_theme_blue_grey = {
/* Text (& small inline icon) colours */
0xDEDEDE, /* on_sys_bar */
0xFFFFFF, /* on_header */
0x212121, /* list_text */
0x000000, /* list_text_highlighted */
0x666666, /* list_hint_text */
0x212121, /* list_hint_text_highlighted */
0x000000, /* status_bar_text */
/* Background colours */
0x34515e, /* sys_bar_background */
0x607d8b, /* title_bar_background */
0xF5F5F6, /* list_background */
0xe0e0e0, /* list_highlighted_background */
0xE1E2E1, /* nav_bar_background */
0xFFFFFF, /* surface_background */
0x242424, /* thumbnail_background */
0xe0e0e0, /* side_bar_background */
0x9F9FA0, /* status_bar_background */
/* List icon colours */
0x34515e, /* list_icon */
0x607d8b, /* list_switch_on */
0x8eacbb, /* list_switch_on_background */
0xbcbcbc, /* list_switch_off */
0xc7c7c7, /* list_switch_off_background */
/* Navigation bar icon colours */
0x34515e, /* nav_bar_icon_active */
0xaeaeae, /* nav_bar_icon_passive */
0xffffff, /* nav_bar_icon_disabled */
/* Screensaver */
0xF5F5F6, /* screensaver_tint */
/* Misc. colours */
0x000000, /* header_shadow */
0x000000, /* landscape_border_shadow */
0x000000, /* status_bar_shadow */
0x000000, /* selection_marker_shadow */
0x34515e, /* scrollbar */
0xc2c2c2, /* divider */
0x000000, /* screen_fade */
0xF5F5F6, /* missing_thumbnail_icon */
0.3f, /* header_shadow_opacity */
0.35f, /* landscape_border_shadow_opacity */
0.45f, /* status_bar_shadow_opacity */
0.2f, /* selection_marker_shadow_opacity */
0.75f /* screen_fade_opacity */
};
static const materialui_theme_t materialui_theme_dark_blue = {
/* Text (& small inline icon) colours */
0xC4C4C4, /* on_sys_bar */
0xFFFFFF, /* on_header */
0xDEDEDE, /* list_text */
0xFFFFFF, /* list_text_highlighted */
0x999999, /* list_hint_text */
0xDEDEDE, /* list_hint_text_highlighted */
0x999999, /* status_bar_text */
/* Background colours */
0x000000, /* sys_bar_background */
0x1F1F1F, /* title_bar_background */
0x121212, /* list_background */
0x34515e, /* list_highlighted_background */
0x242424, /* nav_bar_background */
0x1D1D1D, /* surface_background */
0x000000, /* thumbnail_background */
0x1D1D1D, /* side_bar_background */
0x242424, /* status_bar_background */
/* List icon colours */
0x90caf9, /* list_icon */
0x64b5f6, /* list_switch_on */
0x5d99c6, /* list_switch_on_background */
0x4b636e, /* list_switch_off */
0x607d8b, /* list_switch_off_background */
/* Navigation bar icon colours */
0x6ec6ff, /* nav_bar_icon_active */
0xA5B4BB, /* nav_bar_icon_passive */
0x000000, /* nav_bar_icon_disabled */
/* Screensaver */
0xDEDEDE, /* screensaver_tint */
/* Misc. colours */
0x000000, /* header_shadow */
0x3B3B3B, /* landscape_border_shadow */
0x000000, /* status_bar_shadow */
0x3B3B3B, /* selection_marker_shadow */
0x90caf9, /* scrollbar */
0x607d8b, /* divider */
0x000000, /* screen_fade */
0xDEDEDE, /* missing_thumbnail_icon */
0.3f, /* header_shadow_opacity */
0.45f, /* landscape_border_shadow_opacity */
0.8f, /* status_bar_shadow_opacity */
0.2f, /* selection_marker_shadow_opacity */
0.75f /* screen_fade_opacity */
};
static const materialui_theme_t materialui_theme_green = {
/* Text (& small inline icon) colours */
0xDEDEDE, /* on_sys_bar */
0xFFFFFF, /* on_header */
0x212121, /* list_text */
0x000000, /* list_text_highlighted */
0x666666, /* list_hint_text */
0x212121, /* list_hint_text_highlighted */
0x000000, /* status_bar_text */
/* Background colours */
0x087f23, /* sys_bar_background */
0x4caf50, /* title_bar_background */
0xF5F5F6, /* list_background */
0xdcedc8, /* list_highlighted_background */
0xE1E2E1, /* nav_bar_background */
0xFFFFFF, /* surface_background */
0x242424, /* thumbnail_background */
0xdcedc8, /* side_bar_background */
0x9F9FA0, /* status_bar_background */
/* List icon colours */
0x087f23, /* list_icon */
0x4caf50, /* list_switch_on */
0x80e27e, /* list_switch_on_background */
0xaabb97, /* list_switch_off */
0xbec5b7, /* list_switch_off_background */
/* Navigation bar icon colours */
0x087f23, /* nav_bar_icon_active */
0xaeaeae, /* nav_bar_icon_passive */