Colorramp elements are not updated when changed via layout.prop() #119648

Open
opened 2024-03-19 07:25:10 +01:00 by ugorek · 6 comments

System Information
Operating system: Windows-10-10.0.19045-SP0 64 Bits
Graphics card: NVIDIA GeForce GTX 1650/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 546.33

Blender Version
Broken: version: 4.2.0 Alpha, branch: main, commit date: 2024-03-16 19:16, hash: 6768ded89586
Worked: never?

Short description of error
An element's position changed using a property via api does not update the order of elements.
2024-03-19_13.17.44.gif

Exact steps for others to reproduce the error

  1. Copy script and run.
  2. Use the new panel to change position.
import bpy

class Panel(bpy.types.Panel):
    bl_idname = 'Panel_PT_Panel'
    bl_label = "Panel"
    bl_space_type = 'NODE_EDITOR'
    bl_region_type = 'UI'
    def draw(self, context):
        col = self.layout.column(align=True)
        tree = context.space_data.edit_tree
        aNd = tree.nodes.active
        if aNd:
            if aNd.type=='VALTORGB':
                for el in aNd.color_ramp.elements:
                    row = col.row(align=True)
                    row.prop(el,'color', text="")
                    row.prop(el,'position', text="")
            else:
                col.label(text=aNd.bl_idname)

bpy.utils.register_class(Panel)
**System Information** Operating system: Windows-10-10.0.19045-SP0 64 Bits Graphics card: NVIDIA GeForce GTX 1650/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 546.33 **Blender Version** Broken: version: 4.2.0 Alpha, branch: main, commit date: 2024-03-16 19:16, hash: `6768ded89586` Worked: never? **Short description of error** An element's position changed using a property via api does not update the order of elements. ![2024-03-19_13.17.44.gif](/attachments/6b517132-7803-43b6-9036-e6b130c289a7) **Exact steps for others to reproduce the error** 1. Copy script and run. 2. Use the new panel to change position. ``` import bpy class Panel(bpy.types.Panel): bl_idname = 'Panel_PT_Panel' bl_label = "Panel" bl_space_type = 'NODE_EDITOR' bl_region_type = 'UI' def draw(self, context): col = self.layout.column(align=True) tree = context.space_data.edit_tree aNd = tree.nodes.active if aNd: if aNd.type=='VALTORGB': for el in aNd.color_ramp.elements: row = col.row(align=True) row.prop(el,'color', text="") row.prop(el,'position', text="") else: col.label(text=aNd.bl_idname) bpy.utils.register_class(Panel) ```
ugorek added the
Priority
Normal
Type
Report
Status
Needs Triage
labels 2024-03-19 07:25:11 +01:00
Member

Can confirm, will have a quick look

Can confirm, will have a quick look
Member

Hm, not sure if there is a nice way to solve this.

In code, colorband_update_cb switches button pointers around when going across another stop.
You can also see this in your gif (color stops changing order there, going up and down).

Sorting could take place I assume (using BKE_colorband_update_sort), not sure though how the buttons would correctly update in the panel (meaning the currently dragged slider would need to change order, too... sounds hairy...)

Hm, not sure if there is a nice way to solve this. In code, `colorband_update_cb` switches button pointers around when going across another stop. You can also see this in your gif (color stops changing order there, going up and down). Sorting could take place I assume (using `BKE_colorband_update_sort`), not sure though how the buttons would correctly update in the panel (meaning the currently dragged slider would need to change order, too... sounds hairy...)

Hi, I am new to blender development. I can reproduce this issue, and would like to work on it. This issue looks easy enough to be a Good First Issue. Can I proceed with this issue?

Hi, I am new to blender development. I can reproduce this issue, and would like to work on it. This issue looks easy enough to be a Good First Issue. Can I proceed with this issue?
Member

Not really sure if this is a good first issue (due to my comments above), but of course, you could give it a try

The thing would have to be done in rna_ColorRamp_update

Not really sure if this is a good first issue (due to my comments above), but of course, you could give it a try The thing would have to be done in `rna_ColorRamp_update`
Author

P. s.

I thought that if I changed the position "explicitly" through the api, the order would be updated, but this did not happen.

import functools

def Timer(nd):
    nd.color_ramp.elements[0].position = nd.color_ramp.elements[0].position

class Panel(bpy.types.Panel):
    ...
    def draw(self, context):
        ...
        bpy.app.timers.register(functools.partial(Timer, aNd))

P. p.s.

meaning the currently dragged slider would need to change order, too...

Personally, I had no problems when the changeable slider moved to a new place. I used this for my sorting needs, and it’s very comfortable.
2023-11-17_04.38.12.gif

P. s. I thought that if I changed the position "explicitly" through the api, the order would be updated, but this did not happen. ```py import functools def Timer(nd): nd.color_ramp.elements[0].position = nd.color_ramp.elements[0].position class Panel(bpy.types.Panel): ... def draw(self, context): ... bpy.app.timers.register(functools.partial(Timer, aNd)) ``` P. p.s. > meaning the currently dragged slider would need to change order, too... Personally, I had no problems when the changeable slider moved to a new place. I used this for my sorting needs, and it’s very comfortable. ![2023-11-17_04.38.12.gif](/attachments/9d5f410b-acf3-4abe-ba1b-65d017c91f0f)

Not really sure if this is a good first issue (due to my comments above), but of course, you could give it a try

The thing would have to be done in rna_ColorRamp_update

I didn't saw your comment as I didn't refresh the page. Though I would like to give this a try any ways. Thanks for the reference.

> Not really sure if this is a good first issue (due to my comments above), but of course, you could give it a try > > The thing would have to be done in `rna_ColorRamp_update` I didn't saw your comment as I didn't refresh the page. Though I would like to give this a try any ways. Thanks for the reference.
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
3 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#119648
No description provided.