DetachedWindow class
#include <Jazz2/UI/Windows/DetachedWindow.h>
Window of the system an element of the interface is shown in, outside of the main window.
The element keeps its position relative to the main window, as everything else of the interface, so it's laid out, drawn and pointed at the same way — the window only shows the part of the interface where the element is. Where the window is on the desktop is what counts though: the window stays there when the main window moves, and the element follows it, see GetDesktopPosition().
What it shows is drawn into a texture by a viewport of its own every frame, and shown in the window after the frame is drawn, see AuxiliaryWindow. On a display with another scale than the main window, the texture has more or fewer pixels than the element has, so it's as large there as it would be in the main window, see GetRaster().
Public types
-
using DrawFunc = Death::
Containers:: Function<void(UI:: Canvas&, DetachedWindow&)> - Draws the element into the picture of the window, given the canvas to draw into.
Public static functions
-
static auto Create(Element* element,
const Rectf& bounds,
Vector2i desktopPosition,
float toDesktop,
bool popup,
bool passThrough,
DrawFunc&& draw) -> std::
unique_ptr<DetachedWindow> - Makes a window for an element,
nullptrif it can't be made.
Constructors, destructors, conversion operators
- ~DetachedWindow()
- DetachedWindow(const DetachedWindow&) deleted
Public functions
- auto operator=(const DetachedWindow&) -> DetachedWindow& deleted
- auto GetElement() const -> Element*
- Returns the element shown in it.
-
auto GetId() const -> std::
uint32_t - Returns the identifier of the window in input events, see PointerEvent::
WindowId. - auto HasRoundedCorners() const -> bool
- Returns
trueif the system rounds the corners of the window, see AuxiliaryWindow::HasRoundedCorners(). - auto IsPopup() const -> bool
- Returns
trueif it's a popup, a menu or a list. - auto GetBounds() const -> const Rectf&
- Returns where the element is relative to the main window and its size, in pixels.
- auto GetDesktopPosition() const -> Vector2i
- Returns where the window is on the desktop, in units of the desktop.
- auto GetDesktopSize() const -> Vector2i
- Returns the size of the window on the desktop, in units of the desktop.
- auto GetRaster() const -> float
- Returns the pixels of the window for a pixel of the main window, 1 on a display with the same scale.
- auto ToDesktop(Vector2f point) const -> Vector2i
- Returns where a point relative to the main window in pixels is on the desktop, as the window shows it.
-
auto GetLines() const -> Rendering::
PolylineRenderer* - Returns the polyline renderer of the window, it draws only into it.
- void Place(const Rectf& bounds, Vector2i desktopPosition, float toDesktop)
- Puts the window on the desktop and the element relative to the main window.
- void Show(bool activate)
- Shows the window, it's seen once its contents are drawn.
- void Hide()
- Hides the window.
- auto IsShown() const -> bool
- Returns
trueif the window is shown. - void Raise()
- Brings the window in front of the others and gives it the focus.
- void SetTitle(StringView title)
- Sets the title of the window, shown on the taskbar.
Function documentation
static std:: unique_ptr<DetachedWindow> Jazz2:: UI:: Windows:: DetachedWindow:: Create(Element* element,
const Rectf& bounds,
Vector2i desktopPosition,
float toDesktop,
bool popup,
bool passThrough,
DrawFunc&& draw)
Makes a window for an element, nullptr if it can't be made.
bounds are relative to the main window in pixels, desktopPosition where the window is on the desktop. With passThrough, the pointer goes through it, as through a tooltip. The element may be nullptr if the function draws something else.
float Jazz2:: UI:: Windows:: DetachedWindow:: GetRaster() const
Returns the pixels of the window for a pixel of the main window, 1 on a display with the same scale.
Rounded, so a few scales are drawn, see Painter::
void Jazz2:: UI:: Windows:: DetachedWindow:: Place(const Rectf& bounds,
Vector2i desktopPosition,
float toDesktop)
Puts the window on the desktop and the element relative to the main window.
The size is in pixels, the position on the desktop in units of the desktop, toDesktop is how many units of the desktop a pixel takes. The viewport of the window is added to the chain of viewports again if it was taken out.