diff options
author | Daniel Stenberg <daniel@haxx.se> | 2002-08-01 13:29:30 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2002-08-01 13:29:30 +0000 |
commit | 57e2fb1f3769a8be74c25217a360fb27d48822bb (patch) | |
tree | 79bcd10f9592107b9fc40cc3ad0e5805e55d109a /firmware/drivers/lcd.c | |
parent | 7769ad2982ce958e0c3df66cd3011c0c6aa6221e (diff) | |
download | rockbox-57e2fb1f3769a8be74c25217a360fb27d48822bb.tar.gz rockbox-57e2fb1f3769a8be74c25217a360fb27d48822bb.zip |
Markus Braun's progressbar and slidebar code
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1510 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/lcd.c')
-rw-r--r-- | firmware/drivers/lcd.c | 138 |
1 files changed, 138 insertions, 0 deletions
diff --git a/firmware/drivers/lcd.c b/firmware/drivers/lcd.c index 5a08b55930..5e86647280 100644 --- a/firmware/drivers/lcd.c +++ b/firmware/drivers/lcd.c | |||
@@ -1051,6 +1051,144 @@ void lcd_getfontsize(unsigned int font, int *width, int *height) | |||
1051 | } | 1051 | } |
1052 | } | 1052 | } |
1053 | 1053 | ||
1054 | /* | ||
1055 | * Print a progress bar | ||
1056 | */ | ||
1057 | void lcd_progressbar(int x, int y, int width, int height, int percent, int direction) | ||
1058 | { | ||
1059 | int pos; | ||
1060 | int i,j; | ||
1061 | |||
1062 | /* draw horizontal lines */ | ||
1063 | for(i=x+1;i<=x+width-2;i++) { | ||
1064 | DRAW_PIXEL(i,y); | ||
1065 | DRAW_PIXEL(i,(y+height-1)); | ||
1066 | } | ||
1067 | |||
1068 | /* draw vertical lines */ | ||
1069 | for(i=1;i<height;i++) { | ||
1070 | DRAW_PIXEL(x,(y+i)); | ||
1071 | DRAW_PIXEL((x+width-1),(y+i)); | ||
1072 | } | ||
1073 | |||
1074 | /* clear edge pixels */ | ||
1075 | CLEAR_PIXEL(x,y); | ||
1076 | CLEAR_PIXEL((x+width-1),y); | ||
1077 | CLEAR_PIXEL(x,(y+height-1)); | ||
1078 | CLEAR_PIXEL((x+width-1),(y+height-1)); | ||
1079 | |||
1080 | /* clear pixels in progress bar */ | ||
1081 | for(i=1;i<=width-2;i++) { | ||
1082 | for(j=1;j<=height-2;j++) { | ||
1083 | CLEAR_PIXEL((x+i),(y+j)); | ||
1084 | CLEAR_PIXEL((x+i),(y+j)); | ||
1085 | } | ||
1086 | } | ||
1087 | |||
1088 | /* draw bar */ | ||
1089 | pos=percent; | ||
1090 | if(pos<0) | ||
1091 | pos=0; | ||
1092 | if(pos>100) | ||
1093 | pos=100; | ||
1094 | |||
1095 | switch (direction) | ||
1096 | { | ||
1097 | case BAR_RIGHT: | ||
1098 | pos=(width-2)*pos/100; | ||
1099 | for(i=1;i<=pos;i++) | ||
1100 | for(j=1;j<height-1;j++) | ||
1101 | DRAW_PIXEL((x+i),(y+j)); | ||
1102 | break; | ||
1103 | case BAR_LEFT: | ||
1104 | pos=(width-2)*(100-pos)/100; | ||
1105 | for(i=pos+1;i<=width-2;i++) | ||
1106 | for(j=1;j<height-1;j++) | ||
1107 | DRAW_PIXEL((x+i),(y+j)); | ||
1108 | break; | ||
1109 | case BAR_DOWN: | ||
1110 | pos=(height-2)*pos/100; | ||
1111 | for(i=1;i<=pos;i++) | ||
1112 | for(j=1;j<width-1;j++) | ||
1113 | DRAW_PIXEL((x+j),(y+i)); | ||
1114 | break; | ||
1115 | case BAR_UP: | ||
1116 | pos=(height-2)*(100-pos)/100; | ||
1117 | for(i=pos+1;i<=height-2;i++) | ||
1118 | for(j=1;j<width-1;j++) | ||
1119 | DRAW_PIXEL((x+j),(y+i)); | ||
1120 | break; | ||
1121 | } | ||
1122 | |||
1123 | } | ||
1124 | |||
1125 | |||
1126 | /* | ||
1127 | * Print a slidebar bar | ||
1128 | */ | ||
1129 | void lcd_slidebar(int x, int y, int width, int height, int percent, int direction) | ||
1130 | { | ||
1131 | int pos; | ||
1132 | int i,j; | ||
1133 | |||
1134 | /* draw horizontal lines */ | ||
1135 | for(i=x+1;i<=x+width-2;i++) { | ||
1136 | DRAW_PIXEL(i,y); | ||
1137 | DRAW_PIXEL(i,(y+height-1)); | ||
1138 | } | ||
1139 | |||
1140 | /* draw vertical lines */ | ||
1141 | for(i=1;i<height;i++) { | ||
1142 | DRAW_PIXEL(x,(y+i)); | ||
1143 | DRAW_PIXEL((x+width-1),(y+i)); | ||
1144 | } | ||
1145 | |||
1146 | /* clear edge pixels */ | ||
1147 | CLEAR_PIXEL(x,y); | ||
1148 | CLEAR_PIXEL((x+width-1),y); | ||
1149 | CLEAR_PIXEL(x,(y+height-1)); | ||
1150 | CLEAR_PIXEL((x+width-1),(y+height-1)); | ||
1151 | |||
1152 | /* clear pixels in progress bar */ | ||
1153 | for(i=1;i<=width-2;i++) | ||
1154 | for(j=1;j<=height-2;j++) { | ||
1155 | CLEAR_PIXEL((x+i),(y+j)); | ||
1156 | CLEAR_PIXEL((x+i),(y+j)); | ||
1157 | } | ||
1158 | |||
1159 | /* draw point */ | ||
1160 | pos=percent; | ||
1161 | if(pos<0) | ||
1162 | pos=0; | ||
1163 | if(pos>100) | ||
1164 | pos=100; | ||
1165 | |||
1166 | switch (direction) | ||
1167 | { | ||
1168 | case BAR_RIGHT: | ||
1169 | pos=(width-height-1)*pos/100; | ||
1170 | break; | ||
1171 | case BAR_LEFT: | ||
1172 | pos=(width-height-1)*(100-pos)/100; | ||
1173 | break; | ||
1174 | case BAR_DOWN: | ||
1175 | pos=(height-width-1)*pos/100; | ||
1176 | break; | ||
1177 | case BAR_UP: | ||
1178 | pos=(height-width-1)*(100-pos)/100; | ||
1179 | break; | ||
1180 | } | ||
1181 | |||
1182 | if(direction == BAR_LEFT || direction == BAR_RIGHT) | ||
1183 | for(i=1;i<height;i++) | ||
1184 | for(j=1;j<height;j++) | ||
1185 | DRAW_PIXEL((x+pos+i),(y+j)); | ||
1186 | else | ||
1187 | for(i=1;i<width;i++) | ||
1188 | for(j=1;j<width;j++) | ||
1189 | DRAW_PIXEL((x+i),(y+pos+j)); | ||
1190 | } | ||
1191 | |||
1054 | #else | 1192 | #else |
1055 | /* no LCD defined, no code to use */ | 1193 | /* no LCD defined, no code to use */ |
1056 | #endif | 1194 | #endif |