1
0
Fork 0
forked from len0rd/rockbox

Use scrollbar widget for the sliders instead of custom drawing routines.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8761 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dan Everton 2006-02-21 08:59:59 +00:00
parent ed5f612c26
commit 1b5030cb9f

View file

@ -33,7 +33,6 @@
#include "screens.h" #include "screens.h"
#include "icons.h" #include "icons.h"
#include "font.h" #include "font.h"
#include "widgets.h"
#include "lang.h" #include "lang.h"
#include "sprintf.h" #include "sprintf.h"
#include "talk.h" #include "talk.h"
@ -45,6 +44,7 @@
#include "talk.h" #include "talk.h"
#include "screen_access.h" #include "screen_access.h"
#include "keyboard.h" #include "keyboard.h"
#include "gui/scrollbar.h"
/* Key definitions */ /* Key definitions */
#if (CONFIG_KEYPAD == IRIVER_H100_PAD || \ #if (CONFIG_KEYPAD == IRIVER_H100_PAD || \
@ -345,9 +345,6 @@ static bool eq_advanced_menu(void)
return result; return result;
} }
#define SLIDER_KNOB_HEIGHT 6
#define SLIDER_KNOB_WIDTH 4
enum eq_slider_mode { enum eq_slider_mode {
GAIN, GAIN,
CUTOFF, CUTOFF,
@ -360,22 +357,8 @@ enum eq_type {
HIGH_SHELF HIGH_SHELF
}; };
/* Draw a slider */
static void draw_slider(const struct screen * screen, int x, int y,
int width, int steps, int current_step)
{
int knob_x = ((width * 100 / steps) * current_step) / 100
+ (SLIDER_KNOB_WIDTH / 2);
/* Draw groove */
screen->fillrect(x, y + 2, width, 2);
/* Draw knob */
screen->fillrect(x + knob_x, y, SLIDER_KNOB_WIDTH, SLIDER_KNOB_HEIGHT);
}
/* Draw the UI for a whole EQ band */ /* Draw the UI for a whole EQ band */
static int draw_eq_slider(const struct screen * screen, int x, int y, static int draw_eq_slider(struct screen * screen, int x, int y,
int width, int cutoff, int q, int gain, bool selected, int width, int cutoff, int q, int gain, bool selected,
enum eq_slider_mode mode, enum eq_type type) enum eq_slider_mode mode, enum eq_type type)
{ {
@ -386,6 +369,7 @@ static int draw_eq_slider(const struct screen * screen, int x, int y,
int abs_gain = abs(gain); int abs_gain = abs(gain);
int current_x, total_height, separator_width, separator_height; int current_x, total_height, separator_width, separator_height;
int w, h; int w, h;
const int slider_height = 6;
/* Start two pixels in, one for border, one for margin */ /* Start two pixels in, one for border, one for margin */
current_x = x + 2; current_x = x + 2;
@ -394,7 +378,7 @@ static int draw_eq_slider(const struct screen * screen, int x, int y,
screen->getstringsize(separator, &separator_width, &separator_height); screen->getstringsize(separator, &separator_width, &separator_height);
/* Total height includes margins, text, and line selector */ /* Total height includes margins, text, and line selector */
total_height = separator_height + SLIDER_KNOB_HEIGHT + 2 + 3; total_height = separator_height + slider_height + 2 + 3;
/* Print out the band label */ /* Print out the band label */
if (type == LOW_SHELF) { if (type == LOW_SHELF) {
@ -463,9 +447,10 @@ static int draw_eq_slider(const struct screen * screen, int x, int y,
screen->drawrect(x, y, width, total_height); screen->drawrect(x, y, width, total_height);
} }
/* Draw horizontal slider */ /* Draw horizontal slider. Reuse scrollbar for this */
draw_slider(screen, x + 3, y + h + 3, width - 6, steps, gui_scrollbar_draw(screen, x + 3, y + h + 3, width - 6, slider_height, steps,
abs(EQ_GAIN_MIN) + gain); abs(EQ_GAIN_MIN) + gain - 10, abs(EQ_GAIN_MIN) + gain + 10,
HORIZONTAL);
return total_height; return total_height;
} }