Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tutorius/viewer.py
diff options
context:
space:
mode:
authorSimon Poirier <simpoir@gmail.com>2009-10-27 19:25:12 (GMT)
committer Simon Poirier <simpoir@gmail.com>2009-10-27 19:25:12 (GMT)
commit636ea828404401df256b234f254bad32c70aba66 (patch)
tree5db056380d566436378dc450061e76f453bfb35b /tutorius/viewer.py
parent660a5bd1e0a24d83fc963a83097b540bc2f28eaa (diff)
code review related fixes
Diffstat (limited to 'tutorius/viewer.py')
-rw-r--r--tutorius/viewer.py31
1 files changed, 24 insertions, 7 deletions
diff --git a/tutorius/viewer.py b/tutorius/viewer.py
index 751e89a..272558e 100644
--- a/tutorius/viewer.py
+++ b/tutorius/viewer.py
@@ -75,13 +75,11 @@ class Viewer(object):
self.win.set_deletable(False)
self.win.move(0, 0)
- #vbox = gtk.VBox()
vbox = gtk.ScrolledWindow()
self.win.add(vbox)
canvas = gtk.DrawingArea()
- #vbox.pack_start(canvas)
- vbox.add_with_viewport(canvas) # temp
+ vbox.add_with_viewport(canvas)
canvas.set_app_paintable(True)
canvas.connect_after("expose-event", self.on_viewer_expose, tutorial._states)
canvas.add_events(gtk.gdk.BUTTON_PRESS_MASK \
@@ -97,9 +95,6 @@ class Viewer(object):
canvas.set_flags(gtk.HAS_FOCUS|gtk.CAN_FOCUS)
canvas.grab_focus()
- #self.scroll = gtk.HScrollbar()
- #vbox.pack_end(self.scroll, False)
-
self.win.show_all()
canvas.set_size_request(2048, 180) # FIXME
@@ -221,6 +216,9 @@ class Viewer(object):
yield False
def _render_snapshot(self, ctx, elem):
+ """
+ Render the "simplified screenshot-like" representation of elements positions.
+ """
ctx.set_source_rgba(1.0, 1.0, 1.0, 0.5)
ctx.rectangle(0, 0, SNAP_WIDTH, SNAP_HEIGHT)
ctx.fill_preserve()
@@ -236,6 +234,10 @@ class Viewer(object):
ctx.stroke()
def _render_app_hints(self, ctx, appname):
+ """
+ Fetches the icon of the app related to current states and renders it on a
+ separator, between states.
+ """
ctx.set_source_rgb(0.0, 0.0, 0.0)
ctx.set_dash((1,1,0,0), 1)
ctx.move_to(0, 0)
@@ -255,6 +257,9 @@ class Viewer(object):
def render_action(self, ctx, width, height, action):
+ """
+ Renders the action block, along with the icon of the action tool.
+ """
ctx.save()
inner_width = width-(BLOCK_CORNERS<<1)
inner_height = height-(BLOCK_CORNERS<<1)
@@ -300,6 +305,9 @@ class Viewer(object):
ctx.restore()
def render_event(self, ctx, width, height, event):
+ """
+ Renders the action block, along with the icon of the action tool.
+ """
ctx.save()
inner_width = width-(BLOCK_CORNERS<<1)
inner_height = height-(BLOCK_CORNERS<<1)
@@ -347,13 +355,22 @@ class Viewer(object):
ctx.restore()
def on_viewer_expose(self, widget, evt, states):
+ """
+ Expose signal handler for the viewer's DrawingArea.
+ This loops through states and renders every action and transition of
+ the "happy path".
+
+ @param widget: the gtk.DrawingArea on which to draw
+ @param evt: the gtk.gdk.Event containing an "expose" event
+ @param states: a tutorius FiniteStateMachine object to paint
+ """
ctx = widget.window.cairo_create()
self.alloc = widget.get_allocation()
ctx.set_source_pixmap(widget.window,
widget.allocation.x,
widget.allocation.y)
- #draw no more than our expose event intersects our child
+ # draw no more than our expose event intersects our child
region = gtk.gdk.region_rectangle(widget.allocation)
r = gtk.gdk.region_rectangle(evt.area)
region.intersect(r)