displaying a grid of images

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

displaying a grid of images

Rob Withers
Can anyone demonstrate how I could display a grid of images within a  
SystemWindow?  For example, I have a 5 by 5 grid and each grid would  
display a scaled Form.  I tried adding a morph for each cell and I  
ran into a couple of problems.  First, as I increase the size of the  
grid, window creation takes longer and longer due to the processing  
of Splitters, it looks like.  I don't need those I don't believe.  
Secondly, given this drawOn: method:

drawOn: aCanvas

        | src dest |
        src := self form.
        dest := Form extent: self extent depth: aCanvas form depth.
        src displayScaledOn: dest.
        aCanvas drawImage: dest at: bounds origin.

For each use in the grid of a particular form (I am reusing the  
source forms of which there are 7 currently) it would get  
progressively magnified.  It is like the #displayScaledOn: is  
affecting the src form.

I think I need to blt each grid form into a window sized form and  
build my own grid image then draw it to the canvas.  Does that sound  
like the right approach?  Does anyone have some example code of this  
kind of thing?   I will also be needing to identify where mouse  
clicks are happening within this image and take some action.

thanks fr any help,
Robert

Reply | Threaded
Open this post in threaded view
|

Re: displaying a grid of images

Rob Withers
Ok, I found a way to do this.  First I WarpBlt one of the source  
images into a tempForm appropriately sized as a portion of the  
Window.  Then I BitBlt that tempForm to the appropriate place within  
a Form the size of the window.   I'll need to identify which grid a  
mouse click lands.  I also need to scroll the window.  I'll explain.

I am trying to build a strategy game along the lines of StarCraft or  
Civilization (I have not yet decided if it is to be a realtime or  
turn-based game).  The view will have a small map of the entire world  
and a viewer window showing a large view of a smaller portion of the  
map.  Now, StarCraft ad Civ are full screen games, so they own the  
mouse (the mouse never leaves the game).  Currently I am shooting for  
a SystemWindow that is maximized in Squeak, like if you hit the  
expand button.  I was hoping to capture the mouse inside of this  
window and then detect when it is against one of the edges of the  
window to start scrolling the viewer.  Is this possible?

thanks,
Robert

On Jan 2, 2007, at 3:04 PM, Robert Withers wrote:

> Can anyone demonstrate how I could display a grid of images within  
> a SystemWindow?  For example, I have a 5 by 5 grid and each grid  
> would display a scaled Form.  I tried adding a morph for each cell  
> and I ran into a couple of problems.  First, as I increase the size  
> of the grid, window creation takes longer and longer due to the  
> processing of Splitters, it looks like.  I don't need those I don't  
> believe.  Secondly, given this drawOn: method:
>
> drawOn: aCanvas
>
> | src dest |
> src := self form.
> dest := Form extent: self extent depth: aCanvas form depth.
> src displayScaledOn: dest.
> aCanvas drawImage: dest at: bounds origin.
>
> For each use in the grid of a particular form (I am reusing the  
> source forms of which there are 7 currently) it would get  
> progressively magnified.  It is like the #displayScaledOn: is  
> affecting the src form.
>
> I think I need to blt each grid form into a window sized form and  
> build my own grid image then draw it to the canvas.  Does that  
> sound like the right approach?  Does anyone have some example code  
> of this kind of thing?   I will also be needing to identify where  
> mouse clicks are happening within this image and take some action.
>
> thanks fr any help,
> Robert
>


Reply | Threaded
Open this post in threaded view
|

Re: displaying a grid of images

Brian Rice
Hi Rob,

On Jan 2, 2007, at 8:29 PM, Robert Withers wrote:

> I am trying to build a strategy game along the lines of StarCraft  
> or Civilization (I have not yet decided if it is to be a realtime  
> or turn-based game).  The view will have a small map of the entire  
> world and a viewer window showing a large view of a smaller portion  
> of the map.  Now, StarCraft ad Civ are full screen games, so they  
> own the mouse (the mouse never leaves the game).

That's interesting, and reminds me of Eddie's WarGame (see below).

> Currently I am shooting for a SystemWindow that is maximized in  
> Squeak, like if you hit the expand button.

I hope your eventual target is full-screen mode.

> I was hoping to capture the mouse inside of this window and then  
> detect when it is against one of the edges of the window to start  
> scrolling the viewer.  Is this possible?

Have you seen/ran/edited Eddie Cottongim's RTS-style WarGame demo?
  See http://wiki.squeak.org/squeak/3136

He uses morphs that border the screen and/or window to get mouse-
click-less intuitive scrolling.

I've wanted to play with using SIMS together with this framework, but  
priorities have been elsewhere.

--
-Brian
http://briantrice.com




PGP.sig (193 bytes) Download Attachment