sdlWindowMgr.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _WINDOWMANAGER_SDL_WINDOWMANAGER_
  23. #define _WINDOWMANAGER_SDL_WINDOWMANAGER_
  24. #include "math/mMath.h"
  25. #include "gfx/gfxStructs.h"
  26. #include "windowManager/sdl/sdlWindow.h"
  27. #include "core/util/tVector.h"
  28. struct SDL_Window;
  29. class FileDialog; // TODO SDL REMOVE
  30. /// SDL2 implementation of the window manager interface.
  31. class PlatformWindowManagerSDL : public PlatformWindowManager
  32. {
  33. friend class PlatformWindowSDL;
  34. friend class FileDialog; // TODO SDL REMOVE
  35. virtual void _processCmdLineArgs(const S32 argc, const char **argv);
  36. /// Link the specified window into the window list.
  37. void linkWindow(PlatformWindowSDL *w);
  38. /// Remove specified window from the window list.
  39. void unlinkWindow(PlatformWindowSDL *w);
  40. /// Callback for the process list.
  41. void _process();
  42. /// List of allocated windows.
  43. PlatformWindowSDL *mWindowListHead;
  44. /// Parent window, used in window setup in web plugin scenarios.
  45. SDL_Window *mParentWindow;
  46. /// This is set as part of the canvas being shown, and flags that the windows should render as normal from now on.
  47. // Basically a flag that lets the window manager know that we've handled the splash screen, and to operate as normal.
  48. bool mDisplayWindow;
  49. /// set via command line -offscreen option, controls whether rendering/input
  50. // is intended for offscreen rendering
  51. bool mOffscreenRender;
  52. /// If a curtain window is present, then will be stored here.
  53. SDL_Window *mCurtainWindow;
  54. Map<U32, PlatformWindowSDL*> mWindowMap;
  55. SignalSlot<void()> mOnProcessSignalSlot;
  56. public:
  57. PlatformWindowManagerSDL();
  58. ~PlatformWindowManagerSDL();
  59. virtual RectI getPrimaryDesktopArea();
  60. virtual S32 getDesktopBitDepth();
  61. virtual Point2I getDesktopResolution();
  62. /// Build out the monitors list.
  63. virtual void buildMonitorsList();
  64. virtual S32 findFirstMatchingMonitor(const char* name);
  65. virtual U32 getMonitorCount();
  66. virtual const char* getMonitorName(U32 index);
  67. virtual RectI getMonitorRect(U32 index);
  68. virtual void getMonitorRegions(Vector<RectI> &regions);
  69. virtual PlatformWindow *createWindow(GFXDevice *device, const GFXVideoMode &mode);
  70. virtual void getWindows(VectorPtr<PlatformWindow*> &windows);
  71. virtual void setParentWindow(void* newParent);
  72. virtual void* getParentWindow();
  73. virtual PlatformWindow *getWindowById(WindowId id);
  74. virtual PlatformWindow *getFirstWindow();
  75. virtual PlatformWindow* getFocusedWindow();
  76. virtual void lowerCurtain();
  77. virtual void raiseCurtain();
  78. virtual void setDisplayWindow(bool set) { mDisplayWindow = set; }
  79. };
  80. #endif