Home » Eclipse Projects » Nebula » Newbie Gallery questions
Newbie Gallery questions [message #479472] |
Tue, 11 August 2009 05:30  |
Eclipse User |
|
|
|
The Gallery widget is working for me, but I have issues with the item
sizes.
I want to show prescaled images (thumbnails) and I don't want the gallery
to mess with the size of them. They are all in the range 1-160 pixels in
width and in height, but the Gallery widget -- with the default item
renderer -- will scale them all to the same size.
I want them to be shown untouched in a 160x160 region, can this be done?
Here comes the next question. When I set item size to 160 x 160 it is not
the region reserved for the image but for the whole item with caption and
margins.
Can I control the region reserved for the image?
Because if I can I can box the smaller ones inside a 160x160 black image.
Thomas
|
|
|
Re: Newbie Gallery questions [message #479480 is a reply to message #479472] |
Tue, 11 August 2009 06:05   |
Eclipse User |
|
|
|
Hi Thomas,
This is exactly why Gallery supports pluggable item renderers. In your case, you should just create a new ItemRenderer by extending AbstractItemRenderer.
During redraw, 'draw' is invoked for each item.
public void draw(GC gc, GalleryItem item, int index, int x, int y,
int width, int height) {
you get an untouched area you can paint as you wish, without resizing.
width and height are the one defined with setItemSize(). If you want to draw labels, just add a little room for them.
(You can even contribute your item renderer to Nebula )
--
Nicolas
|
|
|
Re: Newbie Gallery questions [message #479653 is a reply to message #479480] |
Tue, 11 August 2009 16:24  |
Eclipse User |
|
|
|
Nicolas Richeton wrote:
> Hi Thomas,
> This is exactly why Gallery supports pluggable item renderers. In your case,
you should just create a new ItemRenderer by extending AbstractItemRenderer.
> During redraw, 'draw' is invoked for each item.
> public void draw(GC gc, GalleryItem item, int index, int x, int y,
> int width, int height) {
> you get an untouched area you can paint as you wish, without resizing.
> width and height are the one defined with setItemSize(). If you want to draw
labels, just add a little room for them.
Works like a charm, thanks.
> (You can even contribute your item renderer to Nebula :) )
If I get proud of it I will consider :-)
|
|
|
Re: Newbie Gallery questions [message #598115 is a reply to message #479472] |
Tue, 11 August 2009 06:05  |
Eclipse User |
|
|
|
Hi Thomas,
This is exactly why Gallery supports pluggable item renderers. In your case, you should just create a new ItemRenderer by extending AbstractItemRenderer.
During redraw, 'draw' is invoked for each item.
public void draw(GC gc, GalleryItem item, int index, int x, int y,
int width, int height) {
you get an untouched area you can paint as you wish, without resizing.
width and height are the one defined with setItemSize(). If you want to draw labels, just add a little room for them.
(You can even contribute your item renderer to Nebula :) )
--
Nicolas
|
|
|
Re: Newbie Gallery questions [message #598133 is a reply to message #598115] |
Tue, 11 August 2009 16:24  |
Eclipse User |
|
|
|
Nicolas Richeton wrote:
> Hi Thomas,
> This is exactly why Gallery supports pluggable item renderers. In your case,
you should just create a new ItemRenderer by extending AbstractItemRenderer.
> During redraw, 'draw' is invoked for each item.
> public void draw(GC gc, GalleryItem item, int index, int x, int y,
> int width, int height) {
> you get an untouched area you can paint as you wish, without resizing.
> width and height are the one defined with setItemSize(). If you want to draw
labels, just add a little room for them.
Works like a charm, thanks.
> (You can even contribute your item renderer to Nebula :) )
If I get proud of it I will consider :-)
|
|
|
Goto Forum:
Current Time: Wed Jul 23 01:11:40 EDT 2025
Powered by FUDForum. Page generated in 0.04512 seconds
|