UI: disabled items are still drawn in white instead of grayed-out #83868

Closed
opened 2020-12-16 21:35:23 +01:00 by Yevgeny Makarov · 9 comments

System Information
Operating system: Darwin-19.6.0-x86_64-i386-64bit 64 Bits
Graphics card: AMD Radeon Pro 455 OpenGL Engine ATI Technologies Inc. 4.1 ATI-3.10.18

Blender Version
Broken: version: 2.91, 2.92.0 Alpha
Worked: 2.83, 2.90
Caused by 933bf62a61

Short description of error
Inside "uiTemplateList" if layout's enabled or active set to False
it is still drawn in white, not gray as it should be.

Examples:

list-layout-enabled-false-1.png

list-layout-enabled-false-2.png

lang=py
class POINTCLOUD_UL_attributes(UIList):
    def draw_item(self, context, layout, data, attribute, icon, active_data, active_propname, index):
        data_type = attribute.bl_rna.properties['data_type'].enum_items[attribute.data_type]

        split = layout.split(factor=0.75)
        split.prop(attribute, "name", text="", emboss=False)
        sub = split.row()
        sub.alignment = 'RIGHT'
  ----> sub.active = False
        sub.label(text=data_type.name)
**System Information** Operating system: Darwin-19.6.0-x86_64-i386-64bit 64 Bits Graphics card: AMD Radeon Pro 455 OpenGL Engine ATI Technologies Inc. 4.1 ATI-3.10.18 **Blender Version** Broken: version: 2.91, 2.92.0 Alpha Worked: 2.83, 2.90 Caused by 933bf62a61 **Short description of error** Inside "uiTemplateList" if layout's `enabled` or `active` set to `False` it is still drawn in white, not gray as it should be. Examples: ![list-layout-enabled-false-1.png](https://archive.blender.org/developer/F9513789/list-layout-enabled-false-1.png) ![list-layout-enabled-false-2.png](https://archive.blender.org/developer/F9513790/list-layout-enabled-false-2.png) ``` lang=py class POINTCLOUD_UL_attributes(UIList): def draw_item(self, context, layout, data, attribute, icon, active_data, active_propname, index): data_type = attribute.bl_rna.properties['data_type'].enum_items[attribute.data_type] split = layout.split(factor=0.75) split.prop(attribute, "name", text="", emboss=False) sub = split.row() sub.alignment = 'RIGHT' ----> sub.active = False sub.label(text=data_type.name) ```
Author
Member

Added subscriber: @jenkm

Added subscriber: @jenkm

Added subscriber: @rjg

Added subscriber: @rjg

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'

I can confirm this issue. Below is a self-contained example to test this:

import bpy


class MATERIAL_UL_matslots_example(bpy.types.UIList):
    - The draw_item function is called for each item of the collection that is visible in the list.
    - data is the RNA object containing the collection,
    - item is the current drawn item of the collection,
    - icon is the "computed" icon for the item (as an integer, because some objects like materials or textures
    - have custom icons ID, which are not available as enum items).
    - active_data is the RNA object containing the active property for the collection (i.e. integer pointing to the
    - active item of the collection).
    - active_propname is the name of the active property (use 'getattr(active_data, active_propname)').
    - index is index of the current item in the collection.
    - flt_flag is the result of the filtering process for this item.
    - Note: as index and flt_flag are optional arguments, you do not have to use/declare them here if you don't
    - need them.

def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
ob = data
slot = item
ma = slot.material

        # draw_item must handle the three layout types... Usually 'DEFAULT' and 'COMPACT' can share the same code.
  if self.layout_type in {'DEFAULT', 'COMPACT'}:
            - You should always start your row layout by a label (icon + text), or a non-embossed text field,
            - this will also make the row easily selectable in the list! The later also enables ctrl-click rename.
            - We use icon_value of label, as our given icon is an integer value, not an enum ID.
            - Note "data" names should never be translated!
      if ma:
          layout.prop(ma, "name", text="", emboss=False, icon_value=icon)
      else:
          layout.label(text="", translate=False, icon_value=icon)
      sub = layout.row()
      sub.alignment = 'RIGHT'
      sub.enabled = False
      sub.label(text="Test")
        # 'GRID' layout type should be as compact as possible (typically a single icon!).
  elif self.layout_type in {'GRID'}:
      layout.alignment = 'CENTER'
      layout.label(text="", icon_value=icon)


# And now we can use this list everywhere in Blender. Here is a small example panel.
class UIListPanelExample(bpy.types.Panel):

