Hey,
the thing is that with-output-as-gadget is specified to return the gadget and not the output record containing it - that's really not useful, but that's what it is. That is the reason why you had to also manually specify the offset x0 y0 when drawing and add the bounding rectangle size.
I don't know how this should be handled in LW CLIM, but McCLIM returns two values and the second value is the created output record. In other words, this will give you the desired result disregarding whether the display is incremental or not:
(defun v-pane-df (frame pane)
(declare (ignore frame))
(multiple-value-bind (gadget gadget-output-record)
(with-output-as-gadget (pane :x 20 :y 20)
(declare (ignore pane))
(make-pane 'label-pane :label "A Label"
:background +green+))
(declare (ignore gadget))
(with-bounding-rectangle* (x1 y1 x2 y2) gadget-output-record
(draw-rectangle* pane x1 y1 x2 y2
:ink +red+ :filled nil :line-thickness 1))))
Best regards,
Daniel
--
Daniel Kochmański ;; aka jackdaniel | Przemyśl, Poland
TurtleWare - Daniel Kochmański | www.turtleware.eu
"Be the change that you wish to see in the world." - Mahatma Gandhi
------- Original Message -------
On Saturday, November 12th, 2022 at 16:03, Paul Werkowski <pw(a)snoopy.qozzy.com> wrote:
> Hi Daniel,
>
> I wonder if you could tell me what is happening. Not a bug, I think,
> because Lispworks CLIM does the same thing.
>
> If you still have that example I sent, change :incremental-redisplay to
> T and run the program.
> Note the blue border is does not surround the label but is size 100x100
> which is a default size somewhere.
>
> If I stuff the value of g into a global symbol (setq g g) and take the
> bounding rectangle size I get the correct value. I'm wondering if the
> problem is somehow related to dynamic-extent. Is there a correct way to
> use the gadget dimensions that works both settings of
> :incremental-redisplay?
>
> Thanks for any information you can share.
>
> Paul
Hey Paul,
sorry for taking so much time to respond. I'm answering your emails in batch.
> [two down one to go]
The issue was that (draw-rectangle* t 0 0 10 10 :filled nil) has the extent
[-.5 -.5 10.5 10.5], I've explained that the line thickness when filled is nil
is normally 1 (or 2 depending on the backend), so it extends beyond the
rectangle dimensions in question.
You've concured that LispWorks makes the bounding rectangle [0 0 11 11]
(proving that they take into account the line thickness), but I wonder why
they are doing that? If we draw a rectangle with line thickness 4 then the
bounding rectangle is [0 0 14 14] and not [-2 -2 12 12]? Does it mean that
drawing a border around the object may produce a result where the object is
not in the center, because it is "too close to the edge"?
Or does it mean that /after all drawing/ they move all output so it fits
inside the sheet region defined (by them) as [0 0 width height]? McCLIM allows
defining sheets with a region that is not aligned with 0X and 0Y, so perhaps
it is their limitation of the implementation?
> [follow up to previous convo]
>
> Please give the attached code a try. (clim-user::tryit)
> Keep left clicking in the pane. Expected behavior?
>From the file in question I think that you've mixed some other program after
the initial output (starting from the function ~test-draw-line~).
Either way the behavior I'm observing is expected. You take the sheet
dimensions to draw on a sheet and then the sheet dimensions are computed based
on the output (bar the fact that we seem to come beyond specified max-width -
this is most likely a bug).
> [with-radio-box]
Thank you for the kind words. CAPI backend sounds nice. I'm working on SDL2
backend on the other hand (in parallel with other things, i.e today I've
finished an initial port of ECL to emscripten, so it is possible to run CL in
the web browser (see turtleware.eu/static/ecl/ecl.html, open the js console).
Thanks for the code - it had an issue that "selected" toggle boxes did not
have a desired background. I've implemented this feature by hooking the
background directly in the local function MAKE-PANE (while still respecting
the background if the programmer explicitly supplied one). See the recent
commit if you are curious, here is the code for a simple test:
```
(define-application-frame with-boxes ()
()
(:panes (app :application)
(rad (with-radio-box (:background +light-blue+ :type :some-of)
"Daniel" "Ma"
(radio-box-current-selection "Kota")
(radio-box-current-selection "bata")
(make-pane :toggle-button :label "make-pane 1")
(radio-box-current-selection
(make-pane :toggle-button :label "make-pane 2"))
(make-pane :toggle-button :label "make-pane 1"
:background +light-pink+)
(radio-box-current-selection
(make-pane :toggle-button :label "make-pane 2"
:background +light-pink+))))))
(find-application-frame 'with-boxes)
```
> [mcclim: redisplay-frame-panes where application-pane contains a gadget
> fails]
Thanks for the report. Notice that if we define a redisplay command, then the
problem does not happen (when the command is activated) - that means that the
issue is caused by the fact that we try to redisplay the frame asynchronously
```
(define-v-frame-command (com-redisplay :menu t) ()
(with-application-frame (frame)
(redisplay-frame-panes frame)))
```
and indeed the issue is caused by the fact that the pane realizer is not
bound. REDISPLAY-FRAME-PANES works fine if we bind it:
```
(let ((fm (frame-manager *frame*)))
(with-look-and-feel-realization (fm *frame*)
(redisplay-frame-panes *frame*)))
```
That said asynchronous access is not safe unless you either call
EXECUTE-FRAME-COMMAND (safe!) and/or dispatch an event and handle it (safe and
low level). I hope that this is a satisfying answer.
Best regards,
Daniel
--
Daniel Kochmański ;; aka jackdaniel | Przemyśl, Poland
TurtleWare - Daniel Kochmański | www.turtleware.eu
"Be the change that you wish to see in the world." - Mahatma Gandhi
------- Original Message -------
On Thursday, November 10th, 2022 at 19:38, Paul Werkowski <pw(a)snoopy.qozzy.com> wrote:
> LispWorks 8.0.1 Windows:
> McCLIM current source:
> Example attached
>
> Paul
>
> CLIM-USER 5 > (redisplay-frame-panes frame)
>
>
> Error: No applicable methods for #<STANDARD-GENERIC-FUNCTION MAKE-PANE-1
> 4160C3ACB4> with args (NIL #<CLIM-INTERNALS::DEFAULT-APPLICATION
>
> 405047874B> LABEL-PANE :LABEL "A Label" :BACKGROUND
>
> #<CLIM-INTERNALS::NAMED-COLOR "green">)
>
> 1 (continue) Call #<STANDARD-GENERIC-FUNCTION MAKE-PANE-1 4160C3ACB4>
>
> again
> 2 Clear the output history of the pane and reattempt forceful redisplay.
> 3 Clear the output history of the pane, but don't redisplay.
> 4 Skip this redisplay.
> 5 (abort) Return to top loop level 0.
>
> Type :b for backtrace or :c <option number> to proceed.
>
> Type :bug-form "<subject>" for a bug report template or :? for other
>
> options.
>
> CLIM-USER 6 : 1 >