I’ve been trying to create a UI with the built-in UI system, but I’m getting some behaviour that seems weird to me.
UI* ui = GetSubsystem<UI>();
Graphics* graphics = GetSubsystem<Graphics>();
UIElement* root = ui->GetRoot();
// Load the style sheet from xml
root->SetDefaultStyle(cache_->GetResource<XMLFile>("UI/DefaultStyle.xml"));
UIElement* window = root->CreateChild<UIElement>();
window->SetLayout(LM_VERTICAL);
UIElement* topMenu = window->CreateChild<UIElement>();
topMenu->SetLayout(LM_HORIZONTAL);
BorderImage* columnOne = topMenu->CreateChild<BorderImage>();
columnOne->SetLayout(LM_VERTICAL, 6, IntRect(6,6,6,6));
columnOne->SetColor(Color(1.0f, 0.0f, 0.0f));
columnOne->SetMinWidth(graphics->GetWidth()/2);
BorderImage* columnTwo = topMenu->CreateChild<BorderImage>();
columnTwo->SetLayout(LM_VERTICAL, 6, IntRect(6,6,6,6));
columnTwo->SetColor(Color(0.0f, 0.0f, 1.0f));
columnTwo->SetMinWidth(graphics->GetWidth()/2);
CheckBox* checkBox = columnOne->CreateChild<CheckBox>();
checkBox->SetStyleAuto();
CheckBox* checkBox2 = columnTwo->CreateChild<CheckBox>();
checkBox2->SetStyleAuto();
My expected layout versus what I get:
Shouldn’t each column be half the screen width?