1// Aseprite
2// Copyright (C) 2020 Igara Studio S.A.
3// Copyright (C) 2016-2017 David Capello
4//
5// This program is distributed under the terms of
6// the End-User License Agreement for Aseprite.
7
8#ifndef APP_UI_EDITOR_GLUE_H_INCLUDED
9#define APP_UI_EDITOR_GLUE_H_INCLUDED
10#pragma once
11
12#include "app/tools/pointer.h"
13#include "app/ui/editor/editor.h"
14#include "base/vector2d.h"
15#include "ui/message.h"
16
17namespace app {
18
19// Code to convert "ui" messages to "tools" mouse pointers
20
21inline tools::Pointer::Button button_from_msg(const ui::MouseMessage* msg)
22{
23 return
24 (msg->right() ? tools::Pointer::Right:
25 (msg->middle() ? tools::Pointer::Middle:
26 tools::Pointer::Left));
27}
28
29inline tools::Pointer pointer_from_msg(
30 Editor* editor,
31 const ui::MouseMessage* msg,
32 const tools::Vec2& velocity = tools::Vec2(0.0f, 0.0f))
33{
34 return
35 tools::Pointer(editor->screenToEditor(msg->position()),
36 velocity,
37 button_from_msg(msg),
38 msg->pointerType(),
39 msg->pressure());
40}
41
42} // namespace app
43
44#endif
45