Imagecache on LInux

Discuss GUI programming with the RapaGUI plugin here
Post Reply
evil
Posts: 177
Joined: Mon Jun 14, 2010 1:38 pm

Imagecache on LInux

Post by evil »

Hello again!

I Created a gui, which contains one listview. And three sliders.
Inside this listview are some entries, which contain images (brushes, which show just one color...)
The sliders will be used to change the colors of those listviewimages.
When I now change an image of an entry, the new image will be displayed correct on amiga.

Doing the same on linux will cause some other entries to change their images, too.
Could not test on Win/Mac....

Its difficult to discribe the problem, so here is a (not that) small code snippet:

Code: Select all

@REQUIRE "RapaGUI"
xml$=[[<?xml version="1.0" encoding="iso-8859-1"?>
    <application id="app">
        <window>
            <hgroup>
                <listview id="lv" notify="active">
                    <column icon="1"> </column>
                </listview>
                <slider id="red" horiz="0" notify="level" max="255" reverse="1"/>
                <slider id="green" horiz="0" notify="level" max="255" reverse="1"/>
                <slider id="blue" horiz="0" notify="level" max="255" reverse="1"/>
                <rectangle/>
            </hgroup>
        </window>
    </application>]]

color={r=0,g=0,b=0}
lvcolor={0,0,0,0,0,0}
Function p_eventfunc(msg)
    Switch msg.class
    Case "Slider"
        color.r=moai.get("red","level")
        color.g=moai.get("green","level")
        color.b=moai.get("blue","level")
        lvcolor[activeentry]=color.r*65536+color.g*256+color.b
            moai.set("lv","quiet","1")
            moai.domethod("lv","remove",activeentry)
            moai.FreeImage(activeentry)
            CreateBrush(activeentry,30,20,lvcolor[activeentry])
            moai.DoMethod("lv","insert",activeentry,activeentry,hexstr(lvcolor[activeentry]))
            moai.set("lv","active",activeentry)
            moai.set("lv","quiet","0")
 
    Case "Listview"
        activeentry=moai.get("lv","active")
        moai.set("red","level",red(lvcolor[activeentry]),"nonotify","1")
        moai.set("green","level",green(lvcolor[activeentry]),"nonotify","1")
        moai.set("blue","level",blue(lvcolor[activeentry]),"nonotify","1")
    EndSwitch
EndFunction

InstallEventHandler({Rapagui=p_eventfunc})

moai.createapp(xml$)

for t=0 to 5
    CreateBrush(t,30,20,#Black)
    moai.DoMethod("lv","insert","bottom",t,0)
Next

activeentry=0 moai.set("lv","active",activeentry)

Repeat
    WaitEvent()
Forever
Do I have a logical problem, or is it a bug??

Best regards

George
evil
Posts: 177
Joined: Mon Jun 14, 2010 1:38 pm

Re: Imagecache on LInux

Post by evil »

Ok, I think I got it...

Using Listview.ForceMode with attribute dataview, seems to solve the problem..

Best regards

George
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Imagecache on LInux

Post by airsoftsoftwair »

Looks still like a bug, using data view mode is a good workaround then, though :)
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Imagecache on LInux

Post by airsoftsoftwair »

I've examined it now and it is indeed a bug but I won't fix it because of some design flaw in wxWidgets it would only be possible by going to great pains which is probably not worth the effort since you can just use dataview as a workaround.

By the way, there's a lot of overhead in the way you try to change the icon. Instead of:

Code: Select all

moai.set("lv","quiet","1")
moai.domethod("lv","remove",activeentry)
moai.FreeImage(activeentry)
CreateBrush(activeentry,30,20,lvcolor[activeentry])
moai.DoMethod("lv","insert",activeentry,activeentry,hexstr(lvcolor[activeentry]))
moai.set("lv","active",activeentry)
moai.set("lv","quiet","0")
You can just do:

Code: Select all

moai.FreeImage(activeentry)
CreateBrush(activeentry,30,20,lvcolor[activeentry])
moai.DoMethod("lv","rename",activeentry,activeentry,hexstr(lvcolor[activeentry]))
This is much quicker and cleaner.
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Imagecache on LInux

Post by airsoftsoftwair »

Code: Select all

- New: Added moai.UpdateImage(); this can be used to update the graphics of an image; note that this is
  currently only supported for images inside Listview or Treeview objects; after calling moai.UpdateImage()
  you also have to make sure that rows that use the image are redrawn, e.g. by using Listview.Rename() to
  update the image information in a row 
Post Reply