Skip to content

Commit e1f6f82

Browse files
committed
Issue #78: Layer [Panel] Redesign [Update] 2.56:
- transformation controls widget refactor Issue #73: Delta [Panel] Redesign: - fixed "Layer changed" subroutine; - fixed setting proper stem values in UI;
1 parent 3f25df1 commit e1f6f82

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

Lib/typerig/proxy/fl/gui/widgets.py

+10-11
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,15 @@ def __init__(self, label_text, tooltip=None, obj_name=None):
138138
if tooltip is not None: self.setToolTip(tooltip)
139139
if obj_name is not None: self.setObjectName(obj_name)
140140

141-
class CustomSpinBox(QtGui.QSpinBox):
141+
class CustomSpinBox(QtGui.QDoubleSpinBox):
142142
def __init__(self, init_values=(0., 100., 0., 1.), tooltip=None, suffix=None, obj_name=None):
143143
super(CustomSpinBox, self).__init__()
144144

145145
if any([isinstance(n, float) for n in init_values]):
146-
self.input = QtGui.QDoubleSpinBox()
146+
self.setDecimals(2)
147147
init_values = [float(n) for n in init_values]
148148
else:
149-
self.input = QtGui.QSpinBox()
149+
self.setDecimals(0)
150150

151151
# - Init
152152
spb_min, spb_max, spb_value, spb_step = init_values
@@ -173,7 +173,7 @@ def __init__(self, label_text, init_values=(0., 100., 0., 1.), tooltip=None, suf
173173
input_obj_name, lbl_obj_name = obj_name
174174

175175
# - Widgets
176-
self.label =CustomLabel(label_text, tooltip, lbl_obj_name)
176+
self.label = CustomLabel(label_text, tooltip, lbl_obj_name)
177177
self.input = CustomSpinBox(init_values, tooltip, suffix, input_obj_name)
178178

179179
# - Layout
@@ -871,35 +871,34 @@ def __init__(self):
871871
self.lay_controls = TRFlowLayout(spacing=10)
872872

873873
tooltip_button = "Scale X"
874-
self.spb_scale_x = CustomSpinLabel('scale_x', (-999., 999, 0, 1), tooltip_button, ' %', ('spn_panel_inf', 'lbl_panel'))
874+
self.spb_scale_x = CustomSpinLabel('scale_x', (-999., 999., 100., 1.), tooltip_button, ' %', ('spn_panel_inf', 'lbl_panel'))
875875
self.lay_controls.addWidget(self.spb_scale_x)
876876

877877
tooltip_button = "Scale Y"
878-
self.spb_scale_y = CustomSpinLabel('scale_y', (-999., 999, 0, 1), tooltip_button, ' %', ('spn_panel_inf', 'lbl_panel'))
878+
self.spb_scale_y = CustomSpinLabel('scale_y', (-999., 999., 100., 1.), tooltip_button, ' %', ('spn_panel_inf', 'lbl_panel'))
879879
self.lay_controls.addWidget(self.spb_scale_y)
880880

881881
tooltip_button = "Translate X"
882-
self.spb_translate_x = CustomSpinLabel('translate_x', (-999., 999, 0, 1), tooltip_button, ' u', ('spn_panel_inf', 'lbl_panel'))
882+
self.spb_translate_x = CustomSpinLabel('translate_x', (-999., 999, 0., 1.), tooltip_button, ' u', ('spn_panel_inf', 'lbl_panel'))
883883
self.lay_controls.addWidget(self.spb_translate_x)
884884

885885
tooltip_button = "Translate Y"
886-
self.spb_translate_y = CustomSpinLabel('translate_y', (-999., 999, 0, 1), tooltip_button, ' u', ('spn_panel_inf', 'lbl_panel'))
886+
self.spb_translate_y = CustomSpinLabel('translate_y', (-999., 999., 0., 1.), tooltip_button, ' u', ('spn_panel_inf', 'lbl_panel'))
887887
self.lay_controls.addWidget(self.spb_translate_y)
888888

889889
tooltip_button = "Skew/Slant"
890-
self.spb_shear = CustomSpinLabel('skew', (-90., 90, 0, 1), tooltip_button, ' °', ('spn_panel_inf', 'lbl_panel'))
890+
self.spb_shear = CustomSpinLabel('skew', (-90., 90., 0., 1.), tooltip_button, ' °', ('spn_panel_inf', 'lbl_panel'))
891891
self.lay_controls.addWidget(self.spb_shear)
892892

893893
tooltip_button = "Rotate"
894-
self.spb_rotate = CustomSpinLabel('rotate', (-360., 360, 0, 1), tooltip_button, ' °', ('spn_panel_inf', 'lbl_panel'))
894+
self.spb_rotate = CustomSpinLabel('rotate', (-360., 360., 0., 1.), tooltip_button, ' °', ('spn_panel_inf', 'lbl_panel'))
895895
self.lay_controls.addWidget(self.spb_rotate)
896896

897897
self.lay_box.addLayout(self.lay_controls)
898898

899899
box_transform.setLayout(self.lay_box)
900900
self.lay_main.addWidget(box_transform)
901901

902-
self.reset()
903902
self.setLayout(self.lay_main)
904903

905904
def reset(self):

Scripts/TypeRig GUI/Panel/Delta.py

+16-10
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
global pMode
3737
pLayers = None
3838
pMode = 0
39-
app_name, app_version = 'TypeRig | Delta', '5.3'
39+
app_name, app_version = 'TypeRig | Delta', '5.4'
4040

4141
TRToolFont = getTRIconFontPath()
4242
font_loaded = QtGui.QFontDatabase.addApplicationFont(TRToolFont)
@@ -198,27 +198,27 @@ def __init__(self):
198198
# -- Delta controls
199199
lay_controls = TRFlowLayout(spacing=10)
200200

201-
self.cpn_value_width = TRCustomSpinController('width', (-999., 999., 100, 1.), ' %', 'Width')
201+
self.cpn_value_width = TRCustomSpinController('width', (-999, 999, 100, 1), ' %', 'Width')
202202
lay_controls.addWidget(self.cpn_value_width)
203203
self.cpn_value_width.spin_box.valueChanged.connect(lambda: self.execute_scale())
204204

205-
self.cpn_value_height = TRCustomSpinController('height', (-999., 999., 100, 1.), ' %', 'Height')
205+
self.cpn_value_height = TRCustomSpinController('height', (-999, 999, 100, 1), ' %', 'Height')
206206
lay_controls.addWidget(self.cpn_value_height)
207207
self.cpn_value_height.spin_box.valueChanged.connect(lambda: self.execute_scale())
208208

209-
self.cpn_value_stem_x = TRCustomSpinController('stem_vertical_alt', (-300., 300., 1, 1.), ' u', 'Vertical stem width')
209+
self.cpn_value_stem_x = TRCustomSpinController('stem_vertical_alt', (-300, 300, 1, 1), ' u', 'Vertical stem width')
210210
lay_controls.addWidget(self.cpn_value_stem_x)
211211
self.cpn_value_stem_x.spin_box.valueChanged.connect(lambda: self.execute_scale())
212212

213-
self.cpn_value_stem_y = TRCustomSpinController('stem_horizontal_alt', (-300., 300., 1, 1.), ' u', 'Horizontal stem width')
213+
self.cpn_value_stem_y = TRCustomSpinController('stem_horizontal_alt', (-300, 300, 1, 1), ' u', 'Horizontal stem width')
214214
lay_controls.addWidget(self.cpn_value_stem_y)
215215
self.cpn_value_stem_y.spin_box.valueChanged.connect(lambda: self.execute_scale())
216216

217-
self.cpn_value_lerp_t = TRCustomSpinController('interpolate', (-300., 300., 0, 1.), ' %', 'Time along axis')
217+
self.cpn_value_lerp_t = TRCustomSpinController('interpolate', (-300, 300, 0, 1), ' %', 'Time along axis')
218218
lay_controls.addWidget(self.cpn_value_lerp_t)
219219
self.cpn_value_lerp_t.spin_box.valueChanged.connect(lambda: self.execute_scale(True))
220220

221-
self.cpn_value_ital = TRCustomSpinController('slope_italic', (-20., 20., self.active_font.italic_angle, 1.), ' °', 'Italic angle')
221+
self.cpn_value_ital = TRCustomSpinController('slope_italic', (-20, 20, self.active_font.italic_angle, 1), ' °', 'Italic angle')
222222
lay_controls.addWidget(self.cpn_value_ital)
223223
self.cpn_value_ital.spin_box.valueChanged.connect(lambda: self.execute_scale())
224224

@@ -306,7 +306,7 @@ def __prepare_delta(self):
306306
self.__refresh_ui()
307307
return False
308308

309-
elif self.active_glyph.layer().name != self.active_layer:
309+
if self.active_glyph.layer().name != self.active_layer:
310310
self.__refresh_ui()
311311
self.active_layer = self.active_glyph.layer().name
312312
warnings.warn('Layer changed! Forcing refresh...', LayerWarning)
@@ -339,10 +339,11 @@ def __refresh_ui(self):
339339
self.cpn_value_width.setValue(100)
340340
self.cpn_value_height.setValue(100)
341341
self.value_array = DeltaScale(self.axis_stems, self.axis_stems)
342+
all_layers = sum(self.masters_data.values(),[])
342343

343344
if len(self.axis_data):
344-
self.cpn_value_stem_x.setValue(float(self.__where(self.axis_data, self.active_glyph.layer().name, 1)))
345-
self.cpn_value_stem_y.setValue(float(self.__where(self.axis_data, self.active_glyph.layer().name, 2)))
345+
self.cpn_value_stem_x.setValue(float(self.__where(all_layers, self.active_glyph.layer().name, 1)))
346+
self.cpn_value_stem_y.setValue(float(self.__where(all_layers, self.active_glyph.layer().name, 2)))
346347

347348
self.cpn_value_ital.setValue(self.active_font.italic_angle)
348349

@@ -361,6 +362,10 @@ def __set_axis(self, verbose=False):
361362
self.masters_data = self.tree_layer.getTree()
362363
self.axis_data = self.masters_data[tree_axis_group_name]
363364
self.axis_stems = []
365+
366+
if not len(self.axis_data):
367+
warnings.warn('Axis not set! Please add two or more layers!', TRDeltaAxisWarning)
368+
return
364369

365370
for layer_data in self.axis_data:
366371
try:
@@ -371,6 +376,7 @@ def __set_axis(self, verbose=False):
371376
warnings.warn('Missing or invalid stem data!', TRDeltaStemWarning)
372377
return
373378

379+
self.__refresh_ui()
374380
if verbose: output(0, '%s %s' %(app_name, app_version), 'Font: %s; Axis set.' %(self.active_font.name))
375381

376382
def __reset_axis(self, verbose=False):

0 commit comments

Comments
 (0)