spec column/ row layout

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

spec column/ row layout

Sebastian Heidbrink-2
 What is wrong with this spec?
Why is the checkbox attached to the buttom? I would have expected it to be directly underneath the password label.
Is this default behavior and how can I prevent this?


defaultSpec
    <spec: #default>
    ^SpecLayout composed
      newColumn: [ :col |
        col
          newRow: [ :row |
            row
              add: #usernameLabel ;
              add: #usernameField ]
          height: self inputTextHeight;
          newRow: [ :row |
            row
              add: #passwordLabel;
              add: #passwordField ]
          height: self inputTextHeight;
            newRow: [ :row |
            row
              add: #showPasswordCheckBox]
          height: self inputTextHeight  ];
       yourself

Thank you
Sebastian


screen.png (21K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: spec column/ row layout

Peter Uhnak
Hi Sebastian,

the problem is that the layout tries to always take all the available space.
What I usually do is add an empty row at the bottom
newRow: [ :row | ]
to take all the excessive space.

Peter

On Sat, Feb 14, 2015 at 12:52 AM, Sebastian Heidbrink <[hidden email]> wrote:
 What is wrong with this spec?
Why is the checkbox attached to the buttom? I would have expected it to be directly underneath the password label.
Is this default behavior and how can I prevent this?


defaultSpec
    <spec: #default>
    ^SpecLayout composed
      newColumn: [ :col |
        col
          newRow: [ :row |
            row
              add: #usernameLabel ;
              add: #usernameField ]
          height: self inputTextHeight;
          newRow: [ :row |
            row
              add: #passwordLabel;
              add: #passwordField ]
          height: self inputTextHeight;
            newRow: [ :row |
            row
              add: #showPasswordCheckBox]
          height: self inputTextHeight  ];
       yourself

Thank you
Sebastian


Reply | Threaded
Open this post in threaded view
|

Re: spec column/ row layout

HilaireFernandes
In reply to this post by Sebastian Heidbrink-2
Le 14/02/2015 00:52, Sebastian Heidbrink a écrit :
>  What is wrong with this spec?
> Why is the checkbox attached to the buttom? I would have expected it
> to be directly underneath the password label.
> Is this default behavior and how can I prevent this?
>
I don't know spec at all, but it looks like a shrink attributes should
be used. May be there is on the spec api.

Hilaire

--
Dr. Geo - http://drgeo.eu
iStoa - http://istoa.drgeo.eu



Reply | Threaded
Open this post in threaded view
|

Re: spec column/ row layout

HilaireFernandes
Le 14/02/2015 10:21, Hilaire a écrit :

> Le 14/02/2015 00:52, Sebastian Heidbrink a écrit :
>>  What is wrong with this spec?
>> Why is the checkbox attached to the buttom? I would have expected it
>> to be directly underneath the password label.
>> Is this default behavior and how can I prevent this?
>>
> I don't know spec at all, but it looks like a shrink attributes should
> be used. May be there is on the spec api.
>
> Hilaire
>
Another remark, why is
          height: self inputTextHeight;
needed?

Should not spec have a default automatic way to set it, deducing from
the row contents?

Hilaire

--
Dr. Geo - http://drgeo.eu
iStoa - http://istoa.drgeo.eu



Reply | Threaded
Open this post in threaded view
|

Re: spec column/ row layout

Peter Uhnak

Another remark, why is
          height: self inputTextHeight;
needed?

Should not spec have a default automatic way to set it, deducing from
the row contents?
 
Actually it would do the opposite. The content has no fixed height so if you don't specify the height it will actually expand the content (the layout always uses all available space if not constrained).

You can see for yourself if you remove the height here...

=================================
view := DynamicComposableModel new
    instantiateModels: #(
usernameLabel LabelModel usernameField TextInputFieldModel
passwordLabel LabelModel passwordField TextInputFieldModel
showPasswordCheckBox CheckBoxModel
);
yourself.

view usernameLabel text: 'Username'.
view passwordLabel text: 'Password'.
view showPasswordCheckBox label: 'Show password'.

layout := SpecLayout composed
newColumn: [ :col |
col
newRow: [ :row |
row
add: #usernameLabel;
add: #usernameField ] height: DynamicComposableModel inputTextHeight;
newRow: [ :row |
row
add: #passwordLabel;
add: #passwordField ] height: DynamicComposableModel inputTextHeight;
newRow: [ :row |
row
add: #showPasswordCheckBox] height: DynamicComposableModel inputTextHeight;
newRow: [ :row | ]
];
yourself.
   
view openWithSpecLayout: layout.
=====================================

Peter
Reply | Threaded
Open this post in threaded view
|

Re: spec column/ row layout

Peter Uhnak
However the more worrying thing I've just noticed is that the usernameField is taller than passwordField... that seems like a bug.

Peter
Reply | Threaded
Open this post in threaded view
|

Re: spec column/ row layout

Sebastian Heidbrink-2
In reply to this post by HilaireFernandes
Hmmm I don't know!

It was from the examples :-D

Sebastian

Am 14.02.2015 um 01:25 schrieb Hilaire:

> Le 14/02/2015 10:21, Hilaire a écrit :
>> Le 14/02/2015 00:52, Sebastian Heidbrink a écrit :
>>>   What is wrong with this spec?
>>> Why is the checkbox attached to the buttom? I would have expected it
>>> to be directly underneath the password label.
>>> Is this default behavior and how can I prevent this?
>>>
>> I don't know spec at all, but it looks like a shrink attributes should
>> be used. May be there is on the spec api.
>>
>> Hilaire
>>
> Another remark, why is
>            height: self inputTextHeight;
> needed?
>
> Should not spec have a default automatic way to set it, deducing from
> the row contents?
>
> Hilaire
>


Reply | Threaded
Open this post in threaded view
|

Re: spec column/ row layout

HilaireFernandes
In reply to this post by Peter Uhnak
Le 14/02/2015 10:42, Peter Uhnák a écrit :
> Actually it would do the opposite. The content has no fixed height so
> if you don't specify the height it will actually expand the content
> (the layout always uses all available space if not constrained).
>
But should it not shrink by default? It will be both easier and make
more sense

Hilaire

--
Dr. Geo - http://drgeo.eu
iStoa - http://istoa.drgeo.eu



Reply | Threaded
Open this post in threaded view
|

Re: spec column/ row layout

Peter Uhnak
On Sat, Feb 14, 2015 at 7:26 PM, Hilaire <[hidden email]> wrote:
Le 14/02/2015 10:42, Peter Uhnák a écrit :
> Actually it would do the opposite. The content has no fixed height so
> if you don't specify the height it will actually expand the content
> (the layout always uses all available space if not constrained).
>
But should it not shrink by default? It will be both easier and make
more sense
 
It would definitely make sense, especially considering we are basically setting the height of input text to "inputTextHeight". :)

But then again, there are many things in Spec that would need to be addressed, so some extra work will be required in many areas for some time.

Peter