Modifying tooltips in Squeak

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Modifying tooltips in Squeak

Jerome Peace
MJK wrote:
> I also
> don't understand where the tooltip gets those polygon coordinates that shape
> the balloon.
[Newbies] Modifying tooltips in Squeak


>As far as I can tell it is in
>BalloonMorph class getVertices:

>Hope that helps, David



It starts with the boundry for the text morph which is a rectangle.

Sending the message #corners to the rectangle gets you four vertices. They need to be arranged in a certain order.
Then you add a few more to get the speech tail. Those become vertices for a smooth curve polygon. Then you have to figure where to put the text morph inside the polygon. The way balloon morph uses is #adjustedCenter which isolates the four rectangle vertices and takes the average. The center of the text morph is aligned with that point.

Getting the curve to look good gets a little tricky because the polygon is working on being a smooth curve. If you are willing to use a rectangular looking tool tip you could use a segmented polygon and gain more control over the shape at the cost of having to generate all the extra vertices yourself.

Basically the tool tip boundry is just some function of the corners of the text morph boundry and where you want the speech tail.

A good way to play would be to subclass the BalloonMorph and modify the #initialize #getVertices and #adjustedCenter methods.

Hth,

Yours in curiosity and service, Jerome Peace
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
MJK
Reply | Threaded
Open this post in threaded view
|

Re: Modifying tooltips in Squeak

MJK
Jerome Peace wrote
A good way to play would be to subclass the BalloonMorph and modify the #initialize #getVertices and #adjustedCenter methods.
Thanks, good idea. I've created a new subclass and it works perfectly, when I replace BalloonMorphs with my own. Only thing left is to figure out, how themes and color preferences work with BalloonMorphs. I have a general idea of the system, but apparently no one has implemented browsable preferences for BalloonMorphs that could be modified and applied via Preferences Browser. But for now I'm very happy how things work.

Btw, if anybody is interested in seeing my tooltip implementation, it is available at SqueakSource: http://www.squeaksource.com/MJKTooltip.html It's not much code, but I'm proud of it :)

-Matti