Maniphest T48813

Custom icon is not drawn on header / addons prefs panel
Closed, Resolved

Assigned To
Bastien Montagne (mont29)
Authored By
Sybren A. Stüvel (sybren)
Jul 8 2016, 4:53 PM
Tags
  • BF Blender
  • BF Blender: 2.8
Subscribers
Bastien Montagne (mont29)
Campbell Barton (campbellbarton)
Sergey Sharybin (sergey)
Sybren A. Stüvel (sybren)

Description

System Information
Kubuntu 16.04, GeForce 8800 GTS 512

Blender Version
Broken: 2.77a and rB8bb69b61579113a

Short description of error
When drawing a button or label with a custom icon on a header or addons panel, the icon isn't shown. Only after forcing a redraw (for example by moving the mouse over the UI element) the icon gets drawn.

Exact steps for others to reproduce the error

  1. Place the attached blend file and icon
    in the same folder.
  2. Open the blend file.
  3. Scroll the text editor header such that there is plenty of space on the right-hand side of the header. This is necessary so that you can see the button that will appear here, directly on the first draw.
  4. Run the script.
  5. See the "Render" button without cloud icon.
  6. Move the mouse around over the button.
  7. See the "Render" button appear.

If you go to the properties editor, objects tab, the script also registers a button there, in a custom panel. You can also see that it is drawn without the icon first, but is redrawn when the icon is loaded. My bet is that this redraw trigger doesn't happen for other areas.

Revisions and Commits

rB Blender

Related Objects

Mentioned In
T48831: Icon Preview generation for textures and images
Mentioned Here
rB8bb69b615791: BMesh: add decimate edit-mode tool

Event Timeline

Sybren A. Stüvel (sybren) created this task.Jul 8 2016, 4:53 PM
Sergey Sharybin (sergey) lowered the priority of this task from 90 to Normal.Jul 8 2016, 5:39 PM
Sergey Sharybin (sergey) added subscribers: Bastien Montagne (mont29), Sergey Sharybin (sergey).

@Bastien Montagne (mont29), is it something in your area?

Bastien Montagne (mont29) triaged this task as 50 priority.Jul 10 2016, 9:31 PM
Bastien Montagne (mont29) added a subscriber: Campbell Barton (campbellbarton).

Problem is that those 'custom icons from file' are asynchronously deferred loaded, using 'generic' icon generation job, which generates NC_MATERIAL notifications. Replacing those with NC_WINDOW does fix the issue, question is, do we accept that kind of 'redraw everything' message from icon generation? @Campbell Barton (campbellbarton), what do you think?

Campbell Barton (campbellbarton) added a comment.EditedJul 11 2016, 5:16 AM

@Bastien Montagne (mont29), right, we can always add global redraw flags to workaround these issues. In this case I don't have a strong opinion,
though IMHO it's quite weak - the more add-ons use generated icons, the more we will redraw everything when they update.


I think we need a more flexible notification system which doesn't depend on hard coded values (making assumptions about whats shown in a region).

Currently a Python script may show any information in the UI, its totally hit-and-miss that the UI is refreshed when they're changed.

We could have design task for this (if someone has time to develop it...) would suggest moving to a publish/subscribe pattern for the notifier system where...

  • hard coded listener functions are replaced with dynamically registered listeners based on the contents of the region/area.
  • defining the UI elements automatically subscribes that region to be updated when those values are changed.

How fine-grained we need to be can be chosen later... per-property is possible but overkill. (probably ID & RNA-type is enough).
This way using dynamically generated icons is just a matter of asking to listen for changes to icons - a different kind of listener.

This allows for Python scripts to be able to register to be notified on changes too.

For the 3D-view for eg, it probably doesn't make sense to inspect whats drawn and listen to changes in each object's ID. It could just register a listener for changes to data-types (material, object-object data).
So something similar to the existing system could be done where needed.

Sergey Sharybin (sergey) assigned this task to Bastien Montagne (mont29).Jul 26 2016, 5:45 PM

While notifier is a weak solution it is the only one for now. So either we go this way or consider this a TODO.

Since for now we don't have have much addons who uses this function think it's acceptable to just use notifiers.

Bastien Montagne (mont29) added a comment.Jul 26 2016, 5:51 PM

Yes, agree, for now notifier will do the work.

@Campbell Barton (campbellbarton) your idea sounds nice, imho at this point should be part of the bigger 'workflow' 2.8 topic (as part of custom editors, which will require that kind of thing anyway)…

Bastien Montagne (mont29) changed the task status from Unknown Status to Resolved by committing rBf3f10e4515c4: Fix T48813: Custom icon is not drawn on header / addons prefs panel..Jul 26 2016, 5:56 PM
Bastien Montagne (mont29) added a commit: rBf3f10e4515c4: Fix T48813: Custom icon is not drawn on header / addons prefs panel..
Sybren A. Stüvel (sybren) added a comment.Jul 26 2016, 11:20 PM

Thanks guys!

Bastien Montagne (mont29) added a project: BF Blender: 2.8.Aug 19 2016, 4:35 PM