Skip to content

Commit

Permalink
-Fixed AnimOffset not working with gizmos
Browse files Browse the repository at this point in the history
  • Loading branch information
aresdevo committed Feb 15, 2022
1 parent 2b4ac93 commit b986555
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 29 deletions.
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"name": "AnimAide",
"description": "Helpful tools to manipulate keys on f-curves",
"author": "Ares Deveaux",
"version": (1, 0, 35),
"version": (1, 0, 36),
"blender": (2, 92, 0),
"location": "Graph Editor - Dope Sheet - Timeline - 3D View - sidebar and menu bar",
"warning": "This addon is still in development.",
Expand Down
12 changes: 6 additions & 6 deletions anim_offset/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ def execute(self, context):

if support.magnet_handlers not in bpy.app.handlers.depsgraph_update_post:
bpy.app.handlers.depsgraph_update_post.append(support.magnet_handlers)
utils.set_bar_color(0.5, 0.3, 0.2, 1)
utils.add_message(self.message)

# anim_offset_info = bpy.types.SpaceView3D.draw_handler_add(
# utils.info_text,
# (self, context, self.bl_label),
# 'WINDOW',
# 'POST_PIXEL')

utils.add_message(self.message)

# support.remove_mask(context)

context.area.tag_redraw()
Expand Down Expand Up @@ -136,8 +136,8 @@ def execute(self, context):

if support.magnet_handlers in bpy.app.handlers.depsgraph_update_post:
bpy.app.handlers.depsgraph_update_post.remove(support.magnet_handlers)

utils.remove_message()
utils.reset_bar_color()
utils.remove_message()

scene = context.scene
anim_offset = scene.animaide.anim_offset
Expand Down Expand Up @@ -424,8 +424,8 @@ def invoke(self, context, event):
anim_offset.user_scene_auto = scene.tool_settings.use_keyframe_insert_auto
support.store_user_timeline_ranges(context)
bpy.app.handlers.depsgraph_update_post.append(support.magnet_handlers)

utils.add_message(self.message)
utils.set_bar_color(0.5, 0.3, 0.2, 1)
utils.add_message(self.message)

scene.tool_settings.use_keyframe_insert_auto = False

Expand Down
48 changes: 26 additions & 22 deletions utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,24 +167,37 @@ def get_items(context, any_mode=False):
nla_color = None


def add_message(message):

global text_handle, dopesheet_color, graph_color, nla_color, pref_autosave
if text_handle is None:
pref_autosave = bpy.context.preferences.use_preferences_save
dopesheet_color = bpy.context.preferences.themes[0].dopesheet_editor.space.header[:]
graph_color = bpy.context.preferences.themes[0].graph_editor.space.header[:]
nla_color = bpy.context.preferences.themes[0].nla_editor.space.header[:]
def set_bar_color(r, g, b, a):
global dopesheet_color, graph_color, nla_color, pref_autosave
# if text_handle is None:
pref_autosave = bpy.context.preferences.use_preferences_save
dopesheet_color = bpy.context.preferences.themes[0].dopesheet_editor.space.header[:]
graph_color = bpy.context.preferences.themes[0].graph_editor.space.header[:]
nla_color = bpy.context.preferences.themes[0].nla_editor.space.header[:]

warning_color = (0.5, 0.3, 0.2, 1)
bpy.context.preferences.use_preferences_save = False
bpy.context.preferences.themes[0].dopesheet_editor.space.header = (r, g, b, a)
bpy.context.preferences.themes[0].nla_editor.space.header = (r, g, b, a)
bpy.context.preferences.themes[0].graph_editor.space.header = (r, g, b, a)


def reset_bar_color():
if pref_autosave is not None:
bpy.context.preferences.use_preferences_save = pref_autosave
if dopesheet_color is not None:
bpy.context.preferences.themes[0].dopesheet_editor.space.header = dopesheet_color
if graph_color is not None:
bpy.context.preferences.themes[0].nla_editor.space.header = graph_color
if nla_color is not None:
bpy.context.preferences.themes[0].graph_editor.space.header = nla_color


def add_message(message):

global text_handle

def draw_text_callback(info):
font_id = 0
# draw some text
bpy.context.preferences.themes[0].dopesheet_editor.space.header = warning_color
bpy.context.preferences.themes[0].nla_editor.space.header = warning_color
bpy.context.preferences.themes[0].graph_editor.space.header = warning_color
blf.position(font_id, 5, 80, 0)
blf.size(font_id, 30, 72)
blf.color(font_id, 1, 1, 1, .5)
Expand All @@ -201,12 +214,3 @@ def remove_message():

bpy.types.SpaceView3D.draw_handler_remove(text_handle, 'WINDOW')
text_handle = None

if pref_autosave is not None:
bpy.context.preferences.use_preferences_save = pref_autosave
if dopesheet_color is not None:
bpy.context.preferences.themes[0].dopesheet_editor.space.header = dopesheet_color
if graph_color is not None:
bpy.context.preferences.themes[0].nla_editor.space.header = graph_color
if nla_color is not None:
bpy.context.preferences.themes[0].graph_editor.space.header = nla_color

0 comments on commit b986555

Please sign in to comment.