summaryrefslogtreecommitdiff
path: root/gtk/gtkconstraintsolverprivate.h
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2019-07-01 12:39:24 +0100
committerEmmanuele Bassi <ebassi@gnome.org>2019-07-01 12:39:24 +0100
commit4dd1de41293cdb5ca06d64136ab5549794f1cac3 (patch)
tree0cb179008372f1ee65f6d3f4e1d568e2fd66795d /gtk/gtkconstraintsolverprivate.h
parent48e6cd42559558956350620e9deb744219a1bd04 (diff)
downloadgtk+-4dd1de41293cdb5ca06d64136ab5549794f1cac3.tar.gz
Use explicit values for constraint strength
Instead of playing games with mapping negative symbolic values to positive ones, let's use the appropriate constants everywhere. This allows us to use: GTK_CONSTRAINT_STRENGTH_WEAK * 2 Or GTK_CONSTRAINT_STRENGTH_STRONG + 1 In code using the public API. We also store the strength values as integers, so we can compare them properly, and only turn them into doubles when they are inserted into the solver, just like every other variable.
Diffstat (limited to 'gtk/gtkconstraintsolverprivate.h')
-rw-r--r--gtk/gtkconstraintsolverprivate.h37
1 files changed, 3 insertions, 34 deletions
diff --git a/gtk/gtkconstraintsolverprivate.h b/gtk/gtkconstraintsolverprivate.h
index bf2e0df8b6..cb7f74e681 100644
--- a/gtk/gtkconstraintsolverprivate.h
+++ b/gtk/gtkconstraintsolverprivate.h
@@ -29,37 +29,6 @@ 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);
@@ -83,7 +52,7 @@ gtk_constraint_solver_add_constraint (GtkConstraintSolver *solver,
GtkConstraintVariable *variable,
GtkConstraintRelation relation,
GtkConstraintExpression *expression,
- double strength);
+ int strength);
void
gtk_constraint_solver_remove_constraint (GtkConstraintSolver *solver,
@@ -92,7 +61,7 @@ gtk_constraint_solver_remove_constraint (GtkConstraintSolver *solver,
GtkConstraintRef *
gtk_constraint_solver_add_stay_variable (GtkConstraintSolver *solver,
GtkConstraintVariable *variable,
- double strength);
+ int strength);
void
gtk_constraint_solver_remove_stay_variable (GtkConstraintSolver *solver,
@@ -105,7 +74,7 @@ gtk_constraint_solver_has_stay_variable (GtkConstraintSolver *solver,
GtkConstraintRef *
gtk_constraint_solver_add_edit_variable (GtkConstraintSolver *solver,
GtkConstraintVariable *variable,
- double strength);
+ int strength);
void
gtk_constraint_solver_remove_edit_variable (GtkConstraintSolver *solver,