Skip to content

Commit

Permalink
Create expanding type header to reduce code duplication (#1169)
Browse files Browse the repository at this point in the history
* Create exanpding type header to reduce code duplication in the component inspector

Signed-off-by: Nate Koenig <nate@openrobotics.org>

* Revert TypeHeader changes

Signed-off-by: Nate Koenig <nate@openrobotics.org>

* Removed extra lines

Signed-off-by: Nate Koenig <nate@openrobotics.org>

Co-authored-by: Nate Koenig <nate@openrobotics.org>
  • Loading branch information
nkoenig and Nate Koenig authored Nov 6, 2021
1 parent a90bf42 commit 9e4b5e4
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 205 deletions.
1 change: 1 addition & 0 deletions src/gui/plugins/component_inspector/ComponentInspector.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<qresource prefix="ComponentInspector/">
<file>Boolean.qml</file>
<file>ComponentInspector.qml</file>
<file>ExpandingTypeHeader.qml</file>
<file>Light.qml</file>
<file>NoData.qml</file>
<file>Physics.qml</file>
Expand Down
72 changes: 72 additions & 0 deletions src/gui/plugins/component_inspector/ExpandingTypeHeader.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright (C) 2021 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import QtQuick 2.9
import QtQuick.Controls 1.4
import QtQuick.Controls 2.2
import QtQuick.Controls.Material 2.1
import QtQuick.Layouts 1.3
import QtQuick.Controls.Styles 1.4

// Header
Rectangle {
id: header
width: parent.width
height: typeHeader.height
color: "transparent"

// Horizontal margins
property int margin: 5

// Left indentation
property int indentation: 10

RowLayout {
anchors.fill: parent
Item {
width: margin
}
Image {
id: icon
sourceSize.height: indentation
sourceSize.width: indentation
fillMode: Image.Pad
Layout.alignment : Qt.AlignVCenter
source: content.show ?
"qrc:/Gazebo/images/minus.png" : "qrc:/Gazebo/images/plus.png"
}
TypeHeader {
id: typeHeader
}
Item {
Layout.fillWidth: true
}
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
content.show = !content.show
}
onEntered: {
header.color = highlightColor
}
onExited: {
header.color = "transparent"
}
}
}
45 changes: 4 additions & 41 deletions src/gui/plugins/component_inspector/Light.qml
Original file line number Diff line number Diff line change
Expand Up @@ -221,48 +221,11 @@ Rectangle {
Column {
anchors.fill: parent

// Header
Rectangle {
// The expanding header. Make sure that the content to expand has an id set
// to the value "content".
ExpandingTypeHeader {
id: header
width: parent.width
height: typeHeader.height
color: "transparent"

RowLayout {
anchors.fill: parent
Item {
width: margin
}
Image {
id: icon
sourceSize.height: indentation
sourceSize.width: indentation
fillMode: Image.Pad
Layout.alignment : Qt.AlignVCenter
source: content.show ?
"qrc:/Gazebo/images/minus.png" : "qrc:/Gazebo/images/plus.png"
}
TypeHeader {
id: typeHeader
}
Item {
Layout.fillWidth: true
}
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
content.show = !content.show
}
onEntered: {
header.color = highlightColor
}
onExited: {
header.color = "transparent"
}
}
// Using the default header text values.
}

// Content
Expand Down
45 changes: 4 additions & 41 deletions src/gui/plugins/component_inspector/Physics.qml
Original file line number Diff line number Diff line change
Expand Up @@ -116,48 +116,11 @@ Rectangle {
Column {
anchors.fill: parent

// Header
Rectangle {
// The expanding header. Make sure that the content to expand has an id set
// to the value "content".
ExpandingTypeHeader {
id: header
width: parent.width
height: typeHeader.height
color: "transparent"

RowLayout {
anchors.fill: parent
Item {
width: margin
}
Image {
id: icon
sourceSize.height: indentation
sourceSize.width: indentation
fillMode: Image.Pad
Layout.alignment : Qt.AlignVCenter
source: content.show ?
"qrc:/Gazebo/images/minus.png" : "qrc:/Gazebo/images/plus.png"
}
TypeHeader {
id: typeHeader
}
Item {
Layout.fillWidth: true
}
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
content.show = !content.show
}
onEntered: {
header.color = highlightColor
}
onExited: {
header.color = "transparent"
}
}
// Using the default header text values.
}

// Content
Expand Down
45 changes: 4 additions & 41 deletions src/gui/plugins/component_inspector/Pose3d.qml
Original file line number Diff line number Diff line change
Expand Up @@ -120,48 +120,11 @@ Rectangle {
Column {
anchors.fill: parent

// Header
Rectangle {
// The expanding header. Make sure that the content to expand has an id set
// to the value "content".
ExpandingTypeHeader {
id: header
width: parent.width
height: typeHeader.height
color: "transparent"

RowLayout {
anchors.fill: parent
Item {
width: margin
}
Image {
id: icon
sourceSize.height: indentation
sourceSize.width: indentation
fillMode: Image.Pad
Layout.alignment : Qt.AlignVCenter
source: content.show ?
"qrc:/Gazebo/images/minus.png" : "qrc:/Gazebo/images/plus.png"
}
TypeHeader {
id: typeHeader
}
Item {
Layout.fillWidth: true
}
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
content.show = !content.show
}
onEntered: {
header.color = highlightColor
}
onExited: {
header.color = "transparent"
}
}
// Using the default header text values.
}

// Content
Expand Down
45 changes: 4 additions & 41 deletions src/gui/plugins/component_inspector/SphericalCoordinates.qml
Original file line number Diff line number Diff line change
Expand Up @@ -84,48 +84,11 @@ Rectangle {
Column {
anchors.fill: parent

// Header
Rectangle {
// The expanding header. Make sure that the content to expand has an id set
// to the value "content".
ExpandingTypeHeader {
id: header
width: parent.width
height: typeHeader.height
color: "transparent"

RowLayout {
anchors.fill: parent
Item {
width: margin
}
Image {
id: icon
sourceSize.height: indentation
sourceSize.width: indentation
fillMode: Image.Pad
Layout.alignment : Qt.AlignVCenter
source: content.show ?
"qrc:/Gazebo/images/minus.png" : "qrc:/Gazebo/images/plus.png"
}
TypeHeader {
id: typeHeader
}
Item {
Layout.fillWidth: true
}
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
content.show = !content.show
}
onEntered: {
header.color = highlightColor
}
onExited: {
header.color = "transparent"
}
}
// Using the default header text values.
}

// Content
Expand Down
45 changes: 4 additions & 41 deletions src/gui/plugins/component_inspector/Vector3d.qml
Original file line number Diff line number Diff line change
Expand Up @@ -110,48 +110,11 @@ Rectangle {
Column {
anchors.fill: parent

// Header
Rectangle {
// The expanding header. Make sure that the content to expand has an id set
// to the value "content".
ExpandingTypeHeader {
id: header
width: parent.width
height: typeHeader.height
color: "transparent"

RowLayout {
anchors.fill: parent
Item {
width: margin
}
Image {
id: icon
sourceSize.height: indentation
sourceSize.width: indentation
fillMode: Image.Pad
Layout.alignment : Qt.AlignVCenter
source: content.show ?
"qrc:/Gazebo/images/minus.png" : "qrc:/Gazebo/images/plus.png"
}
TypeHeader {
id: typeHeader
}
Item {
Layout.fillWidth: true
}
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
content.show = !content.show
}
onEntered: {
header.color = highlightColor
}
onExited: {
header.color = "transparent"
}
}
// Using the default header text values.
}

// Content
Expand Down

0 comments on commit 9e4b5e4

Please sign in to comment.