gazebosim/gz-gui

Anchored floating plugins share same size

Aperta

#129 aperta il 26 set 2020

 (1 commento) (0 reazioni) (1 assegnatario)C++ (68 fork)auto 404
bughelp wanted

Metriche repository

Star
 (103 stelle)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

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.

Guida contributor