picker on visible
parent
a218aefd10
commit
985e395beb
|
@ -5,7 +5,7 @@
|
||||||
- feat: Namespace upgrade
|
- feat: Namespace upgrade
|
||||||
- support pseudo group naming
|
- support pseudo group naming
|
||||||
- add group and indent button
|
- add group and indent button
|
||||||
- feat: Fill tool shortcut for material color picker (from closest stroke)
|
- feat: Fill tool shortcut for material color picker (from closest visible stroke)
|
||||||
- `S` : get material closest *fill* stroke
|
- `S` : get material closest *fill* stroke
|
||||||
- `Àlt+S` : get closest stroke (fill or stroke)
|
- `Àlt+S` : get closest stroke (fill or stroke)
|
||||||
|
|
||||||
|
|
|
@ -139,16 +139,19 @@ class GPTB_OT_layer_name_build(Operator):
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
def grp_toggle(l):
|
def grp_toggle(l, mode='TOGGLE'):
|
||||||
|
'''take mode in (TOGGLE, GROUP, UNGROUP) '''
|
||||||
grp_item_id = ' - '
|
grp_item_id = ' - '
|
||||||
res = re.search(r'^(\s{1,3}-\s{0,3})(.*)', l.info)
|
res = re.search(r'^(\s{1,3}-\s{0,3})(.*)', l.info)
|
||||||
if not res:
|
if not res and mode in ('TOGGLE', 'GROUP'):
|
||||||
# add group prefix after stripping all space and dash
|
# No gpr : add group prefix after stripping all space and dash
|
||||||
l.info = grp_item_id + l.info.lstrip(' -')
|
l.info = grp_item_id + l.info.lstrip(' -')
|
||||||
else:
|
|
||||||
# delete group prefix
|
elif res and mode in ('TOGGLE', 'UNGROUP'):
|
||||||
|
# found : delete group prefix
|
||||||
l.info = res.group(2)
|
l.info = res.group(2)
|
||||||
|
|
||||||
|
|
||||||
class GPTB_OT_layer_group_toggle(Operator):
|
class GPTB_OT_layer_group_toggle(Operator):
|
||||||
bl_idname = "gp.layer_group_toggle"
|
bl_idname = "gp.layer_group_toggle"
|
||||||
bl_label = "Group Toggle"
|
bl_label = "Group Toggle"
|
||||||
|
@ -186,18 +189,26 @@ class GPTB_OT_layer_new_group(Operator):
|
||||||
if not act:
|
if not act:
|
||||||
self.report({'ERROR'}, 'no layer active')
|
self.report({'ERROR'}, 'no layer active')
|
||||||
return {"CANCELLED"}
|
return {"CANCELLED"}
|
||||||
|
|
||||||
res = re.search(PATTERN, act.info)
|
res = re.search(PATTERN, act.info)
|
||||||
if not res:
|
if not res:
|
||||||
self.report({'ERROR'}, 'Could not create a group name, create a layer manually')
|
self.report({'ERROR'}, 'Could not create a group name, create a layer manually')
|
||||||
return {"CANCELLED"}
|
return {"CANCELLED"}
|
||||||
name = res.group('name')
|
|
||||||
|
name = res.group('name').strip(' -')
|
||||||
if not name:
|
if not name:
|
||||||
self.report({'ERROR'}, f'No name found in {act.info}')
|
self.report({'ERROR'}, f'No name found in {act.info}')
|
||||||
return {"CANCELLED"}
|
return {"CANCELLED"}
|
||||||
if name in [l.info for l in gpl]:
|
|
||||||
|
if name in [l.info.strip(' -') for l in gpl]:
|
||||||
self.report({'WARNING'}, f'Name already exists: {act.info}')
|
self.report({'WARNING'}, f'Name already exists: {act.info}')
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
gpl.new(name, set_active=False)
|
|
||||||
|
grp_toggle(act, mode='GROUP')
|
||||||
|
n = gpl.new(name, set_active=False)
|
||||||
|
n.use_onion_skinning = n.use_lights = False
|
||||||
|
n.hide = True
|
||||||
|
n.opacity = 0
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -479,14 +490,21 @@ def obj_layer_name_callback():
|
||||||
if not ob.data.layers.active:
|
if not ob.data.layers.active:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
## Set selection to active object ot avoid un-sync selection on Layers stack
|
||||||
|
## (happen when an objet is selected but not active with 'lock object mode')
|
||||||
for l in ob.data.layers:
|
for l in ob.data.layers:
|
||||||
l.select = l == ob.data.layers.active
|
l.select = l == ob.data.layers.active
|
||||||
|
|
||||||
res = re.search(PATTERN, ob.data.layers.active.info)
|
res = re.search(PATTERN, ob.data.layers.active.info.strip())
|
||||||
if not res:
|
if not res:
|
||||||
return
|
return
|
||||||
if not res.group('name'):
|
if not res.group('name'):
|
||||||
return
|
return
|
||||||
|
print('grp:', res.group('grp'))
|
||||||
|
print('tag:', res.group('tag'))
|
||||||
|
print('name:', res.group('name'))
|
||||||
|
print('sfix:', res.group('sfix'))
|
||||||
|
print('inc:', res.group('inc'))
|
||||||
bpy.context.scene.gptoolprops['layer_name'] = res.group('name')
|
bpy.context.scene.gptoolprops['layer_name'] = res.group('name')
|
||||||
|
|
||||||
@persistent
|
@persistent
|
||||||
|
|
|
@ -77,7 +77,7 @@ class GP_OT_pick_closest_material(Operator):
|
||||||
|
|
||||||
if self.gp.use_multiedit:
|
if self.gp.use_multiedit:
|
||||||
for l in self.gp.layers:
|
for l in self.gp.layers:
|
||||||
if l.lock or l.hide:
|
if l.hide:# l.lock or
|
||||||
continue
|
continue
|
||||||
for f in l.frames:
|
for f in l.frames:
|
||||||
if not f.select:
|
if not f.select:
|
||||||
|
@ -88,7 +88,7 @@ class GP_OT_pick_closest_material(Operator):
|
||||||
else:
|
else:
|
||||||
# [s for l in self.gp.layers if not l.lock and not l.hide for s in l.active_frame.stokes]
|
# [s for l in self.gp.layers if not l.lock and not l.hide for s in l.active_frame.stokes]
|
||||||
for l in self.gp.layers:
|
for l in self.gp.layers:
|
||||||
if l.lock or l.hide or not l.active_frame:
|
if l.hide or not l.active_frame:# l.lock or
|
||||||
continue
|
continue
|
||||||
for s in l.active_frame.strokes:
|
for s in l.active_frame.strokes:
|
||||||
self.stroke_list.append(s)
|
self.stroke_list.append(s)
|
||||||
|
|
Loading…
Reference in New Issue