Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWade Brainerd <wadetb@gmail.com>2009-11-21 17:17:08 (GMT)
committer Wade Brainerd <wadetb@gmail.com>2009-11-21 17:17:08 (GMT)
commit7f8f78bfbce3406981c203c878a892e1065e4e4d (patch)
tree5214d6c8da366c98c399bcf708ce215fc98f4b76
parente02b66129dc1b6450d357b9df29de10bf35c42fe (diff)
Make Pygame display size match the widget size.
Also rename _canvas member to _pygamecanvas to avoid conflict with Sugar.
-rw-r--r--sugargame/event.py8
-rw-r--r--test/TestActivity.py6
-rwxr-xr-xtest/TestGame.py4
3 files changed, 13 insertions, 5 deletions
diff --git a/sugargame/event.py b/sugargame/event.py
index 42fca1e..b315c1c 100644
--- a/sugargame/event.py
+++ b/sugargame/event.py
@@ -70,6 +70,12 @@ class Translator(object):
self._inner_evb.connect('expose-event', self._expose_cb)
self._inner_evb.connect('configure-event', self._resize_cb)
+ # Fake the first VIDEORESIZE event to set the initial screen dimensions.
+ r = self._inner_evb.get_allocation()
+ evt = pygame.event.Event(pygame.VIDEORESIZE,
+ size=(r.width,r.height), width=r.width, height=r.height)
+ pygame.event.post(evt)
+
# Internal data
self.__stopped = False
self.__keystate = [0] * 323
@@ -92,7 +98,7 @@ class Translator(object):
return True
def _resize_cb(self, widget, event):
- evt = pygame.event.Event(pygame.event.VIDEORESIZE,
+ evt = pygame.event.Event(pygame.VIDEORESIZE,
size=(event.width,event.height), width=event.width, height=event.height)
pygame.event.post(evt)
return False # continue processing
diff --git a/test/TestActivity.py b/test/TestActivity.py
index 693789a..ccc0e35 100644
--- a/test/TestActivity.py
+++ b/test/TestActivity.py
@@ -25,12 +25,12 @@ class TestActivity(sugar.activity.activity.Activity):
self.build_toolbar()
# Build the Pygame canvas.
- self._canvas = sugargame.canvas.PygameCanvas(self)
+ self._pygamecanvas = sugargame.canvas.PygameCanvas(self)
# Note that set_canvas implicitly calls read_file when resuming from the Journal.
- self.set_canvas(self._canvas)
+ self.set_canvas(self._pygamecanvas)
# Start the game running.
- self._canvas.run_pygame(self.game.run)
+ self._pygamecanvas.run_pygame(self.game.run)
def build_toolbar(self):
stop_play = sugar.graphics.toolbutton.ToolButton('media-playback-stop')
diff --git a/test/TestGame.py b/test/TestGame.py
index 2c96803..d9dbc2e 100755
--- a/test/TestGame.py
+++ b/test/TestGame.py
@@ -41,7 +41,9 @@ class TestGame:
for event in pygame.event.get():
if event.type == pygame.QUIT:
return
-
+ elif event.type == pygame.VIDEORESIZE:
+ pygame.display.set_mode(event.size, pygame.RESIZABLE)
+
# Move the ball
if not self.paused:
self.x += self.vx