38 hilet size =
extent2{DIAMETER * 3.0f + 2.0f * MARGIN + 2.0f * SPACING, DIAMETER + 2.0f * MARGIN};
39 return {size, size, size};
50 closeRectangle =
aarectangle{point2(MARGIN, extent.height() / 2.0f - RADIUS),
extent2{DIAMETER, DIAMETER}};
53 aarectangle{point2(MARGIN + DIAMETER + SPACING, extent.height() / 2.0f - RADIUS),
extent2{DIAMETER, DIAMETER}};
56 point2(MARGIN + DIAMETER + SPACING + DIAMETER + SPACING, extent.height() / 2.0f - RADIUS),
59 closeWindowGlyph = find_glyph(hikogui_icon::CloseWindow);
60 minimizeWindowGlyph = find_glyph(hikogui_icon::MinimizeWindow);
61 maximizeWindowGlyph = find_glyph(hikogui_icon::MaximizeWindowMacOS);
62 restoreWindowGlyph = find_glyph(hikogui_icon::RestoreWindowMacOS);
70 closeWindowGlyphRectangle = align(closeRectangle,
closeWindowGlyphBB, alignment::middle_center());
71 minimizeWindowGlyphRectangle = align(minimizeRectangle,
minimizeWindowGlyphBB, alignment::middle_center());
72 maximizeWindowGlyphRectangle = align(maximizeRectangle,
maximizeWindowGlyphBB, alignment::middle_center());
73 restoreWindowGlyphRectangle = align(maximizeRectangle,
restoreWindowGlyphBB, alignment::middle_center());
81 pressedClose ?
color(1.0f, 0.242f, 0.212f) :
82 color(1.0f, 0.1f, 0.082f);
86 pressedMinimize ?
color(1.0f, 0.847f, 0.093f) :
87 color(0.784f, 0.521f, 0.021f);
91 pressedMaximize ?
color(0.223f, 0.863f, 0.1f) :
92 color(0.082f, 0.533f, 0.024f);
98 layout(), translate_z(0.1f) * closeWindowGlyphRectangle, closeWindowGlyph,
color{0.319f, 0.0f, 0.0f});
100 layout(), translate_z(0.1f) * minimizeWindowGlyphRectangle, minimizeWindowGlyph,
color{0.212f, 0.1f, 0.0f});
102 if (
layout().window_size_state == gui_window_size::maximized) {
104 layout(), translate_z(0.1f) * restoreWindowGlyphRectangle, restoreWindowGlyph,
color{0.0f, 0.133f, 0.0f});
108 translate_z(0.1f) * maximizeWindowGlyphRectangle,
110 color{0.0f, 0.133f, 0.0f});
118 switch (
event.type()) {
119 case gui_event_type::mouse_move:
120 case gui_event_type::mouse_drag:
133 case gui_event_type::mouse_exit:
135 hoverMinimize =
false;
136 hoverMaximize =
false;
140 case gui_event_type::mouse_down:
141 if (
event.mouse().cause.left_button) {
145 }
else if (minimizeRectangle.
contains(
event.mouse().position)) {
146 pressedMinimize =
true;
148 }
else if (maximizeRectangle.
contains(
event.mouse().position)) {
149 pressedMaximize =
true;
156 case gui_event_type::mouse_up:
157 if (
event.mouse().cause.left_button) {
158 pressedClose =
false;
159 pressedMinimize =
false;
160 pressedMaximize =
false;
166 }
else if (minimizeRectangle.
contains(
event.mouse().position)) {
169 }
else if (maximizeRectangle.
contains(
event.mouse().position)) {
170 switch (
layout().window_size_state) {
171 case gui_window_size::normal:
174 case gui_window_size::maximized:
190 [[
nodiscard]] hitbox hitbox_test(point2 position)
const noexcept override
192 hi_axiom(loop::main().on_thread());
196 return hitbox{
id, _layout.elevation, hitbox_type::button};
203 constexpr static int GLYPH_SIZE = 5;
204 constexpr static int RADIUS = 5;
205 constexpr static int DIAMETER = RADIUS * 2;
206 constexpr static int MARGIN = 10;
207 constexpr static int SPACING = 8;
213 font_book::font_glyph_type closeWindowGlyph;
214 font_book::font_glyph_type minimizeWindowGlyph;
215 font_book::font_glyph_type maximizeWindowGlyph;
216 font_book::font_glyph_type restoreWindowGlyph;
223 bool hoverClose =
false;
224 bool hoverMinimize =
false;
225 bool hoverMaximize =
false;
227 bool pressedClose =
false;
228 bool pressedMinimize =
false;
229 bool pressedMaximize =
false;