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 <memory>
10#include <string>
11#include <array>
12
13namespace tt {
14struct graphic_path;
15}
16
17namespace tt {
18
20public:
21 using super = widget;
22
25
26 [[nodiscard]] bool
27 update_constraints(hires_utc_clock::time_point display_time_point, bool need_reconstrain) noexcept override;
28 [[nodiscard]] void update_layout(hires_utc_clock::time_point display_time_point, bool need_layout) noexcept override;
29 void draw(draw_context context, hires_utc_clock::time_point display_time_point) noexcept override;
30
31 bool handle_event(mouse_event const &event) noexcept override;
32 [[nodiscard]] hit_box hitbox_test(point2 position) const noexcept override;
33
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
41 aarectangle closeRectangle;
42 aarectangle minimizeRectangle;
43 aarectangle maximizeRectangle;
44
45 font_glyph_ids closeWindowGlyph;
46 font_glyph_ids minimizeWindowGlyph;
47 font_glyph_ids maximizeWindowGlyph;
48 font_glyph_ids restoreWindowGlyph;
49
50 aarectangle closeWindowGlyphRectangle;
51 aarectangle minimizeWindowGlyphRectangle;
52 aarectangle maximizeWindowGlyphRectangle;
53 aarectangle restoreWindowGlyphRectangle;
54
55 bool hoverClose = false;
56 bool hoverMinimize = false;
57 bool hoverMaximize = false;
58
59 bool pressedClose = false;
60 bool pressedMinimize = false;
61 bool pressedMaximize = false;
62
63 void drawMacOS(draw_context const &context, hires_utc_clock::time_point display_time_point) noexcept;
64 void drawWindows(draw_context const &context, hires_utc_clock::time_point display_time_point) noexcept;
65};
66
67}
Class which represents an axis-aligned rectangle.
Definition axis_aligned_rectangle.hpp:18
Draw context for drawing using the TTauri shaders.
Definition draw_context.hpp:33
Definition gui_window.hpp:37
Definition hit_box.hpp:15
Definition mouse_event.hpp:15
Definition font_glyph_ids.hpp:78
Definition widget.hpp:97
widget(gui_window &window, std::shared_ptr< abstract_container_widget > parent) noexcept
gui_window & window
Convenient reference to the Window.
Definition widget.hpp:101
abstract_container_widget const & parent() const noexcept
Get a reference to the parent.
Definition window_traffic_lights_widget.hpp:19
void update_layout(hires_utc_clock::time_point display_time_point, bool need_layout) noexcept override
Update the internal layout of the widget.
void draw(draw_context context, hires_utc_clock::time_point display_time_point) noexcept override
Draw the widget.
bool update_constraints(hires_utc_clock::time_point display_time_point, bool need_reconstrain) noexcept override
Update the constraints of the widget.
bool handle_event(mouse_event const &event) noexcept override
hit_box hitbox_test(point2 position) const noexcept override
Find the widget that is under the mouse cursor.