mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 04:46:55 +03:00
Merge branch '3173_popup_location'
* 3173_popup_location: (dlg_set_size): clarify comment and hangling of DLG_TRYUP flag. Ticket #3173: fix location of popup windows upon screen resize.
This commit is contained in:
commit
5ae9521760
@ -700,7 +700,7 @@ dlg_set_position (WDialog * h, int y1, int x1, int y2, int x2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
/** this function sets only size, leaving positioning to automatic methods */
|
/** Set dialog size and position */
|
||||||
|
|
||||||
void
|
void
|
||||||
dlg_set_size (WDialog * h, int lines, int cols)
|
dlg_set_size (WDialog * h, int lines, int cols)
|
||||||
@ -708,14 +708,19 @@ dlg_set_size (WDialog * h, int lines, int cols)
|
|||||||
int x = WIDGET (h)->x;
|
int x = WIDGET (h)->x;
|
||||||
int y = WIDGET (h)->y;
|
int y = WIDGET (h)->y;
|
||||||
|
|
||||||
if (h->flags & DLG_CENTER)
|
if ((h->flags & DLG_CENTER) != 0)
|
||||||
{
|
{
|
||||||
y = (LINES - lines) / 2;
|
y = (LINES - lines) / 2;
|
||||||
x = (COLS - cols) / 2;
|
x = (COLS - cols) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((h->flags & DLG_TRYUP) && (y > 3))
|
if ((h->flags & DLG_TRYUP) != 0)
|
||||||
y -= 2;
|
{
|
||||||
|
if (y > 3)
|
||||||
|
y -= 2;
|
||||||
|
else if (y == 3)
|
||||||
|
y = 2;
|
||||||
|
}
|
||||||
|
|
||||||
dlg_set_position (h, y, x, y + lines, x + cols);
|
dlg_set_position (h, y, x, y + lines, x + cols);
|
||||||
}
|
}
|
||||||
|
@ -61,8 +61,9 @@ create_listbox_window_centered (int center_y, int center_x, int lines, int cols,
|
|||||||
{
|
{
|
||||||
const int space = 4;
|
const int space = 4;
|
||||||
|
|
||||||
int xpos, ypos;
|
int xpos = 0, ypos = 0;
|
||||||
Listbox *listbox;
|
Listbox *listbox;
|
||||||
|
dlg_flags_t dlg_flags = DLG_TRYUP;
|
||||||
|
|
||||||
/* Adjust sizes */
|
/* Adjust sizes */
|
||||||
lines = min (lines, LINES - 6);
|
lines = min (lines, LINES - 6);
|
||||||
@ -79,34 +80,33 @@ create_listbox_window_centered (int center_y, int center_x, int lines, int cols,
|
|||||||
|
|
||||||
/* adjust position */
|
/* adjust position */
|
||||||
if ((center_y < 0) || (center_x < 0))
|
if ((center_y < 0) || (center_x < 0))
|
||||||
{
|
dlg_flags |= DLG_CENTER;
|
||||||
ypos = LINES / 2;
|
|
||||||
xpos = COLS / 2;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/* Actually, this this is not used in MC. */
|
||||||
|
|
||||||
ypos = center_y;
|
ypos = center_y;
|
||||||
xpos = center_x;
|
xpos = center_x;
|
||||||
|
|
||||||
|
ypos -= lines / 2;
|
||||||
|
xpos -= cols / 2;
|
||||||
|
|
||||||
|
if (ypos + lines >= LINES)
|
||||||
|
ypos = LINES - lines - space;
|
||||||
|
if (ypos < 0)
|
||||||
|
ypos = 0;
|
||||||
|
|
||||||
|
if (xpos + cols >= COLS)
|
||||||
|
xpos = COLS - cols - space;
|
||||||
|
if (xpos < 0)
|
||||||
|
xpos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ypos -= lines / 2;
|
|
||||||
xpos -= cols / 2;
|
|
||||||
|
|
||||||
if (ypos + lines >= LINES)
|
|
||||||
ypos = LINES - lines - space;
|
|
||||||
if (ypos < 0)
|
|
||||||
ypos = 0;
|
|
||||||
|
|
||||||
if (xpos + cols >= COLS)
|
|
||||||
xpos = COLS - cols - space;
|
|
||||||
if (xpos < 0)
|
|
||||||
xpos = 0;
|
|
||||||
|
|
||||||
listbox = g_new (Listbox, 1);
|
listbox = g_new (Listbox, 1);
|
||||||
|
|
||||||
listbox->dlg =
|
listbox->dlg =
|
||||||
dlg_create (TRUE, ypos, xpos, lines + space, cols + space,
|
dlg_create (TRUE, ypos, xpos, lines + space, cols + space,
|
||||||
listbox_colors, NULL, NULL, help, title, DLG_TRYUP);
|
listbox_colors, NULL, NULL, help, title, dlg_flags);
|
||||||
|
|
||||||
listbox->list = listbox_new (2, 2, lines, cols, FALSE, NULL);
|
listbox->list = listbox_new (2, 2, lines, cols, FALSE, NULL);
|
||||||
add_widget (listbox->dlg, listbox->list);
|
add_widget (listbox->dlg, listbox->list);
|
||||||
|
Loading…
Reference in New Issue
Block a user