1// Aseprite UI Library
2// Copyright (C) 2019-2021 Igara Studio S.A.
3// Copyright (C) 2001-2018 David Capello
4//
5// This file is released under the terms of the MIT license.
6// Read LICENSE.txt for more information.
7
8#ifndef UI_SYSTEM_H_INCLUDED
9#define UI_SYSTEM_H_INCLUDED
10#pragma once
11
12#include "gfx/fwd.h"
13#include "ui/base.h"
14#include "ui/cursor_type.h"
15
16#include <functional>
17#include <string>
18
19namespace ui {
20
21 class ClipboardDelegate;
22 class Cursor;
23 class Display;
24 class Widget;
25
26 class UISystem {
27 public:
28 static UISystem* instance();
29
30 UISystem();
31 ~UISystem();
32
33 void setClipboardDelegate(ClipboardDelegate* delegate) {
34 m_clipboardDelegate = delegate;
35 }
36 ClipboardDelegate* clipboardDelegate() {
37 return m_clipboardDelegate;
38 }
39 private:
40 ClipboardDelegate* m_clipboardDelegate;
41 };
42
43 void set_multiple_displays(bool multi);
44 bool get_multiple_displays();
45
46 void set_clipboard_text(const std::string& text);
47 bool get_clipboard_text(std::string& text);
48
49 // Mouse related
50
51 // Updates the position of the mouse cursor overlay depending on the
52 // current mouse position.
53 void update_cursor_overlay();
54
55 void set_use_native_cursors(bool state);
56 CursorType get_mouse_cursor();
57 void set_mouse_cursor(CursorType type, const Cursor* cursor = nullptr);
58 void set_mouse_cursor_scale(const int newScale);
59 void set_mouse_cursor_reset_info();
60
61 void hide_mouse_cursor();
62 void show_mouse_cursor();
63
64 void _internal_set_mouse_display(Display* display);
65 void _internal_no_mouse_position();
66
67 // Returns desktop/screen mouse position (relative to no-display)
68 gfx::Point get_mouse_position();
69
70 // Sets the mouse position relative to a specific display (or
71 // relative to the desktop if it's nullptr)
72 void set_mouse_position(const gfx::Point& newPos,
73 Display* display);
74
75 void execute_from_ui_thread(std::function<void()>&& func);
76 bool is_ui_thread();
77#ifdef _DEBUG
78 void assert_ui_thread();
79#else
80 static inline void assert_ui_thread() { }
81#endif
82
83} // namespace ui
84
85#endif
86