diff options
Diffstat (limited to 'apps/recorder/widgets.c')
-rw-r--r-- | apps/recorder/widgets.c | 115 |
1 files changed, 12 insertions, 103 deletions
diff --git a/apps/recorder/widgets.c b/apps/recorder/widgets.c index 4008d2b4c2..7ac647024a 100644 --- a/apps/recorder/widgets.c +++ b/apps/recorder/widgets.c | |||
@@ -23,7 +23,7 @@ | |||
23 | #ifdef HAVE_LCD_BITMAP | 23 | #ifdef HAVE_LCD_BITMAP |
24 | 24 | ||
25 | /* Valid dimensions return true, invalid false */ | 25 | /* Valid dimensions return true, invalid false */ |
26 | bool valid_dimensions(int x, int y, int width, int height) | 26 | static bool valid_dimensions(int x, int y, int width, int height) |
27 | { | 27 | { |
28 | if((x < 0) || (x + width > LCD_WIDTH) || | 28 | if((x < 0) || (x + width > LCD_WIDTH) || |
29 | (y < 0) || (y + height > LCD_HEIGHT)) | 29 | (y < 0) || (y + height > LCD_HEIGHT)) |
@@ -34,107 +34,6 @@ bool valid_dimensions(int x, int y, int width, int height) | |||
34 | return true; | 34 | return true; |
35 | } | 35 | } |
36 | 36 | ||
37 | void init_bar(int x, int y, int width, int height) | ||
38 | { | ||
39 | /* draw box */ | ||
40 | lcd_drawrect(x, y, width, height); | ||
41 | |||
42 | /* clear edge pixels */ | ||
43 | lcd_clearpixel(x, y); | ||
44 | lcd_clearpixel((x + width - 1), y); | ||
45 | lcd_clearpixel(x, (y + height - 1)); | ||
46 | lcd_clearpixel((x + width - 1), (y + height - 1)); | ||
47 | |||
48 | /* clear pixels in progress bar */ | ||
49 | lcd_clearrect(x + 1, y + 1, width - 2, height - 2); | ||
50 | } | ||
51 | |||
52 | /* | ||
53 | * Print a progress bar | ||
54 | */ | ||
55 | void progressbar(int x, int y, int width, int height, int percent, | ||
56 | int direction) | ||
57 | { | ||
58 | int pos; | ||
59 | |||
60 | /* check position and dimensions */ | ||
61 | if (!valid_dimensions(x, y, width, height)) | ||
62 | return; | ||
63 | |||
64 | init_bar(x, y, width, height); | ||
65 | |||
66 | /* draw bar */ | ||
67 | pos = percent; | ||
68 | if(pos < 0) | ||
69 | pos = 0; | ||
70 | if(pos > 100) | ||
71 | pos = 100; | ||
72 | |||
73 | switch (direction) | ||
74 | { | ||
75 | case Grow_Right: | ||
76 | pos=(width - 2) * pos / 100; | ||
77 | lcd_fillrect(x + 1, y + 1, pos, height - 2); | ||
78 | break; | ||
79 | case Grow_Left: | ||
80 | pos=(width - 2) * (100 - pos) / 100; | ||
81 | lcd_fillrect(x + pos, y + 1, width - 1 - pos, height - 2); | ||
82 | break; | ||
83 | case Grow_Down: | ||
84 | pos=(height - 2) * pos / 100; | ||
85 | lcd_fillrect(x + 1, y + 1, width - 2, pos); | ||
86 | break; | ||
87 | case Grow_Up: | ||
88 | pos=(height - 2) * (100 - pos) / 100; | ||
89 | lcd_fillrect(x + 1, y + pos, width - 2, height - 1 - pos); | ||
90 | break; | ||
91 | } | ||
92 | } | ||
93 | |||
94 | |||
95 | /* | ||
96 | * Print a slidebar bar | ||
97 | */ | ||
98 | void slidebar(int x, int y, int width, int height, int percent, int direction) | ||
99 | { | ||
100 | int pos; | ||
101 | |||
102 | /* check position and dimensions */ | ||
103 | if (!valid_dimensions(x, y, width, height)) | ||
104 | return; | ||
105 | |||
106 | init_bar(x, y, width, height); | ||
107 | |||
108 | /* draw knob */ | ||
109 | pos = percent; | ||
110 | if(pos < 0) | ||
111 | pos = 0; | ||
112 | if(pos > 100) | ||
113 | pos = 100; | ||
114 | |||
115 | switch (direction) | ||
116 | { | ||
117 | case Grow_Right: | ||
118 | pos = (width - height) * pos / 100; | ||
119 | break; | ||
120 | case Grow_Left: | ||
121 | pos=(width - height) * (100 - pos) / 100; | ||
122 | break; | ||
123 | case Grow_Down: | ||
124 | pos=(height - width) * pos / 100; | ||
125 | break; | ||
126 | case Grow_Up: | ||
127 | pos=(height - width) * (100 - pos) / 100; | ||
128 | break; | ||
129 | } | ||
130 | |||
131 | if(direction == Grow_Left || direction == Grow_Right) | ||
132 | lcd_fillrect(x + pos + 1, y + 1, height - 2, height - 2); | ||
133 | else | ||
134 | lcd_fillrect(x + 1, y + pos + 1, width - 2, width - 2); | ||
135 | } | ||
136 | |||
137 | |||
138 | /* | 37 | /* |
139 | * Print a scroll bar | 38 | * Print a scroll bar |
140 | */ | 39 | */ |
@@ -150,7 +49,17 @@ void scrollbar(int x, int y, int width, int height, int items, int min_shown, | |||
150 | if (!valid_dimensions(x, y, width, height)) | 49 | if (!valid_dimensions(x, y, width, height)) |
151 | return; | 50 | return; |
152 | 51 | ||
153 | init_bar(x, y, width, height); | 52 | /* draw box */ |
53 | lcd_drawrect(x, y, width, height); | ||
54 | |||
55 | /* clear edge pixels */ | ||
56 | lcd_clearpixel(x, y); | ||
57 | lcd_clearpixel((x + width - 1), y); | ||
58 | lcd_clearpixel(x, (y + height - 1)); | ||
59 | lcd_clearpixel((x + width - 1), (y + height - 1)); | ||
60 | |||
61 | /* clear pixels in progress bar */ | ||
62 | lcd_clearrect(x + 1, y + 1, width - 2, height - 2); | ||
154 | 63 | ||
155 | /* min should be min */ | 64 | /* min should be min */ |
156 | if(min_shown < max_shown) { | 65 | if(min_shown < max_shown) { |