A Presentation defines the way a Pane is to be displayed and how the user interaction should change its state. It does that by interpreting the values from the Ports and by specifying how these Ports should change.
Presentations can be parameterized in several ways using blocks. The basic parameters are:
- Every presentation has a title set via
- A presentation can transform the input into a model better suited for it. This is accomplished via the
- The visibility of each presentation can be controlled via a condition block that is set by sending a
- By default, there is an implicit condition saying that all input objects must be not nil for the presentation to appear. If we still want to allow the presentation to appear even if the the input objects are nil we can use
All these specifications take as input blocks that accept a variable number of parameters depending on the number of objects present in the
In our example, from Section 18.1, we only used transmissions with one origin, and thus the display blocks took one parameter as input. For example, the code below describes how on the
#details pane we should show a TextPresentation that should
display: the result of a block that takes as parameter the
#selection from the
#methods pane, and this in turn happens to be a method entity which understands
browser transmit from: #methods; to: #details; andShow: [ :a |
display: [ :method | method sourceText ] ].
If on the other hand, we might want to be able to show the source code for both a class and a method, we could write:
to: #details; andShow: [ :a |
title: [ :class | class name, ' source'];
display: [ :class | class sourceText ];
title: [ :class :method | method name, ' source'];
display: [ :class :method | method sourceText ] ].
Because now we have two origins, there will be two objects in the #entity port corresponding to the selected class and to the selected method. Thus, the
display: block of the presentations accepts two parameters. However, when we only need the first one we can leave the second one out, as is the case for displaying the class source text. Furthermore, because we want to display the class source even when no method is selected, we want to allow the presentation to appear even when one of the ports is nil.
Glamour offers multiple types of presentations, and the figure below shows an overview. Some of these correspond to basic widgets that can be found in user interface frameworks, while others are more sophisticated and tailored for the needs of browsing. The following section describe each of them. Browsers are handled in Section 18.6, while Actions are dealt with in Section 18.7.