mirror of https://github.com/davatorium/rofi.git
Cleanup drawing a bit.
This commit is contained in:
parent
d9a9d2489a
commit
2277501566
|
@ -486,12 +486,14 @@ void config_sanity_check ( )
|
||||||
config.location = WL_CENTER;
|
config.location = WL_CENTER;
|
||||||
found_error = 1;
|
found_error = 1;
|
||||||
}
|
}
|
||||||
|
if ( 0 ) {
|
||||||
if ( !( config.line_margin >= 3 && config.line_margin <= 50 ) ) {
|
if ( !( config.line_margin >= 3 && config.line_margin <= 50 ) ) {
|
||||||
g_string_append_printf ( msg, "\t<b>config.line_margin</b>=%d is invalid. Value should be between %d and %d.\n",
|
g_string_append_printf ( msg, "\t<b>config.line_margin</b>=%d is invalid. Value should be between %d and %d.\n",
|
||||||
config.line_margin, 3, 50 );
|
config.line_margin, 3, 50 );
|
||||||
config.line_margin = 3;
|
config.line_margin = 3;
|
||||||
found_error = 1;
|
found_error = 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if ( found_error ) {
|
if ( found_error ) {
|
||||||
g_string_append ( msg, "Please update your configuration." );
|
g_string_append ( msg, "Please update your configuration." );
|
||||||
show_error_message ( msg->str, TRUE );
|
show_error_message ( msg->str, TRUE );
|
||||||
|
|
|
@ -818,7 +818,7 @@ static void menu_draw ( MenuState *state )
|
||||||
// Move, resize visible boxes and show them.
|
// Move, resize visible boxes and show them.
|
||||||
for ( i = 0; i < max_elements; i++ ) {
|
for ( i = 0; i < max_elements; i++ ) {
|
||||||
unsigned int ex = ( ( i ) / state->max_rows ) * ( element_width + config.line_margin );
|
unsigned int ex = ( ( i ) / state->max_rows ) * ( element_width + config.line_margin );
|
||||||
unsigned int ey = ( ( i ) % state->max_rows ) * ( element_height + config.line_margin ) + config.line_margin;
|
unsigned int ey = ( ( i ) % state->max_rows ) * ( element_height + config.line_margin );
|
||||||
// Move it around.
|
// Move it around.
|
||||||
textbox_moveresize ( state->boxes[i],
|
textbox_moveresize ( state->boxes[i],
|
||||||
ex + x_offset, ey + y_offset,
|
ex + x_offset, ey + y_offset,
|
||||||
|
@ -865,24 +865,24 @@ static void menu_update ( MenuState *state )
|
||||||
state->max_elements, state->arrowbox_top,
|
state->max_elements, state->arrowbox_top,
|
||||||
state->arrowbox_bottom );
|
state->arrowbox_bottom );
|
||||||
// Why do we need the special -1?
|
// Why do we need the special -1?
|
||||||
XDrawLine ( display, main_window, gc, ( config.padding ),
|
XDrawLine ( display, main_window, gc, 0,
|
||||||
state->line_height + ( config.padding ) + ( config.line_margin ) / 2,
|
state->line_height + ( config.padding ) * 1 + config.line_margin + 1,
|
||||||
state->w - ( ( config.padding ) ) - 1,
|
state->w - 1,
|
||||||
state->line_height + ( config.padding ) + ( config.line_margin ) / 2 );
|
state->line_height + ( config.padding ) * 1 + config.line_margin + 1 );
|
||||||
if ( state->message_tb ) {
|
if ( state->message_tb ) {
|
||||||
XDrawLine ( display, main_window, gc,
|
XDrawLine ( display, main_window, gc,
|
||||||
( config.padding ),
|
0,
|
||||||
state->top_offset + ( config.line_margin ) / 2,
|
state->top_offset - ( config.line_margin ) - 1,
|
||||||
state->w - ( ( config.padding ) ) - 1,
|
state->w - 1,
|
||||||
state->top_offset + ( config.line_margin ) / 2 );
|
state->top_offset - ( config.line_margin ) - 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( config.sidebar_mode == TRUE ) {
|
if ( config.sidebar_mode == TRUE ) {
|
||||||
XDrawLine ( display, main_window, gc,
|
XDrawLine ( display, main_window, gc,
|
||||||
( config.padding ),
|
0,
|
||||||
state->h - state->line_height - ( config.padding ) - config.line_margin / 2,
|
state->h - state->line_height - ( config.padding ) * 1 - 1 - config.line_margin,
|
||||||
state->w - ( ( config.padding ) ) - 1,
|
state->w - 1,
|
||||||
state->h - state->line_height - ( config.padding ) - config.line_margin / 2 );
|
state->h - state->line_height - ( config.padding ) * 1 - 1 - config.line_margin );
|
||||||
for ( unsigned int j = 0; j < num_switchers; j++ ) {
|
for ( unsigned int j = 0; j < num_switchers; j++ ) {
|
||||||
textbox_draw ( switchers[j]->tb );
|
textbox_draw ( switchers[j]->tb );
|
||||||
}
|
}
|
||||||
|
@ -1007,7 +1007,7 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom
|
||||||
NORMAL,
|
NORMAL,
|
||||||
*input );
|
*input );
|
||||||
|
|
||||||
state.top_offset = config.padding + state.line_height;
|
state.top_offset = config.padding * 1 + state.line_height + 2 + config.line_margin * 2;
|
||||||
|
|
||||||
// Move indicator to end.
|
// Move indicator to end.
|
||||||
textbox_move ( state.case_indicator,
|
textbox_move ( state.case_indicator,
|
||||||
|
@ -1023,7 +1023,7 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom
|
||||||
|
|
||||||
state.message_tb = NULL;
|
state.message_tb = NULL;
|
||||||
if ( message ) {
|
if ( message ) {
|
||||||
state.top_offset += config.menu_bw;
|
// state.top_offset += config.line_margin;
|
||||||
state.message_tb = textbox_create ( main_window, &vinfo, map, TB_AUTOHEIGHT | TB_MARKUP,
|
state.message_tb = textbox_create ( main_window, &vinfo, map, TB_AUTOHEIGHT | TB_MARKUP,
|
||||||
( config.padding ),
|
( config.padding ),
|
||||||
state.top_offset,
|
state.top_offset,
|
||||||
|
@ -1033,7 +1033,7 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom
|
||||||
message );
|
message );
|
||||||
textbox_show ( state.message_tb );
|
textbox_show ( state.message_tb );
|
||||||
state.top_offset += textbox_get_height ( state.message_tb );
|
state.top_offset += textbox_get_height ( state.message_tb );
|
||||||
state.top_offset += config.menu_bw;
|
state.top_offset += config.line_margin * 2 + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int element_height = state.line_height * config.element_height;
|
int element_height = state.line_height * config.element_height;
|
||||||
|
@ -1047,7 +1047,6 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom
|
||||||
state.boxes[i] = textbox_create ( main_window, &vinfo, map, 0,
|
state.boxes[i] = textbox_create ( main_window, &vinfo, map, 0,
|
||||||
x_offset, y_offset,
|
x_offset, y_offset,
|
||||||
state.element_width, element_height, NORMAL, "" );
|
state.element_width, element_height, NORMAL, "" );
|
||||||
textbox_show ( state.boxes[i] );
|
|
||||||
}
|
}
|
||||||
// Arrows
|
// Arrows
|
||||||
state.arrowbox_top = textbox_create ( main_window, &vinfo, map, TB_AUTOWIDTH,
|
state.arrowbox_top = textbox_create ( main_window, &vinfo, map, TB_AUTOWIDTH,
|
||||||
|
@ -1060,10 +1059,10 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom
|
||||||
"↓" );
|
"↓" );
|
||||||
textbox_move ( state.arrowbox_top,
|
textbox_move ( state.arrowbox_top,
|
||||||
state.w - config.padding - state.arrowbox_top->w,
|
state.w - config.padding - state.arrowbox_top->w,
|
||||||
state.top_offset + config.line_margin );
|
state.top_offset );
|
||||||
textbox_move ( state.arrowbox_bottom,
|
textbox_move ( state.arrowbox_bottom,
|
||||||
state.w - config.padding - state.arrowbox_bottom->w,
|
state.w - config.padding - state.arrowbox_bottom->w,
|
||||||
state.top_offset + ( state.max_rows - 1 ) * ( element_height + config.line_margin ) + config.line_margin );
|
state.top_offset + ( state.max_rows - 1 ) * ( element_height + config.line_margin ) );
|
||||||
|
|
||||||
// filtered list
|
// filtered list
|
||||||
state.line_map = g_malloc0_n ( state.num_lines, sizeof ( int ) );
|
state.line_map = g_malloc0_n ( state.num_lines, sizeof ( int ) );
|
||||||
|
@ -1073,11 +1072,12 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom
|
||||||
|
|
||||||
// resize window vertically to suit
|
// resize window vertically to suit
|
||||||
// Subtract the margin of the last row.
|
// Subtract the margin of the last row.
|
||||||
state.h = state.top_offset + ( element_height + config.line_margin ) * state.max_rows + ( config.padding ) + config.line_margin;
|
state.h = state.top_offset + ( element_height + config.line_margin ) * ( state.max_rows ) - config.line_margin;
|
||||||
|
state.h += config.padding;
|
||||||
|
state.h += 0;
|
||||||
// Add entry
|
// Add entry
|
||||||
if ( config.sidebar_mode == TRUE ) {
|
if ( config.sidebar_mode == TRUE ) {
|
||||||
state.h += state.line_height + config.line_margin * 0;
|
state.h += state.line_height + 2 * config.line_margin + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sidebar mode.
|
// Sidebar mode.
|
||||||
|
|
Loading…
Reference in New Issue