From 42e345061429abe1c7e74d523b25659fe6859bb8 Mon Sep 17 00:00:00 2001 From: player-03 Date: Fri, 12 Aug 2022 12:16:26 -0400 Subject: [PATCH] Sort functions and standardize formatting. The new version no longer checks the return code of `SDL_GetWindowOpacity`, for consistency with the other getters. In theory this should be fine, because the only documented error condition is if the window is invalid, at which point none of the getters matter. If the platform doesn't support transparency, "opacity will be reported as 1.0f without error." --- project/src/backend/sdl/SDLWindow.cpp | 36 +++++++++++++++------------ 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/project/src/backend/sdl/SDLWindow.cpp b/project/src/backend/sdl/SDLWindow.cpp index 92c3017c3..6709ca036 100644 --- a/project/src/backend/sdl/SDLWindow.cpp +++ b/project/src/backend/sdl/SDLWindow.cpp @@ -496,9 +496,6 @@ namespace lime { } - - - const char* SDLWindow::GetContextType () { if (context) { @@ -592,6 +589,17 @@ namespace lime { } + float SDLWindow::GetOpacity () { + + float opacity = 1.0f; + + SDL_GetWindowOpacity (sdlWindow, &opacity); + + return opacity; + + } + + double SDLWindow::GetScale () { if (sdlRenderer) { @@ -1010,6 +1018,13 @@ namespace lime { } + void SDLWindow::SetOpacity (float opacity) { + + SDL_SetWindowOpacity (sdlWindow, opacity); + + } + + bool SDLWindow::SetResizable (bool resizable) { #ifndef EMSCRIPTEN @@ -1076,23 +1091,12 @@ namespace lime { } - void SDLWindow::WarpMouse (int x, int y){ + void SDLWindow::WarpMouse (int x, int y) { SDL_WarpMouseInWindow (sdlWindow, x, y); } - float SDLWindow::GetOpacity() { - float opacity = 1.0; - if(SDL_GetWindowOpacity(sdlWindow, &opacity) != 0) { - return 1.0; - } - return opacity; - } - - void SDLWindow::SetOpacity(float opacity) { - SDL_SetWindowOpacity(sdlWindow, opacity); - } Window* CreateWindow (Application* application, int width, int height, int flags, const char* title) { @@ -1101,4 +1105,4 @@ namespace lime { } -} \ No newline at end of file +}