2020-01-18 08:38:21 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
|
|
* list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2019-03-31 20:09:10 +00:00
|
|
|
#pragma once
|
|
|
|
|
2020-02-06 11:04:00 +00:00
|
|
|
#include <LibGfx/GraphicsBitmap.h>
|
2019-03-31 20:09:10 +00:00
|
|
|
|
2019-06-07 15:13:23 +00:00
|
|
|
enum class WSStandardCursor {
|
2019-03-31 21:52:02 +00:00
|
|
|
None = 0,
|
|
|
|
Arrow,
|
|
|
|
IBeam,
|
2019-04-02 00:34:09 +00:00
|
|
|
ResizeHorizontal,
|
|
|
|
ResizeVertical,
|
2019-05-02 23:38:24 +00:00
|
|
|
ResizeDiagonalTLBR,
|
|
|
|
ResizeDiagonalBLTR,
|
2019-10-10 19:35:12 +00:00
|
|
|
Hand,
|
2019-12-08 19:28:48 +00:00
|
|
|
Drag,
|
2019-03-31 21:52:02 +00:00
|
|
|
};
|
|
|
|
|
2019-06-21 13:29:31 +00:00
|
|
|
class WSCursor : public RefCounted<WSCursor> {
|
2019-03-31 20:09:10 +00:00
|
|
|
public:
|
2020-02-06 10:56:38 +00:00
|
|
|
static NonnullRefPtr<WSCursor> create(NonnullRefPtr<Gfx::Bitmap>&&, const Gfx::Point& hotspot);
|
|
|
|
static NonnullRefPtr<WSCursor> create(NonnullRefPtr<Gfx::Bitmap>&&);
|
2019-06-21 16:37:47 +00:00
|
|
|
static RefPtr<WSCursor> create(WSStandardCursor);
|
2019-03-31 20:09:10 +00:00
|
|
|
~WSCursor();
|
|
|
|
|
|
|
|
Point hotspot() const { return m_hotspot; }
|
2020-02-06 10:56:38 +00:00
|
|
|
const Gfx::Bitmap& bitmap() const { return *m_bitmap; }
|
2019-03-31 20:09:10 +00:00
|
|
|
|
|
|
|
Rect rect() const { return m_bitmap->rect(); }
|
|
|
|
Size size() const { return m_bitmap->size(); }
|
|
|
|
|
|
|
|
private:
|
2020-02-06 10:56:38 +00:00
|
|
|
WSCursor(NonnullRefPtr<Gfx::Bitmap>&&, const Gfx::Point&);
|
2019-03-31 20:09:10 +00:00
|
|
|
|
2020-02-06 10:56:38 +00:00
|
|
|
RefPtr<Gfx::Bitmap> m_bitmap;
|
|
|
|
Gfx::Point m_hotspot;
|
2019-03-31 20:09:10 +00:00
|
|
|
};
|