Virtual Gadget example

11 posts / 0 new
Last post
walkero
walkero's picture
Offline
Last seen: 3 months 3 weeks ago
Joined: 2009-05-03 16:54
Virtual Gadget example

Hello to all. I am trying to create a list of thumbs in my program, and I would like this list to have a scrollbar. So I tried to use a virtual gadget with a vertical layout in it.

Here is what I wrote:

  1. // Thumbs list
  2. LAYOUT_AddChild, objects[OID_LAYOUT_THUMBS_WRAPPER] = IIntuition->NewObject(NULL, "layout.gadget",
  3. LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
  4. LAYOUT_SpaceOuter, TRUE,
  5. LAYOUT_BevelStyle, BVS_GROUP,
  6. LAYOUT_Label, " THUMBS ",
  7.  
  8. LAYOUT_AddChild, objects[OID_VIRT_THUMBS] = IIntuition->NewObject(NULL, "virtual.gadget",
  9. VIRTUALA_Contents, objects[OID_LAYOUT_THUMBS] = IIntuition->NewObject(NULL, "layout.gadget",
  10. LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
  11. LAYOUT_SpaceOuter, FALSE,
  12. TAG_DONE),
  13. CHILD_WeightedWidth, 0,
  14. TAG_DONE),
  15.  
  16. TAG_DONE),
  17. CHILD_WeightedWidth, 35,

The problem is that other times it works just fine, but other times the program crashes before it even starts to show up.

Is there anything stupid I did there? Should I add something else too?

jabirulo
jabirulo's picture
Offline
Last seen: 3 weeks 1 day ago
Joined: 2013-05-30 00:53
Hi, maybe you can take a look

Hi, maybe you can take a look at AISSview (gui.c) it uses virtual.gadget to show icons and can help you a little with your thumbs programm.

http://www.os4depot.net/share/graphics/aiss/aissviewer-src.lha

  1. ...
  2. OBJ(OBJ_TOP_LAYOUT) = VLayoutObject,
  3. LAYOUT_TopSpacing, 10,
  4. LAYOUT_AddChild, OBJ(OBJ_CLEAR_ALL),
  5. End; // VLayout
  6.  
  7. ...
  8.  
  9. LAYOUT_AddChild, VLayoutObject,
  10. LAYOUT_BevelStyle, BVS_GROUP,
  11. LAYOUT_Label, " Image Buttons ",
  12. LAYOUT_AddChild, OBJ(OBJ_VIRTUAL) = VirtualObject,
  13.  
  14. VIRTUALA_Contents, VLayoutObject,
  15. LAYOUT_AddChild, OBJ(OBJ_TOP_LAYOUT),
  16. CHILD_WeightedHeight, 0,
  17. End, // VIRTUALA_Contents, VLayoutObject
  18.  
  19. VirtualEnd,
  20. ...

AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P

broadblues
broadblues's picture
Offline
Last seen: 4 years 9 months ago
Joined: 2012-05-02 21:48
Is there anything stupid I


Is there anything stupid I did there?

Unless I'm reading it wrong you appear to have a CHILD_WeightedWidth,0, just after your thumbs layout, nad *inside* your Virtual gadgets tags, which is proably not what you want!

broadblues
broadblues's picture
Offline
Last seen: 4 years 9 months ago
Joined: 2012-05-02 21:48
BTW a listbrowser is a better

BTW a listbrowser is a better choice for a list of thumbs.

walkero
walkero's picture
Offline
Last seen: 3 months 3 weeks ago
Joined: 2009-05-03 16:54
Re: Virtual Gadget example

@jabirulo
Thanks. I will check this out

@broadblues
How can I dynamically show images inside a listbrowser? Is there a good example I could check? This solution could help me more, in case it works.

Thank you guys for your help and time.

