Cursor.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. //
  2. // Copyright (c) 2008-2013 the Urho3D project.
  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 deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // 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 FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #pragma once
  23. #include "BorderImage.h"
  24. namespace Urho3D
  25. {
  26. /// %Cursor shapes recognized by the UI subsystem.
  27. enum CursorShape
  28. {
  29. CS_NORMAL = 0,
  30. CS_RESIZEVERTICAL,
  31. CS_RESIZEDIAGONAL_TOPRIGHT,
  32. CS_RESIZEHORIZONTAL,
  33. CS_RESIZEDIAGONAL_TOPLEFT,
  34. CS_ACCEPTDROP,
  35. CS_REJECTDROP,
  36. CS_MAX_SHAPES
  37. };
  38. /// %Cursor image and hotspot information.
  39. struct CursorShapeInfo
  40. {
  41. /// Texture.
  42. SharedPtr<Texture> texture_;
  43. /// Image rectangle.
  44. IntRect imageRect_;
  45. /// Hotspot coordinates.
  46. IntVector2 hotSpot_;
  47. };
  48. /// Mouse cursor %UI element.
  49. class Cursor : public BorderImage
  50. {
  51. OBJECT(Cursor);
  52. public:
  53. /// Construct.
  54. Cursor(Context* context);
  55. /// Destruct.
  56. virtual ~Cursor();
  57. /// Register object factory.
  58. static void RegisterObject(Context* context);
  59. /// Return UI rendering batches.
  60. virtual void GetBatches(PODVector<UIBatch>& batches, PODVector<UIQuad>& quads, const IntRect& currentScissor);
  61. /// Define a shape.
  62. void DefineShape(CursorShape shape, Texture* texture, const IntRect& imageRect, const IntVector2& hotSpot);
  63. /// Set current shape.
  64. void SetShape(CursorShape shape);
  65. /// Get current shape.
  66. CursorShape GetShape() const { return shape_; }
  67. /// Set shapes attribute.
  68. void SetShapesAttr(VariantVector value);
  69. /// Return shapes attribute.
  70. VariantVector GetShapesAttr() const;
  71. protected:
  72. /// Current shape index.
  73. CursorShape shape_;
  74. /// Shape definitions.
  75. CursorShapeInfo shapeInfos_[CS_MAX_SHAPES];
  76. };
  77. }