Re: CAPI - scrolling pane question
It worked the way you described also on LW Professional OS X 5.1.2.
If you want that the instruction box does not expand, perhaps you
should put some minimum and maximum height constraints on instruction
box? I typically use visible box constraints for limiting the real
pane size, external box constraints just limit how much of the box is
embedded in the parent pane so they not necessarily limit the actual
pane size.
:visible-min-height '(character 30)
:visible-max-height t
I tested your code and adding these to the instruction box seem to
change the behavior.
Some other comments from a CAPI beginner
(1) Is setting parent of child to nil legal way to remove elements
from layouts? I thought the official way is remove the child from the
layout-description of the parent. I.e.
(setf (capi:layout-description parent) (remove child
(capi:layout-description parent)))
(2) Modifying the layout-description has side-effects, so I have
avoided using destructive operations such as appendf. Also, appendf
seems to expand to setq, which may also behave differently for complex
slot values than setf.
Hope this helps,
Mikko
On Sat, Apr 25, 2009 at 12:30 AM, Mike Watters <mike@mwatters.net> wrote:
> I'm trying out CAPI on LWF 5.1 (openmotif 2.2.3).
>
> When removing elements from a column-layout contained within a scrolling
> pane, the siblings of the column expand in height and the bottom of the
> scrolled content becomes unreachable (can't see actual bottom of content
> with slug at bottom position). Manually resizing the containing window
> fixes the issue. If the scrolled content is inside a switchable-layout,
> switching between layouts also fixes the issue.
>
> Attached is a demo with a couple of possible workarounds. What is the
> proper way to solve this issue? Or am I just doing it wrong by modifying
> column layouts in this manner?
>
> Thanks.
>
>
> Mike
>
>
> (in-package :cl-user)
>
> (eval-when (:compile-toplevel :load-toplevel :execute)
> (use-package '(:lw :capi)))
>
> (defun column (&rest things)
> (make-instance 'column-layout :description things))
>
> (defun row (&rest things)
> (make-instance 'row-layout :description things))
>
> (defun colored-box (color)
> (make-instance 'output-pane
> :background color
> :internal-min-height '(:character 10)))
>
> (defun button-doing (cb &rest args)
> (apply #'make-instance 'push-button
> :callback-type :item
> :selection-callback cb
> args))
>
> (defun make-delete-button (how)
> (button-doing (or how
> #'(lambda (button)
> (setf (element-parent
> (element-parent button)) nil)))
> :text "[DEL]"
> :foreground :red))
>
>
> (defun solution-1 (button)
> (symbol-macrolet ((parent (element-parent
> (element-parent button))))
> (let ((outer-parent (element-parent parent)))
> (setf parent nil)
> (capi::force-change-size
> (element-parent outer-parent) outer-parent))))
>
> (defun solution-2 (button)
> (let ((iface (top-level-interface button)))
> (setf (element-parent
> (element-parent button)) nil)
> (with-geometry iface
> (let ((h %height%))
> (set-top-level-interface-geometry
> iface
> :x %x% :y %y%
> :width %width%
> :height (1+ h))
> (set-top-level-interface-geometry
> iface
> :x %x% :y %y%
> :width %width%
> :height h)))))
>
>
> (defun make-add-button (text delete-fun)
> (button-doing #'(lambda (button)
> (appendf
> (layout-description
> (element-parent button))
> `(,(row (make-delete-button delete-fun)
> (colored-box :yellow)))))
> :text text))
>
> (defun make-instructions-pane (bt)
> (let ((p (make-instance 'collector-pane
> :external-min-width '(:character 48)
> :external-max-width '(:character 72))))
> (format (collector-pane-stream p)
> "Click ~S a few times & scroll to the bottom, noting ~
> visibility of blue box. Delete a couple, scroll ~
> down, and note lack of blue box visibility."
> bt)
> p))
>
> (defun conundrum (&optional solution)
> (let ((bottom-column
> (apply #'column "Thing 2"
> (mapcar #'colored-box '(:red :green :blue))))
> (button (make-add-button "Add box" solution))
> (ip (make-instructions-pane "Add box")))
> (make-instance 'simple-layout
> :title (if solution
> "Solution?"
> "Problem")
> :child
> (column (column "Thing 1"
> ip
> button)
> bottom-column)
> :vertical-scroll t)))
>
> (defun do-it ()
> (list
> (contain (conundrum))
> (contain (conundrum #'solution-1))
> (contain (conundrum #'solution-2))))
>
>
>
>
>