Commit 20d38df1 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Add highlight function at scene level

parent 9dbd75a1
......@@ -320,6 +320,8 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
self.select_rect = None
# Keep a list of composite states: {'stateName': SDL_Scene}
self._composite_states = {}
# Keep a track of highlighted symbols: { symbol: brush }
self.highlighted = {}
def visible_symb(self):
......@@ -603,6 +605,27 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
nextstate=False, cpy=True))
def highlight(self, item):
''' Highlight a symbol '''
if item in self.highlighted:
bound = item.boundingRect()
center =
gradient = QtGui.QLinearGradient(center, 0, center, bound.height())
gradient.setColorAt(0, Qt.cyan)
gradient.setColorAt(1, Qt.white)
self.highlighted[item] = item.brush()
def clear_highlight(self, item=None, reset=True):
''' Remove the highlighting of one item or all items on the scene '''
if item in self.highlighted:
if reset:
for item, brush in self.highlighted.viewitems():
self.highlighted = {}
def find_text(self, pattern):
''' Return all symbols with matching text '''
for item in (symbol for symbol in self.items()
Supports Markdown
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