Urho's internal GUI system is rather minimal at the moment. There's not much one can do with it and it's made rather complicated (at least when one is used to real big GUI systems like Qt). USP uses the internal GUI, see the game state classes (gs_*.cpp) for the GUI usage there (https://github.com/gawag/Urho-Sample-Platformer/tree/master/Source). This page tries to explain some general stuff and common pitfalls.
[There may be wiki articles in the future on how to use other GUI systems inside Urho. The next Urho sample project is quite likely to use something else.]
Urho uses the typical hierarchical UI system of elements being positioned inside and relative to their parents.
Making a window:
Window* window_menu=new Window(context); // Make the window a child of the root element, which fills the whole screen. GetSubsystem<UI>()->GetRoot()->AddChild(window_menu); window_menu->SetSize(300,400);
window_menu->SetLayout(LM_FREE,0,IntRect(10,10,10,10)); // Urho has three layouts: LM_FREE, LM_HORIZONTAL and LM_VERTICAL. // In LM_FREE the child elements of this window can be arranged freely. // In the other two they are arranged as a horizontal or vertical list. // Center this window in it's parent element. window_menu->SetAlignment(HA_CENTER,VA_CENTER);
window_menu->SetColor(Color(.0,.15,.3,.5)); // you can use transparency
Adding a button to the window:
Button* button=new Button(context);
button->SetPosition(10,350); // the position inside and relative to the parent
button->SetName("Button"); // not required
button->SetStyleAuto(); // this is (weirdly) sometimes required for UI elements
button->SetOpacity(0.75); // transparency
// buttons don't have a text by itself, a text needs to be added as a child Text* t=new Text(context); // setting a font is required
window_menu->AddChild(button); // connect the button press event to a function