diff options
author | Dan Everton <dan@iocaine.org> | 2006-02-16 21:53:50 +0000 |
---|---|---|
committer | Dan Everton <dan@iocaine.org> | 2006-02-16 21:53:50 +0000 |
commit | 791005a54128f6393cfa5189864f68d09cdfc03a (patch) | |
tree | ddad32ed3499142cfde1cc9170587fcd2ed1bc10 /apps/eq_menu.c | |
parent | 72ea4f38baf7a806536ef4b3e99110615e1ed027 (diff) | |
download | rockbox-791005a54128f6393cfa5189864f68d09cdfc03a.tar.gz rockbox-791005a54128f6393cfa5189864f68d09cdfc03a.zip |
Smoother slider knob movement.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8709 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/eq_menu.c')
-rw-r--r-- | apps/eq_menu.c | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/apps/eq_menu.c b/apps/eq_menu.c index b80b2af7db..73c066705c 100644 --- a/apps/eq_menu.c +++ b/apps/eq_menu.c | |||
@@ -359,12 +359,12 @@ enum eq_type { | |||
359 | static void draw_slider(const struct screen * screen, int x, int y, | 359 | static void draw_slider(const struct screen * screen, int x, int y, |
360 | int width, int steps, int current_step) | 360 | int width, int steps, int current_step) |
361 | { | 361 | { |
362 | 362 | int knob_x = ((width * 100 / steps) * current_step) / 100 | |
363 | int knob_x = (width / steps) * current_step + (SLIDER_KNOB_WIDTH / 2); | 363 | + (SLIDER_KNOB_WIDTH / 2); |
364 | 364 | ||
365 | /* Draw groove */ | 365 | /* Draw groove */ |
366 | screen->fillrect(x, y + 2, width, 2); | 366 | screen->fillrect(x, y + 2, width, 2); |
367 | 367 | ||
368 | /* Draw knob */ | 368 | /* Draw knob */ |
369 | screen->fillrect(x + knob_x, y, SLIDER_KNOB_WIDTH, SLIDER_KNOB_HEIGHT); | 369 | screen->fillrect(x + knob_x, y, SLIDER_KNOB_WIDTH, SLIDER_KNOB_HEIGHT); |
370 | } | 370 | } |
@@ -376,7 +376,7 @@ static int draw_eq_slider(const struct screen * screen, int x, int y, | |||
376 | { | 376 | { |
377 | char buf[26]; | 377 | char buf[26]; |
378 | const char separator[2] = " "; | 378 | const char separator[2] = " "; |
379 | int steps = (abs(EQ_GAIN_MIN) + abs(EQ_GAIN_MAX)) / EQ_USER_DIVISOR; | 379 | int steps = EQ_GAIN_MAX - EQ_GAIN_MIN; |
380 | int abs_q = abs(q); | 380 | int abs_q = abs(q); |
381 | int abs_gain = abs(gain); | 381 | int abs_gain = abs(gain); |
382 | int current_x, total_height, separator_width, separator_height; | 382 | int current_x, total_height, separator_width, separator_height; |
@@ -439,7 +439,7 @@ static int draw_eq_slider(const struct screen * screen, int x, int y, | |||
439 | screen->set_drawmode(DRMODE_SOLID); | 439 | screen->set_drawmode(DRMODE_SOLID); |
440 | screen->putsxy(current_x, y + 2, separator); | 440 | screen->putsxy(current_x, y + 2, separator); |
441 | current_x += separator_width; | 441 | current_x += separator_width; |
442 | 442 | ||
443 | /* Print out Q part of status line */ | 443 | /* Print out Q part of status line */ |
444 | snprintf(buf, sizeof(buf), "%d.%d Q", abs_q / EQ_USER_DIVISOR, | 444 | snprintf(buf, sizeof(buf), "%d.%d Q", abs_q / EQ_USER_DIVISOR, |
445 | abs_q % EQ_USER_DIVISOR); | 445 | abs_q % EQ_USER_DIVISOR); |
@@ -457,10 +457,10 @@ static int draw_eq_slider(const struct screen * screen, int x, int y, | |||
457 | if (selected) { | 457 | if (selected) { |
458 | screen->drawrect(x, y, width, total_height); | 458 | screen->drawrect(x, y, width, total_height); |
459 | } | 459 | } |
460 | 460 | ||
461 | /* Draw horizontal slider */ | 461 | /* Draw horizontal slider */ |
462 | draw_slider(screen, x + 3, y + h + 3, width - 6, steps, | 462 | draw_slider(screen, x + 3, y + h + 3, width - 6, steps, |
463 | (EQ_GAIN_MAX + gain) / EQ_USER_DIVISOR); | 463 | abs(EQ_GAIN_MIN) + gain); |
464 | 464 | ||
465 | return total_height; | 465 | return total_height; |
466 | } | 466 | } |
@@ -474,12 +474,11 @@ static int draw_eq_sliders(int current_band, enum eq_slider_mode mode) | |||
474 | int *setting = &global_settings.eq_band0_cutoff; | 474 | int *setting = &global_settings.eq_band0_cutoff; |
475 | enum eq_type type; | 475 | enum eq_type type; |
476 | 476 | ||
477 | for( i = 0; i < 5; ++i) | 477 | for( i = 0; i < 5; ++i) { |
478 | { | ||
479 | cutoff = *setting++; | 478 | cutoff = *setting++; |
480 | q = *setting++; | 479 | q = *setting++; |
481 | gain = *setting++; | 480 | gain = *setting++; |
482 | 481 | ||
483 | if (i == 0) { | 482 | if (i == 0) { |
484 | type = LOW_SHELF; | 483 | type = LOW_SHELF; |
485 | } else if (i == 4) { | 484 | } else if (i == 4) { |
@@ -487,7 +486,7 @@ static int draw_eq_sliders(int current_band, enum eq_slider_mode mode) | |||
487 | } else { | 486 | } else { |
488 | type = PEAK; | 487 | type = PEAK; |
489 | } | 488 | } |
490 | 489 | ||
491 | height += draw_eq_slider(&(screens[SCREEN_MAIN]), 2, height, | 490 | height += draw_eq_slider(&(screens[SCREEN_MAIN]), 2, height, |
492 | slider_width, cutoff, q, gain, i == current_band, mode, type); | 491 | slider_width, cutoff, q, gain, i == current_band, mode, type); |
493 | 492 | ||
@@ -531,7 +530,7 @@ bool eq_menu_graphical(void) | |||
531 | /* gain */ | 530 | /* gain */ |
532 | setting = &global_settings.eq_band0_gain; | 531 | setting = &global_settings.eq_band0_gain; |
533 | setting += current_band * 3; | 532 | setting += current_band * 3; |
534 | 533 | ||
535 | step = EQ_GAIN_STEP; | 534 | step = EQ_GAIN_STEP; |
536 | fast_step = EQ_GAIN_FAST_STEP; | 535 | fast_step = EQ_GAIN_FAST_STEP; |
537 | min = EQ_GAIN_MIN; | 536 | min = EQ_GAIN_MIN; |
@@ -546,7 +545,7 @@ bool eq_menu_graphical(void) | |||
546 | /* cutoff */ | 545 | /* cutoff */ |
547 | setting = &global_settings.eq_band0_cutoff; | 546 | setting = &global_settings.eq_band0_cutoff; |
548 | setting += current_band * 3; | 547 | setting += current_band * 3; |
549 | 548 | ||
550 | step = EQ_CUTOFF_STEP; | 549 | step = EQ_CUTOFF_STEP; |
551 | fast_step = EQ_CUTOFF_FAST_STEP; | 550 | fast_step = EQ_CUTOFF_FAST_STEP; |
552 | min = EQ_CUTOFF_MIN; | 551 | min = EQ_CUTOFF_MIN; |
@@ -561,7 +560,7 @@ bool eq_menu_graphical(void) | |||
561 | /* Q */ | 560 | /* Q */ |
562 | setting = &global_settings.eq_band0_q; | 561 | setting = &global_settings.eq_band0_q; |
563 | setting += current_band * 3; | 562 | setting += current_band * 3; |
564 | 563 | ||
565 | step = EQ_Q_STEP; | 564 | step = EQ_Q_STEP; |
566 | fast_step = EQ_Q_FAST_STEP; | 565 | fast_step = EQ_Q_FAST_STEP; |
567 | min = EQ_Q_MIN; | 566 | min = EQ_Q_MIN; |
@@ -594,7 +593,7 @@ bool eq_menu_graphical(void) | |||
594 | if (*(setting) > max) | 593 | if (*(setting) > max) |
595 | *(setting) = max; | 594 | *(setting) = max; |
596 | break; | 595 | break; |
597 | 596 | ||
598 | #ifdef EQ_BTN_MODIFIER | 597 | #ifdef EQ_BTN_MODIFIER |
599 | case EQ_BTN_MODIFIER | EQ_BTN_INCREMENT: | 598 | case EQ_BTN_MODIFIER | EQ_BTN_INCREMENT: |
600 | case EQ_BTN_MODIFIER | EQ_BTN_INCREMENT | BUTTON_REPEAT: | 599 | case EQ_BTN_MODIFIER | EQ_BTN_INCREMENT | BUTTON_REPEAT: |
@@ -626,20 +625,20 @@ bool eq_menu_graphical(void) | |||
626 | if (current_band > 4) | 625 | if (current_band > 4) |
627 | current_band = 0; /* wrap around */ | 626 | current_band = 0; /* wrap around */ |
628 | break; | 627 | break; |
629 | 628 | ||
630 | case EQ_BTN_CHANGE_MODE: | 629 | case EQ_BTN_CHANGE_MODE: |
631 | case EQ_BTN_CHANGE_MODE | BUTTON_REPEAT: | 630 | case EQ_BTN_CHANGE_MODE | BUTTON_REPEAT: |
632 | mode++; | 631 | mode++; |
633 | if (mode > Q) | 632 | if (mode > Q) |
634 | mode = GAIN; /* wrap around */ | 633 | mode = GAIN; /* wrap around */ |
635 | break; | 634 | break; |
636 | 635 | ||
637 | case EQ_BTN_EXIT: | 636 | case EQ_BTN_EXIT: |
638 | case EQ_BTN_EXIT | BUTTON_REPEAT: | 637 | case EQ_BTN_EXIT | BUTTON_REPEAT: |
639 | exit_request = true; | 638 | exit_request = true; |
640 | result = false; | 639 | result = false; |
641 | break; | 640 | break; |
642 | 641 | ||
643 | default: | 642 | default: |
644 | if(default_event_handler(button) == SYS_USB_CONNECTED) { | 643 | if(default_event_handler(button) == SYS_USB_CONNECTED) { |
645 | exit_request = true; | 644 | exit_request = true; |