Page 1 of 1

Imagecache on LInux

Posted: Sun Jan 20, 2019 11:19 am
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

Re: Imagecache on LInux

Posted: Sun Jan 20, 2019 11:52 am
by evil
Ok, I think I got it...

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

Best regards

George

Re: Imagecache on LInux

Posted: Wed Jan 23, 2019 5:31 pm
by airsoftsoftwair
Looks still like a bug, using data view mode is a good workaround then, though :)

Re: Imagecache on LInux

Posted: Fri Jul 31, 2020 9:21 pm
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.

Re: Imagecache on LInux

Posted: Wed Aug 12, 2020 2:57 pm
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