HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
window_traffic_lights_widget.hpp
1// Copyright Take Vos 2020-2021.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include "widget.hpp"
8#include "../graphic_path.hpp"
9#include "../text/font_glyph_ids.hpp"
10#include <memory>
11#include <string>
12#include <array>
13
14namespace tt {
15struct graphic_path;
16}
17
18namespace tt {
19
21public:
22 using super = widget;
23
25
27 [[nodiscard]] float margin() const noexcept override;
28 [[nodiscard]] bool constrain(utc_nanoseconds display_time_point, bool need_reconstrain) noexcept override;
29 [[nodiscard]] void layout(utc_nanoseconds display_time_point, bool need_layout) noexcept override;
30 void draw(draw_context context, utc_nanoseconds display_time_point) noexcept override;
31 bool handle_event(mouse_event const &event) noexcept override;
32 [[nodiscard]] hitbox hitbox_test(point2 position) const noexcept override;
34private:
35 static constexpr float GLYPH_SIZE = 5.0f;
36 static constexpr float RADIUS = 5.5f;
37 static constexpr float DIAMETER = RADIUS * 2.0f;
38 static constexpr float MARGIN = 10.0f;
39 static constexpr float SPACING = 8.0f;
40
43 float _glyph_size;
44
45 aarectangle closeRectangle;
46 aarectangle minimizeRectangle;
47 aarectangle maximizeRectangle;
48
49 font_glyph_ids closeWindowGlyph;
50 font_glyph_ids minimizeWindowGlyph;
51 font_glyph_ids maximizeWindowGlyph;
52 font_glyph_ids restoreWindowGlyph;
53
54 aarectangle closeWindowGlyphRectangle;
55 aarectangle minimizeWindowGlyphRectangle;
56 aarectangle maximizeWindowGlyphRectangle;
57 aarectangle restoreWindowGlyphRectangle;
58
59 bool hoverClose = false;
60 bool hoverMinimize = false;
61 bool hoverMaximize = false;
62
63 bool pressedClose = false;
64 bool pressedMinimize = false;
65 bool pressedMaximize = false;
66
67 void drawMacOS(draw_context const &context, utc_nanoseconds display_time_point) noexcept;
68 void drawWindows(draw_context const &context, utc_nanoseconds display_time_point) noexcept;
69};
70
71} // namespace tt
Class which represents an axis-aligned rectangle.
Definition axis_aligned_rectangle.hpp:20
Draw context for drawing using the TTauri shaders.
Definition draw_context.hpp:28
Definition gui_window.hpp:39
Definition hitbox.hpp:14
Definition mouse_event.hpp:15
Definition font_glyph_ids.hpp:80
An interactive graphical object as part of the user-interface.
Definition widget.hpp:37
widget *const parent
Pointer to the parent widget.
Definition widget.hpp:46
gui_window & window
Convenient reference to the Window.
Definition widget.hpp:41
widget(gui_window &window, widget *parent) noexcept
Definition window_traffic_lights_widget.hpp:20