[Cuis-dev] PluggableScrollPane scroller width

Mariano Montone marianomontone at gmail.com
Sat Aug 17 20:26:28 PDT 2024


It looks nice! And my opinion is that it is fine to overwrite certain
behaviors in Morph classes because Morphic doesnt cover all layout cases.
Havent looked closely at your implementation, though.

El sáb, 17 de ago de 2024, 21:26, Mark Volkmann <r.mark.volkmann at gmail.com>
escribió:

> The feedback from Ken and Mariano helped a lot!
>
> I did not know that LayoutSpecs are ignored if they are on a Morph that is
> not owned by a LayoutMorph, so that was great to learn.
>
> I came up with a solution. Does this seem acceptable?
> I created a subclass of PluggableScrollPane that holds an onExtentChanged block
> instance variable
> and I overrode the extentChanged: method like this:
>
> extentChanged: oldExtent
>     super extentChanged: oldExtent.
>     onExtentChanged ifNotNil: [ onExtentChanged value: self morphExtent ].
>
> This allows me to listen for changes to the extent of my
> PluggableScrollPane subclass where I can do this:
>
> psp onExtentChanged: [ :newExtent |
>     todosPane morphExtent: (psp hScrollBarWidth - 10) @ todosPane
> morphExtent y.
> ].
>
> todosPane is the "scroller" set on the PluggableScrollPane.
> Not sure why I need the minus 10, but without that a horizontal scrollbar
> appears.
> This works perfectly! Now the contents of the PluggableScrollPane resizes
> when its size changes.
>
> The attached screenshot shows the current state of my Todo app.
> This has been a great learning exercise.
>
> On Sat, Aug 17, 2024 at 6:00 PM Mariano Montone via Cuis-dev <
> cuis-dev at lists.cuis.st> wrote:
>
>> Adjust the width of the scroller morph:
>>
>> psp scroller morphWidth: 180.
>>
>> Note that that width will not adjust dynamically (as you change the morph
>> extent of the whole morph).
>>
>>
>> El 17/8/24 a las 16:11, Mark Volkmann via Cuis-dev escribió:
>>
>> Added example code at bottom of this email ...
>>
>> On Fri, Aug 16, 2024 at 1:16 PM Mark Volkmann <r.mark.volkmann at gmail.com>
>> wrote:
>>
>>> I have the following Morph containment hierarchy:
>>>
>>> - PluggableScrollPane
>>>   - LayoutMorph newColumn
>>>     - a bunch of LayoutMorph newRow
>>>
>>> All of these have their layoutSpec proportionalWidth set to 1.
>>> When I run my app, the PluggableScrollPane width is stretched to match
>>> the width of its parent.
>>> But the other morph widths are not stretched to match that width.
>>> Is there something extra I need to send to my PlugglableScrollPane to
>>> tell it that the width of the assigned "scroller" (my LayoutMorph
>>> newColumn) should have its width stretched?
>>>
>>
>> To demonstrate the issue, I created the class ProportionalWidthIssue. A
>> screenshot of the result and a fileOut are attached.
>> The question is why the width of column doesn't expand to fill the
>> PluggableScrollPane.
>>
>> This class is a subclass of Object and only has the following instance
>> methods.
>>
>> initialize
>>     | column psp |
>>
>>     column := LayoutMorph newColumn.
>>     column layoutSpec proportionalWidth: 1.
>>     column addMorph: (self makeRow: #('One' 'Two')).
>>     column addMorph: (self makeRow: #('Three' 'Four')).
>>     column addMorph: (self makeRow: #('Five' 'Six')).
>>     column addMorph: (self makeRow: #('Seven' 'Eight')).
>>     column addMorph: (self makeRow: #('Nine' 'Ten')).
>>
>>     psp := PluggableScrollPane new.
>>     psp morphExtent: 200 @ 70.
>>     psp scroller: column.
>>     psp openInHand.
>>
>> makeRow: anArray
>>     | row |
>>     row := LayoutMorph newRow color: Color white.
>>     row layoutSpec proportionalWidth: 1.
>>     anArray withIndexDo: [ :element :index |
>>         | label |
>>         label := LabelMorph contents: element.
>>         index = 1 ifTrue: [ label layoutSpec proportionalWidth: 1 ].
>>         row addMorph: label.
>>     ].
>>     ^ row
>>
>> A fileOut is attached. To see the issue, enter
>> ProportionalWidthIssue new
>> in a Workspace and "Do It".
>>
>> --
>> R. Mark Volkmann
>> Object Computing, Inc.
>>
>> --
>> Cuis-dev mailing list
>> Cuis-dev at lists.cuis.st
>> https://lists.cuis.st/mailman/listinfo/cuis-dev
>>
>
>
> --
> R. Mark Volkmann
> Object Computing, Inc.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20240818/106359dc/attachment-0001.htm>


More information about the Cuis-dev mailing list