diff --git a/lib/widget/scrollbar.c b/lib/widget/scrollbar.c index 350081e0a..add46f4e3 100644 --- a/lib/widget/scrollbar.c +++ b/lib/widget/scrollbar.c @@ -48,12 +48,25 @@ /*** file scope variables ************************************************************************/ +static struct +{ + char *current_char; + + char *first_vert_char; + char *last_vert_char; + char *background_vert_char; + + char *first_horiz_char; + char *last_horiz_char; + char *background_horiz_char; +} scrollbar_skin; + /* --------------------------------------------------------------------------------------------- */ /*** file scope functions ************************************************************************/ /* --------------------------------------------------------------------------------------------- */ static void -scrollbar_set_size (WScrollBar *scrollbar) +scrollbar_set_size (WScrollBar * scrollbar) { Widget *w = WIDGET (scrollbar); Widget *p = scrollbar->parent; @@ -63,14 +76,14 @@ scrollbar_set_size (WScrollBar *scrollbar) /* There folloing cases are possible here: 1. Parent is in dialog, scrollbar isn't. - Parents coordinates are absolute. Scrollbar's coordinate are relative to owner. - We need relative parent's coordinates here to place scrollbar properly. + Parents coordinates are absolute. Scrollbar's coordinate are relative to owner. + We need relative parent's coordinates here to place scrollbar properly. 2. Parent and scrollbar are in dialog. - Parent's and scrollbar's coordinates are absolute. Use them. + Parent's and scrollbar's coordinates are absolute. Use them. 3. Parent and scrollbar aren't in dialog. - Parent's and scrollbar's coordinates are relative to owner. Use them. + Parent's and scrollbar's coordinates are relative to owner. Use them. 4. Parent isn't in dialog, scrollbar is. - This is abnormal and should not happen. */ + This is abnormal and should not happen. */ if (o != NULL && w->owner == NULL) { @@ -106,17 +119,46 @@ scrollbar_draw_horizontal (WScrollBar * scrollbar) int column = 0; int i; + int start_pos = 0; + int end_pos = w->cols; + int total_columns = w->cols; + + + if (scrollbar_skin.first_horiz_char != NULL) + { + start_pos = 1; + total_columns--; + } + + if (scrollbar_skin.last_horiz_char != NULL) + { + end_pos = w->cols - 1; + total_columns--; + } + /* Now draw the nice relative pointer */ if (*scrollbar->total != 0) - column = *scrollbar->current * w->cols / *scrollbar->total; + column = *scrollbar->current * total_columns / *scrollbar->total - start_pos; - for (i = 0; i < w->cols; i++) + if (scrollbar_skin.first_vert_char != NULL) + { + widget_move (w, 0, 0); + tty_print_string (scrollbar_skin.first_horiz_char); + } + + for (i = start_pos; i < end_pos; i++) { widget_move (w, 0, i); if (i != column) - tty_print_char ('!'); + tty_print_string (scrollbar_skin.background_horiz_char); else - tty_print_char ('+'); + tty_print_string (scrollbar_skin.current_char); + } + + if (scrollbar_skin.last_vert_char != NULL) + { + widget_move (w, 0, w->cols - 1); + tty_print_string (scrollbar_skin.last_horiz_char); } } @@ -129,17 +171,45 @@ scrollbar_draw_vertical (WScrollBar * scrollbar) int line = 0; int i; + int start_pos = 0; + int end_pos = w->lines; + int total_lines = w->lines; + + if (scrollbar_skin.first_vert_char != NULL) + { + start_pos = 1; + total_lines--; + } + + if (scrollbar_skin.last_vert_char != NULL) + { + end_pos = w->lines - 1; + total_lines--; + } + /* Now draw the nice relative pointer */ if (*scrollbar->total != 0) - line = *scrollbar->current * w->lines / *scrollbar->total; + line = *scrollbar->current * total_lines / *scrollbar->total + start_pos; - for (i = 0; i < w->lines; i++) + if (scrollbar_skin.first_vert_char != NULL) + { + widget_move (w, 0, 0); + tty_print_string (scrollbar_skin.first_vert_char); + } + + for (i = start_pos; i < end_pos; i++) { widget_move (w, i, 0); if (i != line) - tty_print_char ('|'); + tty_print_string (scrollbar_skin.background_vert_char); else - tty_print_char ('+'); + tty_print_string (scrollbar_skin.current_char); + } + + if (scrollbar_skin.last_vert_char != NULL) + { + widget_move (w, w->lines - 1, 0); + tty_print_string (scrollbar_skin.last_vert_char); } } @@ -148,8 +218,6 @@ scrollbar_draw_vertical (WScrollBar * scrollbar) static void scrollbar_draw (WScrollBar * scrollbar) { - // const gboolean disabled = (scrollbar->parent->options & W_DISABLED) != 0; - // const int normalc = disabled ? DISABLED_COLOR : scrollbar->parent->color[DLG_COLOR_NORMAL]; const int normalc = DISABLED_COLOR; if (*scrollbar->total <= scrollbar->parent->lines) @@ -178,7 +246,7 @@ scrollbar_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, voi switch (msg) { case MSG_INIT: -// w->pos_flags = WPOS_KEEP_RIGHT | WPOS_KEEP_BOTTOM; + // w->pos_flags = WPOS_KEEP_RIGHT | WPOS_KEEP_BOTTOM; return MSG_HANDLED; case MSG_RESIZE: @@ -283,3 +351,37 @@ scrollbar_set_first_displayed (WScrollBar * scrollbar, int *first_displayed) } /* --------------------------------------------------------------------------------------------- */ + +void +scrollbar_global_init (void) +{ + scrollbar_skin.current_char = mc_skin_get ("widget-scollbar", "current-char", "*"); + + scrollbar_skin.first_vert_char = mc_skin_get ("widget-scollbar", "first-vert-char", NULL); + scrollbar_skin.last_vert_char = mc_skin_get ("widget-scollbar", "last-vert-char", NULL); + scrollbar_skin.background_vert_char = + mc_skin_get ("widget-scollbar", "background-vert-char", "|"); + + scrollbar_skin.first_horiz_char = mc_skin_get ("widget-scollbar", "first-horiz-char", NULL); + scrollbar_skin.last_horiz_char = mc_skin_get ("widget-scollbar", "last-horiz-char", NULL); + scrollbar_skin.background_horiz_char = + mc_skin_get ("widget-scollbar", "background-horiz-char", "-"); +} + +/* --------------------------------------------------------------------------------------------- */ + +void +scrollbar_global_deinit (void) +{ + g_free (scrollbar_skin.current_char); + + g_free (scrollbar_skin.first_vert_char); + g_free (scrollbar_skin.last_vert_char); + g_free (scrollbar_skin.background_vert_char); + + g_free (scrollbar_skin.first_horiz_char); + g_free (scrollbar_skin.last_horiz_char); + g_free (scrollbar_skin.background_horiz_char); +} + +/* --------------------------------------------------------------------------------------------- */ diff --git a/lib/widget/scrollbar.h b/lib/widget/scrollbar.h index 3dcf79f13..f41bd9317 100644 --- a/lib/widget/scrollbar.h +++ b/lib/widget/scrollbar.h @@ -39,6 +39,9 @@ void scrollbar_set_total (WScrollBar * scrollbar, int *total); void scrollbar_set_current (WScrollBar * scrollbar, int *current); void scrollbar_set_first_displayed (WScrollBar * scrollbar, int *first_displayed); +void scrollbar_global_init (void); +void scrollbar_global_deinit (void); + /*** inline functions ****************************************************************************/ #endif /* MC__WIDGET_SCROLLBAR_H */ diff --git a/lib/widget/widget-common.c b/lib/widget/widget-common.c index 39d7fc317..1e07a1279 100644 --- a/lib/widget/widget-common.c +++ b/lib/widget/widget-common.c @@ -377,3 +377,20 @@ mouse_global_in_widget (const Gpm_Event * event, const Widget * w) } /* --------------------------------------------------------------------------------------------- */ + +void +widget_global_init (void) +{ + dlg_set_default_colors (); + scrollbar_global_init (); +} + +/* --------------------------------------------------------------------------------------------- */ + +void +widget_global_deinit (void) +{ + scrollbar_global_deinit (); +} + +/* --------------------------------------------------------------------------------------------- */ diff --git a/lib/widget/widget-common.h b/lib/widget/widget-common.h index 93a2d9a0f..7d4d6cdaa 100644 --- a/lib/widget/widget-common.h +++ b/lib/widget/widget-common.h @@ -122,6 +122,9 @@ typedef struct hotkey_t /*** declarations of public functions ************************************************************/ +void widget_global_init (void); +void widget_global_deinit (void); + /* create hotkey from text */ hotkey_t parse_hotkey (const char *text); /* release hotkey, free all mebers of hotkey_t */ diff --git a/misc/skins/dark.ini b/misc/skins/dark.ini index 1550d1ae0..b2b22e200 100644 --- a/misc/skins/dark.ini +++ b/misc/skins/dark.ini @@ -147,5 +147,6 @@ first-horiz-char=« last-horiz-char=» current-char=■ - background-char=▒ + background-vert-char=▒ + background-horiz-char=▒ diff --git a/misc/skins/darkfar.ini b/misc/skins/darkfar.ini index df2519d82..023c8925e 100644 --- a/misc/skins/darkfar.ini +++ b/misc/skins/darkfar.ini @@ -147,4 +147,5 @@ first-horiz-char=« last-horiz-char=» current-char=■ - background-char=▒ + background-vert-char=▒ + background-horiz-char=▒ diff --git a/misc/skins/default.ini b/misc/skins/default.ini index adcdef5d7..246487f6f 100644 --- a/misc/skins/default.ini +++ b/misc/skins/default.ini @@ -136,3 +136,8 @@ [widget-panel] filename-scroll-left-char = { filename-scroll-right-char = } + +[widget-scollbar] + current-char=■ + background-vert-char=▒ + background-horiz-char=▒ diff --git a/misc/skins/modarcon16-defbg.ini b/misc/skins/modarcon16-defbg.ini index ec06e9be4..e42ab72d1 100644 --- a/misc/skins/modarcon16-defbg.ini +++ b/misc/skins/modarcon16-defbg.ini @@ -179,4 +179,5 @@ first-horiz-char=« last-horiz-char=» current-char=■ - background-char=▒ + background-vert-char=▒ + background-horiz-char=▒ diff --git a/misc/skins/modarcon16.ini b/misc/skins/modarcon16.ini index 6e9d06150..863a1333d 100644 --- a/misc/skins/modarcon16.ini +++ b/misc/skins/modarcon16.ini @@ -179,4 +179,5 @@ first-horiz-char=« last-horiz-char=» current-char=■ - background-char=▒ + background-vert-char=▒ + background-horiz-char=▒ diff --git a/misc/skins/modarcon16root-defbg.ini b/misc/skins/modarcon16root-defbg.ini index 14b8b0187..0b871bbb6 100644 --- a/misc/skins/modarcon16root-defbg.ini +++ b/misc/skins/modarcon16root-defbg.ini @@ -179,4 +179,5 @@ first-horiz-char=« last-horiz-char=» current-char=■ - background-char=▒ + background-vert-char=▒ + background-horiz-char=▒ diff --git a/misc/skins/modarcon16root.ini b/misc/skins/modarcon16root.ini index 9acaeba0f..aa02b3a5f 100644 --- a/misc/skins/modarcon16root.ini +++ b/misc/skins/modarcon16root.ini @@ -179,4 +179,5 @@ first-horiz-char=« last-horiz-char=» current-char=■ - background-char=▒ + background-vert-char=▒ + background-horiz-char=▒ diff --git a/misc/skins/modarin256-defbg.ini b/misc/skins/modarin256-defbg.ini index b3621cb3a..eff3220b2 100644 --- a/misc/skins/modarin256-defbg.ini +++ b/misc/skins/modarin256-defbg.ini @@ -179,4 +179,5 @@ first-horiz-char=« last-horiz-char=» current-char=■ - background-char=▒ + background-vert-char=▒ + background-horiz-char=▒ diff --git a/misc/skins/modarin256.ini b/misc/skins/modarin256.ini index bae811886..6c7d529fc 100644 --- a/misc/skins/modarin256.ini +++ b/misc/skins/modarin256.ini @@ -179,4 +179,5 @@ first-horiz-char=« last-horiz-char=» current-char=■ - background-char=▒ + background-vert-char=▒ + background-horiz-char=▒ diff --git a/misc/skins/modarin256root-defbg.ini b/misc/skins/modarin256root-defbg.ini index 9b510fbc3..d2dd7a6f3 100644 --- a/misc/skins/modarin256root-defbg.ini +++ b/misc/skins/modarin256root-defbg.ini @@ -179,4 +179,5 @@ first-horiz-char=« last-horiz-char=» current-char=■ - background-char=▒ + background-vert-char=▒ + background-horiz-char=▒ diff --git a/misc/skins/modarin256root.ini b/misc/skins/modarin256root.ini index 6d6b5fd50..fe3109fcc 100644 --- a/misc/skins/modarin256root.ini +++ b/misc/skins/modarin256root.ini @@ -179,4 +179,5 @@ first-horiz-char=« last-horiz-char=» current-char=■ - background-char=▒ + background-vert-char=▒ + background-horiz-char=▒ diff --git a/misc/skins/sand256.ini b/misc/skins/sand256.ini index 7f2a55ce6..71a3105a4 100644 --- a/misc/skins/sand256.ini +++ b/misc/skins/sand256.ini @@ -197,5 +197,6 @@ first-horiz-char=« last-horiz-char=» current-char=■ - background-char=▒ + background-vert-char=▒ + background-horiz-char=▒ diff --git a/misc/skins/xoria256.ini b/misc/skins/xoria256.ini index e4f68dda6..43e66627d 100644 --- a/misc/skins/xoria256.ini +++ b/misc/skins/xoria256.ini @@ -188,5 +188,6 @@ first-horiz-char=« last-horiz-char=» current-char=■ - background-char=▒ + background-vert-char=▒ + background-horiz-char=▒ diff --git a/src/main.c b/src/main.c index f4005ccb0..baf1be5c5 100644 --- a/src/main.c +++ b/src/main.c @@ -379,7 +379,7 @@ main (int argc, char *argv[]) error = NULL; } - dlg_set_default_colors (); + widget_global_init (); #ifdef ENABLE_SUBSHELL /* Done here to ensure that the subshell doesn't */ @@ -428,6 +428,8 @@ main (int argc, char *argv[]) flush_extension_file (); /* does only free memory */ + widget_global_deinit (); + mc_skin_deinit (); tty_colors_done ();