Listview and brush

Discuss GUI programming with the MUI Royale plugin here
Post Reply
sinisrus
Posts: 278
Joined: Tue Apr 21, 2015 5:43 pm

Listview and brush

Post by sinisrus »

Hello,

I have problem with listview and brush

If i use:

Code: Select all

CreateBrush(1,30,20,#BLUE)
mui.DoMethod("id_nuance_familly","insert","TOP","\27A[1]","Brush Blue")
FreeBrush(1)
And

Code: Select all

CreateBrush(1,30,20,#RED)
mui.DoMethod("id_nuance_familly","insert","TOP","\27A[1]","Brush Red")
The line inserted content "Brush bleu" and never "Brush red"

For my project I need to use the same id :-/


Full source code

HWS

Code: Select all

@DISPLAY 1, {Hidden=True,color=#WHITE}

Function  p_EventFunc(msg)

    Switch msg.action
    Case "MUIRoyale":
        Switch msg.attribute
        Case "CloseRequest":
            End

        Case "Pressed":
            Switch msg.id
            Case "id_AddReplacenuance_replace":
            mui.DoMethod("id_nuance_familly","Clear")

            Case "id_AddReplacenuance_add":
            mui.set("id_nuance_familly","quiet",0)
            CreateBrush(1,30,20,#RED)
            mui.DoMethod("id_nuance_familly","insert","TOP","\27A[1]","Brush Red")
            mui.set("id_nuance_familly","quiet",1)

            EndSwitch

        EndSwitch

    Case "HideWindow":
        mui.Set("app", "iconified", True)

    Case "ShowWindow":
        mui.Set("app", "iconified", False)
    EndSwitch

EndFunction

 

; dynamically create MUI GUI from an external *.xml file definition
mui.CreateGUI(FileToString("Listview.xml"))

; listen to these events!
InstallEventHandler({MUIRoyale = p_EventFunc})

 

CreateBrush(1,30,20,#BLUE)

mui.DoMethod("id_nuance_familly","insert","TOP","\27A[1]","Brush Blue")

FreeBrush(1)

 

EscapeQuit(True)

/* Boucle infinie */
Repeat
        WaitEvent
Forever

XML

Code: Select all

<?xml version="1.0" encoding="iso-8859-1"?>
<application id="app" base="NOUVEAU">

  <window id="win_popFamillynuance" height="300" title="Famille de nuances" depthgadget="0" notify="closerequest">
    <vgroup fixwidth="250" frame="group" innertop="0" innerleft="0" innerright="0" innerbottom="0" spacing="0">

        <listview id="id_nuance_familly" autolineheight="1" notify="doubleclick">
           <column>
           </column>
           <column>
           </column>
        </listview>

      <hgroup>
      <button id="id_AddReplacenuance_replace" notify="pressed">Clear</button>
      <button id="id_AddReplacenuance_add" notify="pressed">Add</button>
      </hgroup>


    </vgroup>
  </window>

</application>

User avatar
jPV
Posts: 358
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

Re: Listview and brush

Post by jPV »

The brushes are cached as explained recently here: http://forums.hollywood-mal.com/viewtop ... =21&t=1669

You have to use different ID for different listview brushes...

I also hitted to this problem with my program, which has thumbnail images on each listview entry, and the entires are changing depening what user does. I had to work around it by using infinitely increasing id numbering... not the tidyest or the best solution, but didn't come up any better solution yet. But in your case of just two states, different IDs shouldn't be that big problem?

I wish there would be a command to clear the cache at least...

sinisrus
Posts: 278
Joined: Tue Apr 21, 2015 5:43 pm

Re: Listview and brush

Post by sinisrus »

Here is an example to explain my problem but I need more than two entries (+-20, 100 entries max)
This is unimmer for me :-(

sinisrus
Posts: 278
Joined: Tue Apr 21, 2015 5:43 pm

Re: Listview and brush

Post by sinisrus »

PJV

There is another solution!
You have to create a Fake Listview with virtgroup, scrollgroup, inputmode, etc ...

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

Re: Listview and brush

Post by airsoftsoftwair »

jPV wrote:I wish there would be a command to clear the cache at least...
Yes, that's a good idea. I'll add that for a future version.

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

Re: Listview and brush

Post by airsoftsoftwair »

Code: Select all

- New: Added moai.FreeImage(); this allows you to free an image in RapaGUI's internal image cache;
  you have to pass the number of the brush you want to free or -1 to free all images; note that
  you must make sure that the image you free is no longer used by any widget or RapaGUI might
  crash; note that normally it isn't necessary to call moai.FreeImage() because all images are
  freed automatically when RapaGUI quits; it's only necessary in case you want to reuse the same
  brush number with a new image or free memory used by an image

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

Re: Listview and brush

Post by airsoftsoftwair »

And this:

Code: Select all

- New: Added mui.FreeImage(); this allows you to free an image in MUI Royale's internal image
  cache; you have to pass the number of the brush you want to free or -1 to free all images;
  note that you must make sure that the image you free is no longer used by any widget or MUI
  Royale might crash; note that normally it isn't necessary to call mui.FreeImage() because all
  images are freed automatically when MUI Royale quits; it's only necessary in case you want
  to reuse the same brush number with a new image or free memory used by an image

User avatar
jPV
Posts: 358
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

Re: Listview and brush

Post by jPV »

Any idea when the new MUIRoyale update will be out?

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

Re: Listview and brush

Post by airsoftsoftwair »

There'll soon be updates for RapaGUI and MUI Royale :)

Post Reply