mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-09 17:45:41 +01:00
alsamixer - Tricolorize volume bars
A little of bit of Italian taste was missing... Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
05fcb0c79f
commit
29a7dbc552
3 changed files with 51 additions and 18 deletions
|
@ -33,7 +33,11 @@ int attr_ctl_nocapture;
|
|||
int attr_ctl_label;
|
||||
int attr_ctl_label_focus;
|
||||
int attr_ctl_mark_focus;
|
||||
int attr_ctl_bar;
|
||||
int attr_ctl_bar_lo;
|
||||
#ifdef TRICOLOR_VOLUME_BAR
|
||||
int attr_ctl_bar_mi;
|
||||
int attr_ctl_bar_hi;
|
||||
#endif
|
||||
int attr_ctl_inactive;
|
||||
int attr_ctl_label_inactive;
|
||||
int attr_errormsg;
|
||||
|
@ -57,6 +61,10 @@ void init_colors(int use_color)
|
|||
init_pair(7, COLOR_RED, COLOR_BLUE);
|
||||
init_pair(8, COLOR_GREEN, COLOR_GREEN);
|
||||
init_pair(9, COLOR_WHITE, COLOR_RED);
|
||||
#ifdef TRICOLOR_VOLUME_BAR
|
||||
init_pair(10, COLOR_WHITE, COLOR_WHITE);
|
||||
init_pair(11, COLOR_RED, COLOR_RED);
|
||||
#endif
|
||||
|
||||
attr_mixer_frame = COLOR_PAIR(1);
|
||||
attr_mixer_text = COLOR_PAIR(1);
|
||||
|
@ -69,7 +77,11 @@ void init_colors(int use_color)
|
|||
attr_ctl_label = A_BOLD | COLOR_PAIR(6);
|
||||
attr_ctl_label_focus = A_BOLD | COLOR_PAIR(7);
|
||||
attr_ctl_mark_focus = A_BOLD | COLOR_PAIR(4);
|
||||
attr_ctl_bar = A_BOLD | COLOR_PAIR(8);
|
||||
attr_ctl_bar_lo = A_BOLD | COLOR_PAIR(8);
|
||||
#ifdef TRICOLOR_VOLUME_BAR
|
||||
attr_ctl_bar_mi = A_BOLD | COLOR_PAIR(10);
|
||||
attr_ctl_bar_hi = A_BOLD | COLOR_PAIR(11);
|
||||
#endif
|
||||
attr_ctl_inactive = COLOR_PAIR(5);
|
||||
attr_ctl_label_inactive = A_REVERSE | COLOR_PAIR(5);
|
||||
attr_errormsg = A_BOLD | COLOR_PAIR(9);
|
||||
|
@ -90,7 +102,11 @@ void init_colors(int use_color)
|
|||
attr_ctl_label = A_REVERSE;
|
||||
attr_ctl_label_focus = A_REVERSE | A_BOLD;
|
||||
attr_ctl_mark_focus = A_BOLD;
|
||||
attr_ctl_bar = A_BOLD;
|
||||
attr_ctl_bar_lo = A_BOLD;
|
||||
#ifdef TRICOLOR_VOLUME_BAR
|
||||
attr_ctl_bar_mi = A_BOLD;
|
||||
attr_ctl_bar_hi = A_BOLD;
|
||||
#endif
|
||||
attr_ctl_inactive = A_NORMAL;
|
||||
attr_ctl_label_inactive = A_REVERSE;
|
||||
attr_errormsg = A_STANDOUT;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef COLORS_H_INCLUDED
|
||||
#define COLORS_H_INCLUDED
|
||||
|
||||
#define TRICOLOR_VOLUME_BAR
|
||||
|
||||
extern int attr_mixer_frame;
|
||||
extern int attr_mixer_text;
|
||||
extern int attr_mixer_active;
|
||||
|
@ -12,7 +14,11 @@ extern int attr_ctl_nocapture;
|
|||
extern int attr_ctl_label;
|
||||
extern int attr_ctl_label_focus;
|
||||
extern int attr_ctl_mark_focus;
|
||||
extern int attr_ctl_bar;
|
||||
extern int attr_ctl_bar_lo;
|
||||
#ifdef TRICOLOR_VOLUME_BAR
|
||||
extern int attr_ctl_bar_mi;
|
||||
extern int attr_ctl_bar_hi;
|
||||
#endif
|
||||
extern int attr_ctl_inactive;
|
||||
extern int attr_ctl_label_inactive;
|
||||
extern int attr_errormsg;
|
||||
|
|
|
@ -394,7 +394,7 @@ static void display_control(unsigned int control_index)
|
|||
{
|
||||
struct control *control;
|
||||
int col;
|
||||
int i;
|
||||
int i, c;
|
||||
int left, frame_left;
|
||||
int bar_height, value;
|
||||
long volumes[2];
|
||||
|
@ -465,19 +465,30 @@ static void display_control(unsigned int control_index)
|
|||
|
||||
if (control->flags & IS_ACTIVE)
|
||||
wattrset(mixer_widget.window, 0);
|
||||
bar_height = ((volumes[0] - min) * volume_height + max - min - 1) / (max - min);
|
||||
for (i = 0; i < volume_height; ++i)
|
||||
mvwaddch(mixer_widget.window, base_y - i - 1, frame_left + 1,
|
||||
i + 1 <= bar_height
|
||||
? ACS_CKBOARD | (control->flags & IS_ACTIVE ? attr_ctl_bar : 0)
|
||||
: ' ' | (control->flags & IS_ACTIVE ? attr_ctl_frame : 0));
|
||||
bar_height = ((volumes[1] - min) * volume_height + max - min - 1) / (max - min);
|
||||
for (i = 0; i < volume_height; ++i)
|
||||
mvwaddch(mixer_widget.window, base_y - i - 1, frame_left + 2,
|
||||
i + 1 <= bar_height
|
||||
? ACS_CKBOARD | (control->flags & IS_ACTIVE ? attr_ctl_bar : 0)
|
||||
: ' ' | (control->flags & IS_ACTIVE ? attr_ctl_frame : 0));
|
||||
|
||||
for (c = 0; c < 2; c++) {
|
||||
bar_height = ((volumes[c] - min) * volume_height +
|
||||
max - min - 1) / (max - min);
|
||||
for (i = 0; i < volume_height; ++i) {
|
||||
int attr;
|
||||
if (i + 1 > bar_height)
|
||||
attr = ' ' |
|
||||
(control->flags & IS_ACTIVE ?
|
||||
attr_ctl_frame : 0);
|
||||
else {
|
||||
attr = ACS_CKBOARD;
|
||||
#ifdef TRICOLOR_VOLUME_BAR
|
||||
if (i > volume_height * 8 / 10)
|
||||
attr |= attr_ctl_bar_hi;
|
||||
else if (i > volume_height * 4 / 10)
|
||||
attr |= attr_ctl_bar_mi;
|
||||
else
|
||||
#endif
|
||||
attr |= attr_ctl_bar_lo;
|
||||
}
|
||||
mvwaddch(mixer_widget.window, base_y - i - 1,
|
||||
frame_left + c + 1, attr);
|
||||
}
|
||||
}
|
||||
if (control->flags & IS_ACTIVE)
|
||||
wattrset(mixer_widget.window, attr_mixer_active);
|
||||
value = ((volumes[0] - min) * 100 + (max - min) / 2) / (max - min);
|
||||
|
|
Loading…
Reference in a new issue