set-object-automatic-resize object &key x-align y-align x-offset y-offset x-ratio y-ratio width-ratio height-ratio aspect-ratio aspect-ratio-y-weight pinboard
A pinboard-object or a simple-pane.
nil
,
:left
,
:center
or
:right
.
nil
,
:top
,
:center
or
:bottom
.
A real number, default value 0.
A real number, default value 0.
A positive real number or
nil
.
A positive real number or
nil
.
A positive real number or
nil
.
A positive real number or
nil
.
A positive real number,
t
or
nil
.
A real number, default value 0.5.
A pinboard-layout, if supplied.
The function
set-object-automatic-resize
arranges for
object
to be resized and/or re-positioned automatically when
pinboard
is resized, or removes such a setting.
The value of
aspect-ratio
can be
t
, which means use the current aspect ratio of
object
(that is, its height divided by its width).
object
should be either a pinboard-object or a simple-pane which is (or will be) displayed in a pinboard-layout. This is,
object
will be added to the
description
of the pinboard layout by one of its
:description
initarg,
(setf capi:layout-description)
or manipulate-pinboard.
pinboard is the pinboard layout for object . If pinboard is already displayed with object in its description , the argument pinboard can be omitted.
When pinboard is resized, object is resized if either height-ratio or width-ratio are set.
The new width of object is calculated as follows:
The new height of object is calculated as follows:
If all of width-ratio , height-ratio and aspect-ratio are set, the new width and height of object are calculated as follows:
(/ (/
calculated-height
calculated-width
)
aspect-ratio
)
(
expt
aspect-ratio-ratio
aspect-ratio-y-weight
)
The result is that if aspect-ratio-y-weight is 0, correction is 1 and height-ratio is effectively ignored, while if aspect-ratio-y-weight is 1, correction cancels the effect of width-ratio . With the default value of 0.5, the resulting position is in the (geometric) middle, and object takes a fixed fraction of the area of the pinboard.
After resizing (if needed),
object
is also positioned horizontally if
x-align
is non-
nil
, and vertically if
y-align
is non-
nil
.
The new x coordinate of object is calculated as follows:
The new y coordinate of object is calculated similarly, using y-ratio and y-offset , with an adjustment such that the top, center or bottom of object aligns with the new coordinate according to y-align .
If all of
width-ratio
,
height-ratio
,
x-align
and
y-align
are
nil
, automatic resizing/re-positioning of
object
is removed.
set-object-automatic-resize
can be called before
object
is actually displayed, and its effect persists over calls adding and removing
object
to/from pinboard-layouts. If
object
is to be used in another pinboard layout,
set-object-automatic-resize
must be called to remove the automatic resizing from the first pinboard layout.
Put an object of fixed size at the top right corner:
(set-object-automatic-resize object
:x-ratio 1 :x-align :right)
Put an object in the bottom-right quadrant:
(set-object-automatic-resize
object
:x-ratio 0.5 :y-ratio 0.5
:width-ratio 0.5 :height-ratio 0.5)
Put an object with a fixed aspect ratio and object width linear with the width of the pinboard in the center:
(set-object-automatic-resize
object
:x-align :center :y-align :center
:x-ratio 0.5 :y-ratio 0.5
:aspect-ratio 0.6 :width-ratio 0.1)