diff options
Diffstat (limited to 'chromium/ui/base/cursor/cursor_loader.h')
-rw-r--r-- | chromium/ui/base/cursor/cursor_loader.h | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/chromium/ui/base/cursor/cursor_loader.h b/chromium/ui/base/cursor/cursor_loader.h index 0c516d7fa7c..767758e1619 100644 --- a/chromium/ui/base/cursor/cursor_loader.h +++ b/chromium/ui/base/cursor/cursor_loader.h @@ -5,22 +5,28 @@ #ifndef UI_BASE_CURSOR_CURSOR_LOADER_H_ #define UI_BASE_CURSOR_CURSOR_LOADER_H_ +#include <map> #include <memory> #include "base/component_export.h" +#include "ui/base/cursor/cursor.h" #include "ui/base/cursor/cursor_size.h" #include "ui/base/cursor/mojom/cursor_type.mojom-forward.h" #include "ui/display/display.h" -#include "ui/gfx/native_widget_types.h" + +namespace gfx { +class Point; +} namespace ui { +class CursorFactory; class COMPONENT_EXPORT(UI_BASE_CURSOR) CursorLoader { public: - CursorLoader() = default; + explicit CursorLoader(bool use_platform_cursors = true); CursorLoader(const CursorLoader&) = delete; CursorLoader& operator=(const CursorLoader&) = delete; - virtual ~CursorLoader() = default; + ~CursorLoader(); // Returns the rotation and scale of the currently loaded cursor. display::Display::Rotation rotation() const { return rotation_; } @@ -28,39 +34,34 @@ class COMPONENT_EXPORT(UI_BASE_CURSOR) CursorLoader { // Sets the rotation and scale the cursors are loaded for. // Returns true if the cursor image was reloaded. - bool SetDisplayData(display::Display::Rotation rotation, float scale) { - if (rotation_ == rotation && scale_ == scale) - return false; - - rotation_ = rotation; - scale_ = scale; - UnloadCursors(); - return true; - } + bool SetDisplayData(display::Display::Rotation rotation, float scale); // Returns the size of the currently loaded cursor. CursorSize size() const { return size_; } // Sets the size of the mouse cursor icon. - void set_size(CursorSize size) { - if (size_ == size) - return; + void SetSize(CursorSize size); - size_ = size; - UnloadCursors(); - } + // Sets the platform cursor based on the type of |cursor|. + void SetPlatformCursor(Cursor* cursor); - // Sets the platform cursor based on the native type of |cursor|. - virtual void SetPlatformCursor(gfx::NativeCursor* cursor) = 0; + private: + // Resets the cursor cache. + void UnloadCursors(); + void LoadImageCursor(mojom::CursorType id, + int resource_id, + const gfx::Point& hot); + PlatformCursor CursorFromType(mojom::CursorType type); + PlatformCursor LoadCursorFromAsset(mojom::CursorType type); - // Creates a CursorLoader. - static std::unique_ptr<CursorLoader> Create(bool use_platform_cursors = true); + // Whether to use cursors provided by the underlying platform (e.g. X11 + // cursors). If false or in the case of a failure, Chromium assets will be + // used instead. + const bool use_platform_cursors_; - protected: - // Resets the cursor cache. - virtual void UnloadCursors() = 0; + std::map<mojom::CursorType, PlatformCursor> image_cursors_; + CursorFactory* factory_ = nullptr; - private: // The current scale of the mouse cursor icon. float scale_ = 1.0f; |