diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2019-04-09 14:05:48 +0100 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2019-06-30 23:42:44 +0100 |
commit | 6b308cd71e1c6d37cd32a3b99d21e729e181aa8d (patch) | |
tree | a741e62656b9685662b1775a3d30bfca55ebf54e /gtk/gtkconstraintsolverprivate.h | |
parent | 3b6ee32f83882c8c2c736c7bb504a47bf1fdf407 (diff) | |
download | gtk+-6b308cd71e1c6d37cd32a3b99d21e729e181aa8d.tar.gz |
Add constraint solver
GtkConstraintSolver is an implementation of the Cassowary constraint
solving algorithm:
http://constraints.cs.washington.edu/cassowary/
The Cassowary method allows to incrementally solve a tableau of linear
equations, in the form of:
x = y × coefficient + constant
with different weights, or strengths, applied to each one.
These equations can be used to describe constraints applied to a layout
of UI elements, which allows layout managers using the Cassowary method
to quickly, and efficiently, lay out widgets in complex relations
between themselves and their parent container.
Diffstat (limited to 'gtk/gtkconstraintsolverprivate.h')
-rw-r--r-- | gtk/gtkconstraintsolverprivate.h | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/gtk/gtkconstraintsolverprivate.h b/gtk/gtkconstraintsolverprivate.h new file mode 100644 index 0000000000..807b0b08d6 --- /dev/null +++ b/gtk/gtkconstraintsolverprivate.h @@ -0,0 +1,114 @@ +/* gtkconstraintsolverprivate.h: Constraint solver based on the Cassowary method + * Copyright 2019 GNOME Foundation + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + * + * Author: Emmanuele Bassi + */ + +#pragma once + +#include "gtkconstrainttypesprivate.h" + +G_BEGIN_DECLS + +#define GTK_TYPE_CONSTRAINT_SOLVER (gtk_constraint_solver_get_type()) + +G_DECLARE_FINAL_TYPE (GtkConstraintSolver, gtk_constraint_solver, GTK, CONSTRAINT_SOLVER, GObject) + +GtkConstraintSolver * +gtk_constraint_solver_new (void); + +void +gtk_constraint_solver_freeze (GtkConstraintSolver *solver); + +void +gtk_constraint_solver_thaw (GtkConstraintSolver *solver); + +void +gtk_constraint_solver_resolve (GtkConstraintSolver *solver); + +GtkConstraintVariable * +gtk_constraint_solver_create_variable (GtkConstraintSolver *solver, + const char *prefix, + const char *name, + double value); + +GtkConstraintRef * +gtk_constraint_solver_add_constraint (GtkConstraintSolver *solver, + GtkConstraintVariable *variable, + GtkConstraintRelation relation, + GtkConstraintExpression *expression, + double strength); + +void +gtk_constraint_solver_remove_constraint (GtkConstraintSolver *solver, + GtkConstraintRef *reference); + +GtkConstraintRef * +gtk_constraint_solver_add_stay_variable (GtkConstraintSolver *solver, + GtkConstraintVariable *variable, + double strength); + +void +gtk_constraint_solver_remove_stay_variable (GtkConstraintSolver *solver, + GtkConstraintVariable *variable); + +gboolean +gtk_constraint_solver_has_stay_variable (GtkConstraintSolver *solver, + GtkConstraintVariable *variable); + +GtkConstraintRef * +gtk_constraint_solver_add_edit_variable (GtkConstraintSolver *solver, + GtkConstraintVariable *variable, + double strength); + +void +gtk_constraint_solver_remove_edit_variable (GtkConstraintSolver *solver, + GtkConstraintVariable *variable); + +gboolean +gtk_constraint_solver_has_edit_variable (GtkConstraintSolver *solver, + GtkConstraintVariable *variable); + +void +gtk_constraint_solver_suggest_value (GtkConstraintSolver *solver, + GtkConstraintVariable *variable, + double value); + +void +gtk_constraint_solver_begin_edit (GtkConstraintSolver *solver); + +void +gtk_constraint_solver_end_edit (GtkConstraintSolver *solver); + +void +gtk_constraint_solver_note_added_variable (GtkConstraintSolver *self, + GtkConstraintVariable *variable, + GtkConstraintVariable *subject); + +void +gtk_constraint_solver_note_removed_variable (GtkConstraintSolver *self, + GtkConstraintVariable *variable, + GtkConstraintVariable *subject); + +void +gtk_constraint_solver_clear (GtkConstraintSolver *solver); + +char * +gtk_constraint_solver_to_string (GtkConstraintSolver *solver); + +G_END_DECLS |