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,6 +429,8 @@ void Hy3Layout::resizeActiveWindow(const Vector2D& delta, eRectCorner corner, CW
|
|||
if (display_left && display_right) resize_delta.x = 0;
|
||||
if (display_top && display_bottom) resize_delta.y = 0;
|
||||
|
||||
// Don't execute the logic unless there's something to do
|
||||
if(resize_delta.x != 0 || resize_delta.y != 0) {
|
||||
ShiftDirection target_edge_x;
|
||||
ShiftDirection target_edge_y;
|
||||
|
||||
|
@ -468,6 +470,7 @@ void Hy3Layout::resizeActiveWindow(const Vector2D& delta, eRectCorner corner, CW
|
|||
if(vertical_neighbor) {
|
||||
vertical_neighbor->resize(reverse(target_edge_y), resize_delta.y, *animate == 0);
|
||||
}
|
||||
}
|
||||
} else if(window->m_bIsFloating) {
|
||||
// No parent node - is this a floating window? If so, use the same logic as the `main` layout
|
||||
const auto required_size = Vector2D(
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "Hy3Node.hpp"
|
||||
#include "globals.hpp"
|
||||
|
||||
const float MIN_WINDOW_SIZE = 20;
|
||||
const float MIN_RATIO = 0.0f;
|
||||
|
||||
// Hy3GroupData //
|
||||
|
||||
|
@ -945,9 +945,11 @@ void Hy3Node::resize(
|
|||
auto requested_size_ratio = this->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;
|
||||
neighbor->size_ratio = requested_neighbor_size_ratio;
|
||||
|
||||
parent_node->recalcSizePosRecursive(no_animation);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue