summaryrefslogtreecommitdiff
path: root/grc
diff options
context:
space:
mode:
authorjblum2009-05-06 07:26:58 +0000
committerjblum2009-05-06 07:26:58 +0000
commit79c75e2cadd885afd0b34f30a6926ad908e1d896 (patch)
treea0c991af1df800ecc937cf6f0b982b06819bd654 /grc
parent39a30740c97dbd0ccd4a3effbb1f88a3da491532 (diff)
downloadgnuradio-79c75e2cadd885afd0b34f30a6926ad908e1d896.tar.gz
gnuradio-79c75e2cadd885afd0b34f30a6926ad908e1d896.tar.bz2
gnuradio-79c75e2cadd885afd0b34f30a6926ad908e1d896.zip
Moved resizing logic out of animation path.
Drawing area configure event for pixmap creation. State handler for flow graph resizing. git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@10978 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'grc')
-rw-r--r--grc/src/gui/ActionHandler.py7
-rw-r--r--grc/src/gui/DrawingArea.py20
-rw-r--r--grc/src/platforms/gui/FlowGraph.py25
3 files changed, 28 insertions, 24 deletions
diff --git a/grc/src/gui/ActionHandler.py b/grc/src/gui/ActionHandler.py
index 27f19cbf9..f5f349d4a 100644
--- a/grc/src/gui/ActionHandler.py
+++ b/grc/src/gui/ActionHandler.py
@@ -345,8 +345,13 @@ class ActionHandler:
#saved status
Actions.get_action_from_name(Actions.FLOW_GRAPH_SAVE).set_sensitive(not self.get_page().get_saved())
self.main_window.update()
+ try: #set the size of the flow graph area (if changed)
+ new_size = self.get_flow_graph().get_option('window_size')
+ if self.get_flow_graph().get_size() != tuple(new_size):
+ self.get_flow_graph().set_size(*new_size)
+ except: pass
#draw the flow graph
- self.get_flow_graph().update_highlighting()
+ self.get_flow_graph().update_selected()
self.get_flow_graph().queue_draw()
def update_exec_stop(self):
diff --git a/grc/src/gui/DrawingArea.py b/grc/src/gui/DrawingArea.py
index 5258979d8..feb401978 100644
--- a/grc/src/gui/DrawingArea.py
+++ b/grc/src/gui/DrawingArea.py
@@ -40,11 +40,12 @@ class DrawingArea(gtk.DrawingArea):
self._main_window.drawing_area = self
gtk.DrawingArea.__init__(self)
self.set_size_request(MIN_WINDOW_WIDTH, MIN_WINDOW_HEIGHT)
+ self.connect('configure-event', self._handle_window_configure)
self.connect('expose-event', self._handle_window_expose)
self.connect('motion-notify-event', self._handle_mouse_motion)
self.connect('button-press-event', self._handle_mouse_button_press)
self.connect('button-release-event', self._handle_mouse_button_release)
- self.set_events(
+ self.add_events(
gtk.gdk.BUTTON_PRESS_MASK | \
gtk.gdk.POINTER_MOTION_MASK | \
gtk.gdk.BUTTON_RELEASE_MASK | \
@@ -59,8 +60,6 @@ class DrawingArea(gtk.DrawingArea):
self.get_focus_flag = lambda: self._focus_flag
self.connect('leave-notify-event', self._handle_focus_event, False)
self.connect('enter-notify-event', self._handle_focus_event, True)
- #pixmap for drawing
- self.pixmap = None
##########################################################################
## Handlers
@@ -105,14 +104,19 @@ class DrawingArea(gtk.DrawingArea):
coordinate=(event.x, event.y),
)
+ def _handle_window_configure(self, widget, event):
+ """
+ Called when the window is resized.
+ Create a new pixmap for background buffer.
+ """
+ width, height = self.get_size_request()
+ self.pixmap = gtk.gdk.Pixmap(self.window, width, height, -1)
+
def _handle_window_expose(self, widget, event):
"""
- Called when window is exposed, resized, or queue_draw is called.
+ Called when window is exposed, or queue_draw is called.
+ Double buffering: draw to pixmap, then draw pixmap to window.
"""
gc = self.window.new_gc()
- width, height = self.get_size_request()
- if not self.pixmap or (width, height) != self.pixmap.get_size():
- self.pixmap = gtk.gdk.Pixmap(self.window, width, height, -1)
- #double buffering: draw to pixmap, then draw pixmap
self._main_window.get_flow_graph().draw(gc, self.pixmap)
self.window.draw_drawable(gc, self.pixmap, 0, 0, 0, 0, -1, -1)
diff --git a/grc/src/platforms/gui/FlowGraph.py b/grc/src/platforms/gui/FlowGraph.py
index 11942eb2e..82b45dc03 100644
--- a/grc/src/platforms/gui/FlowGraph.py
+++ b/grc/src/platforms/gui/FlowGraph.py
@@ -247,10 +247,6 @@ class FlowGraph(Element):
Draw all of the elements in this flow graph onto the pixmap.
Draw the pixmap to the drawable window of this flow graph.
"""
- try: #set the size of the flow graph area (if changed)
- new_size = self.get_option('window_size')
- if self.get_size() != tuple(new_size): self.set_size(*new_size)
- except: pass
W,H = self.get_size()
#draw the background
gc.foreground = Colors.BACKGROUND_COLOR
@@ -275,27 +271,26 @@ class FlowGraph(Element):
for selected_element in self.get_selected_connections() + self.get_selected_blocks():
selected_element.draw(gc, window)
- def update_highlighting(self):
+ def update_selected(self):
"""
+ Remove deleted elements from the selected elements list.
Update highlighting so only the selected are highlighted.
"""
selected_elements = self.get_selected_elements()
- for element in self.get_elements():
+ elements = self.get_elements()
+ #remove deleted elements
+ for selected in selected_elements:
+ if selected in elements: continue
+ selected_elements.remove(selected)
+ #update highlighting
+ for element in elements:
element.set_highlighted(element in selected_elements)
def update(self):
"""
- Removed deleted elements from the selected elements list.
Call update on all elements.
"""
- selected_elements = self.get_selected_elements()
- elements = self.get_elements()
- #remove deleted elements
- for selected in selected_elements:
- if selected in elements: continue
- selected_elements.remove(selected)
- #update all
- for element in elements: element.update()
+ for element in self.get_elements(): element.update()
##########################################################################
## Get Selected