Skip to content

Commit

Permalink
Fix: Blender 2.80+ use wrong icons for channel selection on new layer…
Browse files Browse the repository at this point in the history
… popup
  • Loading branch information
ucupumar committed Nov 12, 2024
1 parent daab1e9 commit 09d19ca
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 42 deletions.
12 changes: 4 additions & 8 deletions Bake.py
Original file line number Diff line number Diff line change
Expand Up @@ -1192,10 +1192,8 @@ def bake_vcol_channel_items(self, context):
# Add two spaces to prevent text from being translated
text_ch_name = ch.name + ' '
# Index plus one, minus one when read
if hasattr(lib, 'custom_icons'):
icon_name = lib.channel_custom_icon_dict[ch.type]
items.append((str(i + 2), text_ch_name, '', lib.get_icon(icon_name), i + 2))
else: items.append((str(i + 2), text_ch_name, '', lib.channel_icon_dict[ch.type], i + 2))
icon_name = lib.channel_custom_icon_dict[ch.type]
items.append((str(i + 2), text_ch_name, '', lib.get_icon(icon_name), i + 2))

return items

Expand Down Expand Up @@ -2012,10 +2010,8 @@ def merge_channel_items(self, context):
counter = 0
for i, ch in enumerate(yp.channels):
if not layer.channels[i].enable: continue
if hasattr(lib, 'custom_icons'):
icon_name = lib.channel_custom_icon_dict[ch.type]
items.append((str(i), ch.name, '', lib.get_icon(icon_name), counter))
else: items.append((str(i), ch.name, '', lib.channel_icon_dict[ch.type], counter))
icon_name = lib.channel_custom_icon_dict[ch.type]
items.append((str(i), ch.name, '', lib.get_icon(icon_name), counter))
counter += 1

return items
Expand Down
14 changes: 4 additions & 10 deletions Layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,12 @@ def channel_items(self, context):
items = []

for i, ch in enumerate(yp.channels):
#if hasattr(lib, 'custom_icons'):
# Add two spaces to prevent text from being translated
text_ch_name = ch.name + ' '
if not is_bl_newer_than(2, 80):
icon_name = lib.channel_custom_icon_dict[ch.type]
items.append((str(i), text_ch_name, '', lib.get_icon(icon_name), i))
else: items.append((str(i), text_ch_name, '', lib.channel_icon_dict[ch.type], i))

#if hasattr(lib, 'custom_icons'):
if not is_bl_newer_than(2, 80):
items.append(('-1', 'All Channels', '', lib.get_icon('channels'), len(items)))
else: items.append(('-1', 'All Channels', '', 'GROUP_VERTEX', len(items)))
icon_name = lib.channel_custom_icon_dict[ch.type]
items.append((str(i), text_ch_name, '', lib.get_icon(icon_name), i))

items.append(('-1', 'All Channels', '', lib.get_icon('channels'), len(items)))

return items

Expand Down
16 changes: 0 additions & 16 deletions Root.py
Original file line number Diff line number Diff line change
Expand Up @@ -2561,27 +2561,11 @@ def remove_preview(mat, advanced=False):
# pass

def layer_preview_mode_type_items(self, context):
#node = get_active_ypaint_node()
#yp = node.node_tree.yp

items = (
('LAYER', 'Layer', '', lib.get_icon('texture'), 0),
('MASK', 'Mask', '', lib.get_icon('mask'), 1),
('SPECIFIC_MASK', 'Specific Mask', '', lib.get_icon('mask'), 2)
)

#for i, ch in enumerate(yp.channels):
# #if hasattr(lib, 'custom_icons'):
# if not is_bl_newer_than(2, 80):
# icon_name = lib.channel_custom_icon_dict[ch.type]
# items.append((str(i), ch.name, '', lib.custom_icons[icon_name].icon_id, i))
# else: items.append((str(i), ch.name, '', lib.channel_icon_dict[ch.type], i))

##if hasattr(lib, 'custom_icons'):
#if not is_bl_newer_than(2, 80):
# items.append(('-1', 'All Channels', '', lib.custom_icons['channels'].icon_id, len(items)))
#else: items.append(('-1', 'All Channels', '', 'GROUP_VERTEX', len(items)))

return items

def update_layer_preview_mode(self, context):
Expand Down
6 changes: 0 additions & 6 deletions lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,6 @@
'NORMAL' : 'vector_channel',
}

channel_icon_dict = {
'RGB' : 'KEYTYPE_KEYFRAME_VEC',
'VALUE' : 'HANDLETYPE_FREE_VEC',
'NORMAL' : 'KEYTYPE_BREAKDOWN_VEC',
}

def get_icon_folder():
if not is_bl_newer_than(2, 80):
icon_set = 'legacy'
Expand Down
2 changes: 0 additions & 2 deletions ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -953,8 +953,6 @@ def draw_root_channels_ui(context, layout, node):
else: icon_name = 'collapsed_' + icon_name
icon_value = lib.get_icon(icon_name)
row.prop(chui, 'expand_content', text='', emboss=False, icon_value=icon_value)
#else:
# row.prop(chui, 'expand_content', text='', emboss=True, icon=lib.channel_icon_dict[channel.type])

row.label(text=channel.name + ' ' + pgettext_iface('Channel'))

Expand Down

0 comments on commit 09d19ca

Please sign in to comment.