[Cuis] Newbie question

Hari Balaraman hbalaraman at gmail.com
Mon May 11 23:24:06 CDT 2015


Hi Juan et al,

I’ve been pondering on how to position and size morphs (based on Juan's comment below about automatic layout in an earlier exchange) without having an intermediate layer of layoutMorphs. 

Attached is a fileout of a test class with a class method “example 1” showing a rectangle that varies its size based on its owner (I’m also writing the method to reset the location of a morph if it wishes to be remain in the same location relative to the midpoints of two sides of the enclosing morph.)

This way a morph can be positioned and at any time sent a message to relocate or resize itself based on its then owner. That way there are only two actors, the morph and its owner, and a morph knows (based on two messages, whether it should maintain its relative place and size within its owner. Although I have got a bit of the hang of layoutMorphs, I’m exploring whether positioning and repositioning a lot of elements in my UI may be easier with this approach.

I was wondering what you think of this approach.

Regards,

Hari


> On Mar 31, 2015, at 9:30 AM, Juan Vuletich <juan at jvuletich.org> wrote:
> 
> Hi Hari,
> 
> (inline)
> 
> …..
>> 
>> 1.I’ve spent a some time reviewing the LayoutMorph class examples and have had a certain amount of difficulty in using them. I am using squeak documentation whenever I am stuck in my efforts, so if layouts are a marked departure from Squeak,I would like to request more documentation (in class comments, faq wherever) on when/how layouts are instantiated by objects and are used.
> 
> Have you read the class comments at LayoutSpec and LayoutMorph? In addition, LayoutMorph has an 'examples' class category. Try each one. Resize the top morph, and see layouts in action. inspect / explore the morphs, etc. Try to figure out what's happening. WRT when they are instantiated, check references to these classes. They are all there.
> 
> If something is not clear enough, please ask any questions. They will be useful to enhance this documentation.
> 
>> 
>> 2. One of the things I like about Cuis is the relative positioning of morphs within containers. This has allowed me to build my (very simple) UI without considering layouts.
> 
> Yep. That's the purpose of that. If you don't need automatic layout (maybe because your UI elements are all of fixed size), then just put them wherever you want them :)
> 
>> 3. Not having an intermediary layout layer has allowed me to easily make calls to and from embedded objects within the containers in my system (I considered a decoupled model and spent some time on a version of the announcements framework which I imported from Squeak, but, scattered documentation and various versions later, I have abandoned that approach.) SystemWindow creates a LayoutMorph by default. Looking up the hierarchy, I haven’t as yet, located where the LayoutMorph instantiation behaviour occurs.
> 
> Browse LayoutMorph. Right click on it. Select 'class refs (N)'. See that there are two references from LayoutMorph from SystemWindow. Check senders of those methods. Isn't everything obvious?
> 
>> I would dearly love to get around LayoutMorphs by toggling a switch or preference, and play puppeteer in a more direct fashion (I know, I know, you are shaking your head in despair.)
>> 
> 
> :) I welcome you and everybody else to play and experiment. That's the realization of the "Personal Mastery" principle from Dan Ingalls ("Design Principles behind Smalltalk"), and the whole purpose of Cuis. A Dynabook for me and for everybody.
> 
> Cheers,
> Juan Vuletich
> 
>> Best regards,
>> 
>> Hari
>> 
>> 
>>> On Mar 30, 2015, at 8:51 AM, Juan Vuletich <juan at jvuletich.org <mailto:juan at jvuletich.org>> wrote:
>>> 
>>> Hi Folks,
>>> 
>>> On 3/28/2015 11:26 PM, Ken.Dickey wrote:
>>>> On Sat, 28 Mar 2015 18:47:04 -0400
>>>> "Phil (list)"<pbpublist at gmail.com <mailto:pbpublist at gmail.com>>  wrote:
>>>> 
>>>>>> I’ve been looking up Squeak/Pharo/Cuis documentation on using layouts
>>>>>> (which may be the issue) but have made little headway.
>>>> Cuis layouts are different from Squeak or Pharo.  Given the changes going on, many things require some code reading and playing around.
>>>> 
>>>> To understand Layouts and LayoutSpecs, I did simple editors for them.  They are located in the Morphic-Misc1 package at:
>>>>   https://github.com/KenDickey/Cuis-Smalltalk-Morphic-Misc1 <https://github.com/KenDickey/Cuis-Smalltalk-Morphic-Misc1>
>>>> 
>>>> From the readme:
>>>> "
>>>> After loading this package, one can select a morph, open its menu from the halo, and edit its LayoutSpec.
>>>> If the morph is a LayoutMorph, one can also open an editor for the LayoutMorph from the halo menu.
>>>> "
>>>> 
>>>> Inspecting the window submorphs should help as well.
>>>> 
>>>> Cheers,
>>>> -KenD
>>> 
>>> Hari, you were really close. Unfortunately, a bug in Cuis made it harder than needed. Besides trying Ken suggestion, also do the following:
>>> 
>>> 1) Change #addToScroller: to read
>>> addToScroller: aMorph
>>> 
>>>    scroller
>>>        addMorph: aMorph position: 0 at 0;
>>>        morphExtent: aMorph morphExtent
>>> 
>>> (just found a bug. This fix will be on GitHub soon)
>>> 
>>> 2) Take a look at #inATwoWayScrollPane. Try the comment:
>>> 
>>> (EllipseMorph new morphExtent: 500 at 270) inATwoWayScrollPane openInHand
>>> 
>>> 3) Change your code to read:
>>> mArea := ( DragAndDropAreaMorph new color: Color white) inspect openInWorld.
>>> scrollpane := (PluggableScrollPane new color: Color red) openInWorld .
>>> scrollpane inspect.
>>> gWindow := SystemWindow new.
>>> gWindow addMorph: scrollpane.
>>> 
>>> mArea morphExtent: 800 at 800.
>>> scrollpane addToScroller: mArea.
>>> 
>>> qEllipse := EllipseMorph new.
>>> mArea addMorph: qEllipse.
>>> qEllipse morphPosition: 200 at 500.
>>> 
>>> gWindow openInWorld
>>> 
>>> The change was to set the mArea extent prior to adding to the scroller.... Maybe we'd make InnerPluggableMorph>>#adjustExtent work! If you keep playing with this, and find out whow you think it should behave, please send us your code, for integration.
>>> 
>>> Cheers,
>>> Juan Vuletich
>>> 
>>> 
>>> _______________________________________________
>>> Cuis mailing list
>>> Cuis at jvuletich.org <mailto:Cuis at jvuletich.org>
>>> http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org <http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org>
>> 
>> 
>> _______________________________________________
>> Cuis mailing list
>> Cuis at jvuletich.org <mailto:Cuis at jvuletich.org>
>> http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org <http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org>
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jvuletich.org/pipermail/cuis_jvuletich.org/attachments/20150512/cbf84beb/attachment-0006.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ProportionallyResizingRect.st
Type: application/octet-stream
Size: 5065 bytes
Desc: not available
URL: <http://jvuletich.org/pipermail/cuis_jvuletich.org/attachments/20150512/cbf84beb/attachment-0003.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jvuletich.org/pipermail/cuis_jvuletich.org/attachments/20150512/cbf84beb/attachment-0007.html>


More information about the Cuis mailing list