1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-01 19:42:48 -05:00

dialog system: add a side-by-side alignment feature.

This will let us put two controls side by side (e.g. in disjoint
columns of a multi-col layout) and indicate that instead of the
default behaviour of aligning their top edges, their centreline (or,
even better if available, font baseline) should be aligned.

NFC: nothing uses this yet.
This commit is contained in:
Simon Tatham
2021-04-03 17:45:31 +01:00
parent d33f889a56
commit 1276c13e6a
5 changed files with 103 additions and 4 deletions

View File

@ -2491,6 +2491,28 @@ GtkWidget *layout_ctrls(
COLUMN_SPAN(ctrl->generic.column));
if (left)
columns_force_left_align(cols, w);
if (ctrl->generic.align_next_to) {
/*
* Implement align_next_to by simply forcing the two
* controls to have the same height of size allocation. At
* least for the controls we're currently doing this with,
* the GTK layout system will automatically vertically
* centre each control within its allocation, which will
* get the two controls aligned alongside each other
* reasonably well.
*/
struct uctrl *uc2 = dlg_find_byctrl(
dp, ctrl->generic.align_next_to);
assert(uc2);
columns_force_same_height(cols, w, uc2->toplevel);
#if GTK_CHECK_VERSION(3, 10, 0)
/* Slightly nicer to align baselines than just vertically
* centring, where the option is available */
gtk_widget_set_valign(w, GTK_ALIGN_BASELINE);
gtk_widget_set_valign(uc2->toplevel, GTK_ALIGN_BASELINE);
#endif
}
gtk_widget_show(w);
uc->toplevel = w;