Using Automatic Placement: Difference between revisions

From HLKitWiki
Jump to navigationJump to search
No edit summary
No edit summary
 
(9 intermediate revisions by one other user not shown)
Line 1: Line 1:
[[Category:Basic Concepts and Terminology]]
{{context|Basic Concepts and Terminology|Manipulation of Visual Elements}}
[Context: [[Home|HL Kit]] … [[Basic Concepts and Terminology]] … [[Manipulation of Visual Elements]]]


In an effort to make things as easy as possible, the Kit provides a mechanism called "automatic placement" that makes positioning certain visual elements significantly easier. Although primarily intended for use within sheets, automatic placement can also be used in various places with on-screen visual elements.
==Overview==


Automatic placement can only be used on visual elements within layouts, panels, and sheets. Every one of these element types manages internal logic to support automatic placement, so you can use the mechanism whenever it suits your needs. Automatic placement assumes that you are placing a progression of visual elements in a vertical arrangement, with each successive element appearing beneath the previous element.
In an effort to make things as easy as possible, the Kit provides a mechanism called "automatic placement" that makes positioning certain visual elements significantly easier. Although primarily intended for use within sheets, automatic placement can also be used in various places with on-screen visual elements. The [[Using Batch Placement|batch placement]] mechanism is typically a better choice for on-screen visual elements.


-Visual elements can utilize the "autoplace" target reference for quick and easy
Automatic placement can only be used on visual elements within layouts and scenes. Each of these element types manages internal logic to support automatic placement, so you can use the mechanism whenever it suits your needs. Automatic placement assumes that you are placing a progression of visual elements in a vertical arrangement, with each successive element appearing beneath the previous element. Consequently, the mechanism lends itself best to printed output, but it can also come in handy for on-screen positioning.
    placement of those elements
 
    -Syntax is "autoplace[gap]", where "gap" is the vertical gap between the new
==How It Works==
        element being placed and the bottom of the previous element that was
 
        automatically placed
All placement is performed within a rectangular region. Before anything is placed, the bounds of this region are initialized to be the full height and width of the visual container (i.e. the layout or scene). When placement begins, each new placement consumes vertical space within the region. This automatically shrinks the region, moving the top of the region downward to the bottom of each new visual element that is placed.
    -Additional target references provide an author with complete control over
 
        the bounds of the region within which automatic placement is performed
Automatic placement is performed via the "autoplace" target reference. Each placement can specify a gap that should appear between the new element and the one previously placed, which enables appropriate spacing between visual elements.
        -Set these characteristics before using "autoplace" if you need to first
 
            manually position certain elements
Additional target references provide the author with complete control over the bounds of the region within which automatic placement is performed. This makes it possible to place specific elements at the top and/or bottom of the visual container, then adjust the automatic placement region accordingly, and finally perform automatic placement of the remaining visual elements. You can also place elements automatically and then retrieve the bounds of the remaining unused space, after which you can manually place visual elements in that space.
        -Get these characteristics after using "autoplace" if you need to
 
            manually position elements in the space remaining, or if you need to
==The Rules==
            determine the extent of the elements that were placed
 
        -"autoleft", "autotop", "autoright", and "autobottom" provide read/write
In general, automatic placement is very easy to use and very intuitive in how it handles various situations. However, in the interest of clarity, the following specific rules govern how automatic placement behaves.
            access to the bounds of the region used for automatic placement
 
        -"autowidth" and "autoheight" provide read/write access to the dimensions
#When an element is automatically placed, the width of that element is set to the width of the automatic placement region for the visual container. In other words, each element is sized to take up the full width of the container.
            -They default to the full width of the visual container
#When a layout or template is automatically placed, that element is immediately rendered upon completion. This ensures that the sizing of that element is updated so that the top of the region can be accurately moved to the bottom of the element.
    -Before anything is placed, the bounds of the region are initialized to be
#When automatically placed, most visual elements have their height set to the full remaining height of the automatic placement region. The following caveats apply:
        the full height and width of the visual container (i.e. layout or scene)
##The lone exception to this rule is when a non-table portal is automatically placed within a layout (e.g. a label). In such cases, the height of the portal is assumed to be whatever default height is initialized.
    -When an element is automatically placed, the width of that element is set
##Since the height is set to the full region during automatic placement, it is assumed that every visual element being placed will properly truncate its height as part of its rendering. For example, a template placed within a layout or a layout placed within a sheet must properly set its height at the end of the Position script, basing the height on the extent of the bottommost item within the element.
        to the "autowidth" of the visual container
##Table portals automatically determine their extent, so automatic placement of tables works smoothly, without the need for any special handling.
    -After an element is automatically placed, the "top" edge of the region is
#When automatic placement attempts to place a visual element that will not fully fit in the remaining space, the region is considered to be fully utilized and no further elements will be placed.
        moved downward to the bottom of the placed visual element
#If a table is placed and it does not fully fit in the remaining space, as many items as will fit are output. If the table is within a sheet, all remaining items are treated as "spillover" for output in subsequent tables. If within a panel, the table is assumed to provide scrolling to view the excess items.
    -When a template is automatically placed, it is rendered upon completion
