[Cuis-dev] Viewport with Morph 3

Juan Vuletich juan at cuis.st
Tue Apr 11 08:02:58 PDT 2023


On 4/11/2023 5:56 AM, Hilaire Fernandes via Cuis-dev wrote:
>
> Hi,
>
> How will you implement a viewport?
>
> Let's say I have a PaperMorph with some written texts. Its halo shows 
> the top left corner (0;0). Is there a way to adjust the PaperMorph so 
> it shows (50,0) at the top left corner and its texts are translated of 
> 50 pixels in the left direction?
>
> Thanks
>
> Hilaire
>
> -- 
> GNU Dr. Geo
> http://drgeo.eu
> http://blog.drgeo.eu

Hi Hilaire,

Sample07Clipping is an example on how to clip submorphs, to an arbitrary 
shape:
Sample07Clipping new openInWorld.

If the clipping will be to a simple rectanlge, it may be better to:
Create a new class, like BoxedMorph subclass: #ClippingBoxMorph
Add this method:
     clipsSubmorphs
         ^true
Then do something like:
     star := Sample01Star new.
     container := ClippingBoxMorph new.
     container addMorph: star.
     container openInWorld.
     star morphPosition: 10 at 60. "or whatever"

If you also want automatically handled scrollbars, it is already in the 
image, and used by most of the UI. You can simply do:
     p := PluggableScrollPane new.
     p scroller: Sample01Star new.
     p openInWorld.
Note that in this case, you can't position the submorph at will. The 
ScrollPane will position the "scroller" in such a way that its topLeft 
is visible when scrollbars ar at the top and left.

Hope this helps.

Cheers!

-- 
Juan Vuletich
cuis.st
github.com/jvuletich
researchgate.net/profile/Juan-Vuletich
independent.academia.edu/JuanVuletich
patents.justia.com/inventor/juan-manuel-vuletich
linkedin.com/in/juan-vuletich-75611b3
twitter.com/JuanVuletich

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20230411/f7128c48/attachment.htm>


More information about the Cuis-dev mailing list