Skip to content

Commit 48f0dd6

Browse files
committed
Use universal themese scaled according to DPI_MUL
* Resolution-specific themes are still supported
1 parent 4b66bcb commit 48f0dd6

7 files changed

+72
-550
lines changed

Android.mk

+7-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ LOCAL_SRC_FILES:= \
1717
pong.c \
1818
progressdots.c \
1919
multirom_ui_themes.c \
20+
themes/multirom_ui_landscape.c \
21+
themes/multirom_ui_portrait.c \
2022
fstab.c
2123

2224
ifeq ($(ARCH_ARM_HAVE_NEON),true)
@@ -52,14 +54,17 @@ LOCAL_SRC_FILES += input_$(MR_INPUT_TYPE).c
5254

5355
ifeq ($(DEVICE_RESOLUTION),)
5456
$(info DEVICE_RESOLUTION was not specified)
57+
else ifneq ($(wildcard $(multirom_local_path)/themes/multirom_ui_$(DEVICE_RESOLUTION).c),)
58+
LOCAL_SRC_FILES += themes/multirom_ui_$(DEVICE_RESOLUTION).c
59+
LOCAL_CFLAGS += -DMULTIROM_THEME_$(DEVICE_RESOLUTION)
5560
endif
56-
LOCAL_SRC_FILES += themes/multirom_ui_$(DEVICE_RESOLUTION).c
57-
LOCAL_CFLAGS += -DMULTIROM_THEME_$(DEVICE_RESOLUTION)
5861

5962
ifneq ($(LANDSCAPE_RESOLUTION),)
63+
ifneq ($(wildcard $(multirom_local_path)/themes/multirom_ui_$(LANDSCAPE_RESOLUTION).c),)
6064
LOCAL_SRC_FILES += themes/multirom_ui_$(LANDSCAPE_RESOLUTION).c
6165
LOCAL_CFLAGS += -DMULTIROM_THEME_$(LANDSCAPE_RESOLUTION)
6266
endif
67+
endif
6368
ifneq ($(TW_DEFAULT_ROTATION),)
6469
MULTIROM_DEFAULT_ROTATION := $(TW_DEFAULT_ROTATION)
6570
endif

multirom_ui_themes.c

+16-13
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "multirom_ui_themes.h"
2020
#include "multirom.h"
2121
#include "util.h"
22+
#include "log.h"
2223

2324
multirom_themes_info *multirom_ui_init_themes(void)
2425
{
@@ -31,18 +32,9 @@ multirom_themes_info *multirom_ui_init_themes(void)
3132
extern struct multirom_theme theme_info_ ## RES; \
3233
list_add(&theme_info_ ## RES, &i->themes);
3334

34-
#ifdef MULTIROM_THEME_800x1280
35-
ADD_THEME(800x1280);
36-
#endif
37-
#ifdef MULTIROM_THEME_1280x800
38-
ADD_THEME(1280x800);
39-
#endif
40-
#ifdef MULTIROM_THEME_1200x1920
41-
ADD_THEME(1200x1920);
42-
#endif
43-
#ifdef MULTIROM_THEME_1920x1200
44-
ADD_THEME(1920x1200);
45-
#endif
35+
// universal themes which scale according to DPI_MUL
36+
ADD_THEME(landscape);
37+
ADD_THEME(portrait);
4638
return i;
4739
}
4840

@@ -58,10 +50,21 @@ multirom_theme *multirom_ui_select_theme(multirom_themes_info *i, int w, int h)
5850
if(i->themes == NULL)
5951
return NULL;
6052

53+
multirom_theme *universal = NULL;
54+
const int uni_type = (w > h) ? TH_LANDSCAPE : TH_PORTRAIT;
55+
6156
multirom_theme **itr;
6257
for(itr = i->themes; *itr; ++itr)
58+
{
6359
if((*itr)->width == w && (*itr)->height == h)
6460
return *itr;
6561

66-
return NULL;
62+
if((*itr)->width == uni_type)
63+
universal = *itr;
64+
}
65+
66+
if(universal)
67+
INFO("Using universal theme (%d)\n", uni_type);
68+
69+
return universal;
6770
}

multirom_ui_themes.h

+7-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
#include "progressdots.h"
2424
#include "listview.h"
2525

26+
// universal themes has these as width and height,
27+
// instead of real resolution
28+
#define TH_PORTRAIT (-1)
29+
#define TH_LANDSCAPE (-2)
30+
2631
typedef struct
2732
{
2833
listview *list;
@@ -52,8 +57,8 @@ typedef struct
5257

5358
struct multirom_theme
5459
{
55-
uint16_t width;
56-
uint16_t height;
60+
int16_t width;
61+
int16_t height;
5762

5863
void (*destroy)(multirom_theme_data *t);
5964
void (*init_header)(multirom_theme_data *t);

themes/multirom_ui_1280x800.c

-242
This file was deleted.

0 commit comments

Comments
 (0)