Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
98 user(s) are online (53 user(s) are browsing Forums)

Members: 1
Guests: 97

TheMagicSN, more...

Headlines

 
  Register To Post  

[SOLVED] MUI : How to update image filename of a DTPic when running ?
Just can't stay away
Just can't stay away


See User information
Hi,
With MUI, I have a problem with DTPic.
I want to change the DTPic file when user press a element of a list.
It works at init time.
It works when the first element is selected (the DTpic loads well the file)
But it doesn't work when a new element is selected.

At init, I use
Child, Im_Data_png = DtpicObject, MUIA_Dtpic_Name, "PROGDIR:NoPreview.PNG", End,

In my code, when I select an element,

set(Im_Data_png,MUIA_Dtpic_Name, path_preview);

the DTPic load just the image for the first time and never updated it at subsequents attempts.

I find a related question :
http://amigans.net/index.php?function=viewcomments&threadid=124

Is it implemented in MUI39 ?

If not, is somebody know a other (simple if possible) method ?

Thank you by advance
zzd10h


Edited by zzd10h on 2013/3/11 20:22:09
Go to top
Re: MUI : How to update image filename of a DTPic when running ?
Just popping in
Just popping in


See User information
Quote:
I find a related question :
http://amigans.net/index.php?function=viewcomments&threadid=124

Is it implemented in MUI39 ?


The link you provided already proves that this stuff is implemented since 2 years now.

Changing the image of a Dtpic object definitely works, I just checked it myself with both MUI 3.9 and MUI 4.0. I took the Class1 demo source and just added these few lines:

within the window creation:Quote:

Child, img=DtpicObject, MUIA_Dtpic_Name, "ram:img1.png", End,
Child, b1=KeyButton("Image 1", '1'),
Child, b2=KeyButton("Image 2", '2'),


after the window creation:Quote:

DoMethod(b1, MUIM_Notify, MUIA_Pressed, FALSE, img, 3, MUIM_Set, MUIA_Dtpic_Name, "ram:img1.png");
DoMethod(b2, MUIM_Notify, MUIA_Pressed, FALSE, img, 3, MUIM_Set, MUIA_Dtpic_Name, "ram:img2.png");


Go to top
Re: MUI : How to update image filename of a DTPic when running ?
Just can't stay away
Just can't stay away


See User information
Thank you Thore to your confirmation,

I don't know why but this
doesn't work like this:

set(Im_Data_png,MUIA_Dtpic_Name, path_preview);

but when I double the instruction like this

set(Im_Data_png,MUIA_Dtpic_Name, path_skin_preview);
set(Im_Data_png,MUIA_Dtpic_Name, path_skin_preview);
it doesn't work

But when I do this with a first constant filename
set(Im_Data_png,MUIA_Dtpic_Name, "PROGDIR:Skins/Empty.png");
set(Im_Data_png,MUIA_Dtpic_Name, path_preview);

it works, Im_Data_png show the right png file :)

Of course, path_preview contains always the correct path of the png.




Go to top
Re: MUI : How to update image filename of a DTPic when running ?
Not too shy to talk
Not too shy to talk


See User information

What you say is that

strcpy (path_skin_preview,"PROGDIR:Skins/Empty.png");
set(Im_Data_png,MUIA_Dtpic_Name, path_skin_preview);
strcpy (path_skin_preview,"PROGDIR:Skins/Full.png");
set(Im_Data_png,MUIA_Dtpic_Name, path_skin_preview);

does not work, but

strcpy (path_init_preview,"PROGDIR:Skins/Empty.png");
set(Im_Data_png,MUIA_Dtpic_Name, path_init_preview);
strcpy (path_skin_preview,"PROGDIR:Skins/Full.png");
set(Im_Data_png,MUIA_Dtpic_Name, path_skin_preview);

works?

If this is true, then DTPic might internally keep the pointer to the file name and if you set the same pointer a second time, it thinks the image didn't change and thus doesn't update the display.

Perhaps something like this works:

strcpy (path_skin_preview,"PROGDIR:Skins/Empty.png");
set(Im_Data_png,MUIA_Dtpic_Name, path_skin_preview);

set(Im_Data_png,MUIA_Dtpic_Name, NULL);
strcpy (path_skin_preview,"PROGDIR:Skins/Full.png");
set(Im_Data_png,MUIA_Dtpic_Name, path_skin_preview);


Go to top
Re: MUI : How to update image filename of a DTPic when running ?
Just can't stay away
Just can't stay away


See User information
Hi,
to put NULL in the DTPic_Name make my system freezes.


path_skin_preview is a
path_skin_preview[128]; where I write the path of a picture depending of a selection in a List


memset (path_skin_preview, 0, sizeof (path_skin_preview));
strcpy(path_skin_preview,"PROGDIR:Skins/");
strcat(path_skin_preview,theme);
strcat(path_skin_preview,"/sound7.PNG");


1) works
set(Im_Data_png,MUIA_Dtpic_Name, "PROGDIR:Skins/Empty.png");
set(Im_Data_png,MUIA_Dtpic_Name, path_skin_preview);


2) doesn't work
set(Im_Data_png,MUIA_Dtpic_Name, path_skin_preview);

3) doesn't work
set(Im_Data_png,MUIA_Dtpic_Name, path_skin_preview);
set(Im_Data_png,MUIA_Dtpic_Name, path_skin_preview);

Go to top
Re: MUI : How to update image filename of a DTPic when running ?
Just popping in
Just popping in


See User information
Quote:
If this is true, then DTPic might internally keep the pointer to the file name and if you set the same pointer a second time, it thinks the image didn't change and thus doesn't update the display.


That's true. Dtpic.mui just remembers the string pointer passed to MUIA_Dtpic_Name and does NOT copy the string. Second, during OM_SET it will check if the pointer changes first. Third, NULL is no valid value for MUIA_Dtpic_Name.

Since the string pointer is remembered you must use a different buffer to change the image. Something like this will NOT work:

char buffer[64];
snprintf(buffer, sizeof(buffer), "%s/foo.png", path);
set(dtobj, MUIA_Dtpic_Name, buffer);
snprintf(buffer, sizeof(buffer), "%s/bar.png", path);
set(dtobj, MUIA_Dtpic_Name, buffer);

However, this will work:
char buffer1[64];
char buffer2[64];
snprintf(buffer1, sizeof(buffer1), "%s/foo.png", path);
set(dtobj, MUIA_Dtpic_Name, buffer1);
snprintf(buffer2, sizeof(buffer2), "%s/bar.png", path);
set(dtobj, MUIA_Dtpic_Name, buffer2);

I will add an appropriate comment to the attribute's Autodocs for the next release.

Go to top
Re: MUI : How to update image filename of a DTPic when running ?
Just can't stay away
Just can't stay away


See User information
Thank you Thore and Thomas,
Now, I switch between 2 buffers and it works well without the need of intermediate picture.


Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2023 The XOOPS Project