mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
Merge branch '1703_menubar_colorpair'
* 1703_menubar_colorpair: Fixed width calculation of Buttonbar widget. Ticket #1703: SKIN: Make own colorpairs for buttonbar widget
This commit is contained in:
commit
c0575fff3f
@ -77,6 +77,10 @@
|
||||
[viewer]
|
||||
viewunderline=brightred;black
|
||||
|
||||
[buttonbar]
|
||||
hotkey=red;white
|
||||
button=black;white
|
||||
|
||||
[widget-common]
|
||||
sort-sign-up=↑
|
||||
sort-sign-down=↓
|
||||
|
@ -59,6 +59,10 @@
|
||||
menusel=white;black
|
||||
menuhotsel=yellow;black
|
||||
|
||||
[buttonbar]
|
||||
hotkey=white;black
|
||||
button=black;cyan
|
||||
|
||||
[help]
|
||||
_default_=black;lightgray
|
||||
helpitalic=red;lightgray
|
||||
|
@ -61,6 +61,10 @@
|
||||
menusel=white;black
|
||||
menuhotsel=yellow;black
|
||||
|
||||
[buttonbar]
|
||||
hotkey=white;black
|
||||
button=black;cyan
|
||||
|
||||
[help]
|
||||
_default_=black;lightgray
|
||||
helpitalic=red;lightgray
|
||||
|
@ -76,3 +76,7 @@
|
||||
|
||||
[viewer]
|
||||
viewunderline=brightgreen;black
|
||||
|
||||
[buttonbar]
|
||||
hotkey=brightgreen;white
|
||||
button=black;blue
|
||||
|
@ -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");
|
||||
|
||||
|
||||
}
|
||||
|
@ -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 ***************************************************************************************/
|
||||
|
20
src/widget.c
20
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);
|
||||
tty_setcolor (DEFAULT_COLOR);
|
||||
widget_move (&bb->widget, 0, (i * bb->btn_width) + offset);
|
||||
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));
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user