diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/recorder/widgets.c | 78 |
1 files changed, 3 insertions, 75 deletions
diff --git a/apps/recorder/widgets.c b/apps/recorder/widgets.c index 278917da4f..f06ac4402f 100644 --- a/apps/recorder/widgets.c +++ b/apps/recorder/widgets.c | |||
@@ -18,8 +18,7 @@ | |||
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | #include <lcd.h> | 19 | #include <lcd.h> |
20 | #include <limits.h> | 20 | #include <limits.h> |
21 | 21 | #include "scrollbar.h" | |
22 | #include "widgets.h" | ||
23 | 22 | ||
24 | #ifdef HAVE_LCD_BITMAP | 23 | #ifdef HAVE_LCD_BITMAP |
25 | 24 | ||
@@ -29,79 +28,8 @@ | |||
29 | void scrollbar(int x, int y, int width, int height, int items, int min_shown, | 28 | void scrollbar(int x, int y, int width, int height, int items, int min_shown, |
30 | int max_shown, int orientation) | 29 | int max_shown, int orientation) |
31 | { | 30 | { |
32 | int min; | 31 | gui_scrollbar_draw(&screens[SCREEN_MAIN],x,y,width,height, |
33 | int max; | 32 | items,min_shown, max_shown, orientation); |
34 | int inner_len; | ||
35 | int start; | ||
36 | int size; | ||
37 | |||
38 | /* draw box */ | ||
39 | lcd_drawrect(x, y, width, height); | ||
40 | |||
41 | lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | ||
42 | |||
43 | /* clear edge pixels */ | ||
44 | lcd_drawpixel(x, y); | ||
45 | lcd_drawpixel((x + width - 1), y); | ||
46 | lcd_drawpixel(x, (y + height - 1)); | ||
47 | lcd_drawpixel((x + width - 1), (y + height - 1)); | ||
48 | |||
49 | /* clear pixels in progress bar */ | ||
50 | lcd_fillrect(x + 1, y + 1, width - 2, height - 2); | ||
51 | |||
52 | /* min should be min */ | ||
53 | if(min_shown < max_shown) { | ||
54 | min = min_shown; | ||
55 | max = max_shown; | ||
56 | } | ||
57 | else { | ||
58 | min = max_shown; | ||
59 | max = min_shown; | ||
60 | } | ||
61 | |||
62 | /* limit min and max */ | ||
63 | if(min < 0) | ||
64 | min = 0; | ||
65 | if(min > items) | ||
66 | min = items; | ||
67 | |||
68 | if(max < 0) | ||
69 | max = 0; | ||
70 | if(max > items) | ||
71 | max = items; | ||
72 | |||
73 | if (orientation == VERTICAL) | ||
74 | inner_len = height - 2; | ||
75 | else | ||
76 | inner_len = width - 2; | ||
77 | |||
78 | /* avoid overflows */ | ||
79 | while (items > (INT_MAX / inner_len)) { | ||
80 | items >>= 1; | ||
81 | min >>= 1; | ||
82 | max >>= 1; | ||
83 | } | ||
84 | |||
85 | /* calc start and end of the knob */ | ||
86 | if (items > 0 && items > (max - min)) { | ||
87 | size = inner_len * (max - min) / items; | ||
88 | if (size == 0) { /* width of knob is null */ | ||
89 | size = 1; | ||
90 | start = (inner_len - 1) * min / items; | ||
91 | } else { | ||
92 | start = (inner_len - size) * min / (items - (max - min)); | ||
93 | } | ||
94 | } else { /* if null draw full bar */ | ||
95 | size = inner_len; | ||
96 | start = 0; | ||
97 | } | ||
98 | |||
99 | lcd_set_drawmode(DRMODE_SOLID); | ||
100 | |||
101 | if(orientation == VERTICAL) | ||
102 | lcd_fillrect(x + 1, y + start + 1, width - 2, size); | ||
103 | else | ||
104 | lcd_fillrect(x + start + 1, y + 1, size, height - 2); | ||
105 | } | 33 | } |
106 | 34 | ||
107 | /* | 35 | /* |