"""Creates a Panel in the Object properties window"""
bl_label = "UIList Panel"
bl_idname = "OBJECT_PT_ui_list_example"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "object"


def draw(self, context):
layout = self.layout


  obj = context.object

        - template_list now takes two new args.
        - The first one is the identifier of the registered UIList to use (if you want only the default list,
        # with no custom draw code, use "UI_UL_list").
  layout.template_list("MATERIAL_UL_matslots_example", "", obj, "material_slots", obj, "active_material_index")

        - The second one can usually be left as an empty string.
        - It's an additional ID used to distinguish lists in case you
        # use the same list several times in a given area.
  layout.template_list("MATERIAL_UL_matslots_example", "compact", obj, "material_slots",
                       obj, "active_material_index", type='COMPACT')


def register():

bpy.utils.register_class(MATERIAL_UL_matslots_example)
bpy.utils.register_class(UIListPanelExample)



def unregister():

bpy.utils.unregister_class(MATERIAL_UL_matslots_example)
bpy.utils.unregister_class(UIListPanelExample)



if __name__ == "__main__":

register()


I can confirm this issue. Below is a self-contained example to test this: ```lines import bpy class MATERIAL_UL_matslots_example(bpy.types.UIList): - The draw_item function is called for each item of the collection that is visible in the list. - data is the RNA object containing the collection, - item is the current drawn item of the collection, - icon is the "computed" icon for the item (as an integer, because some objects like materials or textures - have custom icons ID, which are not available as enum items). - active_data is the RNA object containing the active property for the collection (i.e. integer pointing to the - active item of the collection). - active_propname is the name of the active property (use 'getattr(active_data, active_propname)'). - index is index of the current item in the collection. - flt_flag is the result of the filtering process for this item. - Note: as index and flt_flag are optional arguments, you do not have to use/declare them here if you don't - need them. ``` def draw_item(self, context, layout, data, item, icon, active_data, active_propname): ob = data slot = item ma = slot.material ``` # draw_item must handle the three layout types... Usually 'DEFAULT' and 'COMPACT' can share the same code. ``` if self.layout_type in {'DEFAULT', 'COMPACT'}: ``` - You should always start your row layout by a label (icon + text), or a non-embossed text field, - this will also make the row easily selectable in the list! The later also enables ctrl-click rename. - We use icon_value of label, as our given icon is an integer value, not an enum ID. - Note "data" names should never be translated! ``` if ma: layout.prop(ma, "name", text="", emboss=False, icon_value=icon) else: layout.label(text="", translate=False, icon_value=icon) sub = layout.row() sub.alignment = 'RIGHT' sub.enabled = False sub.label(text="Test") ``` # 'GRID' layout type should be as compact as possible (typically a single icon!). ``` elif self.layout_type in {'GRID'}: layout.alignment = 'CENTER' layout.label(text="", icon_value=icon) ``` # And now we can use this list everywhere in Blender. Here is a small example panel. class UIListPanelExample(bpy.types.Panel): ``` """Creates a Panel in the Object properties window""" bl_label = "UIList Panel" bl_idname = "OBJECT_PT_ui_list_example" bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "object" ``` ``` def draw(self, context): layout = self.layout ``` ``` obj = context.object ``` - template_list now takes two new args. - The first one is the identifier of the registered UIList to use (if you want only the default list, # with no custom draw code, use "UI_UL_list"). ``` layout.template_list("MATERIAL_UL_matslots_example", "", obj, "material_slots", obj, "active_material_index") ``` - The second one can usually be left as an empty string. - It's an additional ID used to distinguish lists in case you # use the same list several times in a given area. ``` layout.template_list("MATERIAL_UL_matslots_example", "compact", obj, "material_slots", obj, "active_material_index", type='COMPACT') ``` def register(): ``` bpy.utils.register_class(MATERIAL_UL_matslots_example) bpy.utils.register_class(UIListPanelExample) ``` def unregister(): ``` bpy.utils.unregister_class(MATERIAL_UL_matslots_example) bpy.utils.unregister_class(UIListPanelExample) ``` if __name__ == "__main__": ``` register() ``` ```
Hans Goudey self-assigned this 2020-12-18 04:21:02 +01:00
Member

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Member

Changed status from 'Resolved' to: 'Confirmed'

Changed status from 'Resolved' to: 'Confirmed'
Member

Oops, I closed the wrong task with that commit.

Oops, I closed the wrong task with that commit.

This issue was referenced by 61f1faac3f

This issue was referenced by 61f1faac3f2154de27cedbb100b938e447e5046f
Member

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#83868
No description provided.