aboutsummaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/defconQt/glyphView.py21
-rw-r--r--Lib/defconQt/groupsView.py4
-rw-r--r--Lib/defconQt/spaceCenter.py17
3 files changed, 28 insertions, 14 deletions
diff --git a/Lib/defconQt/glyphView.py b/Lib/defconQt/glyphView.py
index 6dfa676..140e334 100644
--- a/Lib/defconQt/glyphView.py
+++ b/Lib/defconQt/glyphView.py
@@ -95,9 +95,8 @@ class MainGfxWindow(QMainWindow):
self.view.setRenderer(GlyphView.Image)
def setWindowTitle(self, title, font=None):
- if font is not None: puts = "%s – %s %s" % (title, font.info.familyName, font.info.styleName)
- else: puts = title
- super(MainGfxWindow, self).setWindowTitle(puts)
+ if font is not None: title = "%s – %s %s" % (title, font.info.familyName, font.info.styleName)
+ super(MainGfxWindow, self).setWindowTitle(title)
def roundPosition(value):
value = value * 10#self._scale
@@ -149,6 +148,9 @@ class OffCurvePointItem(QGraphicsEllipseItem):
def itemChange(self, change, value):
if change == QGraphicsItem.ItemPositionChange:
+ if self.scene()._integerPlane:
+ value.setX(round(value.x()))
+ value.setY(round(value.y()))
if QApplication.keyboardModifiers() & Qt.ShiftModifier \
and len(self.scene().selectedItems()) == 1:
ax = abs(value.x())
@@ -178,7 +180,7 @@ class OffCurvePointItem(QGraphicsEllipseItem):
# http://www.qtfr.org/viewtopic.php?pid=21045#p21045
def paint(self, painter, option, widget):
- if self.x() == 0 and self.y() == 0: return
+ #if self.x() == 0 and self.y() == 0: return
newOption = QStyleOptionGraphicsItem(option)
newOption.state = QStyle.State_None
pen = self.pen()
@@ -273,7 +275,11 @@ class OnCurvePointItem(QGraphicsPathItem):
self._contour.dirty = True
def itemChange(self, change, value):
- if change == QGraphicsItem.ItemPositionHasChanged:
+ if change == QGraphicsItem.ItemPositionChange:
+ if self.scene()._integerPlane:
+ value.setX(round(value.x()))
+ value.setY(round(value.y()))
+ elif change == QGraphicsItem.ItemPositionHasChanged:
if self.scene() is None: return QGraphicsItem.itemChange(self, change, value)
# TODO: if we're snapped to int round self.pos to int
# have a look at defcon FuzzyNumber as well
@@ -317,6 +323,7 @@ class GlyphScene(QGraphicsScene):
def __init__(self, parent):
super(GlyphScene, self).__init__(parent)
self._editing = False
+ self._integerPlane = True
def getItemForPoint(self, point):
for item in self.items():
@@ -453,7 +460,7 @@ class GlyphScene(QGraphicsScene):
if self._editing:
sel = self.selectedItems()
if len(sel) == 1:
- if isinstance(sel[0], OnCurvePointItem) and (event.scenePos() - sel[0].pos()).manhattanLength() >= 1:
+ if isinstance(sel[0], OnCurvePointItem) and (event.scenePos() - sel[0].pos()).manhattanLength() >= 2:
if len(sel[0]._contour) < 2:
# release current onCurve
self.sendEvent(sel[0], QEvent(QEvent.MouseButtonRelease))
@@ -831,7 +838,7 @@ class GlyphView(QGraphicsView):
#self._setFrame()
self.scale(factor, factor)
scale = self.transform().m11()
- if scale < 4:
+ if scale < 4 and scale > .4:
offCPS = offCurvePointSize / scale
onCPS = onCurvePointSize / scale
onCSPS = onCurveSmoothPointSize / scale
diff --git a/Lib/defconQt/groupsView.py b/Lib/defconQt/groupsView.py
index aa22282..1128483 100644
--- a/Lib/defconQt/groupsView.py
+++ b/Lib/defconQt/groupsView.py
@@ -100,8 +100,6 @@ class GroupsWindow(QWidget):
self.groupsList = GroupListWidget(self.font.groups.keys(), self)
self.groupsList.itemChanged.connect(self._groupRenamed)
- # TODO: it seems grid layout extends the column regardless of this
- self.groupsList.setMaximumWidth(4*56+1)
self.stackWidget = GroupStackWidget(self.font, parent=self)
@@ -129,6 +127,8 @@ class GroupsWindow(QWidget):
layout.addWidget(self.alignLeftBox, 5, 4)
layout.addWidget(self.alignRightBox, 5, 7)
layout.addWidget(self.scrollArea, 6, 0, 4, 8)
+ # TODO: calib this more
+ layout.setColumnStretch(4, 1)
self.setLayout(layout)
self.setWindowTitle("%s%s%s%s" % ("Groups window – ", self.font.info.familyName, " ", self.font.info.styleName))
diff --git a/Lib/defconQt/spaceCenter.py b/Lib/defconQt/spaceCenter.py
index 106c6d1..f0375da 100644
--- a/Lib/defconQt/spaceCenter.py
+++ b/Lib/defconQt/spaceCenter.py
@@ -291,7 +291,8 @@ class GlyphsCanvas(QWidget):
kerning = self.font.kerning
groups = self.font.groups
# quickly check to see if the pair is in the kerning dictionary
- if (first, second) in kerning:
+ pair = (first, second)
+ if pair in kerning:
return kerning[pair]
# get group names and make sure first and second are glyph names
firstGroup = secondGroup = None
@@ -386,7 +387,10 @@ class GlyphCellItemDelegate(QStyledItemDelegate):
chg *= 10
if modifiers & Qt.ControlModifier:
chg *= 10
- cur = int(editor.text())
+ try:
+ cur = int(editor.text())
+ except ValueError:
+ cur = float(editor.text())
editor.setText(str(cur+chg))
self.commitData.emit(editor)
editor.selectAll()
@@ -437,10 +441,13 @@ class SpaceTable(QTableWidget):
def _cellEdited(self, row, col):
if row == 0 or col == 0: return
item = self.item(row, col).text()
- # Glyphs that do not have outlines leave empty cells, can't call
- # int() on that
+ # Glyphs that do not have outlines leave empty cells, can't convert
+ # that to a scalar
if not item: return
- item = int(item)
+ try:
+ item = int(item)
+ except ValueError:
+ item = float(item)
# -1 because the first col contains descriptive text
glyph = self.glyphs[col-1]
if row == 1: