First of all, the only officially supported way to include TGUI is by including TGUI.hpp. If you chose to include other files directly then you are relying on implementation details and you could run into dependency issues like this.
The files have changed a lot, so I'm not sure if there still is a reason why it remains like this, but there are 2 reasons why the current design might have been chosen:
- To improve compilation speed. Lots of templates can slow down compilation, so it might be beneficial to only include them when needed instead of including them in a file that is included by practically every source file (like Widget.hpp). This of course only affects compiling TGUI itself as in your own code you need to include the signal header anyway, plus the performance difference might not be noticeable.
- To fix a circular dependency. Widget uses Signal, but Signal also uses Widget. Looking at the code, this doesn't seem to be an issue as SignalImpl uses shared_ptr<Widget> instead of Widget::Ptr, so that it doesn't need to include Widget.hpp. But it could have been the reason why the signal code was originally split into 2 files.