summaryrefslogtreecommitdiff
path: root/alsamixer
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2009-06-18 14:42:28 +0200
committerTakashi Iwai <tiwai@suse.de>2009-06-18 14:42:28 +0200
commit29a7dbc55233389e154476738d71846aeb1a1773 (patch)
treec92ef4a49a0ff0a65e9588cbc87d8c94b9c01f64 /alsamixer
parent05fcb0c79f6681b33951d66cece1a6d421a0c8e6 (diff)
alsamixer - Tricolorize volume bars
A little of bit of Italian taste was missing... Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'alsamixer')
-rw-r--r--alsamixer/colors.c22
-rw-r--r--alsamixer/colors.h8
-rw-r--r--alsamixer/mixer_display.c39
3 files changed, 51 insertions, 18 deletions
diff --git a/alsamixer/colors.c b/alsamixer/colors.c
index f68de54..fcceb16 100644
--- a/alsamixer/colors.c
+++ b/alsamixer/colors.c
@@ -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;
diff --git a/alsamixer/colors.h b/alsamixer/colors.h
index e1d3b1a..9396004 100644
--- a/alsamixer/colors.h
+++ b/alsamixer/colors.h
@@ -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;
diff --git a/alsamixer/mixer_display.c b/alsamixer/mixer_display.c
index aade71d..d0a0e56 100644
--- a/alsamixer/mixer_display.c
+++ b/alsamixer/mixer_display.c
@@ -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);