[SOLVED] Using Filler and BitMap gadgets

This forum is for general developer support questions.
User avatar
abalaban
Beta Tester
Beta Tester
Posts: 456
Joined: Mon Dec 20, 2010 2:09 pm
Location: France
Contact:

[SOLVED] Using Filler and BitMap gadgets

Post by abalaban »

I'm trying to use Filler and BitMap gadgets in a new little soft I'm currently developing but I encountered the following problems/questions:
  • I'm trying to display a banner in the upper part of my GUI. Browsing the Autodocs I found the Filler gadget was quite adapted for this (according to its autodocs self definition). Unfortunately I can't make it to display anything, for now I've given it a gadget id (GA_Id), a screen pointer (FILLER_Screen) and a source filename (FILLER_ImageFilename). Any idea? Is Filler_ic adapted for the job? Solved -> Use LAYOUT_AddImage instead of LAYOUT_AddGadget.
  • Now I'm trying to display a thumbnail of an on-disk picture, this picture data will *not* be loaded from datatypes (don't ask why, I need to load them by myself), in order to scale my original image to the gadget I need to retrieve the gadget's size. AFAIU IA_Width/IA_Height are the bitmap data size, how can I know the size of the gadget itself, GA_Width/GA_Height does not seem to work for me? Is BitMap_ic the right classe to use? Solved -> Use a readonly button and attach the bitmap to it.
  • I'm willing to allow the user to influence the size of the thumbnail by using a LAYOUT_WeightBar. How can I detect an action on this bar and regenerate my new thumbnail? Solved -> To do this there is no other solution than subclassing gadget class and doing everything by hand. I.e. scaling the thumbnail on the render message reception.
  • Which method would you advise me to obtain a BitMap from my in memory (self loaded) RGB values: BltBitMapTagList() seems good if I can guarantee 24 or 32bits RGB values, what about p96WritePixelArray ? Even if for now I trying to convert to a BitMap struct because of the BitMap_ic I'm using, I will need this conversion at some point, so even if using BitMap_ic isn't the right solution for the thumbnail this question remains. Solved -> BltBitMapTagList() does the job quite well, but there input data format are limited (LUT, RGB24 or ARGB32)
Last edited by abalaban on Tue Dec 11, 2012 9:13 am, edited 3 times in total.
AmigaOne X1000 running AOS 4 beta
AmigaOne XE/G4
Amiga 1200/PPC 603e + BVision PPC
User avatar
abalaban
Beta Tester
Beta Tester
Posts: 456
Joined: Mon Dec 20, 2010 2:09 pm
Location: France
Contact:

Re: Using Filler and BitMap gadgets

Post by abalaban »

Okay after a night of experimentation BitMap_ic is *not* the gadget I want because BITMAP_BitMap attribute can only be set at creation time... I'll have to find another gadget allowing modification of BitMap structure at any time...

Oh and I've gone the BltBitMapTagList() way but can't say if it works or not because for now I can't send the bitmap to a gadget that will display it...

I'm still looking for solutions/explanations for other points (Filler_ic not displaying anything, how Layout_WeightBar can be intercepted, etc.)
AmigaOne X1000 running AOS 4 beta
AmigaOne XE/G4
Amiga 1200/PPC 603e + BVision PPC
User avatar
thomasrapp
Posts: 318
Joined: Sun Jun 19, 2011 12:22 am

Re: Using Filler and BitMap gadgets

Post by thomasrapp »

Both Bitmap_ic and Filler_ic are Image classes (ic = image class), not gadget classes (gc). You cannot apply GA_* attributes to them. Only IA_* attributes work with images.

You could use a read-only button gadget and attach a bitmap image to it. To change the display you create a new bitmap image, attach the new one to the button and dispose the old image. If the image size changes you might need to send WM_RETHINK to the window.
User avatar
abalaban
Beta Tester
Beta Tester
Posts: 456
Joined: Mon Dec 20, 2010 2:09 pm
Location: France
Contact:

Re: Using Filler and BitMap gadgets

Post by abalaban »

thomasrapp wrote:Both Bitmap_ic and Filler_ic are Image classes (ic = image class), not gadget classes (gc). You cannot apply GA_* attributes to them. Only IA_* attributes work with images.
Damn you are right !! Of course they don't answer the GA_* attributes in such conditions ;-) Do you know if there is a relation between IA_Width/IA_Heigth and BITMAP_Width/BITMAP_Height. I'm trying to use them in a layout which contains a WeightBar in it, what happens to IA_Width/IA_Height and corresponding BITMAP_* attributes? I mean I expect the BITMAP_* Width and Height attribute to keep their original values, but what about the IA_* ones? In other words does the image classes stretch to fill the space and center (or any other alignment) the bitmap in it?
thomasrapp wrote:You could use a read-only button gadget and attach a bitmap image to it. To change the display you create a new bitmap image, attach the new one to the button and dispose the old image. If the image size changes you might need to send WM_RETHINK to the window.
Thank you that's a very good idea! I'll experiment with it this night.
AmigaOne X1000 running AOS 4 beta
AmigaOne XE/G4
Amiga 1200/PPC 603e + BVision PPC
User avatar
abalaban
Beta Tester
Beta Tester
Posts: 456
Joined: Mon Dec 20, 2010 2:09 pm
Location: France
Contact:

