Page MenuHome

UIList Assumes UI_UNIT_Y height for all rows
Confirmed, LowPublicDESIGN

Description

System Information
Operating system: Windows-10-10.0.18362-SP0 64 Bits
Graphics card: GeForce GTX 1050 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 445.75

Blender Version
Broken: version: 2.82 (sub 7), branch: master, commit date: 2020-03-12 05:06, hash: rB375c7dc4caf4 rB7df51ca11a227b5e51290f8dc976972a01db5d81
Worked: (optional)

Short description of error
If the UIlist consists of previews of images, materials, etc. then when you resize it behaves strangely.

I know that maybe this is not a bug, because the API says that it is advisable to use a maximum of 1 line for each item in the list containing a name and a small icon. But still I would like to have the opportunity to make a UIList of images as, for example, in Reality Capture

Exact steps for others to reproduce the error

  • Open the attached file
  • Run the script
  • Click on "T" in the sidebar
  • Drag the lower edge of the material layout upwards to shorten it. there's a glitch


Event Timeline

Philipp Oeser (lichtwerk) changed the task status from Needs Triage to Needs Information from User.Apr 16 2020, 4:34 PM

Not exactly sure what you mean by

when you resize it behaves strangely

I can get it to display 4 column list [by setting the columns=4 in the call to layout.template_list]:

Or is this about the grid not setting rows/columns dynamically when resizing?

Sorry for bad translation. I mean when I drag this element to make UIList shorter or longer, it behave wrong

Ankit (ankitm) changed the task status from Needs Information from User to Needs Triage.Sat, May 2, 3:58 PM
Ankit (ankitm) added a subscriber: Ankit (ankitm).

Registering panel class: 'OBJECT_PT_ui_list_example_1' misses category, please update the script

getting this in the console

@Ankit (ankitm), it was reported on version: 2.82 (sub 7), branch: master, commit date: 2020-03-12. On another version is required to define bl_category in OBJECT_PT_ui_list_example_1 class.

Ankit (ankitm) renamed this task from Incorrect UIList resize to Glitch in UIList resizing .Sat, May 2, 7:57 PM
Ankit (ankitm) changed the task status from Needs Triage to Confirmed.
Ankit (ankitm) updated the task description. (Show Details)
Ivan (vanyOk) updated the task description. (Show Details)Sat, May 2, 8:05 PM

This happens because the UIList itself has no idea about the size of its items, so it assumes they all have the height, UI_UNIT_Y. But in this example the height is defined by the template in each item.

This is the same reason the scrollbar is only 3 units tall in the above screenshot.

To solve this the UIList will have to know about the size of its items, (and hopefully assume each item's height is the same!) I'm not exactly sure of the best way to do this though. It definitely seems way out of the original design of this code.

@Bastien Montagne (mont29) Since I see you in git blame all over the UIList code: Do you have any ideas here?

Bastien Montagne (mont29) triaged this task as Low priority.Tue, May 19, 4:29 PM
Bastien Montagne (mont29) changed the subtype of this task from "Report" to "Design".

This is really a TODO (and probably involves a rather huge amount of changes, if even possible at all). As @Hans Goudey (HooglyBoogly) said, current implementation expects items in the list to be of UI_UNIT_Y height, nothing else.

Hans Goudey (HooglyBoogly) renamed this task from Glitch in UIList resizing to UIList Assumes UI_UNIT_Y height for all rows.Tue, May 19, 4:45 PM

Shouldn't we change it to a TODO type then?

IMHO this is a (technical) design task first, current code is really not ready for random items height, would need design and deep refactor for that.

And am not sure we actually want to support that, tbh.

I would want support for this. My addon centers around the use of a UIList and there are certain cases where improved handling of row height would be very beneficial. If nothing else, it would be nice to be able to set the row height without it changing the window size and messing up the scrolling (supporting multiple row heights in the same list would be great too, but I have no idea how hard this would be).

IMHO this is a (technical) design task first, current code is really not ready for random items height, would need design and deep refactor for that.

I think that there is no need to take into account the random height of each element automatically. It would be simple enough to set the height in UI units for all. Moreover, the list is drawn correctly, only the interaction process is incorrect.
It would be possible to add the option "ui_units_y" to bpy.types.UIList?