Custom layout in Spec

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

Custom layout in Spec

webwarrior
I want to make a layout based on TableLayout.

Taking SpecLayout as example, it seems that I also have to create model class similar to ContainerModel and adapter for it.

However, I noticed that SpecInterpreter has some hardcoded behaviour for ContainerModel in computeSpecFrom:selector: method. Is this behaviour really important, and if yes, how can I replicate it?
Reply | Threaded
Open this post in threaded view
|

Re: Custom layout in Spec

jfabry
Hi,

I don’t know what your requirements are for a table layout, but have you tried using rows and columns? Maybe this can already solve your issue.

Have a look at the documentation for Spec, maybe the PFTE book chapter can be of more help. At least it shows an example of use of rows and columns.

https://ci.inria.fr/pharo-contribution/job/PharoForTheEnterprise/lastSuccessfulBuild/artifact/Spec/

On Jun 8, 2014, at 9:21 AM, webwarrior <[hidden email]> wrote:

> I want to make a layout based on TableLayout.
>
> Taking SpecLayout as example, it seems that I also have to create model
> class similar to ContainerModel and adapter for it.
>
> However, I noticed that SpecInterpreter has some hardcoded behaviour for
> ContainerModel in computeSpecFrom:selector: method. Is this behaviour really
> important, and if yes, how can I replicate it?
>
>
>
>
> --
> View this message in context: http://forum.world.st/Custom-layout-in-Spec-tp4762142.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>
>



---> Save our in-boxes! http://emailcharter.org <---

Johan Fabry   -   http://pleiad.cl/~jfabry
PLEIAD lab  -  Computer Science Department (DCC)  -  University of Chile


Reply | Threaded
Open this post in threaded view
|

Re: Custom layout in Spec

webwarrior
My main requirements are such that container respects sizes and resizing behaviour (hResizing, vResizing) of its child elements.

Proportional layout doesn't allow that.

And yes, I've read Spec documentation and some Morphic documentation.
Reply | Threaded
Open this post in threaded view
|

Re: Custom layout in Spec

jfabry

I have been able to get size respecting behavior using rows and columns, by giving newColumn:width: and newRow:width. Combined with splitters (the  addSplitter message) this has worked well for me (modulo some bugs). If you need more complex behavior than that I’m afraid I cannot help you.

On Jun 8, 2014, at 3:39 PM, webwarrior <[hidden email]> wrote:

> My main requirements are such that container respects sizes and resizing
> behaviour (hResizing, vResizing) of its child elements.
>
> Proportional layout doesn't allow that.
>
> And yes, I've read Spec documentation and some Morphic documentation.
>
>
>
> --
> View this message in context: http://forum.world.st/Custom-layout-in-Spec-tp4762142p4762213.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>
>



---> Save our in-boxes! http://emailcharter.org <---

Johan Fabry   -   http://pleiad.cl/~jfabry
PLEIAD lab  -  Computer Science Department (DCC)  -  University of Chile


Reply | Threaded
Open this post in threaded view
|

Re: Custom layout in Spec

Benjamin Van Ryseghem (Pharo)
In reply to this post by webwarrior
On 08 Jun 2014, at 15:21, webwarrior <[hidden email]> wrote:

> I want to make a layout based on TableLayout.

Short answer: it’s not really supported yet.

If you want to give it a try, it’s really welcome ;)

> However, I noticed that SpecInterpreter has some hardcoded behaviour for
> ContainerModel in computeSpecFrom:selector: method. Is this behaviour really
> important, and if yes, how can I replicate it?

It’s really needed (even thought I do not remember why exactly now (but I think it’s to prevent some infinite loops)).

The solution as I was thinking about it would be to have a different keyword per layout.
Today, you start your layout with `SpecLayout composed`, where it could be `SpecLayout table`.

Or it could be `SpecTableLayout composed`.

The main issue you will have is that Spec does not directly rely on Morphic layouts.
So you will have to implement some layouting algorithm by yourself.

Hope it helps,
Ben
Reply | Threaded
Open this post in threaded view
|

Re: Custom layout in Spec

webwarrior
I implemented SpecTableLayout, which uses TableLayout policy.
Wasn't that hard, beacuse actual layouting is done in Morphic.

Interface of SpecTableLayout is somewhat similar to SpecLayout.
All table layout options are supported (see http://wiki.squeak.org/squeak/2340).
One thing that is not part of TableLayout and was added by me is spacer - invisible element that is either fixed size or flexible (aka spring).

Most Spec widgets were designed to occupy all available space, and in order to change that they may be wrapped into single-element table layout. This is done using #add:wrapped: or #add:withSpec:wrapped with last argument being block (a similar to #newRow: and #newColumn:).
For example:
^ SpecTableLayout row 
    add: #toolbar wrapped: [ :e | e hResizing: #shrinkWrap ];

Now I wonder how do I transfer these changes from Monticello to GitHub in order to make pull request?
Reply | Threaded
Open this post in threaded view
|

Re: Custom layout in Spec

Benjamin Van Ryseghem (Pharo)
On 13 Jun 2014, at 17:09, webwarrior <[hidden email]> wrote:

> I implemented SpecTableLayout, which uses TableLayout policy.

Cool :)

> Wasn't that hard, beacuse actual layouting *is* done in Morphic.

It is not.
That’s exactly why SpecLayoutFrame exists by example.

You can convert Spec layout into morphic layout to use in the case of Morphic
but this is decoupled.

> For example:

I do not see your example here :S
Is my Mail.app missing to load a file or did you miss to insert something ?

> Now I wonder how do I transfer these changes from Monticello to GitHub in
> order to make pull request?

clone the repository (as you will do for any other github project)
then serialise your code via Monticello browser using “filetree"

Then you can commit, push, pull request

Thanks,
Ben
Reply | Threaded
Open this post in threaded view
|

Re: Custom layout in Spec

webwarrior
>> Wasn't that hard, beacuse actual layouting *is* done in Morphic.
>
> It is not. That’s exactly why SpecLayoutFrame exists by example.
>
> You can convert Spec layout into morphic layout to use in the case of
>  Morphic but this is decoupled.

Now I see what you mean. But my aim was to make a layout that works here
and now with Morphic.

>> For example:
>
> I do not see your example here :S Is my Mail.app missing to load a
> file or did you miss to insert something ?

It was just a section of code. Maybe your mail client doesn't show html?
It was the following:

^ SpecTableLayout row
     add: #toolbar wrapped: [ :e | e hResizing: #shrinkWrap ];
Reply | Threaded
Open this post in threaded view
|

Re: Custom layout in Spec

Benjamin Van Ryseghem (Pharo)


Ben

On 16 Jun 2014, at 15:01, webwarrior <[hidden email]> wrote:

>> Wasn't that hard, beacuse actual layouting *is* done in Morphic.
>
> It is not. That’s exactly why SpecLayoutFrame exists by example.
>
> You can convert Spec layout into morphic layout to use in the case of
>  Morphic but this is decoupled.

Now I see what you mean. But my aim was to make a layout that works here
and now with Morphic.

Ok :)

But one of the goals of Spec is to not be Morphic specific


>> For example:
>
> I do not see your example here :S Is my Mail.app missing to load a
> file or did you miss to insert something ?

It was just a section of code. Maybe your mail client doesn't show html?

Could be :s

It was the following:

^ SpecTableLayout row
     add: #toolbar wrapped: [ :e | e hResizing: #shrinkWrap ];

That sounds strange :)

Ben




View this message in context: Re: Custom layout in Spec
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.