Update layout.cpp

This commit is contained in:
Andrei Yankovich 2021-09-24 21:55:34 +03:00 committed by GitHub
parent 3a2287bb19
commit bae0b0abb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -89,6 +89,7 @@ void Layout::drawSquare() {
}
int height = qFloor(qSqrt(objects().size()));
int width = qFloor(objects().size() / height);
int indObject = 0;
for (auto idObj = objects().keyBegin(); idObj != objects().keyEnd(); idObj++) {
@ -96,8 +97,8 @@ void Layout::drawSquare() {
float x = indObject % height;
float y = qCeil(indObject / height);
GroupObject::updatePosition(*idObj, {x + _distance,
y + _distance,
GroupObject::updatePosition(*idObj, {(x * _distance) - (height * _distance / 2),
(y * _distance) - (width * _distance / 2),
0});
indObject++;
@ -113,8 +114,10 @@ void Layout::drawLine() {
}
float xObject = 0;
float height = objects().size() * _distance;
for (ClasterItem* object: objects()) {
GroupObject::updatePosition(object->guiId(), {xObject + _distance, 0, 0});
GroupObject::updatePosition(object->guiId(), {xObject * _distance - (height / 2 * _distance), 0, 0});
xObject++;
}