Ultralight C++ API 1.3.0
Loading...
Searching...
No Matches
Overlay.h
Go to the documentation of this file.
1/******************************************************************************
2 * This file is a part of Ultralight, an ultra-portable web-browser engine. *
3 * *
4 * See <https://ultralig.ht> for licensing and more. *
5 * *
6 * (C) 2023 Ultralight, Inc. *
7 *****************************************************************************/
8#pragma once
9#include "Window.h"
10#include <Ultralight/View.h>
11
12namespace ultralight {
13
14///
15/// Web-content overlay. Displays a web-page within an area of a Window.
16///
17/// @note Each Overlay is essentially a View and an on-screen quad. You should
18/// create the Overlay then load content into the underlying View.
19///
20class AExport Overlay : public RefCounted {
21public:
22 ///
23 /// Create a new Overlay.
24 ///
25 /// @param window The window to create the Overlay in.
26 ///
27 /// @param width The width in pixels.
28 ///
29 /// @param height The height in pixels.
30 ///
31 /// @param x The x-position (offset from the left of the Window), in
32 /// pixels.
33 ///
34 /// @param y The y-position (offset from the top of the Window), in
35 /// pixels.
36 ///
37 static RefPtr<Overlay> Create(RefPtr<Window> window, uint32_t width,
38 uint32_t height, int x, int y);
39
40 ///
41 /// Create a new Overlay, wrapping an existing View.
42 ///
43 /// @param window The window to create the Overlay in.
44 ///
45 /// @param view The View to wrap (will use its width and height).
46 ///
47 /// @param x The x-position (offset from the left of the Window), in
48 /// pixels.
49 ///
50 /// @param y The y-position (offset from the top of the Window), in
51 /// pixels.
52 ///
53 static RefPtr<Overlay> Create(RefPtr<Window> window, RefPtr<View> view, int x, int y);
54
55 ///
56 /// Get the underlying View.
57 ///
59
60 ///
61 /// Get the width (in pixels).
62 ///
63 virtual uint32_t width() const = 0;
64
65 ///
66 /// Get the height (in pixels).
67 ///
68 virtual uint32_t height() const = 0;
69
70 ///
71 /// Get the x-position (offset from the left of the Window), in pixels.
72 ///
73 virtual int x() const = 0;
74
75 ///
76 /// Get the y-position (offset from the top of the Window), in pixels.
77 ///
78 virtual int y() const = 0;
79
80 ///
81 /// Whether or not the overlay is hidden (not drawn).
82 ///
83 virtual bool is_hidden() const = 0;
84
85 ///
86 /// Hide the overlay (will no longer be drawn)
87 ///
88 virtual void Hide() = 0;
89
90 ///
91 /// Show the overlay.
92 ///
93 virtual void Show() = 0;
94
95 ///
96 /// Whether or not this overlay has keyboard focus.
97 ///
98 virtual bool has_focus() const = 0;
99
100 ///
101 /// Grant this overlay exclusive keyboard focus.
102 ///
103 virtual void Focus() = 0;
104
105 ///
106 /// Remove keyboard focus.
107 ///
108 virtual void Unfocus() = 0;
109
110 ///
111 /// Move the overlay to a new position (in pixels).
112 ///
113 virtual void MoveTo(int x, int y) = 0;
114
115 ///
116 /// Resize the overlay (and underlying View), dimensions should be
117 /// specified in pixels.
118 ///
119 virtual void Resize(uint32_t width, uint32_t height) = 0;
120
121 ///
122 /// Whether or not this Overlay needs repaint (either it has moved, resized,
123 /// or the internal View needs repaint).
124 ///
125 virtual bool NeedsRepaint() = 0;
126
127protected:
128 virtual ~Overlay();
129 virtual void Paint() = 0;
130 friend class OverlayManager;
131};
132
133} // namespace framework
#define AExport
Definition Defines.h:42
Web-content overlay.
Definition Overlay.h:20
static RefPtr< Overlay > Create(RefPtr< Window > window, RefPtr< View > view, int x, int y)
Create a new Overlay, wrapping an existing View.
virtual void Hide()=0
Hide the overlay (will no longer be drawn)
virtual bool has_focus() const =0
Whether or not this overlay has keyboard focus.
virtual uint32_t width() const =0
Get the width (in pixels).
virtual void Focus()=0
Grant this overlay exclusive keyboard focus.
virtual void Resize(uint32_t width, uint32_t height)=0
Resize the overlay (and underlying View), dimensions should be specified in pixels.
virtual bool is_hidden() const =0
Whether or not the overlay is hidden (not drawn).
virtual bool NeedsRepaint()=0
Whether or not this Overlay needs repaint (either it has moved, resized, or the internal View needs r...
virtual void MoveTo(int x, int y)=0
Move the overlay to a new position (in pixels).
virtual int y() const =0
Get the y-position (offset from the top of the Window), in pixels.
virtual int x() const =0
Get the x-position (offset from the left of the Window), in pixels.
virtual void Paint()=0
virtual void Unfocus()=0
Remove keyboard focus.
virtual ultralight::RefPtr< ultralight::View > view()=0
Get the underlying View.
virtual uint32_t height() const =0
Get the height (in pixels).
static RefPtr< Overlay > Create(RefPtr< Window > window, uint32_t width, uint32_t height, int x, int y)
Create a new Overlay.
virtual void Show()=0
Show the overlay.
Interface for all ref-counted objects that will be managed using the RefPtr<> smart pointer.
Definition RefPtr.h:47
A nullable smart pointer.
Definition RefPtr.h:79
Definition App.h:14