[Kst] branches/work/kst/portto4/kst/src/libkstapp
Mike Fenton
mike at staikos.net
Wed Jul 16 21:57:04 CEST 2008
SVN commit 833426 by fenton:
Fix updateChildGeometry to function with Circles.
Update Layout drawing to support fixedSize and lockedAspectRatio items.
M +19 -0 viewgridlayout.cpp
M +3 -1 viewitem.cpp
--- branches/work/kst/portto4/kst/src/libkstapp/viewgridlayout.cpp #833425:833426
@@ -202,6 +202,25 @@
item.viewItem->resetTransform();
item.viewItem->setPos(itemRect.topLeft());
+
+ if (item.viewItem->fixedSize()) {
+ itemRect.setBottom(itemRect.top() + item.viewItem->rect().height());
+ itemRect.setRight(itemRect.left() + item.viewItem->rect().width());
+ } else if (item.viewItem->lockAspectRatio()) {
+ qreal newHeight = itemRect.height();
+ qreal newWidth = itemRect.width();
+
+ qreal aspectRatio = item.viewItem->rect().width() / item.viewItem->rect().height();
+ if ((newWidth / newHeight) > aspectRatio) {
+ // newWidth is too large. Use newHeight as key.
+ newWidth = newHeight * aspectRatio;
+ } else {
+ // newHeight is either too large, or perfect. use newWidth as key.
+ newHeight = newWidth / aspectRatio;
+ }
+ itemRect.setBottom(itemRect.top() + newHeight);
+ itemRect.setRight(itemRect.left() + newWidth);
+ }
item.viewItem->setViewRect(QRectF(QPoint(0,0), itemRect.size()));
if (PlotItem *plotItem = qobject_cast<PlotItem*>(item.viewItem))
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.cpp #833425:833426
@@ -1257,6 +1257,7 @@
setParent(0);
setPos(mapToParent(mapFromScene(origin)) + pos() - mapToParent(QPointF(0,0)));
+ updateRelativeSize();
#ifdef DEBUG_REPARENT
qDebug() << "after new parent"
@@ -1306,6 +1307,7 @@
setParent(viewItem);
setPos(mapToParent(mapFromScene(origin)) + pos() - mapToParent(QPointF(0,0)));
+ updateRelativeSize();
#ifdef DEBUG_REPARENT
qDebug() << "after new parent"
@@ -1337,6 +1339,7 @@
setParent(0);
setPos(mapToParent(mapFromScene(origin)) + pos() - mapToParent(QPointF(0,0)));
+ updateRelativeSize();
#ifdef DEBUG_REPARENT
qDebug() << "after new parent"
@@ -1352,7 +1355,6 @@
void ViewItem::setParent(ViewItem* parent) {
setParentItem(parent);
- updateRelativeSize();
}
More information about the Kst
mailing list