Skip to content

Commit

Permalink
Issue #74: Contour [Panel] Redesign [Update] 4.2:
Browse files Browse the repository at this point in the history
- Paste to mask;
  • Loading branch information
kateliev committed May 17, 2023
1 parent b3249b4 commit ff48e72
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Scripts/TypeRig GUI/Panel/Contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
# - Init -------------------------------
global pLayers
global pMode
pLayers = None
pLayers = (True, False, False, False)
pMode = 0
app_name, app_version = 'TypeRig | Contour', '4.1'
app_name, app_version = 'TypeRig | Contour', '4.2'

cfg_addon_reversed = ' (Reversed)'

Expand Down Expand Up @@ -533,10 +533,10 @@ def __init__(self):
lay_contour_copy.addWidget(self.btn_copy_contour)
self.btn_copy_contour.clicked.connect(self.copy_contour)

tooltip_button = "Paste selected contours from bank"
tooltip_button = "Paste selected contours from bank\nALT + Click: Paste to mask"
self.btn_paste_contour = CustomPushButton("clipboard_paste", tooltip=tooltip_button, obj_name='btn_panel')
lay_contour_copy.addWidget(self.btn_paste_contour)
self.btn_paste_contour.clicked.connect(self.paste_contour)
self.btn_paste_contour.clicked.connect(lambda: self.paste_contour(to_mask=get_modifier()))

tooltip_button = "Remove selected items from contour bank"
self.btn_clear = CustomPushButton("clipboard_clear", tooltip=tooltip_button, obj_name='btn_panel')
Expand Down Expand Up @@ -746,7 +746,7 @@ def copy_contour(self):

output(0, app_name, 'Copy contours; Glyph: %s; Layers: %s.' %(wGlyph.name, '; '.join(process_layers)))

def paste_contour(self):
def paste_contour(self, to_mask=False):
# - Init
wGlyph = eGlyph()
wLayers = wGlyph._prepareLayers(pLayers)
Expand All @@ -765,8 +765,13 @@ def add_new_shape(layer, contours):
paste_data = self.contour_clipboard[paste_uid]

for layerName, contours in paste_data.items():
# - Get destination layer or mask. If mask is missing create it
wLayer = wGlyph.layer(layerName)

if to_mask:
wLayer = wGlyph.mask(layerName, force_create=True)
layerName = wLayer.name

# - Skip if wrong data type is being fed
if not isinstance(contours[0], fl6.flContour):
output(3, app_name, '< Partial path > not suitable for < Paste contours > operation!')
Expand Down

0 comments on commit ff48e72

Please sign in to comment.