Re: Using Filler and BitMap gadgets

Post by abalaban »

Okay, So the idea to use a read-only button_gc instead of a bitmap_ic is working great, thank you very much!!
Now I'm surprised about one thing: my button is allowed to shrink under the bitmap_ic size (fine). *But* in such case the bitmap is displayed in full and overwrite the GUI around the button. i.e. there does not seem to be any clipping of the bitmap_ic to the button's extend. Is it intended (which would be strange), a tag I forgot to pass or a bug?

Note I still wasn't able to have the Filler display anything while using the same on image with a bitmap in my button worked fine (I'm only passing the Filler the filename/path on disk, the datatype system should do the other things.)
AmigaOne X1000 running AOS 4 beta
AmigaOne XE/G4
Amiga 1200/PPC 603e + BVision PPC
User avatar
tbreeden
Posts: 160
Joined: Sat Jun 18, 2011 1:57 am
Location: Charlottesville, VA, USA
Contact:

Re: Using Filler and BitMap gadgets

Post by tbreeden »

abalaban wrote: Note I still wasn't able to have the Filler display anything while using the same on image with a bitmap in my button worked fine (I'm only passing the Filler the filename/path on disk, the datatype system should do the other things.)
Make sure you add it to the layout with tag "LAYOUT_AddImage" rather than "LAYOUT_AddChild".

Tom
User avatar
thomasrapp
Posts: 318
Joined: Sun Jun 19, 2011 12:22 am

Re: Using Filler and BitMap gadgets

Post by thomasrapp »

abalaban wrote:(I'm only passing the Filler the filename/path on disk, the datatype system should do the other things.)
RTFM?
ATTRIBUTES
FILLER_Screen (struct Screen *)
Screen for allocation of needed pens for the display.
This MUST be provided and MUST remain open until after
the gadget has been disposed.


Applicability is (OM_NEW, OM_SET)
User avatar
abalaban
Beta Tester
Beta Tester
Posts: 456
Joined: Mon Dec 20, 2010 2:09 pm
Location: France
Contact:

Re: Using Filler and BitMap gadgets

Post by abalaban »

@Thomasrapp

Yes when I was saying I was just passing the image filename I wanted to say that contrary to the bitmap_ic in the button I was not loading/decoding the image by myself. As I wrote in my first post, I'm of course also passing the tag FILLER_Screen (which is non null and pointing to the Workbench screen).

@tbreeden

Hmmm, it's the first time I'm using an image subclass directly in a layout and didn't noticed there was a distinct method to do it... It makes sense and you are probably right. Thank you very much, I read the FILLER_ic autodocs to find the problem, but didn't thought looking at the LAYOUT_gc one. My mistake, sorry. It will probably solve my problem.

EDIT: and it did (solve my problem), I've updated my first post to reflect this.
AmigaOne X1000 running AOS 4 beta
AmigaOne XE/G4
Amiga 1200/PPC 603e + BVision PPC
User avatar
abalaban
Beta Tester
Beta Tester
Posts: 456
Joined: Mon Dec 20, 2010 2:09 pm
Location: France
Contact:

Re: Using Filler and BitMap gadgets

Post by abalaban »

Now I'm left with two problems:
1) is it possible to catch WeightBar changes (I imagine one solution would be to subclass the gadget and customize some methods, but if I could avoid this)
2) how can I prevent the bitmap in my read-only button to overflow the button extent and override things outside the button when I resize my window? I.e. is it possible to clip the bitmap into the button extent?

The idea is that this bitmap in the button is some sort of preview thumbnail and I would like the user to be able to resize the thumbnail to his liking using the WeightBar.
AmigaOne X1000 running AOS 4 beta
AmigaOne XE/G4
Amiga 1200/PPC 603e + BVision PPC
User avatar
thomasrapp
Posts: 318
Joined: Sun Jun 19, 2011 12:22 am

Re: Using Filler and BitMap gadgets

Post by thomasrapp »

You could make your own gadget class which behaves all like you want. This would fix all your issues.

Here is an example: http://thomas-rapp.homepage.t-online.de ... /scale.lha
Post Reply