Custom childWindow not fully displayed

Started by byronhaochen, 26 December 2024, 06:43:17

byronhaochen

I use childWindow as the base class to make a custom widget, but the background becomes invisible after drawing. What is the reason for this?  :)
2024-12-26 13-32-29-76.jpg
NewProjectWindow::NewProjectWindow(const char* typeName, bool initRenderer) :
ChildWindow(typeName, false)
{
if (initRenderer)
{
m_renderer = aurora::makeCopied<NewProjectWindowRenderer>();
setRenderer(Theme::getDefault()->getRendererNoThrow(m_type));
}
setTitleButtons(ChildWindow::TitleButton::None);
setTextSize(getGlobalTextSize());

setClientSize({ 450, 350 });
init();
}


texus

The theme doesn't contain a section for your custom widget, so the BackgroundColor and TitleBarColor in the renderer are never set. No value is apparently transparent here.

In your constructor code you have 'getRendererNoThrow(m_type)', I guess if you change it to 'getRendererNoThrow("ChildWindow")' then it would load correctly.

Alternatively, the Theme class has a few static functions to allow specifying relationships between widgets. I'm guessing you need 'tgui::Theme::addRendererInheritanceParent("YourCustomWidgetName", "ChildWindow");' somewhere before creating the widget to tell the Theme to fall back to the "ChildWindow" section for your custom widget type if no more specific section exists.