Lisp HUG Maillist Archive

capi::update-automatic-resize-object


What would be a correct place to specify a call to
`capi:set-object-automatic-resize'?  Placing it in a `:create-callback'
like this causes problems when trying to put up a representation later:

(capi:define-interface test ()
  ()
  (:panes
   (ellipse capi:ellipse))
  (:layouts
   (pinboard capi:pinboard-layout '(ellipse)))
  (:default-initargs
   :create-callback (lambda (self)
                      (with-slots (ellipse pinboard) self
                        (capi:set-object-automatic-resize
                         ellipse :height-ratio 1 :width-ratio 1
                         :pinboard pinboard)))
   :visible-min-height 300 
   :visible-min-width 300))

(capi:display (make-instance 'capi:interface
		:layout (make-instance 'capi:simple-layout
			  :description (list (make-instance test)))))


Would I be justified in expecting the above to work?
--  
Madhu


RE: capi::update-automatic-resize-object

I have used set-object-automatic-resize a few times and each time I ended up placing it in an interface-display :after method specialized on my interface. That way you're guaranteed to be working with a displayed pane (a create-callback will run before the pane is actually displayed).

I think it would be nice to have some better examples for the use of this function..

Chris

> To: lisp-hug@lispworks.com
> From: enometh@meer.net
> Subject: capi::update-automatic-resize-object
> Date: Tue, 23 Nov 2010 20:59:36 +0530
>
>
>
> What would be a correct place to specify a call to
> `capi:set-object-automatic-resize'? Placing it in a `:create-callback'
> like this causes problems when trying to put up a representation later:
>
> (capi:define-interface test ()
> ()
> (:panes
> (ellipse capi:ellipse))
> (:layouts
> (pinboard capi:pinboard-layout '(ellipse)))
> (:default-initargs
> :create-callback (lambda (self)
> (with-slots (ellipse pinboard) self
> (capi:set-object-automatic-resize
> ellipse :height-ratio 1 :width-ratio 1
> :pinboard pinboard)))
> :visible-min-height 300
> :visible-min-width 300))
>
> (capi:display (make-instance 'capi:interface
> :layout (make-instance 'capi:simple-layout
> :description (list (make-instance test)))))
>
>
> Would I be justified in expecting the above to work?
> --
> Madhu
>

Re: capi::update-automatic-resize-object


* Christopher Melen <SNT136-w34E69E3562CADC26252813813E0@phx.gbl> :
Wrote on Tue, 23 Nov 2010 20:45:38 +0000:

| I have used set-object-automatic-resize a few times and each time I
| ended up placing it in an interface-display :after method specialized
| on my interface.  That way you're guaranteed to be working with a
| displayed pane (a create-callback will run before the pane is actually
| displayed).
|
| I think it would be nice to have some better examples for the use of
| this function.
|

Thanks.  I wanted to note that there is an issue with putting it in an
INTERFACE-DISPLAY :AFTER method---it interacts badly with
capi:calculate-constraints.  Consider a use of calculate-constraints
like this in `my-ellipse', where, say, i want to calculate just the
height and later have it adapt to its parent's width:

(defclass my-ellipse (capi:ellipse)
  ()
  (:default-initargs
   :visible-min-height :no-hint))

(defmethod capi:calculate-constraints ((self my-ellipse))
  (let ((height 65))
    (capi:with-geometry self
      (setf capi:%min-height% height capi:%max-height% t))))

(capi:define-interface test2 ()
  ()
  (:panes
   (ellipse my-ellipse))
  (:layouts
   (pinboard capi:pinboard-layout '(ellipse)))
  (:default-initargs
   :visible-min-height 300 
   :visible-min-width 300))

(defmethod capi:interface-display :after ((self test2))
  (with-slots (ellipse pinboard) self
    (capi:set-object-automatic-resize ellipse
     :width-ratio 1
     :pinboard pinboard)))

(capi:contain (make-instance 'test2))  ;; <-- expected behaviour

;; unexpected behaviour:
(capi:display (make-instance 'capi:interface
		:layout (make-instance 'capi:simple-layout
			  :description (list (make-instance 'test2)))))


[Placing the call to SET-OBJECT-AUTOMATIC-RESIZE in the create callback
seems to be the way to go, if I could just ignore the error that is
signalled]

--
Regards
Madhu


Re: capi::update-automatic-resize-object

Unable to parse email body. Email id is 10768

Updated at: 2020-12-10 08:38 UTC