Hi all,
does Morphic has an equivalent of JavaScript's 'display: none'? #show/#hide/#visible: reserve space for the hidden morph. However, there are other scenarios where you do not want to reserve space. (A simple example would be a list that should only appear iff it has items.) In JS, you can use 'display: none' instead of 'visibility: hidden' to give the space back to the element's remaining siblings. But in Morphic, is there currently any better option than #delete (and #addMorph:) later?
(IMO, delete'n'add is not always the best pattern to do this. You need to remember the index and owner of the relevant morph for adding it later.)
Provided that I did not overlook any existing features, would you consider this a useful extension for Morphic? I was thinking of a property (#skipLayout, if you do not have any better idea) and a convenience method (#nonSkippedSubmorphs) that rejects suppressed submorphs. TableLayout would need to use this selector instead of regular #submorphs. Or would this break too many existing things that rely on #submorphs?
Another approach would be a selector in the TableLayoutProperties to have all submorphs skipped that are hidden via classical #visible. But this would be less powerful as you couldn't combine both kinds of hiding in the same morph. But maybe this would be even better in terms of avoiding complexity?
I'm looking forward to your opinions.
Best, Christoph
Carpe Squeak!
|
> #show/#hide/#visible: reserve space for the hidden morph. However, there
> are other scenarios where you do not want to reserve space. (A simple > example would be a list that should only appear iff it has items.) You could have such a "removed morph" temporarily #become: a collapsed representation (like a flat invisible morph for a list item), and then swap it back when you need it. I have used that pattern; #become: is fast. > > In JS, you can use 'display: none' instead of 'visibility: hidden' to > give the space back to the element's remaining siblings. > > But in Morphic, is there currently any better option than #delete (and > #addMorph:) later? > > > (IMO, delete'n'add is not always the best pattern to do this. You > need to remember the index and owner of the relevant morph for adding it > later.) > > > Provided that I did not overlook any existing features, would you > consider this a useful extension for Morphic? No. I think this should be implemented either via specific mophs or via specific layout (probably yet to be invented). > > I was thinking of a property (#skipLayout, if you do not have any better > idea) and a convenience method (#nonSkippedSubmorphs) that > rejects suppressed submorphs. TableLayout would need to use this > selector instead of regular #submorphs. > > Or would this break too many existing things that rely on #submorphs? Oh, yes, please do not add any logic to #submorphs. It is a plain array and a lot of things rely on this. You can implement a wrapper Morph with all that logic, instead. > > > Another approach would be a selector in the TableLayoutProperties > to have all submorphs skipped that are hidden via classical #visible. > But this would be less powerful as you couldn't combine both kinds of > hiding in the same morph. But maybe this would be even better in terms > of avoiding complexity? Not a good idea IMO to use a property tag to represent another property. #visible should just be about visibility. Best, Stef |
Hi! Yes, there is: aMorph disableLayout: true; visible: false. Best, Marcel
|
In reply to this post by Stéphane Rollandin
> You could have such a "removed morph" temporarily #become: a collapsed representation (like a flat invisible morph for a list item), and then swap it back when you need it. I have used that pattern; #become: is fast. Hm, this does not convince me. :-) #become: replaces all references to the original morph. I could not access or modify any part of it during it is collapsed, or I would need to deal with a second variable. This feels like unnecessary metaprogramming.
> Oh, yes, please do not add any logic to #submorphs. It is a plain array and a lot of things rely on this. You can implement a wrapper Morph with all
that logic, instead.
I may have expressed myself wrong - I would never override #submorphs, I meant to introduce a second selector, #nonSkippedSubmorphs.
So your general advice is to introduce a special morph that supports morph skipping? The disadvantages of this approach would the limitation that you cannot skip morphs in any regular morphs such as MorphicModels, RectangleMorphs etc. ... I would rather
like to use a layout for this.
Best,
Christoph
Von: Squeak-dev <[hidden email]> im Auftrag von Stéphane Rollandin <[hidden email]>
Gesendet: Freitag, 3. April 2020 17:48:16 An: [hidden email] Betreff: Re: [squeak-dev] Morphic equivalent of 'display: none'? > #show/#hide/#visible: reserve space for the hidden morph. However, there
> are other scenarios where you do not want to reserve space. (A simple > example would be a list that should only appear iff it has items.) You could have such a "removed morph" temporarily #become: a collapsed representation (like a flat invisible morph for a list item), and then swap it back when you need it. I have used that pattern; #become: is fast. > > In JS, you can use 'display: none' instead of 'visibility: hidden' to > give the space back to the element's remaining siblings. > > But in Morphic, is there currently any better option than #delete (and > #addMorph:) later? > > > (IMO, delete'n'add is not always the best pattern to do this. You > need to remember the index and owner of the relevant morph for adding it > later.) > > > Provided that I did not overlook any existing features, would you > consider this a useful extension for Morphic? No. I think this should be implemented either via specific mophs or via specific layout (probably yet to be invented). > > I was thinking of a property (#skipLayout, if you do not have any better > idea) and a convenience method (#nonSkippedSubmorphs) that > rejects suppressed submorphs. TableLayout would need to use this > selector instead of regular #submorphs. > > Or would this break too many existing things that rely on #submorphs? Oh, yes, please do not add any logic to #submorphs. It is a plain array and a lot of things rely on this. You can implement a wrapper Morph with all that logic, instead. > > > Another approach would be a selector in the TableLayoutProperties > to have all submorphs skipped that are hidden via classical #visible. > But this would be less powerful as you couldn't combine both kinds of > hiding in the same morph. But maybe this would be even better in terms > of avoiding complexity? Not a good idea IMO to use a property tag to represent another property. #visible should just be about visibility. Best, Stef
Carpe Squeak!
|
In reply to this post by marcel.taeumel
Perfect! Thanks, Marcel! :-)
Best, Christoph Von: Squeak-dev <[hidden email]> im Auftrag von Taeumel, Marcel
Gesendet: Freitag, 3. April 2020 18:59:44 An: John Pfersich via Squeak-dev Betreff: Re: [squeak-dev] Morphic equivalent of 'display: none'?
Hi!
Yes, there is:
aMorph
disableLayout: true;
visible: false.
Best,
Marcel
Carpe Squeak!
|
In reply to this post by Christoph Thiede
> > You could have such a "removed morph" temporarily #become: a
> collapsed representation (like a flat invisible morph for a list item), > and then swap it back when you need it. I have used that pattern; > #become: is fast. > > > Hm, this does not convince me. :-) #become: replaces all references to > the original morph. I could not access or modify any part of it during > it is collapsed, or I would need to deal with a second variable. This > feels like unnecessary metaprogramming. True. > > > Oh, yes, please do not add any logic to #submorphs. It is a plain > array and a lot of things rely on this. You can implement a wrapper > Morph with all that logic, instead. > > I may have expressed myself wrong - I would never override #submorphs, I > meant to introduce a second selector, #nonSkippedSubmorphs. Hmm.. the name in itself is a code smell :) > So your general advice is to introduce a special morph that supports > morph skipping? The disadvantages of this approach would the limitation > that you cannot skip morphs in any regular morphs such as MorphicModels, > RectangleMorphs etc. ... I would rather like to use a layout for this. Yes, if you plan to use this skipping functionality transversaly over a range of already existing morphs, a layout is probably the way to go. Stef |
However, #disableLayout is exactly what I was searching for. I do not think that we need any additional layout stuff for it. Thanks for your help, Stef! :-)
Best, Christoph Von: Squeak-dev <[hidden email]> im Auftrag von Stéphane Rollandin <[hidden email]>
Gesendet: Freitag, 3. April 2020 23:07:39 An: [hidden email] Betreff: Re: [squeak-dev] Morphic equivalent of 'display: none'? > > You could have such a "removed morph" temporarily #become: a
> collapsed representation (like a flat invisible morph for a list item), > and then swap it back when you need it. I have used that pattern; > #become: is fast. > > > Hm, this does not convince me. :-) #become: replaces all references to > the original morph. I could not access or modify any part of it during > it is collapsed, or I would need to deal with a second variable. This > feels like unnecessary metaprogramming. True. > > > Oh, yes, please do not add any logic to #submorphs. It is a plain > array and a lot of things rely on this. You can implement a wrapper > Morph with all that logic, instead. > > I may have expressed myself wrong - I would never override #submorphs, I > meant to introduce a second selector, #nonSkippedSubmorphs. Hmm.. the name in itself is a code smell :) > So your general advice is to introduce a special morph that supports > morph skipping? The disadvantages of this approach would the limitation > that you cannot skip morphs in any regular morphs such as MorphicModels, > RectangleMorphs etc. ... I would rather like to use a layout for this. Yes, if you plan to use this skipping functionality transversaly over a range of already existing morphs, a layout is probably the way to go. Stef
Carpe Squeak!
|
Free forum by Nabble | Edit this page |