CursorManager.cc 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 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. #include "platform/platformInput.h"
  23. #include "platform/platformVideo.h"
  24. #include "platform/event.h"
  25. #include "console/console.h"
  26. //------------------------------------------------------------------------------
  27. //*** DAW: Cursor Manager Methods
  28. CursorManager* Input::getCursorManager()
  29. {
  30. return smCursorManager;
  31. }
  32. void CursorManager::pushCursor(S32 cursorID)
  33. {
  34. //*** Place the new cursor shape onto the stack
  35. mCursors.increment();
  36. mCursors.last().mCursorID = cursorID;
  37. //*** Now actually change the shape
  38. changeCursorShape(cursorID);
  39. }
  40. void CursorManager::popCursor()
  41. {
  42. //*** Before poping the stack, make sure we're not trying to remove the last cursor shape
  43. if(mCursors.size() <= 1)
  44. return;
  45. //*** Pop the stack
  46. mCursors.pop_back();
  47. //*** Now set the cursor shape
  48. changeCursorShape(mCursors.last().mCursorID);
  49. }
  50. void CursorManager::refreshCursor()
  51. {
  52. //*** Refresh the cursor's shape
  53. changeCursorShape(mCursors.last().mCursorID);
  54. }
  55. void CursorManager::changeCursorShape(S32 cursorID)
  56. {
  57. if(cursorID >= 0)
  58. Input::setCursorShape((U32)cursorID);
  59. }
  60. static EnumTable::Enums curManagerShapesEnums[] =
  61. {
  62. { CursorManager::curArrow, "Arrow" },
  63. { CursorManager::curWait, "Wait" },
  64. { CursorManager::curPlus, "Plus" },
  65. { CursorManager::curResizeVert, "ResizeVert" },
  66. { CursorManager::curResizeHorz, "ResizeHorz" },
  67. { CursorManager::curResizeAll, "ResizeAll" },
  68. { CursorManager::curIBeam, "ibeam" },
  69. { CursorManager::curResizeNESW, "ResizeNESW" },
  70. { CursorManager::curResizeNWSE, "ResizeNWSE" },
  71. };
  72. static EnumTable gCurManagerShapesTable(8, &curManagerShapesEnums[0]);
  73. //------------------------------------------------------------------------------
  74. #include "CursorManager_ScriptBinding.h"