mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 12:32:40 +03:00
Add skin support
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
8912ba1c8e
commit
c504f0b247
@ -48,6 +48,19 @@
|
||||
|
||||
/*** 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 ************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -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)
|
||||
@ -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);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -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 */
|
||||
|
@ -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 ();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -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 */
|
||||
|
@ -147,5 +147,6 @@
|
||||
first-horiz-char=«
|
||||
last-horiz-char=»
|
||||
current-char=■
|
||||
background-char=▒
|
||||
background-vert-char=▒
|
||||
background-horiz-char=▒
|
||||
|
||||
|
@ -147,4 +147,5 @@
|
||||
first-horiz-char=«
|
||||
last-horiz-char=»
|
||||
current-char=■
|
||||
background-char=▒
|
||||
background-vert-char=▒
|
||||
background-horiz-char=▒
|
||||
|
@ -136,3 +136,8 @@
|
||||
[widget-panel]
|
||||
filename-scroll-left-char = {
|
||||
filename-scroll-right-char = }
|
||||
|
||||
[widget-scollbar]
|
||||
current-char=■
|
||||
background-vert-char=▒
|
||||
background-horiz-char=▒
|
||||
|
@ -179,4 +179,5 @@
|
||||
first-horiz-char=«
|
||||
last-horiz-char=»
|
||||
current-char=■
|
||||
background-char=▒
|
||||
background-vert-char=▒
|
||||
background-horiz-char=▒
|
||||
|
@ -179,4 +179,5 @@
|
||||
first-horiz-char=«
|
||||
last-horiz-char=»
|
||||
current-char=■
|
||||
background-char=▒
|
||||
background-vert-char=▒
|
||||
background-horiz-char=▒
|
||||
|
@ -179,4 +179,5 @@
|
||||
first-horiz-char=«
|
||||
last-horiz-char=»
|
||||
current-char=■
|
||||
background-char=▒
|
||||
background-vert-char=▒
|
||||
background-horiz-char=▒
|
||||
|
@ -179,4 +179,5 @@
|
||||
first-horiz-char=«
|
||||
last-horiz-char=»
|
||||
current-char=■
|
||||
background-char=▒
|
||||
background-vert-char=▒
|
||||
background-horiz-char=▒
|
||||
|
@ -179,4 +179,5 @@
|
||||
first-horiz-char=«
|
||||
last-horiz-char=»
|
||||
current-char=■
|
||||
background-char=▒
|
||||
background-vert-char=▒
|
||||
background-horiz-char=▒
|
||||
|
@ -179,4 +179,5 @@
|
||||
first-horiz-char=«
|
||||
last-horiz-char=»
|
||||
current-char=■
|
||||
background-char=▒
|
||||
background-vert-char=▒
|
||||
background-horiz-char=▒
|
||||
|
@ -179,4 +179,5 @@
|
||||
first-horiz-char=«
|
||||
last-horiz-char=»
|
||||
current-char=■
|
||||
background-char=▒
|
||||
background-vert-char=▒
|
||||
background-horiz-char=▒
|
||||
|
@ -179,4 +179,5 @@
|
||||
first-horiz-char=«
|
||||
last-horiz-char=»
|
||||
current-char=■
|
||||
background-char=▒
|
||||
background-vert-char=▒
|
||||
background-horiz-char=▒
|
||||
|
@ -197,5 +197,6 @@
|
||||
first-horiz-char=«
|
||||
last-horiz-char=»
|
||||
current-char=■
|
||||
background-char=▒
|
||||
background-vert-char=▒
|
||||
background-horiz-char=▒
|
||||
|
||||
|
@ -188,5 +188,6 @@
|
||||
first-horiz-char=«
|
||||
last-horiz-char=»
|
||||
current-char=■
|
||||
background-char=▒
|
||||
background-vert-char=▒
|
||||
background-horiz-char=▒
|
||||
|
||||
|
@ -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 ();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user