1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-18 11:31:00 -05:00

Improve the align_next_to mechanism.

Various alignments I want to do in the host CA box have shown up
deficiencies in this system, so I've reworked it a bit.

Firstly, you can now specify more than two controls to be tied
together with an align_next_to (e.g. multiple checkboxes alongside
something else).

Secondly, as well as forcing the controls to be the same height as
each other, the layout algorithm will also move the later controls
further _downward_, so that their top y positions also line up. Until
now that hasn't been necessary, because they lined up already.

In the GTK implementation of this via the Columns class, I've renamed
'columns_force_same_height' to 'columns_align_next_to', and similarly
for some of the internal fields, since the latter change makes the
previous names a misnomer.

In the Windows implementation, I found it most convenient to set this
up by following a linked list of align_next_to fields backwards. But
it won't always be convenient to initialise them that way, so I've
also written a crude normaliser that will rewrite those links into a
canonical form. But I only call that on Windows; it's unnecessary in
GTK, where the Columns class provides plenty of per-widget extra
storage so I just keep each alignment class as a circular list.
This commit is contained in:
Simon Tatham
2022-05-02 14:37:11 +01:00
parent a5717f5ac2
commit b5ab90143a
7 changed files with 162 additions and 56 deletions

View File

@ -163,14 +163,20 @@ struct dlgcontrol {
*/
intorptr helpctx;
/*
* Setting this to non-NULL coerces two controls to have their
* y-coordinates adjusted so that they can sit alongside each
* other and look nicely aligned, even if they're different
* Setting this to non-NULL coerces two or more controls to have
* their y-coordinates adjusted so that they can sit alongside
* each other and look nicely aligned, even if they're different
* heights.
*
* Set this field on the _second_ control of the pair (in terms of
* order in the data structure), so that when it's instantiated,
* the first one is already there to be referred to.
* Set this field on later controls (in terms of order in the data
* structure), pointing back to earlier ones, so that when each
* control is instantiated, the referred-to one is already there
* to be referred to.
*
* Don't expect this to change the position of the _first_
* control. Currently, the layout is done one control at a time,
* so that once the first control has been placed, the second one
* can't cause the first one to be retrospectively moved.
*/
dlgcontrol *align_next_to;
@ -667,3 +673,9 @@ int ctrl_path_elements(const char *path);
/* Return the number of matching path elements at the starts of p1 and p2,
* or INT_MAX if the paths are identical. */
int ctrl_path_compare(const char *p1, const char *p2);
/*
* Normalise the align_next_to fields in a controlset so that they
* form a backwards linked list.
*/
void ctrlset_normalise_aligns(struct controlset *s);