gz-gui icon indicating copy to clipboard operation
gz-gui copied to clipboard

Anchored floating plugins share same size

Open chapulina opened this issue 4 years ago • 1 comments

Loading this config:

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:

QML

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.

chapulina avatar Sep 26 '20 02:09 chapulina

I would like to add a few more observations to this issue:

  1. Expanding/collapsing the second plugin will change the size of the first plugin as well. But expanding/collapsing the first plugin will work independently.
  2. I tried adding multiple plugins (2+) anchored plugins as described in the above config file. So if I have n plugins, the nth plugin can change the size of itself and all the plugins before it.
  3. If I add 3 plugins and then resize each of them manually (so that all of them have different sizes), they all become independent, i.e. changing the size of any plugin doesn't affect the size of the others as described in 2.

From what I understand, there might be an issue with anchors being set due to line <line own="left" target="right"/> where the target is the previous plugin in order, and not the size of the plugin. I am saying this because if we set the anchor <line own="left" target="left"/>" to all the plugins with target plugin as scene their sizes work as intended.

Sarath18 avatar Sep 26 '20 12:09 Sarath18