gazebosim/gz-gui

Anchored floating plugins share same size

開放

#129 建立於 2020年9月26日

 (1 則留言) (0 個反應) (1 位負責人)C++ (68 個分叉)auto 404
bughelp wanted

倉庫指標

星標
 (103 顆星)
PR 合併指標
 (平均合併 8小時 31分鐘) (30 天內合併 3 個 PR)

描述

Loading this config:

<?xml version="1.0"?>

<window>
  <width>800</width>
  <height>800</height>
</window>

<plugin filename="Scene3D">
    <ignition-gui>
      <title>scene</title>
      <property type="string" key="state">docked</property>
      <property type="bool" key="showTitleBar">false</property>
    </ignition-gui>
    <engine>ogre</engine>
    <scene>scene</scene>
    <ambient_light>0 0 1</ambient_light>
    <background_color>0.8 0.8 0.8</background_color>
    <camera_pose>-6 0 6 0 0.5 0</camera_pose>
</plugin>

<plugin filename="Publisher">
  <ignition-gui>
    <title>pub</title>
    <property type="int" key="height">500</property>
    <property type="int" key="width">100</property>
    <property key="cardBackground" type="string">#ff0000</property>
    <property type="string" key="state">floating</property>
    <anchors target="scene">
      <line own="left" target="left"/>
      <line own="top" target="top"/>
    </anchors>
  </ignition-gui>
</plugin>

<plugin filename="TopicEcho">
  <ignition-gui>
    <title>sub</title>
    <property type="int" key="height">200</property>
    <property type="int" key="width">300</property>
    <property key="cardBackground" type="string">#00ff00</property>
    <property type="string" key="state">floating</property>
    <anchors target="pub">
      <line own="left" target="right"/>
      <line own="top" target="top"/>
    </anchors>
  </ignition-gui>
</plugin>

Where one plugin's size is 100x500 and the other is 300x200, results in both plugins having the size 300x200.

igngui

This is where the height and width are being applied for anchored plugins:

https://github.com/ignitionrobotics/ign-gui/blob/22434e23832760130c88d38d7c569a049dcec65c/src/Plugin.cc#L474-L481

I checked that setProperty("width"... is being set with the correct values to the correct CardItems. If I prevent the 2nd plugin's width from being set, both plugins end up with the 1st plugin's width: 500.

This pure QML file sets the widths correctly for items anchored the same way as in the example:

Open with qmlscene

import QtQuick 2.0

Rectangle {
    id: scene
    width: 800
    height: 800
    color: "#cccccc"
    Rectangle {
        id: pub
        anchors.top: scene.top
        anchors.left: scene.left
        width: 100
        height: 500
        color: "#ff0000"
    }
    Rectangle {
        id: sub
        anchors.top: pub.top
        anchors.left: pub.right
        width: 300
        height: 200
        color: "#00ff00"
    }
}

qml


I'm not sure if there's a problem within Qt when setting sizes through C++ after items are anchored, or if we're doing something wrong in ign-gui.

貢獻者指南