Auto-Fit Panels: Difference between revisions

From Planimate Knowledge Base
Jump to navigation Jump to search
(New page: Planimate 5.22 supports a number of mechanisms which enable panels in a model to resize and rearrange their content to fit the window they are in. This is an overview of the mechanisms inv...)
 
No edit summary
 
Line 1: Line 1:
Planimate 5.22 supports a number of mechanisms which enable panels in a model to resize and rearrange their content to fit the window they are in. This is an overview of the mechanisms involved.
Planimate 5.22 supports a number of mechanisms which used in concert enable panels in a model to resize and rearrange their content to fit the window they are in. This is an overview of the mechanisms involved.  


__TOC__
__TOC__  


===Panel Option: "Auto Fit Panel To Window"===
=== Panel Option: "Auto Fit Panel To Window" ===


This option has been added to the "Engine" panel option section.
This option has been added to the "Engine" panel option section.  


When this option is selected PL will automatically resize the work area of the panel to fit the window space available. The update will occur as the panel is resized and when the panel is shown.
When this option is selected PL will automatically resize the work area of the panel to fit the window space available. The update will occur as the panel is resized and when the panel is shown.The update occurs whether the engine is running or not, to facilitate editing layouts.<br>


This option complements the "Fit Panel To Used Area" menu bar option; instead of the window being resized to fit the content, the work area (and content) is resized to fit the window.
This option complements the "Fit Panel To Used Area" menu bar option; instead of the window being resized to fit the content, the work area (and content) is resized to fit the window.  


This option has not been tested with popup windows. The Auto-Fit Panel capability is intended for the main window only at this stage.
This option has not been tested with popup windows. The Auto-Fit Panel capability is intended for the main window only at this stage.  


===Anchor Option===
=== Anchor Option ===


Paint Objects, Views and ViewPorts have a new "Anchor" option. This enables Planimate to automatically manage the object's position when its panel's work area is resized. By default all objects are anchored to the top-left of the panel work area, so as the panel grows or shrinks, they stay in the same position relative to the top left.
Paint Objects, Views and ViewPorts have a new "Anchor" option. This enables Planimate to automatically manage the object's position when its panel's work area is resized. By default all objects are anchored to the top-left of the panel work area. As the panel grows or shrinks, they stay in the same position relative to the top left.  


The "Anchor To Panel Right" causes the object to be anchored to the right side of the panel window instead of the left. As the window resizes, it keeps its same relative distance to the right side.
The "Anchor To Panel Right" option causes the object to be anchored to the right side of the panel window instead of the left. As the window resizes, it keeps its same relative distance to the right side.  


Likewise the "Anchor To Panel Bottom" option causes the object to be anchored to the bottom of the panel window.
Likewise the "Anchor To Panel Bottom" option causes the object to be anchored to the bottom of the panel window.  


Hence an object can be anchored to all combinations of left/right and top/bottom.
Hence an object can be anchored to all combinations of left/right and top/bottom.  


===Panel Work Area Dialog Enhancement===
Note that anchored objects retain their size. Dynamically sized objects require a small amount of model code. This approach enables arbitrarily complex layouts to be implemented as required.


The Panel Work Area dialog is used to resize the work area of a panel. It is also useful for inspecting the current work area for a panel which is auto-fitting its window.
=== Panel Work Area Dialog Enhancement ===


The dialog contains two new fields which enable the minimum work area to be specified. When the panel window is resized beyond this limit, the panel stops shrinking and scrollbars appear instead, just as if the panel was of fixed size.
The Panel Work Area dialog is normally used to resize the work area of a panel. It is also useful for inspecting the current work area for a panel which is auto-fitting its window.  


This is useful in ensuring a minimum area is available for a layout to remain sensible.
The dialog contains two new fields which enable the minimum work area size to be specified. When the panel window is shrunk beyond this limit, the panel stops shrinking and scrollbars appear instead, just as if the panel was of fixed size.  


A useful technique to determining the minimum values is to layout your objects, set their anchors then turn on the Auto Fit panel option. Then shrink the window to the minimum that makes sense. Open the Panel Work Area dialog and copy the current X and Y widths to the Minimum. Now the panel area will not shrink below the current size even if the window is made smaller.
This is useful in ensuring a minimum area is available for a layout to remain sensible.  


===_Panel Resized Broadcast===
A useful technique to determine the minimum values is to layout the objects, set their anchors then turn on the Auto Fit Panel To Window panel option. Then shrink the window to the minimum that makes sense. Open the Panel Work Area dialog and copy the current X and Y widths to the Minimum values. Now the panel area will not shrink below the current size even if the window is made smaller.  
This new broadcast is sent to the panel as it is resized. It includes the panel's _width and _height. It is useful for Auto-Fit panels as it gives the modeller opportunity to update the widths/heights of dynamically sized objects - ie: objects which can grow in size to fit the available panel realestate, for example maps show using Paint objects.


To ensure that dynamic objects are correctly sized in all circumstances, the modeller should intercept _run start and _panel opened broadcasts and update the sizes of dynamically sized objects.
=== _Panel Resized Broadcast ===


===Calculating Dynamic Object Sizes===
This new broadcast is sent to the panel as it is resized. It can be picked up by a portal therein set to handle its parent's broadcasts. It includes the panel's _width and _height. It is useful for Auto-Fit panels as it gives the modeller opportunity to update the widths/heights of dynamically sized objects - ie: objects which can grow/shrink in size to fit the available panel realestate, for example maps shown using Paint objects.  
For a single dynamically sized object, the formula for its size is fairly simple. For width:


