Pharo-dev
By thread
pharo-dev@lists.pharo.org
By month
Messages by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- 3 participants
- 144636 messages
Re: [Pharo-dev] How to get launcher launching Spur images?
by Stephan Eggermont
On 10-01-16 18:49, stepharo wrote:
> I changed the setting to be the following but I cannot get a spur image
> started on mac.
> Does anybody succeed?
The paths look good to me.
Yes, it works for me on both Linux and Mac. These are my paths
Spur:
/Users/stephan/Library/Application
Support/Pharo/spur/pharo-vm/Pharo.app/Contents/MacOS/Pharo
Cog:
/Users/stephan/Library/Application
Support/Pharo/vms/pharo-vm/Pharo.app/Contents/MacOS/pharo
Could it be that the OS security manager does not allow the starting?
Do you need to start it once by hand? I loaded the pharo spur vm with
the bash script, that migth be a difference
Stephan
Jan. 11, 2016
New #s senders search functionality was in Spotter Re: Understanding Spotter?
by Paul DeBruicker
Hi Doru,
The lack of this functionality has been my main complaint against spotter.
So thanks for adding it.
Is the #s <myMethodName> functionality backported to/loadable in Pharo 4?
is there an equivalent search for implementors?
Will you also please please please fix it such that the entire list of
search results is shown as its only one category rather than having to 'dive
in' on anything? E.g. In the example you've given you cut the list of
class/method name pairs shown to the first 5 alphabetically where certainly
the entire list of 11 would fit in the drawn window without scrolling. And
really since there aren't any sections you should be able to run a massive
list of 500++ that could be scrolled with the page up/page down keys or
scroll wheel on a mouse.
Thanks
Paul
Tudor Girba-2 wrote
> Hi Stef,
>
> Thanks for taking the time. I think I did not express myself properly in
> the previous mail because we are not really in disagreement :).
>
> The basic mechanism you talk about exists already in Spotter. Let me
> explain. When you type: "#e graphs", you will get two examples (and only
> the example search is being performed).
>
>
>
> This works because the name of the âExamplesâ category starts with âEâ.
>
> Until now we did not have a top level processor that would search for
> Senders (only inside a method). So, because of this you could not search
> for them at the top level. In the meantime Stefan just finished
> implementing it, the name of the category is Senders. So, you will type
> â#s somethingâ.
>
>
>
> I now made the category name start with # so that it is closer to the way
> to query for it. So, when you do not know how, you will just search for
> âsomethingâ. Then you will discover the #Senders category, and then you
> can learn that you can search for it.
>
> Now, you seem to be saying that instead of â#s somethingâ you want to type
> â#n somethingâ. For this we would need to find a solution to reconcile the
> two. My proposal was to maybe introduce something like â&n somethingâ to
> distinguish between the string match of a category name and a âshortcutâ
> (I do not know how to call it). I can see how to do this technically, but
> I still think this is less discoverable then the filtering by the name
> like described above, and it would be an extra mechanism. We could add
> this shortcut next to the category name to address this issue. The
> interesting thing about the shortcut is that we could possibly make it
> less ambiguous. For example, if you have two categories starting with #S,
> you will get both when you type â#S somethingâ, which is less ideal for a
> common case. So, there are pros and cons.
>
> Now, what is missing is a top level category for References, and I really
> think we would have what you wanted (and it is a good goal). The cool
> thing is that we would be solving this problem with a generic mechanism.
>
> So, what I am suggesting is to invest a bit in categories (#Senders can be
> integrated now) and then we play with it.
>
> Is this explanation clearer? Did I misunderstand something? What do you
> think?
>
> Cheers,
> Doru
>
>
>> On Jan 10, 2016, at 10:23 PM, stepharo <
> stepharo@
> > wrote:
>>
>> Ok my last attempt :(
>>
>> When I look for something there are two cases
>>
>> - most of the time I
>> ********************KKKKNNNOOOOOOOWWWWWWW*********
>> is it clear? I know I know I know what I look for and I WANT THE
>> FASTER WAY TO GET IT
>> => no three clicks and strange navigation.
>>
>> I want the sender of this message (not the implementors the sender)
>> I want that package
>> I want the references to this class (not the class and the refs that
>> class)
>> and I'm ready to learn
>> #N for reference
>> #n for senders
>> #m for implementors
>> Because they are the same.
>> #e for example like in the finder
>>
>> - looking around and the system can propose me something
>> and I can navigate and think.
>>
>> But this is ok I just use Spotter to open the class browser and all the
>> rest I do it with shortcuts.
>> I tried to help but I failed.
>>
>> I will present Spotter as the great tool to open browser because I cannot
>> use it otherwise and
>> nobody around me can show me on the spot something more efficient than a
>> shortcut in a workspace.
>> Or may be I will simply not spend energy doing a videos on Spotter
>> because to me this is not ready
>> and far less usable than it is supposed to be.
>>
>> Now to me Spotter is taking a lot of classes for the gain I get. What
>> esteban did or what is in Squeak
>> is working perfectly for me because Spotter does not let me express my
>> needs.
>> So may be you have other needs but I would like to know how people really
>> works and not
>> how Spotter should be usefull.
>>
>> The video of dimitry shows that well: Just browse a class and sometimes
>> you get an implementor
>> May be you do not like my mail because they look aggressive but when is
>> the last time
>> you did a real study with users that were not already convinced. Or may
>> be with users
>> that loves just one tiny feature and not the one you think that they use?
>>
>> And BTW it hangs my images two times with 4.0 when I was in africa and
>> this was annoying.
>> Stef
>>
>>
>>>> I do not get why you cannot
>>>> - have a set of fixed most used queries and this will create a small
>>>> vocabulary that can be extensible
>>>> and it can be mapped to what we do with shortcuts = reduce cognitive
>>>> load
>>>> and then a full search when you do not know what you are searching.
>>>> This is not exclusive and it works for the two scenario.
>>>
>>> I understand the intention, but I do not understand how these fixed
>>> queries are any different than we have now. When you are on the top of
>>> Spotter, when you query, you get always the same processors being
>>> executed. At first you will not know their names, and you will scroll.
>>> And if you see them, you might remember them and reproduce afterwards.
>>> Itâs a discoverable learning process that you do not have to remember.
>>
>> Because with these wonderfull queries I do not get what I'm looking for.
>> Because the system is trying to guess what I have in my mind and this
>> system is not good for that because I'm thinking about
>> the metallica song I'm listening.
>>
>>
>>> The only part that is not discoverable is that # introduces a category
>>> search. Thinking loud, I just thought that we can make the label start
>>> with # like this (I committed this change):
>>
>> Sorry but I do not get it.
>>
>>>
>>>
> <Mail Attachment.png>
>>>
>>> We also thought of having completion as soon as someone type #. So, you
>>> have a kind of a dropdown for the available categories, but we did not
>>> get to implement that one. This should solve the discoverability problem
>>> even more. What do you think about that?
>> Why not
>> but just a ghost with
>> #n printOn: #m #N ....
>> would be a huge improvement
>>
>> Each time I used Spotter to look for something more than a class I could
>> not find it.
>>
>>
>>
>>> Regarding the shortcuts, we could associated such shortcuts with a
>>> processor, but I would first want to see if we cannot manage to produce
>>> a solution with the current set of options.
>>
>> I was not saying shortcuts and I was thinking the same vocabulary
>>
>> Cmd+N
>> #N
>> Cmd+m
>> #m
>> Cmd+n
>> #n
>>>
>>>
>>>> I was discussing with Luc and he made a fun but sad remark
>>>> "Since people do not understand well spotter they most of the time
>>>> only use it to open a class.
>>>> And this is something that he already had before."
>>>> I briefly looked at the Youtube video of Chloupis and
>>>> So you can have a generic super cool tool, if people do not use it it
>>>> defeats its purpose.
>>>
>>> Certainly.
>>>
>>>
>>>> You can be really happy because you go fast with it but you only.
>>>
>>> That is not really true :).
>>
>> See my remark above.
>>>
>>>> So making sure that the most used actions are really supported is
>>>> important.
>>>
>>> Of course it is. For Senders we did not find a good solution yet that is
>>> reasonably fast and useful. Stefan and I are still literally working on
>>> this. I think we should be able to have a solution, but we have to see
>>> if it is reasonable enough. We will announce it once we have it working.
>>
>> the problem is that you want to solve everything at once. While the
>> divide and conquer is the solution for the first
>> scenario I mention. I do not need something that crawls the entire system
>> when I have one precise query.
>>
>>
>>>
>>> But, really, this tool more than anything allows one to play with
>>> possibilities in a couple of lines of code. We want people to play (some
>>> did) and to get concrete feedback and possible solutions. I think we
>>> should not just say that we need something else before we actually play
>>> with it a bit more.
>> I do not get it.
>> I never worked with me. And so far I did not see anybody succeeding to
>> show me how to find something that I cannot
>> find faster with a shortcut.
>>
>>
>>
>>>> But more important the discoverability is important because there is
>>>> not even a help.
>>>> Right now as a user I can only guess and often I close spotter and use
>>>> my shortcuts.
>>>> As a user I see something that ask me about network (and I do not care)
>>>> but nothing
>>>> that brings me to the next level.
>>>
>>> This is something we need to work on, but you know, time is limited for
>>> us, too.
>>
>> Add a button and an help text copied from your blog!
>> And you will have made a 100% documentation jump.
>>>
>>>
>>>> Most of the time the user forgets the key combination (may be this will
>>>> be solved with
>>>> the cool shortcut reminder we developed and is under review)
>>>
>>> All actions in spotter have a visible icon. All. And if you hover over
>>> it you get the command. And there are literally 5 such actions. What is
>>> missing in this regard from your point of view?
>>
>> I do not know
>> They do not cover what I want to do.
>> I do not care of setting
>> Most of the time I do not care about seeing all. I saw now that you
>> have an arrow to show more than the top 5
>> good but again Cmd-shift > is not easy to type and give pain.
>> I do not understand why I should dive in most of the time.
>>
>> I realised that I could use Spotter when I saw that I can press shift
>> under the return because
>> before I got immediate pain when trying with the left shift.
>> To me left shift is a NO WAY.
>> esc (top left) would work but I did not have the time to hack Spotter.
>>
>>>
>>> Doru
>>>
>>>
>>>> Stef
>>>>
>>>>
>>>>
>>>>
>>>
>>> --
>>> www.tudorgirba.com
>>> www.feenk.com
>>>
>>> "Reasonable is what we are accustomed with."
>>>
>>
>
> --
> www.tudorgirba.com
> www.feenk.com
>
> "The coherence of a trip is given by the clearness of the goal."
>
>
>
>
>
>
>
> a GTSpotterMorph(858507264)2016-01-10T23-06-19-10433+02-00.png (108K)
> <http://forum.world.st/attachment/4870487/0/a%20GTSpotterMorph%28858507264%292016-01-10T23-06-19-10433%2B02-00.png>
> a GTSpotterMorph(10402452482016-01-10T23-11-35-849359+02-00.png (130K)
> <http://forum.world.st/attachment/4870487/1/a%20GTSpotterMorph%2810402452482016-01-10T23-11-35-849359%2B02-00.png>
--
View this message in context: http://forum.world.st/Understanding-Spotter-tp4870311p4870547.html
Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
Jan. 11, 2016
Re: [Pharo-dev] #sum:, #detectSum:, #sumNumbers:
by Sven Van Caekenberghe
> On 08 Jan 2016, at 21:15, stepharo <stepharo(a)free.fr> wrote:
>
> Sven
>
> may be should do the following:
> - introduce the best solution (not using your and henrik decomposition)
> - continue to think about it.
There is no intermediary solution, we'll continue to think about it.
> I would like to see if Xtreams does not go in the same direction too. But I do not have the code at hand to think about it.
Xtreams does not solve the problem either, I think.
The key question is: can you write operations on objects, generic containers of element objects, that depend on the fact that the element objects are of a certain type (or protocol), but that might fail and make completely no sense for others.
Consider the 'data get/put' category on PositionalStream with operations like #int32 and #int32: - these assume that this are byte streams. But in my book, streams can be anything, colors, records, points, fonts, ...
> Stef
Jan. 11, 2016
Re: [Pharo-dev] [pharo-project/pharo-core] 636bf8: 50521
by Sven Van Caekenberghe
You probably chose a font that cannot display that character.
> On 11 Jan 2016, at 00:38, David Allouche <david(a)allouche.net> wrote:
>
> Cool! Nice addition.
>
> When the shortcut reminder appears, on my Mac, the Command symbol â is not displayed, instead there is generic symbol that looks like this: â§ (but might be a different one). There might be a problem with some font configuration.
>
>>
>> Log Message:
>> -----------
>> 50521
>> 17348 Enhance shortcut learnability
>> https://pharo.fogbugz.com/f/cases/17348
>>
>> http://files.pharo.org/image/50/50521.zip
>>
>>
>
>
Jan. 11, 2016
Re: [Pharo-dev] Better class comment version2
by David Allouche
Oh thanks, that explains the problem I observed and why I did not spot the bug in all the time I spent staring at it in the debugger: the values were there in the rectangle, only swapped between origin and corner!
Maybe receiving a rectangle as the second argument of #fractions:offsets: should cause a warning to be printed on the Transcript. It is such an easy mistake with such a tricky behaviourâ¦
Anyway, the improved FrameLayout documentation will already help a lot.
> On 10 Jan 2016, at 23:16, Thierry Goubier <thierry.goubier(a)gmail.com> wrote:
>
> Hi David,
>
> this is the bug with LayoutFrame>>#fractions:offsets: we were talking
> about relative to that class comment.
>
> In Pharo, Rectangles are constrained to have the smallest vertical value
> as the top, smallest horizontal value as the left, largest vertical
> value as bottom and largest horizontal value as right. So, your
> rectangle 'offsets' was in fact:
> -3 @ -3 corner: 3 @ 3
> which is exactly the reverse of what you intended ;)
>
> Using the elementary distance accessors is the correct approach.
>
> Regards,
>
> Thierry
>
> Le 10/01/2016 23:05, David Allouche a écrit :
>> I guess that is a class comment for LayoutFrame. I think this is
>> great improvement.
>>
>> By I the way, I noticed something really strange when I was using it
>> in my learning project of a TicTacToe game. I started initializing a
>> LayoutFrame using #fractions:offsets:, but I had strange incorrect
>> results. I have fixed them by using the elementary distance
>> accessors.
>>
>> Here is the relevant method in my code.
>>
>> drawCircleOn: aCanvas "Draw a circle cell" | layout oval | "That
>> should worlk, but does not!" "offsets := (1@1 corner: (-1)@(-1))
>> scaleBy: lineWidth*3." "layout := LayoutFrame fractions: (0@0 corner:
>> 1@1) offsets: offsets." layout := (0@0 corner: 1@1) asLayoutFrame.
>> layout topOffset: lineWidth*3; leftOffset: lineWidth*3; bottomOffset:
>> lineWidth*(-3); rightOffset: lineWidth*(-3). oval := layout
>> transform: self bounds. aCanvas frameOval: oval width: lineWidth
>> color: color.
>>
>> I could not find an online syntax highlighter that supports
>> Smalltalk, so here it comes unstyled.
>>
>> Should I write a test case for that, or did I try to do something
>> obviously incorrect?
>>
>>> On 9 Jan 2016, at 10:22, stepharo <stepharo(a)free.fr> wrote:
>>>
>>> I define a transformation frame relative to some rectangle. I'm
>>> basic data structure used for graphics. I represent two groups of
>>> distances: - The fractional distance (between 0 and 1) to place the
>>> morph in its owner's bounds - Fixed pixel offset to apply after
>>> fractional positioning (e.g., "10 pixel right of the center of the
>>> owner")
>>>
>>> !! API usage It is important to understand that it is better to use
>>> the fine grained API using elementary distances (bottomFraction:,
>>> bottomOffset:, leftFraction: ....) than the ones (historical) using
>>> points and rectangles (fractions:offsets:)
>>>
>>> The reason is that the old API (fractions:offsets:) is only
>>> interesting if you already have a rectangle and point at hand. If
>>> you need to create new ones, then they are created for nothing
>>> because they will be destructured to extract their information to
>>> be feed into the layoutFrame. So please do not blindly copy and
>>> paste code!
>>>
>>> Example: Favor
>>>
>>> (LayoutFrame identity leftFraction: 0; yourself);
>>>
>>> (LayoutFrame identity leftFraction: 0.5; rightFraction: 0.95;
>>>
>>> (LayoutFrame identity topOffset: topHeight; bottomFraction: 0;
>>> bottomOffset: self buttonsBarHeight; leftOffset: -1; rightOffset:
>>> 1) over
>>>
>>> (LayoutFrame fractions: (0 @ 0 corner: 1 @ 1))
>>>
>>> For this one in particular it is better to use LayoutFrame
>>> identity
>>>
>>> It is faster and more readable
>>>
>>> because you are creating for nothing a new rectangle and some
>>> points.
>>>
>>> !! Final point: Do not use Rectangles for specifying layoutFrames
>>>
>>> If you happen to need to create a rectangle and use the
>>> fractions:offsets: class methods, refrain from creating a
>>> rectangle. The reason is that a rectangle is not 4 numbers, it
>>> represents a space area and when you use a rectangle to represent
>>> random numbers you end up creating rectangles with negative extents
>>> and this is not good. In this case use Margin, Margin is a nice
>>> class holding either one number (the same "margin" on the four
>>> sides of a rectangle), or two number (top/bottom, left/right
>>> margins) or 4 numbers.
>>>
>>> !! Implementation
>>>
>>> Instance variables: The fractional distance (between 0 and 1) to
>>> place the morph in its owner's bounds is represented by the
>>> following instance variables: leftFraction topFraction
>>> rightFraction bottomFraction <Float>
>>>
>>>
>>> Fixed pixel offset to apply after fractional positioning (e.g., "10
>>> pixel right of the center of the owner") is represented by the
>>> following instance variables: leftOffset topOffset rightOffset
>>> bottomOffset <Integer>
>>>
>>
>>
>>
>
>
Jan. 11, 2016
Re: [Pharo-dev] [pharo-project/pharo-core] 636bf8: 50521
by David Allouche
Cool! Nice addition.
When the shortcut reminder appears, on my Mac, the Command symbol â is not displayed, instead there is generic symbol that looks like this: â§ (but might be a different one). There might be a problem with some font configuration.
>
> Log Message:
> -----------
> 50521
> 17348 Enhance shortcut learnability
> https://pharo.fogbugz.com/f/cases/17348
>
> http://files.pharo.org/image/50/50521.zip
>
>
Jan. 10, 2016
gtdebugger - icons with text and a couple of others
by Tudor Girba
Hi,
Andrei and I took your feedback into account, and now we have this in the last version:
- actions have text (this is a feature introduced in Glamour now)
- the order of the code actions is better (accept is next to cancel)
On top of that, there are a couple of extra features that we did not talk about until now:
- whenever there is another kind of debugger available, a new button appears on the top right. When the Bytecode Debugger is loaded, you can always switch to it. Or, when you get in a situation in which the SUnit is available, you can switch to it.
- the selection from the inspector is preserved when you move back and forth in the stack.
- the panes in the inspector can be closed
- stack highlighting is not on by default (it never was actually)
- if you âInspect and Goâ, you inspect in place instead of the inspector at the bottom (no extra window)
There are probably still glitches, but we think they are fixable.
We still would like to add a couple of more features if there is time:
- having a table in the stack to show class / method / package
- having multiple inspectors in tabs when you inspect in place to not remove the original inspector
Please let us know what you think.
Cheers,
Doru
--
www.tudorgirba.com
www.feenk.com
"Every thing has its own flow."
Jan. 10, 2016
Re: [Pharo-dev] [Moose-dev] Re: gtdebugger in pharo 5.0
by Alexandre Bergel
I see the motivation, but things should go incrementally. If code should be highly documented, with a high test coverage, friendly to API migration then well.. not much happensâ¦
Cheers,
Alexandre
> On Jan 10, 2016, at 5:24 PM, Sven Van Caekenberghe <sven(a)stfx.eu> wrote:
>
>> I think that we should not integrate new classes if they don't have a
>> class comment that follow the template.
>
> +100
>
> I can understand that when prototype, hacking, being generally productive inside Pharo, you don't write comments at first. But once you go public, after some iterations, and especially if you want to be integrated into Pharo itself, there is no excuse. We need proper class comments, and comments for the main non-trivial public methods.
--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
Jan. 10, 2016
Re: [Pharo-dev] Better class comment version2
by Thierry Goubier
Hi David,
this is the bug with LayoutFrame>>#fractions:offsets: we were talking
about relative to that class comment.
In Pharo, Rectangles are constrained to have the smallest vertical value
as the top, smallest horizontal value as the left, largest vertical
value as bottom and largest horizontal value as right. So, your
rectangle 'offsets' was in fact:
-3 @ -3 corner: 3 @ 3
which is exactly the reverse of what you intended ;)
Using the elementary distance accessors is the correct approach.
Regards,
Thierry
Le 10/01/2016 23:05, David Allouche a écrit :
> I guess that is a class comment for LayoutFrame. I think this is
> great improvement.
>
> By I the way, I noticed something really strange when I was using it
> in my learning project of a TicTacToe game. I started initializing a
> LayoutFrame using #fractions:offsets:, but I had strange incorrect
> results. I have fixed them by using the elementary distance
> accessors.
>
> Here is the relevant method in my code.
>
> drawCircleOn: aCanvas "Draw a circle cell" | layout oval | "That
> should worlk, but does not!" "offsets := (1@1 corner: (-1)@(-1))
> scaleBy: lineWidth*3." "layout := LayoutFrame fractions: (0@0 corner:
> 1@1) offsets: offsets." layout := (0@0 corner: 1@1) asLayoutFrame.
> layout topOffset: lineWidth*3; leftOffset: lineWidth*3; bottomOffset:
> lineWidth*(-3); rightOffset: lineWidth*(-3). oval := layout
> transform: self bounds. aCanvas frameOval: oval width: lineWidth
> color: color.
>
> I could not find an online syntax highlighter that supports
> Smalltalk, so here it comes unstyled.
>
> Should I write a test case for that, or did I try to do something
> obviously incorrect?
>
>> On 9 Jan 2016, at 10:22, stepharo <stepharo(a)free.fr> wrote:
>>
>> I define a transformation frame relative to some rectangle. I'm
>> basic data structure used for graphics. I represent two groups of
>> distances: - The fractional distance (between 0 and 1) to place the
>> morph in its owner's bounds - Fixed pixel offset to apply after
>> fractional positioning (e.g., "10 pixel right of the center of the
>> owner")
>>
>> !! API usage It is important to understand that it is better to use
>> the fine grained API using elementary distances (bottomFraction:,
>> bottomOffset:, leftFraction: ....) than the ones (historical) using
>> points and rectangles (fractions:offsets:)
>>
>> The reason is that the old API (fractions:offsets:) is only
>> interesting if you already have a rectangle and point at hand. If
>> you need to create new ones, then they are created for nothing
>> because they will be destructured to extract their information to
>> be feed into the layoutFrame. So please do not blindly copy and
>> paste code!
>>
>> Example: Favor
>>
>> (LayoutFrame identity leftFraction: 0; yourself);
>>
>> (LayoutFrame identity leftFraction: 0.5; rightFraction: 0.95;
>>
>> (LayoutFrame identity topOffset: topHeight; bottomFraction: 0;
>> bottomOffset: self buttonsBarHeight; leftOffset: -1; rightOffset:
>> 1) over
>>
>> (LayoutFrame fractions: (0 @ 0 corner: 1 @ 1))
>>
>> For this one in particular it is better to use LayoutFrame
>> identity
>>
>> It is faster and more readable
>>
>> because you are creating for nothing a new rectangle and some
>> points.
>>
>> !! Final point: Do not use Rectangles for specifying layoutFrames
>>
>> If you happen to need to create a rectangle and use the
>> fractions:offsets: class methods, refrain from creating a
>> rectangle. The reason is that a rectangle is not 4 numbers, it
>> represents a space area and when you use a rectangle to represent
>> random numbers you end up creating rectangles with negative extents
>> and this is not good. In this case use Margin, Margin is a nice
>> class holding either one number (the same "margin" on the four
>> sides of a rectangle), or two number (top/bottom, left/right
>> margins) or 4 numbers.
>>
>> !! Implementation
>>
>> Instance variables: The fractional distance (between 0 and 1) to
>> place the morph in its owner's bounds is represented by the
>> following instance variables: leftFraction topFraction
>> rightFraction bottomFraction <Float>
>>
>>
>> Fixed pixel offset to apply after fractional positioning (e.g., "10
>> pixel right of the center of the owner") is represented by the
>> following instance variables: leftOffset topOffset rightOffset
>> bottomOffset <Integer>
>>
>
>
>
Jan. 10, 2016
Re: [Pharo-dev] Better class comment version2
by David Allouche
I guess that is a class comment for LayoutFrame. I think this is great improvement.
By I the way, I noticed something really strange when I was using it in my learning project of a TicTacToe game. I started initializing a LayoutFrame using #fractions:offsets:, but I had strange incorrect results. I have fixed them by using the elementary distance accessors.
Here is the relevant method in my code.
drawCircleOn: aCanvas
"Draw a circle cell"
| layout oval |
"That should worlk, but does not!"
"offsets := (1@1 corner: (-1)@(-1)) scaleBy: lineWidth*3."
"layout := LayoutFrame fractions: (0@0 corner: 1@1) offsets: offsets."
layout := (0@0 corner: 1@1) asLayoutFrame.
layout
topOffset: lineWidth*3;
leftOffset: lineWidth*3;
bottomOffset: lineWidth*(-3);
rightOffset: lineWidth*(-3).
oval := layout transform: self bounds.
aCanvas frameOval: oval width: lineWidth color: color.
I could not find an online syntax highlighter that supports Smalltalk, so here it comes unstyled.
Should I write a test case for that, or did I try to do something obviously incorrect?
> On 9 Jan 2016, at 10:22, stepharo <stepharo(a)free.fr> wrote:
>
> I define a transformation frame relative to some rectangle. I'm basic data structure used for graphics.
> I represent two groups of distances:
> - The fractional distance (between 0 and 1) to place the morph in its owner's bounds
> - Fixed pixel offset to apply after fractional positioning (e.g., "10 pixel right of the center of the owner")
>
> !! API usage
> It is important to understand that it is better to use the fine grained API using elementary distances (bottomFraction:, bottomOffset:, leftFraction: ....) than the ones (historical) using points and rectangles (fractions:offsets:)
>
> The reason is that the old API (fractions:offsets:) is only interesting if you already have a rectangle and point at hand. If you need to create new ones, then they are created for nothing because they will be destructured to extract their information to be feed into the layoutFrame.
> So please do not blindly copy and paste code!
>
> Example:
> Favor
>
> (LayoutFrame identity
> leftFraction: 0;
> yourself);
>
> (LayoutFrame identity
> leftFraction: 0.5;
> rightFraction: 0.95;
>
> (LayoutFrame identity
> topOffset: topHeight;
> bottomFraction: 0;
> bottomOffset: self buttonsBarHeight;
> leftOffset: -1;
> rightOffset: 1)
> over
>
> (LayoutFrame fractions: (0 @ 0 corner: 1 @ 1))
>
> For this one in particular it is better to use
> LayoutFrame identity
>
> It is faster and more readable
>
> because you are creating for nothing a new rectangle and some points.
>
> !! Final point: Do not use Rectangles for specifying layoutFrames
>
> If you happen to need to create a rectangle and use the fractions:offsets: class methods, refrain from creating a rectangle.
> The reason is that a rectangle is not 4 numbers, it represents a space area and when you use a rectangle to represent random numbers you end up creating rectangles with negative extents and this is not good.
> In this case use Margin, Margin is a nice class holding either one number (the same "margin" on the four sides of a rectangle), or two number (top/bottom, left/right margins) or 4 numbers.
>
> !! Implementation
>
> Instance variables:
> The fractional distance (between 0 and 1) to place the morph in its owner's bounds is represented by the following instance variables:
> leftFraction
> topFraction
> rightFraction
> bottomFraction <Float>
>
>
> Fixed pixel offset to apply after fractional positioning (e.g., "10 pixel right of the center of the owner") is represented by the following instance variables:
> leftOffset
> topOffset
> rightOffset
> bottomOffset <Integer>
>
Jan. 10, 2016