HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
WindowTrafficLightsWidget.hpp
1// Copyright 2019 Pokitec
2// All rights reserved.
3
4#pragma once
5
6#include "TTauri/Widgets/Widget.hpp"
7#include "TTauri/Foundation/Path.hpp"
8#include <memory>
9#include <string>
10#include <array>
11
12namespace tt {
13struct Path;
14}
15
16namespace tt {
17
19public:
20 static constexpr float GLYPH_SIZE = 5.0f;
21 static constexpr float RADIUS = 5.5f;
22 static constexpr float DIAMETER = RADIUS * 2.0f;
23 static constexpr float MARGIN = 10.0f;
24 static constexpr float SPACING = 8.0f;
25
26 aarect closeRectangle;
27 aarect minimizeRectangle;
28 aarect maximizeRectangle;
29
30 FontGlyphIDs closeWindowGlyph;
31 FontGlyphIDs minimizeWindowGlyph;
32 FontGlyphIDs maximizeWindowGlyph;
33 FontGlyphIDs restoreWindowGlyph;
34
35 aarect closeWindowGlyphRectangle;
36 aarect minimizeWindowGlyphRectangle;
37 aarect maximizeWindowGlyphRectangle;
38 aarect restoreWindowGlyphRectangle;
39
40 bool hoverClose = false;
41 bool hoverMinimize = false;
42 bool hoverMaximize = false;
43
44 bool pressedClose = false;
45 bool pressedMinimize = false;
46 bool pressedMaximize = false;
47
48 WindowTrafficLightsWidget(Window &window, Widget *parent) noexcept;
50
52 WindowTrafficLightsWidget &operator=(const WindowTrafficLightsWidget &) = delete;
55
56 void layout(hires_utc_clock::time_point displayTimePoint) noexcept override;
57 void draw(DrawContext const &drawContext, hires_utc_clock::time_point displayTimePoint) noexcept override;
58
59 void handleMouseEvent(MouseEvent const &event) noexcept override;
60 [[nodiscard]] HitBox hitBoxTest(vec position) const noexcept override;
61
62private:
63 static vec calculateExtent(Window &window) noexcept;
64
65 void drawMacOS(DrawContext const &drawContext, hires_utc_clock::time_point displayTimePoint) noexcept;
66 void drawWindows(DrawContext const &drawContext, hires_utc_clock::time_point displayTimePoint) noexcept;
67
68};
69
70}
Class which represents an axis-aligned rectangle.
Definition aarect.hpp:13
A 4D vector.
Definition vec.hpp:37
Draw context for drawing using the TTauri shaders.
Definition DrawContext.hpp:30
Definition HitBox.hpp:12
Definition MouseEvent.hpp:12
Definition Window_vulkan_win32.hpp:15
Definition FontGlyphIDs.hpp:77
Definition Widget.hpp:64
Definition WindowTrafficLightsWidget.hpp:18
void handleMouseEvent(MouseEvent const &event) noexcept override
void layout(hires_utc_clock::time_point displayTimePoint) noexcept override
Layout the widget.
HitBox hitBoxTest(vec position) const noexcept override
Find the widget that is under the mouse cursor.
void draw(DrawContext const &drawContext, hires_utc_clock::time_point displayTimePoint) noexcept override
Draw widget.