You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by SYSE | Edvin <es...@syse.no> on 2011/07/12 17:55:03 UTC

IconView in Pivot

I find myself missing an IconView in Pivot more and more often. With 
IconView I mean a view that behaves like Windows Explorer in Icon mode.

Each cell flows horizontaly and wraps vertically when there is no more 
space.

Have anyone created a component like this? I've created some rudimentary 
versions myself, but it would be nice to have something as complete as 
TableView. If not, would it be any interest in such a component? I could 
do most of the work myself, but it would be good with some pointers:

What component is best suited as the base for an IconView? A GridPane 
sounded like a good plan until you need to account for resizing. I'm 
thinking FlowPane?

-- Edvin

Re: IconView in Pivot

Posted by Greg Brown <gk...@verizon.net>.
>> - I saw on https://issues.apache.org/jira/browse/PIVOT-276 that it was suggested that it had a fixed renderer size. What makes for a sensible default?
> 
> That means that it should assume a fixed renderer size - that is, it shouldn't expect the preferred size of each item to be different. That's what ListView does when the "variableItemHeight" style is set to false (the default). 

FYI, this is for performance reasons. When calculating the preferred size, it can simply ask the renderer once for its preferred size and use that to perform the calculations, rather than iterating over each item, rendering it, and calculating the max. pref. size of each item.

G


Re: IconView in Pivot

Posted by Greg Brown <gk...@verizon.net>.
>>>> That means that it should assume a fixed renderer size - that is, it shouldn't expect the preferred size of each item to be different. That's what ListView does when the "variableItemHeight" style is set to false (the default).
>>> 
>>> Ah, ofcourse. I'll adjust. What about the renderer's default ImageView, should it have a fixed size like in ListView, or should it be determined by the image that get's loaded into it?
>> 
>> The size should be fixed by the ImageView - if it depends on the image, then the renderer isn't guaranteed to have a fixed size.
> 
> Does that mean that I should set a default size on the ImageView that should be overridable, or how do I solve this? I'm mostly done with the rest of it, I'll supply a patch to PIVOT-276 after I've tested it a bit more :)

Yes, this is what ListViewItemRenderer does. It provides setters to allow a caller to control this size.


Re: IconView in Pivot

Posted by SYSE | Edvin <es...@syse.no>.
Den 13.07.2011 16:41, skrev Greg Brown:
>>> That means that it should assume a fixed renderer size - that is, it shouldn't expect the preferred size of each item to be different. That's what ListView does when the "variableItemHeight" style is set to false (the default).
>>
>> Ah, ofcourse. I'll adjust. What about the renderer's default ImageView, should it have a fixed size like in ListView, or should it be determined by the image that get's loaded into it?
>
> The size should be fixed by the ImageView - if it depends on the image, then the renderer isn't guaranteed to have a fixed size.

Does that mean that I should set a default size on the ImageView that 
should be overridable, or how do I solve this? I'm mostly done with the 
rest of it, I'll supply a patch to PIVOT-276 after I've tested it a bit 
more :)

-- Edvin

Re: IconView in Pivot

Posted by Greg Brown <gk...@verizon.net>.
>> That means that it should assume a fixed renderer size - that is, it shouldn't expect the preferred size of each item to be different. That's what ListView does when the "variableItemHeight" style is set to false (the default).
> 
> Ah, ofcourse. I'll adjust. What about the renderer's default ImageView, should it have a fixed size like in ListView, or should it be determined by the image that get's loaded into it?

The size should be fixed by the ImageView - if it depends on the image, then the renderer isn't guaranteed to have a fixed size.

>> Did you define a GridView.ItemRenderer interface and associated data class, etc.?
> 
> Yes I did. I must say you guys did a great job with Pivot's interfaces and structure - it was a joy working with this :)

Thanks.  :-)


Re: IconView in Pivot

Posted by SYSE | Edvin <es...@syse.no>.

Den 13.07.2011 01:42, skrev Greg Brown:
>> - I saw on https://issues.apache.org/jira/browse/PIVOT-276 that it was suggested that it had a fixed renderer size. What makes for a sensible default?
>
> That means that it should assume a fixed renderer size - that is, it shouldn't expect the preferred size of each item to be different. That's what ListView does when the "variableItemHeight" style is set to false (the default).

Ah, ofcourse. I'll adjust. What about the renderer's default ImageView, 
should it have a fixed size like in ListView, or should it be determined 
by the image that get's loaded into it?

> Did you define a GridView.ItemRenderer interface and associated data class, etc.?

Yes I did. I must say you guys did a great job with Pivot's interfaces 
and structure - it was a joy working with this :)

-- Edvin


Re: IconView in Pivot

Posted by Greg Brown <gk...@verizon.net>.
> I implemented a GridView component mostly modelled after ListView, complete with skin, events, keyboard navigation, selection (including multi) and binding. It's only painting components within the clipbounds and seems to be very performant.
> 
> See a short demo here:
> 
> https://edvin.viewscreencasts.com/2cd0ac2c9795422f875f8f048e3f8f80

