Modify WTree creation API.

* (tree_init): use WRect to define widget area.
 * (create_panel): sync with modified API.
 * (tree_box): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2024-02-18 13:28:45 +03:00
parent 46dde8697b
commit d16ca7a1f5
4 changed files with 7 additions and 6 deletions

View File

@ -1077,6 +1077,7 @@ char *
tree_box (const char *current_dir) tree_box (const char *current_dir)
{ {
WTree *mytree; WTree *mytree;
WRect r;
WDialog *dlg; WDialog *dlg;
WGroup *g; WGroup *g;
Widget *wd; Widget *wd;
@ -1091,7 +1092,8 @@ tree_box (const char *current_dir)
g = GROUP (dlg); g = GROUP (dlg);
wd = WIDGET (dlg); wd = WIDGET (dlg);
mytree = tree_new (2, 2, wd->rect.lines - 6, wd->rect.cols - 5, FALSE); rect_init (&r, 2, 2, wd->rect.lines - 6, wd->rect.cols - 5);
mytree = tree_new (&r, FALSE);
group_add_widget_autopos (g, mytree, WPOS_KEEP_ALL, NULL); group_add_widget_autopos (g, mytree, WPOS_KEEP_ALL, NULL);
group_add_widget_autopos (g, hline_new (wd->rect.lines - 4, 1, -1), WPOS_KEEP_BOTTOM, NULL); group_add_widget_autopos (g, hline_new (wd->rect.lines - 4, 1, -1), WPOS_KEEP_BOTTOM, NULL);
bar = buttonbar_new (); bar = buttonbar_new ();

View File

@ -1192,7 +1192,7 @@ create_panel (int num, panel_view_mode_t type)
break; break;
case view_tree: case view_tree:
new_widget = WIDGET (tree_new (r.y, r.x, r.lines, r.cols, TRUE)); new_widget = WIDGET (tree_new (&r, TRUE));
break; break;
case view_quick: case view_quick:

View File

@ -1282,16 +1282,15 @@ tree_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
WTree * WTree *
tree_new (int y, int x, int lines, int cols, gboolean is_panel) tree_new (const WRect * r, gboolean is_panel)
{ {
WRect r = { y, x, lines, cols };
WTree *tree; WTree *tree;
Widget *w; Widget *w;
tree = g_new (WTree, 1); tree = g_new (WTree, 1);
w = WIDGET (tree); w = WIDGET (tree);
widget_init (w, &r, tree_callback, tree_mouse_callback); widget_init (w, r, tree_callback, tree_mouse_callback);
w->options |= WOP_SELECTABLE | WOP_TOP_SELECT; w->options |= WOP_SELECTABLE | WOP_TOP_SELECT;
w->keymap = tree_map; w->keymap = tree_map;

View File

@ -22,7 +22,7 @@ extern gboolean xtree_mode;
/*** declarations of public functions ************************************************************/ /*** declarations of public functions ************************************************************/
WTree *tree_new (int y, int x, int lines, int cols, gboolean is_panel); WTree *tree_new (const WRect * r, gboolean is_panel);
void tree_chdir (WTree * tree, const vfs_path_t * dir); void tree_chdir (WTree * tree, const vfs_path_t * dir);
const vfs_path_t *tree_selected_name (const WTree * tree); const vfs_path_t *tree_selected_name (const WTree * tree);