Aqt.Cassowary
Public Member Functions | Protected Member Functions | Properties | List of all members
aqt::cassowary::Variable Class Reference

Represents a variable whose value will be determined by a constraint solver. More...

#include <aqt/cassowary/Variable.hpp>

Inheritance diagram for aqt::cassowary::Variable:
aqt::cassowary::Contextual

Public Member Functions

 Variable (QQuickItem *pParent=nullptr)
 
double value () const
 
void setValue (double)
 
Q_SIGNAL void valueChanged (double value)
 
Q_SIGNAL void initialChanged (double initial)
 
const rhea::variable & variableImpl () const
 
- Public Member Functions inherited from aqt::cassowary::Contextual
 Contextual (QQuickItem *pParent=nullptr)
 
std::shared_ptr< Contextcontext ()
 
std::shared_ptr< const Contextcontext () const
 
Q_SIGNAL void contextChanged ()
 
Q_SIGNAL void extendChanged (aqt::cassowary::Contextual *extend)
 
Q_INVOKABLE void commit ()
 Applies all the changes associated to the context used by this contextual. More...
 
Q_INVOKABLE void defer (QJSValue cb)
 Executes the callback cb at the end of the next phase of updates in the solver, but before the changes are propagated to the bindings.
 
void defer (Context::Callback cb)
 
void defer_ (Context::Callback cb)
 
template<typename... Args>
void log (Args &&...args)
 Used to log a debug trace, that may be visible when the current context's debug property is set. More...
 

Protected Member Functions

void addIn (Context &) override
 
void removeIn (Context &) override
 
- Protected Member Functions inherited from aqt::cassowary::Contextual
void add ()
 
void remove ()
 
template<typename Fn >
void update (Fn &&cb)
 
template<typename Fn >
Context::Callback guarded (Fn fn)
 
void updateContext ()
 
Contextualprovider ()
 
virtual std::shared_ptr< Contextprovided ()
 

Properties

double value
 Contains the current value as determined by the constrained solver. More...
 
double initial
 Sets the initial value of this variable. More...
 
- Properties inherited from aqt::cassowary::Contextual
aqt::cassowary::Contextual extend
 If non-null, this contextual will use the same context as used by this contextual.
 

Detailed Description

Represents a variable whose value will be determined by a constraint solver.

Example
Solver {
Variable {
id: vX
initial: 100
}
}
Rectangle {
x: vX.value
}
Import in QML
import Aqt.Cassowary 1.0

Property Documentation

double aqt::cassowary::Variable::initial

Sets the initial value of this variable.

If NaN is set, the variable will have an implicit initial value of 0. However, explicitly set initial values will are considered strong, but not the implicit ones even if the later variable has supporting stay constraints.

See also
Stay
Todo:
Like for the value property setter, it would be nice to be able to specify the strength and weight of this suggestion to the solver.
double aqt::cassowary::Variable::value
readwrite

Contains the current value as determined by the constrained solver.

The value will be updated automatically after the next solver update, in the presence of changes in the constraints of the system.

Note
Setting the value only suggests the setting to the solver. Also, the suggestion is not applied inmediatelly, but in the next solver update.
Todo:
Add syntax to specify the strength and weight of the suggestions done via the setter.

The documentation for this class was generated from the following file: