2013-08-09 08:01:20 +08:00
|
|
|
// Aseprite UI Library
|
2021-07-09 21:21:16 +08:00
|
|
|
// Copyright (C) 2020-2021 Igara Studio S.A.
|
2016-03-04 06:17:07 +08:00
|
|
|
// Copyright (C) 2001-2016 David Capello
|
2012-08-11 10:14:54 +08:00
|
|
|
//
|
2014-03-30 07:08:05 +08:00
|
|
|
// This file is released under the terms of the MIT license.
|
|
|
|
|
// Read LICENSE.txt for more information.
|
2012-08-11 10:14:54 +08:00
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2012-08-11 10:14:54 +08:00
|
|
|
#include "config.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#endif
|
2012-08-11 10:14:54 +08:00
|
|
|
|
|
|
|
|
#include "ui/cursor.h"
|
|
|
|
|
|
2016-03-04 06:17:07 +08:00
|
|
|
#include "base/debug.h"
|
2018-08-09 23:58:43 +08:00
|
|
|
#include "os/surface.h"
|
2021-07-09 21:21:16 +08:00
|
|
|
#include "os/system.h"
|
2012-08-11 10:14:54 +08:00
|
|
|
|
|
|
|
|
namespace ui {
|
|
|
|
|
|
2021-07-09 21:21:16 +08:00
|
|
|
Cursor::Cursor(const os::SurfaceRef& surface,
|
|
|
|
|
const gfx::Point& focus)
|
2012-08-11 10:14:54 +08:00
|
|
|
: m_surface(surface)
|
|
|
|
|
, m_focus(focus)
|
2021-07-09 21:21:16 +08:00
|
|
|
, m_scale(0)
|
2012-08-11 10:14:54 +08:00
|
|
|
{
|
2021-07-09 21:21:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Cursor::reset()
|
|
|
|
|
{
|
|
|
|
|
m_surface.reset();
|
|
|
|
|
m_cursor.reset();
|
|
|
|
|
m_focus = gfx::Point(0, 0);
|
|
|
|
|
m_scale = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
os::CursorRef Cursor::nativeCursor(const int scale) const
|
|
|
|
|
{
|
|
|
|
|
if (m_cursor && m_scale == scale)
|
|
|
|
|
return m_cursor;
|
|
|
|
|
|
|
|
|
|
m_cursor = os::instance()->makeCursor(
|
|
|
|
|
m_surface.get(),
|
|
|
|
|
m_focus,
|
|
|
|
|
m_scale = scale);
|
|
|
|
|
return m_cursor;
|
2012-08-11 10:14:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace ui
|