WOP_TOP_SELECT: new widget option

...to place widget on top of other widgets in dialog.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2016-04-12 13:35:12 +03:00
parent 4b72fb5f5e
commit fd4e56bf39
7 changed files with 17 additions and 22 deletions

View File

@ -833,6 +833,7 @@ dlg_create (gboolean modal, int y1, int x1, int lines, int cols,
widget_init (w, y1, x1, lines, cols, (callback != NULL) ? callback : dlg_default_callback,
mouse_callback);
widget_want_cursor (w, FALSE);
w->options |= WOP_TOP_SELECT;
w->state |= WST_CONSTRUCT;
new_d->modal = modal;
@ -1120,18 +1121,10 @@ dlg_select_widget (void *w)
Widget *widget = WIDGET (w);
WDialog *h = widget->owner;
do_select_widget (h, g_list_find (h->widgets, widget), SELECT_EXACT);
}
/* --------------------------------------------------------------------------------------------- */
/**
* Set widget at top of widget list and make it current.
*/
void
dlg_set_top_widget (void *w)
{
dlg_set_top_or_bottom_widget (w, TRUE);
if (widget_get_options (widget, WOP_TOP_SELECT))
dlg_set_top_or_bottom_widget (w, TRUE);
else
do_select_widget (h, g_list_find (h->widgets, widget), SELECT_EXACT);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -159,7 +159,6 @@ void dlg_stop (WDialog * h);
/* Widget selection */
void dlg_select_widget (void *w);
void dlg_set_top_widget (void *w);
void dlg_set_bottom_widget (void *w);
void dlg_one_up (WDialog * h);
void dlg_one_down (WDialog * h);

View File

@ -892,9 +892,10 @@ menubar_new (int y, int x, int cols, GList * menu, gboolean visible)
menubar = g_new0 (WMenuBar, 1);
w = WIDGET (menubar);
widget_init (w, y, x, 1, cols, menubar_callback, menubar_mouse_callback);
w->options |= WOP_TOP_SELECT;
widget_want_cursor (w, FALSE);
menubar->is_visible = visible;
widget_want_cursor (w, FALSE);
menubar_set_menu (menubar, menu);
return menubar;
@ -1017,7 +1018,7 @@ menubar_activate (WMenuBar * menubar, gboolean dropped, int which)
/* Bring it to the top so it receives all mouse events before any other widget.
* See also comment in menubar_finish(). */
dlg_set_top_widget (w);
dlg_select_widget (w);
}
}

View File

@ -67,7 +67,8 @@ typedef enum
WOP_DEFAULT = (0 << 0),
WOP_WANT_HOTKEY = (1 << 1),
WOP_WANT_CURSOR = (1 << 2),
WOP_IS_INPUT = (1 << 3)
WOP_IS_INPUT = (1 << 3),
WOP_TOP_SELECT = (1 << 4)
} widget_options_t;
/* Widget state */

View File

@ -2097,6 +2097,7 @@ edit_init (WEdit * edit, int y, int x, int lines, int cols, const vfs_path_t * f
to_free = TRUE;
widget_init (WIDGET (edit), y, x, lines, cols, NULL, NULL);
widget_set_options (WIDGET (edit), WOP_TOP_SELECT, TRUE);
edit->fullscreen = TRUE;
edit_save_size (edit);
}

View File

@ -2262,7 +2262,7 @@ edit_close_cmd (WEdit * edit)
{
edit = find_editor (h);
if (edit != NULL)
dlg_set_top_widget (edit);
dlg_select_widget (edit);
}
}

View File

@ -356,7 +356,7 @@ edit_window_list (const WDialog * h)
if (rv >= 0)
{
w = g_list_nth (h->widgets, rv + offset);
dlg_set_top_widget (w->data);
dlg_select_widget (w->data);
}
}
@ -485,11 +485,11 @@ edit_dialog_command_execute (WDialog * h, long command)
break;
case CK_WindowNext:
dlg_one_down (h);
dlg_set_top_widget (h->current->data);
dlg_select_widget (h->current->data);
break;
case CK_WindowPrev:
dlg_one_up (h);
dlg_set_top_widget (h->current->data);
dlg_select_widget (h->current->data);
break;
case CK_Options:
edit_options_dialog (h);
@ -906,7 +906,7 @@ edit_dialog_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event)
if (top != h->current)
{
/* Window is not active. Activate it */
dlg_set_top_widget (e);
dlg_select_widget (e);
}
/* Handle buttons */
@ -1087,7 +1087,7 @@ edit_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event)
switch (msg)
{
case MSG_MOUSE_DOWN:
dlg_set_top_widget (w);
dlg_select_widget (w);
edit_update_curs_row (edit);
edit_update_curs_col (edit);