diff --git a/CHANGELOG.md b/CHANGELOG.md index 3587681..e67461b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +2.0.7 + +- fix: broken auto-fade with gp layer navigation when used with a customized shortcut. +- changed: supported version number to 3.0.0 + 2.0.6 - changed: Use prefixes toggle is enabled by default diff --git a/OP_layer_nav.py b/OP_layer_nav.py index c8c354a..da0a7b1 100644 --- a/OP_layer_nav.py +++ b/OP_layer_nav.py @@ -9,8 +9,8 @@ class GPT_OT_layer_nav(bpy.types.Operator): direction : bpy.props.EnumProperty( name='direction', - items=(('NONE', 'None', ''),('UP', 'Up', ''),('DOWN', 'Down', '')), - default='NONE', + items=(('UP', 'Up', ''),('DOWN', 'Down', ''), ('NONE', 'None', '')), + default='UP', description='Direction to change layer in active GPencil stack', options={'SKIP_SAVE'}) @@ -24,14 +24,24 @@ class GPT_OT_layer_nav(bpy.types.Operator): def invoke(self, context, event): ## initialise vvalue from prefs prefs = utils.get_addon_prefs() - if not prefs.nav_use_fade: - if self.direction == 'DOWN' or (event.type == 'PAGE_DOWN' and event.value == 'PRESS'): + if self.direction == 'DOWN': utils.iterate_selector(context.object.data.layers, 'active_index', -1, info_attr = 'info') - if self.direction == 'UP' or (event.type == 'PAGE_UP' and event.value == 'PRESS'): + if self.direction == 'UP': utils.iterate_selector(context.object.data.layers, 'active_index', 1, info_attr = 'info') return {'FINISHED'} + + ## get up and down keys for use in modal + self.up_keys = [] + self.down_keys = [] + for km in context.window_manager.keyconfigs.user.keymaps: + for kmi in km.keymap_items: + if kmi.idname == 'gp.layer_nav': + if kmi.properties.direction == 'UP': + self.up_keys.append(kmi.type) + elif kmi.properties.direction == 'DOWN': + self.down_keys.append(kmi.type) self.interval = prefs.nav_interval self.limit = prefs.nav_limit @@ -51,7 +61,7 @@ class GPT_OT_layer_nav(bpy.types.Operator): self.fade_start = self.limit - self.fade_in_time self.first = True - self._timer = wm.event_timer_add(self.interval, window=context.window) # 0.1 + self._timer = wm.event_timer_add(self.interval, window=context.window) wm.modal_handler_add(self) return {'RUNNING_MODAL'} @@ -79,12 +89,12 @@ class GPT_OT_layer_nav(bpy.types.Operator): fade = utils.transfer_value(self.lapse, self.fade_start, self.limit, self.fade_val, self.fade_target) # print(f'lapse {self.lapse} - fade {fade}') context.space_data.overlay.gpencil_fade_layer = fade - - if self.direction == 'DOWN' or (event.type == 'PAGE_DOWN' and event.value == 'PRESS'): + + if self.direction == 'DOWN' or ((event.type in self.down_keys) and event.value == 'PRESS'): _val = utils.iterate_selector(context.object.data.layers, 'active_index', -1, info_attr = 'info') trigger = True - if self.direction == 'UP' or (event.type == 'PAGE_UP' and event.value == 'PRESS'): + if self.direction == 'UP' or ((event.type in self.up_keys) and event.value == 'PRESS'): _val = utils.iterate_selector(context.object.data.layers, 'active_index', 1, info_attr = 'info') # utils.iterate_selector(bpy.context.scene.grease_pencil.layers, 'active_index', 1, info_attr = 'info')#layers trigger = True diff --git a/__init__.py b/__init__.py index 8b65479..4e548c6 100755 --- a/__init__.py +++ b/__init__.py @@ -4,8 +4,8 @@ bl_info = { "name": "GP toolbox", "description": "Tool set for Grease Pencil in animation production", "author": "Samuel Bernou, Christophe Seux", -"version": (2, 0, 6), -"blender": (2, 91, 0), +"version": (2, 0, 7), +"blender": (3, 0, 0), "location": "Sidebar (N menu) > Gpencil > Toolbox / Gpencil properties", "warning": "", "doc_url": "https://gitlab.com/autour-de-minuit/blender/gp_toolbox",