#ifndef UI_BASE_CURSOR_CURSOR_H_
#define UI_BASE_CURSOR_CURSOR_H_
#include <vector>
#include "base/component_export.h"
#include "base/memory/scoped_refptr.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/base/cursor/platform_cursor.h"
#include "ui/gfx/geometry/point.h"
namespace gfx {
class Size;
}
namespace ui {
inline constexpr SkColor kDefaultCursorColor = SK_ColorBLACK;
inline constexpr int kDefaultLargeCursorSize = 64;
inline constexpr int kMinLargeCursorSize = 25;
inline constexpr int kMaxLargeCursorSize = 128;
struct COMPONENT_EXPORT(UI_BASE_CURSOR) CursorData {
public:
CursorData();
CursorData(std::vector<SkBitmap> bitmaps,
gfx::Point hotspot,
float scale_factor = 1.0f);
CursorData(const CursorData&);
~CursorData();
std::vector<SkBitmap> bitmaps;
gfx::Point hotspot;
float scale_factor = 1.0f;
};
class COMPONENT_EXPORT(UI_BASE_CURSOR) Cursor {
public:
static Cursor NewCustom(SkBitmap bitmap,
gfx::Point hotspot,
float image_scale_factor = 1.0f);
Cursor();
Cursor(mojom::CursorType type);
Cursor(const Cursor& cursor);
~Cursor();
void SetPlatformCursor(scoped_refptr<PlatformCursor> platform_cursor);
mojom::CursorType type() const { return type_; }
scoped_refptr<PlatformCursor> platform() const { return platform_cursor_; }
const SkBitmap& custom_bitmap() const;
const gfx::Point& custom_hotspot() const;
float image_scale_factor() const;
bool operator==(const Cursor& cursor) const;
bool operator==(mojom::CursorType type) const { return type_ == type; }
static bool AreDimensionsValidForWeb(const gfx::Size& size,
float scale_factor);
private:
Cursor(SkBitmap bitmap, gfx::Point hotspot, float image_scale_factor);
mojom::CursorType type_ = mojom::CursorType::kNull;
scoped_refptr<PlatformCursor> platform_cursor_;
SkBitmap custom_bitmap_;
gfx::Point custom_hotspot_;
float image_scale_factor_ = 1.0f;
};
}
#endif