That looks awesome!

> I have three questions:
> 
> - Should it support checkboxes?

I don't see a need for that. Anyone else?

> - Should it support databinding in the same way as ListView does?

That would be good. It shouldn't be too hard to hook up - you can probably copy most of the code from ListView.

> - I saw on https://issues.apache.org/jira/browse/PIVOT-276 that it was suggested that it had a fixed renderer size. What makes for a sensible default?

That means that it should assume a fixed renderer size - that is, it shouldn't expect the preferred size of each item to be different. That's what ListView does when the "variableItemHeight" style is set to false (the default). 

Did you define a GridView.ItemRenderer interface and associated data class, etc.?

G


Re: IconView in Pivot

Posted by SYSE | Edvin <es...@syse.no>.
Den 13.07.2011 07:52, skrev Chris Bartlett:
> On 13 July 2011 06:36, SYSE | Edvin<es...@syse.no>  wrote:
>> Den 12.07.2011 18:34, skrev SYSE | Edvin:
>> - Should it support checkboxes?
> I personally don't see a need for them, but if you have already
> written the code for them, then it is probably not worth the effort of
> ripping it out.
> If it is not already written, then it can be added at a later date if
> the need arises.

I wrote most of it, but I think I'll remove it for now, I had a hard 
time coming up with a usecase, and it does complicate the code a bit.

-- Edvin

Re: IconView in Pivot

Posted by Sandro Martini <sa...@gmail.com>.
Edvin, good work.
I hope will be included on Pivot.
Bye
Il giorno 13/lug/2011 07:53, "Chris Bartlett" <cb...@gmail.com> ha
scritto:
> On 13 July 2011 06:36, SYSE | Edvin <es...@syse.no> wrote:
>> Den 12.07.2011 18:34, skrev SYSE | Edvin:
>> - Should it support checkboxes?
> I personally don't see a need for them, but if you have already
> written the code for them, then it is probably not worth the effort of
> ripping it out.
> If it is not already written, then it can be added at a later date if
> the need arises.

Re: IconView in Pivot

Posted by Chris Bartlett <cb...@gmail.com>.
On 13 July 2011 06:36, SYSE | Edvin <es...@syse.no> wrote:
> Den 12.07.2011 18:34, skrev SYSE | Edvin:
> - Should it support checkboxes?
I personally don't see a need for them, but if you have already
written the code for them, then it is probably not worth the effort of
ripping it out.
If it is not already written, then it can be added at a later date if
the need arises.

Re: IconView in Pivot

Posted by SYSE | Edvin <es...@syse.no>.
Den 12.07.2011 18:34, skrev SYSE | Edvin:
> Den 12.07.2011 18:29, skrev Greg Brown:
>> You might want to look at ListView - TableView is a bit more complex.
>
> Ah ofcourse :) Thanks, I'll take this exercise to get to know
> painting/skins etc a little better :)

I implemented a GridView component mostly modelled after ListView, 
complete with skin, events, keyboard navigation, selection (including 
multi) and binding. It's only painting components within the clipbounds 
and seems to be very performant.

See a short demo here:

https://edvin.viewscreencasts.com/2cd0ac2c9795422f875f8f048e3f8f80

I pulled some facebook photos and names, and use the default ItemRenderer.

I would like to contribute this to Pivot when it is done. I will try to 
polish it a bit after work tomorrow and show you the code :)

I have three questions:

- Should it support checkboxes?
- Should it support databinding in the same way as ListView does?
- I saw on https://issues.apache.org/jira/browse/PIVOT-276 that it was 
suggested that it had a fixed renderer size. What makes for a sensible 
default?

-- Edvin

Re: IconView in Pivot

Posted by SYSE | Edvin <es...@syse.no>.
Den 12.07.2011 18:29, skrev Greg Brown:
> You might want to look at ListView - TableView is a bit more complex.

Ah ofcourse :) Thanks, I'll take this exercise to get to know 
painting/skins etc a little better :)

Re: IconView in Pivot

Posted by Greg Brown <gk...@verizon.net>.
You might want to look at ListView - TableView is a bit more complex.

On Jul 12, 2011, at 12:18 PM, SYSE | Edvin wrote:

> Den 12.07.2011 18:10, skrev SYSE | Edvin:
>> Den 12.07.2011 18:07, skrev Chris Bartlett:
>>> GridView = ( FlowPane/GridPane + internal List<?> + renderers +
>>> selection logic + keyboard handling ) ?
>>> 
>>> On 12 July 2011 23:03, Greg Brown<gk...@verizon.net> wrote:
>>>> I don't think you'd want to use either GridPane or FlowPane as a
>>>> basis for this component - those are containers, whereas I think what
>>>> you want is a data-driven component.
>> 
>> I found https://issues.apache.org/jira/browse/PIVOT-276. I was thinking
>> the same as Chris is describing here. Why is FlowPane not a good base?
> 
> I've been looking at the code for TerraTableViewSkin, so I see now that that was a stupid question :) Wondering if I should try to create a GridView by stealing ideas from TableView...
> 
> -- Edvin


