1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef UI_BASE_CURSOR_CURSOR_LOADER_H_ 6 #define UI_BASE_CURSOR_CURSOR_LOADER_H_ 7 8 #include "base/logging.h" 9 #include "base/strings/string16.h" 10 #include "ui/base/ui_base_export.h" 11 #include "ui/gfx/display.h" 12 #include "ui/gfx/native_widget_types.h" 13 #include "ui/gfx/point.h" 14 15 namespace ui { 16 17 class UI_BASE_EXPORT CursorLoader { 18 public: 19 CursorLoader() : scale_(1.f), rotation_(gfx::Display::ROTATE_0) {} 20 virtual ~CursorLoader() {} 21 22 gfx::Display::Rotation rotation() const { 23 return rotation_; 24 } 25 26 void set_rotation(gfx::Display::Rotation rotation) { 27 rotation_ = rotation; 28 } 29 30 // Returns the current scale of the mouse cursor icon. 31 float scale() const { 32 return scale_; 33 } 34 35 // Sets the scale of the mouse cursor icon. 36 void set_scale(const float scale) { 37 scale_ = scale; 38 } 39 40 // Creates a cursor from an image resource and puts it in the cursor map. 41 virtual void LoadImageCursor(int id, 42 int resource_id, 43 const gfx::Point& hot) = 0; 44 45 // Creates an animated cursor from an image resource and puts it in the 46 // cursor map. The image is assumed to be a concatenation of animation frames 47 // from left to right. Also, each frame is assumed to be square 48 // (width == height). 49 // |frame_delay_ms| is the delay between frames in millisecond. 50 virtual void LoadAnimatedCursor(int id, 51 int resource_id, 52 const gfx::Point& hot, 53 int frame_delay_ms) = 0; 54 55 // Unloads all the cursors. 56 virtual void UnloadAll() = 0; 57 58 // Sets the platform cursor based on the native type of |cursor|. 59 virtual void SetPlatformCursor(gfx::NativeCursor* cursor) = 0; 60 61 // Creates a CursorLoader. 62 static CursorLoader* Create(); 63 64 private: 65 // The current scale of the mouse cursor icon. 66 float scale_; 67 68 // The current rotation of the mouse cursor icon. 69 gfx::Display::Rotation rotation_; 70 71 DISALLOW_COPY_AND_ASSIGN(CursorLoader); 72 }; 73 74 } // namespace ui 75 76 #endif // UI_BASE_CURSOR_CURSOR_LOADER_H_ 77