Commit e866c277 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Improve text placement, minor optimisations

parent c1d36bfa
......@@ -49,8 +49,7 @@ class Record(genericSymbols.HorizontalSymbol, object):
_unique_followers = []
_insertable_followers = ['Record', 'Diamond', 'Stop']
_terminal_followers = []
textbox_alignment = (QtCore.Qt.AlignTop
| QtCore.Qt.AlignHCenter)
textbox_alignment = (QtCore.Qt.AlignTop | QtCore.Qt.AlignHCenter)
def __init__(self, node, graph):
''' Initialization: compute the polygon shape '''
......@@ -66,6 +65,7 @@ class Record(genericSymbols.HorizontalSymbol, object):
property_box.setPlainText(node['properties'])
# Text in statecharts is read-only:
self.text.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction)
self.text.set_textbox_position()
def set_shape(self, width, height):
''' Define the polygon shape from width and height '''
......
......@@ -200,10 +200,14 @@ class EditableText(QGraphicsTextItem, object):
x_pos = 0
elif alignment & Qt.AlignHCenter:
x_pos = rect_center.x()
else:
x_pos = 0
if alignment & Qt.AlignTop:
y_pos = 0
elif alignment & Qt.AlignVCenter:
y_pos = rect_center.y()
else:
y_pos = 0
self.setPos(x_pos, y_pos)
# def paint(self, painter, _, ___):
......@@ -224,6 +228,7 @@ class EditableText(QGraphicsTextItem, object):
parent_rect.setWidth(rect.width() + 15)
parent_rect.setHeight(max(rect.height(), parent_rect.height()))
self.parent.resize_item(parent_rect)
self.set_textbox_position()
@Slot(QListWidgetItem)
def completion_selected(self, item):
......
......@@ -711,6 +711,7 @@ class Comment(Symbol):
# Define reserved keywords for the syntax highlighter
blackbold = ('TODO', 'FIXME', 'XXX')
redbold = ()
textbox_alignment = Qt.AlignLeft | Qt.AlignVCenter
def __init__(self, parent=None, ast=None):
ast = ast or ogAST.Comment()
......@@ -724,7 +725,6 @@ class Comment(Symbol):
if parent:
local_pos = parent.mapFromScene(ast.pos_x or 0, ast.pos_y or 0)
self.insert_symbol(parent, local_pos.x(), local_pos.y())
#self.set_shape(ast.width, ast.height)
self.common_name = 'end'
self.parser = ogParser
......@@ -775,6 +775,7 @@ class Comment(Symbol):
self.set_shape(rect.width(), rect.height())
self.update_connections()
def set_shape(self, width, height):
''' Set a box - actual shape is computed in the paint function '''
path = QPainterPath()
......
......@@ -1735,7 +1735,6 @@ class SDL_View(QtGui.QGraphicsView, object):
if not autosave:
self.scene().clear_focus()
for each in scene.all_nested_scenes:
print 'clean',each.name
each.undo_stack.setClean()
else:
LOG.debug('Auto-saving backup file completed:' + filename)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment