mirror of
https://github.com/weechat/weechat.git
synced 2026-07-09 11:13:12 +02:00
core: add resize of window parents (closes #893)
This commit is contained in:
committed by
Sébastien Helleu
parent
2f2b04e139
commit
1b23cd3a47
@@ -1874,7 +1874,7 @@ gui_window_split_vertical (struct t_gui_window *window, int percentage)
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_resize (struct t_gui_window *window, int percentage)
|
||||
gui_window_resize (struct t_gui_window_tree *tree, int percentage)
|
||||
{
|
||||
struct t_gui_window_tree *parent;
|
||||
int old_split_pct, add_bottom, add_top, add_left, add_right;
|
||||
@@ -1882,12 +1882,12 @@ gui_window_resize (struct t_gui_window *window, int percentage)
|
||||
if (!gui_init_ok)
|
||||
return;
|
||||
|
||||
parent = window->ptr_tree->parent_node;
|
||||
parent = tree->parent_node;
|
||||
if (parent)
|
||||
{
|
||||
old_split_pct = parent->split_pct;
|
||||
if (((parent->split_horizontal) && (window->ptr_tree == parent->child2))
|
||||
|| ((!(parent->split_horizontal)) && (window->ptr_tree == parent->child1)))
|
||||
if (((parent->split_horizontal) && (tree == parent->child2))
|
||||
|| ((!(parent->split_horizontal)) && (tree == parent->child1)))
|
||||
{
|
||||
parent->split_pct = percentage;
|
||||
}
|
||||
@@ -1916,7 +1916,7 @@ gui_window_resize (struct t_gui_window *window, int percentage)
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_resize_delta (struct t_gui_window *window, int delta_percentage)
|
||||
gui_window_resize_delta (struct t_gui_window_tree *tree, int delta_percentage)
|
||||
{
|
||||
struct t_gui_window_tree *parent;
|
||||
int old_split_pct, add_bottom, add_top, add_left, add_right;
|
||||
@@ -1924,12 +1924,12 @@ gui_window_resize_delta (struct t_gui_window *window, int delta_percentage)
|
||||
if (!gui_init_ok)
|
||||
return;
|
||||
|
||||
parent = window->ptr_tree->parent_node;
|
||||
parent = tree->parent_node;
|
||||
if (parent)
|
||||
{
|
||||
old_split_pct = parent->split_pct;
|
||||
if (((parent->split_horizontal) && (window->ptr_tree == parent->child2))
|
||||
|| ((!(parent->split_horizontal)) && (window->ptr_tree == parent->child1)))
|
||||
if (((parent->split_horizontal) && (tree == parent->child2))
|
||||
|| ((!(parent->split_horizontal)) && (tree == parent->child1)))
|
||||
{
|
||||
parent->split_pct += delta_percentage;
|
||||
}
|
||||
|
||||
@@ -343,6 +343,27 @@ gui_window_tree_free (struct t_gui_window_tree **tree)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Searches a parent window which is split on the given direction
|
||||
* ('h' or 'v').
|
||||
*/
|
||||
|
||||
struct t_gui_window_tree *
|
||||
gui_window_tree_get_split (struct t_gui_window_tree *tree,
|
||||
char direction)
|
||||
{
|
||||
if (!tree->parent_node)
|
||||
return tree;
|
||||
|
||||
if (((tree->parent_node->split_horizontal) && (direction == 'h'))
|
||||
|| (!(tree->parent_node->split_horizontal) && (direction == 'v')))
|
||||
{
|
||||
return tree;
|
||||
}
|
||||
|
||||
return gui_window_tree_get_split (tree->parent_node, direction);
|
||||
}
|
||||
|
||||
/*
|
||||
* Searches for a scroll with buffer pointer.
|
||||
*
|
||||
|
||||
@@ -146,6 +146,8 @@ extern int gui_window_tree_init (struct t_gui_window *window);
|
||||
extern void gui_window_tree_node_to_leaf (struct t_gui_window_tree *node,
|
||||
struct t_gui_window *window);
|
||||
extern void gui_window_tree_free (struct t_gui_window_tree **tree);
|
||||
extern struct t_gui_window_tree *gui_window_tree_get_split (struct t_gui_window_tree *tree,
|
||||
char direction);
|
||||
extern void gui_window_scroll_switch (struct t_gui_window *window,
|
||||
struct t_gui_buffer *buffer);
|
||||
extern void gui_window_scroll_remove_buffer (struct t_gui_window *window,
|
||||
@@ -226,8 +228,8 @@ extern struct t_gui_window *gui_window_split_horizontal (struct t_gui_window *wi
|
||||
int percentage);
|
||||
extern struct t_gui_window *gui_window_split_vertical (struct t_gui_window *window,
|
||||
int percentage);
|
||||
extern void gui_window_resize (struct t_gui_window *window, int percentage);
|
||||
extern void gui_window_resize_delta (struct t_gui_window *window,
|
||||
extern void gui_window_resize (struct t_gui_window_tree *tree, int percentage);
|
||||
extern void gui_window_resize_delta (struct t_gui_window_tree *tree,
|
||||
int delta_percentage);
|
||||
extern int gui_window_merge (struct t_gui_window *window);
|
||||
extern void gui_window_merge_all (struct t_gui_window *window);
|
||||
|
||||
Reference in New Issue
Block a user