Console and HtmlPane

https://docs.google.com/file/d/0BwNvfRUx_gIUbl9zMi1WLUVRem8/edit?usp=sharing

You need to apply this patch against latest svn version of tonygodgui.

Inside, there is HtmlPane and Console (plus small fixes to way scrolling works - I hope it has not broken some of other components using scrollbars).

Html Pane:

  • displaying styled html
  • images from arbitrary urls (images from asset loader are loaded using jme3:// protocol)
  • scrollable directly by attaching ScrollBar (no need for ScrollPane)
  • select/copy text to clipboard from html text
  • dynamic resizing

Console

  • doom/quake like console, similar to ChatBox, but with html pane for output
  • command history accessible by pressing up/down arrows
  • command autocompletion/hints

I’m using it as follows
[java]
console = new Console(screen, ā€œConsoleā€, 0.3f) {
@Override
public void executeCommand(String cmd) {
VmatGuiSystem.this.executeCommand(cmd);
}
};

    console.setGlobalAlpha(0.7f);
    console.appendLine("Vmat console",true);

    screen.addElement(console);
    console.hide();
    
    for (String cmd : vmat.getCommandInterpreter().getAllCommands().keySet()) {
        console.addCompletionCommand(cmd);
    }

[/java]

and then have following things bound under global keys in my app
ā€˜~’ key - toggle showConsole/hideConsole
ESC key - hideConsole if it is shown

[java]
public void showConsole() {
console.showWithEffect();
console.setTabFocus();
}

public void hideConsole() {
    console.hideWithEffect();
}

[/java]

and obviously executeCommand pointing to my execution logic.

2 Likes

I’ll have to check this a lil later on. The one caveat (imho) of using ToneGod’s splendid lib is the positioning and (maybe?) resizing.
With it, you have to position each element, which can be tedious, so having an html pane could help a lot here, for some screens.
A vid or some pictures would give a great idea of the potential.
Anyway, thx.

This is looking better and better. Thanks for this!

And @loopies
I agree that initial positioning can be tedious… though, it seems to be getting easier the more I use the library. I still need to do some work with the resizing feature… but remember to use setDockNS, setDockEW on child elements to make sure they position themselves properly. This should ensure that you don’t have to do anything past this to keep child elements positioned where they are supposed to be when resizing.

I still think that the docking is a bit confusing… mostly due to the Y orientation being flipped after you initially create the control. Hopefully, something will click soon and I can simplify this a bit.

Yah, I added ā€œmaybeā€ for the resizing because I did see those dock methods, but didn’t try them yet. Not really a concern for me since my menus fit on a 800*600 page and I’ll probably remove the ability to resize altogether.

I’m just used to html (jspx etc) to position controls in a page.
Been using your lib for my menus and enjoyed using them. Will post a vid when I’m where I want to be.

1 Like

Html pane is just for rich text/pictures - you cannot really embed interactive gui in there (well, you can react to link clicks in custom way, but that’s not the gui). So it is in no way replacement for positioning things. But you can use it to have rich text labels for example, which will be later positioned using normal tonegod facilities.

1 Like

Oki, sorry for confusion