Newer
Older
prop = row.operator("view3d.view_move_qcd_slot", text="", icon=icon,
icon_value=icon_value, depress=not qcd_laycol.exclude)
prop.slot = str(x+1)
else:
row.label(text="", icon='X')
if idx%5==0:
row.separator()
if idx == 10:
row = col.row(align=True)
row.scale_y = 0.5
idx += 1
def view_layer_update(self, context):
if context.view_layer.name != CollectionManager.last_view_layer:
bpy.app.timers.register(update_qcd_header)
CollectionManager.last_view_layer = context.view_layer.name
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
def get_active_icon(context, qcd_laycol):
global last_icon_theme_text
global last_icon_theme_text_sel
tool_theme = context.preferences.themes[0].user_interface.wcol_tool
pcoll = preview_collections["icons"]
if qcd_laycol.exclude:
theme_color = tool_theme.text
last_theme_color = last_icon_theme_text
icon = pcoll["active_icon_text"]
else:
theme_color = tool_theme.text_sel
last_theme_color = last_icon_theme_text_sel
icon = pcoll["active_icon_text_sel"]
if last_theme_color == None or theme_color.hsv != last_theme_color:
update_icon(pcoll["active_icon_base"], icon, theme_color)
if qcd_laycol.exclude:
last_icon_theme_text = theme_color.hsv
else:
last_icon_theme_text_sel = theme_color.hsv
return icon
def update_icon(base, icon, theme_color):
icon.icon_pixels = base.icon_pixels
colored_icon = []
for offset in range(len(icon.icon_pixels)):
idx = offset * 4
r = icon.icon_pixels_float[idx]
g = icon.icon_pixels_float[idx+1]
b = icon.icon_pixels_float[idx+2]
a = icon.icon_pixels_float[idx+3]
# add back some brightness and opacity blender takes away from the custom icon
r = min(r+r*0.2,1)
g = min(g+g*0.2,1)
b = min(b+b*0.2,1)
a = min(a+a*0.2,1)
# make the icon follow the theme color (assuming the icon is white)
r *= theme_color.r
g *= theme_color.g
b *= theme_color.b
colored_icon.append(r)
colored_icon.append(g)
colored_icon.append(b)
colored_icon.append(a)
icon.icon_pixels_float = colored_icon
def filter_items_by_name_custom(pattern, bitflag, items, propname="name", flags=None, reverse=False):
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
"""
Set FILTER_ITEM for items which name matches filter_name one (case-insensitive).
pattern is the filtering pattern.
propname is the name of the string property to use for filtering.
flags must be a list of integers the same length as items, or None!
return a list of flags (based on given flags if not None),
or an empty list if no flags were given and no filtering has been done.
"""
import fnmatch
if not pattern or not items: # Empty pattern or list = no filtering!
return flags or []
if flags is None:
flags = [0] * len(items)
# Make pattern case-insensitive
pattern = pattern.lower()
# Implicitly add heading/trailing wildcards.
pattern = "*" + pattern + "*"
for i, item in enumerate(items):
name = getattr(item, propname, None)
# Make name case-insensitive
name = name.lower()
# This is similar to a logical xor
if bool(name and fnmatch.fnmatch(name, pattern)) is not bool(reverse):
flags[i] |= bitflag
# add in any recently created collections
if item.name in CM_UL_items.new_collections:
flags[i] |= bitflag