(setup_panels): refactoring: optimization

..,and change order of widget origin/size calculation.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2019-08-14 11:39:08 +03:00
parent 2b55c54efc
commit f6c4ae2f31

View File

@ -711,17 +711,47 @@ panel_update_cols (Widget * widget, panel_display_t frame_size)
void void
setup_panels (void) setup_panels (void)
{ {
/* File manager screen layout:
*
* +---------------------------------------------------------------+
* | Menu bar |
* +-------------------------------+-------------------------------+
* | | |
* | | |
* | | |
* | | |
* | Left panel | Right panel |
* | | |
* | | |
* | | |
* | | |
* +-------------------------------+-------------------------------+
* | Hint (message) bar |
* +---------------------------------------------------------------+
* | |
* | Console content |
* | |
* +--------+------------------------------------------------------+
* | Prompt | Command line |
* | Key (button) bar |
* +--------+------------------------------------------------------+
*/
int start_y; int start_y;
/* iniitial height of panels */
height =
LINES - menubar_visible - mc_global.message_visible - (command_prompt ? 1 : 0) -
mc_global.keybar_visible;
if (mc_global.tty.console_flag != '\0') if (mc_global.tty.console_flag != '\0')
{ {
int minimum; int minimum;
if (output_lines < 0) if (output_lines < 0)
output_lines = 0; output_lines = 0;
height = else
LINES - mc_global.keybar_visible - (command_prompt ? 1 : 0) - menubar_visible - height -= output_lines;
output_lines - mc_global.message_visible;
minimum = MINHEIGHT * (1 + panels_layout.horizontal_split); minimum = MINHEIGHT * (1 + panels_layout.horizontal_split);
if (height < minimum) if (height < minimum)
{ {
@ -729,12 +759,9 @@ setup_panels (void)
height = minimum; height = minimum;
} }
} }
else
{ widget_set_size (WIDGET (the_menubar), 0, 0, 1, COLS);
height = menubar_set_visible (the_menubar, menubar_visible);
LINES - menubar_visible - (command_prompt ? 1 : 0) - mc_global.keybar_visible -
mc_global.message_visible;
}
check_split (&panels_layout); check_split (&panels_layout);
start_y = menubar_visible; start_y = menubar_visible;
@ -758,7 +785,19 @@ setup_panels (void)
panels[1].widget->cols); panels[1].widget->cols);
} }
widget_set_size (WIDGET (the_menubar), 0, 0, 1, COLS); if (mc_global.message_visible)
widget_set_size (WIDGET (the_hint), height + start_y, 0, 1, COLS);
else
widget_set_size (WIDGET (the_hint), 0, 0, 0, 0);
/* Output window */
if (mc_global.tty.console_flag != '\0' && output_lines)
{
output_start_y = LINES - (command_prompt ? 1 : 0) - mc_global.keybar_visible - output_lines;
show_console_contents (output_start_y,
LINES - output_lines - mc_global.keybar_visible - 1,
LINES - mc_global.keybar_visible - 1);
}
if (command_prompt) if (command_prompt)
{ {
@ -776,20 +815,6 @@ setup_panels (void)
widget_set_size (WIDGET (the_bar), LINES - 1, 0, mc_global.keybar_visible, COLS); widget_set_size (WIDGET (the_bar), LINES - 1, 0, mc_global.keybar_visible, COLS);
buttonbar_set_visible (the_bar, mc_global.keybar_visible); buttonbar_set_visible (the_bar, mc_global.keybar_visible);
/* Output window */
if (mc_global.tty.console_flag != '\0' && output_lines)
{
output_start_y = LINES - (command_prompt ? 1 : 0) - mc_global.keybar_visible - output_lines;
show_console_contents (output_start_y,
LINES - output_lines - mc_global.keybar_visible - 1,
LINES - mc_global.keybar_visible - 1);
}
if (mc_global.message_visible)
widget_set_size (WIDGET (the_hint), height + start_y, 0, 1, COLS);
else
widget_set_size (WIDGET (the_hint), 0, 0, 0, 0);
update_xterm_title_path (); update_xterm_title_path ();
} }