1
+ #FLM: TR: New Nodes
2
+ # -----------------------------------------------------------
3
+ # (C) Vassil Kateliev, 2017-2021 (http://www.kateliev.com)
4
+ # (C) Karandash Type Foundry (http://www.karandash.eu)
5
+ #------------------------------------------------------------
6
+
7
+ # No warranties. By using this you agree
8
+ # that you use it at your own risk!
9
+
10
+ # - Dependencies -----------------
11
+ from __future__ import absolute_import , print_function
12
+ from collections import OrderedDict
13
+
14
+ import fontlab as fl6
15
+ from PythonQt import QtCore , QtGui
16
+
17
+ from typerig .proxy .fl .actions .node import TRNodeActionCollector
18
+ from typerig .proxy .fl .application .app import pWorkspace
19
+ #from typerig.proxy.fl.gui import QtGui
20
+ from typerig .proxy .fl .gui .widgets import getTRIconFontPath , CustomPushButton , CustomSpinButton
21
+ from typerig .proxy .fl .gui .styles import css_tr_button
22
+
23
+ # - Init -------------------------------
24
+ global pLayers
25
+ global pMode
26
+ pLayers = None
27
+ pMode = 0
28
+ app_name , app_version = 'TypeRig | Nodes' , '3.00'
29
+
30
+ TRToolFont = getTRIconFontPath ()
31
+ font_loaded = QtGui .QFontDatabase .addApplicationFont (TRToolFont )
32
+
33
+ # - Sub widgets ------------------------
34
+ # -- Layouts ---------------------------
35
+ class TRNodeBasics (QtGui .QWidget ):
36
+ def __init__ (self ):
37
+ super (TRNodeBasics , self ).__init__ ()
38
+
39
+ # - Init
40
+
41
+ # - Layout
42
+ self .lay_main = QtGui .QVBoxLayout ()
43
+
44
+ # - Widgets
45
+ self .lay_main .addWidget (QtGui .QLabel ('Node: Basic Operations' ))
46
+
47
+ tooltip_button = 'Insert Node'
48
+ self .btn_node_add = CustomSpinButton ('node_add' , (0. , 100. , 0. , 1. ), ('Set value' , tooltip_button ), ('spn_panel' , 'btn_mast' ))
49
+ self .lay_main .addWidget (self .btn_node_add )
50
+ self .btn_node_add .button .clicked .connect (lambda : TRNodeActionCollector .node_insert_dlg (pMode , pLayers , get_modifier ()))
51
+
52
+ tooltip_button = 'Insert Node at the beginning of a bezier.\n <ALT + Mouse Left> Use single node mode.'
53
+ self .btn_node_add_0 = CustomSpinButton ('node_add_bgn' , (0. , 100. , 0. , 1. ), ('Set value' , tooltip_button ), ('spn_panel' , 'btn_mast' ))
54
+ self .lay_main .addWidget (self .btn_node_add_0 )
55
+ self .btn_node_add_0 .button .clicked .connect (lambda : TRNodeActionCollector .node_insert (pMode , pLayers , 0. , get_modifier ()))
56
+
57
+ tooltip_button = 'Insert Node at the middle of a bezier.\n <ALT + Mouse Left> Use single node mode.'
58
+ self .btn_node_add_5 = CustomSpinButton ('node_add_mid' , (0. , 100. , 0. , 1. ), ('Set value' , tooltip_button ), ('spn_panel' , 'btn_mast' ))
59
+ self .lay_main .addWidget (self .btn_node_add_5 )
60
+ self .btn_node_add_5 .button .clicked .connect (lambda : TRNodeActionCollector .node_insert (pMode , pLayers , .5 , get_modifier ()))
61
+
62
+ tooltip_button = 'Insert Node at the end of a bezier.\n <ALT + Mouse Left> Use single node mode.'
63
+ self .btn_node_add_1 = CustomSpinButton ('node_add_end' , (0. , 100. , 0. , 1. ), ('Set value' , tooltip_button ), ('spn_panel' , 'btn_mast' ))
64
+ self .lay_main .addWidget (self .btn_node_add_1 )
65
+ self .btn_node_add_1 .button .clicked .connect (lambda : TRNodeActionCollector .node_insert (pMode , pLayers , 1. , get_modifier ()))
66
+
67
+ tooltip_button = 'Remove Node'
68
+ self .btn_node_remove = CustomSpinButton ('node_remove' , (0. , 100. , 0. , 1. ), ('Set value' , tooltip_button ), ('spn_panel' , 'btn_mast' ))
69
+ self .lay_main .addWidget (self .btn_node_remove )
70
+ self .btn_node_remove .button .clicked .connect (lambda : TRNodeActionCollector .node_remove (pMode , pLayers ))
71
+
72
+ tooltip_button = 'Round selected nodes to integer coordinates.\n <Mouse Left> Ceil.\n <ALT + Mouse Left> Floor.\n <... + Shift> Round all nodes.'
73
+ self .btn_node_round = CustomSpinButton ('node_round' , (0. , 100. , 0. , 1. ), ('Set value' , tooltip_button ), ('spn_panel' , 'btn_mast' ))
74
+ self .lay_main .addWidget (self .btn_node_round )
75
+ self .btn_node_round .button .clicked .connect (lambda : TRNodeActionCollector .node_round (pMode , pLayers , get_modifier (QtCore .Qt .AltModifier ), get_modifier (QtCore .Qt .ShiftModifier )))
76
+
77
+ tooltip_button = 'Corner Mitre'
78
+ self .btn_corner_mitre = CustomSpinButton ('corner_mitre' , (0. , 100. , 0. , 1. ), ('Set value' , tooltip_button ), ('spn_panel' , 'btn_mast' ))
79
+ self .lay_main .addWidget (self .btn_corner_mitre )
80
+ self .btn_corner_mitre .button .clicked .connect (lambda : TRNodeActionCollector .corner_mitre_dlg (pMode , pLayers ))
81
+
82
+ tooltip_button = 'Corner Round'
83
+ self .btn_corner_round = CustomSpinButton ('corner_round' , (0. , 100. , 0. , 1. ), ('Set value' , tooltip_button ), ('spn_panel' , 'btn_mast' ))
84
+ self .lay_main .addWidget (self .btn_corner_round )
85
+ self .btn_corner_round .button .clicked .connect (lambda : TRNodeActionCollector .corner_round_dlg (pMode , pLayers ))
86
+
87
+ tooltip_button = 'Corner Loop'
88
+ self .btn_corner_loop = CustomSpinButton ('corner_loop' , (0. , 100. , 0. , 1. ), ('Set value' , tooltip_button ), ('spn_panel' , 'btn_mast' ))
89
+ self .lay_main .addWidget (self .btn_corner_loop )
90
+ self .btn_corner_loop .button .clicked .connect (lambda : TRNodeActionCollector .corner_loop_dlg (pMode , pLayers ))
91
+
92
+ tooltip_button = 'Create Ink Trap\n <ALT + Mouse Left> Create non-smooth basic trap.'
93
+ self .btn_corner_trap = CustomSpinButton ('corner_trap' , (0. , 100. , 0. , 1. ), ('Set value' , tooltip_button ), ('spn_panel' , 'btn_mast' ))
94
+ self .lay_main .addWidget (self .btn_corner_trap )
95
+ self .btn_corner_trap .button .clicked .connect (lambda : TRNodeActionCollector .corner_trap_dlg (pMode , pLayers , get_modifier ()))
96
+
97
+ tooltip_button = 'Rebuild Corner'
98
+ self .btn_corner_rebuild = CustomSpinButton ('corner_rebuild' , (0. , 100. , 0. , 1. ), ('Set value' , tooltip_button ), ('spn_panel' , 'btn_mast' ))
99
+ self .lay_main .addWidget (self .btn_corner_rebuild )
100
+ self .btn_corner_rebuild .button .clicked .connect (lambda : TRNodeActionCollector .corner_rebuild (pMode , pLayers ))
101
+
102
+ self .setLayout (self .lay_main )
103
+
104
+
105
+ # - Tabs -------------------------------
106
+ class tool_tab (QtGui .QWidget ):
107
+ def __init__ (self ):
108
+ super (tool_tab , self ).__init__ ()
109
+
110
+ # - Init
111
+ self .setStyleSheet (css_tr_button )
112
+ layoutV = QtGui .QVBoxLayout ()
113
+
114
+ # - Add widgets to main dialog -------------------------
115
+ layoutV .addWidget (TRNodeBasics ())
116
+
117
+ # - Build ---------------------------
118
+ layoutV .addStretch ()
119
+ self .setLayout (layoutV )
120
+
121
+ # !!! Hotfix FL7 7355
122
+ self .setMinimumSize (300 ,self .sizeHint .height ())
123
+
124
+ # - Test ----------------------
125
+ if __name__ == '__main__' :
126
+ test = tool_tab ()
127
+ test .setWindowTitle ('%s %s' % (app_name , app_version ))
128
+ test .setGeometry (100 , 100 , 200 , 400 )
129
+ test .setWindowFlags (QtCore .Qt .WindowStaysOnTopHint ) # Always on top!!
130
+
131
+ test .show ()
0 commit comments