Object Width = Panel Width -
To ensure that dynamic objects are correctly sized in all circumstances, the modeller should intercept _run start and _panel opened broadcasts and update the sizes of dynamically sized objects.
                Left Object Coordinate -
                RHS Minimum Margin


Object Height = Panel Height -
=== Calculating Dynamically Sized Object Dimensions<br> ===
                Top Object Coordinate -
                Bottom Minimum Margin


If multiple objects are involved, then the formulae for each object will need to consider the percentage of total "available space" that you want to apportion to that object vs. the other objects.
For a single dynamically sized object, the formula for its size is fairly simple. For width:


The size of a paint object can be set as a property. The _Panel Resized broadcast handler should not force a repaint, whereas the _Model Loaded broadcast handler needs to since setting paint object properties does not automatically redraw them.
Object Width = Panel Width -
Left Object Coordinate -
RHS Minimum Margin


[[Category:Interaction (User)]]
Object Height = Panel Height -
[[Category:Graphics]]
Top Object Coordinate -
[[Category:Presentation]]
Bottom Minimum Margin
[[Category:Paint]]
 
[[Category:Panel]]
If multiple objects are involved, then the formulae for each object will need to consider the percentage of total "available space" that you want to apportion to that object vs. the other objects.
[[Category:Broadcast]]
 
The size of a paint object can be set as a property. The _Panel Resized broadcast handler should not force a repaint, whereas the _Model Loaded broadcast handler needs to since setting paint object properties does not automatically redraw them.
 
=== Anchors And Simulation Objects ===
 
Anchoring of simulation objects (eg: portals) is not supported as it is anticipated any model using this advanced technique will also be positioning its portals dynamically already.
Typically these objects will sit on a background "map" paint button object. Once this paint object is updated (as described above) its screen co-ordinates can then be used as the basis to position the network nodes over it.
 
[[Category:Interaction_(User)]] [[Category:Graphics]] [[Category:Presentation]] [[Category:Paint]] [[Category:Panel]] [[Category:Broadcast]]

Latest revision as of 03:09, 2 March 2009

Planimate 5.22 supports a number of mechanisms which used in concert enable panels in a model to resize and rearrange their content to fit the window they are in. This is an overview of the mechanisms involved.

Panel Option: "Auto Fit Panel To Window"

This option has been added to the "Engine" panel option section.

When this option is selected PL will automatically resize the work area of the panel to fit the window space available. The update will occur as the panel is resized and when the panel is shown.The update occurs whether the engine is running or not, to facilitate editing layouts.

This option complements the "Fit Panel To Used Area" menu bar option; instead of the window being resized to fit the content, the work area (and content) is resized to fit the window.

This option has not been tested with popup windows. The Auto-Fit Panel capability is intended for the main window only at this stage.

Anchor Option

Paint Objects, Views and ViewPorts have a new "Anchor" option. This enables Planimate to automatically manage the object's position when its panel's work area is resized. By default all objects are anchored to the top-left of the panel work area. As the panel grows or shrinks, they stay in the same position relative to the top left.

The "Anchor To Panel Right" option causes the object to be anchored to the right side of the panel window instead of the left. As the window resizes, it keeps its same relative distance to the right side.

Likewise the "Anchor To Panel Bottom" option causes the object to be anchored to the bottom of the panel window.

Hence an object can be anchored to all combinations of left/right and top/bottom.

Note that anchored objects retain their size. Dynamically sized objects require a small amount of model code. This approach enables arbitrarily complex layouts to be implemented as required.

Panel Work Area Dialog Enhancement

The Panel Work Area dialog is normally used to resize the work area of a panel. It is also useful for inspecting the current work area for a panel which is auto-fitting its window.

The dialog contains two new fields which enable the minimum work area size to be specified. When the panel window is shrunk beyond this limit, the panel stops shrinking and scrollbars appear instead, just as if the panel was of fixed size.

This is useful in ensuring a minimum area is available for a layout to remain sensible.

A useful technique to determine the minimum values is to layout the objects, set their anchors then turn on the Auto Fit Panel To Window panel option. Then shrink the window to the minimum that makes sense. Open the Panel Work Area dialog and copy the current X and Y widths to the Minimum values. Now the panel area will not shrink below the current size even if the window is made smaller.

_Panel Resized Broadcast

This new broadcast is sent to the panel as it is resized. It can be picked up by a portal therein set to handle its parent's broadcasts. It includes the panel's _width and _height. It is useful for Auto-Fit panels as it gives the modeller opportunity to update the widths/heights of dynamically sized objects - ie: objects which can grow/shrink in size to fit the available panel realestate, for example maps shown using Paint objects.

To ensure that dynamic objects are correctly sized in all circumstances, the modeller should intercept _run start and _panel opened broadcasts and update the sizes of dynamically sized objects.

Calculating Dynamically Sized Object Dimensions

For a single dynamically sized object, the formula for its size is fairly simple. For width:

Object Width = Panel Width -
Left Object Coordinate -
RHS Minimum Margin
Object Height = Panel Height -
Top Object Coordinate -
Bottom Minimum Margin

If multiple objects are involved, then the formulae for each object will need to consider the percentage of total "available space" that you want to apportion to that object vs. the other objects.

The size of a paint object can be set as a property. The _Panel Resized broadcast handler should not force a repaint, whereas the _Model Loaded broadcast handler needs to since setting paint object properties does not automatically redraw them.

Anchors And Simulation Objects

Anchoring of simulation objects (eg: portals) is not supported as it is anticipated any model using this advanced technique will also be positioning its portals dynamically already. Typically these objects will sit on a background "map" paint button object. Once this paint object is updated (as described above) its screen co-ordinates can then be used as the basis to position the network nodes over it.