commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r10978 - in gnuradio/trunk/grc/src: gui platforms/gui


From: jblum
Subject: [Commit-gnuradio] r10978 - in gnuradio/trunk/grc/src: gui platforms/gui
Date: Wed, 6 May 2009 01:26:58 -0600 (MDT)

Author: jblum
Date: 2009-05-06 01:26:58 -0600 (Wed, 06 May 2009)
New Revision: 10978

Modified:
   gnuradio/trunk/grc/src/gui/ActionHandler.py
   gnuradio/trunk/grc/src/gui/DrawingArea.py
   gnuradio/trunk/grc/src/platforms/gui/FlowGraph.py
Log:
Moved resizing logic out of animation path.
Drawing area configure event for pixmap creation.
State handler for flow graph resizing.



Modified: gnuradio/trunk/grc/src/gui/ActionHandler.py
===================================================================
--- gnuradio/trunk/grc/src/gui/ActionHandler.py 2009-05-06 01:49:34 UTC (rev 
10977)
+++ gnuradio/trunk/grc/src/gui/ActionHandler.py 2009-05-06 07:26:58 UTC (rev 
10978)
@@ -345,8 +345,13 @@
                #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):

Modified: gnuradio/trunk/grc/src/gui/DrawingArea.py
===================================================================
--- gnuradio/trunk/grc/src/gui/DrawingArea.py   2009-05-06 01:49:34 UTC (rev 
10977)
+++ gnuradio/trunk/grc/src/gui/DrawingArea.py   2009-05-06 07:26:58 UTC (rev 
10978)
@@ -40,11 +40,12 @@
                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 @@
                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 @@
                        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)

Modified: gnuradio/trunk/grc/src/platforms/gui/FlowGraph.py
===================================================================
--- gnuradio/trunk/grc/src/platforms/gui/FlowGraph.py   2009-05-06 01:49:34 UTC 
(rev 10977)
+++ gnuradio/trunk/grc/src/platforms/gui/FlowGraph.py   2009-05-06 07:26:58 UTC 
(rev 10978)
@@ -247,10 +247,6 @@
                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 @@
                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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]