MogreBetaGUI - Talk

Beauty

22-04-2008 11:16:47

.
This is a thread for talking, asking and improving related to the GUI system MogreBetaGUI.

The Wiki page is here:
http://www.ogre3d.org/wiki/index.php/MogreBetaGUI

The talk about the original Ogre add-on is here:
http://www.ogre3d.org/phpBB2/viewtopic.php?t=25853

Beauty

22-04-2008 11:22:24

This I moved from Wiki discussion page to here, because in our wiki nearly nobody read/use it.

.
Intention of BetaGUI

I don't think it's very good to overload this GUI with lots of information. It should be kept short and simple to help developers getting a quick overview of a working gui system. raygeee


agreed
public Overlay mO, mMPo; // Overlay, MousePointerOverlay (it just needs it own)
public Window mXW; // KillWindow (special boX for killing the window)
public OverlayContainer mMP; // MousePointer

//buttons, inputs ...
public OverlayContainer mO, mCP; // memberOverlay, memberCaption
public String mmn, mma; // not-active, active

raygeee

28-04-2008 21:38:32

I just added a link to the original posting of the porter (http://www.ogre3d.org/phpBB2/viewtopic.php?t=25853&postdays=0&postorder=asc&start=259) and the original source code header (like Betajaen requested).

As far as I understand funguine's post the port is based on revision 015 of BetaGUI. There have been some newer versions (seems most of them replaced older ones).
At least 4 different versions can be found on Betajaen's website: http://get.nxogre.org/betagui/
If somebody is interested in more features he can port one of those.

Update: Added some information to the add-ons page related to MogreBetaGUI including classification under the Public Domain license.

Beauty

28-04-2008 22:39:48

In the [u]Ogre thread[/u] somebody answered to my question "2.5 = 015 = 1.0'15 or whatever. MogerBetaGUI was ported from this version."

So I supposed, it's right. Nice that you did correct it in the wiki.

I still know, I want to improve my little modified version and publish it in a simple sample program. This should also show the current problems.

my problems with the public code
(just as a remark)

* ''curPlayMode'' and ''PlayMode'' are not defined
* on resizing / moving with medium or fast speed, mouse pointer lost capture to window
* Changing the text field is bad implemented - just Backspace and entering '1' are possible

raygeee

28-04-2008 23:07:55

Well for number 1 we could simply remove the three lines referencing the non-existing enumeration "PlayMode". The sample code would compile then.

About number 2 I don't know, is this a bug which also happens in the c++ version?

Concerning number 3 we could implement some more keys (like for example a,s,d,f), but it would be an overkill to implement all keys. That's just not the purpose of the sample code. This is something anyone can do for himself and still compile and run the sample code.

Beauty

29-04-2008 11:25:22

(1)
Right. Because of this I want to create a full runable demo.

(2)
I have no idea about C++ programming. In the BetaGUI thread I didn't read about this.

(3)
A text input field should accept at least all letters and numbers. I try to create a solution (with MOIS?) to support without to ask for each key seperatly.
I didn't know about MOIS when I experimented with MogreBetaGui.
So I tried something like this:
this.renderPanel.KeyDown += new KeyEventHandler(renderPanel_KeyDownHandler);

// ...

void renderPanel_KeyDownHandler(object sender, KeyEventArgs e)
{
if (e.KeyData != Keys.None)
{
// get input from e.KeyData
}
}

But I couldn't find out how to convert the information of e.KeyData to a String or Char. The method ToString() didn't work right, but today I can't remember why. Maybe it just wrote a numered key code?

Luth

29-04-2008 13:07:47

Hi.

Are we talking about the standard WindowsForms Events and Eventargs here? Then maybe something like ...

myString += (char) e.KeyCode;

or

myString += Convert.ToChar(e.KeyCode);

... would work?


Edit:
Forget that above .... it seems if you use OnKeyPress you get all letters, numbers and symbols. But you don't get things like Backspace, Escape and such:

void window_KeyPress(object sender, KeyPressEventArgs e)
{
System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();

Char c = (char)e.KeyChar;

messageBoxCS.AppendFormat("{0} = {1}", "Test", c.ToString());
MessageBox.Show(messageBoxCS.ToString(), "KeyDown Event");
}


If you are using KeyDown- or Keyup-Events, you have to do it manually. That way you get info on the pressed keys, modifiers and at least lower/upper letters and numbers. Unfortunatly you do not get symbols like ' # . ! and similar.


System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "Alt", e.Alt);
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Control", e.Control);
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Handled", e.Handled);
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "KeyCode", e.KeyCode);
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "KeyValue", e.KeyValue);
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "KeyData", e.KeyData);
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Modifiers", e.Modifiers);
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Shift", e.Shift);
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "SuppressKeyPress", e.SuppressKeyPress);
messageBoxCS.AppendLine();

if ((e.Shift) && (Char.IsLetter((char)e.KeyCode)))
messageBoxCS.AppendFormat("{0} = {1}", "InputSymbol", Char.ToUpper((char)(e.KeyCode)));

if ((!e.Shift) && (Char.IsLetter((char)e.KeyCode)))
messageBoxCS.AppendFormat("{0} = {1}", "InputSymbol", Char.ToLower((char)(e.KeyCode)));

if (!(Char.IsLetter((char)e.KeyCode)))
messageBoxCS.AppendFormat("{0} = {1}", "InputSymbol",(char)(e.KeyCode));

