zomgistania

Main page | About | Articles | Previous Posts | Archives

Monday, June 12, 2006

User Interface

I'm reworking the classes I used for creating some simple GUI elements. The old classes I had were a bit bad I might say... not very simple to use as I'd like.

I'm currently working on a bit similar model as System.Windows.Forms.Control uses.

I have a "base" class called Control. It's basically a class which holds 1-9 Quad-objects.



Control c = new Control(Vector3.Empty, new SizeF(5, 10));

c.SetBorders(0.1f);

c.SetTexture(TextureManager.GetTextureData("white"));

c.SetBackgroundColor(Color.Brown);

c.SetBorderColor(Color.Red);

c.HookMouse();

c.MouseOver += new EventHandler(c_MouseOver);

c.MouseOut += new EventHandler(c_MouseOut);




Okay and now the CopySourceAsHTML2005 plugin has been tested too.

So that's how the Control works. I also made a quick wrapper around the mouse events in a WinForms Control. The HookMouse() command hooks mouse events from the MouseManager and allows for functionality like MouseOver and MouseOut.

The Control initially holds a single Quad. When calling SetBorders, 8 more are added (top corners, top, left side, right side, bottom corners and bottom) which hold the actual border data. The whole block can only use a single texture, but I'm going to add UV-coordinate support and maybe completely different textures if I feel I'm going to use that.

The color methods are simple: They just set a Material with the color given as Emissive light. Works wonders! If you use a white texture like in the example code, the color shows up, not as white, but as pure red if you set it to red. Result will obviously be different if you set a texture which is not white, but then you can use the functions to create different tones or such.


I'm going to add support for adding child controls, and maybe for dragging and dropping the controls to other places and such.


I also need to add something to allow a Control to smoothly slide from the side to the middle of the screen or something like that. Transitions, or whatever they should be called. They could probably just be a bunch of Vector3's which define the start location and the result location... maybe something fancy, like a rotation.

Adding rotations would need matrixes though.. well, not necessarily, but I'm not going to work positioning all the different vertices by hand when they're turned or such! Maybe later.
Using a matrix translation for a menu transition or something would cause very little effect on performance. It would just require one another DrawIndexedPrimitives call anyway, as the whole menu could be batched using the same matrix, and the functionality for sorting quads into proper buffers is already in the RenderPipeline, I just need to add detections for matrixes there or such.


Gah. Maybe it would be time to go sleep. 7 AM... so it's getting kind of late.. or early, depending on how you like to think. ;)

Labels:

0 Comments:

Post a Comment

<< Home