diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2019-04-09 15:33:52 +0100 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2019-06-30 23:42:44 +0100 |
commit | cdf80f1d652114a6bb7c9a3d38adec61f8dbcabb (patch) | |
tree | c1cd3872541d8c1e27bc2e6cb5dd28b24697ae7d /gtk/gtkconstraintsolverprivate.h | |
parent | e7b2c530c512523242270caaaa8e0a15bf99e492 (diff) | |
download | gtk+-cdf80f1d652114a6bb7c9a3d38adec61f8dbcabb.tar.gz |
Add GtkConstraintLayout
A layout manager using GtkConstraintSolver to measure and allocate
children.
Diffstat (limited to 'gtk/gtkconstraintsolverprivate.h')
-rw-r--r-- | gtk/gtkconstraintsolverprivate.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/gtk/gtkconstraintsolverprivate.h b/gtk/gtkconstraintsolverprivate.h index 807b0b08d6..69eed376c7 100644 --- a/gtk/gtkconstraintsolverprivate.h +++ b/gtk/gtkconstraintsolverprivate.h @@ -29,6 +29,37 @@ G_BEGIN_DECLS G_DECLARE_FINAL_TYPE (GtkConstraintSolver, gtk_constraint_solver, GTK, CONSTRAINT_SOLVER, GObject) +/* Symbolic weight thresholds + * + * Constraint weights live on a continuum, but we use thresholds for simplicity's + * sake, so we don't have to necessarily reason in terms of numeric values. + * + * The public API has a similar approach, where the symbolic constants are negative + * values, and positive values are explicit weights. We map those values into + * numeric values that the GtkConstraintSolver can plug into the linear equations + * tableau. + */ +#define GTK_CONSTRAINT_WEIGHT_REQUIRED (make_weight (1000, 1000, 1000, 1)) +#define GTK_CONSTRAINT_WEIGHT_STRONG (make_weight ( 1, 0, 0, 1)) +#define GTK_CONSTRAINT_WEIGHT_MEDIUM (make_weight ( 0, 1, 0, 1)) +#define GTK_CONSTRAINT_WEIGHT_WEAK (make_weight ( 0, 0, 1, 1)) + +G_GNUC_PURE +static inline double +make_weight (double a, + double b, + double c, + double w) +{ + double res = 0; + + res += CLAMP (a * w, 0, 1000) * 1000000; + res += CLAMP (b * w, 0, 1000) * 1000; + res += CLAMP (c * w, 0, 1000); + + return res; +} + GtkConstraintSolver * gtk_constraint_solver_new (void); |