fixed missing gaps showing
This commit is contained in:
parent
dce97e6b3e
commit
9a6786b2b5
3 changed files with 58 additions and 80 deletions
|
|
@ -86,37 +86,3 @@ struct ct_bounds *dup_bounds(const struct ct_bounds *const bounds) {
|
|||
|
||||
return dup;
|
||||
}
|
||||
|
||||
/* Calculate the dimensions for nodes resulting from a bifurcation.
|
||||
* Returns 0 on success, and 1 on failure if any width/height are 0 characters.
|
||||
* WARNING: This function does not guarantee the x,y positions returned
|
||||
* WARNING: are valid screen coordinates.
|
||||
*/
|
||||
// int bifurcate_dims(const struct ct_dims *const parent_dims,
|
||||
// const enum ct_axis axis, const float ratio,
|
||||
// struct ct_dims **const dims0, struct ct_dims **const
|
||||
// dims1) {
|
||||
// assert(0 < ratio && ratio < 1);
|
||||
// struct ct_dims *_dims0, *_dims1;
|
||||
|
||||
// _dims0 = dup_dims(parent_dims);
|
||||
// _dims1 = dup_dims(parent_dims);
|
||||
|
||||
// if (axis == AXIS_X) {
|
||||
// _dims0->width *= ratio;
|
||||
// _dims1->width -= _dims0->width;
|
||||
// _dims1->x += _dims0->width;
|
||||
// } else {
|
||||
// _dims0->height *= ratio;
|
||||
// _dims1->height -= _dims0->height;
|
||||
// _dims1->y += _dims0->height;
|
||||
// }
|
||||
|
||||
// if (!_dims0->width || !_dims0->height || !_dims1->width || !_dims1->height)
|
||||
// return 1;
|
||||
|
||||
// // propagate bifurcated dimensions
|
||||
// *dims0 = _dims0;
|
||||
// *dims1 = _dims1;
|
||||
// return 0;
|
||||
// }
|
||||
|
|
|
|||
|
|
@ -103,42 +103,36 @@ int resize_node(struct ct_node *const node, struct ct_dims *dims) {
|
|||
}
|
||||
|
||||
int axm_size, axm_free;
|
||||
/* DEBUG: WARNING :DEBUG */
|
||||
// size_t bounds_axm_min_offset, bounds_axm_max_offset;
|
||||
// size_t dims_axm_pos_offset, dims_axm_size_offset;
|
||||
size_t bounds_axm_min_offset, bounds_axm_max_offset;
|
||||
size_t dims_axm_pos_offset, dims_axm_size_offset;
|
||||
|
||||
if (node->axis == AXIS_X) {
|
||||
axm_free = dims->width;
|
||||
axm_size = dims->width;
|
||||
|
||||
/* DEBUG: WARNING :DEBUG */
|
||||
// dims_axm_pos_offset = offsetof(struct ct_dims, x);
|
||||
// dims_axm_size_offset = offsetof(struct ct_dims, width);
|
||||
// bounds_axm_min_offset = offsetof(struct ct_bounds, wmin);
|
||||
// bounds_axm_max_offset = offsetof(struct ct_bounds, wmax);
|
||||
dims_axm_pos_offset = offsetof(struct ct_dims, x);
|
||||
dims_axm_size_offset = offsetof(struct ct_dims, width);
|
||||
bounds_axm_min_offset = offsetof(struct ct_bounds, wmin);
|
||||
bounds_axm_max_offset = offsetof(struct ct_bounds, wmax);
|
||||
} else {
|
||||
assert(node->axis == AXIS_Y);
|
||||
axm_free = dims->height;
|
||||
axm_size = dims->height;
|
||||
|
||||
/* DEBUG: WARNING :DEBUG */
|
||||
// dims_axm_pos_offset = offsetof(struct ct_dims, y);
|
||||
// dims_axm_size_offset = offsetof(struct ct_dims, height);
|
||||
// bounds_axm_min_offset = offsetof(struct ct_bounds, hmin);
|
||||
// bounds_axm_max_offset = offsetof(struct ct_bounds, hmax);
|
||||
dims_axm_pos_offset = offsetof(struct ct_dims, y);
|
||||
dims_axm_size_offset = offsetof(struct ct_dims, height);
|
||||
bounds_axm_min_offset = offsetof(struct ct_bounds, hmin);
|
||||
bounds_axm_max_offset = offsetof(struct ct_bounds, hmax);
|
||||
}
|
||||
|
||||
struct ct_spdims cspdims[node->cindex];
|
||||
cindex parts_n = node->cindex;
|
||||
memset(cspdims, 0, sizeof(struct ct_spdims) * node->cindex);
|
||||
for (int i = 0; i < node->cindex; i++) {
|
||||
/* DEBUG: WARNING :DEBUG */
|
||||
// cspdims[i].min =
|
||||
// *(int *)(node->child[i]->surface->bounds + bounds_axm_min_offset);
|
||||
// cspdims[i].max =
|
||||
// *(int *)(node->child[i]->surface->bounds + bounds_axm_max_offset);
|
||||
cspdims[i].min = node->child[i]->surface->bounds->wmin;
|
||||
cspdims[i].max = node->child[i]->surface->bounds->wmax;
|
||||
cspdims[i].min = *(int *)((char *)node->child[i]->surface->bounds +
|
||||
bounds_axm_min_offset);
|
||||
cspdims[i].max = *(int *)((char *)node->child[i]->surface->bounds +
|
||||
bounds_axm_max_offset);
|
||||
|
||||
if (node->child[i]->surface->bounds->type == BOUND_RELATIVE) {
|
||||
cspdims[i].min *= axm_size;
|
||||
|
|
@ -149,14 +143,15 @@ int resize_node(struct ct_node *const node, struct ct_dims *dims) {
|
|||
}
|
||||
|
||||
int split, new_size;
|
||||
while (parts_n) {
|
||||
split = axm_free / parts_n;
|
||||
while (axm_free && parts_n) {
|
||||
split = (axm_free > parts_n) ? (axm_free / parts_n) : 1;
|
||||
for (int i = 0; i < node->cindex; i++) {
|
||||
if (cspdims[i].fixed)
|
||||
continue;
|
||||
|
||||
new_size =
|
||||
clampi(cspdims[i].axm_size + split, cspdims[i].min, cspdims[i].max);
|
||||
|
||||
if (new_size == cspdims[i].axm_size) {
|
||||
cspdims[i].fixed = true;
|
||||
parts_n--;
|
||||
|
|
@ -165,22 +160,23 @@ int resize_node(struct ct_node *const node, struct ct_dims *dims) {
|
|||
|
||||
axm_free -= (new_size - cspdims[i].axm_size);
|
||||
cspdims[i].axm_size = new_size;
|
||||
|
||||
if (axm_free == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
struct ct_dims *cdims = dup_dims(dims);
|
||||
/* NOTE: the statements below are done implicitly by dup_dims */
|
||||
// *(int*)(cdims + dims_axm_pos_offset) = *(int*)(dims + dims_axm_pos_offset);
|
||||
// *(int*)(cdims + dims_axo_pos_offset) = *(int*)(dims + dims_axo_pos_offset);
|
||||
// *(int*)(cdims + dims_axm_pos_offset) = *(int*)(dims +
|
||||
// dims_axm_pos_offset);
|
||||
// *(int*)(cdims + dims_axo_pos_offset) = *(int*)(dims +
|
||||
// dims_axo_pos_offset);
|
||||
// *(int*)(cdims + dims_axo_size_offset) = axo_size;
|
||||
for (int i = 0; i < node->cindex; i++) {
|
||||
/* DEBUG: WARNING :DEBUG */
|
||||
// *(int *)(cdims + dims_axm_size_offset) = cspdims[i].axm_size;
|
||||
cdims->width = cspdims[i].axm_size;
|
||||
*(int *)((char *)cdims + dims_axm_size_offset) = cspdims[i].axm_size;
|
||||
resize_node(node->child[i], dup_dims(cdims));
|
||||
/* DEBUG: WARNING :DEBUG */
|
||||
// *(int *)(cdims + dims_axm_pos_offset) += cspdims[i].axm_size;
|
||||
cdims->x += cspdims[i].axm_size;
|
||||
*(int *)((char *)cdims + dims_axm_pos_offset) += cspdims[i].axm_size;
|
||||
}
|
||||
free(cdims);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue