Animation manager improve animated hint

2.3.1

- changed: Animation manager show icons when animation is enabled: fully, partially or not at all.
This commit is contained in:
pullusb
2023-03-09 17:53:40 +01:00
parent 7e92ae182e
commit 798afbe82a
4 changed files with 162 additions and 21 deletions
+42 -19
View File
@@ -1,5 +1,8 @@
# from . import addon_updater_ops
from .utils import get_addon_prefs, all_anim_enabled, all_object_modifier_enabled
from .utils import (get_addon_prefs,
anim_status,
gp_modifier_status,
)
import bpy
from pathlib import Path
from bpy.types import Panel
@@ -179,48 +182,69 @@ class GPTB_PT_anim_manager(Panel):
# def draw_header(self,context):
# self.layout.prop(context.scene.camera.data, "show_background_images", text="")
def get_object_by_types(self, context) -> dict:
# import time
# t0 = time.perf_counter()
# objs = [o for o in context.scene.objects if o.type not in ('GPENCIL', 'CAMERA')]
# gps = [o for o in context.scene.objects if o.type == 'GPENCIL']
# cams = [o for o in context.scene.objects if o.type == 'CAMERA']
objs = []
gps = []
cams = []
for o in context.scene.objects:
if o.type not in ('GPENCIL', 'CAMERA'):
objs.append(o)
elif o.type == 'GPENCIL':
gps.append(o)
elif o.type == 'CAMERA':
cams.append(o)
# print(f'{time.perf_counter() - t0:.8f}s')
return {'OBJECT': objs, 'GPENCIL': gps, 'CAMERA': cams}
def draw(self, context):
layout = self.layout
layout.use_property_split = True
col = layout.column()
## Animation enable disable anim (shift click to select) OP_helpers.GPTB_OT_toggle_mute_animation
# import time
# t0 = time.time()
scn = context.scene
objs = [o for o in scn.objects if o.type not in ('GPENCIL', 'CAMERA')] # show_alert
gps = [o for o in scn.objects if o.type == 'GPENCIL'] # show_alert
cams = [o for o in scn.objects if o.type == 'CAMERA'] # show_alert
obj_types = self.get_object_by_types(context)
col.operator('gp.list_disabled_anims')
## Show Enable / Disable
for cat, cat_type, tgt in [('Obj anims:', 'OBJECT', objs), ('Cam anims:', 'CAMERA', cams), ('Gp anims:', 'GPENCIL', gps)]:
## Show Enable / Disable anims
for cat, cat_type in [('Obj anims:', 'OBJECT'), ('Cam anims:', 'CAMERA'), ('Gp anims:', 'GPENCIL')]:
on_icon, off_icon = anim_status(obj_types[cat_type])
subcol = col.column()
subcol.alert = not all_anim_enabled(tgt) # show_alert
# subcol.alert = off_icon == 'LAYER_ACTIVE' # Turn red
row = subcol.row(align=True)
row.label(text=cat)
ops = row.operator('gp.toggle_mute_animation', text = 'ON')
ops = row.operator('gp.toggle_mute_animation', text='ON', icon=on_icon)
ops.mode = cat_type
ops.mute = False
ops = row.operator('gp.toggle_mute_animation', text = 'OFF')
ops = row.operator('gp.toggle_mute_animation', text='OFF', icon=off_icon)
ops.mode = cat_type
ops.mute = True
## GP modifiers
subcol = col.column()
subcol.alert = not all_object_modifier_enabled(gps) # show_alert
row = subcol.row(align=True)
row.label(text='Gp modifiers:')
row.operator('gp.toggle_hide_gp_modifier', text = 'ON').show = True
row.operator('gp.toggle_hide_gp_modifier', text = 'OFF').show = False
on_icon, off_icon = gp_modifier_status(obj_types['GPENCIL'])
# subcol.alert = off_icon == 'LAYER_ACTIVE' # Turn red
row.operator('gp.toggle_hide_gp_modifier', text='ON', icon=on_icon).show = True
row.operator('gp.toggle_hide_gp_modifier', text='OFF', icon=off_icon).show = False
## Follow curve path
col = col.column()
row = col.row(align=True)
# row.operator('object.create_follow_path_curve', text='Create Curve', icon='CURVE_BEZCURVE')
if context.object:
if context.object.type == 'CURVE' and context.mode in ('OBJECT', 'EDIT_CURVE'):
@@ -248,7 +272,6 @@ class GPTB_PT_anim_manager(Panel):
text, icon = ('Cursor Follow On', 'PIVOT_CURSOR') if context.scene.gptoolprops.cursor_follow else ('Cursor Follow Off', 'CURSOR')
col.prop(context.scene.gptoolprops, 'cursor_follow', text=text, icon=icon)
# print(f'{time.time() - t0:.6f}s')
class GPTB_PT_toolbox_playblast(Panel):
bl_label = "Playblast"