pharo-spec / Spec

Spec is a framework in Pharo for describing user interfaces.
MIT License
61 stars 63 forks source link

Changing window extent seems broken in P12 and P13 #1592

Open ClotildeToullec opened 1 month ago

ClotildeToullec commented 1 month ago

To reproduce:

presenter := SpPresenter new.
presenter layout: (SpBoxLayout newVertical).
presenter open.
presenter window extent. "This returns nil".
presenter window window extent. "This returns 400.0@300.0"

presenter withWindowDo: [ :window | window extent: 100 @ 100 ]. "This does nothing"
presenter withWindowDo: [ :window | window window extent: 100 @ 100 ]. "This works"
Ducasse commented 1 month ago

@estebanlm can you have a look because this can impact the book? @koendehondt

estebanlm commented 1 month ago

I will, give me a couple of days, I am still in "back from holidays" mode :) there are some misconceptions there and at least one issue may be a bug... but I need to look at it :)

estebanlm commented 1 month ago

So, some answers.

  1. You should never use window window, this is the backend window and you should not be going against demeters law or you will lose portability and you may cause sync problems between spec and the backend (nnot saying this will be the case here, but it could happen).
  2. extent and extent: are in the TOREMOVE protocol on SpPresenter, so... you should not use it ;)
  3. The correct protocols are:
    • initialExtent: to declare the original size of the window before it is opened.
    • resize: to change the size after it is opened.

What I do believe is a bug (or a missing feature) is that there is no vocabulary to query current window size, I will add it :)

estebanlm commented 1 month ago

done (not integrated into P13 yet).

ClotildeToullec commented 1 month ago

Ah, thanks. We tried window window while debugging; of course we don't keep that. The use of #extent:is legacy, thank you for pointing #resize:, I will make the change in Moose.

koendehondt commented 1 month ago

@Ducasse

@estebanlm can you have a look because this can impact the book? @koendehondt

In the book, in chapter "9 Managing windows", there is a section "9.5 Window size and decoration" with a subsection "Setting initial size and changing size" that describes what @estebanlm wrote about the correct protocols.