[Cuis-dev] Morph render leftovers when dragging the mouse

Juan Vuletich juan at jvuletich.org
Mon Jul 26 19:01:40 PDT 2021


Oh, gosh.

I read your previous message in haste, and only tried the first script. 
Yes, when you add the WidgetMorph, drawing breaks. The reason is that 
WidgetMorph is a superclass of system widgets. One assumption is that 
widgets don't have submorphs that protrude them. This is true for 
SystemWindows and all the other widgets in the hierarchy. It allows the 
framework to do some optimizations when computing dirty rectangles (i.e. 
the display rectangles that need to be redrawn). If you define 
#submorphsMightProtrude to answer true, then drawing works ok. Still, my 
suggestion is to just use a new subclass of MovableMorph, or maybe a 
copy of it (right click on MovableMorph / copy class... ), and only 
ensure that #submorphsMightProtrude answers true in this new class.

WRT your other question (I completely missed it earlier today), no. Cuis 
doesn't include "shrink wrap" morphs. I guess it shouldn't be difficult 
to implement it for your own morph. Cuis Layouts are based on the 
opposite idea: each morph decides the location and maybe extent of its 
submorphs.

Cheers,

-- 
Juan Vuletich
www.cuis-smalltalk.org
https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev
https://github.com/jvuletich
https://www.linkedin.com/in/juan-vuletich-75611b3
@JuanVuletich


On 7/26/2021 8:53 PM, Nicolás Papagna Maldonado via Cuis-dev wrote:
> Hi Juan!
>
> Thanks for taking the time to look into this.
>
> I've cloned the Cuis repo and was able to reproduce the artifacts that 
> are shown in the video link I shared in the previous email.
>
> label := UpdatingLabelMorph new
>     target: [
>         self runningWorld submorphs
>             detect: [ :morph | morph containsGlobalPoint: self 
>  runningWorld activeHand morphPositionInWorld ]
>             ifFound: [ :morph | morph class name ]
>             ifNone: [ 'nothing here' ]
>     ];
>     getSelector: #value;
>     stepTime: 10.
>
> self
>     runningWorld
>     activeHand
>     attachMorphBeside:  (WidgetMorph new addMorph: label).
>
> Tried running updated too, but that didn't work.
>
> Am I missing something?
>
> Best,
> Nico PM
>
> On Mon, Jul 26, 2021 at 4:03 PM Juan Vuletich <juan at jvuletich.org 
> <mailto:juan at jvuletich.org>> wrote:
>
>     Hi Nico,
>
>     Your code works perfectly well on my pc on an updated Cuis. Maybe
>     the bug you see has already been fixed?
>
>     Cheers,
>
>     -- 
>     Juan Vuletich
>     www.cuis-smalltalk.org  <http://www.cuis-smalltalk.org>
>     https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev
>     https://github.com/jvuletich
>     https://www.linkedin.com/in/juan-vuletich-75611b3
>     @JuanVuletich
>
>
>
>     On 7/25/2021 3:39 PM, Nicolás Papagna Maldonado via Cuis-dev wrote:
>>     Friendly bump to see if anyone has a lead on this one :)
>>
>>     Thanks in advance,
>>     Nico PM
>>
>>     On Tue, Jul 20, 2021 at 4:17 PM Nicolás Papagna Maldonado
>>     <nicolas.papagna at gmail.com <mailto:nicolas.papagna at gmail.com>> wrote:
>>
>>         Aloha folks!
>>
>>         I've run into the following issue. I'll do my best to explain
>>         it with the following example.
>>
>>         TL;DR see video reproducing the issue here:
>>         https://drive.google.com/file/d/1HikB46LCob-bf-W4LOnT_azH-0ohlB9I/view?usp=sharing
>>
>>         Let's say I want to display the class name of a morph when I
>>         point to it.
>>         If I do this, everything works fine:
>>
>>         label := UpdatingLabelMorph new
>>             target: [
>>                 self runningWorld submorphs
>>                     detect: [ :morph | morph containsGlobalPoint:
>>         self  runningWorld activeHand morphPositionInWorld ]
>>                     ifFound: [ :morph | morph class name ]
>>                     ifNone: [ 'nothing here' ]
>>             ];
>>             getSelector: #value;
>>             stepTime: 10.
>>
>>         self
>>             runningWorld
>>             activeHand
>>             attachMorphBeside: label.
>>
>>         If I try to attach a morph that contains the label defined
>>         above (say I want to display something fancier, not just a
>>         label), then every time I drag the mouse the label behaves
>>         like a "pen" leaving traces of its old renders on the canvas:
>>
>>         self
>>             runningWorld
>>             activeHand
>>             attachMorphBeside:  (WidgetMorph new addMorph: label).
>>
>>         My gut feeling is that this might be related to the fact that
>>         the WidgetMorph that contains the label is not aware that it
>>         is rendered outside of its bounds, but I don't have much
>>         experience with Morphic.
>>
>>         1) Am I doing something wrong/missing an important concept
>>         for understanding how Morphic works?
>>         2) Related to that: I often find myself wrapping a bunch of
>>         morphs to add behavior/glue code to them, but that wrapper
>>         does not do any rendering. What would be the right way to
>>         adjust the wrapper's extent to fit its submorphs perfectly
>>         (e.g. no extra space/no clipping)?
>>
>>         Thanks in advance,
>>         Nico PM
>>
>>
>>
>>     -- 
>>
>>     Nicolás Papagna
>
>
>
> -- 
>
> Nicolás Papagna
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20210726/749b06ca/attachment-0001.htm>


More information about the Cuis-dev mailing list