[ui] GraphEditor.newNodeMenu: fix unstable menu height

Use an explicit height on the newNodeMenu, this fixes the issue with
unstable size of the menu.
This commit is contained in:
Fabien Castan 2024-08-22 22:23:28 +02:00
parent 9fb1e229ae
commit 6646bde7a9

View file

@ -224,6 +224,7 @@ Item {
id: newNodeMenu id: newNodeMenu
property point spawnPosition property point spawnPosition
property variant menuKeys: Object.keys(root.nodeTypesModel).concat(Object.values(MeshroomApp.pipelineTemplateNames)) property variant menuKeys: Object.keys(root.nodeTypesModel).concat(Object.values(MeshroomApp.pipelineTemplateNames))
height: searchBar.height + nodeMenuRepeater.height + instantiator.height
function createNode(nodeType) { function createNode(nodeType) {
uigraph.clearNodeSelection() // Ensures that only the created node / imported pipeline will be selected uigraph.clearNodeSelection() // Ensures that only the created node / imported pipeline will be selected
@ -268,10 +269,9 @@ Item {
} }
onVisibleChanged: { onVisibleChanged: {
if (visible) {
// when menu is shown,
// clear and give focus to the TextField filter
searchBar.clear() searchBar.clear()
if (visible) {
// when menu is shown, give focus to the TextField filter
searchBar.forceActiveFocus() searchBar.forceActiveFocus()
} }
} }
@ -343,7 +343,8 @@ Item {
// Dynamically add the menu categories // Dynamically add the menu categories
Instantiator { Instantiator {
model: !(searchBar.text !== "") ? Object.keys(newNodeMenu.parseCategories()).sort() : undefined id: instantiator
model: (searchBar.text === "") ? Object.keys(newNodeMenu.parseCategories()).sort() : undefined
onObjectAdded: newNodeMenu.insertMenu(index + 1, object ) // add sub-menu under the search bar onObjectAdded: newNodeMenu.insertMenu(index + 1, object ) // add sub-menu under the search bar
onObjectRemoved: newNodeMenu.removeMenu(object) onObjectRemoved: newNodeMenu.removeMenu(object)