All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Go to the documentation of this file.
1/**************************************************************************************************
2 * This file is a part of Ultralight. *
3 * *
4 * See <https://ultralig.ht> for licensing and more. *
5 * *
6 * (C) 2024 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 a portion of a Window.
16///
17/// Overlays are used to display web-based content in a portion of a window. They automatically
18/// forward input events to the underlying View instance and handle rendering.
19///
20/// ## Creating an Overlay
21///
22/// Call Overlay::Create() to create an overlay in a window.
23///
24/// ```
25/// auto overlay = Overlay::Create(window, 1024, 768, 0, 0);
26/// ```
27///
28/// ## Loading Content into an Overlay
29///
30/// Each Overlay has a View instance that you can use to load web content into.
31///
32/// ```
33/// overlay->view()->LoadURL("https://google.com");
34/// ```
35///
36class AExport Overlay : public RefCounted {
37public:
38 ///
39 /// Create a new Overlay.
40 ///
41 /// @param window The window to create the Overlay in.
42 ///
43 /// @param width The width in pixels.
44 ///
45 /// @param height The height in pixels.
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, uint32_t width,
54 uint32_t height, int x, int y);
55
56 ///
57 /// Create a new Overlay, wrapping an existing View.
58 ///
59 /// @param window The window to create the Overlay in.
60 ///
61 /// @param view The View to wrap (will use its width and height).
62 ///
63 /// @param x The x-position (offset from the left of the Window), in
64 /// pixels.
65 ///
66 /// @param y The y-position (offset from the top of the Window), in
67 /// pixels.
68 ///
69 static RefPtr<Overlay> Create(RefPtr<Window> window, RefPtr<View> view, int x, int y);
70
71 ///
72 /// Get the underlying View.
73 ///
75
76 ///
77 /// Get the width (in pixels).
78 ///
79 virtual uint32_t width() const = 0;
80
81 ///
82 /// Get the height (in pixels).
83 ///
84 virtual uint32_t height() const = 0;
85
86 ///
87 /// Get the x-position (offset from the left of the Window), in pixels.
88 ///
89 virtual int x() const = 0;
90
91 ///
92 /// Get the y-position (offset from the top of the Window), in pixels.
93 ///
94 virtual int y() const = 0;
95
96 ///
97 /// Whether or not the overlay is hidden (not drawn).
98 ///
99 virtual bool is_hidden() const = 0;
100
101 ///
102 /// Hide the overlay (will no longer be drawn)
103 ///
104 virtual void Hide() = 0;
105
106 ///
107 /// Show the overlay.
108 ///
109 virtual void Show() = 0;
110
111 ///
112 /// Whether or not this overlay has keyboard focus.
113 ///
114 virtual bool has_focus() const = 0;
115
116 ///
117 /// Grant this overlay exclusive keyboard focus.
118 ///
119 virtual void Focus() = 0;
120
121 ///
122 /// Remove keyboard focus.
123 ///
124 virtual void Unfocus() = 0;
125
126 ///
127 /// Move the overlay to a new position (in pixels).
128 ///
129 virtual void MoveTo(int x, int y) = 0;
130
131 ///
132 /// Resize the overlay (and underlying View), dimensions should be
133 /// specified in pixels.
134 ///
135 virtual void Resize(uint32_t width, uint32_t height) = 0;
136
137 ///
138 /// Whether or not this Overlay needs repaint (either it has moved, resized,
139 /// or the internal View needs repaint).
140 ///
141 virtual bool NeedsRepaint() = 0;
142
143protected:
144 virtual ~Overlay();
145 virtual void Render() = 0;
146 virtual void Paint() = 0;
147 friend class OverlayManager;
148};
149
150} // namespace framework
#define AExport
Definition Defines.h:42
Web-content overlay, displays a web-page within a portion of a Window.
Definition Overlay.h:36
virtual uint32_t height() const =0
Get the height (in pixels).
virtual bool NeedsRepaint()=0
Whether or not this Overlay needs repaint (either it has moved, resized, or the internal View needs r...
virtual void Resize(uint32_t width, uint32_t height)=0
Resize the overlay (and underlying View), dimensions should be specified in pixels.
static RefPtr< Overlay > Create(RefPtr< Window > window, uint32_t width, uint32_t height, int x, int y)
Create a new Overlay.
virtual ultralight::RefPtr< ultralight::View > view()=0
Get the underlying View.
virtual uint32_t width() const =0
Get the width (in pixels).
virtual bool has_focus() const =0
Whether or not this overlay has keyboard focus.
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 Show()=0
Show the overlay.
virtual void Hide()=0
Hide the overlay (will no longer be drawn)
virtual void Focus()=0
Grant this overlay exclusive keyboard focus.
virtual void Unfocus()=0
Remove keyboard focus.
static RefPtr< Overlay > Create(RefPtr< Window > window, RefPtr< View > view, int x, int y)
Create a new Overlay, wrapping an existing View.
virtual void MoveTo(int x, int y)=0
Move the overlay to a new position (in pixels).
virtual void Render()=0
virtual bool is_hidden() const =0
Whether or not the overlay is hidden (not drawn).
virtual void Paint()=0
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