acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
window.h
1//
2// window.h
3// acme
4// Created by camilo on 2026-02-39 15:09 <3ThomasBorregaardSørensen!!
5//
6// Created by Camilo Sasuke Thomas Borregaard Sørensen on 20/02/26.
7// Copyright © 2026 ca2 Software Development. All rights reserved.
8//
9#pragma once
10
11
12#include "acme/constant/windowing2.h"
13
14
15struct opaque_t {};
16
17
18CLASS_DECL_ACME bool best_effort_is_same_operating_system_window(::acme::windowing::window * pacmewindowingwindow, const ::lparam & lparam);
19
20
21namespace operating_system
22{
23
24
25 //struct window_opaque_union_type
26 //{
27
28 // union
29 // {
30
31 // ::u8 m_opaque[32];
32 // ::u64 m_la[4];
33
34 // };
35
36 //};
37
38
39 struct window_opaque_t
40 //: public window_opaque_union_type
41 {
42
43
44 union
45 {
46
47 ::u8 m_opaque[24];
48 ::u64 m_ulla[3];
49
50 };
51
52
53 window_opaque_t(nullptr_t)
54 {
55
56 this->Null();
57
58 }
59
60
61 window_opaque_t() :
62 window_opaque_t(nullptr)
63 {
64
65 }
66
67
68 window_opaque_t(const window_opaque_t& window)
69 {
70
71 this->operator = (window);
72
73 }
74
75 window_opaque_t(
76 ::u64 ulla0,
77 ::u64 ulla1,
78 ::u64 ulla2)
79 {
80
81 this->m_ulla[0] = ulla0;
82 this->m_ulla[1] = ulla1;
83 this->m_ulla[2] = ulla2;
84
85 }
86
87
88 void Null()
89 {
90
91 this->m_ulla[0] = 0;
92 this->m_ulla[1] = 0;
93 this->m_ulla[2] = 0;
94
95 }
96
97
98 bool is_null() const
99 {
100
101 return
102 this->m_ulla[0] == 0
103 && this->m_ulla[1] == 0
104 && this->m_ulla[2] == 0;
105
106 }
107
108
109 bool is_set() const
110 {
111
112 return !this->is_null();
113
114 }
115
116
117 bool operator == (const window_opaque_t& windowopaque) const
118 {
119
120 return
121 this->m_ulla[0] == windowopaque.m_ulla[0]
122 && this->m_ulla[1] == windowopaque.m_ulla[1]
123 && this->m_ulla[2] == windowopaque.m_ulla[2];
124
125 }
126
127
128 window_opaque_t& operator = (const window_opaque_t& windowopaque)
129 {
130
131 this->m_ulla[0] = windowopaque.m_ulla[0];
132 this->m_ulla[1] = windowopaque.m_ulla[1];
133 this->m_ulla[2] = windowopaque.m_ulla[2];
134
135 return *this;
136
137 }
138
139
140 operator ::hash32() const
141 {
142 return ::as_hash32(this->m_ulla[0])
143 + ::as_hash32(this->m_ulla[1])
144 + ::as_hash32(this->m_ulla[2]);
145 }
146
147
148
149 };
150
151
152 template < typename WINDOW_T >
153 struct a_window_t
154 {
155
156
157 using WINDOW_TYPE = WINDOW_T;
158
159
160 union
161 {
162
163 window_opaque_t m_opaque;
164 WINDOW_T m_window;
165
166 };
167
168
169 a_window_t(nullptr_t) { this->Null(); }
170
171
172 a_window_t() : a_window_t(nullptr) {}
173
174
175 template < typename WINDOW_OPAQUE_T >
176 requires (!::is_same < WINDOW_T, window_opaque_t >
177 && ::is_same < WINDOW_OPAQUE_T, window_opaque_t >)
178 a_window_t(const WINDOW_OPAQUE_T& windowopaque)
179 {
180
181 this->operator = (windowopaque);
182
183 }
184
185
186 a_window_t(const WINDOW_T & window)
187 {
188
189 this->operator = (window);
190
191 }
192
193
194 void Null() { this->m_window.Null(); }
195
196
197 bool operator == (const a_window_t & awindowt) const
198 {
199
200 return this->m_window == awindowt.m_window;
201
202 }
203
204
205 template < typename WINDOW_OPAQUE_T >
206 requires (!::is_same < WINDOW_T, window_opaque_t >
207 && ::is_same < WINDOW_OPAQUE_T, window_opaque_t >)
208 bool operator ==(const WINDOW_OPAQUE_T & windowopaque) const
209 {
210
211 return this->m_opaque == windowopaque;
212
213 }
214
215
216 bool operator == (const WINDOW_TYPE & window) const
217 {
218
219 return this->m_window == window;
220
221 }
222
223
224 a_window_t& operator = (const a_window_t & awindowt)
225 {
226
227 this->m_window = awindowt.m_window;
228
229 return *this;
230
231 }
232
233
234 template < typename WINDOW_OPAQUE_T >
235 requires (!::is_same < WINDOW_T, window_opaque_t >
236 && ::is_same < WINDOW_OPAQUE_T, window_opaque_t >)
237 a_window_t& operator = (const WINDOW_OPAQUE_T & windowopaque)
238 {
239
240 this->m_opaque = windowopaque;
241
242 return *this;
243
244 }
245
246
247 a_window_t& operator = (const WINDOW_T & window)
248 {
249
250 this->m_window = window;
251
252 return *this;
253
254 }
255
256
257 bool is_null() const
258 {
259
260 return m_window.is_null();
261
262 }
263
264
265 bool is_set() const
266 {
267
268 return !this->is_null();
269
270 }
271
272
273 operator ::hash32() const { return m_opaque; }
274
275
276 };
277
278
279 template < ::windowing::enum_operating_ambient t_eoperatingambient, typename WINDOW_T >
280 class a_window;
281
282
283 using window = a_window < ::windowing::e_operating_ambient_none, window_opaque_t >;
284
285
286 template < ::windowing::enum_operating_ambient t_eoperatingambient, typename WINDOW_T >
287 class a_window :
288 public a_window_t < WINDOW_T >
289 {
290 protected:
291 ::acme::windowing::window * m_pacmewindowingwindow;
292 public:
293
294
295 using BASE_TYPE = a_window_t < WINDOW_T >;
296
297
298 using WINDOW_TYPE = typename BASE_TYPE::WINDOW_TYPE;
299
300
301 ::windowing::enum_operating_ambient m_eoperatingambient;
302
303
304 a_window(nullptr_t)
305 {
306
307 this->Null();
308
309 }
310
311
312 a_window() :
313 a_window(nullptr)
314 {
315
316 }
317
318
319 a_window(const a_window & awindow) :
320 m_pacmewindowingwindow(awindow.m_pacmewindowingwindow),
321 m_eoperatingambient(awindow.m_eoperatingambient),
322 BASE_TYPE(awindow.m_window)
323 {
324
325 }
326
327
328 template < typename WINDOW >
329 requires (!::is_same < WINDOW_TYPE, window_opaque_t >
330 && ::is_same < WINDOW, window >)
331 a_window(const WINDOW & window) :
332 m_pacmewindowingwindow(window._get_acme_windowing_window()),
333 m_eoperatingambient(window.m_eoperatingambient),
334 BASE_TYPE(window.m_opaque)
335 {
336
337 }
338
339
340 a_window(const WINDOW_TYPE & window, ::acme::windowing::window * pacmewindowingwindow = nullptr) :
341 m_pacmewindowingwindow(pacmewindowingwindow),
342 m_eoperatingambient(t_eoperatingambient),
343 BASE_TYPE(window)
344 {
345
346 }
347
348
349 template < typename WINDOW_OPAQUE_T >
350 requires (!::is_same < WINDOW_T, window_opaque_t >
351 && ::is_same < WINDOW_OPAQUE_T, window_opaque_t >)
352 a_window(const ::windowing::enum_operating_ambient& eoperatingambient, const WINDOW_OPAQUE_T & windowopaque, ::acme::windowing::window* pacmewindowingwindow = nullptr) :
353 m_pacmewindowingwindow(pacmewindowingwindow),
354 m_eoperatingambient(eoperatingambient),
355 BASE_TYPE(windowopaque)
356 {
357
358 }
359
360 a_window(const ::windowing::enum_operating_ambient& eoperatingambient,
361 ::u64 ulla0,
362 ::u64 ulla1 = 0,
363 ::u64 ulla2 = 0) :
364 m_pacmewindowingwindow(nullptr),
365 m_eoperatingambient(eoperatingambient),
366 BASE_TYPE({ulla0, ulla1, ulla2})
367 {
368
369 }
370
371
372 void _set_acme_windowing_window(::acme::windowing::window * pwindow)
373 {
374
375 m_pacmewindowingwindow = pwindow;
376
377 }
378
379
380 ::acme::windowing::window * _get_acme_windowing_window() const
381 {
382
383 return m_pacmewindowingwindow;
384
385 }
386
387
388
389 void Null()
390 {
391 this->m_window.Null();
392 m_pacmewindowingwindow = nullptr;
393 m_eoperatingambient = ::windowing::e_operating_ambient_none;
394 }
395
396
397 ::operating_system::window & as_operating_system_window()
398 {
399
400 auto pthis = (::operating_system::window*)this;
401
402 return *pthis;
403
404 }
405
406
407 const ::operating_system::window & as_operating_system_window() const
408 {
409
410 auto pthis = (::operating_system::window*)this;
411
412 return *pthis;
413
414 }
415
416
417 bool is_null() const
418 {
419
420 return (m_eoperatingambient == ::windowing::e_operating_ambient_none
421 || BASE_TYPE::is_null()) && m_pacmewindowingwindow == nullptr;
422
423 }
424
425
426 bool is_impact() const
427 {
428
429 return (m_eoperatingambient == ::windowing::e_operating_ambient_macos_impact2)
430 || (m_eoperatingambient == ::windowing::e_operating_ambient_macos_impact_by_tag);
431
432 }
433
434
435 bool is_set() const
436 {
437
438 return !this->is_null();
439
440 }
441
442
443 bool operator == (const ::operating_system::window& operatingsystemwindow) const
444 {
445
446 if (operatingsystemwindow.m_eoperatingambient != ::windowing::e_operating_ambient_none)
447 {
448
449 return (this->m_eoperatingambient == operatingsystemwindow.m_eoperatingambient
450 && BASE_TYPE::operator == (operatingsystemwindow.m_window));
451
452 }
453
454 return m_pacmewindowingwindow == operatingsystemwindow.m_pacmewindowingwindow;
455
456 }
457
458 bool operator == (const ::lparam & lparam) const
459 {
460
461 if (this->m_eoperatingambient != ::windowing::e_operating_ambient_none)
462 {
463
464 // todo check if eoperatingambient is of current operating_ambient native type
465
466 return this->m_opaque.m_ulla[0] == lparam.m_lparam
467 && this->m_opaque.m_ulla[1] == 0
468 && this->m_opaque.m_ulla[2] == 0
469 && this->m_opaque.m_ulla[3] == 0;
470
471 }
472
473 return ::best_effort_is_same_operating_system_window(m_pacmewindowingwindow, lparam);
474
475 }
476
477
478
479
480 template < typename WINDOW >
481 requires (!::is_same < WINDOW_TYPE, window_opaque_t >
482 && ::is_same < WINDOW, window >)
483 a_window & operator = (const WINDOW & window)
484 {
485
486 this->m_pacmewindowingwindow = window._get_acme_windowing_window();
487 this->m_eoperatingambient = window.m_eoperatingambient;
488 BASE_TYPE::operator = (window.m_window);
489
490 return *this;
491
492 }
493
494
495 a_window & operator = (const a_window & awindow)
496 {
497
498 this->m_pacmewindowingwindow = awindow.m_pacmewindowingwindow;
499 this->m_eoperatingambient = awindow.m_eoperatingambient;
500 BASE_TYPE::operator = (awindow.m_window);
501
502 return *this;
503
504 }
505
506
507 };
508
509
510 //class window
511 //{
512 //public:
513
514 // ::windowing::enum_operating_ambient m_eoperatingambient;
515 // window_t m_window;
516
517
518 // window(nullptr_t) :
519 // m_eoperatingambient(::windowing::e_operating_ambient_none),
520 // m_window(nullptr)
521 // {
522
523 // }
524
525
526 // window() :
527 // window(nullptr)
528 // {
529
530 // }
531
532
533 // window(const window& window) :
534 // m_eoperatingambient(window.m_eoperatingambient),
535 // m_window(window.m_window)
536 // {
537
538 // }
539
540
541 // window(const ::windowing::enum_operating_ambient& eoperatingambient, const window_t& window) :
542 // m_eoperatingambient(eoperatingambient),
543 // m_window(window)
544 // {
545
546 // }
547
548
549 // bool is_null() const
550 // {
551 // return m_eoperatingambient == ::windowing::e_operating_ambient_none
552 // || m_window.is_null();
553
554 // }
555
556
557 // bool is_set() const
558 // {
559
560 // return !this->is_null();
561
562 // }
563
564 // bool operator == (const ::operating_system::window& operatingsystemwindow) const
565 // {
566
567 // return this->m_eoperatingambient == operatingsystemwindow.m_eoperatingambient
568 // && this->m_window == operatingsystemwindow.m_window;
569
570 // }
571
572 //};
573
574
575
576} // namespace operating_system
577
578
579
580CLASS_DECL_ACME ::operating_system::window as_operating_system_window(::uptr u);
581CLASS_DECL_ACME ::uptr as_uptr(const ::operating_system::window & operatingsystemwindow);
582CLASS_DECL_ACME ::u64 as_u64(const ::operating_system::window & operatingsystemwindow);
Definition window.h:50
Definition lparam.h:9
Definition window.h:289
Definition device_context.h:12
Definition window.h:41