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:
parent
8fc04fdfb3
commit
3b18a3667b
3 changed files with 21 additions and 18 deletions
|
@ -190,7 +190,6 @@ FGQCanvasFontCache *CanvasConnection::fontCache() const
|
||||||
|
|
||||||
void CanvasConnection::onWebSocketConnected()
|
void CanvasConnection::onWebSocketConnected()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
m_localPropertyRoot.reset(new LocalProp{nullptr, NameIndexTuple("")});
|
m_localPropertyRoot.reset(new LocalProp{nullptr, NameIndexTuple("")});
|
||||||
setStatus(Connected);
|
setStatus(Connected);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,14 +29,12 @@
|
||||||
CanvasDisplay::CanvasDisplay(QQuickItem* parent) :
|
CanvasDisplay::CanvasDisplay(QQuickItem* parent) :
|
||||||
QQuickItem(parent)
|
QQuickItem(parent)
|
||||||
{
|
{
|
||||||
qDebug() << "created a canvas display";
|
setTransformOrigin(QQuickItem::TopLeft);
|
||||||
|
|
||||||
setFlag(ItemHasContents);
|
setFlag(ItemHasContents);
|
||||||
}
|
}
|
||||||
|
|
||||||
CanvasDisplay::~CanvasDisplay()
|
CanvasDisplay::~CanvasDisplay()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << "connection is" << m_connection;
|
|
||||||
delete m_rootItem;
|
delete m_rootItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,8 +107,9 @@ void CanvasDisplay::onConnectionStatusChanged()
|
||||||
m_rootItem = m_rootElement->createQuickItem(this);
|
m_rootItem = m_rootElement->createQuickItem(this);
|
||||||
onCanvasSizeChanged();
|
onCanvasSizeChanged();
|
||||||
|
|
||||||
m_connection->propertyRoot()->recursiveNotifyRestored();
|
if (m_connection->status() == CanvasConnection::Snapshot) {
|
||||||
qDebug() << Q_FUNC_INFO << "did build item tree";
|
m_connection->propertyRoot()->recursiveNotifyRestored();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,8 +123,9 @@ void CanvasDisplay::onConnectionUpdated()
|
||||||
|
|
||||||
void CanvasDisplay::onCanvasSizeChanged()
|
void CanvasDisplay::onCanvasSizeChanged()
|
||||||
{
|
{
|
||||||
m_sourceSize = QSizeF(m_connection->propertyRoot()->value("size", 400).toDouble(),
|
m_sourceSize = QSizeF(m_connection->propertyRoot()->value("size", 256).toDouble(),
|
||||||
m_connection->propertyRoot()->value("size[1]", 400).toDouble());
|
m_connection->propertyRoot()->value("size[1]", 256).toDouble());
|
||||||
|
setImplicitSize(m_sourceSize.width(), m_sourceSize.height());
|
||||||
recomputeScaling();
|
recomputeScaling();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,6 @@ Item {
|
||||||
property alias canvas: canvasDisplay.canvas
|
property alias canvas: canvasDisplay.canvas
|
||||||
property bool showUi: true
|
property bool showUi: true
|
||||||
|
|
||||||
//clip: true;
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (canvas) {
|
if (canvas) {
|
||||||
width = canvas.size.width
|
width = canvas.size.width
|
||||||
|
@ -24,16 +22,22 @@ Item {
|
||||||
canvas.size = Qt.size(root.width, root.height);
|
canvas.size = Qt.size(root.width, root.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
FG.CanvasDisplay {
|
Item {
|
||||||
id: canvasDisplay
|
id: clipShell
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
clip: true
|
||||||
|
|
||||||
onCanvasChanged: {
|
FG.CanvasDisplay {
|
||||||
if (canvas) {
|
id: canvasDisplay
|
||||||
root.width = canvas.size.width
|
anchors.fill: parent
|
||||||
root.height = canvas.size.height
|
|
||||||
root.x = canvas.origin.x
|
onCanvasChanged: {
|
||||||
root.y = canvas.origin.y
|
if (canvas) {
|
||||||
|
root.width = canvas.size.width
|
||||||
|
root.height = canvas.size.height
|
||||||
|
root.x = canvas.origin.x
|
||||||
|
root.y = canvas.origin.y
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue