librocket GUI support

Return to Panda Features in Development

Postby powerpup118 » Sat Jan 28, 2012 9:41 pm

I just wanted to say that your last commit fixed a segfault issue for me.

I successfully compiled it and can now use it on Ubuntu 11.04 / 32 bit.

Thank you! ~powerpup118
User avatar
powerpup118
 
Posts: 325
Joined: Sat Apr 17, 2010 11:59 pm

Postby morgul » Sun Jan 29, 2012 10:20 pm

Hey rdb, could you post some test code, or a sample? I built the latest, and while nothing crashes, the rocket windows aren't rendering. (I started with the walking panda example, and the panda looks great.)

(Also, I'm no longer at the machine with the code on it; I'll post that separately tomorrow)

--Chris
Christopher S. Case
Skewed Aspect
http://dev.skewedaspect.com/projects/precursors
Image
User avatar
morgul
 
Posts: 38
Joined: Sun Dec 28, 2008 1:49 pm
Location: Lubbock, TX

Postby rdb » Mon Jan 30, 2012 4:12 am

Sure. It's not very clean code or anything, but it should do the trick:

http://rdb.name/rocket-sample.zip
rdb
 
Posts: 9481
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands

Postby GrizzLyCRO » Fri Feb 03, 2012 5:43 pm

In case someone is reluctant to try librocket, it works now :)

http://dl.dropbox.com/u/14000546/DUMP/screenshot17.png
User avatar
GrizzLyCRO
 
Posts: 301
Joined: Tue Dec 16, 2008 4:03 pm
Location: Croatia

Postby shimrod » Mon Feb 13, 2012 3:54 pm

With which tools are you generating rml files? Is there any kind of free editors to do your windows/menu?
shimrod
 
Posts: 331
Joined: Mon Dec 28, 2009 11:39 am
Location: France

Postby rdb » Mon Feb 13, 2012 4:13 pm

I didn't make those, I used the files from a libRocket sample. But .rml files are very similar to .html files, and .rcss to .css. If you know HTML and CSS then picking up the libRocket syntax shouldn't be difficult. You can use your favourite text editor, one with HTML syntax highlighting.
rdb
 
Posts: 9481
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands

Debugging librocket

Postby Revington » Tue Feb 14, 2012 11:36 am

Hi all,

how can I open the debugger window that is displayed here: http://librocket.com/wiki/documentation/tutorials/WindowTemplate?

I guess I need to use the Debugger plugin from librocket, but how do I do that? :roll:

Thanks for the addition of librocket, looks really cool!

Greetings
Revington
Revington
 
Posts: 30
Joined: Thu Nov 18, 2010 10:45 am

Postby EdBighead » Wed Feb 15, 2012 8:24 pm

Has anyone gotten the High Scores portion of the rocket sample to work? I created my own class which inherited from DataSource and the object exists and contains all of the information, but I can't seem to get the datagrid to know about the source. I get this error:
Code: Select all
:rocket(error) Bad data source name high_scores.scores


In high_score.rml:
Code: Select all
def OnLoad(window):
   dataSource = HighScoreDataSource('high_scores')

   datagrid = window.GetElementById('datagrid')
   datagrid.AddEventListener('rowupdate', OnRowAdd, False)


HighScoreDataSource:
Code: Select all
class HighScoreDataSource(DataSource):

   def __init__(self, name):
      DataSource.__init__(self, name)

   def GetRow(self, row, tableName, rowIndex, columns):
      if(tableName == 'scores'):

         for col in columns:

            if(col == 'name'):
               row.append('TestName')

            elif(col == 'score'):
               row.append('5')

            elif(col == 'color'):
               row.append('#F00')

            elif(col == 'wave'):
               row.append('testWave')

   def GetNumRows(self, tableName):
      if(tableName == 'scores'):
         return 1

      return 0


http://librocket.com/wiki/documentation ... s/Datagrid

Edit:

On an aside, when can we expect to see documentation for the classes associated with libRocket? For example, I discovered the DataSource class by looking at the documentation at libRocket's site and got lucky that it exists in panda3d.rocket, but it doesn't seem like the entire class is there. For example, the APIs over there describe a GetDataSourceName function that doesn't exist in the panda version of DataSource
EdBighead
 
Posts: 109
Joined: Tue Jan 18, 2011 12:14 pm
Location: U.S.

Postby rdb » Thu Feb 16, 2012 2:34 am

@Revington: I haven't thought about the debugger yet. I'll look into it.

@EdBighead: The API that Panda3D exposes is 100% the same as the Python bindings of libRocket expose.
rdb
 
Posts: 9481
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands

Postby Revington » Thu Feb 16, 2012 12:49 pm

@rdb: Thank you!

@EdBighead:
You need an instance of your HighScoreDataSource where you passed the name of the datasource to the constructor.

Below is how I got it to work:
Code: Select all
import traceback

class HighScoreDataSource(DataSource):
    def __init__(self, name):
        self.scores = [] # could be any name
        self.scores.append({'name': 'Mike', 'wave': 1, 'score': "42", "colour": "USSExcelsior"})
       
        DataSource.__init__(self, name)


    def GetRow(self, table_name, index, columns):
        row = list()
       
        try:
            if index > len(self.scores)-1:
                return row
                   
            if(table_name == 'scores'):
                for col in columns:
                   
                    if col not in self.scores[index]:
                        continue # skip columns we don't know
                   
                    if(col == 'name'):
                        row.append(self.scores[index][col])

                    elif(col == 'score'):
                        row.append(self.scores[index][col])

                    elif(col == 'colour'):
                        row.append(self.scores[index][col])

                    elif(col == 'wave'):
                        row.append(self.scores[index][col])
                   
        except:
            traceback.print_exc()

        return row
       
    def GetNumRows(self, table_name):
        if(table_name == 'scores'):
            return len(self.scores)

        return 0

hs = HighScoreDataSource("high_scores")
Revington
 
Posts: 30
Joined: Thu Nov 18, 2010 10:45 am

Postby GrizzLyCRO » Thu Feb 16, 2012 2:39 pm

How to access event data("parameters" is property name).
From their sample, i found that there is "key_identifier", but not much else... I tried to iterate over "parameters", but had no success.
User avatar
GrizzLyCRO
 
Posts: 301
Joined: Tue Dec 16, 2008 4:03 pm
Location: Croatia

Postby rdb » Thu Feb 16, 2012 3:35 pm

I think it's event.parameters["mouse_x"] etc.
rdb
 
Posts: 9481
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands

Postby Revington » Thu Feb 16, 2012 3:38 pm

GrizzLyCRO wrote:How to access event data("parameters" is property name).
From their sample, i found that there is "key_identifier", but not much else... I tried to iterate over "parameters", but had no success.


That's what I do:
Code: Select all
def myClicker():
    print "event: ", event
    print "event.current_element: ", event.current_element
    print "event.type: ", event.type
    print "event.parameters: ", event.parameters

myBut = doc.GetElementById("myclickerbutton")
myBut.AddEventListener("click", myClicker)


As stated here http://librocket.com/wiki/documentation/PythonManual/Events, the event handler that is called has three global variables: event, document and self
Revington
 
Posts: 30
Joined: Thu Nov 18, 2010 10:45 am

Postby GrizzLyCRO » Thu Feb 16, 2012 3:53 pm

Thanks rdb, and Revington, so for now i know that there are 3 parameters that exist.

"key_identifier"
"mouse_x"
"mouse_y"

For me, print(event.parameters gives only _rocketcore.Dictionary instance at 0x.....)

len(event.parameters) gives 8.
User avatar
GrizzLyCRO
 
Posts: 301
Joined: Tue Dec 16, 2008 4:03 pm
Location: Croatia

Postby Revington » Thu Feb 16, 2012 4:12 pm

This should list all possible parameters.
Revington
 
Posts: 30
Joined: Thu Nov 18, 2010 10:45 am

Postby GrizzLyCRO » Thu Feb 16, 2012 4:17 pm

Revington, thank you very much, do not know how i missed that :)
Thanks again!
User avatar
GrizzLyCRO
 
Posts: 301
Joined: Tue Dec 16, 2008 4:03 pm
Location: Croatia

Postby rdb » Sun Feb 19, 2012 7:22 am

I've just checked in support for the libRocket debugger:
http://rdb.name/librocket_debugger.png

You can enable it using rocketRegion.initDebugger() and then setDebuggerVisible(True).

It's only available in a build with optimize level 3 and lower, so the standard SDK builds will contain support for it, but in the runtime build (if you pack your app as .p3d), initDebugger will not work and simply return false.

The change will be in tomorrow's devel builds (assuming I didn't make a mistake and the build succeeds) and also in the upcoming 1.8.1 release.
rdb
 
Posts: 9481
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands

Postby Revington » Mon Feb 20, 2012 12:37 pm

Nice, I'll check it out, as soon as possible.

RDB, does your example from above work on your system with threading-model Cull/Draw
support-threads t?
I get random crashes if I fiddle with the buttons etc. I guess it's because of librocket lack of threading support(http://librocket.com/wiki/PlannedFeatures), but just to make sure I didn't break something. :)
Revington
 
Posts: 30
Joined: Thu Nov 18, 2010 10:45 am

Postby rdb » Mon Feb 20, 2012 2:59 pm

Right, libRocket is not thread-safe. I've pondered for a long time about how to resolve this properly on the Panda side, but don't know of a way until perhaps panda switches to boost::python.

Maybe I could submit a patch to the libRocket developer team, but that'd require me to devote a significant amount of time to it, which I don't have.
rdb
 
Posts: 9481
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands

Postby EdBighead » Tue Feb 21, 2012 9:43 am

Does the 501 dev build include the debugger?
EdBighead
 
Posts: 109
Joined: Tue Jan 18, 2011 12:14 pm
Location: U.S.

Postby rdb » Tue Feb 21, 2012 9:48 am

Assuming you mean the Windows SDK build, no, it does not. The next build will.
rdb
 
Posts: 9481
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands

Postby carharttguy » Fri Feb 24, 2012 7:16 am

Sorry if I ask weird questions, or something. I'm pretty new.

But i'm busy with some project in Panda3D, And would really like to use librocket (seems to be a lot better dan DirectGUI to me), I now use the stable version.

My question to the developers is, when will this be in the stable version of Panda? I don't ask an exact date, but, are we speaking about 5 weeks, 4 months or 2 years?

Just to know if it's worth the effort to even start to learn DirectGUI.

Thanks a lot!
carharttguy
 
Posts: 34
Joined: Tue Feb 21, 2012 11:33 am
Location: Belgium

Postby Nemesis#13 » Fri Feb 24, 2012 7:46 am

Stable as in 1.8.1, you mean?

Librocket already is included in 1.8.0, which is considered the current stable release (although releases with a zero at the end of the version number are not as stable as the following ones).

Only thing that is not uncluded in the 1,8,0 release is the librocket debugger, which is helpful, but not necessarily required for using rocket.

BTW:
I'm always using snapshots and never had any major problems with anything.
User avatar
Nemesis#13
 
Posts: 1041
Joined: Mon Aug 04, 2008 8:09 pm
Location: Germany

Postby carharttguy » Fri Feb 24, 2012 9:14 am

Well, this page http://www.panda3d.org/download.php?sdk states that 1.8.0 is likely to be unstable, so I choose for 1.7.2, just to be safe (Again, I'm new, so :) )

But if 1.8.0 includes librocket, and it is not unstable, I will download that right away ;)

Thanks for your help Nemesis!

Edit: I downloaded and installed 1.8.0 (1.8.0-1~oneiric3 to be precise), and when I try to execute this testscript:

Code: Select all
from direct.showbase.ShowBase import ShowBase