MessageBox.Show(messageBoxCS.ToString(), "KeyDown Event");


So i suppose it's best to implement both events if you want to do it with WindowsForm-Events at all. The Keypress-Events for entering text and the KeyUp/Down Events to delete text with backspace, insert linebreaks, move the cursor and such. And if you want to use MOIS i have no idea what their event-args look like and how to do it then. :mrgreen:

Beauty

14-09-2008 01:32:15

After a long time I started to create a simple demo application.

Now I still have problems.
It's my first try with MOIS.

For this I used the code of the wiki.
When I use these lines together then I get the exeption
OverlayElement with name ContainerHack10 already exists.
Nowhere in code/ressource files I found a String with this name.
mGui.createMousePointer(new Vector2(30, 30), "bgui.pointer");
single = window.createButton(new Vector4(10, 30, 100, 30),
"bgui.button", "Button 1", cc);



Some code changes ago the mouse pointer was always hidden while the program was running. (except for pressing Alt+Tab)


Well, now my demo application only can display the GUI.
But the mouse input is not working.
So moving/resizing window, clicking button, focus the input field is not possible.

Here is the complete project:
http://www.beauty-of-darkness.de/pub/Mo ... emo_1a.rar

If somebody is interested he can test it.
After improvements I would be happy to get the changed code.
If the application works well, I would add the download link to the wiki.
(my mail address: beautyod at gmx.de)

Roy Berube

17-09-2008 05:23:05

I can see what you are missing. Here is the code you need to get on the right track. The MOIS inputs need to be captured each frame.

I have your code running in buffered mode with 5 callbacks for mouse and keyboard. The window dragging and resizing isn't working correctly so I don't think you'll want that.

public void Go()
{
Show();
while (mRoot != null && mRoot.RenderOneFrame())
{
// Capture all key presses since last check. MOIS needs to be updated.
inputKeyboard.Capture();
// Capture all mouse movements and button presses since last check.
inputMouse.Capture();
Application.DoEvents();
}

}

Roy Berube

17-09-2008 05:50:42

Since we are on the topic of improving MogreBetaGui, here is some code I did a while back to create some alterable text. The methods can be dropped into the betagui c# code.

//2/13/08 for alterable text.
public OverlayElement createAlterableOverlay(String N, Vector2 P, Vector2 D,
String M, String C, bool A)
{
String t = "Panel";
if (C != "")
t = "TextArea";

OverlayElement e = OverlayManager.Singleton.CreateOverlayElement(t, N);
e.MetricsMode = GuiMetricsMode.GMM_PIXELS;
e.SetDimensions(D.x, D.y);
e.SetPosition(P.x, P.y);
if (C != "")
{
e.Caption = C;
e.SetParameter("font_name", mFont);
e.SetParameter("char_height", StringConverter.ToString(mFontSize));
}
OverlayContainer c = (OverlayContainer)OverlayManager.Singleton.CreateOverlayElement("Panel", "ContainerHack" + (oc++).ToString());
c.MetricsMode = GuiMetricsMode.GMM_PIXELS;
c.SetDimensions(D.x, D.y);
c.SetPosition(P.x, P.y);
if (M != "")
c.MaterialName = M;
c.AddChild(e);
if (A)
{
mO.Add2D(c);
c.Show();
}
return e;
}

//returns the element with the caption.
public OverlayElement createAlterableText(Vector4 D, String text)
{
OverlayElement x = mGUI.createAlterableOverlay(mO.Name +
StringConverter.ToString(mGUI.tc++),
new Vector2(D.x, D.y), new Vector2(D.z, D.w), "", text, true);//false works
mO.AddChild(x);
x.Show();
return x;
}


The text field is created like so:

testElement = window.createAlterableText(new Vector4(0, 150, Viewport.ActualWidth / 6, 30), "t");


and updated like so:

testElement.Caption = ("dPitch = " + rocket.dPitch.ValueDegrees );


I wanted to update some data output every frame and this does the trick.

Beauty

17-09-2008 08:36:13

Great - thanks for the help!

I was thinking about if I have to create a new static text for every frame. But this would be no good performance.
So your extension is realy nice :)

In my first tests (without MOIS) the moving/resizing generally worked although it had some problems. You can send me the modified code. Maybe I can improve it.

Did you also get the ContainerHack10 exception?

Roy Berube

18-09-2008 02:11:47

Beauty:
No, I'm not getting the container exception. I suspect a fix could be to use a static uint variable that increments with each new element, and append the variable to each new element name on creation. No possibility of naming conflicts then.

I'll email my project files over to you (vc# 2008). And btw I was looking at the code for the dragging of windows and it would need a rework. The line is in the 'check' method at case 3. As designed the window does not get dragged if the mouse moves so fast it moves out of the window title-bar within one frame update. The dragging method used is really a kludge and only snaps the title-bar to the mouse. Try changing the '/2' to '/4' and see how the window snaps to 1/4 position on the mouse.

Beauty

18-09-2008 07:31:54

With the container - I don't know where the elements will be created. I found no such string.

For the window moving - nice that you found the source of problems. Maybe other BetaGUI users didn't have this problem, because of a better frame rate. My main develop computer on university has only a very bad graphic card.
Do you think that the problem is also in the current version of original BetaGUI?
Maybe we should report this in the BetaGUI thread. Then possibly the author or others make an update and we just have to port it. Also then more users have a solution for this problem.