update to gpv3 context modes

master
pullusb 2024-11-11 15:47:33 +01:00
parent f5a78601b6
commit eae69b6f75
11 changed files with 20 additions and 20 deletions

View File

@ -58,7 +58,7 @@ class GPTB_OT_brush_set(bpy.types.Operator):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.object and context.mode == 'PAINT_GPENCIL' return context.object and context.mode == 'PAINT_GREASE_PENCIL'
def execute(self, context): def execute(self, context):
brush = bpy.data.brushes.get(self.brush_name) brush = bpy.data.brushes.get(self.brush_name)
@ -72,12 +72,12 @@ class GPTB_OT_brush_set(bpy.types.Operator):
def load_brush_ui(self, context): def load_brush_ui(self, context):
prefs = get_addon_prefs() prefs = get_addon_prefs()
if context.mode == 'PAINT_GPENCIL': if context.mode == 'PAINT_GREASE_PENCIL':
self.layout.operator('gp.load_brushes', icon='KEYTYPE_JITTER_VEC').filepath = prefs.brush_path self.layout.operator('gp.load_brushes', icon='KEYTYPE_JITTER_VEC').filepath = prefs.brush_path
def load_brush_top_bar_ui(self, context): def load_brush_top_bar_ui(self, context):
prefs = get_addon_prefs() prefs = get_addon_prefs()
if context.mode == 'PAINT_GPENCIL': if context.mode == 'PAINT_GREASE_PENCIL':
self.layout.operator('gp.load_brushes').filepath = prefs.brush_path self.layout.operator('gp.load_brushes').filepath = prefs.brush_path
classes = ( classes = (

View File

@ -259,7 +259,7 @@ class GPTB_OT_eraser(Operator):
#bpy.data.materials.remove(self.hld_mat) #bpy.data.materials.remove(self.hld_mat)
bpy.ops.object.mode_set(mode='EDIT_GPENCIL') bpy.ops.object.mode_set(mode='EDIT')
context.scene.tool_settings.gpencil_selectmode_edit = 'POINT' context.scene.tool_settings.gpencil_selectmode_edit = 'POINT'
#context.scene.tool_settings.gpencil_selectmode_edit = 'POINT' #context.scene.tool_settings.gpencil_selectmode_edit = 'POINT'
@ -358,9 +358,9 @@ class GPTB_OT_eraser(Operator):
#bpy.ops.object.mode_set(mode='OBJECT') #bpy.ops.object.mode_set(mode='OBJECT')
context.scene.tool_settings.gpencil_selectmode_edit = self.gpencil_selectmode_edit context.scene.tool_settings.gpencil_selectmode_edit = self.gpencil_selectmode_edit
bpy.ops.object.mode_set(mode='PAINT_GPENCIL') bpy.ops.object.mode_set(mode='PAINT_GREASE_PENCIL')
#selected_strokes = [s for s in self.gp_frame.strokes if s.select] #selected_strokes = [s for s in self.gp_frame.strokes if s.select]
#bpy.ops.object.mode_set(mode='PAINT_GPENCIL') #bpy.ops.object.mode_set(mode='PAINT_GREASE_PENCIL')
def modal(self, context, event): def modal(self, context, event):
self.mouse = Vector((event.mouse_region_x, event.mouse_region_y)) self.mouse = Vector((event.mouse_region_x, event.mouse_region_y))

View File

@ -120,7 +120,7 @@ class GPTB_OT_file_checker(bpy.types.Operator):
setattr(area.spaces[0], 'show_locked_time', True) setattr(area.spaces[0], 'show_locked_time', True)
## set cursor type ## set cursor type
if context.mode in ("EDIT_GPENCIL", "SCULPT_GPENCIL"): if context.mode in ("EDIT_GREASE_PENCIL", "SCULPT_GREASE_PENCIL"):
tool = fix.select_active_tool tool = fix.select_active_tool
if tool != 'none': if tool != 'none':
if bpy.context.workspace.tools.from_space_view3d_mode(bpy.context.mode, create=False).idname != tool: if bpy.context.workspace.tools.from_space_view3d_mode(bpy.context.mode, create=False).idname != tool:

View File

@ -132,12 +132,12 @@ class GPTB_OT_batch_flat_reproject(bpy.types.Operator):
### -- MENU ENTRY -- ### -- MENU ENTRY --
def flat_reproject_clean_menu(self, context): def flat_reproject_clean_menu(self, context):
if context.mode == 'EDIT_GPENCIL': if context.mode == 'EDIT_GREASE_PENCIL':
self.layout.operator_context = 'INVOKE_REGION_WIN' # needed for popup (also works with 'INVOKE_DEFAULT') self.layout.operator_context = 'INVOKE_REGION_WIN' # needed for popup (also works with 'INVOKE_DEFAULT')
self.layout.operator('gp.batch_flat_reproject', icon='KEYTYPE_JITTER_VEC') self.layout.operator('gp.batch_flat_reproject', icon='KEYTYPE_JITTER_VEC')
def flat_reproject_context_menu(self, context): def flat_reproject_context_menu(self, context):
if context.mode == 'EDIT_GPENCIL' and context.scene.tool_settings.gpencil_selectmode_edit == 'STROKE': if context.mode == 'EDIT_GREASE_PENCIL' and context.scene.tool_settings.gpencil_selectmode_edit == 'STROKE':
self.layout.operator_context = 'INVOKE_REGION_WIN' # needed for popup self.layout.operator_context = 'INVOKE_REGION_WIN' # needed for popup
self.layout.operator('gp.batch_flat_reproject', icon='KEYTYPE_JITTER_VEC') self.layout.operator('gp.batch_flat_reproject', icon='KEYTYPE_JITTER_VEC')

View File

@ -136,7 +136,7 @@ class GPTB_OT_go_to_object(bpy.types.Operator):
self.report({'INFO'}, f'Back to pose mode, {obj.name}') self.report({'INFO'}, f'Back to pose mode, {obj.name}')
elif obj.type == 'GREASEPENCIL': elif obj.type == 'GREASEPENCIL':
bpy.ops.object.mode_set(mode='PAINT_GPENCIL', toggle=False) bpy.ops.object.mode_set(mode='PAINT_GREASE_PENCIL', toggle=False)
else: else:
self.report({'INFO'}, f'Back to object mode, {obj.name}') self.report({'INFO'}, f'Back to object mode, {obj.name}')

View File

@ -557,7 +557,7 @@ def layer_name_builder_ui(self, context):
return return
layout = self.layout layout = self.layout
# {'EDIT_GPENCIL', 'PAINT_GPENCIL','SCULPT_GPENCIL','WEIGHT_GPENCIL', 'VERTEX_GPENCIL'} # {'EDIT_GREASE_PENCIL', 'PAINT_GREASE_PENCIL','SCULPT_GREASE_PENCIL','WEIGHT_GREASE_PENCIL', 'VERTEX_GPENCIL'}
# layout.separator() # layout.separator()
col = layout.column() col = layout.column()

View File

@ -14,7 +14,7 @@ class GP_OT_pick_closest_layer(Operator):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.object and context.object.type == 'GREASEPENCIL' and context.mode == 'PAINT_GPENCIL' return context.object and context.object.type == 'GREASEPENCIL' and context.mode == 'PAINT_GREASE_PENCIL'
stroke_filter : bpy.props.EnumProperty(name='Target', stroke_filter : bpy.props.EnumProperty(name='Target',
default='STROKE', default='STROKE',

View File

@ -33,7 +33,7 @@ class GP_OT_pick_closest_material(Operator):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.object and context.object.type == 'GREASEPENCIL' and context.mode == 'PAINT_GPENCIL' return context.object and context.object.type == 'GREASEPENCIL' and context.mode == 'PAINT_GREASE_PENCIL'
fill_only : bpy.props.BoolProperty(default=False, options={'SKIP_SAVE'}) fill_only : bpy.props.BoolProperty(default=False, options={'SKIP_SAVE'})
@ -159,7 +159,7 @@ class GP_OT_pick_closest_material(Operator):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.object and context.object.type == 'GREASEPENCIL' and context.mode == 'PAINT_GPENCIL' return context.object and context.object.type == 'GREASEPENCIL' and context.mode == 'PAINT_GREASE_PENCIL'
# fill_only : bpy.props.BoolProperty(default=False, options={'SKIP_SAVE'}) # fill_only : bpy.props.BoolProperty(default=False, options={'SKIP_SAVE'})
stroke_filter : bpy.props.EnumProperty(default='FILL', stroke_filter : bpy.props.EnumProperty(default='FILL',

View File

@ -25,7 +25,7 @@ if all_strokes:
l.hide = False l.hide = False
l.lock = False l.lock = False
l.lock_frame = False l.lock_frame = False
bpy.ops.object.mode_set(mode='EDIT_GPENCIL') bpy.ops.object.mode_set(mode='EDIT')
for fnum in frame_list: for fnum in frame_list:
@ -432,12 +432,12 @@ class GPTB_OT_batch_reproject_all_frames(bpy.types.Operator):
### -- MENU ENTRY -- ### -- MENU ENTRY --
def reproject_clean_menu(self, context): def reproject_clean_menu(self, context):
if context.mode == 'EDIT_GPENCIL': if context.mode == 'EDIT_GREASE_PENCIL':
self.layout.operator_context = 'INVOKE_REGION_WIN' # needed for popup (also works with 'INVOKE_DEFAULT') self.layout.operator_context = 'INVOKE_REGION_WIN' # needed for popup (also works with 'INVOKE_DEFAULT')
self.layout.operator('gp.batch_reproject_all_frames', icon='KEYTYPE_JITTER_VEC') self.layout.operator('gp.batch_reproject_all_frames', icon='KEYTYPE_JITTER_VEC')
def reproject_context_menu(self, context): def reproject_context_menu(self, context):
if context.mode == 'EDIT_GPENCIL' and context.scene.tool_settings.gpencil_selectmode_edit == 'STROKE': if context.mode == 'EDIT_GREASE_PENCIL' and context.scene.tool_settings.gpencil_selectmode_edit == 'STROKE':
self.layout.operator_context = 'INVOKE_REGION_WIN' # needed for popup self.layout.operator_context = 'INVOKE_REGION_WIN' # needed for popup
self.layout.operator('gp.batch_reproject_all_frames', icon='KEYTYPE_JITTER_VEC') self.layout.operator('gp.batch_reproject_all_frames', icon='KEYTYPE_JITTER_VEC')

View File

@ -7,7 +7,7 @@ from .utils import get_addon_prefs
class GPTB_WT_eraser(WorkSpaceTool): class GPTB_WT_eraser(WorkSpaceTool):
bl_space_type = 'VIEW_3D' bl_space_type = 'VIEW_3D'
bl_context_mode = 'PAINT_GPENCIL' bl_context_mode = 'PAINT_GREASE_PENCIL'
# The prefix of the idname should be your add-on name. # The prefix of the idname should be your add-on name.
bl_idname = "gp.eraser_tool" bl_idname = "gp.eraser_tool"

View File

@ -425,7 +425,7 @@ def palette_manager_menu(self, context):
"""Palette menu to append in existing menu""" """Palette menu to append in existing menu"""
# GPENCIL_MT_material_context_menu # GPENCIL_MT_material_context_menu
layout = self.layout layout = self.layout
# {'EDIT_GPENCIL', 'PAINT_GPENCIL','SCULPT_GPENCIL','WEIGHT_GPENCIL', 'VERTEX_GPENCIL'} # {'EDIT_GREASE_PENCIL', 'PAINT_GREASE_PENCIL','SCULPT_GREASE_PENCIL','WEIGHT_GREASE_PENCIL', 'VERTEX_GPENCIL'}
layout.separator() layout.separator()
prefs = get_addon_prefs() prefs = get_addon_prefs()
@ -658,7 +658,7 @@ class GPTB_PT_tools_grease_pencil_interpolate(Panel):
# settings = context.tool_settings.gpencil_interpolate # old 2.92 global settings # settings = context.tool_settings.gpencil_interpolate # old 2.92 global settings
## access active tool settings ## access active tool settings
# settings = context.workspace.tools[0].operator_properties('gpencil.interpolate') # settings = context.workspace.tools[0].operator_properties('gpencil.interpolate')
settings = context.workspace.tools.from_space_view3d_mode('PAINT_GPENCIL').operator_properties('gpencil.interpolate') settings = context.workspace.tools.from_space_view3d_mode('PAINT_GREASE_PENCIL').operator_properties('gpencil.interpolate')
## custom curve access (still in gp interpolate tools) ## custom curve access (still in gp interpolate tools)
interpolate_settings = context.tool_settings.gpencil_interpolate interpolate_settings = context.tool_settings.gpencil_interpolate