cursor.go 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Copyright 2019 The Ebiten Authors
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package ebiten
  15. import (
  16. "github.com/hajimehoshi/ebiten/v2/internal/ui"
  17. )
  18. // CursorModeType represents a render and coordinate mode of a mouse cursor.
  19. type CursorModeType int
  20. // CursorModeTypes
  21. const (
  22. CursorModeVisible CursorModeType = CursorModeType(ui.CursorModeVisible)
  23. CursorModeHidden CursorModeType = CursorModeType(ui.CursorModeHidden)
  24. CursorModeCaptured CursorModeType = CursorModeType(ui.CursorModeCaptured)
  25. )
  26. // CursorShapeType represents a shape of a mouse cursor.
  27. type CursorShapeType int
  28. // CursorShapeTypes
  29. const (
  30. CursorShapeDefault CursorShapeType = CursorShapeType(ui.CursorShapeDefault)
  31. CursorShapeText CursorShapeType = CursorShapeType(ui.CursorShapeText)
  32. CursorShapeCrosshair CursorShapeType = CursorShapeType(ui.CursorShapeCrosshair)
  33. CursorShapePointer CursorShapeType = CursorShapeType(ui.CursorShapePointer)
  34. CursorShapeEWResize CursorShapeType = CursorShapeType(ui.CursorShapeEWResize)
  35. CursorShapeNSResize CursorShapeType = CursorShapeType(ui.CursorShapeNSResize)
  36. CursorShapeNESWResize CursorShapeType = CursorShapeType(ui.CursorShapeNESWResize)
  37. CursorShapeNWSEResize CursorShapeType = CursorShapeType(ui.CursorShapeNWSEResize)
  38. CursorShapeMove CursorShapeType = CursorShapeType(ui.CursorShapeMove)
  39. CursorShapeNotAllowed CursorShapeType = CursorShapeType(ui.CursorShapeNotAllowed)
  40. )
  41. // CursorShape returns the current cursor shape.
  42. //
  43. // CursorShape returns CursorShapeDefault on mobiles.
  44. //
  45. // CursorShape is concurrent-safe.
  46. func CursorShape() CursorShapeType {
  47. return CursorShapeType(ui.Get().CursorShape())
  48. }
  49. // SetCursorShape sets the cursor shape.
  50. //
  51. // If the platform doesn't implement the given shape, the default cursor shape is used.
  52. //
  53. // SetCursorShape is concurrent-safe.
  54. func SetCursorShape(shape CursorShapeType) {
  55. ui.Get().SetCursorShape(ui.CursorShape(shape))
  56. }