Implement SDL_SetWindowResizable()

Fixes #83
This commit is contained in:
Dmitry Marakasov 2017-07-20 14:12:33 +03:00
parent a53df08ff8
commit f3bc4abd17
4 changed files with 44 additions and 0 deletions

View File

@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## 0.16.0 - unreleased
### Added
* New SDL 2.0.5 ```Window``` method: ```Window::SetResizable()```
## 0.15.0 - 2017-07-10
### Added
* ```Color``` class wrapping around ```SDL_Color```

View File

@ -259,6 +259,11 @@ float Window::GetOpacity() const {
return opacity;
}
Window& Window::SetResizable(bool resizable) {
SDL_SetWindowResizable(window_, resizable ? SDL_TRUE : SDL_FALSE);
return *this;
}
#endif
}

View File

@ -558,6 +558,18 @@ public:
///
////////////////////////////////////////////////////////////
float GetOpacity() const;
////////////////////////////////////////////////////////////
/// \brief Set user-resizable state of a window
///
/// \param[in] resizable True to allow resizing, false to disallow
///
/// \returns Reference to self
///
/// \see http://wiki.libsdl.org/SDL_SetWindowResizable
///
////////////////////////////////////////////////////////////
Window& SetResizable(bool resizable = true);
#endif
};

View File

@ -212,6 +212,29 @@ BEGIN_TEST(int, char*[])
EventSleep(1000);
}
}
{
// Resizable
Uint32 flags = window.GetFlags();
if (flags & SDL_WINDOW_RESIZABLE) {
window.SetResizable(false);
EXPECT_TRUE(!(window.GetFlags() & SDL_WINDOW_RESIZABLE));
EventSleep(1000);
window.SetResizable(true);
EXPECT_TRUE(window.GetFlags() & SDL_WINDOW_RESIZABLE);
EventSleep(1000);
} else {
window.SetResizable(true);
EXPECT_TRUE(window.GetFlags() & SDL_WINDOW_RESIZABLE);
EventSleep(1000);
window.SetResizable(false);
EXPECT_TRUE(!(window.GetFlags() & SDL_WINDOW_RESIZABLE));
EventSleep(1000);
}
}
#endif
END_TEST()