Login
  • Username:

    Password:
  • Remember my login on this computer
  • Register

R3GUI resizing

Contents

[edit] Purpose

The purpose of this document is to describe the R3 GUI resizing subsystem.

[edit] Overview

[edit] Original version

The original resizing in R3 GUI had the following bugs and limitations:

  • problematic offset computation
  • the MAX-SIZE field influenced the expansion ratio
  • box model not implemented
  • low flexibility

What was needed, was to define an algorithm that would:

  • be flexible
  • use a built-in box model
  • easy to use by layout makers
  • easy to understand by style makers
  • simple consistent rules to compute positions
  • simple consistent rules to compute sizes

[edit] Improvements

[edit] Objects expand evenly

Since the idea to use the MAX-SIZE field to determine the expansion ratio was not accepted well, we needed to use a different approach, looking more "natural" to the user.

The most natural expansion principle seemed to be the principle to expand objects "evenly", i.e. proportionally to their original dimensions. The attribute used is called INIT-SIZE.

[edit] Example

Let's consider two objects with no resizing limits, object A having INIT-SIZE 50x20, object B having INIT-SIZE 100x20. Moreover, let's suppose that the objects are in a hpanel consisting of just one row and containing no additional space.

view [
 hpanel [
  a: box red options [init-size: 50x20]
  b: box green options [init-size: 100x20]
  ]
 ]

Image:R3guiresize1.jpg

Initially, both objects will have the dimensions 50x20 and 100x20, and the hpanel will have the dimensions 150x20. If it is needed to expand the hpanel to 300x20, the object A will be resized to 100x20, while the object B will be resized to 200x20, i.e. proportionally to their INIT-SIZE values.

Image:R3guiresize2.jpg

[edit] MIN-SIZE is used as the lowest boundary

For every object it is possible to specify the smallest dimensions the object is allowed to have after resizing. The attribute is called MIN-SIZE. When the size computed by the resizing algorithm would be smaller than the MIN-SIZE, the calculated size is clipped to the MIN-SIZE.

If we do not want to limit the object's ability to shrink, we can set the MIN-SIZE of the object to 0x0. That does not limit the object's ability to shrink.

[edit] MAX-SIZE is used as the highest boundary

For every object it is possible to specify the greatest dimensions the object is allowed to have after resizing. The attribute is called MAX-SIZE. When the size computed by the resizing algorithm would be greater than the MAX-SIZE, the calculated size is clipped to the MAX-SIZE.

view [
 hpanel [
  a: box red options [init-size: 50x20 min-size: 0x0]
  b: box green options [init-size: 100x20 min-size: 10x10  max-size: 150x150 ]
 ]
]

If we do not want to limit the object's ability to expand, we can set the MAX-SIZE of the object to GUIE/MAX-PAIR value, which is large enough to not limit the object's ability to expand.

[edit] Notes

The initial size is the size that is suggested as the size when the object is first displayed. Due to the dynamic nature of resizing, the actual dimensions of the object may differ.

For example, if the object is in a vpanel, and the column width of the vpanel is larger than the suggested initial size, the resizing algorithm automatically tries to magnify the object so that its width becomes as large as the column width if possible.

Another reason, why the object size might differ from its INIT-SIZE may be that the object dimensions are clipped to either its MIN-SIZE, or MAX-SIZE

There is not much sense (although it is not forbidden) to having the initial size equal to zero, since the object with zero initial size is invisible, and it cannot be enlarged to a nonzero size.

To specify that an object has a fixed size it suffices to specify that its minimal as well as maximal sizes are equal to its initial size.

[edit] Hints are used to specify the dimensions of layouts

To specify the way, how the dimensions of layouts, layout rows and columns are calculated, it is possible to use hints.

[edit] Box model is used to specify margins, etc.

Every graphic object has a content area and optional surrounding padding, border, and margin areas.

[edit] Object visibility can be specified

For every object in a layout it is possible to specify that the object is:

  • VISIBLE, meaning that the object is visible, and it normally resizes with the layout
  • HIDDEN, meaning that the object is invisible, and it normally resizes with the layout reserving the necessary empty space
  • FIXED, meaning that the objects is: visible, and it does not resize with the layout, i.e. it changes neither its size,nor its position, when the layout resizes
  • IGNORED, meaning that the objects is: invisible, and it does not take up any space in the layout

[edit] Hints

In a hpanel, vpanel, hgroup, or vgroup the initial, minimal, and maximal sizes are computed using the dimensions of the graphic elements the layout contains and the hints user has given.