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_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_EXPORT CursorLoader { 18 public: 19 CursorLoader() : scale_(1.f) {} 20 virtual ~CursorLoader() {} 21 22 // Returns the display the loader loads images for. 23 const gfx::Display& display() const { 24 return display_; 25 } 26 27 // Sets the display the loader loads images for. 28 void set_display(const gfx::Display& display) { 29 display_ = display; 30 } 31 32 // Returns the current scale of the mouse cursor icon. 33 float scale() const { 34 return scale_; 35 } 36 37 // Sets the scale of the mouse cursor icon. 38 void set_scale(const float scale) { 39 scale_ = scale; 40 } 41 42 // Creates a cursor from an image resource and puts it in the cursor map. 43 virtual void LoadImageCursor(int id, 44 int resource_id, 45 const gfx::Point& hot) = 0; 46 47 // Creates an animated cursor from an image resource and puts it in the 48 // cursor map. The image is assumed to be a concatenation of animation frames 49 // from left to right. Also, each frame is assumed to be square 50 // (width == height). 51 // |frame_delay_ms| is the delay between frames in millisecond. 52 virtual void LoadAnimatedCursor(int id, 53 int resource_id, 54 const gfx::Point& hot, 55 int frame_delay_ms) = 0; 56 57 // Unloads all the cursors. 58 virtual void UnloadAll() = 0; 59 60 // Sets the platform cursor based on the native type of |cursor|. 61 virtual void SetPlatformCursor(gfx::NativeCursor* cursor) = 0; 62 63 // Creates a CursorLoader. 64 static CursorLoader* Create(); 65 66 private: 67 // The display the loader loads images for. 68 gfx::Display display_; 69 70 // The current scale of the mouse cursor icon. 71 float scale_; 72 73 DISALLOW_COPY_AND_ASSIGN(CursorLoader); 74 }; 75 76 } // namespace ui 77 78 #endif // UI_BASE_CURSOR_CURSOR_LOADER_H_ 79