print "Imported ShowBase."

import rocket

print "Imported rocket."

from panda3d.rocket import RocketRegion, RocketInputHandler

print "Imported panda3d.rocket."


class MyApp(ShowBase):
    def __init__(self):
        ShowBase.__init__(self)

        print "ShowBase init finished."

        r = RocketRegion.make('pandaRocket', self.win)
        r.setActive(1)

        print "RocketRegion created."

        ih = RocketInputHandler()
        self.mouseWatcher.attachNewNode(ih)
        r.setInputHandler(ih)

        print "RocketInputHandler created."

        context = r.getContext()

        print "Got rocket context."


app = MyApp()
app.run()


It gives this ouput:

Imported ShowBase.
Traceback (most recent call last):
File "naamloos.py", line 5, in <module>
import rocket
ImportError: No module named rocket


------------------
(program exited with code: 1)
Press return to continue


But rocket is included in Panda, so I don't know what to do, install it by myself?
carharttguy
 
Posts: 34
Joined: Tue Feb 21, 2012 11:33 am
Location: Belgium

Postby Nemesis#13 » Fri Feb 24, 2012 11:23 am

Only rocket modules you need are in the panda3d.rocket package.

You shouldn't import "rocket".

Beside that you'll need to load a font into Rocket, before it can write any text.

Take a close look at the sample provided by rdb and try to run that first.
User avatar
Nemesis#13
 
Posts: 1041
Joined: Mon Aug 04, 2008 8:09 pm
Location: Germany

Postby carharttguy » Fri Feb 24, 2012 11:35 am

Oh ok, sorry!

Traceback (most recent call last):
File "test.py", line 1, in <module>
from panda3d.rocket import *
File "/usr/share/panda3d/panda3d.py", line 200, in __getattr__
for obj in dir(self.__manager__.libimport(lib)):
File "/usr/share/panda3d/panda3d.py", line 129, in libimport
raise ImportError, message
ImportError: DLL loader cannot find _rocketcore.


Sorry I'm causing a lot of trouble.

Carharttguy
carharttguy
 
Posts: 34
Joined: Tue Feb 21, 2012 11:33 am
Location: Belgium

Postby rdb » Fri Feb 24, 2012 1:24 pm

That's odd. Are you sure you removed the old version of Panda3D first, and installed Panda3D 1.8.0 from the download page?

If you're sure, can you verify if /usr/lib/panda3d contains a _rocketcore.so and libp3rocket.so file?
rdb
 
Posts: 9481
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands

Postby carharttguy » Sat Feb 25, 2012 5:33 am

rdb wrote:That's odd. Are you sure you removed the old version of Panda3D first, and installed Panda3D 1.8.0 from the download page?

If you're sure, can you verify if /usr/lib/panda3d contains a _rocketcore.so and libp3rocket.so file?


Ok, I check /usr/lib and found 2 files related to librocket:

  • libp3rocket.so
  • libp3rocket.so.1.8


So, the _rocketcore file was missing.
Next, I deleted the 1.8.0 version, and reïnstalled it.

No luck, still can't find the _rocketcore.so. Maybe if someone wants to upload it, I can just paste it into the folder?

Thanks in advance!
carharttguy
 
Posts: 34
Joined: Tue Feb 21, 2012 11:33 am
Location: Belgium

Postby Nemesis#13 » Sat Feb 25, 2012 8:21 am

I don't have the _rocketcore.so either, but for me everything works anyway.
User avatar
Nemesis#13
 
Posts: 1041
Joined: Mon Aug 04, 2008 8:09 pm
Location: Germany

Postby rdb » Mon Feb 27, 2012 2:45 am

Hmm, that's strange. Someone else has reported the same issue to me earlier, but he reported that getting the latest devel build worked for him. Could you try that and see if it works for you?
rdb
 
Posts: 9481
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands

PreviousNext

Return to Panda Features in Development

Who is online

Users browsing this forum: No registered users and 0 guests