Here is the new class comments I'm trying to write.
I hope that it will help people to understand the circumstances under which they should use fractions:offset: creation API. 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 points 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)) because you are creating for nothing a new rectangle and some points. !! 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> |
that’s important.
I never understood LayoutFrame… I always finish doing random stuff until I have something that “more or less” works :) > On 09 Jan 2016, at 09:56, stepharo <[hidden email]> wrote: > > Here is the new class comments I'm trying to write. > I hope that it will help people to understand the circumstances under which they should use fractions:offset: creation API. > > > > 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 points 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)) > > because you are creating for nothing a new rectangle and some points. > > > > !! 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> > |
In reply to this post by stepharo
Stef,
could you deprecate the use of fractions:offsets: ? It's a nice way of shooting oneself in the foot. Create a LayoutFrame taking all space: LayoutFrame fractions: (0@0 corner: 1@1) right? Create a layout frame taking all space with an inset of three, so an offset of +3 left and above, and -3 right and bottom: LayoutFrame fractions: (0@0 corner: 1@1) offsets: (3@3 extent: -3@ -3) Fail! See what I mean? You have to forbid the use of a rectangle for offsets! (Note: I think the easiest API is the one used by Spec and Morphic: Rectangle asLayoutFrame topOffset: / bottomOffset ...) Thierry Le 09/01/2016 09:56, stepharo a écrit : > Here is the new class comments I'm trying to write. > I hope that it will help people to understand the circumstances under > which they should use fractions:offset: creation API. > > > > 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 points 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)) > > because you are creating for nothing a new rectangle and some points. > > > > !! 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> > > |
Hi,
This issue is still pending: https://pharo.fogbugz.com/f/cases/7077/LayoutFrame-refactoring Let us fix the Glamour issues and then we can deprecate it. Cheers, Doru > On Jan 9, 2016, at 11:54 AM, Thierry Goubier <[hidden email]> wrote: > > Stef, > > could you deprecate the use of fractions:offsets: ? It's a nice way of shooting oneself in the foot. > > Create a LayoutFrame taking all space: > > LayoutFrame fractions: (0@0 corner: 1@1) > > right? > > Create a layout frame taking all space with an inset of three, so an offset of +3 left and above, and -3 right and bottom: > > LayoutFrame fractions: (0@0 corner: 1@1) offsets: (3@3 extent: -3@ -3) > > Fail! > > See what I mean? You have to forbid the use of a rectangle for offsets! > > (Note: I think the easiest API is the one used by Spec and Morphic: Rectangle asLayoutFrame topOffset: / bottomOffset ...) > > Thierry > > Le 09/01/2016 09:56, stepharo a écrit : >> Here is the new class comments I'm trying to write. >> I hope that it will help people to understand the circumstances under >> which they should use fractions:offset: creation API. >> >> >> >> 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 points 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)) >> >> because you are creating for nothing a new rectangle and some points. >> >> >> >> !! 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> >> >> > > -- www.tudorgirba.com www.feenk.com "The coherence of a trip is given by the clearness of the goal." |
In reply to this post by Thierry Goubier
Hi thierry
> Stef, > > could you deprecate the use of fractions:offsets: ? It's a nice way of > shooting oneself in the foot. Yes we should in fact. Today I was thinking that there may be cases where this api makes sense but your remark in the bug tracker made me think and you are right. > Create a LayoutFrame taking all space: > > LayoutFrame fractions: (0@0 corner: 1@1) > > right? better LayoutFrame identity :) > > Create a layout frame taking all space with an inset of three, so an > offset of +3 left and above, and -3 right and bottom: > > LayoutFrame fractions: (0@0 corner: 1@1) offsets: (3@3 extent: -3@ -3) > > Fail! > > See what I mean? You have to forbid the use of a rectangle for offsets! oh yes pretty well :) > > (Note: I think the easiest API is the one used by Spec and Morphic: > Rectangle asLayoutFrame topOffset: / bottomOffset ...) > > Thierry > > Le 09/01/2016 09:56, stepharo a écrit : >> Here is the new class comments I'm trying to write. >> I hope that it will help people to understand the circumstances under >> which they should use fractions:offset: creation API. >> >> >> >> 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 points 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)) >> >> because you are creating for nothing a new rectangle and some points. >> >> >> >> !! 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> >> >> > > > |
In reply to this post by Tudor Girba-2
Le 9/1/16 11:15, Tudor Girba a écrit : > Hi, > > This issue is still pending: > https://pharo.fogbugz.com/f/cases/7077/LayoutFrame-refactoring > > Let us fix the Glamour issues and then we can deprecate it. Yes please. I should said that I was discouraged when I saw Glamour code but this is easy to fix. There is one spec left and we can be done. I fixed the paginated I do not what. > > Cheers, > Doru > > >> On Jan 9, 2016, at 11:54 AM, Thierry Goubier <[hidden email]> wrote: >> >> Stef, >> >> could you deprecate the use of fractions:offsets: ? It's a nice way of shooting oneself in the foot. >> >> Create a LayoutFrame taking all space: >> >> LayoutFrame fractions: (0@0 corner: 1@1) >> >> right? >> >> Create a layout frame taking all space with an inset of three, so an offset of +3 left and above, and -3 right and bottom: >> >> LayoutFrame fractions: (0@0 corner: 1@1) offsets: (3@3 extent: -3@ -3) >> >> Fail! >> >> See what I mean? You have to forbid the use of a rectangle for offsets! >> >> (Note: I think the easiest API is the one used by Spec and Morphic: Rectangle asLayoutFrame topOffset: / bottomOffset ...) >> >> Thierry >> >> Le 09/01/2016 09:56, stepharo a écrit : >>> Here is the new class comments I'm trying to write. >>> I hope that it will help people to understand the circumstances under >>> which they should use fractions:offset: creation API. >>> >>> >>> >>> 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 points 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)) >>> >>> because you are creating for nothing a new rectangle and some points. >>> >>> >>> >>> !! 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> >>> >>> >> > -- > www.tudorgirba.com > www.feenk.com > > "The coherence of a trip is given by the clearness of the goal." > > > > > > > |
In reply to this post by stepharo
Le 09/01/2016 13:59, stepharo a écrit :
> Hi thierry >> Stef, >> >> could you deprecate the use of fractions:offsets: ? It's a nice way of >> shooting oneself in the foot. > Yes we should in fact. > Today I was thinking that there may be cases where this api makes sense > but your remark in the bug tracker > made me think and you are right. > >> Create a LayoutFrame taking all space: >> >> LayoutFrame fractions: (0@0 corner: 1@1) >> >> right? > better LayoutFrame identity :) Well, maybe the comment could say that the 0@0 corner: 1@1 rectangle is the identity ;) That this is the identity is not obvious in fact, unless you consider what algorithm is used to compute layouts. I tend to think that this (0@0 corner: 1@1) rectangle is the full area (the max area?)... not the identity of something. Why not LayoutFrame fullFrame ? Thierry |
> On Jan 9, 2016, at 9:09 PM, Thierry Goubier <[hidden email]> wrote: > > Le 09/01/2016 13:59, stepharo a écrit : >> Hi thierry >>> Stef, >>> >>> could you deprecate the use of fractions:offsets: ? It's a nice way of >>> shooting oneself in the foot. >> Yes we should in fact. >> Today I was thinking that there may be cases where this api makes sense >> but your remark in the bug tracker >> made me think and you are right. >> >>> Create a LayoutFrame taking all space: >>> >>> LayoutFrame fractions: (0@0 corner: 1@1) >>> >>> right? >> better LayoutFrame identity :) > > Well, maybe the comment could say that the 0@0 corner: 1@1 rectangle is the identity ;) > > That this is the identity is not obvious in fact, unless you consider what algorithm is used to compute layouts. I tend to think that this (0@0 corner: 1@1) rectangle is the full area (the max area?)... not the identity of something. > > Why not LayoutFrame fullFrame ? Indeed, this sounds better. Doru > Thierry -- www.tudorgirba.com www.feenk.com "Be rather willing to give than demanding to get." |
Yes fullFrame would be better.
Now we should rewrite all the senders and I do not have cycles now for that. But if people want to do a pass go ahead. better LayoutFrame identity :) >> Well, maybe the comment could say that the 0@0 corner: 1@1 rectangle is the identity ;) No because we do not want to have rectangle anymore. >> >> That this is the identity is not obvious in fact, unless you consider what algorithm is used to compute layouts. I tend to think that this (0@0 corner: 1@1) rectangle is the full area (the max area?)... not the identity of something. >> >> Why not LayoutFrame fullFrame ? > Indeed, this sounds better. > > Doru > >> Thierry > -- > www.tudorgirba.com > www.feenk.com > > "Be rather willing to give than demanding to get." > > > > > > |
Free forum by Nabble | Edit this page |