mirror of
https://github.com/Trensa-Organization/hy3.git
synced 2025-03-15 18:53:40 +01:00
Use MIN_RATIO to cap node sizes
A minimum Vector2D would be ideal, but hard to calculate - it would require either a tree walk for every single resize operation (very expensive), or storing after a `recalcSizePosRecursive` operation (significant work)
This commit is contained in:
parent
dad1589d21
commit
cfa15c9ef6
2 changed files with 39 additions and 34 deletions
|
@ -429,44 +429,47 @@ void Hy3Layout::resizeActiveWindow(const Vector2D& delta, eRectCorner corner, CW
|
||||||
if (display_left && display_right) resize_delta.x = 0;
|
if (display_left && display_right) resize_delta.x = 0;
|
||||||
if (display_top && display_bottom) resize_delta.y = 0;
|
if (display_top && display_bottom) resize_delta.y = 0;
|
||||||
|
|
||||||
ShiftDirection target_edge_x;
|
// Don't execute the logic unless there's something to do
|
||||||
ShiftDirection target_edge_y;
|
if(resize_delta.x != 0 || resize_delta.y != 0) {
|
||||||
|
ShiftDirection target_edge_x;
|
||||||
|
ShiftDirection target_edge_y;
|
||||||
|
|
||||||
// Determine the direction in which we're going to look for the neighbor node
|
// Determine the direction in which we're going to look for the neighbor node
|
||||||
// that will be resized
|
// that will be resized
|
||||||
if(corner == CORNER_NONE) { // It's probably a keyboard event.
|
if(corner == CORNER_NONE) { // It's probably a keyboard event.
|
||||||
target_edge_x = display_right ? ShiftDirection::Left : ShiftDirection::Right;
|
target_edge_x = display_right ? ShiftDirection::Left : ShiftDirection::Right;
|
||||||
target_edge_y = display_bottom ? ShiftDirection::Up : ShiftDirection::Down;
|
target_edge_y = display_bottom ? ShiftDirection::Up : ShiftDirection::Down;
|
||||||
|
|
||||||
// If the anchor is not at the top/left then reverse the delta
|
// If the anchor is not at the top/left then reverse the delta
|
||||||
if(target_edge_x == ShiftDirection::Left) resize_delta.x = -resize_delta.x;
|
if(target_edge_x == ShiftDirection::Left) resize_delta.x = -resize_delta.x;
|
||||||
if(target_edge_y == ShiftDirection::Up) resize_delta.y = -resize_delta.y;
|
if(target_edge_y == ShiftDirection::Up) resize_delta.y = -resize_delta.y;
|
||||||
} else { // It's probably a mouse event
|
} else { // It's probably a mouse event
|
||||||
// Resize against the edges corresponding to the selected corner
|
// Resize against the edges corresponding to the selected corner
|
||||||
target_edge_x = corner == CORNER_TOPLEFT || corner == CORNER_BOTTOMLEFT
|
target_edge_x = corner == CORNER_TOPLEFT || corner == CORNER_BOTTOMLEFT
|
||||||
? ShiftDirection::Left : ShiftDirection::Right;
|
? ShiftDirection::Left : ShiftDirection::Right;
|
||||||
target_edge_y = corner == CORNER_TOPLEFT || corner == CORNER_TOPRIGHT
|
target_edge_y = corner == CORNER_TOPLEFT || corner == CORNER_TOPRIGHT
|
||||||
? ShiftDirection::Up : ShiftDirection::Down;
|
? ShiftDirection::Up : ShiftDirection::Down;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the neighboring node in each axis, which will be either above or at the
|
// Find the neighboring node in each axis, which will be either above or at the
|
||||||
// same level as the initiating node in the layout hierarchy. These are the nodes
|
// same level as the initiating node in the layout hierarchy. These are the nodes
|
||||||
// which must get resized (rather than the initiator) because they are the
|
// which must get resized (rather than the initiator) because they are the
|
||||||
// highest point in the hierarchy
|
// highest point in the hierarchy
|
||||||
auto horizontal_neighbor = node->findNeighbor(target_edge_x);
|
auto horizontal_neighbor = node->findNeighbor(target_edge_x);
|
||||||
auto vertical_neighbor = node->findNeighbor(target_edge_y);
|
auto vertical_neighbor = node->findNeighbor(target_edge_y);
|
||||||
|
|
||||||
const auto animate =
|
const auto animate =
|
||||||
&g_pConfigManager->getConfigValuePtr("misc:animate_manual_resizes")->intValue;
|
&g_pConfigManager->getConfigValuePtr("misc:animate_manual_resizes")->intValue;
|
||||||
|
|
||||||
// Note that the resize direction is reversed, because from the neighbor's perspective
|
// Note that the resize direction is reversed, because from the neighbor's perspective
|
||||||
// the edge to be moved is the opposite way round. However, the delta is still the same.
|
// the edge to be moved is the opposite way round. However, the delta is still the same.
|
||||||
if(horizontal_neighbor) {
|
if(horizontal_neighbor) {
|
||||||
horizontal_neighbor->resize(reverse(target_edge_x), resize_delta.x, *animate == 0);
|
horizontal_neighbor->resize(reverse(target_edge_x), resize_delta.x, *animate == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(vertical_neighbor) {
|
if(vertical_neighbor) {
|
||||||
vertical_neighbor->resize(reverse(target_edge_y), resize_delta.y, *animate == 0);
|
vertical_neighbor->resize(reverse(target_edge_y), resize_delta.y, *animate == 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if(window->m_bIsFloating) {
|
} else if(window->m_bIsFloating) {
|
||||||
// No parent node - is this a floating window? If so, use the same logic as the `main` layout
|
// No parent node - is this a floating window? If so, use the same logic as the `main` layout
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include "Hy3Node.hpp"
|
#include "Hy3Node.hpp"
|
||||||
#include "globals.hpp"
|
#include "globals.hpp"
|
||||||
|
|
||||||
const float MIN_WINDOW_SIZE = 20;
|
const float MIN_RATIO = 0.0f;
|
||||||
|
|
||||||
// Hy3GroupData //
|
// Hy3GroupData //
|
||||||
|
|
||||||
|
@ -945,9 +945,11 @@ void Hy3Node::resize(
|
||||||
auto requested_size_ratio = this->size_ratio + ratio_mod;
|
auto requested_size_ratio = this->size_ratio + ratio_mod;
|
||||||
auto requested_neighbor_size_ratio = neighbor->size_ratio -ratio_mod;
|
auto requested_neighbor_size_ratio = neighbor->size_ratio -ratio_mod;
|
||||||
|
|
||||||
if(requested_size_ratio * parent_size >= MIN_WINDOW_SIZE) {
|
if(requested_size_ratio >= MIN_RATIO
|
||||||
|
&& requested_neighbor_size_ratio >= MIN_RATIO) {
|
||||||
this->size_ratio = requested_size_ratio;
|
this->size_ratio = requested_size_ratio;
|
||||||
neighbor->size_ratio = requested_neighbor_size_ratio;
|
neighbor->size_ratio = requested_neighbor_size_ratio;
|
||||||
|
|
||||||
parent_node->recalcSizePosRecursive(no_animation);
|
parent_node->recalcSizePosRecursive(no_animation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue