1
0
Fork 0

Fix offsetting in FGQCanvas, enable clipping

Visual output is nearly correct now, just some crashes when changing
the display contents to track down.
This commit is contained in:
James Turner 2017-11-16 08:29:24 +00:00
parent 8fc04fdfb3
commit 3b18a3667b
3 changed files with 21 additions and 18 deletions

View file

@ -190,7 +190,6 @@ FGQCanvasFontCache *CanvasConnection::fontCache() const
void CanvasConnection::onWebSocketConnected()
{
qDebug() << Q_FUNC_INFO;
m_localPropertyRoot.reset(new LocalProp{nullptr, NameIndexTuple("")});
setStatus(Connected);
}

View file

@ -29,14 +29,12 @@
CanvasDisplay::CanvasDisplay(QQuickItem* parent) :
QQuickItem(parent)
{
qDebug() << "created a canvas display";
setTransformOrigin(QQuickItem::TopLeft);
setFlag(ItemHasContents);
}
CanvasDisplay::~CanvasDisplay()
{
qDebug() << Q_FUNC_INFO << "connection is" << m_connection;
delete m_rootItem;
}
@ -109,8 +107,9 @@ void CanvasDisplay::onConnectionStatusChanged()
m_rootItem = m_rootElement->createQuickItem(this);
onCanvasSizeChanged();
m_connection->propertyRoot()->recursiveNotifyRestored();
qDebug() << Q_FUNC_INFO << "did build item tree";
if (m_connection->status() == CanvasConnection::Snapshot) {
m_connection->propertyRoot()->recursiveNotifyRestored();
}
}
}
@ -124,8 +123,9 @@ void CanvasDisplay::onConnectionUpdated()
void CanvasDisplay::onCanvasSizeChanged()
{
m_sourceSize = QSizeF(m_connection->propertyRoot()->value("size", 400).toDouble(),
m_connection->propertyRoot()->value("size[1]", 400).toDouble());
m_sourceSize = QSizeF(m_connection->propertyRoot()->value("size", 256).toDouble(),
m_connection->propertyRoot()->value("size[1]", 256).toDouble());
setImplicitSize(m_sourceSize.width(), m_sourceSize.height());
recomputeScaling();
}

View file

@ -7,8 +7,6 @@ Item {
property alias canvas: canvasDisplay.canvas
property bool showUi: true
//clip: true;
Component.onCompleted: {
if (canvas) {
width = canvas.size.width
@ -24,16 +22,22 @@ Item {
canvas.size = Qt.size(root.width, root.height);
}
FG.CanvasDisplay {
id: canvasDisplay
Item {
id: clipShell
anchors.fill: parent
clip: true
onCanvasChanged: {
if (canvas) {
root.width = canvas.size.width
root.height = canvas.size.height
root.x = canvas.origin.x
root.y = canvas.origin.y
FG.CanvasDisplay {
id: canvasDisplay
anchors.fill: parent
onCanvasChanged: {
if (canvas) {
root.width = canvas.size.width
root.height = canvas.size.height
root.x = canvas.origin.x
root.y = canvas.origin.y
}
}
}
}