From 742eae18d2261d5703404bbe9bb513f56e6fc40d Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Wed, 28 Oct 2009 16:18:06 +0200 Subject: [PATCH 1/2] Ticket #1703: SKIN: Make own colorpairs for buttonbar widget Now buttonbar have own colorpairs: [buttonbar] hotkey=red;black button=yellow;cyan Signed-off-by: Ilia Maslakov Signed-off-by: Slava Zanko --- misc/skins/darkfar.ini | 4 ++++ misc/skins/default.ini | 4 ++++ misc/skins/featured.ini | 4 ++++ misc/skins/gotar.ini | 4 ++++ src/skin/colors.c | 2 ++ src/skin/skin.h | 5 ++++- src/widget.c | 4 ++-- 7 files changed, 24 insertions(+), 3 deletions(-) diff --git a/misc/skins/darkfar.ini b/misc/skins/darkfar.ini index 8c4b7296a..321d441ec 100644 --- a/misc/skins/darkfar.ini +++ b/misc/skins/darkfar.ini @@ -77,6 +77,10 @@ [viewer] viewunderline=brightred;black +[buttonbar] + hotkey=red;white + button=black;white + [widget-common] sort-sign-up=↑ sort-sign-down=↓ diff --git a/misc/skins/default.ini b/misc/skins/default.ini index d0f378fd3..2054b6632 100644 --- a/misc/skins/default.ini +++ b/misc/skins/default.ini @@ -59,6 +59,10 @@ menusel=white;black menuhotsel=yellow;black +[buttonbar] + hotkey=white;black + button=black;cyan + [help] _default_=black;lightgray helpitalic=red;lightgray diff --git a/misc/skins/featured.ini b/misc/skins/featured.ini index e90ea3bcb..d9f288596 100644 --- a/misc/skins/featured.ini +++ b/misc/skins/featured.ini @@ -61,6 +61,10 @@ menusel=white;black menuhotsel=yellow;black +[buttonbar] + hotkey=white;black + button=black;cyan + [help] _default_=black;lightgray helpitalic=red;lightgray diff --git a/misc/skins/gotar.ini b/misc/skins/gotar.ini index 601625c21..28440d5fa 100644 --- a/misc/skins/gotar.ini +++ b/misc/skins/gotar.ini @@ -76,3 +76,7 @@ [viewer] viewunderline=brightgreen;black + +[buttonbar] + hotkey=brightgreen;white + button=black;blue diff --git a/src/skin/colors.c b/src/skin/colors.c index e6e9011a7..e4dd66b93 100644 --- a/src/skin/colors.c +++ b/src/skin/colors.c @@ -230,6 +230,8 @@ mc_skin_color_cache_init (void) LINE_STATE_COLOR = mc_skin_color_get ("editor", "linestate"); BOOK_MARK_COLOR = mc_skin_color_get ("editor", "bookmark"); BOOK_MARK_FOUND_COLOR = mc_skin_color_get ("editor", "bookmarkfound"); + BUTTONBAR_HOTKEY_COLOR = mc_skin_color_get ("buttonbar", "hotkey"); + BUTTONBAR_BUTTON_COLOR = mc_skin_color_get ("buttonbar", "button"); } diff --git a/src/skin/skin.h b/src/skin/skin.h index 42a509d49..499f0feeb 100644 --- a/src/skin/skin.h +++ b/src/skin/skin.h @@ -66,7 +66,10 @@ #define BOOK_MARK_COLOR mc_skin_color__cache[30] #define BOOK_MARK_FOUND_COLOR mc_skin_color__cache[31] -#define MC_SKIN_COLOR_CACHE_COUNT 32 +#define BUTTONBAR_HOTKEY_COLOR mc_skin_color__cache[32] +#define BUTTONBAR_BUTTON_COLOR mc_skin_color__cache[33] + +#define MC_SKIN_COLOR_CACHE_COUNT 34 /*** enums ***************************************************************************************/ diff --git a/src/widget.c b/src/widget.c index 89b0b3e6f..3b3fee54c 100644 --- a/src/widget.c +++ b/src/widget.c @@ -2597,9 +2597,9 @@ buttonbar_callback (Widget *w, widget_msg_t msg, int parm) for (i = 0; i < COLS / bb->btn_width && i < BUTTONBAR_LABELS_NUM; i++) { widget_move (&bb->widget, 0, i * bb->btn_width); - tty_setcolor (DEFAULT_COLOR); + tty_setcolor (BUTTONBAR_HOTKEY_COLOR); tty_printf ("%2d", i + 1); - tty_setcolor (SELECTED_COLOR); + tty_setcolor (BUTTONBAR_BUTTON_COLOR); text = (bb->labels[i].text != NULL) ? bb->labels[i].text : ""; tty_print_string (str_fit_to_term (text, bb->btn_width - 2, J_CENTER_LEFT)); } From b62aece7eb1bf5260fd0e010dc61894bd1eeea08 Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Wed, 28 Oct 2009 17:20:54 +0200 Subject: [PATCH 2/2] Fixed width calculation of Buttonbar widget. Also Labels on buttonbar aligned to left side. Signed-off-by: Ilia Maslakov Signed-off-by: Slava Zanko --- src/widget.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/widget.c b/src/widget.c index 3b3fee54c..c144c7758 100644 --- a/src/widget.c +++ b/src/widget.c @@ -2590,18 +2590,28 @@ buttonbar_callback (Widget *w, widget_msg_t msg, int parm) case WIDGET_DRAW: if (bb->visible) { + int offset = 0; + int count_free_positions; + widget_move (&bb->widget, 0, 0); tty_setcolor (DEFAULT_COLOR); bb->btn_width = buttonbat_get_button_width (); tty_printf ("%-*s", bb->widget.cols, ""); + count_free_positions = COLS - bb->btn_width*BUTTONBAR_LABELS_NUM; for (i = 0; i < COLS / bb->btn_width && i < BUTTONBAR_LABELS_NUM; i++) { - widget_move (&bb->widget, 0, i * bb->btn_width); + widget_move (&bb->widget, 0, (i * bb->btn_width) + offset); tty_setcolor (BUTTONBAR_HOTKEY_COLOR); tty_printf ("%2d", i + 1); tty_setcolor (BUTTONBAR_BUTTON_COLOR); text = (bb->labels[i].text != NULL) ? bb->labels[i].text : ""; - tty_print_string (str_fit_to_term (text, bb->btn_width - 2, J_CENTER_LEFT)); + tty_print_string (str_fit_to_term ( + text, + bb->btn_width - 2 + (int)(offset < count_free_positions), + J_LEFT_FIT)); + + if (count_free_positions != 0 && offset < count_free_positions) + offset++; } } return MSG_HANDLED; @@ -2626,7 +2636,7 @@ buttonbar_event (Gpm_Event *event, void *data) return MOU_NORMAL; if (event->y == 2) return MOU_NORMAL; - button = (event->x - 1) / bb->btn_width; + button = (event->x - 1) * BUTTONBAR_LABELS_NUM / (COLS); if (button < BUTTONBAR_LABELS_NUM) buttonbar_call (bb, button); return MOU_NORMAL;