jabirulo
jabirulo's picture
Offline
Last seen: 3 weeks 1 day ago
Joined: 2013-05-30 00:53
...n =
  1. ...
  2. n = IListBrowser->AllocListBrowserNode(TOTALCOLUMNS,
  3. LBNA_Column,0, LBNCA_CopyText,TRUE,
  4. LBNCA_Text,dat->Name,
  5. LBNA_Column,1, LBNCA_Image,imageP,
  6. //LBNA_Column,2, LBNCA_CopyText, TRUE,
  7. // LBNCA_Text, KM_desc1,
  8. //LBNA_Column,2, LBNCA_CopyInteger, TRUE,
  9. // LBNCA_Integer, &KM_cs,
  10. TAG_DONE);
  11.  
  12. IExec->AddTail(&listbrowser_list, n);
  13. ...

being imageP:

  1. ...
  2. dd->fiso[2].tta.tta_Name = font->ta_Name;
  3. dd->fiso[2].tta.tta_YSize = font->ta_YSize;
  4. dd->fiso[2].tta.tta_Style = font->ta_Style | FSF_TAGGED;
  5. dd->fiso[2].tta.tta_Flags = font->ta_Flags;
  6. dd->fiso[2].tta.tta_Tags = dd->fiso[1].ti;
  7. dd->fiso[2].ti[0].ti_Tag = TA_CharSet;
  8. dd->fiso[2].ti[0].ti_Data = 5; // 5=ISO_8859-2
  9. dd->fiso[2].ti[1].ti_Tag = TAG_DONE;
  10. ...
  11. imageP = IIntuition->NewObject(LabelClass, NULL,
  12. IA_Font,&dd->fiso[2].tta,
  13. LABEL_DisposeImage,TRUE, LABEL_Underscore,0,
  14. LABEL_Text,KM_desc2, TAG_END);

I use it to show string/languages in its native/local charset.

AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P

walkero
walkero's picture
Offline
Last seen: 3 months 3 weeks ago
Joined: 2009-05-03 16:54
Re: Virtual Gadget example

@jabirulo
But where do you set the image at your example? It should be loaded as a file or using datatypes. Where do you give to the listbrowser where it can find the image?

broadblues
broadblues's picture
Offline
Last seen: 4 years 9 months ago
Joined: 2012-05-02 21:48
@walkero jabiluro's example

@walkero

jabiluro's example is using a label image but you can just as well use a bitmap image.

adds the image to a coulmn in the node

LBNA_Column,1, LBNCA_Image,imageP,

code to load an image as bitmap:

imageP = IIntuition->NewObject(BitmapClass, NULL,
BITMAP_SelectSourceFile, path_s,
BITMAP_DisabledSourceFile, path_g,
BITMAP_Screen, scr,
BITMAP_Masking, TRUE,
, TAG_END);

walkero
walkero's picture
Offline
Last seen: 3 months 3 weeks ago
Joined: 2009-05-03 16:54
Re: Virtual Gadget example

@broadblues
Thanks for the code... it worked like charm. I have two more questions:
1. Is there a way to have a column of a listbrowser hidden? Checked the autodocs where you set the columninfo and didn't find anything useful. Rigo says that it is feasible at the following post (http://www.amigans.net/modules/xforum/viewtopic.php?post_id=80893). Any clue?
2. When I load a lot of images in the list the gfx memory fills. Is there a way to free the image from memory, but remain in the list? It also isn't cleared from memory when I close the app. It seems that when you dispose a win doesn't free it's resources.

Thank you all for your help and time.

broadblues
broadblues's picture
Offline
Last seen: 4 years 9 months ago
Joined: 2012-05-02 21:48
How many is a lot of

How many is a lot of images?

You need to dispose of those bitmaps images at program exit, they wont be disposed of by disposing of the listbroswer, same goes for the listnode in fact.

trixie
trixie's picture
Offline
Last seen: 6 months 3 weeks ago
Joined: 2011-02-03 13:58
Re: Virtual Gadget example

@walkero

Is there a way to have a column of a listbrowser hidden? Checked the autodocs where you set the columninfo and didn't find anything useful. Rigo says that it is feasible

ADRipper uses column hiding when switching between the Compilation and the Normal mode, but looking at the code it merely modifies the ColumnInfo structure, setting ci_Width = 0 and ci_Title = "" for the particular column. A rather ugly kludge if you ask me but whether there's another way I don't know.

AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2

Log in or register to post comments