質問

I am trying to create a Dominion game in Smalltalk, and I can't get the layout of the GUI the way I want.

Currently, I have this as code to build the GUI:

open: game
| builder content |
builder := UITheme builder.
content := builder
    newColumn:
    {(builder
        newListFor: game
            list: #supplyStrings
            selected: nil
            changeSelected: nil
            getEnabled: nil
            help: 'Supply') .
        (builder newRow: (game players collect: [ :p | self morphForPlayer: p usingBuilder: builder ]))}.

gui := (content openInWindowLabeled: 'DominionGame') extent: 1024 @ 768

(forgive the poor Smalltalk style, I've been using Smalltalk for a week).

I am getting the basic idea of what I want: a window with the top portion common to all players, and a bottom portion divided into sections for each player.

The trouble I have is that the top portion is too big, taking up about half the window, and I don't know how to fix that.

I've tried adding "vsizing: #shrinkWrap" to the builder for the #supplyStrings list, but that made it too small, forcing the contents to use a scrollbar; I've tried adding "extent: 1024@200" to that morph, and saw no effect.

So I have two questions:

1) How do I get finer layout control over the objects built with UITheme builder? 2) Where can I find documentation on how to do UI design using Pharo? I'd love to RTFM, if I know where TFM was to R!

役に立ちましたか?

解決

You can build an UI at different abstraction levels in Pharo. There is Glamour, where you describe the UI in terms of presentations, panes & ports. It is most useful for building specialized model browsers. For building a game it doesn't seem the most suitable. Then there is Spec, aiming at reuse of composable widgets. That could be a good fit. This summer there has been a GSoC project to build an Spec UIPainter, so you can get a good feel for how to layout the UI. PolyMorph is basically an abstraction layer over Morphic providing different skins (UIThemes). Below that is Morphic. An advantage of building directly in Morphic is that there is an excellent game building example: Laser Game (needing slight changes for use in Pharo).

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top