turbobadger icon indicating copy to clipboard operation
turbobadger copied to clipboard

Reloading skin

Open codecat opened this issue 9 years ago • 4 comments
trafficstars

What's the best way to reload a skin at runtime? Currently, I'm using this:

tb::g_tb_skin->UnloadBitmaps();
tb::g_tb_skin->Load("resources/default_skin/skin.tb.txt");
m_root.Invalidate();

This works for colors and such, but not for padding for some reason. Also, would this work on the new shape-based skin system?

codecat avatar Aug 13 '16 11:08 codecat

I actually just realized it doesn't work for padding because the padding is handled at inflate-time. So that would also ultimately require a reload of all widgets.

codecat avatar Aug 13 '16 11:08 codecat

Yes, true. The simple layout that non-TBLayout widgets do, cannot reapply padding like it does when inflated. This is because it doesn't know the difference between widgets that should, and widgets that was given some custom rect programmatically that shouldn't be overwritten.

I think that in the long run, it would be better to always reapply padding & gravity in situations like that (it's also a problem when using strong override with different padding on non-TBLayout layouts). And have a special layout widget (or flag) for when widgets are given custom rects. That should be a rare special case anyway.

fruxo avatar Aug 14 '16 07:08 fruxo

I'll push a fix to shape-rasterizer-3, that makes TBSkin::Load callable multiple times btw. I'll use it to change theme. Same skin and paddings, but with different set of colors.

fruxo avatar Aug 14 '16 07:08 fruxo

Thanks for the clarification!

codecat avatar Aug 14 '16 13:08 codecat