KeyWorksRW / wxUiEditor

RAD tool used to create and maintain wxWidgets UI elements.
Apache License 2.0
64 stars 7 forks source link

refactor/fix/improve wxAnimationCtrl code generation #1476

Closed Randalphwa closed 4 months ago

Randalphwa commented 4 months ago

This PR hides the use_generic property for wxAnimationCtrl, and automatically switches to the generic version if a ANI file is used. This ensures that the same code will display ANI files on wxGTK as it does on wxMSW and wxOSX. Note that the generic version is only available for C++ and wxPython code -- wxRuby3 1.0 does not have a generic version of wxAnimationCtrl.

Contrary to the current documentation, the only native version of wxAnimationCtrl is the one for wxGTK. For Windows and Mac, wxAnimationCtrl always uses the underlying generic version. As such, switching to the explicit generic version doesn't make any difference on Windows/Mac since they are already using the generic version.

The code generation had to change how the wxAnimation object is created. Previously, it could be created on the stack using the animation file, and passwed to the constructor for wxAnimationCtrl. However, on wxGTK when wxGenericAnimationCtrl is used, this would result in a crash. Instead, the code now creates an empty wxAnimationCtrl/wxGenericAnimationCtrl, then calls CreateAnimation() to create the control, load the file, and then set the control's animation object. It's a bit convluted, but matches what the XRC handler code does, and even better, it doesn't crash on wxGTK.