#Any visual element that is not displayed at all within the region is designated as non-visible. This means that any table that contains zero items is declared non-visible. Similarly, any templates and/or layouts that do not fully fit are deemed non-visible. {{important}}The key exception to this rule is dynamic and auto tables. Since these tables must allow the user to add items to them at all times, they are always shown even when they contain zero items.
    -When a layout is automatically placed, it is estimated upon completion
#Until at least one visual element with actual contents is successfully placed within the region, the gap is always considered to be zero. This ensures that the first item actually placed in the container always starts at the top, regardless of how many elements render no contents.
    -Until at least one visual element with actual contents is successfully
        placed within the container, the gap is always considered to be zero
        -This ensures that the first item actually placed in the container always
            starts at the top, regardless of how many elements render no contents
    -When automatically placed, most visual elements have their height set to the
        full remaining height of the automatic placement region
        -Lone exception is a non-table portal being placed within a layout, for
            which the height is assumed to be whatever is already set
        -Since heights are set the full region during automatic placement, it is
            assumed that visual elements will properly truncate their height as
            part of their rendering
        -For example, a template placed within a layout or a layout placed within
            a scene must properly set their height at the end of the Position
            script, based on the extent of the bottommost item within them
        -Table portals automatically determine their extent, so automatic
            placement of tables will work smoothly
    -When automatic placement attempt to place a visual element that will not
        fully fit in the remaining space, the region is considered to be fully
        utilized and no further elements can be placed
    -If a table is placed and it does not fully fit in the remaining space, as
        many items as will fit are output, with all remaining items being treated
        as "spillover" for rendering in subsequent tables
    -Any visual element that is not displayed at all is designated as non-visible
        -Tables that contain zero items are non-visible
        -Templates and layout that do not fully fit are non-visible

Latest revision as of 05:25, 20 December 2013

Context: HL Kit … Basic Concepts and Terminology … Manipulation of Visual Elements 

Overview

In an effort to make things as easy as possible, the Kit provides a mechanism called "automatic placement" that makes positioning certain visual elements significantly easier. Although primarily intended for use within sheets, automatic placement can also be used in various places with on-screen visual elements. The batch placement mechanism is typically a better choice for on-screen visual elements.

Automatic placement can only be used on visual elements within layouts and scenes. Each of these element types manages internal logic to support automatic placement, so you can use the mechanism whenever it suits your needs. Automatic placement assumes that you are placing a progression of visual elements in a vertical arrangement, with each successive element appearing beneath the previous element. Consequently, the mechanism lends itself best to printed output, but it can also come in handy for on-screen positioning.

How It Works

All placement is performed within a rectangular region. Before anything is placed, the bounds of this region are initialized to be the full height and width of the visual container (i.e. the layout or scene). When placement begins, each new placement consumes vertical space within the region. This automatically shrinks the region, moving the top of the region downward to the bottom of each new visual element that is placed.

Automatic placement is performed via the "autoplace" target reference. Each placement can specify a gap that should appear between the new element and the one previously placed, which enables appropriate spacing between visual elements.

Additional target references provide the author with complete control over the bounds of the region within which automatic placement is performed. This makes it possible to place specific elements at the top and/or bottom of the visual container, then adjust the automatic placement region accordingly, and finally perform automatic placement of the remaining visual elements. You can also place elements automatically and then retrieve the bounds of the remaining unused space, after which you can manually place visual elements in that space.

The Rules

In general, automatic placement is very easy to use and very intuitive in how it handles various situations. However, in the interest of clarity, the following specific rules govern how automatic placement behaves.

  1. When an element is automatically placed, the width of that element is set to the width of the automatic placement region for the visual container. In other words, each element is sized to take up the full width of the container.
  2. When a layout or template is automatically placed, that element is immediately rendered upon completion. This ensures that the sizing of that element is updated so that the top of the region can be accurately moved to the bottom of the element.
  3. When automatically placed, most visual elements have their height set to the full remaining height of the automatic placement region. The following caveats apply:
    1. The lone exception to this rule is when a non-table portal is automatically placed within a layout (e.g. a label). In such cases, the height of the portal is assumed to be whatever default height is initialized.
    2. Since the height is set to the full region during automatic placement, it is assumed that every visual element being placed will properly truncate its height as part of its rendering. For example, a template placed within a layout or a layout placed within a sheet must properly set its height at the end of the Position script, basing the height on the extent of the bottommost item within the element.
    3. Table portals automatically determine their extent, so automatic placement of tables works smoothly, without the need for any special handling.
  4. When automatic placement attempts to place a visual element that will not fully fit in the remaining space, the region is considered to be fully utilized and no further elements will be placed.
  5. If a table is placed and it does not fully fit in the remaining space, as many items as will fit are output. If the table is within a sheet, all remaining items are treated as "spillover" for output in subsequent tables. If within a panel, the table is assumed to provide scrolling to view the excess items.
  6. Any visual element that is not displayed at all within the region is designated as non-visible. This means that any table that contains zero items is declared non-visible. Similarly, any templates and/or layouts that do not fully fit are deemed non-visible. IMPORTANT! The key exception to this rule is dynamic and auto tables. Since these tables must allow the user to add items to them at all times, they are always shown even when they contain zero items.
  7. Until at least one visual element with actual contents is successfully placed within the region, the gap is always considered to be zero. This ensures that the first item actually placed in the container always starts at the top, regardless of how many elements render no contents.