|
1 | 1 | import os |
2 | | -from PyQt5.QtCore import QSize |
3 | | -from PyQt5.QtGui import QIcon, QPixmap |
| 2 | +from PyQt5.QtCore import Qt |
| 3 | +from PyQt5.QtGui import QIcon |
4 | 4 | from PyQt5.QtWidgets import * |
5 | 5 |
|
6 | 6 | class HierarchyItem(QTreeWidgetItem): |
@@ -30,12 +30,22 @@ def __init__(self, parent): |
30 | 30 | self.vbox_layout.setSpacing(2) |
31 | 31 |
|
32 | 32 | self.hbox_layout = QHBoxLayout() |
33 | | - self.hbox_layout.setStretch(0, 1) |
34 | | - self.hbox_layout.addWidget(QLabel("Untitled Scene")) |
| 33 | + # self.hbox_layout.setStretch(0, 1) |
| 34 | + self.title = QLabel("Untitled Scene") |
| 35 | + self.hbox_layout.addWidget(self.title) |
| 36 | + |
35 | 37 | self.add_button = QToolButton(self) |
36 | 38 | self.add_button.setIcon(QIcon(os.path.join(os.path.dirname( |
37 | 39 | os.path.abspath(__file__)), "icons", "inspector", "add.png"))) |
38 | 40 | self.add_button.setStyleSheet("padding: 3px;") |
| 41 | + self.add_button.setPopupMode(QToolButton.InstantPopup) |
| 42 | + self.add_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) |
| 43 | + |
| 44 | + self.menu = QMenu() |
| 45 | + self.menu.addAction("New GameObject") |
| 46 | + self.menu.addAction("New Child GameObject") |
| 47 | + self.add_button.setMenu(self.menu) |
| 48 | + |
39 | 49 | self.hbox_layout.addWidget(self.add_button) |
40 | 50 | self.vbox_layout.addLayout(self.hbox_layout) |
41 | 51 |
|
@@ -64,9 +74,10 @@ def add_item_pos(self, gameObject, *args): |
64 | 74 | parent = parent.children[num] |
65 | 75 | parent.add_child(item) |
66 | 76 | return item |
67 | | - |
| 77 | + |
68 | 78 | def load_scene(self, scene): |
69 | 79 | self.loaded = scene |
| 80 | + self.title.setText(scene.name) |
70 | 81 | items = {} |
71 | 82 | for gameObject in self.loaded.rootGameObjects: |
72 | 83 | items[gameObject] = self.add_item(gameObject) |
|
0 commit comments