mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-06 03:29:44 -06:00
Create timer that allows the browser to reload before changing the border radius
This commit is contained in:
@@ -37,6 +37,7 @@ namespace openspace {
|
||||
|
||||
class ScreenSpaceSkyBrowser : public ScreenSpaceRenderable, public WwtCommunicator {
|
||||
public:
|
||||
static constexpr int RadiusTimeOut = 25;
|
||||
explicit ScreenSpaceSkyBrowser(const ghoul::Dictionary& dictionary);
|
||||
~ScreenSpaceSkyBrowser() override;
|
||||
|
||||
@@ -80,6 +81,7 @@ private:
|
||||
bool _ratioIsDirty = false;
|
||||
bool _radiusIsDirty = false;
|
||||
bool _isInitialized = false;
|
||||
int _borderRadiusTimer = -1;
|
||||
|
||||
float _ratio = 1.f;
|
||||
};
|
||||
|
||||
@@ -129,6 +129,7 @@ ScreenSpaceSkyBrowser::ScreenSpaceSkyBrowser(const ghoul::Dictionary& dictionary
|
||||
|
||||
_scale.onChange([this]() {
|
||||
updateTextureResolution();
|
||||
_borderRadiusTimer = 0;
|
||||
});
|
||||
|
||||
_useRadiusAzimuthElevation.onChange(
|
||||
@@ -325,11 +326,15 @@ void ScreenSpaceSkyBrowser::update() {
|
||||
if (_shouldReload) {
|
||||
_isInitialized = false;
|
||||
}
|
||||
|
||||
if (_radiusIsDirty && _isInitialized) {
|
||||
// After the texture has been updated, wait a little bit before updating the border
|
||||
// radius so the browser has time to update its size
|
||||
if (_radiusIsDirty && _isInitialized && _borderRadiusTimer == RadiusTimeOut) {
|
||||
setBorderRadius(_borderRadius);
|
||||
_radiusIsDirty = false;
|
||||
_borderRadiusTimer = -1;
|
||||
}
|
||||
_borderRadiusTimer++;
|
||||
|
||||
|
||||
ScreenSpaceRenderable::update();
|
||||
WwtCommunicator::update();
|
||||
|
||||
Reference in New Issue
Block a user