![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
#include <qgraphicsanchorlayout_p.h>
Classes | |
struct | GraphParts |
Public Types | |
enum | Interval { MinimumToMinPreferred = 0 , MinPreferredToPreferred , PreferredToMaxPreferred , MaxPreferredToMaximum } |
typedef Qt::Orientation | Orientation |
Public Types inherited from QGraphicsLayoutItemPrivate | |
enum | SizeComponent { Width , Height } |
Static Public Member Functions | |
static QGraphicsAnchorLayoutPrivate * | get (QGraphicsAnchorLayout *q) |
static Qt::AnchorPoint | oppositeEdge (Qt::AnchorPoint edge) |
static Qt::Orientation | edgeOrientation (Qt::AnchorPoint edge) noexcept |
static Qt::AnchorPoint | pickEdge (Qt::AnchorPoint edge, Qt::Orientation orientation) |
Static Public Member Functions inherited from QGraphicsLayoutItemPrivate | |
static QGraphicsLayoutItemPrivate * | get (QGraphicsLayoutItem *q) |
static const QGraphicsLayoutItemPrivate * | get (const QGraphicsLayoutItem *q) |
Static Public Attributes | |
static constexpr Qt::Orientation | Horizontal = Qt::Horizontal |
static constexpr Qt::Orientation | Vertical = Qt::Vertical |
Friends | |
class | QGraphicsAnchorPrivate |
QGraphicsAnchorLayout private methods and attributes.
Definition at line 349 of file qgraphicsanchorlayout_p.h.
Definition at line 366 of file qgraphicsanchorlayout_p.h.
Enumerator | |
---|---|
MinimumToMinPreferred | |
MinPreferredToPreferred | |
PreferredToMaxPreferred | |
MaxPreferredToMaximum |
Definition at line 359 of file qgraphicsanchorlayout_p.h.
QGraphicsAnchorLayoutPrivate::QGraphicsAnchorLayoutPrivate | ( | ) |
Definition at line 586 of file qgraphicsanchorlayout_p.cpp.
|
inline |
Definition at line 400 of file qgraphicsanchorlayout_p.h.
QGraphicsAnchor * QGraphicsAnchorLayoutPrivate::addAnchor | ( | QGraphicsLayoutItem * | firstItem, |
Qt::AnchorPoint | firstEdge, | ||
QGraphicsLayoutItem * | secondItem, | ||
Qt::AnchorPoint | secondEdge, | ||
qreal * | spacing = nullptr ) |
Implements the high level "addAnchor" feature. Called by the public API addAnchor method.
The optional spacing argument defines the size of the anchor. If not provided, the anchor size is either 0 or not-set, depending on type of anchor created (see matrix below).
All anchors that remain with size not-set will assume the standard spacing, set either by the layout style or through the "setSpacing" layout API.
Definition at line 1580 of file qgraphicsanchorlayout_p.cpp.
void QGraphicsAnchorLayoutPrivate::addAnchor_helper | ( | QGraphicsLayoutItem * | firstItem, |
Qt::AnchorPoint | firstEdge, | ||
QGraphicsLayoutItem * | secondItem, | ||
Qt::AnchorPoint | secondEdge, | ||
AnchorData * | data ) |
Definition at line 1674 of file qgraphicsanchorlayout_p.cpp.
AnchorData * QGraphicsAnchorLayoutPrivate::addAnchorMaybeParallel | ( | AnchorData * | newAnchor, |
bool * | feasible ) |
Adds newAnchor to the graph.
Returns the newAnchor itself if it could be added without further changes to the graph. If a new parallel anchor had to be created, then returns the new parallel anchor. If a parallel anchor had to be created and it results in an unfeasible setup, feasible is set to false, otherwise true.
Note that in the case a new parallel anchor is created, it might also take over some constraints from its children anchors.
Definition at line 626 of file qgraphicsanchorlayout_p.cpp.
AnchorVertex * QGraphicsAnchorLayoutPrivate::addInternalVertex | ( | QGraphicsLayoutItem * | item, |
Qt::AnchorPoint | edge ) |
Definition at line 1836 of file qgraphicsanchorlayout_p.cpp.
void QGraphicsAnchorLayoutPrivate::calculateGraphs | ( | ) |
Called on activation. Uses Linear Programming to define minimum, preferred and maximum sizes for the layout. Also calculates the sizes that each item should assume when the layout is in one of such situations.
Definition at line 1998 of file qgraphicsanchorlayout_p.cpp.
void QGraphicsAnchorLayoutPrivate::calculateGraphs | ( | Qt::Orientation | orientation | ) |
Calculate graphs is the method that puts together all the helper routines so that the AnchorLayout can calculate the sizes of each item.
In a nutshell it should do:
1) Refresh anchor nominal sizes, that is, the size that each anchor would have if no other restrictions applied. This is done by querying the layout style and the sizeHints of the items belonging to the layout.
2) Simplify the graph by grouping together parallel and sequential anchors into "group anchors". These have equivalent minimum, preferred and maximum sizeHints as the anchors they replace.
3) Check if we got to a trivial case. In some cases, the whole graph can be simplified into a single anchor. If so, use this information. If not, then call the Simplex solver to calculate the anchors sizes.
4) Once the root anchors had its sizes calculated, propagate that to the anchors they represent.
Definition at line 2043 of file qgraphicsanchorlayout_p.cpp.
bool QGraphicsAnchorLayoutPrivate::calculateNonTrunk | ( | const QList< QSimplexConstraint * > & | constraints, |
const QList< AnchorData * > & | variables ) |
Definition at line 2208 of file qgraphicsanchorlayout_p.cpp.
bool QGraphicsAnchorLayoutPrivate::calculateTrunk | ( | Qt::Orientation | orientation, |
const GraphPath & | path, | ||
const QList< QSimplexConstraint * > & | constraints, | ||
const QList< AnchorData * > & | variables ) |
Calculate the sizes for all anchors which are part of the trunk. This works on top of a (possibly) simplified graph.
Definition at line 2140 of file qgraphicsanchorlayout_p.cpp.
void QGraphicsAnchorLayoutPrivate::calculateVertexPositions | ( | Qt::Orientation | orientation | ) |
Calculate the position of each vertex based on the paths to each of them as well as the current edges sizes.
Definition at line 2624 of file qgraphicsanchorlayout_p.cpp.
|
inline |
Definition at line 491 of file qgraphicsanchorlayout_p.h.
void QGraphicsAnchorLayoutPrivate::constraintsFromPaths | ( | Qt::Orientation | orientation | ) |
Each vertex on the graph that has more than one path to it represents a contra int to the sizes of the items in these paths.
This method walks the list of paths to each vertex, generate the constraints and store them in a list so they can be used later by the Simplex solver.
Definition at line 2309 of file qgraphicsanchorlayout_p.cpp.
QList< QSimplexConstraint * > QGraphicsAnchorLayoutPrivate::constraintsFromSizeHints | ( | const QList< AnchorData * > & | anchors | ) |
Create LP constraints for each anchor based on its minimum and maximum sizes, as specified in its size hints
Definition at line 2345 of file qgraphicsanchorlayout_p.cpp.
void QGraphicsAnchorLayoutPrivate::correctEdgeDirection | ( | QGraphicsLayoutItem *& | firstItem, |
Qt::AnchorPoint & | firstEdge, | ||
QGraphicsLayoutItem *& | secondItem, | ||
Qt::AnchorPoint & | secondEdge ) |
Use heuristics to determine the correct orientation of a given anchor.
After API discussions, we decided we would like expressions like anchor(A, Left, B, Right) to mean the same as anchor(B, Right, A, Left). The problem with this is that anchors could become ambiguous, for instance, what does the anchor A, B of size X mean?
"pos(B) = pos(A) + X" or "pos(A) = pos(B) + X" ?
To keep the API user friendly and at the same time, keep our algorithm deterministic, we use an heuristic to determine a direction for each added anchor and then keep it. The heuristic is based on the fact that people usually avoid overlapping items, therefore:
"A, RIGHT to B, LEFT" means that B is to the LEFT of A. "B, LEFT to A, RIGHT" is corrected to the above anchor.
Special correction is also applied when one of the items is the layout. We handle Layout Left as if it was another items's Right and Layout Right as another item's Left.
Definition at line 1934 of file qgraphicsanchorlayout_p.cpp.
void QGraphicsAnchorLayoutPrivate::createCenterAnchors | ( | QGraphicsLayoutItem * | item, |
Qt::AnchorPoint | centerEdge ) |
By default, each item in the layout is represented internally as a single anchor in each direction. For instance, from Left to Right.
However, to support anchorage of items to the center of items, we must split this internal anchor into two half-anchors. From Left to Center and then from Center to Right, with the restriction that these anchors must have the same time at all times.
Definition at line 1389 of file qgraphicsanchorlayout_p.cpp.
void QGraphicsAnchorLayoutPrivate::createItemEdges | ( | QGraphicsLayoutItem * | item | ) |
Definition at line 1363 of file qgraphicsanchorlayout_p.cpp.
void QGraphicsAnchorLayoutPrivate::createLayoutEdges | ( | ) |
Create internal anchors to connect the layout edges (Left to Right and Top to Bottom).
These anchors doesn't have size restrictions, that will be enforced by other anchors and items in the layout.
Definition at line 1322 of file qgraphicsanchorlayout_p.cpp.
void QGraphicsAnchorLayoutPrivate::deleteLayoutEdges | ( | ) |
Definition at line 1350 of file qgraphicsanchorlayout_p.cpp.
|
staticnoexcept |
Definition at line 1308 of file qgraphicsanchorlayout_p.cpp.
void QGraphicsAnchorLayoutPrivate::findPaths | ( | Qt::Orientation | orientation | ) |
This method walks the graph using a breadth-first search to find paths between the root vertex and each vertex on the graph. The edges directions in each path are considered and they are stored as a positive edge (left-to-right) or negative edge (right-to-left).
The list of paths is used later to generate a list of constraints.
Definition at line 2257 of file qgraphicsanchorlayout_p.cpp.
|
inlinestatic |
Definition at line 372 of file qgraphicsanchorlayout_p.h.
QGraphicsAnchor * QGraphicsAnchorLayoutPrivate::getAnchor | ( | QGraphicsLayoutItem * | firstItem, |
Qt::AnchorPoint | firstEdge, | ||
QGraphicsLayoutItem * | secondItem, | ||
Qt::AnchorPoint | secondEdge ) |
Definition at line 1714 of file qgraphicsanchorlayout_p.cpp.
QGraphicsAnchorLayoutPrivate::GraphParts QGraphicsAnchorLayoutPrivate::getGraphParts | ( | Qt::Orientation | orientation | ) |
Definition at line 2440 of file qgraphicsanchorlayout_p.cpp.
bool QGraphicsAnchorLayoutPrivate::hasConflicts | ( | ) | const |
Returns true
if there are no arrangement that satisfies all constraints. Otherwise returns false
.
Definition at line 2900 of file qgraphicsanchorlayout_p.cpp.
void QGraphicsAnchorLayoutPrivate::identifyFloatItems | ( | const QSet< AnchorData * > & | visited, |
Qt::Orientation | orientation ) |
Use all visited Anchors on findPaths() so we can identify non-float Items.
Definition at line 2517 of file qgraphicsanchorlayout_p.cpp.
void QGraphicsAnchorLayoutPrivate::identifyNonFloatItems_helper | ( | const AnchorData * | ad, |
QSet< QGraphicsLayoutItem * > * | nonFloatingItemsIdentifiedSoFar ) |
Given an anchor, if it is an internal anchor and Normal we must mark it's item as non-float. If the anchor is Sequential or Parallel, we must iterate on its children recursively until we reach internal anchors (items).
Definition at line 2540 of file qgraphicsanchorlayout_p.cpp.
|
inline |
Definition at line 486 of file qgraphicsanchorlayout_p.h.
|
inline |
Definition at line 481 of file qgraphicsanchorlayout_p.h.
void QGraphicsAnchorLayoutPrivate::interpolateEdge | ( | AnchorVertex * | base, |
AnchorData * | edge ) |
Calculate the current Edge size based on the current Layout size and the size the edge is supposed to have when the layout is at its:
These three key values are calculated in advance using linear programming (more expensive) or the simplification algorithm, then subsequential resizes of the parent layout require a simple interpolation.
Definition at line 2704 of file qgraphicsanchorlayout_p.cpp.
|
static |
Definition at line 591 of file qgraphicsanchorlayout_p.cpp.
|
inlinestatic |
Definition at line 382 of file qgraphicsanchorlayout_p.h.
void QGraphicsAnchorLayoutPrivate::refreshAllSizeHints | ( | Qt::Orientation | orientation | ) |
Traverse the graph refreshing the size hints. Edges will query their associated item or graphicsAnchor for their size hints.
Definition at line 2235 of file qgraphicsanchorlayout_p.cpp.
void QGraphicsAnchorLayoutPrivate::removeAnchor | ( | AnchorVertex * | firstVertex, |
AnchorVertex * | secondVertex ) |
Implements the high level "removeAnchor" feature. Called by the QAnchorData destructor.
Definition at line 1749 of file qgraphicsanchorlayout_p.cpp.
void QGraphicsAnchorLayoutPrivate::removeAnchor_helper | ( | AnchorVertex * | v1, |
AnchorVertex * | v2 ) |
Definition at line 1823 of file qgraphicsanchorlayout_p.cpp.
void QGraphicsAnchorLayoutPrivate::removeAnchors | ( | QGraphicsLayoutItem * | item | ) |
Definition at line 1898 of file qgraphicsanchorlayout_p.cpp.
void QGraphicsAnchorLayoutPrivate::removeCenterAnchors | ( | QGraphicsLayoutItem * | item, |
Qt::AnchorPoint | centerEdge, | ||
bool | substitute = true ) |
Definition at line 1454 of file qgraphicsanchorlayout_p.cpp.
void QGraphicsAnchorLayoutPrivate::removeCenterConstraints | ( | QGraphicsLayoutItem * | item, |
Qt::Orientation | orientation ) |
Definition at line 1537 of file qgraphicsanchorlayout_p.cpp.
void QGraphicsAnchorLayoutPrivate::removeInternalVertex | ( | QGraphicsLayoutItem * | item, |
Qt::AnchorPoint | edge ) |
returns the AnchorVertex that was dereferenced, also when it was removed. returns 0 if it did not exist.
Definition at line 1857 of file qgraphicsanchorlayout_p.cpp.
void QGraphicsAnchorLayoutPrivate::removeVertex | ( | QGraphicsLayoutItem * | item, |
Qt::AnchorPoint | edge ) |
Definition at line 1885 of file qgraphicsanchorlayout_p.cpp.
bool QGraphicsAnchorLayoutPrivate::replaceVertex | ( | Qt::Orientation | orientation, |
AnchorVertex * | oldV, | ||
AnchorVertex * | newV, | ||
const QList< AnchorData * > & | edges ) |
Definition at line 832 of file qgraphicsanchorlayout_p.cpp.
void QGraphicsAnchorLayoutPrivate::restoreSimplifiedAnchor | ( | AnchorData * | edge | ) |
Definition at line 1135 of file qgraphicsanchorlayout_p.cpp.
void QGraphicsAnchorLayoutPrivate::restoreSimplifiedConstraints | ( | ParallelAnchorData * | parallel | ) |
Definition at line 1181 of file qgraphicsanchorlayout_p.cpp.
void QGraphicsAnchorLayoutPrivate::restoreSimplifiedGraph | ( | Qt::Orientation | orientation | ) |
Definition at line 1207 of file qgraphicsanchorlayout_p.cpp.
void QGraphicsAnchorLayoutPrivate::restoreVertices | ( | Qt::Orientation | orientation | ) |
Definition at line 1236 of file qgraphicsanchorlayout_p.cpp.
Use the current vertices distance to calculate and set the geometry of each item.
Definition at line 2566 of file qgraphicsanchorlayout_p.cpp.
void QGraphicsAnchorLayoutPrivate::setupEdgesInterpolation | ( | Qt::Orientation | orientation | ) |
Calculate interpolation parameters based on current Layout Size. Must be called once before calling "interpolateEdgeSize()" for the edges.
Definition at line 2669 of file qgraphicsanchorlayout_p.cpp.
bool QGraphicsAnchorLayoutPrivate::simplifyGraph | ( | Qt::Orientation | orientation | ) |
The purpose of this function is to simplify the graph. Simplification serves two purposes:
It is essential that it must be possible to restore simplified anchors back to their "original" form. This is done by restoreSimplifiedAnchor().
There are two types of simplification that can be done:
The process of simplification can be described as:
When creating the parallel anchors, the algorithm might identify unfeasible situations. In this case the simplification process stops and returns false
. Otherwise returns true
.
Definition at line 775 of file qgraphicsanchorlayout_p.cpp.
bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration | ( | Qt::Orientation | orientation, |
bool * | feasible ) |
One iteration of the simplification algorithm. Returns true
if another iteration is needed.
The algorithm walks the graph in depth-first order, and only collects vertices that has two edges connected to it. If the vertex does not have two edges or if it is a layout edge, it will take all the previously collected vertices and try to create a simplified sequential anchor representing all the previously collected vertices. Once the simplified anchor is inserted, the collected list is cleared in order to find the next sequence to simplify.
Note that there are some catches to this that are not covered by the above explanation, see the function comments for more details.
Definition at line 979 of file qgraphicsanchorlayout_p.cpp.
bool QGraphicsAnchorLayoutPrivate::simplifyVertices | ( | Qt::Orientation | orientation | ) |
Definition at line 866 of file qgraphicsanchorlayout_p.cpp.
bool QGraphicsAnchorLayoutPrivate::solveMinMax | ( | const QList< QSimplexConstraint * > & | constraints, |
const GraphPath & | path, | ||
qreal * | min, | ||
qreal * | max ) |
Definition at line 2724 of file qgraphicsanchorlayout_p.cpp.
bool QGraphicsAnchorLayoutPrivate::solvePreferred | ( | const QList< QSimplexConstraint * > & | constraints, |
const QList< AnchorData * > & | variables ) |
Definition at line 2783 of file qgraphicsanchorlayout_p.cpp.
QLayoutStyleInfo & QGraphicsAnchorLayoutPrivate::styleInfo | ( | ) | const |
Definition at line 1963 of file qgraphicsanchorlayout_p.cpp.
void QGraphicsAnchorLayoutPrivate::updateAnchorSizes | ( | Qt::Orientation | orientation | ) |
Definition at line 2328 of file qgraphicsanchorlayout_p.cpp.
|
friend |
Definition at line 568 of file qgraphicsanchorlayout_p.h.
QHVContainer<QList<AnchorData *> > QGraphicsAnchorLayoutPrivate::anchorsFromSimplifiedVertices |
Definition at line 545 of file qgraphicsanchorlayout_p.h.
|
mutable |
Definition at line 566 of file qgraphicsanchorlayout_p.h.
uint QGraphicsAnchorLayoutPrivate::calculateGraphCacheDirty |
Definition at line 564 of file qgraphicsanchorlayout_p.h.
QHVContainer<QList<QSimplexConstraint *> > QGraphicsAnchorLayoutPrivate::constraints |
Definition at line 549 of file qgraphicsanchorlayout_p.h.
QHVContainer<Graph<AnchorVertex, AnchorData> > QGraphicsAnchorLayoutPrivate::graph |
Definition at line 537 of file qgraphicsanchorlayout_p.h.
QHVContainer<bool> QGraphicsAnchorLayoutPrivate::graphHasConflicts = {} |
Definition at line 557 of file qgraphicsanchorlayout_p.h.
QHVContainer<QMultiHash<AnchorVertex *, GraphPath> > QGraphicsAnchorLayoutPrivate::graphPaths |
Definition at line 548 of file qgraphicsanchorlayout_p.h.
|
inlinestaticconstexpr |
Definition at line 367 of file qgraphicsanchorlayout_p.h.
QHVContainer<Interval> QGraphicsAnchorLayoutPrivate::interpolationInterval |
Definition at line 554 of file qgraphicsanchorlayout_p.h.
QHVContainer<qreal> QGraphicsAnchorLayoutPrivate::interpolationProgress = {-1, -1} |
Definition at line 555 of file qgraphicsanchorlayout_p.h.
QHVContainer<QList<QSimplexConstraint *> > QGraphicsAnchorLayoutPrivate::itemCenterConstraints |
Definition at line 550 of file qgraphicsanchorlayout_p.h.
QList<QGraphicsLayoutItem *> QGraphicsAnchorLayoutPrivate::items |
Definition at line 529 of file qgraphicsanchorlayout_p.h.
QHVContainer<AnchorVertex *> QGraphicsAnchorLayoutPrivate::layoutCentralVertex = {} |
Definition at line 540 of file qgraphicsanchorlayout_p.h.
QHVContainer<AnchorVertex *> QGraphicsAnchorLayoutPrivate::layoutFirstVertex = {} |
Definition at line 539 of file qgraphicsanchorlayout_p.h.
QHVContainer<AnchorVertex *> QGraphicsAnchorLayoutPrivate::layoutLastVertex = {} |
Definition at line 541 of file qgraphicsanchorlayout_p.h.
QHVContainer<QSet<QGraphicsLayoutItem *> > QGraphicsAnchorLayoutPrivate::m_floatItems |
Definition at line 558 of file qgraphicsanchorlayout_p.h.
QHash<std::pair<QGraphicsLayoutItem*, Qt::AnchorPoint>, std::pair<AnchorVertex *, int> > QGraphicsAnchorLayoutPrivate::m_vertexList |
Definition at line 534 of file qgraphicsanchorlayout_p.h.
QHVContainer<QList<AnchorVertexPair *> > QGraphicsAnchorLayoutPrivate::simplifiedVertices |
Definition at line 544 of file qgraphicsanchorlayout_p.h.
QHVContainer<std::array<qreal, 3> > QGraphicsAnchorLayoutPrivate::sizeHints = {{-1, -1, -1}, {-1, -1, -1}} |
Definition at line 526 of file qgraphicsanchorlayout_p.h.
QHVContainer<qreal> QGraphicsAnchorLayoutPrivate::spacings = {-1, -1} |
Definition at line 524 of file qgraphicsanchorlayout_p.h.
|
mutable |
Definition at line 565 of file qgraphicsanchorlayout_p.h.
|
inlinestaticconstexpr |
Definition at line 368 of file qgraphicsanchorlayout_p.h.