[Solved] drawlist.image - no image drawn

This forum is for general developer support questions.
Post Reply
chris
Posts: 564
Joined: Sat Jun 18, 2011 12:05 pm
Contact:

[Solved] drawlist.image - no image drawn

Post by chris »

How does drawlist.image work? I'm trying to create a custom drawlist image with the following code:

Code: Select all

struct DrawList opendrawer[] = {
	{DLST_LINESIZE, 0, 0, 0, 0, 0xff},	
	{DLST_LINEPAT, 0, 0, 0, 0, 0xff},
					
	{DLST_LINE, 90, 60, 90, 90, 1},
	{DLST_LINE, 90, 90, 10, 90, 1},
	{DLST_LINE, 10, 90, 10, 60, 1},
	{DLST_LINE, 10, 60, 90, 60, 1},
	{DLST_LINE, 90, 60, 70, 30, 1},
	{DLST_LINE, 70, 30, 30, 30, 1},
	{DLST_LINE, 30, 30, 10, 60, 1},
	
	{DLST_LINE, 30, 30, 20, 30, 1},
	{DLST_LINE, 20, 30, 20, 50, 1},

	{DLST_LINE, 70, 30, 80, 30, 1},
	{DLST_LINE, 80, 30, 80, 50, 1},

	{DLST_END, 0, 0, 0, 0, 0},
};

obj = NewObject(DrawListClass, NULL,
		DRAWLIST_Directives, &opendrawer,
		DRAWLIST_RefHeight, 100,
		DRAWLIST_RefWidth, 100,
	End;
obj is then attached to a button using GA_Image, obj

I added LINESIZE and LINEPAT later in case it defaulted to invisible. I've also tried all different pens from 0-3.
However no matter what I do, I'm getting a blank image on my button.

Is there something obvious I've done wrong, or should this work? I've been looking for drawlist.image examples but I can't find any indication that anybody has ever tried to use it (apart from @xenic, and of course glyph.image)
Last edited by chris on Sat Jul 12, 2025 2:33 pm, edited 1 time in total.
User avatar
thomasrapp
Posts: 318
Joined: Sun Jun 19, 2011 12:22 am

Re: drawlist.image - no image drawn

Post by thomasrapp »

I just tried a drawlist image for the first time and it worked immediately.

However, I found the documentation to be wrong. LINESIZE and LINEPAT don't take their value from the pen field but rather from x1. As you set both to 0, the image indeed becomes invisible.

However, without LINESIZE and LINEPAT or if I put the values into the x1 field, your array works for me. So your error is not in this code snippet.

If I had to guess I would suppose that you placed the two statements in a subroutine and the opendrawer array disappears when the routine is left. It has to stay alive as long as the image object lives because it is not copied.
chris
Posts: 564
Joined: Sat Jun 18, 2011 12:05 pm
Contact:

Re: drawlist.image - no image drawn

Post by chris »

I did wonder if it wasn't copied, so I tried making it global - but by that point I'd already added the line pattern and width commands which were making it invisible!

I've got it working now, thanks.

Sounds like the docs need updating though.
Post Reply