Card layout in Bloc?

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

Card layout in Bloc?

Stephan Eggermont-3
I'm looking at a way to layout the drag wells in a drag panel.
I would like the width of the panel to remain constant, and the
submorphs to be layed out flowing into new rows. How do I do that
with the new layout strategies?

Stephan


Reply | Threaded
Open this post in threaded view
|

Re: Card layout in Bloc?

Pharo Smalltalk Developers mailing list
Hello again Stephan,
yes, you need a kind of TableLayout for Bloc.
Not available for now, maybe Alex have a flow layout policy in Brick.
If not, I will try to revive the BlTableLayoutStrategy that I’ve made a the very
beginning of Bloc by porting TableLayout to local coordinate.
I am eager to see your card layout in Bloc :)

Cheers
Alain

> On 14 Jul 2015, at 15:21, Stephan Eggermont <[hidden email]> wrote:
>
> I'm looking at a way to layout the drag wells in a drag panel.
> I would like the width of the panel to remain constant, and the
> submorphs to be layed out flowing into new rows. How do I do that
> with the new layout strategies?
>
> Stephan
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Card layout in Bloc?

Stephan Eggermont-3
Writing a LayoutStrategy in Bloc can be easy.
Generic layout strategies get complex because
they can be parametrized a lot. That tends to
distract from the essentials.

In this case, all I need is a strategy that
adds submorphs from left to right in the panel,
breaking to a new line when it is full, and
recalculate the height when finished.

A LayoutStrategy needs to provide only one
method #layout:in:. In that, the morph and its
submorphs need to be layouted in the proposed
bounds. These bounds can be changed. Resizing
needs to happen with #innerExtent:, not with
#extent: as that results in a non-interruptible
loop.

Instead of using #submorphsDo, Bloc uses
#layoutComponentsDo:.

BlCardLayout>>layout: aMorph in: newBounds
        |offset maxHeight|
        offset := 0@0.
        maxHeight := 0.
        aMorph layoutComponentsDo: [ :component |
                offset x + component width > newBounds width ifTrue: [
                        "start a new line"
                        offset := 0@ (offset y + maxHeight).
                        maxHeight := 0].
                component position: offset.
                maxHeight := maxHeight max: component height.
                offset := (offset x + component width) @ offset y].
        maxHeight + offset y > aMorph height ifTrue: [
                aMorph innerExtent: aMorph innerExtent x @ (maxHeight+ offset y)]

For the card wall I'll need to add margin and inset.

Stephan



Reply | Threaded
Open this post in threaded view
|

Re: Card layout in Bloc?

Pharo Smalltalk Developers mailing list

> BlCardLayout>>layout: aMorph in: newBounds
> |offset maxHeight|
> offset := 0@0.
> maxHeight := 0.
> aMorph layoutComponentsDo: [ :component |
> offset x + component width > newBounds width ifTrue: [
> "start a new line"
> offset := 0@ (offset y + maxHeight).
> maxHeight := 0].
> component position: offset.
> maxHeight := maxHeight max: component height.
> offset := (offset x + component width) @ offset y].
> maxHeight + offset y > aMorph height ifTrue: [
> aMorph innerExtent: aMorph innerExtent x @ (maxHeight+ offset y)]

cool, can you commit your BlCardLayout  into the bloc repo?

>
> For the card wall I'll need to add margin and inset.

A BlSolidRectangleBorder can have an inset and an outset (as a margin I guess).

Cheers
Alain


>
> Stephan
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Card layout in Bloc?

Stephan Eggermont-3
On 14-07-15 22:18, Alain Plantec via Pharo-dev wrote:
 >cool, can you commit your BlCardLayout  into the bloc repo?

I copied Bloc-DragPanels into the bloc repo.

Stephan


Reply | Threaded
Open this post in threaded view
|

Re: Card layout in Bloc?

Pharo Smalltalk Developers mailing list
I’ve changed it to have the label at the top of the card

Cheers
Alain

> On 15 Jul 2015, at 08:06, Stephan Eggermont <[hidden email]> wrote:
>
> On 14-07-15 22:18, Alain Plantec via Pharo-dev wrote:
> >cool, can you commit your BlCardLayout  into the bloc repo?
>
> I copied Bloc-DragPanels into the bloc repo.
>
> Stephan
>
>