Re: IconView in Pivot

Posted by SYSE | Edvin <es...@syse.no>.
Den 12.07.2011 18:10, skrev SYSE | Edvin:
> Den 12.07.2011 18:07, skrev Chris Bartlett:
>> GridView = ( FlowPane/GridPane + internal List<?> + renderers +
>> selection logic + keyboard handling ) ?
>>
>> On 12 July 2011 23:03, Greg Brown<gk...@verizon.net> wrote:
>>> I don't think you'd want to use either GridPane or FlowPane as a
>>> basis for this component - those are containers, whereas I think what
>>> you want is a data-driven component.
>
> I found https://issues.apache.org/jira/browse/PIVOT-276. I was thinking
> the same as Chris is describing here. Why is FlowPane not a good base?

I've been looking at the code for TerraTableViewSkin, so I see now that 
that was a stupid question :) Wondering if I should try to create a 
GridView by stealing ideas from TableView...

-- Edvin

Re: IconView in Pivot

Posted by Greg Brown <gk...@verizon.net>.
FlowPane is a container. I'm assuming you want a data-driven component.

On Jul 12, 2011, at 12:10 PM, SYSE | Edvin wrote:

> Den 12.07.2011 18:07, skrev Chris Bartlett:
>> GridView = ( FlowPane/GridPane + internal List<?>  + renderers +
>> selection logic + keyboard handling ) ?
>> 
>> On 12 July 2011 23:03, Greg Brown<gk...@verizon.net>  wrote:
>>> I don't think you'd want to use either GridPane or FlowPane as a basis for this component - those are containers, whereas I think what you want is a data-driven component.
> 
> I found https://issues.apache.org/jira/browse/PIVOT-276. I was thinking the same as Chris is describing here. Why is FlowPane not a good base?
> 
> -- Edvin


Re: IconView in Pivot

Posted by SYSE | Edvin <es...@syse.no>.
Den 12.07.2011 18:07, skrev Chris Bartlett:
> GridView = ( FlowPane/GridPane + internal List<?>  + renderers +
> selection logic + keyboard handling ) ?
>
> On 12 July 2011 23:03, Greg Brown<gk...@verizon.net>  wrote:
>> I don't think you'd want to use either GridPane or FlowPane as a basis for this component - those are containers, whereas I think what you want is a data-driven component.

I found https://issues.apache.org/jira/browse/PIVOT-276. I was thinking 
the same as Chris is describing here. Why is FlowPane not a good base?

-- Edvin

Re: IconView in Pivot

Posted by Chris Bartlett <cb...@gmail.com>.
GridView = ( FlowPane/GridPane + internal List<?> + renderers +
selection logic + keyboard handling ) ?

On 12 July 2011 23:03, Greg Brown <gk...@verizon.net> wrote:
> I don't think you'd want to use either GridPane or FlowPane as a basis for this component - those are containers, whereas I think what you want is a data-driven component.
>
> I think there is a JIRA ticked for a "GridView" component that might be similar to what you are describing.
>
> On Jul 12, 2011, at 11:55 AM, SYSE | Edvin wrote:
>
>> I find myself missing an IconView in Pivot more and more often. With IconView I mean a view that behaves like Windows Explorer in Icon mode.
>>
>> Each cell flows horizontaly and wraps vertically when there is no more space.
>>
>> Have anyone created a component like this? I've created some rudimentary versions myself, but it would be nice to have something as complete as TableView. If not, would it be any interest in such a component? I could do most of the work myself, but it would be good with some pointers:
>>
>> What component is best suited as the base for an IconView? A GridPane sounded like a good plan until you need to account for resizing. I'm thinking FlowPane?
>>
>> -- Edvin
>
>

Re: IconView in Pivot

Posted by Greg Brown <gk...@verizon.net>.
I don't think you'd want to use either GridPane or FlowPane as a basis for this component - those are containers, whereas I think what you want is a data-driven component.

I think there is a JIRA ticked for a "GridView" component that might be similar to what you are describing. 

On Jul 12, 2011, at 11:55 AM, SYSE | Edvin wrote:

> I find myself missing an IconView in Pivot more and more often. With IconView I mean a view that behaves like Windows Explorer in Icon mode.
> 
> Each cell flows horizontaly and wraps vertically when there is no more space.
> 
> Have anyone created a component like this? I've created some rudimentary versions myself, but it would be nice to have something as complete as TableView. If not, would it be any interest in such a component? I could do most of the work myself, but it would be good with some pointers:
> 
> What component is best suited as the base for an IconView? A GridPane sounded like a good plan until you need to account for resizing. I'm thinking FlowPane?
> 
> -- Edvin