Compare commits
1462 Commits
master
...
features/s
Author | SHA1 | Date | |
---|---|---|---|
|
bbf2cd28b1 | ||
|
8d5c79096f | ||
|
f63c95a076 | ||
|
6d70c2dc73 | ||
|
6af9ac29ec | ||
|
226e0d579d | ||
|
8c4dceba08 | ||
|
4fc187dc60 | ||
|
947961b7b4 | ||
|
8b37da74db | ||
|
fed4841bd4 | ||
|
ea01c63e36 | ||
|
24b077c7f8 | ||
|
65840c19c4 | ||
|
fa65dcf24c | ||
|
fbafc33376 | ||
|
7b6314f47d | ||
|
a18f020072 | ||
|
d8c98c8c14 | ||
|
cfd23957fb | ||
|
139e99ca37 | ||
|
6df1a06fc3 | ||
|
e212511047 | ||
|
5c9825c16d | ||
|
3552df562e | ||
|
aa0f6b37bd | ||
|
271910e349 | ||
|
3fab2bb7be | ||
|
02cc7d451c | ||
|
fd77815f9f | ||
|
0e485a2109 | ||
|
5ea96c15cd | ||
|
527b2c45af | ||
|
3f61da7e8b | ||
|
3369cbd277 | ||
|
3fec562da1 | ||
|
138d9d0c21 | ||
|
a028c2df2a | ||
|
10a5a857f5 | ||
|
7237d3e5c3 | ||
|
66ed89b0ca | ||
|
e863f89d39 | ||
|
416cfdb99d | ||
|
3acb869a95 | ||
|
2ebb4e931d | ||
|
3e7f1d42db | ||
|
64a82d73c9 | ||
|
6d948ab47e | ||
|
fdc084f532 | ||
|
222dd775fc | ||
|
2db79d0868 | ||
|
975beafafd | ||
|
fee0210592 | ||
|
5ecef2f321 | ||
|
36ffdd69d3 | ||
|
9ebab255d2 | ||
|
b39fc84f89 | ||
|
15d8d41f86 | ||
|
eabe98f6d5 | ||
|
e391fe2e66 | ||
|
8b2c6dd42f | ||
|
f5d185238c | ||
|
2f2d5070f5 | ||
|
ebb8d78102 | ||
|
49e70e60a2 | ||
|
9d6818d0ce | ||
|
5717f0a33e | ||
|
b555984a94 | ||
|
4cb0fe3c7d | ||
|
c1743eef48 | ||
|
1db579d458 | ||
|
085781f5ca | ||
|
adcc3217c3 | ||
|
9d9ca37a84 | ||
|
fd75685fb0 | ||
|
77dff5a735 | ||
|
4e8c43f6b7 | ||
|
1a487165b1 | ||
|
c6aa051629 | ||
|
2b662b1ab9 | ||
|
8048b52498 | ||
|
c66a1e7d51 | ||
|
d79514c407 | ||
|
8490a262c4 | ||
|
71bcf350bd | ||
|
30ba3c347c | ||
|
59c8db69eb | ||
|
82eeafc196 | ||
|
54ef4092a9 | ||
|
eb42e164dd | ||
|
01b99a974d | ||
|
cab7edd135 | ||
|
80c83a4277 | ||
|
cceff4684a | ||
|
69b64e2b73 | ||
|
a27f22f0e9 | ||
|
32a3c61d00 | ||
|
2dc85e6e43 | ||
|
cf02023565 | ||
|
ebcfcd8da3 | ||
|
8deb1007cd | ||
|
a683033e49 | ||
|
e3d7cd665d | ||
|
2523c197bc | ||
|
20e1caec85 | ||
|
4aa81116a5 | ||
|
8add6bcb9f | ||
|
96b5b1724b | ||
|
f6253b87d0 | ||
|
e07663d9a1 | ||
|
ce0d0ac829 | ||
|
6695006bea | ||
|
0941adc931 | ||
|
9d950444a2 | ||
|
450f1d7e7b | ||
|
37ea320b96 | ||
|
208b8242bc | ||
|
4cde40dbe1 | ||
|
9298e310b2 | ||
|
04e9a2fac1 | ||
|
2a6d7b1eaa | ||
|
51d1a72e9b | ||
|
4521dec85d | ||
|
83c4336828 | ||
|
f7fc186408 | ||
|
72ebd91567 | ||
|
9064dbd404 | ||
|
d27b4ad366 | ||
|
17bfafda55 | ||
|
ff534b0d0a | ||
|
f8aed6499f | ||
|
b7c250925f | ||
|
bb2fb74645 | ||
|
c418685315 | ||
|
2c0007731f | ||
|
61acb34e32 | ||
|
3ce6b06feb | ||
|
64b1e448d2 | ||
|
ac3bc73c13 | ||
|
afd0d3fca1 | ||
|
72d760ba00 | ||
|
f693c3d806 | ||
|
7e246a7bb9 | ||
|
1612813114 | ||
|
14f8b76c1a | ||
|
72dbe45adc | ||
|
1d8e48c161 | ||
|
a1b60fc1f5 | ||
|
300464a487 | ||
|
7d6e83efca | ||
|
762ec445e6 | ||
|
475453668d | ||
|
61d35972e2 | ||
|
676497fe05 | ||
|
1161301386 | ||
|
f422e7826f | ||
|
63b6300c39 | ||
|
f8704cd085 | ||
|
30594c37d0 | ||
|
f8f805f046 | ||
|
07d1709ca2 | ||
|
023e59a5f2 | ||
|
0110f4c8cc | ||
|
51b348095c | ||
|
f4942bca32 | ||
|
27c735e3e9 | ||
|
f6feddd1ee | ||
|
b79751ebad | ||
|
a5aff5fd3e | ||
|
8566fec661 | ||
|
dc3e531ff2 | ||
|
ac8573884d | ||
|
677c7b2258 | ||
|
a88e5be7f4 | ||
|
6b01114057 | ||
|
057fcae30c | ||
|
35b41949fb | ||
|
099e8533e2 | ||
|
66c09fc05b | ||
|
7d81a166f9 | ||
|
e4aeef4b9f | ||
|
1450d23b60 | ||
|
b9db5c566b | ||
|
ef07ddf087 | ||
|
fa5d2656b0 | ||
|
3f63cee4c1 | ||
|
0664877998 | ||
|
8fd0a04135 | ||
|
823a1385a2 | ||
|
3418d50949 | ||
|
f0f3b927e0 | ||
|
6cc967a124 | ||
|
2e810d575c | ||
|
19b436f68d | ||
|
54c1ac3e38 | ||
|
e590b5114e | ||
|
530134d125 | ||
|
031148dc56 | ||
|
594cc4793a | ||
|
d2291df551 | ||
|
bba39762dc | ||
|
ac38c8e6fe | ||
|
c11128891e | ||
|
adf693c061 | ||
|
07e07030a6 | ||
|
88ac2ced7c | ||
|
f498f084d6 | ||
|
4bc51c6ff4 | ||
|
1f2b84a654 | ||
|
4f692ba840 | ||
|
0ea3b87bd6 | ||
|
bed11b35d1 | ||
|
aec062a8a5 | ||
|
1668693bcf | ||
|
ec461c6ccb | ||
|
63370be0e5 | ||
|
1f0b46b93c | ||
|
ed72fcd12a | ||
|
dcb6335bfe | ||
|
ee5ce36745 | ||
|
4fdafef54f | ||
|
bf87fbcbcc | ||
|
ad44f5831a | ||
|
5320a6ebd3 | ||
|
6b3435a2db | ||
|
85beda96de | ||
|
9e30fb0ec1 | ||
|
9937660b1c | ||
|
e2cede6542 | ||
|
f5c5a710aa | ||
|
4078abe14c | ||
|
702626dd8a | ||
|
e25e4526cd | ||
|
192196711a | ||
|
345184330b | ||
|
ea4565368e | ||
|
0d7d877cb5 | ||
|
95412ad3a5 | ||
|
a526ff8c30 | ||
|
e4233c6fb6 | ||
|
c807192abc | ||
|
b0a936e5d4 | ||
|
97a1f761c6 | ||
|
5ebb6a2954 | ||
|
5386ddcd05 | ||
|
887abe9578 | ||
|
88dfd85e92 | ||
|
6342275bbb | ||
|
d822c65317 | ||
|
fc3815bfe5 | ||
|
824baa6a4d | ||
|
42e166089a | ||
|
6939676372 | ||
|
16aaf60697 | ||
|
90de839445 | ||
|
c191faf0ba | ||
|
d3025cde37 | ||
|
5eda547e6f | ||
|
3ea0fad204 | ||
|
540909bddf | ||
|
fad8afd62a | ||
|
595a428baa | ||
|
d2f9c5dfb7 | ||
|
9964740a47 | ||
|
38cfe22b8b | ||
|
94e850fd6f | ||
|
d7aca168ee | ||
|
a571933f8b | ||
|
4d5da74c79 | ||
|
5728f2e15f | ||
|
849c8052b7 | ||
|
ced92d9c52 | ||
|
375ae5dce4 | ||
|
50c4234aca | ||
|
5370b46c4e | ||
|
f87e891f18 | ||
|
edf522b58a | ||
|
cb04326b46 | ||
|
fb0b9c7160 | ||
|
69beaa1d0b | ||
|
d91211f9f2 | ||
|
11f5be0caf | ||
|
8f434874c0 | ||
|
6fd2ee9416 | ||
|
1dc7d0e633 | ||
|
3af9ac320d | ||
|
64b88da21b | ||
|
caf4b7f1e6 | ||
|
aceab9a877 | ||
|
bc2002ab92 | ||
|
71a0701920 | ||
|
db798fd5be | ||
|
b78738ff23 | ||
|
8cbd391f09 | ||
|
ff1567e240 | ||
|
e9f50fb87c | ||
|
f573ebf31a | ||
|
b12e056c21 | ||
|
0abe7d1cc5 | ||
|
e21f462f6f | ||
|
28a123ca47 | ||
|
cb8ead1f71 | ||
|
77637fd936 | ||
|
21fc57f2cf | ||
|
ad5aa54166 | ||
|
5d0deebba4 | ||
|
58eb40db76 | ||
|
9cd9c2eff9 | ||
|
9764adc7bb | ||
|
506717390f | ||
|
101aec95d9 | ||
|
e135cdbc24 | ||
|
24dfebf455 | ||
|
e900ca355e | ||
|
4789c7e485 | ||
|
7b5a8e4f2b | ||
|
250333d895 | ||
|
36055213c5 | ||
|
6b5a2426d7 | ||
|
2fa60bec27 | ||
|
693b4c57fe | ||
|
d666a1d473 | ||
|
6868d11669 | ||
|
414165d23f | ||
|
ec48681455 | ||
|
8dd5425182 | ||
|
505f19e3b0 | ||
|
377b864bb4 | ||
|
9b0c26b0b2 | ||
|
f337378066 | ||
|
8639a2f9f8 | ||
|
64519c6875 | ||
|
7b0d58c5e5 | ||
|
9948535118 | ||
|
1e14cc5cae | ||
|
aa86800092 | ||
|
1ee252772a | ||
|
033538731c | ||
|
31762a8173 | ||
|
5017602752 | ||
|
37958ca1b5 | ||
|
8eb8689391 | ||
|
c1ab3c406f | ||
|
d378e4088f | ||
|
08350e53e7 | ||
|
27004aca70 | ||
|
d5f0d45ae4 | ||
|
f1a073186c | ||
|
3e0d6ec895 | ||
|
e278277d53 | ||
|
1338eb31f7 | ||
|
007a427e0a | ||
|
8567a4cca3 | ||
|
ec1e57ed4a | ||
|
e51a0a80ca | ||
|
0647ba3bad | ||
|
acfc7798fd | ||
|
9ce0f35ef3 | ||
|
ef681e7019 | ||
|
704ab1114a | ||
|
afb1180d7d | ||
|
9c8f288d1a | ||
|
2aa9959553 | ||
|
15b4a064f9 | ||
|
06d5f9297d | ||
|
248ed1b01d | ||
|
cd36acc88b | ||
|
747f7fdbba | ||
|
f605351307 | ||
|
e31d116d37 | ||
|
0647cf434c | ||
|
fc198fe1db | ||
|
c1b70e0391 | ||
|
06e4f4e370 | ||
|
1dc3af381a | ||
|
c122c0ef89 | ||
|
b16f738d04 | ||
|
bf80204e63 | ||
|
8733ca49b0 | ||
|
6afcfe3442 | ||
|
848d21b6b5 | ||
|
1ab3007752 | ||
|
5f5ba8eb11 | ||
|
719d931304 | ||
|
ea83d040e6 | ||
|
7f38773b73 | ||
|
b50b22d787 | ||
|
2080d12bd9 | ||
|
dc8c3618e8 | ||
|
b17dffffb3 | ||
|
c1d2793580 | ||
|
0b4edf4e94 | ||
|
bac748fa95 | ||
|
05877c14df | ||
|
9b59455184 | ||
|
29653273c1 | ||
|
1b215ecb01 | ||
|
1780579403 | ||
|
835a5344b0 | ||
|
65ad63de84 | ||
|
ca097c2c68 | ||
|
fa0a314f59 | ||
|
c58fb46411 | ||
|
e7cc534367 | ||
|
29828d0469 | ||
|
8dfb52245b | ||
|
5d95e7eef9 | ||
|
92a39f78b9 | ||
|
79d39b190b | ||
|
6b77668171 | ||
|
9a49c1ddbd | ||
|
6b1e094cfb | ||
|
cfb837203c | ||
|
40caab4748 | ||
|
fa9fc05ac6 | ||
|
53589092b2 | ||
|
dedb381c51 | ||
|
0eb45a0577 | ||
|
58f5092c53 | ||
|
6bd447c885 | ||
|
47fb332fb2 | ||
|
2e01952b35 | ||
|
5a7d18a441 | ||
|
9c3359ef39 | ||
|
0b06c4b2b0 | ||
|
80b5fb51ed | ||
|
f9b5168fb3 | ||
|
7bfc379a23 | ||
|
3d5dc0d939 | ||
|
a11f36811f | ||
|
eb6f4b1a6a | ||
|
cd4cc9ff0d | ||
|
9e8e5ac363 | ||
|
6136b3844b | ||
|
0a8ab75e4b | ||
|
36a0d1028c | ||
|
0f7eb00f67 | ||
|
682447306d | ||
|
ac35b4bba2 | ||
|
cce307a2be | ||
|
afabb2f3d8 | ||
|
9b417b26d9 | ||
|
90deb0959a | ||
|
db0338a1f2 | ||
|
4161a67b38 | ||
|
865b2ca6f9 | ||
|
a44d4da87c | ||
|
16abfa5eb6 | ||
|
f53db3541a | ||
|
5e528d9eea | ||
|
f03ab2a5c5 | ||
|
fa1f540e6c | ||
|
91704b773e | ||
|
1ad1429c6d | ||
|
1b435ae3e0 | ||
|
105d82d134 | ||
|
86c2b609ef | ||
|
2cdfcb8fd2 | ||
|
31290807dc | ||
|
33cdbe97b8 | ||
|
34d4bc620d | ||
|
76902c482f | ||
|
e5efa01920 | ||
|
3f16a524c8 | ||
|
646c873598 | ||
|
e87dd0e65d | ||
|
539de4387b | ||
|
65cd14502c | ||
|
6ddcdbe3e8 | ||
|
9251eac585 | ||
|
3ed07a8f0b | ||
|
0e0a783b8c | ||
|
5991851eb9 | ||
|
a4adf60576 | ||
|
b79b1cb9c0 | ||
|
d7051928d9 | ||
|
b305953bd1 | ||
|
e7577d570e | ||
|
ca34c81ce9 | ||
|
085cff2fe5 | ||
|
b17bfdd6f4 | ||
|
81e0b18e38 | ||
|
b202fa9063 | ||
|
2231e1a369 | ||
|
256594575d | ||
|
cfe83c4b44 | ||
|
0157502eab | ||
|
f1bf642e8f | ||
|
4b9bc49020 | ||
|
d5a4d53000 | ||
|
705f082674 | ||
|
80533ea5e1 | ||
|
6aee4bcdc5 | ||
|
b794ecc079 | ||
|
732cd837a9 | ||
|
839ecce571 | ||
|
3ec14186cb | ||
|
a4e4f57cb0 | ||
|
ffa863a3ba | ||
|
3d75f438bc | ||
|
7180e9ac66 | ||
|
239d09804d | ||
|
04f7ea818d | ||
|
ee59d7a266 | ||
|
3607c42bec | ||
|
2a5eaf239f | ||
|
6f5f80a544 | ||
|
7a516a266d | ||
|
73ccb7e4b8 | ||
|
1a3af8cb4c | ||
|
862bfc53d3 | ||
|
fa55b0cb60 | ||
|
22d9a61b33 | ||
|
84e8802891 | ||
|
577e7cb493 | ||
|
cff8162454 | ||
|
376c88a864 | ||
|
bb26751b94 | ||
|
ebbb98d519 | ||
|
9e4956d86b | ||
|
388ca563db | ||
|
70703da782 | ||
|
b11518d7d7 | ||
|
7b53551032 | ||
|
06e87014f2 | ||
|
dd4ca70b0d | ||
|
657589ab47 | ||
|
c1ffac2fee | ||
|
4da92b89ed | ||
|
3dcbcd8bf0 | ||
|
cecf6b4209 | ||
|
b2a91dc390 | ||
|
ac08593b96 | ||
|
e3ac52630a | ||
|
455c21df71 | ||
|
d3a80d9f1b | ||
|
b26f1530b7 | ||
|
bae2240eda | ||
|
042a3b01d2 | ||
|
682249396f | ||
|
958e58b06b | ||
|
c49330fc52 | ||
|
fa004ae79a | ||
|
42575d4a99 | ||
|
6bc526676c | ||
|
e230ec5a01 | ||
|
770c995365 | ||
|
78f753ffff | ||
|
aa8e09d7f1 | ||
|
36c331ff74 | ||
|
8dacb4da20 | ||
|
fc625d249f | ||
|
34077c0140 | ||
|
600b8f60b4 | ||
|
e9053515bb | ||
|
30f0900b1c | ||
|
831e2c920e | ||
|
cf312545e8 | ||
|
d6f3a8848d | ||
|
9d20a5f0a5 | ||
|
ad8fdc917f | ||
|
05bc204dbd | ||
|
b36d1d465d | ||
|
25a9209b75 | ||
|
a9626e1162 | ||
|
a5ba26806f | ||
|
dbc70f21a9 | ||
|
85a661d276 | ||
|
acf043a675 | ||
|
2c13a74a9d | ||
|
de1588928b | ||
|
70fa37527d | ||
|
3d4af15d1d | ||
|
cba52b66af | ||
|
f79f0e42f7 | ||
|
cbade7b16d | ||
|
b626dd57d3 | ||
|
cb1d578470 | ||
|
4f5aac319e | ||
|
fc9d6b6cb5 | ||
|
4bdbea8375 | ||
|
2b9d88196e | ||
|
90ea7e2f2f | ||
|
ddabfc3477 | ||
|
f4f04cb5ec | ||
|
d7ef56dca2 | ||
|
5628416bd3 | ||
|
7538bbabb6 | ||
|
e1d7e14717 | ||
|
a616ff5d4a | ||
|
76e40fe5d1 | ||
|
20d61f5f62 | ||
|
2665288b30 | ||
|
8baa4ccff5 | ||
|
5d472c4895 | ||
|
0fe5170bc4 | ||
|
615e9ae345 | ||
|
3b3af6b731 | ||
|
e4d8267188 | ||
|
1cd32d3afe | ||
|
03ea87ea28 | ||
|
c46b79846c | ||
|
6636cb9f2f | ||
|
1e7672acf4 | ||
|
8596f2b0fc | ||
|
538d28e29e | ||
|
574ff0a280 | ||
|
51e568f9dc | ||
|
582f4db59b | ||
|
5116eee108 | ||
|
7ddc1adefb | ||
|
266dff9bed | ||
|
7f8b076f2b | ||
|
36ac557df0 | ||
|
013013737f | ||
|
b8e2b2bd6b | ||
|
71eb4034eb | ||
|
c142540705 | ||
|
3930472f34 | ||
|
6d03f93067 | ||
|
0e884304ee | ||
|
9085c2cae2 | ||
|
e8568f3ec9 | ||
|
16a9488c13 | ||
|
ea0399414c | ||
|
1abb02fb67 | ||
|
fbaf65b8f6 | ||
|
f2c7f3b200 | ||
|
1b579a110d | ||
|
7e00cde8a9 | ||
|
1ecc1db226 | ||
|
a7ace918fe | ||
|
91ac93f9a6 | ||
|
05c3e0b898 | ||
|
103c5edaaa | ||
|
75de34e281 | ||
|
f032ad6b1f | ||
|
871727dd2f | ||
|
3ff13edad9 | ||
|
7d80a8f4f5 | ||
|
3c80d57dc7 | ||
|
bb1e6f8af6 | ||
|
8432d1bfc7 | ||
|
7e2d172ae5 | ||
|
3bde375078 | ||
|
365b639981 | ||
|
d4fc525614 | ||
|
5be649e082 | ||
|
4b4be11fd2 | ||
|
e7bfcb970e | ||
|
7794b104c5 | ||
|
3b828e6f96 | ||
|
bbe946fb6c | ||
|
377f730054 | ||
|
f5528001f6 | ||
|
f68075b333 | ||
|
f1b5c742ff | ||
|
7e068da2bd | ||
|
44174b1fa1 | ||
|
861f786d81 | ||
|
f6951bb67d | ||
|
3b1b5266e5 | ||
|
c163b856d7 | ||
|
07eb7adbb4 | ||
|
4c108d22f0 | ||
|
c706ff6f3a | ||
|
992736dc5d | ||
|
927580d4a8 | ||
|
a1e4af62d3 | ||
|
28dd8d7efd | ||
|
4dff49b2f1 | ||
|
71a58261f6 | ||
|
8d1b82d596 | ||
|
3096e7a9cd | ||
|
1c3a9c8e74 | ||
|
813e0c18e6 | ||
|
3a82994429 | ||
|
106184bbea | ||
|
3895363432 | ||
|
a1e43c682a | ||
|
c3fd4ae473 | ||
|
69b5c2f541 | ||
|
a704614b3e | ||
|
6024051a2f | ||
|
b3e94f5de8 | ||
|
32380a0112 | ||
|
664fb38e39 | ||
|
0cbb96895a | ||
|
7b77cb3bb8 | ||
|
6faad0c34f | ||
|
05c1f2795a | ||
|
7feccf9ab2 | ||
|
bf4880f6a2 | ||
|
e0c0e53edf | ||
|
6994bf10bc | ||
|
3233d85d2f | ||
|
13f00331da | ||
|
af93c21cf9 | ||
|
cf98290873 | ||
|
1ca6ff974c | ||
|
575df6f192 | ||
|
0bdc145343 | ||
|
d049a7988c | ||
|
a4af3cc814 | ||
|
a89a3cd2f1 | ||
|
09780b8b3d | ||
|
9e294be5c5 | ||
|
a01d149369 | ||
|
483534b525 | ||
|
e1fca8d982 | ||
|
10a202422a | ||
|
27431dcc6b | ||
|
d8f9f6ba2a | ||
|
72090b646f | ||
|
aedcd2fb1a | ||
|
76ccbb899d | ||
|
5d87ee8d82 | ||
|
451c756b01 | ||
|
3aa9aae0be | ||
|
967073ba3d | ||
|
b8d8355f10 | ||
|
07c52a25ff | ||
|
cb2de62bb1 | ||
|
949a9fa2cb | ||
|
a1164399b0 | ||
|
e5b905481d | ||
|
7c183dc6a1 | ||
|
7fbd72b735 | ||
|
969278fc0b | ||
|
efc4c0fe9d | ||
|
81b24bd728 | ||
|
db2581bee9 | ||
|
75136d3bea | ||
|
0e6a096afd | ||
|
6f8d34768d | ||
|
9cda3035fd | ||
|
47f5ad32b7 | ||
|
9f35ba8546 | ||
|
7fd34d4f30 | ||
|
bb2aa5e770 | ||
|
56e10f1c35 | ||
|
718e15c7de | ||
|
8bc6d976cb | ||
|
dd80db87a6 | ||
|
1f54c16f52 | ||
|
50d421fa19 | ||
|
adbbd17cb6 | ||
|
3e8eebfbec | ||
|
2cbc0f1287 | ||
|
e2c1f0a7cd | ||
|
ca43436cd3 | ||
|
b27fd87177 | ||
|
07d3083279 | ||
|
d3d998a885 | ||
|
5f409c6fcc | ||
|
63310acd58 | ||
|
e6850891cc | ||
|
440ad0b440 | ||
|
5cdd788f30 | ||
|
596d81a973 | ||
|
84f3ecc231 | ||
|
cc48f1e5dd | ||
|
8dc04a4c9f | ||
|
c72040a715 | ||
|
c7c1bf177b | ||
|
5b0e59d9d5 | ||
|
7c06d9f043 | ||
|
511e32e8ca | ||
|
e5dfa0855f | ||
|
afad952450 | ||
|
fda1365c15 | ||
|
04022114d9 | ||
|
1575a3fbcd | ||
|
7e772f6a51 | ||
|
2e5860b5a0 | ||
|
4158cba1ff | ||
|
b955e485f1 | ||
|
02d6d2d487 | ||
|
b668726a38 | ||
|
835a8b2c9b | ||
|
239c8732d7 | ||
|
9bf3f910c8 | ||
|
e6c982509d | ||
|
9ddb8493d5 | ||
|
76e61958fd | ||
|
4f22a45cb5 | ||
|
825b61e4ba | ||
|
7e67aba286 | ||
|
a649d904d7 | ||
|
dfb82d5c22 | ||
|
d0fb547dc1 | ||
|
20f0cb0281 | ||
|
03b64defa5 | ||
|
655ebe4eaf | ||
|
b89202824e | ||
|
f70eacee8e | ||
|
433a7556c7 | ||
|
712203dbcb | ||
|
800fb26606 | ||
|
224f087a5f | ||
|
092426bed2 | ||
|
c6f1b7b92a | ||
|
328e4fa7e7 | ||
|
f3110a57cd | ||
|
cf029b3e1c | ||
|
7056032483 | ||
|
50ceb25003 | ||
|
9c364b16ff | ||
|
d61caf5714 | ||
|
e70f866ed2 | ||
|
9acb158990 | ||
|
1ba79baab5 | ||
|
01de69de36 | ||
|
8ec24036d7 | ||
|
29269d2aa8 | ||
|
43a85dd02e | ||
|
9ba64f9fe3 | ||
|
49fb8e6c45 | ||
|
9bf6509c6e | ||
|
5af385ea78 | ||
|
47219dd5c6 | ||
|
b6ae8a0dca | ||
|
a33d45d7cd | ||
|
5a665e423c | ||
|
fc95da8aa3 | ||
|
fd5859ed04 | ||
|
75e3793f4d | ||
|
8d4b5fef1d | ||
|
04a9ce3a18 | ||
|
87883abd86 | ||
|
f20725eada | ||
|
26646f2450 | ||
|
f208fd7ebb | ||
|
9350158d61 | ||
|
7a5196601e | ||
|
c7619d4a6a | ||
|
7ba774a440 | ||
|
b1af4d36ce | ||
|
c3f20f6b81 | ||
|
e7dca4fec2 | ||
|
9afb849e16 | ||
|
e1acb0b1fa | ||
|
3ead9820f7 | ||
|
f7db4fad31 | ||
|
cf4fcc4735 | ||
|
3eedb542a6 | ||
|
ecf7666624 | ||
|
d77d3416d3 | ||
|
5ce93bc0cc | ||
|
54a129a2e2 | ||
|
bdf60dac6a | ||
|
bbb543fc16 | ||
|
28d8eb220b | ||
|
0a6c5bc234 | ||
|
e91d275b10 | ||
|
8b8ab1db5b | ||
|
e02d6014bf | ||
|
8414c0bb09 | ||
|
49eb5f0280 | ||
|
7a536f1bd2 | ||
|
ff0c6c2bde | ||
|
4eecf80a4b | ||
|
104294c7e4 | ||
|
6b43a314bf | ||
|
8915f7933a | ||
|
87ded34f9f | ||
|
ff0f9aa856 | ||
|
9dc02464a4 | ||
|
7573d10a4a | ||
|
5412cdf2c8 | ||
|
3de440fda2 | ||
|
5bf9029bf9 | ||
|
09c9bf2edb | ||
|
b46076458c | ||
|
8691b56136 | ||
|
7f6a025c93 | ||
|
2cada3c143 | ||
|
4a3a895be9 | ||
|
f6fbb99a9c | ||
|
be107ba8f8 | ||
|
f902435a53 | ||
|
80d51c692a | ||
|
7227454dca | ||
|
f087359621 | ||
|
e215809c4d | ||
|
03b0266b59 | ||
|
d1c45c0d76 | ||
|
e30babef09 | ||
|
a608156da3 | ||
|
65a2350a5f | ||
|
cbf24a9151 | ||
|
f906d53f7d | ||
|
1f2bdd37b3 | ||
|
dc8ff68871 | ||
|
5536edede9 | ||
|
578e15f006 | ||
|
e1143377c2 | ||
|
8563ef3ce4 | ||
|
37fb531d1c | ||
|
86d3bba157 | ||
|
2ccc6d2ed1 | ||
|
13a5f5ba8b | ||
|
737a3644fc | ||
|
07ff47bf1b | ||
|
0737433c71 | ||
|
0bda7f196d | ||
|
9f96fcff3c | ||
|
bfacbac7c4 | ||
|
86fce79a6c | ||
|
c81a5a6070 | ||
|
0947fa3de0 | ||
|
cb9a6b8a8b | ||
|
2d21a64fed | ||
|
f94af2f5c5 | ||
|
8079344cee | ||
|
82e31d34f0 | ||
|
acdb4823dd | ||
|
b5144e477f | ||
|
e9c625a1dc | ||
|
d1851ed6b7 | ||
|
32c4e01267 | ||
|
2f9bae140b | ||
|
8a45c56c2c | ||
|
9391a97fbf | ||
|
79d497edae | ||
|
515ad62335 | ||
|
73353fad64 | ||
|
ff4bd758ca | ||
|
e24674fc0e | ||
|
529fccd9c2 | ||
|
4ee4f65c70 | ||
|
7cc86d4bc9 | ||
|
8011197c50 | ||
|
c96aaef132 | ||
|
6b32570644 | ||
|
5af930f97a | ||
|
515ecbddc2 | ||
|
7f7e8eeecd | ||
|
4e98d4329b | ||
|
5278da98d2 | ||
|
e1ed27aeaa | ||
|
c8349d3305 | ||
|
606175b98f | ||
|
05bc323be0 | ||
|
599a52629a | ||
|
c3efccaa9c | ||
|
b26f16a27f | ||
|
a0c2e55e8c | ||
|
5aebfedfad | ||
|
ce1626a51e | ||
|
0cabe4dedf | ||
|
0d6e3ab2b0 | ||
|
cfcad42b89 | ||
|
4a6f95acc8 | ||
|
5305c32242 | ||
|
951c9dd68b | ||
|
4ea9fdbbea | ||
|
e194219f2e | ||
|
a71d3c8cb3 | ||
|
238321c159 | ||
|
e181b0c3fc | ||
|
9d0bc3f9ab | ||
|
afe9c5c5f7 | ||
|
81a2546cea | ||
|
ee5560a958 | ||
|
62cfdceac1 | ||
|
d9fda22763 | ||
|
8dd83c5fe8 | ||
|
5794c0491a | ||
|
e043b89814 | ||
|
8fc19d2194 | ||
|
02501f07c3 | ||
|
a0e5bb9532 | ||
|
088ef6623a | ||
|
9c916cdaf9 | ||
|
ac9512e095 | ||
|
5d20da1b36 | ||
|
9b09c7597f | ||
|
2a1e903f43 | ||
|
e50894c95e | ||
|
991b16cc6a | ||
|
2886e0b6f5 | ||
|
067b691fd8 | ||
|
c40feabe4d | ||
|
2d4018aa89 | ||
|
e6439e1a16 | ||
|
26b9e2d0a5 | ||
|
3a5e758ee3 | ||
|
f768727284 | ||
|
a03846bd9e | ||
|
f3a0b17bb8 | ||
|
ac52d9d44c | ||
|
e2082a675c | ||
|
b94f0241f1 | ||
|
b96b1f2412 | ||
|
6644f1ff64 | ||
|
8cac70d8af | ||
|
5105c6c0d0 | ||
|
3a678d48b1 | ||
|
8bac6d428d | ||
|
2da200fc16 | ||
|
f6b6ad1959 | ||
|
3e84f7cd1d | ||
|
ac10889bde | ||
|
89a530b442 | ||
|
65e579e558 | ||
|
34e18ef771 | ||
|
8289e5f6b4 | ||
|
025e00cccc | ||
|
f78b5a0cdb | ||
|
ec49a486c7 | ||
|
afeefadb4e | ||
|
a423f032ee | ||
|
4ef06f5aa2 | ||
|
753223bd7b | ||
|
f663277591 | ||
|
1c7be88a1a | ||
|
3c114b280a | ||
|
2fbbcaa339 | ||
|
36cbe1e521 | ||
|
19d17ed274 | ||
|
01f940dc9a | ||
|
19c4fa8dd5 | ||
|
3bcc25f588 | ||
|
4cadb57c46 | ||
|
99c32ed4a5 | ||
|
c08b4b46f4 | ||
|
e138a5fcb5 | ||
|
fc16e54612 | ||
|
4575354bc0 | ||
|
3f51c831de | ||
|
962dcb466d | ||
|
b8d9c5c130 | ||
|
1a0d2578a1 | ||
|
12a1e7d04e | ||
|
4a8efd7e68 | ||
|
66cfbbff5e | ||
|
d23c69d319 | ||
|
1e7b50aeae | ||
|
c93e92671a | ||
|
ddc3f8f069 | ||
|
5261e5a6ba | ||
|
379733aba1 | ||
|
131de7ab62 | ||
|
d8ab2c1ac9 | ||
|
862781b195 | ||
|
cae4d020dc | ||
|
1f78e08427 | ||
|
760c1d95b9 | ||
|
510f0e505c | ||
|
d9c54826bb | ||
|
2515413080 | ||
|
d87b80c6c1 | ||
|
4a43f347bb | ||
|
dcbf976a8e | ||
|
f2d577c33f | ||
|
ae34241f8b | ||
|
1546153ca2 | ||
|
a3d6554e8e | ||
|
565af90958 | ||
|
797f2044cd | ||
|
5ea08394f5 | ||
|
9ee86f22b7 | ||
|
52ca91ca57 | ||
|
168af9b377 | ||
|
1a6eea012d | ||
|
50f6e12d31 | ||
|
c547b2e8ee | ||
|
56ba60ee68 | ||
|
f270c81c49 | ||
|
745fda081e | ||
|
5f8c9ae0ef | ||
|
056af2b1af | ||
|
5f79a28a07 | ||
|
69db792bf0 | ||
|
8b956216b7 | ||
|
e6cc547a94 | ||
|
e73217d6f7 | ||
|
2eaf5b03df | ||
|
c398153b40 | ||
|
33994bbfa1 | ||
|
7525637804 | ||
|
15ec78e9d8 | ||
|
3a7828de6b | ||
|
7b3433c68b | ||
|
84507cc744 | ||
|
cb76c086e0 | ||
|
407822e6a5 | ||
|
4e30698706 | ||
|
2dd8338e7d | ||
|
059560d28b | ||
|
d348d86df4 | ||
|
1d3862b6b3 | ||
|
bd82539ad5 | ||
|
83f55c9de5 | ||
|
33b88a0339 | ||
|
44bfa24cc3 | ||
|
2cff3f6a65 | ||
|
b48ed9ebc0 | ||
|
4e717b524c | ||
|
ae657a349a | ||
|
ed3c015f4e | ||
|
9cfc40c2cc | ||
|
6ebc63d3ef | ||
|
1ae0a1e658 | ||
|
46dff42239 | ||
|
35d1fb7b34 | ||
|
876a3299fc | ||
|
93896d550e | ||
|
18ffb7dd86 | ||
|
c0a89f8f4e | ||
|
c6193d0605 | ||
|
6cc380fc41 | ||
|
4053d9d638 | ||
|
45731cca19 | ||
|
dc92431328 | ||
|
d3e8e5731a | ||
|
53a5d32df1 | ||
|
85e1e2b0c8 | ||
|
9960ccddb2 | ||
|
4021776d0f | ||
|
fa0ce4b7d5 | ||
|
2a5ce1849a | ||
|
ae4b838840 | ||
|
79c075ca09 | ||
|
1127804109 | ||
|
67be485e24 | ||
|
fda57f48d5 | ||
|
840652830d | ||
|
5eabf44021 | ||
|
599d5f185c | ||
|
7abc368927 | ||
|
b57baa5ba0 | ||
|
3e47978a80 | ||
|
e647f89c33 | ||
|
82978fc88f | ||
|
95d49c3b98 | ||
|
455dc6e229 | ||
|
291bfe6841 | ||
|
35032d41fa | ||
|
28094b7cea | ||
|
b55b9aee9b | ||
|
0f1c21a6c9 | ||
|
175bab4f5f | ||
|
ba7b68798d | ||
|
e32256b4b4 | ||
|
132d8c5a99 | ||
|
b85f345369 | ||
|
85a3fb3bef | ||
|
6d91055462 | ||
|
136fc56af0 | ||
|
c355ed1267 | ||
|
1cefc48f13 | ||
|
211a9c8fd2 | ||
|
f29b3b4033 | ||
|
df65d4a14f | ||
|
c4e26f4b92 | ||
|
416918429d | ||
|
d5692bff00 | ||
|
dcef0c0237 | ||
|
a68c98bb67 | ||
|
b872aa5c8e | ||
|
a82be53407 | ||
|
49533bc86e | ||
|
e381f22ac1 | ||
|
9ac1e93aa1 | ||
|
bd5b38e232 | ||
|
5adcb9ce6d | ||
|
2ec135c9f7 | ||
|
58d46e1fe6 | ||
|
c039a77d21 | ||
|
741bdf151a | ||
|
5070c769b8 | ||
|
52e0de84a9 | ||
|
b974fffea0 | ||
|
a2616c79fe | ||
|
31b5b18611 | ||
|
8601c39571 | ||
|
af27ec296b | ||
|
a848807847 | ||
|
bdb30d7145 | ||
|
897e5c6231 | ||
|
1007873d94 | ||
|
fd201a90f1 | ||
|
a52ce7ac8b | ||
|
fd90afef43 | ||
|
5207afa0dd | ||
|
0699310b9c | ||
|
0c24fe276c | ||
|
c83391262e | ||
|
00262d51ad | ||
|
d7c04ccbfb | ||
|
b1f263b34b | ||
|
a58e4dfd0f | ||
|
18d6490dbd | ||
|
346f83e014 | ||
|
fefcc77f13 | ||
|
b6cdfef442 | ||
|
172e426ba9 | ||
|
f74d9ec7f7 | ||
|
9093166eea | ||
|
f5ed5478e1 | ||
|
9a4234ea8e | ||
|
af002dc861 | ||
|
adeb993122 | ||
|
81bc4265e5 | ||
|
a44c5f7afe | ||
|
66b51940bd | ||
|
d4e49a2697 | ||
|
521405488b | ||
|
24dfa0c957 | ||
|
158a65c98f | ||
|
6caf074bd5 | ||
|
905e14f384 | ||
|
4be79a8955 | ||
|
2d952504ed | ||
|
43219d36a6 | ||
|
99b27488e7 | ||
|
18972c5513 | ||
|
e312363007 | ||
|
6c34bffbb5 | ||
|
36b2f64051 | ||
|
705ff49400 | ||
|
f81caac459 | ||
|
0ada716184 | ||
|
e9c849884a | ||
|
a4191857c1 | ||
|
9d7480774f | ||
|
5d630c930d | ||
|
9852649e97 | ||
|
1722a31155 | ||
|
e5f2295398 | ||
|
8ef0ca9765 | ||
|
c031ea088a | ||
|
9824bf1ba1 | ||
|
0095b7a0ea | ||
|
6b4f6cd2c5 | ||
|
1b646a4440 | ||
|
f22024cb19 | ||
|
049c515840 | ||
|
352695bc57 | ||
|
74077491ce | ||
|
23b67e6ff5 | ||
|
7b4fbf4301 | ||
|
b8b74970d7 | ||
|
defbf1c4b3 | ||
|
16c6734bcb | ||
|
ee98a069f0 | ||
|
b30b82835a | ||
|
d107146687 | ||
|
88df66ec83 | ||
|
ce18371d1b | ||
|
9dea27b273 | ||
|
140ece0aeb | ||
|
7abf72ec78 | ||
|
574185426c | ||
|
dd61c4802a | ||
|
14cef31467 | ||
|
6277781e83 | ||
|
770cba0bd0 | ||
|
c38fe6b0e1 | ||
|
d3ee3e7ab5 | ||
|
ce500f8727 | ||
|
9a5f742e63 | ||
|
7e6700d261 | ||
|
c71522adc5 | ||
|
70b0bd13aa | ||
|
087ab2acbf | ||
|
24aeca3d0c | ||
|
9660657e95 | ||
|
13a3a2d0f3 | ||
|
ff4f40de41 | ||
|
24fc7c30dd | ||
|
06aa9d8d9a | ||
|
8c374512fd | ||
|
77d51ebf24 | ||
|
93b032ea92 | ||
|
03c8a78f04 | ||
|
002e513b82 | ||
|
ed84b2aaeb | ||
|
1176460e44 | ||
|
01429e7d16 | ||
|
4c35e00f49 | ||
|
7f960616e0 | ||
|
1cafdb5b46 | ||
|
b0fb340b57 | ||
|
85f3ba844c | ||
|
090eb437ed | ||
|
d574604a5d | ||
|
6eacddb50f | ||
|
4ff23d3306 | ||
|
c7687fc1d6 | ||
|
c47d34cf70 | ||
|
cd51f37fc0 | ||
|
da70c837da | ||
|
f1ae07e532 | ||
|
d9cd494eaf | ||
|
5979233a3c | ||
|
0b1d6a0d52 | ||
|
7b433605f9 | ||
|
3b9b1956cd | ||
|
7a41e0b1ea | ||
|
cc882b0723 | ||
|
6d6580f6be | ||
|
7684f53328 | ||
|
e3e4b7bdf5 | ||
|
679f4882a5 | ||
|
cb78e62df9 | ||
|
376f2aec54 | ||
|
010757266e | ||
|
d268471285 | ||
|
423577e14e | ||
|
f1c31ebc67 | ||
|
4433ce4312 | ||
|
456bbffcc4 | ||
|
17a7f352b5 | ||
|
637d9c42bf | ||
|
1c385c2ca4 | ||
|
25f25d546d | ||
|
6ac50634e3 | ||
|
50e453a3e2 | ||
|
4649bf042e | ||
|
2bd0ee27f0 | ||
|
0d16492eb7 | ||
|
2ae19801a9 | ||
|
950539b768 | ||
|
f270d6c52c | ||
|
22d6f00110 | ||
|
38e357ef10 | ||
|
0b7f3edc26 | ||
|
285269ef55 | ||
|
e25da4230b | ||
|
8be6f40ae1 | ||
|
83bd3595a4 | ||
|
32ee0a3947 | ||
|
7ddc22b326 | ||
|
0d5042f0f3 | ||
|
0eaddb4dcd | ||
|
74a11e2087 | ||
|
d4dd448511 | ||
|
56ad2a2d74 | ||
|
f421e73b40 | ||
|
72899318e6 | ||
|
84c6ea0cee | ||
|
c23b5463c7 | ||
|
9d8bc79025 | ||
|
0cad274b87 | ||
|
ac8931b2e9 | ||
|
4f112f898e | ||
|
e5ba982be0 | ||
|
200754b013 | ||
|
42ad3c1dd3 | ||
|
172570acae | ||
|
c29971cf72 | ||
|
ccc9a22db3 | ||
|
c00523dba4 | ||
|
9d5ec05150 | ||
|
2fecd332fc | ||
|
0e09032750 | ||
|
46b61427e1 | ||
|
bcf4ed28a9 | ||
|
6cfc9e6256 | ||
|
1ab236d9df | ||
|
2e1ac0f683 | ||
|
8364d1ca6c | ||
|
09d8943967 | ||
|
6e58a95a01 | ||
|
207ad45983 | ||
|
83ef61fa56 | ||
|
d0e0b106f0 | ||
|
98b66a5fc9 | ||
|
921bb92eec | ||
|
c50198debe | ||
|
6371474031 | ||
|
8657201257 | ||
|
b88492746e | ||
|
f6fc28dfd2 | ||
|
cdeef65b05 | ||
|
1e81a53e75 | ||
|
5e63711084 | ||
|
a2fbcc9ad4 | ||
|
10030ff3ec | ||
|
648735a4cf | ||
|
a4629b0b36 | ||
|
64cbbed152 | ||
|
43f375b2f2 | ||
|
1eb89d7e3b | ||
|
4d46383100 | ||
|
aa3fe81c87 | ||
|
9ea16e344a | ||
|
d8719cf59b | ||
|
9dcc07422e | ||
|
52c78820aa | ||
|
19b92751b9 | ||
|
f318f2d5ea | ||
|
21ff03978a | ||
|
25fd9d6132 | ||
|
3637193556 | ||
|
8e3274e137 | ||
|
c4a158656e | ||
|
e026c8d3b7 | ||
|
cab41d954e | ||
|
e0cbfd74d7 | ||
|
426930e028 | ||
|
e9fa17e1bf | ||
|
b807347e94 | ||
|
7113fc7dee | ||
|
e0f283cfcb | ||
|
7b968b098e | ||
|
e927a6ac4a | ||
|
9da475e4e8 | ||
|
5b282bdd48 | ||
|
fc80f2b41a | ||
|
68e9ef9885 | ||
|
296db2ed33 | ||
|
3171d61dfc | ||
|
00b9e70ba2 | ||
|
57e9f61852 | ||
|
cf365ed00b | ||
|
d98a5d54aa | ||
|
8074d56bdd | ||
|
fc3c3de70d | ||
|
997d1bd0eb | ||
|
baef79415b | ||
|
cb601d79e8 | ||
|
4cee46f909 | ||
|
25349b31d7 | ||
|
735267d27c | ||
|
b5ced477f4 | ||
|
67319a71e5 | ||
|
184a6f1198 | ||
|
b32bb4e6e3 | ||
|
0e62b7d68a | ||
|
a761779b12 | ||
|
29510fcb83 | ||
|
3f335b0d42 | ||
|
ffda84cfae | ||
|
e6bc840f6f | ||
|
0b26387a2b | ||
|
f7ef10e547 | ||
|
91cadc1130 | ||
|
47d1360124 | ||
|
f67699456c | ||
|
387f724d33 | ||
|
bcdfd5d61c | ||
|
e660d92fa5 | ||
|
9fdf72e42b | ||
|
df9051ded2 | ||
|
230c5ca735 | ||
|
3bd3693fb7 | ||
|
45cbebad64 | ||
|
6d0f9244b8 | ||
|
80a8aea7e3 | ||
|
4f0db01f7c | ||
|
6cd4e30b58 | ||
|
19540479d4 | ||
|
90dffb5a06 | ||
|
ef521d1e0b | ||
|
42c32bf00c | ||
|
c8a9969511 | ||
|
b0a8734c92 | ||
|
8d0723c2c3 |
@ -6,7 +6,8 @@
|
|||||||
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy ALLEGRO_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy ALLEGRO_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// [X] Platform: Clipboard support (from Allegro 5.1.12)
|
// [X] Platform: Clipboard support (from Allegro 5.1.12)
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
// Issues:
|
// Missing features:
|
||||||
|
// [ ] Renderer: Multi-viewport support (multiple windows)..
|
||||||
// [ ] Renderer: The renderer is suboptimal as we need to convert vertices manually.
|
// [ ] Renderer: The renderer is suboptimal as we need to convert vertices manually.
|
||||||
// [ ] Platform: Missing gamepad support.
|
// [ ] Platform: Missing gamepad support.
|
||||||
|
|
||||||
|
@ -6,7 +6,8 @@
|
|||||||
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy ALLEGRO_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy ALLEGRO_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// [X] Platform: Clipboard support (from Allegro 5.1.12)
|
// [X] Platform: Clipboard support (from Allegro 5.1.12)
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
// Issues:
|
// Missing features:
|
||||||
|
// [ ] Renderer: Multi-viewport support (multiple windows)..
|
||||||
// [ ] Renderer: The renderer is suboptimal as we need to unindex our buffers and convert vertices manually.
|
// [ ] Renderer: The renderer is suboptimal as we need to unindex our buffers and convert vertices manually.
|
||||||
// [ ] Platform: Missing gamepad support.
|
// [ ] Platform: Missing gamepad support.
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
// [ ] Platform: Clipboard support.
|
// [ ] Platform: Clipboard support.
|
||||||
// [ ] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [ ] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
// [ ] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: Check if this is even possible with Android.
|
// [ ] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: Check if this is even possible with Android.
|
||||||
|
// [ ] Platform: Multi-viewport support (multiple windows). Not meaningful on Android.
|
||||||
// Important:
|
// Important:
|
||||||
// - Consider using SDL or GLFW backend on Android, which will be more full-featured than this.
|
// - Consider using SDL or GLFW backend on Android, which will be more full-featured than this.
|
||||||
// - FIXME: On-screen keyboard currently needs to be enabled by the application (see examples/ and issue #3446)
|
// - FIXME: On-screen keyboard currently needs to be enabled by the application (see examples/ and issue #3446)
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
// [ ] Platform: Clipboard support.
|
// [ ] Platform: Clipboard support.
|
||||||
// [ ] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [ ] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
// [ ] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: Check if this is even possible with Android.
|
// [ ] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: Check if this is even possible with Android.
|
||||||
|
// [ ] Platform: Multi-viewport support (multiple windows). Not meaningful on Android.
|
||||||
// Important:
|
// Important:
|
||||||
// - Consider using SDL or GLFW backend on Android, which will be more full-featured than this.
|
// - Consider using SDL or GLFW backend on Android, which will be more full-featured than this.
|
||||||
// - FIXME: On-screen keyboard currently needs to be enabled by the application (see examples/ and issue #3446)
|
// - FIXME: On-screen keyboard currently needs to be enabled by the application (see examples/ and issue #3446)
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'ID3D10ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'ID3D10ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
@ -15,6 +16,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
||||||
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
||||||
// 2021-05-19: DirectX10: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
|
// 2021-05-19: DirectX10: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
|
||||||
@ -79,6 +81,10 @@ static ImGui_ImplDX10_Data* ImGui_ImplDX10_GetBackendData()
|
|||||||
return ImGui::GetCurrentContext() ? (ImGui_ImplDX10_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
return ImGui::GetCurrentContext() ? (ImGui_ImplDX10_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
static void ImGui_ImplDX10_InitPlatformInterface();
|
||||||
|
static void ImGui_ImplDX10_ShutdownPlatformInterface();
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
static void ImGui_ImplDX10_SetupRenderState(ImDrawData* draw_data, ID3D10Device* ctx)
|
static void ImGui_ImplDX10_SetupRenderState(ImDrawData* draw_data, ID3D10Device* ctx)
|
||||||
{
|
{
|
||||||
@ -542,6 +548,7 @@ bool ImGui_ImplDX10_Init(ID3D10Device* device)
|
|||||||
io.BackendRendererUserData = (void*)bd;
|
io.BackendRendererUserData = (void*)bd;
|
||||||
io.BackendRendererName = "imgui_impl_dx10";
|
io.BackendRendererName = "imgui_impl_dx10";
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasViewports; // We can create multi-viewports on the Renderer side (optional)
|
||||||
|
|
||||||
// Get factory from device
|
// Get factory from device
|
||||||
IDXGIDevice* pDXGIDevice = nullptr;
|
IDXGIDevice* pDXGIDevice = nullptr;
|
||||||
@ -558,6 +565,8 @@ bool ImGui_ImplDX10_Init(ID3D10Device* device)
|
|||||||
if (pDXGIAdapter) pDXGIAdapter->Release();
|
if (pDXGIAdapter) pDXGIAdapter->Release();
|
||||||
bd->pd3dDevice->AddRef();
|
bd->pd3dDevice->AddRef();
|
||||||
|
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
ImGui_ImplDX10_InitPlatformInterface();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -567,12 +576,13 @@ void ImGui_ImplDX10_Shutdown()
|
|||||||
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
ImGui_ImplDX10_ShutdownPlatformInterface();
|
||||||
ImGui_ImplDX10_InvalidateDeviceObjects();
|
ImGui_ImplDX10_InvalidateDeviceObjects();
|
||||||
if (bd->pFactory) { bd->pFactory->Release(); }
|
if (bd->pFactory) { bd->pFactory->Release(); }
|
||||||
if (bd->pd3dDevice) { bd->pd3dDevice->Release(); }
|
if (bd->pd3dDevice) { bd->pd3dDevice->Release(); }
|
||||||
io.BackendRendererName = nullptr;
|
io.BackendRendererName = nullptr;
|
||||||
io.BackendRendererUserData = nullptr;
|
io.BackendRendererUserData = nullptr;
|
||||||
io.BackendFlags &= ~ImGuiBackendFlags_RendererHasVtxOffset;
|
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasViewports);
|
||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -585,6 +595,129 @@ void ImGui_ImplDX10_NewFrame()
|
|||||||
ImGui_ImplDX10_CreateDeviceObjects();
|
ImGui_ImplDX10_CreateDeviceObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
|
||||||
|
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
|
||||||
|
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
|
||||||
|
struct ImGui_ImplDX10_ViewportData
|
||||||
|
{
|
||||||
|
IDXGISwapChain* SwapChain;
|
||||||
|
ID3D10RenderTargetView* RTView;
|
||||||
|
|
||||||
|
ImGui_ImplDX10_ViewportData() { SwapChain = nullptr; RTView = nullptr; }
|
||||||
|
~ImGui_ImplDX10_ViewportData() { IM_ASSERT(SwapChain == nullptr && RTView == nullptr); }
|
||||||
|
};
|
||||||
|
|
||||||
|
static void ImGui_ImplDX10_CreateWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX10_Data* bd = ImGui_ImplDX10_GetBackendData();
|
||||||
|
ImGui_ImplDX10_ViewportData* vd = IM_NEW(ImGui_ImplDX10_ViewportData)();
|
||||||
|
viewport->RendererUserData = vd;
|
||||||
|
|
||||||
|
// PlatformHandleRaw should always be a HWND, whereas PlatformHandle might be a higher-level handle (e.g. GLFWWindow*, SDL_Window*).
|
||||||
|
// Some backends will leave PlatformHandleRaw == 0, in which case we assume PlatformHandle will contain the HWND.
|
||||||
|
HWND hwnd = viewport->PlatformHandleRaw ? (HWND)viewport->PlatformHandleRaw : (HWND)viewport->PlatformHandle;
|
||||||
|
IM_ASSERT(hwnd != 0);
|
||||||
|
|
||||||
|
// Create swap chain
|
||||||
|
DXGI_SWAP_CHAIN_DESC sd;
|
||||||
|
ZeroMemory(&sd, sizeof(sd));
|
||||||
|
sd.BufferDesc.Width = (UINT)viewport->Size.x;
|
||||||
|
sd.BufferDesc.Height = (UINT)viewport->Size.y;
|
||||||
|
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||||
|
sd.SampleDesc.Count = 1;
|
||||||
|
sd.SampleDesc.Quality = 0;
|
||||||
|
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||||
|
sd.BufferCount = 1;
|
||||||
|
sd.OutputWindow = hwnd;
|
||||||
|
sd.Windowed = TRUE;
|
||||||
|
sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
|
||||||
|
sd.Flags = 0;
|
||||||
|
|
||||||
|
IM_ASSERT(vd->SwapChain == nullptr && vd->RTView == nullptr);
|
||||||
|
bd->pFactory->CreateSwapChain(bd->pd3dDevice, &sd, &vd->SwapChain);
|
||||||
|
|
||||||
|
// Create the render target
|
||||||
|
if (vd->SwapChain)
|
||||||
|
{
|
||||||
|
ID3D10Texture2D* pBackBuffer;
|
||||||
|
vd->SwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer));
|
||||||
|
bd->pd3dDevice->CreateRenderTargetView(pBackBuffer, nullptr, &vd->RTView);
|
||||||
|
pBackBuffer->Release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX10_DestroyWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
// The main viewport (owned by the application) will always have RendererUserData == 0 here since we didn't create the data for it.
|
||||||
|
if (ImGui_ImplDX10_ViewportData* vd = (ImGui_ImplDX10_ViewportData*)viewport->RendererUserData)
|
||||||
|
{
|
||||||
|
if (vd->SwapChain)
|
||||||
|
vd->SwapChain->Release();
|
||||||
|
vd->SwapChain = nullptr;
|
||||||
|
if (vd->RTView)
|
||||||
|
vd->RTView->Release();
|
||||||
|
vd->RTView = nullptr;
|
||||||
|
IM_DELETE(vd);
|
||||||
|
}
|
||||||
|
viewport->RendererUserData = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX10_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX10_Data* bd = ImGui_ImplDX10_GetBackendData();
|
||||||
|
ImGui_ImplDX10_ViewportData* vd = (ImGui_ImplDX10_ViewportData*)viewport->RendererUserData;
|
||||||
|
if (vd->RTView)
|
||||||
|
{
|
||||||
|
vd->RTView->Release();
|
||||||
|
vd->RTView = nullptr;
|
||||||
|
}
|
||||||
|
if (vd->SwapChain)
|
||||||
|
{
|
||||||
|
ID3D10Texture2D* pBackBuffer = nullptr;
|
||||||
|
vd->SwapChain->ResizeBuffers(0, (UINT)size.x, (UINT)size.y, DXGI_FORMAT_UNKNOWN, 0);
|
||||||
|
vd->SwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer));
|
||||||
|
if (pBackBuffer == nullptr) { fprintf(stderr, "ImGui_ImplDX10_SetWindowSize() failed creating buffers.\n"); return; }
|
||||||
|
bd->pd3dDevice->CreateRenderTargetView(pBackBuffer, nullptr, &vd->RTView);
|
||||||
|
pBackBuffer->Release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX10_RenderViewport(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX10_Data* bd = ImGui_ImplDX10_GetBackendData();
|
||||||
|
ImGui_ImplDX10_ViewportData* vd = (ImGui_ImplDX10_ViewportData*)viewport->RendererUserData;
|
||||||
|
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
bd->pd3dDevice->OMSetRenderTargets(1, &vd->RTView, nullptr);
|
||||||
|
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
|
||||||
|
bd->pd3dDevice->ClearRenderTargetView(vd->RTView, (float*)&clear_color);
|
||||||
|
ImGui_ImplDX10_RenderDrawData(viewport->DrawData);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX10_SwapBuffers(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX10_ViewportData* vd = (ImGui_ImplDX10_ViewportData*)viewport->RendererUserData;
|
||||||
|
vd->SwapChain->Present(0, 0); // Present without vsync
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplDX10_InitPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
platform_io.Renderer_CreateWindow = ImGui_ImplDX10_CreateWindow;
|
||||||
|
platform_io.Renderer_DestroyWindow = ImGui_ImplDX10_DestroyWindow;
|
||||||
|
platform_io.Renderer_SetWindowSize = ImGui_ImplDX10_SetWindowSize;
|
||||||
|
platform_io.Renderer_RenderWindow = ImGui_ImplDX10_RenderViewport;
|
||||||
|
platform_io.Renderer_SwapBuffers = ImGui_ImplDX10_SwapBuffers;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplDX10_ShutdownPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGui::DestroyPlatformWindows();
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#endif // #ifndef IMGUI_DISABLE
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'ID3D10ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'ID3D10ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
@ -15,6 +16,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
||||||
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
||||||
// 2021-05-19: DirectX11: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
|
// 2021-05-19: DirectX11: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
|
||||||
@ -80,6 +82,10 @@ static ImGui_ImplDX11_Data* ImGui_ImplDX11_GetBackendData()
|
|||||||
return ImGui::GetCurrentContext() ? (ImGui_ImplDX11_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
return ImGui::GetCurrentContext() ? (ImGui_ImplDX11_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
static void ImGui_ImplDX11_InitPlatformInterface();
|
||||||
|
static void ImGui_ImplDX11_ShutdownPlatformInterface();
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
static void ImGui_ImplDX11_SetupRenderState(ImDrawData* draw_data, ID3D11DeviceContext* ctx)
|
static void ImGui_ImplDX11_SetupRenderState(ImDrawData* draw_data, ID3D11DeviceContext* ctx)
|
||||||
{
|
{
|
||||||
@ -554,6 +560,7 @@ bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_co
|
|||||||
io.BackendRendererUserData = (void*)bd;
|
io.BackendRendererUserData = (void*)bd;
|
||||||
io.BackendRendererName = "imgui_impl_dx11";
|
io.BackendRendererName = "imgui_impl_dx11";
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasViewports; // We can create multi-viewports on the Renderer side (optional)
|
||||||
|
|
||||||
// Get factory from device
|
// Get factory from device
|
||||||
IDXGIDevice* pDXGIDevice = nullptr;
|
IDXGIDevice* pDXGIDevice = nullptr;
|
||||||
@ -573,6 +580,9 @@ bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_co
|
|||||||
bd->pd3dDevice->AddRef();
|
bd->pd3dDevice->AddRef();
|
||||||
bd->pd3dDeviceContext->AddRef();
|
bd->pd3dDeviceContext->AddRef();
|
||||||
|
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
ImGui_ImplDX11_InitPlatformInterface();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -582,13 +592,14 @@ void ImGui_ImplDX11_Shutdown()
|
|||||||
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
ImGui_ImplDX11_ShutdownPlatformInterface();
|
||||||
ImGui_ImplDX11_InvalidateDeviceObjects();
|
ImGui_ImplDX11_InvalidateDeviceObjects();
|
||||||
if (bd->pFactory) { bd->pFactory->Release(); }
|
if (bd->pFactory) { bd->pFactory->Release(); }
|
||||||
if (bd->pd3dDevice) { bd->pd3dDevice->Release(); }
|
if (bd->pd3dDevice) { bd->pd3dDevice->Release(); }
|
||||||
if (bd->pd3dDeviceContext) { bd->pd3dDeviceContext->Release(); }
|
if (bd->pd3dDeviceContext) { bd->pd3dDeviceContext->Release(); }
|
||||||
io.BackendRendererName = nullptr;
|
io.BackendRendererName = nullptr;
|
||||||
io.BackendRendererUserData = nullptr;
|
io.BackendRendererUserData = nullptr;
|
||||||
io.BackendFlags &= ~ImGuiBackendFlags_RendererHasVtxOffset;
|
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasViewports);
|
||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -601,6 +612,129 @@ void ImGui_ImplDX11_NewFrame()
|
|||||||
ImGui_ImplDX11_CreateDeviceObjects();
|
ImGui_ImplDX11_CreateDeviceObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
|
||||||
|
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
|
||||||
|
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
|
||||||
|
struct ImGui_ImplDX11_ViewportData
|
||||||
|
{
|
||||||
|
IDXGISwapChain* SwapChain;
|
||||||
|
ID3D11RenderTargetView* RTView;
|
||||||
|
|
||||||
|
ImGui_ImplDX11_ViewportData() { SwapChain = nullptr; RTView = nullptr; }
|
||||||
|
~ImGui_ImplDX11_ViewportData() { IM_ASSERT(SwapChain == nullptr && RTView == nullptr); }
|
||||||
|
};
|
||||||
|
|
||||||
|
static void ImGui_ImplDX11_CreateWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData();
|
||||||
|
ImGui_ImplDX11_ViewportData* vd = IM_NEW(ImGui_ImplDX11_ViewportData)();
|
||||||
|
viewport->RendererUserData = vd;
|
||||||
|
|
||||||
|
// PlatformHandleRaw should always be a HWND, whereas PlatformHandle might be a higher-level handle (e.g. GLFWWindow*, SDL_Window*).
|
||||||
|
// Some backends will leave PlatformHandleRaw == 0, in which case we assume PlatformHandle will contain the HWND.
|
||||||
|
HWND hwnd = viewport->PlatformHandleRaw ? (HWND)viewport->PlatformHandleRaw : (HWND)viewport->PlatformHandle;
|
||||||
|
IM_ASSERT(hwnd != 0);
|
||||||
|
|
||||||
|
// Create swap chain
|
||||||
|
DXGI_SWAP_CHAIN_DESC sd;
|
||||||
|
ZeroMemory(&sd, sizeof(sd));
|
||||||
|
sd.BufferDesc.Width = (UINT)viewport->Size.x;
|
||||||
|
sd.BufferDesc.Height = (UINT)viewport->Size.y;
|
||||||
|
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||||
|
sd.SampleDesc.Count = 1;
|
||||||
|
sd.SampleDesc.Quality = 0;
|
||||||
|
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||||
|
sd.BufferCount = 1;
|
||||||
|
sd.OutputWindow = hwnd;
|
||||||
|
sd.Windowed = TRUE;
|
||||||
|
sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
|
||||||
|
sd.Flags = 0;
|
||||||
|
|
||||||
|
IM_ASSERT(vd->SwapChain == nullptr && vd->RTView == nullptr);
|
||||||
|
bd->pFactory->CreateSwapChain(bd->pd3dDevice, &sd, &vd->SwapChain);
|
||||||
|
|
||||||
|
// Create the render target
|
||||||
|
if (vd->SwapChain)
|
||||||
|
{
|
||||||
|
ID3D11Texture2D* pBackBuffer;
|
||||||
|
vd->SwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer));
|
||||||
|
bd->pd3dDevice->CreateRenderTargetView(pBackBuffer, nullptr, &vd->RTView);
|
||||||
|
pBackBuffer->Release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX11_DestroyWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
// The main viewport (owned by the application) will always have RendererUserData == nullptr since we didn't create the data for it.
|
||||||
|
if (ImGui_ImplDX11_ViewportData* vd = (ImGui_ImplDX11_ViewportData*)viewport->RendererUserData)
|
||||||
|
{
|
||||||
|
if (vd->SwapChain)
|
||||||
|
vd->SwapChain->Release();
|
||||||
|
vd->SwapChain = nullptr;
|
||||||
|
if (vd->RTView)
|
||||||
|
vd->RTView->Release();
|
||||||
|
vd->RTView = nullptr;
|
||||||
|
IM_DELETE(vd);
|
||||||
|
}
|
||||||
|
viewport->RendererUserData = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX11_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData();
|
||||||
|
ImGui_ImplDX11_ViewportData* vd = (ImGui_ImplDX11_ViewportData*)viewport->RendererUserData;
|
||||||
|
if (vd->RTView)
|
||||||
|
{
|
||||||
|
vd->RTView->Release();
|
||||||
|
vd->RTView = nullptr;
|
||||||
|
}
|
||||||
|
if (vd->SwapChain)
|
||||||
|
{
|
||||||
|
ID3D11Texture2D* pBackBuffer = nullptr;
|
||||||
|
vd->SwapChain->ResizeBuffers(0, (UINT)size.x, (UINT)size.y, DXGI_FORMAT_UNKNOWN, 0);
|
||||||
|
vd->SwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer));
|
||||||
|
if (pBackBuffer == nullptr) { fprintf(stderr, "ImGui_ImplDX11_SetWindowSize() failed creating buffers.\n"); return; }
|
||||||
|
bd->pd3dDevice->CreateRenderTargetView(pBackBuffer, nullptr, &vd->RTView);
|
||||||
|
pBackBuffer->Release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX11_RenderWindow(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData();
|
||||||
|
ImGui_ImplDX11_ViewportData* vd = (ImGui_ImplDX11_ViewportData*)viewport->RendererUserData;
|
||||||
|
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
bd->pd3dDeviceContext->OMSetRenderTargets(1, &vd->RTView, nullptr);
|
||||||
|
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
|
||||||
|
bd->pd3dDeviceContext->ClearRenderTargetView(vd->RTView, (float*)&clear_color);
|
||||||
|
ImGui_ImplDX11_RenderDrawData(viewport->DrawData);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX11_SwapBuffers(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX11_ViewportData* vd = (ImGui_ImplDX11_ViewportData*)viewport->RendererUserData;
|
||||||
|
vd->SwapChain->Present(0, 0); // Present without vsync
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX11_InitPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
platform_io.Renderer_CreateWindow = ImGui_ImplDX11_CreateWindow;
|
||||||
|
platform_io.Renderer_DestroyWindow = ImGui_ImplDX11_DestroyWindow;
|
||||||
|
platform_io.Renderer_SetWindowSize = ImGui_ImplDX11_SetWindowSize;
|
||||||
|
platform_io.Renderer_RenderWindow = ImGui_ImplDX11_RenderWindow;
|
||||||
|
platform_io.Renderer_SwapBuffers = ImGui_ImplDX11_SwapBuffers;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX11_ShutdownPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGui::DestroyPlatformWindows();
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#endif // #ifndef IMGUI_DISABLE
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
// FIXME: The transition from removing a viewport and moving the window in an existing hosted viewport tends to flicker.
|
||||||
|
|
||||||
// Important: to compile on 32-bit systems, this backend requires code to be compiled with '#define ImTextureID ImU64'.
|
// Important: to compile on 32-bit systems, this backend requires code to be compiled with '#define ImTextureID ImU64'.
|
||||||
// This is because we need ImTextureID to carry a 64-bit value and by default ImTextureID is defined as void*.
|
// This is because we need ImTextureID to carry a 64-bit value and by default ImTextureID is defined as void*.
|
||||||
@ -23,6 +25,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
||||||
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
||||||
// 2021-05-19: DirectX12: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
|
// 2021-05-19: DirectX12: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
|
||||||
@ -54,7 +57,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// DirectX data
|
// DirectX data
|
||||||
struct ImGui_ImplDX12_RenderBuffers;
|
|
||||||
struct ImGui_ImplDX12_Data
|
struct ImGui_ImplDX12_Data
|
||||||
{
|
{
|
||||||
ID3D12Device* pd3dDevice;
|
ID3D12Device* pd3dDevice;
|
||||||
@ -67,10 +69,7 @@ struct ImGui_ImplDX12_Data
|
|||||||
ID3D12DescriptorHeap* pd3dSrvDescHeap;
|
ID3D12DescriptorHeap* pd3dSrvDescHeap;
|
||||||
UINT numFramesInFlight;
|
UINT numFramesInFlight;
|
||||||
|
|
||||||
ImGui_ImplDX12_RenderBuffers* pFrameResources;
|
ImGui_ImplDX12_Data() { memset((void*)this, 0, sizeof(*this)); }
|
||||||
UINT frameIndex;
|
|
||||||
|
|
||||||
ImGui_ImplDX12_Data() { memset((void*)this, 0, sizeof(*this)); frameIndex = UINT_MAX; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts
|
// Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts
|
||||||
@ -89,11 +88,88 @@ struct ImGui_ImplDX12_RenderBuffers
|
|||||||
int VertexBufferSize;
|
int VertexBufferSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Buffers used for secondary viewports created by the multi-viewports systems
|
||||||
|
struct ImGui_ImplDX12_FrameContext
|
||||||
|
{
|
||||||
|
ID3D12CommandAllocator* CommandAllocator;
|
||||||
|
ID3D12Resource* RenderTarget;
|
||||||
|
D3D12_CPU_DESCRIPTOR_HANDLE RenderTargetCpuDescriptors;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
|
||||||
|
// Main viewport created by application will only use the Resources field.
|
||||||
|
// Secondary viewports created by this backend will use all the fields (including Window fields),
|
||||||
|
struct ImGui_ImplDX12_ViewportData
|
||||||
|
{
|
||||||
|
// Window
|
||||||
|
ID3D12CommandQueue* CommandQueue;
|
||||||
|
ID3D12GraphicsCommandList* CommandList;
|
||||||
|
ID3D12DescriptorHeap* RtvDescHeap;
|
||||||
|
IDXGISwapChain3* SwapChain;
|
||||||
|
ID3D12Fence* Fence;
|
||||||
|
UINT64 FenceSignaledValue;
|
||||||
|
HANDLE FenceEvent;
|
||||||
|
UINT NumFramesInFlight;
|
||||||
|
ImGui_ImplDX12_FrameContext* FrameCtx;
|
||||||
|
|
||||||
|
// Render buffers
|
||||||
|
UINT FrameIndex;
|
||||||
|
ImGui_ImplDX12_RenderBuffers* FrameRenderBuffers;
|
||||||
|
|
||||||
|
ImGui_ImplDX12_ViewportData(UINT num_frames_in_flight)
|
||||||
|
{
|
||||||
|
CommandQueue = nullptr;
|
||||||
|
CommandList = nullptr;
|
||||||
|
RtvDescHeap = nullptr;
|
||||||
|
SwapChain = nullptr;
|
||||||
|
Fence = nullptr;
|
||||||
|
FenceSignaledValue = 0;
|
||||||
|
FenceEvent = nullptr;
|
||||||
|
NumFramesInFlight = num_frames_in_flight;
|
||||||
|
FrameCtx = new ImGui_ImplDX12_FrameContext[NumFramesInFlight];
|
||||||
|
FrameIndex = UINT_MAX;
|
||||||
|
FrameRenderBuffers = new ImGui_ImplDX12_RenderBuffers[NumFramesInFlight];
|
||||||
|
|
||||||
|
for (UINT i = 0; i < NumFramesInFlight; ++i)
|
||||||
|
{
|
||||||
|
FrameCtx[i].CommandAllocator = nullptr;
|
||||||
|
FrameCtx[i].RenderTarget = nullptr;
|
||||||
|
|
||||||
|
// Create buffers with a default size (they will later be grown as needed)
|
||||||
|
FrameRenderBuffers[i].IndexBuffer = nullptr;
|
||||||
|
FrameRenderBuffers[i].VertexBuffer = nullptr;
|
||||||
|
FrameRenderBuffers[i].VertexBufferSize = 5000;
|
||||||
|
FrameRenderBuffers[i].IndexBufferSize = 10000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
~ImGui_ImplDX12_ViewportData()
|
||||||
|
{
|
||||||
|
IM_ASSERT(CommandQueue == nullptr && CommandList == nullptr);
|
||||||
|
IM_ASSERT(RtvDescHeap == nullptr);
|
||||||
|
IM_ASSERT(SwapChain == nullptr);
|
||||||
|
IM_ASSERT(Fence == nullptr);
|
||||||
|
IM_ASSERT(FenceEvent == nullptr);
|
||||||
|
|
||||||
|
for (UINT i = 0; i < NumFramesInFlight; ++i)
|
||||||
|
{
|
||||||
|
IM_ASSERT(FrameCtx[i].CommandAllocator == nullptr && FrameCtx[i].RenderTarget == nullptr);
|
||||||
|
IM_ASSERT(FrameRenderBuffers[i].IndexBuffer == nullptr && FrameRenderBuffers[i].VertexBuffer == nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete[] FrameCtx; FrameCtx = nullptr;
|
||||||
|
delete[] FrameRenderBuffers; FrameRenderBuffers = nullptr;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct VERTEX_CONSTANT_BUFFER_DX12
|
struct VERTEX_CONSTANT_BUFFER_DX12
|
||||||
{
|
{
|
||||||
float mvp[4][4];
|
float mvp[4][4];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
static void ImGui_ImplDX12_InitPlatformInterface();
|
||||||
|
static void ImGui_ImplDX12_ShutdownPlatformInterface();
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
static void ImGui_ImplDX12_SetupRenderState(ImDrawData* draw_data, ID3D12GraphicsCommandList* ctx, ImGui_ImplDX12_RenderBuffers* fr)
|
static void ImGui_ImplDX12_SetupRenderState(ImDrawData* draw_data, ID3D12GraphicsCommandList* ctx, ImGui_ImplDX12_RenderBuffers* fr)
|
||||||
{
|
{
|
||||||
@ -167,11 +243,10 @@ void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandL
|
|||||||
if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f)
|
if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// FIXME: I'm assuming that this only gets called once per frame!
|
|
||||||
// If not, we can't just re-allocate the IB or VB, we'll have to do a proper allocator.
|
|
||||||
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
|
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
|
||||||
bd->frameIndex = bd->frameIndex + 1;
|
ImGui_ImplDX12_ViewportData* vd = (ImGui_ImplDX12_ViewportData*)draw_data->OwnerViewport->RendererUserData;
|
||||||
ImGui_ImplDX12_RenderBuffers* fr = &bd->pFrameResources[bd->frameIndex % bd->numFramesInFlight];
|
vd->FrameIndex++;
|
||||||
|
ImGui_ImplDX12_RenderBuffers* fr = &vd->FrameRenderBuffers[vd->FrameIndex % bd->numFramesInFlight];
|
||||||
|
|
||||||
// Create and grow vertex/index buffers if needed
|
// Create and grow vertex/index buffers if needed
|
||||||
if (fr->VertexBuffer == nullptr || fr->VertexBufferSize < draw_data->TotalVtxCount)
|
if (fr->VertexBuffer == nullptr || fr->VertexBufferSize < draw_data->TotalVtxCount)
|
||||||
@ -678,6 +753,13 @@ bool ImGui_ImplDX12_CreateDeviceObjects()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX12_DestroyRenderBuffers(ImGui_ImplDX12_RenderBuffers* render_buffers)
|
||||||
|
{
|
||||||
|
SafeRelease(render_buffers->IndexBuffer);
|
||||||
|
SafeRelease(render_buffers->VertexBuffer);
|
||||||
|
render_buffers->IndexBufferSize = render_buffers->VertexBufferSize = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void ImGui_ImplDX12_InvalidateDeviceObjects()
|
void ImGui_ImplDX12_InvalidateDeviceObjects()
|
||||||
{
|
{
|
||||||
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
|
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
|
||||||
@ -689,13 +771,6 @@ void ImGui_ImplDX12_InvalidateDeviceObjects()
|
|||||||
SafeRelease(bd->pPipelineState);
|
SafeRelease(bd->pPipelineState);
|
||||||
SafeRelease(bd->pFontTextureResource);
|
SafeRelease(bd->pFontTextureResource);
|
||||||
io.Fonts->SetTexID(0); // We copied bd->pFontTextureView to io.Fonts->TexID so let's clear that as well.
|
io.Fonts->SetTexID(0); // We copied bd->pFontTextureView to io.Fonts->TexID so let's clear that as well.
|
||||||
|
|
||||||
for (UINT i = 0; i < bd->numFramesInFlight; i++)
|
|
||||||
{
|
|
||||||
ImGui_ImplDX12_RenderBuffers* fr = &bd->pFrameResources[i];
|
|
||||||
SafeRelease(fr->IndexBuffer);
|
|
||||||
SafeRelease(fr->VertexBuffer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FORMAT rtv_format, ID3D12DescriptorHeap* cbv_srv_heap,
|
bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FORMAT rtv_format, ID3D12DescriptorHeap* cbv_srv_heap,
|
||||||
@ -710,25 +785,21 @@ bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FO
|
|||||||
io.BackendRendererUserData = (void*)bd;
|
io.BackendRendererUserData = (void*)bd;
|
||||||
io.BackendRendererName = "imgui_impl_dx12";
|
io.BackendRendererName = "imgui_impl_dx12";
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasViewports; // We can create multi-viewports on the Renderer side (optional)
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
ImGui_ImplDX12_InitPlatformInterface();
|
||||||
|
|
||||||
bd->pd3dDevice = device;
|
bd->pd3dDevice = device;
|
||||||
bd->RTVFormat = rtv_format;
|
bd->RTVFormat = rtv_format;
|
||||||
bd->hFontSrvCpuDescHandle = font_srv_cpu_desc_handle;
|
bd->hFontSrvCpuDescHandle = font_srv_cpu_desc_handle;
|
||||||
bd->hFontSrvGpuDescHandle = font_srv_gpu_desc_handle;
|
bd->hFontSrvGpuDescHandle = font_srv_gpu_desc_handle;
|
||||||
bd->pFrameResources = new ImGui_ImplDX12_RenderBuffers[num_frames_in_flight];
|
|
||||||
bd->numFramesInFlight = num_frames_in_flight;
|
bd->numFramesInFlight = num_frames_in_flight;
|
||||||
bd->pd3dSrvDescHeap = cbv_srv_heap;
|
bd->pd3dSrvDescHeap = cbv_srv_heap;
|
||||||
bd->frameIndex = UINT_MAX;
|
|
||||||
|
|
||||||
// Create buffers with a default size (they will later be grown as needed)
|
// Create a dummy ImGui_ImplDX12_ViewportData holder for the main viewport,
|
||||||
for (int i = 0; i < num_frames_in_flight; i++)
|
// Since this is created and managed by the application, we will only use the ->Resources[] fields.
|
||||||
{
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
ImGui_ImplDX12_RenderBuffers* fr = &bd->pFrameResources[i];
|
main_viewport->RendererUserData = IM_NEW(ImGui_ImplDX12_ViewportData)(bd->numFramesInFlight);
|
||||||
fr->IndexBuffer = nullptr;
|
|
||||||
fr->VertexBuffer = nullptr;
|
|
||||||
fr->IndexBufferSize = 10000;
|
|
||||||
fr->VertexBufferSize = 5000;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -739,12 +810,24 @@ void ImGui_ImplDX12_Shutdown()
|
|||||||
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
// Manually delete main viewport render resources in-case we haven't initialized for viewports
|
||||||
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
|
if (ImGui_ImplDX12_ViewportData* vd = (ImGui_ImplDX12_ViewportData*)main_viewport->RendererUserData)
|
||||||
|
{
|
||||||
|
// We could just call ImGui_ImplDX12_DestroyWindow(main_viewport) as a convenience but that would be misleading since we only use data->Resources[]
|
||||||
|
for (UINT i = 0; i < bd->numFramesInFlight; i++)
|
||||||
|
ImGui_ImplDX12_DestroyRenderBuffers(&vd->FrameRenderBuffers[i]);
|
||||||
|
IM_DELETE(vd);
|
||||||
|
main_viewport->RendererUserData = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
// Clean up windows and device objects
|
// Clean up windows and device objects
|
||||||
|
ImGui_ImplDX12_ShutdownPlatformInterface();
|
||||||
ImGui_ImplDX12_InvalidateDeviceObjects();
|
ImGui_ImplDX12_InvalidateDeviceObjects();
|
||||||
delete[] bd->pFrameResources;
|
|
||||||
io.BackendRendererName = nullptr;
|
io.BackendRendererName = nullptr;
|
||||||
io.BackendRendererUserData = nullptr;
|
io.BackendRendererUserData = nullptr;
|
||||||
io.BackendFlags &= ~ImGuiBackendFlags_RendererHasVtxOffset;
|
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasViewports);
|
||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -757,6 +840,246 @@ void ImGui_ImplDX12_NewFrame()
|
|||||||
ImGui_ImplDX12_CreateDeviceObjects();
|
ImGui_ImplDX12_CreateDeviceObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
|
||||||
|
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
|
||||||
|
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static void ImGui_ImplDX12_CreateWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
|
||||||
|
ImGui_ImplDX12_ViewportData* vd = IM_NEW(ImGui_ImplDX12_ViewportData)(bd->numFramesInFlight);
|
||||||
|
viewport->RendererUserData = vd;
|
||||||
|
|
||||||
|
// PlatformHandleRaw should always be a HWND, whereas PlatformHandle might be a higher-level handle (e.g. GLFWWindow*, SDL_Window*).
|
||||||
|
// Some backends will leave PlatformHandleRaw == 0, in which case we assume PlatformHandle will contain the HWND.
|
||||||
|
HWND hwnd = viewport->PlatformHandleRaw ? (HWND)viewport->PlatformHandleRaw : (HWND)viewport->PlatformHandle;
|
||||||
|
IM_ASSERT(hwnd != 0);
|
||||||
|
|
||||||
|
vd->FrameIndex = UINT_MAX;
|
||||||
|
|
||||||
|
// Create command queue.
|
||||||
|
D3D12_COMMAND_QUEUE_DESC queue_desc = {};
|
||||||
|
queue_desc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;
|
||||||
|
queue_desc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT;
|
||||||
|
|
||||||
|
HRESULT res = S_OK;
|
||||||
|
res = bd->pd3dDevice->CreateCommandQueue(&queue_desc, IID_PPV_ARGS(&vd->CommandQueue));
|
||||||
|
IM_ASSERT(res == S_OK);
|
||||||
|
|
||||||
|
// Create command allocator.
|
||||||
|
for (UINT i = 0; i < bd->numFramesInFlight; ++i)
|
||||||
|
{
|
||||||
|
res = bd->pd3dDevice->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&vd->FrameCtx[i].CommandAllocator));
|
||||||
|
IM_ASSERT(res == S_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create command list.
|
||||||
|
res = bd->pd3dDevice->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, vd->FrameCtx[0].CommandAllocator, nullptr, IID_PPV_ARGS(&vd->CommandList));
|
||||||
|
IM_ASSERT(res == S_OK);
|
||||||
|
vd->CommandList->Close();
|
||||||
|
|
||||||
|
// Create fence.
|
||||||
|
res = bd->pd3dDevice->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&vd->Fence));
|
||||||
|
IM_ASSERT(res == S_OK);
|
||||||
|
|
||||||
|
vd->FenceEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
|
||||||
|
IM_ASSERT(vd->FenceEvent != nullptr);
|
||||||
|
|
||||||
|
// Create swap chain
|
||||||
|
// FIXME-VIEWPORT: May want to copy/inherit swap chain settings from the user/application.
|
||||||
|
DXGI_SWAP_CHAIN_DESC1 sd1;
|
||||||
|
ZeroMemory(&sd1, sizeof(sd1));
|
||||||
|
sd1.BufferCount = bd->numFramesInFlight;
|
||||||
|
sd1.Width = (UINT)viewport->Size.x;
|
||||||
|
sd1.Height = (UINT)viewport->Size.y;
|
||||||
|
sd1.Format = bd->RTVFormat;
|
||||||
|
sd1.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||||
|
sd1.SampleDesc.Count = 1;
|
||||||
|
sd1.SampleDesc.Quality = 0;
|
||||||
|
sd1.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
|
||||||
|
sd1.AlphaMode = DXGI_ALPHA_MODE_UNSPECIFIED;
|
||||||
|
sd1.Scaling = DXGI_SCALING_NONE;
|
||||||
|
sd1.Stereo = FALSE;
|
||||||
|
|
||||||
|
IDXGIFactory4* dxgi_factory = nullptr;
|
||||||
|
res = ::CreateDXGIFactory1(IID_PPV_ARGS(&dxgi_factory));
|
||||||
|
IM_ASSERT(res == S_OK);
|
||||||
|
|
||||||
|
IDXGISwapChain1* swap_chain = nullptr;
|
||||||
|
res = dxgi_factory->CreateSwapChainForHwnd(vd->CommandQueue, hwnd, &sd1, nullptr, nullptr, &swap_chain);
|
||||||
|
IM_ASSERT(res == S_OK);
|
||||||
|
|
||||||
|
dxgi_factory->Release();
|
||||||
|
|
||||||
|
// Or swapChain.As(&mSwapChain)
|
||||||
|
IM_ASSERT(vd->SwapChain == nullptr);
|
||||||
|
swap_chain->QueryInterface(IID_PPV_ARGS(&vd->SwapChain));
|
||||||
|
swap_chain->Release();
|
||||||
|
|
||||||
|
// Create the render targets
|
||||||
|
if (vd->SwapChain)
|
||||||
|
{
|
||||||
|
D3D12_DESCRIPTOR_HEAP_DESC desc = {};
|
||||||
|
desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV;
|
||||||
|
desc.NumDescriptors = bd->numFramesInFlight;
|
||||||
|
desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
|
||||||
|
desc.NodeMask = 1;
|
||||||
|
|
||||||
|
HRESULT hr = bd->pd3dDevice->CreateDescriptorHeap(&desc, IID_PPV_ARGS(&vd->RtvDescHeap));
|
||||||
|
IM_ASSERT(hr == S_OK);
|
||||||
|
|
||||||
|
SIZE_T rtv_descriptor_size = bd->pd3dDevice->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV);
|
||||||
|
D3D12_CPU_DESCRIPTOR_HANDLE rtv_handle = vd->RtvDescHeap->GetCPUDescriptorHandleForHeapStart();
|
||||||
|
for (UINT i = 0; i < bd->numFramesInFlight; i++)
|
||||||
|
{
|
||||||
|
vd->FrameCtx[i].RenderTargetCpuDescriptors = rtv_handle;
|
||||||
|
rtv_handle.ptr += rtv_descriptor_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
ID3D12Resource* back_buffer;
|
||||||
|
for (UINT i = 0; i < bd->numFramesInFlight; i++)
|
||||||
|
{
|
||||||
|
IM_ASSERT(vd->FrameCtx[i].RenderTarget == nullptr);
|
||||||
|
vd->SwapChain->GetBuffer(i, IID_PPV_ARGS(&back_buffer));
|
||||||
|
bd->pd3dDevice->CreateRenderTargetView(back_buffer, nullptr, vd->FrameCtx[i].RenderTargetCpuDescriptors);
|
||||||
|
vd->FrameCtx[i].RenderTarget = back_buffer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (UINT i = 0; i < bd->numFramesInFlight; i++)
|
||||||
|
ImGui_ImplDX12_DestroyRenderBuffers(&vd->FrameRenderBuffers[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_WaitForPendingOperations(ImGui_ImplDX12_ViewportData* vd)
|
||||||
|
{
|
||||||
|
HRESULT hr = S_FALSE;
|
||||||
|
if (vd && vd->CommandQueue && vd->Fence && vd->FenceEvent)
|
||||||
|
{
|
||||||
|
hr = vd->CommandQueue->Signal(vd->Fence, ++vd->FenceSignaledValue);
|
||||||
|
IM_ASSERT(hr == S_OK);
|
||||||
|
::WaitForSingleObject(vd->FenceEvent, 0); // Reset any forgotten waits
|
||||||
|
hr = vd->Fence->SetEventOnCompletion(vd->FenceSignaledValue, vd->FenceEvent);
|
||||||
|
IM_ASSERT(hr == S_OK);
|
||||||
|
::WaitForSingleObject(vd->FenceEvent, INFINITE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX12_DestroyWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
// The main viewport (owned by the application) will always have RendererUserData == 0 since we didn't create the data for it.
|
||||||
|
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
|
||||||
|
if (ImGui_ImplDX12_ViewportData* vd = (ImGui_ImplDX12_ViewportData*)viewport->RendererUserData)
|
||||||
|
{
|
||||||
|
ImGui_WaitForPendingOperations(vd);
|
||||||
|
|
||||||
|
SafeRelease(vd->CommandQueue);
|
||||||
|
SafeRelease(vd->CommandList);
|
||||||
|
SafeRelease(vd->SwapChain);
|
||||||
|
SafeRelease(vd->RtvDescHeap);
|
||||||
|
SafeRelease(vd->Fence);
|
||||||
|
::CloseHandle(vd->FenceEvent);
|
||||||
|
vd->FenceEvent = nullptr;
|
||||||
|
|
||||||
|
for (UINT i = 0; i < bd->numFramesInFlight; i++)
|
||||||
|
{
|
||||||
|
SafeRelease(vd->FrameCtx[i].RenderTarget);
|
||||||
|
SafeRelease(vd->FrameCtx[i].CommandAllocator);
|
||||||
|
ImGui_ImplDX12_DestroyRenderBuffers(&vd->FrameRenderBuffers[i]);
|
||||||
|
}
|
||||||
|
IM_DELETE(vd);
|
||||||
|
}
|
||||||
|
viewport->RendererUserData = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX12_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
|
||||||
|
ImGui_ImplDX12_ViewportData* vd = (ImGui_ImplDX12_ViewportData*)viewport->RendererUserData;
|
||||||
|
|
||||||
|
ImGui_WaitForPendingOperations(vd);
|
||||||
|
|
||||||
|
for (UINT i = 0; i < bd->numFramesInFlight; i++)
|
||||||
|
SafeRelease(vd->FrameCtx[i].RenderTarget);
|
||||||
|
|
||||||
|
if (vd->SwapChain)
|
||||||
|
{
|
||||||
|
ID3D12Resource* back_buffer = nullptr;
|
||||||
|
vd->SwapChain->ResizeBuffers(0, (UINT)size.x, (UINT)size.y, DXGI_FORMAT_UNKNOWN, 0);
|
||||||
|
for (UINT i = 0; i < bd->numFramesInFlight; i++)
|
||||||
|
{
|
||||||
|
vd->SwapChain->GetBuffer(i, IID_PPV_ARGS(&back_buffer));
|
||||||
|
bd->pd3dDevice->CreateRenderTargetView(back_buffer, nullptr, vd->FrameCtx[i].RenderTargetCpuDescriptors);
|
||||||
|
vd->FrameCtx[i].RenderTarget = back_buffer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX12_RenderWindow(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
|
||||||
|
ImGui_ImplDX12_ViewportData* vd = (ImGui_ImplDX12_ViewportData*)viewport->RendererUserData;
|
||||||
|
|
||||||
|
ImGui_ImplDX12_FrameContext* frame_context = &vd->FrameCtx[vd->FrameIndex % bd->numFramesInFlight];
|
||||||
|
UINT back_buffer_idx = vd->SwapChain->GetCurrentBackBufferIndex();
|
||||||
|
|
||||||
|
const ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
D3D12_RESOURCE_BARRIER barrier = {};
|
||||||
|
barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
|
||||||
|
barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
|
||||||
|
barrier.Transition.pResource = vd->FrameCtx[back_buffer_idx].RenderTarget;
|
||||||
|
barrier.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;
|
||||||
|
barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_PRESENT;
|
||||||
|
barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_RENDER_TARGET;
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
ID3D12GraphicsCommandList* cmd_list = vd->CommandList;
|
||||||
|
|
||||||
|
frame_context->CommandAllocator->Reset();
|
||||||
|
cmd_list->Reset(frame_context->CommandAllocator, nullptr);
|
||||||
|
cmd_list->ResourceBarrier(1, &barrier);
|
||||||
|
cmd_list->OMSetRenderTargets(1, &vd->FrameCtx[back_buffer_idx].RenderTargetCpuDescriptors, FALSE, nullptr);
|
||||||
|
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
|
||||||
|
cmd_list->ClearRenderTargetView(vd->FrameCtx[back_buffer_idx].RenderTargetCpuDescriptors, (float*)&clear_color, 0, nullptr);
|
||||||
|
cmd_list->SetDescriptorHeaps(1, &bd->pd3dSrvDescHeap);
|
||||||
|
|
||||||
|
ImGui_ImplDX12_RenderDrawData(viewport->DrawData, cmd_list);
|
||||||
|
|
||||||
|
barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_RENDER_TARGET;
|
||||||
|
barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_PRESENT;
|
||||||
|
cmd_list->ResourceBarrier(1, &barrier);
|
||||||
|
cmd_list->Close();
|
||||||
|
|
||||||
|
vd->CommandQueue->Wait(vd->Fence, vd->FenceSignaledValue);
|
||||||
|
vd->CommandQueue->ExecuteCommandLists(1, (ID3D12CommandList* const*)&cmd_list);
|
||||||
|
vd->CommandQueue->Signal(vd->Fence, ++vd->FenceSignaledValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX12_SwapBuffers(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX12_ViewportData* vd = (ImGui_ImplDX12_ViewportData*)viewport->RendererUserData;
|
||||||
|
|
||||||
|
vd->SwapChain->Present(0, 0);
|
||||||
|
while (vd->Fence->GetCompletedValue() < vd->FenceSignaledValue)
|
||||||
|
::SwitchToThread();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplDX12_InitPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
platform_io.Renderer_CreateWindow = ImGui_ImplDX12_CreateWindow;
|
||||||
|
platform_io.Renderer_DestroyWindow = ImGui_ImplDX12_DestroyWindow;
|
||||||
|
platform_io.Renderer_SetWindowSize = ImGui_ImplDX12_SetWindowSize;
|
||||||
|
platform_io.Renderer_RenderWindow = ImGui_ImplDX12_RenderWindow;
|
||||||
|
platform_io.Renderer_SwapBuffers = ImGui_ImplDX12_SwapBuffers;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplDX12_ShutdownPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGui::DestroyPlatformWindows();
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#endif // #ifndef IMGUI_DISABLE
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
|
||||||
// Important: to compile on 32-bit systems, this backend requires code to be compiled with '#define ImTextureID ImU64'.
|
// Important: to compile on 32-bit systems, this backend requires code to be compiled with '#define ImTextureID ImU64'.
|
||||||
// See imgui_impl_dx12.cpp file for details.
|
// See imgui_impl_dx12.cpp file for details.
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
@ -15,6 +16,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
// 2024-02-12: DirectX9: Using RGBA format when supported by the driver to avoid CPU side conversion. (#6575)
|
// 2024-02-12: DirectX9: Using RGBA format when supported by the driver to avoid CPU side conversion. (#6575)
|
||||||
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
||||||
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
||||||
@ -76,6 +78,12 @@ static ImGui_ImplDX9_Data* ImGui_ImplDX9_GetBackendData()
|
|||||||
return ImGui::GetCurrentContext() ? (ImGui_ImplDX9_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
return ImGui::GetCurrentContext() ? (ImGui_ImplDX9_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
static void ImGui_ImplDX9_InitPlatformInterface();
|
||||||
|
static void ImGui_ImplDX9_ShutdownPlatformInterface();
|
||||||
|
static void ImGui_ImplDX9_CreateDeviceObjectsForPlatformWindows();
|
||||||
|
static void ImGui_ImplDX9_InvalidateDeviceObjectsForPlatformWindows();
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
static void ImGui_ImplDX9_SetupRenderState(ImDrawData* draw_data)
|
static void ImGui_ImplDX9_SetupRenderState(ImDrawData* draw_data)
|
||||||
{
|
{
|
||||||
@ -272,6 +280,11 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data)
|
|||||||
global_vtx_offset += cmd_list->VtxBuffer.Size;
|
global_vtx_offset += cmd_list->VtxBuffer.Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When using multi-viewports, it appears that there's an odd logic in DirectX9 which prevent subsequent windows
|
||||||
|
// from rendering until the first window submits at least one draw call, even once. That's our workaround. (see #2560)
|
||||||
|
if (global_vtx_offset == 0)
|
||||||
|
bd->pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 0, 0, 0);
|
||||||
|
|
||||||
// Restore the DX9 transform
|
// Restore the DX9 transform
|
||||||
bd->pd3dDevice->SetTransform(D3DTS_WORLD, &last_world);
|
bd->pd3dDevice->SetTransform(D3DTS_WORLD, &last_world);
|
||||||
bd->pd3dDevice->SetTransform(D3DTS_VIEW, &last_view);
|
bd->pd3dDevice->SetTransform(D3DTS_VIEW, &last_view);
|
||||||
@ -293,10 +306,14 @@ bool ImGui_ImplDX9_Init(IDirect3DDevice9* device)
|
|||||||
io.BackendRendererUserData = (void*)bd;
|
io.BackendRendererUserData = (void*)bd;
|
||||||
io.BackendRendererName = "imgui_impl_dx9";
|
io.BackendRendererName = "imgui_impl_dx9";
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasViewports; // We can create multi-viewports on the Renderer side (optional)
|
||||||
|
|
||||||
bd->pd3dDevice = device;
|
bd->pd3dDevice = device;
|
||||||
bd->pd3dDevice->AddRef();
|
bd->pd3dDevice->AddRef();
|
||||||
|
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
ImGui_ImplDX9_InitPlatformInterface();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,11 +323,12 @@ void ImGui_ImplDX9_Shutdown()
|
|||||||
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
ImGui_ImplDX9_ShutdownPlatformInterface();
|
||||||
ImGui_ImplDX9_InvalidateDeviceObjects();
|
ImGui_ImplDX9_InvalidateDeviceObjects();
|
||||||
if (bd->pd3dDevice) { bd->pd3dDevice->Release(); }
|
if (bd->pd3dDevice) { bd->pd3dDevice->Release(); }
|
||||||
io.BackendRendererName = nullptr;
|
io.BackendRendererName = nullptr;
|
||||||
io.BackendRendererUserData = nullptr;
|
io.BackendRendererUserData = nullptr;
|
||||||
io.BackendFlags &= ~ImGuiBackendFlags_RendererHasVtxOffset;
|
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasViewports);
|
||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -384,6 +402,7 @@ bool ImGui_ImplDX9_CreateDeviceObjects()
|
|||||||
return false;
|
return false;
|
||||||
if (!ImGui_ImplDX9_CreateFontsTexture())
|
if (!ImGui_ImplDX9_CreateFontsTexture())
|
||||||
return false;
|
return false;
|
||||||
|
ImGui_ImplDX9_CreateDeviceObjectsForPlatformWindows();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -395,6 +414,7 @@ void ImGui_ImplDX9_InvalidateDeviceObjects()
|
|||||||
if (bd->pVB) { bd->pVB->Release(); bd->pVB = nullptr; }
|
if (bd->pVB) { bd->pVB->Release(); bd->pVB = nullptr; }
|
||||||
if (bd->pIB) { bd->pIB->Release(); bd->pIB = nullptr; }
|
if (bd->pIB) { bd->pIB->Release(); bd->pIB = nullptr; }
|
||||||
if (bd->FontTexture) { bd->FontTexture->Release(); bd->FontTexture = nullptr; ImGui::GetIO().Fonts->SetTexID(0); } // We copied bd->pFontTextureView to io.Fonts->TexID so let's clear that as well.
|
if (bd->FontTexture) { bd->FontTexture->Release(); bd->FontTexture = nullptr; ImGui::GetIO().Fonts->SetTexID(0); } // We copied bd->pFontTextureView to io.Fonts->TexID so let's clear that as well.
|
||||||
|
ImGui_ImplDX9_InvalidateDeviceObjectsForPlatformWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplDX9_NewFrame()
|
void ImGui_ImplDX9_NewFrame()
|
||||||
@ -406,6 +426,148 @@ void ImGui_ImplDX9_NewFrame()
|
|||||||
ImGui_ImplDX9_CreateDeviceObjects();
|
ImGui_ImplDX9_CreateDeviceObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
|
||||||
|
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
|
||||||
|
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
|
||||||
|
struct ImGui_ImplDX9_ViewportData
|
||||||
|
{
|
||||||
|
IDirect3DSwapChain9* SwapChain;
|
||||||
|
D3DPRESENT_PARAMETERS d3dpp;
|
||||||
|
|
||||||
|
ImGui_ImplDX9_ViewportData() { SwapChain = nullptr; ZeroMemory(&d3dpp, sizeof(D3DPRESENT_PARAMETERS)); }
|
||||||
|
~ImGui_ImplDX9_ViewportData() { IM_ASSERT(SwapChain == nullptr); }
|
||||||
|
};
|
||||||
|
|
||||||
|
static void ImGui_ImplDX9_CreateWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData();
|
||||||
|
ImGui_ImplDX9_ViewportData* vd = IM_NEW(ImGui_ImplDX9_ViewportData)();
|
||||||
|
viewport->RendererUserData = vd;
|
||||||
|
|
||||||
|
// PlatformHandleRaw should always be a HWND, whereas PlatformHandle might be a higher-level handle (e.g. GLFWWindow*, SDL_Window*).
|
||||||
|
// Some backends will leave PlatformHandleRaw == 0, in which case we assume PlatformHandle will contain the HWND.
|
||||||
|
HWND hwnd = viewport->PlatformHandleRaw ? (HWND)viewport->PlatformHandleRaw : (HWND)viewport->PlatformHandle;
|
||||||
|
IM_ASSERT(hwnd != 0);
|
||||||
|
|
||||||
|
ZeroMemory(&vd->d3dpp, sizeof(D3DPRESENT_PARAMETERS));
|
||||||
|
vd->d3dpp.Windowed = TRUE;
|
||||||
|
vd->d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||||
|
vd->d3dpp.BackBufferWidth = (UINT)viewport->Size.x;
|
||||||
|
vd->d3dpp.BackBufferHeight = (UINT)viewport->Size.y;
|
||||||
|
vd->d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
|
||||||
|
vd->d3dpp.hDeviceWindow = hwnd;
|
||||||
|
vd->d3dpp.EnableAutoDepthStencil = FALSE;
|
||||||
|
vd->d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
|
||||||
|
vd->d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; // Present without vsync
|
||||||
|
|
||||||
|
HRESULT hr = bd->pd3dDevice->CreateAdditionalSwapChain(&vd->d3dpp, &vd->SwapChain); IM_UNUSED(hr);
|
||||||
|
IM_ASSERT(hr == D3D_OK);
|
||||||
|
IM_ASSERT(vd->SwapChain != nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX9_DestroyWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
// The main viewport (owned by the application) will always have RendererUserData == 0 since we didn't create the data for it.
|
||||||
|
if (ImGui_ImplDX9_ViewportData* vd = (ImGui_ImplDX9_ViewportData*)viewport->RendererUserData)
|
||||||
|
{
|
||||||
|
if (vd->SwapChain)
|
||||||
|
vd->SwapChain->Release();
|
||||||
|
vd->SwapChain = nullptr;
|
||||||
|
ZeroMemory(&vd->d3dpp, sizeof(D3DPRESENT_PARAMETERS));
|
||||||
|
IM_DELETE(vd);
|
||||||
|
}
|
||||||
|
viewport->RendererUserData = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX9_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData();
|
||||||
|
ImGui_ImplDX9_ViewportData* vd = (ImGui_ImplDX9_ViewportData*)viewport->RendererUserData;
|
||||||
|
if (vd->SwapChain)
|
||||||
|
{
|
||||||
|
vd->SwapChain->Release();
|
||||||
|
vd->SwapChain = nullptr;
|
||||||
|
vd->d3dpp.BackBufferWidth = (UINT)size.x;
|
||||||
|
vd->d3dpp.BackBufferHeight = (UINT)size.y;
|
||||||
|
HRESULT hr = bd->pd3dDevice->CreateAdditionalSwapChain(&vd->d3dpp, &vd->SwapChain); IM_UNUSED(hr);
|
||||||
|
IM_ASSERT(hr == D3D_OK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX9_RenderWindow(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData();
|
||||||
|
ImGui_ImplDX9_ViewportData* vd = (ImGui_ImplDX9_ViewportData*)viewport->RendererUserData;
|
||||||
|
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
|
LPDIRECT3DSURFACE9 render_target = nullptr;
|
||||||
|
LPDIRECT3DSURFACE9 last_render_target = nullptr;
|
||||||
|
LPDIRECT3DSURFACE9 last_depth_stencil = nullptr;
|
||||||
|
vd->SwapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &render_target);
|
||||||
|
bd->pd3dDevice->GetRenderTarget(0, &last_render_target);
|
||||||
|
bd->pd3dDevice->GetDepthStencilSurface(&last_depth_stencil);
|
||||||
|
bd->pd3dDevice->SetRenderTarget(0, render_target);
|
||||||
|
bd->pd3dDevice->SetDepthStencilSurface(nullptr);
|
||||||
|
|
||||||
|
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
|
||||||
|
{
|
||||||
|
D3DCOLOR clear_col_dx = D3DCOLOR_RGBA((int)(clear_color.x*255.0f), (int)(clear_color.y*255.0f), (int)(clear_color.z*255.0f), (int)(clear_color.w*255.0f));
|
||||||
|
bd->pd3dDevice->Clear(0, nullptr, D3DCLEAR_TARGET, clear_col_dx, 1.0f, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui_ImplDX9_RenderDrawData(viewport->DrawData);
|
||||||
|
|
||||||
|
// Restore render target
|
||||||
|
bd->pd3dDevice->SetRenderTarget(0, last_render_target);
|
||||||
|
bd->pd3dDevice->SetDepthStencilSurface(last_depth_stencil);
|
||||||
|
render_target->Release();
|
||||||
|
last_render_target->Release();
|
||||||
|
if (last_depth_stencil) last_depth_stencil->Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX9_SwapBuffers(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGui_ImplDX9_ViewportData* vd = (ImGui_ImplDX9_ViewportData*)viewport->RendererUserData;
|
||||||
|
HRESULT hr = vd->SwapChain->Present(nullptr, nullptr, vd->d3dpp.hDeviceWindow, nullptr, 0);
|
||||||
|
// Let main application handle D3DERR_DEVICELOST by resetting the device.
|
||||||
|
IM_ASSERT(SUCCEEDED(hr) || hr == D3DERR_DEVICELOST);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX9_InitPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
platform_io.Renderer_CreateWindow = ImGui_ImplDX9_CreateWindow;
|
||||||
|
platform_io.Renderer_DestroyWindow = ImGui_ImplDX9_DestroyWindow;
|
||||||
|
platform_io.Renderer_SetWindowSize = ImGui_ImplDX9_SetWindowSize;
|
||||||
|
platform_io.Renderer_RenderWindow = ImGui_ImplDX9_RenderWindow;
|
||||||
|
platform_io.Renderer_SwapBuffers = ImGui_ImplDX9_SwapBuffers;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX9_ShutdownPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGui::DestroyPlatformWindows();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX9_CreateDeviceObjectsForPlatformWindows()
|
||||||
|
{
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
for (int i = 1; i < platform_io.Viewports.Size; i++)
|
||||||
|
if (!platform_io.Viewports[i]->RendererUserData)
|
||||||
|
ImGui_ImplDX9_CreateWindow(platform_io.Viewports[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplDX9_InvalidateDeviceObjectsForPlatformWindows()
|
||||||
|
{
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
for (int i = 1; i < platform_io.Viewports.Size; i++)
|
||||||
|
if (platform_io.Viewports[i]->RendererUserData)
|
||||||
|
ImGui_ImplDX9_DestroyWindow(platform_io.Viewports[i]);
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#endif // #ifndef IMGUI_DISABLE
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
|
@ -9,6 +9,9 @@
|
|||||||
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLFW_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLFW_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange' (note: the resizing cursors requires GLFW 3.4+).
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange' (note: the resizing cursors requires GLFW 3.4+).
|
||||||
|
// [X] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
// Issues:
|
||||||
|
// [ ] Platform: Multi-viewport: ParentViewportID not honored, and so io.ConfigViewportsNoDefaultParent has no effect (minor).
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
@ -20,6 +23,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
// 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO:
|
// 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO:
|
||||||
// - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn
|
// - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn
|
||||||
// - io.SetClipboardTextFn -> platform_io.Platform_SetClipboardTextFn
|
// - io.SetClipboardTextFn -> platform_io.Platform_SetClipboardTextFn
|
||||||
@ -36,6 +40,7 @@
|
|||||||
// 2023-03-16: Inputs: Fixed key modifiers handling on secondary viewports (docking branch). Broken on 2023/01/04. (#6248, #6034)
|
// 2023-03-16: Inputs: Fixed key modifiers handling on secondary viewports (docking branch). Broken on 2023/01/04. (#6248, #6034)
|
||||||
// 2023-03-14: Emscripten: Avoid using glfwGetError() and glfwGetGamepadState() which are not correctly implemented in Emscripten emulation. (#6240)
|
// 2023-03-14: Emscripten: Avoid using glfwGetError() and glfwGetGamepadState() which are not correctly implemented in Emscripten emulation. (#6240)
|
||||||
// 2023-02-03: Emscripten: Registering custom low-level mouse wheel handler to get more accurate scrolling impulses on Emscripten. (#4019, #6096)
|
// 2023-02-03: Emscripten: Registering custom low-level mouse wheel handler to get more accurate scrolling impulses on Emscripten. (#4019, #6096)
|
||||||
|
// 2023-01-18: Handle unsupported glfwGetVideoMode() call on e.g. Emscripten.
|
||||||
// 2023-01-04: Inputs: Fixed mods state on Linux when using Alt-GR text input (e.g. German keyboard layout), could lead to broken text input. Revert a 2022/01/17 change were we resumed using mods provided by GLFW, turns out they were faulty.
|
// 2023-01-04: Inputs: Fixed mods state on Linux when using Alt-GR text input (e.g. German keyboard layout), could lead to broken text input. Revert a 2022/01/17 change were we resumed using mods provided by GLFW, turns out they were faulty.
|
||||||
// 2022-11-22: Perform a dummy glfwGetError() read to cancel missing names with glfwGetKeyName(). (#5908)
|
// 2022-11-22: Perform a dummy glfwGetError() read to cancel missing names with glfwGetKeyName(). (#5908)
|
||||||
// 2022-10-18: Perform a dummy glfwGetError() read to cancel missing mouse cursors errors. Using GLFW_VERSION_COMBINED directly. (#5785)
|
// 2022-10-18: Perform a dummy glfwGetError() read to cancel missing mouse cursors errors. Using GLFW_VERSION_COMBINED directly. (#5785)
|
||||||
@ -120,11 +125,29 @@
|
|||||||
|
|
||||||
// We gather version tests as define in order to easily see which features are version-dependent.
|
// We gather version tests as define in order to easily see which features are version-dependent.
|
||||||
#define GLFW_VERSION_COMBINED (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 + GLFW_VERSION_REVISION)
|
#define GLFW_VERSION_COMBINED (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 + GLFW_VERSION_REVISION)
|
||||||
|
#define GLFW_HAS_WINDOW_TOPMOST (GLFW_VERSION_COMBINED >= 3200) // 3.2+ GLFW_FLOATING
|
||||||
|
#define GLFW_HAS_WINDOW_HOVERED (GLFW_VERSION_COMBINED >= 3300) // 3.3+ GLFW_HOVERED
|
||||||
|
#define GLFW_HAS_WINDOW_ALPHA (GLFW_VERSION_COMBINED >= 3300) // 3.3+ glfwSetWindowOpacity
|
||||||
|
#define GLFW_HAS_PER_MONITOR_DPI (GLFW_VERSION_COMBINED >= 3300) // 3.3+ glfwGetMonitorContentScale
|
||||||
|
#if defined(__EMSCRIPTEN__) || defined(__SWITCH__) // no Vulkan support in GLFW for Emscripten or homebrew Nintendo Switch
|
||||||
|
#define GLFW_HAS_VULKAN (0)
|
||||||
|
#else
|
||||||
|
#define GLFW_HAS_VULKAN (GLFW_VERSION_COMBINED >= 3200) // 3.2+ glfwCreateWindowSurface
|
||||||
|
#endif
|
||||||
|
#define GLFW_HAS_FOCUS_WINDOW (GLFW_VERSION_COMBINED >= 3200) // 3.2+ glfwFocusWindow
|
||||||
|
#define GLFW_HAS_FOCUS_ON_SHOW (GLFW_VERSION_COMBINED >= 3300) // 3.3+ GLFW_FOCUS_ON_SHOW
|
||||||
|
#define GLFW_HAS_MONITOR_WORK_AREA (GLFW_VERSION_COMBINED >= 3300) // 3.3+ glfwGetMonitorWorkarea
|
||||||
|
#define GLFW_HAS_OSX_WINDOW_POS_FIX (GLFW_VERSION_COMBINED >= 3301) // 3.3.1+ Fixed: Resizing window repositions it on MacOS #1553
|
||||||
#ifdef GLFW_RESIZE_NESW_CURSOR // Let's be nice to people who pulled GLFW between 2019-04-16 (3.4 define) and 2019-11-29 (cursors defines) // FIXME: Remove when GLFW 3.4 is released?
|
#ifdef GLFW_RESIZE_NESW_CURSOR // Let's be nice to people who pulled GLFW between 2019-04-16 (3.4 define) and 2019-11-29 (cursors defines) // FIXME: Remove when GLFW 3.4 is released?
|
||||||
#define GLFW_HAS_NEW_CURSORS (GLFW_VERSION_COMBINED >= 3400) // 3.4+ GLFW_RESIZE_ALL_CURSOR, GLFW_RESIZE_NESW_CURSOR, GLFW_RESIZE_NWSE_CURSOR, GLFW_NOT_ALLOWED_CURSOR
|
#define GLFW_HAS_NEW_CURSORS (GLFW_VERSION_COMBINED >= 3400) // 3.4+ GLFW_RESIZE_ALL_CURSOR, GLFW_RESIZE_NESW_CURSOR, GLFW_RESIZE_NWSE_CURSOR, GLFW_NOT_ALLOWED_CURSOR
|
||||||
#else
|
#else
|
||||||
#define GLFW_HAS_NEW_CURSORS (0)
|
#define GLFW_HAS_NEW_CURSORS (0)
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef GLFW_MOUSE_PASSTHROUGH // Let's be nice to people who pulled GLFW between 2019-04-16 (3.4 define) and 2020-07-17 (passthrough)
|
||||||
|
#define GLFW_HAS_MOUSE_PASSTHROUGH (GLFW_VERSION_COMBINED >= 3400) // 3.4+ GLFW_MOUSE_PASSTHROUGH
|
||||||
|
#else
|
||||||
|
#define GLFW_HAS_MOUSE_PASSTHROUGH (0)
|
||||||
|
#endif
|
||||||
#define GLFW_HAS_GAMEPAD_API (GLFW_VERSION_COMBINED >= 3300) // 3.3+ glfwGetGamepadState() new api
|
#define GLFW_HAS_GAMEPAD_API (GLFW_VERSION_COMBINED >= 3300) // 3.3+ glfwGetGamepadState() new api
|
||||||
#define GLFW_HAS_GETKEYNAME (GLFW_VERSION_COMBINED >= 3200) // 3.2+ glfwGetKeyName()
|
#define GLFW_HAS_GETKEYNAME (GLFW_VERSION_COMBINED >= 3200) // 3.2+ glfwGetKeyName()
|
||||||
#define GLFW_HAS_GETERROR (GLFW_VERSION_COMBINED >= 3300) // 3.3+ glfwGetError()
|
#define GLFW_HAS_GETERROR (GLFW_VERSION_COMBINED >= 3300) // 3.3+ glfwGetError()
|
||||||
@ -145,8 +168,10 @@ struct ImGui_ImplGlfw_Data
|
|||||||
GLFWwindow* MouseWindow;
|
GLFWwindow* MouseWindow;
|
||||||
GLFWcursor* MouseCursors[ImGuiMouseCursor_COUNT];
|
GLFWcursor* MouseCursors[ImGuiMouseCursor_COUNT];
|
||||||
ImVec2 LastValidMousePos;
|
ImVec2 LastValidMousePos;
|
||||||
|
GLFWwindow* KeyOwnerWindows[GLFW_KEY_LAST];
|
||||||
bool InstalledCallbacks;
|
bool InstalledCallbacks;
|
||||||
bool CallbacksChainForAllWindows;
|
bool CallbacksChainForAllWindows;
|
||||||
|
bool WantUpdateMonitors;
|
||||||
#ifdef EMSCRIPTEN_USE_EMBEDDED_GLFW3
|
#ifdef EMSCRIPTEN_USE_EMBEDDED_GLFW3
|
||||||
const char* CanvasSelector;
|
const char* CanvasSelector;
|
||||||
#endif
|
#endif
|
||||||
@ -179,6 +204,11 @@ static ImGui_ImplGlfw_Data* ImGui_ImplGlfw_GetBackendData()
|
|||||||
return ImGui::GetCurrentContext() ? (ImGui_ImplGlfw_Data*)ImGui::GetIO().BackendPlatformUserData : nullptr;
|
return ImGui::GetCurrentContext() ? (ImGui_ImplGlfw_Data*)ImGui::GetIO().BackendPlatformUserData : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
static void ImGui_ImplGlfw_UpdateMonitors();
|
||||||
|
static void ImGui_ImplGlfw_InitPlatformInterface();
|
||||||
|
static void ImGui_ImplGlfw_ShutdownPlatformInterface();
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
static ImGuiKey ImGui_ImplGlfw_KeyToImGuiKey(int key)
|
static ImGuiKey ImGui_ImplGlfw_KeyToImGuiKey(int key)
|
||||||
{
|
{
|
||||||
@ -394,6 +424,9 @@ void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int keycode, int scancode, i
|
|||||||
|
|
||||||
ImGui_ImplGlfw_UpdateKeyModifiers(window);
|
ImGui_ImplGlfw_UpdateKeyModifiers(window);
|
||||||
|
|
||||||
|
if (keycode >= 0 && keycode < IM_ARRAYSIZE(bd->KeyOwnerWindows))
|
||||||
|
bd->KeyOwnerWindows[keycode] = (action == GLFW_PRESS) ? window : nullptr;
|
||||||
|
|
||||||
keycode = ImGui_ImplGlfw_TranslateUntranslatedKey(keycode, scancode);
|
keycode = ImGui_ImplGlfw_TranslateUntranslatedKey(keycode, scancode);
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
@ -419,6 +452,13 @@ void ImGui_ImplGlfw_CursorPosCallback(GLFWwindow* window, double x, double y)
|
|||||||
bd->PrevUserCallbackCursorPos(window, x, y);
|
bd->PrevUserCallbackCursorPos(window, x, y);
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
int window_x, window_y;
|
||||||
|
glfwGetWindowPos(window, &window_x, &window_y);
|
||||||
|
x += window_x;
|
||||||
|
y += window_y;
|
||||||
|
}
|
||||||
io.AddMousePosEvent((float)x, (float)y);
|
io.AddMousePosEvent((float)x, (float)y);
|
||||||
bd->LastValidMousePos = ImVec2((float)x, (float)y);
|
bd->LastValidMousePos = ImVec2((float)x, (float)y);
|
||||||
}
|
}
|
||||||
@ -457,7 +497,8 @@ void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c)
|
|||||||
|
|
||||||
void ImGui_ImplGlfw_MonitorCallback(GLFWmonitor*, int)
|
void ImGui_ImplGlfw_MonitorCallback(GLFWmonitor*, int)
|
||||||
{
|
{
|
||||||
// Unused in 'master' branch but 'docking' branch will use this, so we declare it ahead of it so if you have to install callbacks you can install this one too.
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
|
bd->WantUpdateMonitors = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef EMSCRIPTEN_USE_EMBEDDED_GLFW3
|
#ifdef EMSCRIPTEN_USE_EMBEDDED_GLFW3
|
||||||
@ -479,32 +520,7 @@ static EM_BOOL ImGui_ImplEmscripten_WheelCallback(int, const EmscriptenWheelEven
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// GLFW doesn't allow to distinguish Mouse vs TouchScreen vs Pen.
|
static LRESULT CALLBACK ImGui_ImplGlfw_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
// Add support for Win32 (based on imgui_impl_win32), because we rely on _TouchScreen info to trickle inputs differently.
|
|
||||||
static ImGuiMouseSource GetMouseSourceFromMessageExtraInfo()
|
|
||||||
{
|
|
||||||
LPARAM extra_info = ::GetMessageExtraInfo();
|
|
||||||
if ((extra_info & 0xFFFFFF80) == 0xFF515700)
|
|
||||||
return ImGuiMouseSource_Pen;
|
|
||||||
if ((extra_info & 0xFFFFFF80) == 0xFF515780)
|
|
||||||
return ImGuiMouseSource_TouchScreen;
|
|
||||||
return ImGuiMouseSource_Mouse;
|
|
||||||
}
|
|
||||||
static LRESULT CALLBACK ImGui_ImplGlfw_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
|
||||||
switch (msg)
|
|
||||||
{
|
|
||||||
case WM_MOUSEMOVE: case WM_NCMOUSEMOVE:
|
|
||||||
case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK: case WM_LBUTTONUP:
|
|
||||||
case WM_RBUTTONDOWN: case WM_RBUTTONDBLCLK: case WM_RBUTTONUP:
|
|
||||||
case WM_MBUTTONDOWN: case WM_MBUTTONDBLCLK: case WM_MBUTTONUP:
|
|
||||||
case WM_XBUTTONDOWN: case WM_XBUTTONDBLCLK: case WM_XBUTTONUP:
|
|
||||||
ImGui::GetIO().AddMouseSourceEvent(GetMouseSourceFromMessageExtraInfo());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return ::CallWindowProcW(bd->PrevWndProc, hWnd, msg, wParam, lParam);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void ImGui_ImplGlfw_InstallCallbacks(GLFWwindow* window)
|
void ImGui_ImplGlfw_InstallCallbacks(GLFWwindow* window)
|
||||||
@ -580,9 +596,16 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
|
|||||||
io.BackendPlatformName = "imgui_impl_glfw";
|
io.BackendPlatformName = "imgui_impl_glfw";
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
||||||
|
#ifndef __EMSCRIPTEN__
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports; // We can create multi-viewports on the Platform side (optional)
|
||||||
|
#endif
|
||||||
|
#if GLFW_HAS_MOUSE_PASSTHROUGH || GLFW_HAS_WINDOW_HOVERED
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_HasMouseHoveredViewport; // We can call io.AddMouseViewportEvent() with correct data (optional)
|
||||||
|
#endif
|
||||||
|
|
||||||
bd->Window = window;
|
bd->Window = window;
|
||||||
bd->Time = 0.0;
|
bd->Time = 0.0;
|
||||||
|
bd->WantUpdateMonitors = true;
|
||||||
|
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
platform_io.Platform_SetClipboardTextFn = [](ImGuiContext*, const char* text) { glfwSetClipboardString(NULL, text); };
|
platform_io.Platform_SetClipboardTextFn = [](ImGuiContext*, const char* text) { glfwSetClipboardString(NULL, text); };
|
||||||
@ -621,6 +644,10 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
|
|||||||
if (install_callbacks)
|
if (install_callbacks)
|
||||||
ImGui_ImplGlfw_InstallCallbacks(window);
|
ImGui_ImplGlfw_InstallCallbacks(window);
|
||||||
|
|
||||||
|
// Update monitors the first time (note: monitor callback are broken in GLFW 3.2 and earlier, see github.com/glfw/glfw/issues/784)
|
||||||
|
ImGui_ImplGlfw_UpdateMonitors();
|
||||||
|
glfwSetMonitorCallback(ImGui_ImplGlfw_MonitorCallback);
|
||||||
|
|
||||||
// Set platform dependent data in viewport
|
// Set platform dependent data in viewport
|
||||||
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
main_viewport->PlatformHandle = (void*)bd->Window;
|
main_viewport->PlatformHandle = (void*)bd->Window;
|
||||||
@ -631,6 +658,8 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
|
|||||||
#else
|
#else
|
||||||
IM_UNUSED(main_viewport);
|
IM_UNUSED(main_viewport);
|
||||||
#endif
|
#endif
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
ImGui_ImplGlfw_InitPlatformInterface();
|
||||||
|
|
||||||
// Windows: register a WndProc hook so we can intercept some messages.
|
// Windows: register a WndProc hook so we can intercept some messages.
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -664,6 +693,8 @@ void ImGui_ImplGlfw_Shutdown()
|
|||||||
IM_ASSERT(bd != nullptr && "No platform backend to shutdown, or already shutdown?");
|
IM_ASSERT(bd != nullptr && "No platform backend to shutdown, or already shutdown?");
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
ImGui_ImplGlfw_ShutdownPlatformInterface();
|
||||||
|
|
||||||
if (bd->InstalledCallbacks)
|
if (bd->InstalledCallbacks)
|
||||||
ImGui_ImplGlfw_RestoreCallbacks(bd->Window);
|
ImGui_ImplGlfw_RestoreCallbacks(bd->Window);
|
||||||
#ifdef EMSCRIPTEN_USE_EMBEDDED_GLFW3
|
#ifdef EMSCRIPTEN_USE_EMBEDDED_GLFW3
|
||||||
@ -683,7 +714,7 @@ void ImGui_ImplGlfw_Shutdown()
|
|||||||
|
|
||||||
io.BackendPlatformName = nullptr;
|
io.BackendPlatformName = nullptr;
|
||||||
io.BackendPlatformUserData = nullptr;
|
io.BackendPlatformUserData = nullptr;
|
||||||
io.BackendFlags &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasSetMousePos | ImGuiBackendFlags_HasGamepad);
|
io.BackendFlags &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasSetMousePos | ImGuiBackendFlags_HasGamepad | ImGuiBackendFlags_PlatformHasViewports | ImGuiBackendFlags_HasMouseHoveredViewport);
|
||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -691,10 +722,15 @@ static void ImGui_ImplGlfw_UpdateMouseData()
|
|||||||
{
|
{
|
||||||
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
|
||||||
// (those braces are here to reduce diff with multi-viewports support in 'docking' branch)
|
ImGuiID mouse_viewport_id = 0;
|
||||||
|
const ImVec2 mouse_pos_prev = io.MousePos;
|
||||||
|
for (int n = 0; n < platform_io.Viewports.Size; n++)
|
||||||
{
|
{
|
||||||
GLFWwindow* window = bd->Window;
|
ImGuiViewport* viewport = platform_io.Viewports[n];
|
||||||
|
GLFWwindow* window = (GLFWwindow*)viewport->PlatformHandle;
|
||||||
|
|
||||||
#ifdef EMSCRIPTEN_USE_EMBEDDED_GLFW3
|
#ifdef EMSCRIPTEN_USE_EMBEDDED_GLFW3
|
||||||
const bool is_window_focused = true;
|
const bool is_window_focused = true;
|
||||||
#else
|
#else
|
||||||
@ -703,19 +739,54 @@ static void ImGui_ImplGlfw_UpdateMouseData()
|
|||||||
if (is_window_focused)
|
if (is_window_focused)
|
||||||
{
|
{
|
||||||
// (Optional) Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
|
// (Optional) Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
|
||||||
|
// When multi-viewports are enabled, all Dear ImGui positions are same as OS positions.
|
||||||
if (io.WantSetMousePos)
|
if (io.WantSetMousePos)
|
||||||
glfwSetCursorPos(window, (double)io.MousePos.x, (double)io.MousePos.y);
|
glfwSetCursorPos(window, (double)(mouse_pos_prev.x - viewport->Pos.x), (double)(mouse_pos_prev.y - viewport->Pos.y));
|
||||||
|
|
||||||
// (Optional) Fallback to provide mouse position when focused (ImGui_ImplGlfw_CursorPosCallback already provides this when hovered or captured)
|
// (Optional) Fallback to provide mouse position when focused (ImGui_ImplGlfw_CursorPosCallback already provides this when hovered or captured)
|
||||||
if (bd->MouseWindow == nullptr)
|
if (bd->MouseWindow == nullptr)
|
||||||
{
|
{
|
||||||
double mouse_x, mouse_y;
|
double mouse_x, mouse_y;
|
||||||
glfwGetCursorPos(window, &mouse_x, &mouse_y);
|
glfwGetCursorPos(window, &mouse_x, &mouse_y);
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
// Single viewport mode: mouse position in client window coordinates (io.MousePos is (0,0) when the mouse is on the upper-left corner of the app window)
|
||||||
|
// Multi-viewport mode: mouse position in OS absolute coordinates (io.MousePos is (0,0) when the mouse is on the upper-left of the primary monitor)
|
||||||
|
int window_x, window_y;
|
||||||
|
glfwGetWindowPos(window, &window_x, &window_y);
|
||||||
|
mouse_x += window_x;
|
||||||
|
mouse_y += window_y;
|
||||||
|
}
|
||||||
bd->LastValidMousePos = ImVec2((float)mouse_x, (float)mouse_y);
|
bd->LastValidMousePos = ImVec2((float)mouse_x, (float)mouse_y);
|
||||||
io.AddMousePosEvent((float)mouse_x, (float)mouse_y);
|
io.AddMousePosEvent((float)mouse_x, (float)mouse_y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// (Optional) When using multiple viewports: call io.AddMouseViewportEvent() with the viewport the OS mouse cursor is hovering.
|
||||||
|
// If ImGuiBackendFlags_HasMouseHoveredViewport is not set by the backend, Dear imGui will ignore this field and infer the information using its flawed heuristic.
|
||||||
|
// - [X] GLFW >= 3.3 backend ON WINDOWS ONLY does correctly ignore viewports with the _NoInputs flag (since we implement hit via our WndProc hook)
|
||||||
|
// On other platforms we rely on the library fallbacking to its own search when reporting a viewport with _NoInputs flag.
|
||||||
|
// - [!] GLFW <= 3.2 backend CANNOT correctly ignore viewports with the _NoInputs flag, and CANNOT reported Hovered Viewport because of mouse capture.
|
||||||
|
// Some backend are not able to handle that correctly. If a backend report an hovered viewport that has the _NoInputs flag (e.g. when dragging a window
|
||||||
|
// for docking, the viewport has the _NoInputs flag in order to allow us to find the viewport under), then Dear ImGui is forced to ignore the value reported
|
||||||
|
// by the backend, and use its flawed heuristic to guess the viewport behind.
|
||||||
|
// - [X] GLFW backend correctly reports this regardless of another viewport behind focused and dragged from (we need this to find a useful drag and drop target).
|
||||||
|
// FIXME: This is currently only correct on Win32. See what we do below with the WM_NCHITTEST, missing an equivalent for other systems.
|
||||||
|
// See https://github.com/glfw/glfw/issues/1236 if you want to help in making this a GLFW feature.
|
||||||
|
#if GLFW_HAS_MOUSE_PASSTHROUGH
|
||||||
|
const bool window_no_input = (viewport->Flags & ImGuiViewportFlags_NoInputs) != 0;
|
||||||
|
glfwSetWindowAttrib(window, GLFW_MOUSE_PASSTHROUGH, window_no_input);
|
||||||
|
#endif
|
||||||
|
#if GLFW_HAS_MOUSE_PASSTHROUGH || GLFW_HAS_WINDOW_HOVERED
|
||||||
|
if (glfwGetWindowAttrib(window, GLFW_HOVERED))
|
||||||
|
mouse_viewport_id = viewport->ID;
|
||||||
|
#else
|
||||||
|
// We cannot use bd->MouseWindow maintained from CursorEnter/Leave callbacks, because it is locked to the window capturing mouse.
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (io.BackendFlags & ImGuiBackendFlags_HasMouseHoveredViewport)
|
||||||
|
io.AddMouseViewportEvent(mouse_viewport_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplGlfw_UpdateMouseCursor()
|
static void ImGui_ImplGlfw_UpdateMouseCursor()
|
||||||
@ -726,9 +797,10 @@ static void ImGui_ImplGlfw_UpdateMouseCursor()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor();
|
ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor();
|
||||||
// (those braces are here to reduce diff with multi-viewports support in 'docking' branch)
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
for (int n = 0; n < platform_io.Viewports.Size; n++)
|
||||||
{
|
{
|
||||||
GLFWwindow* window = bd->Window;
|
GLFWwindow* window = (GLFWwindow*)platform_io.Viewports[n]->PlatformHandle;
|
||||||
if (imgui_cursor == ImGuiMouseCursor_None || io.MouseDrawCursor)
|
if (imgui_cursor == ImGuiMouseCursor_None || io.MouseDrawCursor)
|
||||||
{
|
{
|
||||||
// Hide OS mouse cursor if imgui is drawing it or if it wants no cursor
|
// Hide OS mouse cursor if imgui is drawing it or if it wants no cursor
|
||||||
@ -797,6 +869,50 @@ static void ImGui_ImplGlfw_UpdateGamepads()
|
|||||||
#undef MAP_ANALOG
|
#undef MAP_ANALOG
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplGlfw_UpdateMonitors()
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
bd->WantUpdateMonitors = false;
|
||||||
|
|
||||||
|
int monitors_count = 0;
|
||||||
|
GLFWmonitor** glfw_monitors = glfwGetMonitors(&monitors_count);
|
||||||
|
if (monitors_count == 0) // Preserve existing monitor list if there are none. Happens on macOS sleeping (#5683)
|
||||||
|
return;
|
||||||
|
|
||||||
|
platform_io.Monitors.resize(0);
|
||||||
|
for (int n = 0; n < monitors_count; n++)
|
||||||
|
{
|
||||||
|
ImGuiPlatformMonitor monitor;
|
||||||
|
int x, y;
|
||||||
|
glfwGetMonitorPos(glfw_monitors[n], &x, &y);
|
||||||
|
const GLFWvidmode* vid_mode = glfwGetVideoMode(glfw_monitors[n]);
|
||||||
|
if (vid_mode == nullptr)
|
||||||
|
continue; // Failed to get Video mode (e.g. Emscripten does not support this function)
|
||||||
|
monitor.MainPos = monitor.WorkPos = ImVec2((float)x, (float)y);
|
||||||
|
monitor.MainSize = monitor.WorkSize = ImVec2((float)vid_mode->width, (float)vid_mode->height);
|
||||||
|
#if GLFW_HAS_MONITOR_WORK_AREA
|
||||||
|
int w, h;
|
||||||
|
glfwGetMonitorWorkarea(glfw_monitors[n], &x, &y, &w, &h);
|
||||||
|
if (w > 0 && h > 0) // Workaround a small GLFW issue reporting zero on monitor changes: https://github.com/glfw/glfw/pull/1761
|
||||||
|
{
|
||||||
|
monitor.WorkPos = ImVec2((float)x, (float)y);
|
||||||
|
monitor.WorkSize = ImVec2((float)w, (float)h);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if GLFW_HAS_PER_MONITOR_DPI
|
||||||
|
// Warning: the validity of monitor DPI information on Windows depends on the application DPI awareness settings, which generally needs to be set in the manifest or at runtime.
|
||||||
|
float x_scale, y_scale;
|
||||||
|
glfwGetMonitorContentScale(glfw_monitors[n], &x_scale, &y_scale);
|
||||||
|
if (x_scale == 0.0f)
|
||||||
|
continue; // Some accessibility applications are declaring virtual monitors with a DPI of 0, see #7902.
|
||||||
|
monitor.DpiScale = x_scale;
|
||||||
|
#endif
|
||||||
|
monitor.PlatformHandle = (void*)glfw_monitors[n]; // [...] GLFW doc states: "guaranteed to be valid only until the monitor configuration changes"
|
||||||
|
platform_io.Monitors.push_back(monitor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ImGui_ImplGlfw_NewFrame()
|
void ImGui_ImplGlfw_NewFrame()
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
@ -811,6 +927,8 @@ void ImGui_ImplGlfw_NewFrame()
|
|||||||
io.DisplaySize = ImVec2((float)w, (float)h);
|
io.DisplaySize = ImVec2((float)w, (float)h);
|
||||||
if (w > 0 && h > 0)
|
if (w > 0 && h > 0)
|
||||||
io.DisplayFramebufferScale = ImVec2((float)display_w / (float)w, (float)display_h / (float)h);
|
io.DisplayFramebufferScale = ImVec2((float)display_w / (float)w, (float)display_h / (float)h);
|
||||||
|
if (bd->WantUpdateMonitors)
|
||||||
|
ImGui_ImplGlfw_UpdateMonitors();
|
||||||
|
|
||||||
// Setup time step
|
// Setup time step
|
||||||
// (Accept glfwGetTime() not returning a monotonically increasing value. Seems to happens on disconnecting peripherals and probably on VMs and Emscripten, see #6491, #6189, #6114, #3644)
|
// (Accept glfwGetTime() not returning a monotonically increasing value. Seems to happens on disconnecting peripherals and probably on VMs and Emscripten, see #6491, #6189, #6114, #3644)
|
||||||
@ -889,6 +1007,399 @@ void ImGui_ImplGlfw_InstallEmscriptenCallbacks(GLFWwindow* window, const char* c
|
|||||||
}
|
}
|
||||||
#endif // #ifdef EMSCRIPTEN_USE_PORT_CONTRIB_GLFW3
|
#endif // #ifdef EMSCRIPTEN_USE_PORT_CONTRIB_GLFW3
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
|
||||||
|
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
|
||||||
|
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
|
||||||
|
struct ImGui_ImplGlfw_ViewportData
|
||||||
|
{
|
||||||
|
GLFWwindow* Window;
|
||||||
|
bool WindowOwned;
|
||||||
|
int IgnoreWindowPosEventFrame;
|
||||||
|
int IgnoreWindowSizeEventFrame;
|
||||||
|
#ifdef _WIN32
|
||||||
|
WNDPROC PrevWndProc;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ImGui_ImplGlfw_ViewportData() { memset(this, 0, sizeof(*this)); IgnoreWindowSizeEventFrame = IgnoreWindowPosEventFrame = -1; }
|
||||||
|
~ImGui_ImplGlfw_ViewportData() { IM_ASSERT(Window == nullptr); }
|
||||||
|
};
|
||||||
|
|
||||||
|
static void ImGui_ImplGlfw_WindowCloseCallback(GLFWwindow* window)
|
||||||
|
{
|
||||||
|
if (ImGuiViewport* viewport = ImGui::FindViewportByPlatformHandle(window))
|
||||||
|
viewport->PlatformRequestClose = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// GLFW may dispatch window pos/size events after calling glfwSetWindowPos()/glfwSetWindowSize().
|
||||||
|
// However: depending on the platform the callback may be invoked at different time:
|
||||||
|
// - on Windows it appears to be called within the glfwSetWindowPos()/glfwSetWindowSize() call
|
||||||
|
// - on Linux it is queued and invoked during glfwPollEvents()
|
||||||
|
// Because the event doesn't always fire on glfwSetWindowXXX() we use a frame counter tag to only
|
||||||
|
// ignore recent glfwSetWindowXXX() calls.
|
||||||
|
static void ImGui_ImplGlfw_WindowPosCallback(GLFWwindow* window, int, int)
|
||||||
|
{
|
||||||
|
if (ImGuiViewport* viewport = ImGui::FindViewportByPlatformHandle(window))
|
||||||
|
{
|
||||||
|
if (ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData)
|
||||||
|
{
|
||||||
|
bool ignore_event = (ImGui::GetFrameCount() <= vd->IgnoreWindowPosEventFrame + 1);
|
||||||
|
//data->IgnoreWindowPosEventFrame = -1;
|
||||||
|
if (ignore_event)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
viewport->PlatformRequestMove = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplGlfw_WindowSizeCallback(GLFWwindow* window, int, int)
|
||||||
|
{
|
||||||
|
if (ImGuiViewport* viewport = ImGui::FindViewportByPlatformHandle(window))
|
||||||
|
{
|
||||||
|
if (ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData)
|
||||||
|
{
|
||||||
|
bool ignore_event = (ImGui::GetFrameCount() <= vd->IgnoreWindowSizeEventFrame + 1);
|
||||||
|
//data->IgnoreWindowSizeEventFrame = -1;
|
||||||
|
if (ignore_event)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
viewport->PlatformRequestResize = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplGlfw_CreateWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
|
ImGui_ImplGlfw_ViewportData* vd = IM_NEW(ImGui_ImplGlfw_ViewportData)();
|
||||||
|
viewport->PlatformUserData = vd;
|
||||||
|
|
||||||
|
// GLFW 3.2 unfortunately always set focus on glfwCreateWindow() if GLFW_VISIBLE is set, regardless of GLFW_FOCUSED
|
||||||
|
// With GLFW 3.3, the hint GLFW_FOCUS_ON_SHOW fixes this problem
|
||||||
|
glfwWindowHint(GLFW_VISIBLE, false);
|
||||||
|
glfwWindowHint(GLFW_FOCUSED, false);
|
||||||
|
#if GLFW_HAS_FOCUS_ON_SHOW
|
||||||
|
glfwWindowHint(GLFW_FOCUS_ON_SHOW, false);
|
||||||
|
#endif
|
||||||
|
glfwWindowHint(GLFW_DECORATED, (viewport->Flags & ImGuiViewportFlags_NoDecoration) ? false : true);
|
||||||
|
#if GLFW_HAS_WINDOW_TOPMOST
|
||||||
|
glfwWindowHint(GLFW_FLOATING, (viewport->Flags & ImGuiViewportFlags_TopMost) ? true : false);
|
||||||
|
#endif
|
||||||
|
GLFWwindow* share_window = (bd->ClientApi == GlfwClientApi_OpenGL) ? bd->Window : nullptr;
|
||||||
|
vd->Window = glfwCreateWindow((int)viewport->Size.x, (int)viewport->Size.y, "No Title Yet", nullptr, share_window);
|
||||||
|
vd->WindowOwned = true;
|
||||||
|
viewport->PlatformHandle = (void*)vd->Window;
|
||||||
|
#ifdef _WIN32
|
||||||
|
viewport->PlatformHandleRaw = glfwGetWin32Window(vd->Window);
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
viewport->PlatformHandleRaw = (void*)glfwGetCocoaWindow(vd->Window);
|
||||||
|
#endif
|
||||||
|
glfwSetWindowPos(vd->Window, (int)viewport->Pos.x, (int)viewport->Pos.y);
|
||||||
|
|
||||||
|
// Install GLFW callbacks for secondary viewports
|
||||||
|
glfwSetWindowFocusCallback(vd->Window, ImGui_ImplGlfw_WindowFocusCallback);
|
||||||
|
glfwSetCursorEnterCallback(vd->Window, ImGui_ImplGlfw_CursorEnterCallback);
|
||||||
|
glfwSetCursorPosCallback(vd->Window, ImGui_ImplGlfw_CursorPosCallback);
|
||||||
|
glfwSetMouseButtonCallback(vd->Window, ImGui_ImplGlfw_MouseButtonCallback);
|
||||||
|
glfwSetScrollCallback(vd->Window, ImGui_ImplGlfw_ScrollCallback);
|
||||||
|
glfwSetKeyCallback(vd->Window, ImGui_ImplGlfw_KeyCallback);
|
||||||
|
glfwSetCharCallback(vd->Window, ImGui_ImplGlfw_CharCallback);
|
||||||
|
glfwSetWindowCloseCallback(vd->Window, ImGui_ImplGlfw_WindowCloseCallback);
|
||||||
|
glfwSetWindowPosCallback(vd->Window, ImGui_ImplGlfw_WindowPosCallback);
|
||||||
|
glfwSetWindowSizeCallback(vd->Window, ImGui_ImplGlfw_WindowSizeCallback);
|
||||||
|
if (bd->ClientApi == GlfwClientApi_OpenGL)
|
||||||
|
{
|
||||||
|
glfwMakeContextCurrent(vd->Window);
|
||||||
|
glfwSwapInterval(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplGlfw_DestroyWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
|
if (ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData)
|
||||||
|
{
|
||||||
|
if (vd->WindowOwned)
|
||||||
|
{
|
||||||
|
#if !GLFW_HAS_MOUSE_PASSTHROUGH && GLFW_HAS_WINDOW_HOVERED && defined(_WIN32)
|
||||||
|
HWND hwnd = (HWND)viewport->PlatformHandleRaw;
|
||||||
|
::RemovePropA(hwnd, "IMGUI_VIEWPORT");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Release any keys that were pressed in the window being destroyed and are still held down,
|
||||||
|
// because we will not receive any release events after window is destroyed.
|
||||||
|
for (int i = 0; i < IM_ARRAYSIZE(bd->KeyOwnerWindows); i++)
|
||||||
|
if (bd->KeyOwnerWindows[i] == vd->Window)
|
||||||
|
ImGui_ImplGlfw_KeyCallback(vd->Window, i, 0, GLFW_RELEASE, 0); // Later params are only used for main viewport, on which this function is never called.
|
||||||
|
|
||||||
|
glfwDestroyWindow(vd->Window);
|
||||||
|
}
|
||||||
|
vd->Window = nullptr;
|
||||||
|
IM_DELETE(vd);
|
||||||
|
}
|
||||||
|
viewport->PlatformUserData = viewport->PlatformHandle = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplGlfw_ShowWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
// GLFW hack: Hide icon from task bar
|
||||||
|
HWND hwnd = (HWND)viewport->PlatformHandleRaw;
|
||||||
|
if (viewport->Flags & ImGuiViewportFlags_NoTaskBarIcon)
|
||||||
|
{
|
||||||
|
LONG ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE);
|
||||||
|
ex_style &= ~WS_EX_APPWINDOW;
|
||||||
|
ex_style |= WS_EX_TOOLWINDOW;
|
||||||
|
::SetWindowLong(hwnd, GWL_EXSTYLE, ex_style);
|
||||||
|
}
|
||||||
|
|
||||||
|
// GLFW hack: install hook for WM_NCHITTEST message handler
|
||||||
|
#if !GLFW_HAS_MOUSE_PASSTHROUGH && GLFW_HAS_WINDOW_HOVERED && defined(_WIN32)
|
||||||
|
::SetPropA(hwnd, "IMGUI_VIEWPORT", viewport);
|
||||||
|
vd->PrevWndProc = (WNDPROC)::GetWindowLongPtrW(hwnd, GWLP_WNDPROC);
|
||||||
|
::SetWindowLongPtrW(hwnd, GWLP_WNDPROC, (LONG_PTR)ImGui_ImplGlfw_WndProc);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !GLFW_HAS_FOCUS_ON_SHOW
|
||||||
|
// GLFW hack: GLFW 3.2 has a bug where glfwShowWindow() also activates/focus the window.
|
||||||
|
// The fix was pushed to GLFW repository on 2018/01/09 and should be included in GLFW 3.3 via a GLFW_FOCUS_ON_SHOW window attribute.
|
||||||
|
// See https://github.com/glfw/glfw/issues/1189
|
||||||
|
// FIXME-VIEWPORT: Implement same work-around for Linux/OSX in the meanwhile.
|
||||||
|
if (viewport->Flags & ImGuiViewportFlags_NoFocusOnAppearing)
|
||||||
|
{
|
||||||
|
::ShowWindow(hwnd, SW_SHOWNA);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
glfwShowWindow(vd->Window);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ImVec2 ImGui_ImplGlfw_GetWindowPos(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
|
||||||
|
int x = 0, y = 0;
|
||||||
|
glfwGetWindowPos(vd->Window, &x, &y);
|
||||||
|
return ImVec2((float)x, (float)y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplGlfw_SetWindowPos(ImGuiViewport* viewport, ImVec2 pos)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
|
||||||
|
vd->IgnoreWindowPosEventFrame = ImGui::GetFrameCount();
|
||||||
|
glfwSetWindowPos(vd->Window, (int)pos.x, (int)pos.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ImVec2 ImGui_ImplGlfw_GetWindowSize(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
|
||||||
|
int w = 0, h = 0;
|
||||||
|
glfwGetWindowSize(vd->Window, &w, &h);
|
||||||
|
return ImVec2((float)w, (float)h);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplGlfw_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
|
||||||
|
#if __APPLE__ && !GLFW_HAS_OSX_WINDOW_POS_FIX
|
||||||
|
// Native OS windows are positioned from the bottom-left corner on macOS, whereas on other platforms they are
|
||||||
|
// positioned from the upper-left corner. GLFW makes an effort to convert macOS style coordinates, however it
|
||||||
|
// doesn't handle it when changing size. We are manually moving the window in order for changes of size to be based
|
||||||
|
// on the upper-left corner.
|
||||||
|
int x, y, width, height;
|
||||||
|
glfwGetWindowPos(vd->Window, &x, &y);
|
||||||
|
glfwGetWindowSize(vd->Window, &width, &height);
|
||||||
|
glfwSetWindowPos(vd->Window, x, y - height + size.y);
|
||||||
|
#endif
|
||||||
|
vd->IgnoreWindowSizeEventFrame = ImGui::GetFrameCount();
|
||||||
|
glfwSetWindowSize(vd->Window, (int)size.x, (int)size.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplGlfw_SetWindowTitle(ImGuiViewport* viewport, const char* title)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
|
||||||
|
glfwSetWindowTitle(vd->Window, title);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplGlfw_SetWindowFocus(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
#if GLFW_HAS_FOCUS_WINDOW
|
||||||
|
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
|
||||||
|
glfwFocusWindow(vd->Window);
|
||||||
|
#else
|
||||||
|
// FIXME: What are the effect of not having this function? At the moment imgui doesn't actually call SetWindowFocus - we set that up ahead, will answer that question later.
|
||||||
|
(void)viewport;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ImGui_ImplGlfw_GetWindowFocus(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
|
||||||
|
return glfwGetWindowAttrib(vd->Window, GLFW_FOCUSED) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ImGui_ImplGlfw_GetWindowMinimized(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
|
||||||
|
return glfwGetWindowAttrib(vd->Window, GLFW_ICONIFIED) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if GLFW_HAS_WINDOW_ALPHA
|
||||||
|
static void ImGui_ImplGlfw_SetWindowAlpha(ImGuiViewport* viewport, float alpha)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
|
||||||
|
glfwSetWindowOpacity(vd->Window, alpha);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void ImGui_ImplGlfw_RenderWindow(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
|
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
|
||||||
|
if (bd->ClientApi == GlfwClientApi_OpenGL)
|
||||||
|
glfwMakeContextCurrent(vd->Window);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplGlfw_SwapBuffers(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
|
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
|
||||||
|
if (bd->ClientApi == GlfwClientApi_OpenGL)
|
||||||
|
{
|
||||||
|
glfwMakeContextCurrent(vd->Window);
|
||||||
|
glfwSwapBuffers(vd->Window);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
// Vulkan support (the Vulkan renderer needs to call a platform-side support function to create the surface)
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Avoid including <vulkan.h> so we can build without it
|
||||||
|
#if GLFW_HAS_VULKAN
|
||||||
|
#ifndef VULKAN_H_
|
||||||
|
#define VK_DEFINE_HANDLE(object) typedef struct object##_T* object;
|
||||||
|
#if defined(__LP64__) || defined(_WIN64) || defined(__x86_64__) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
|
||||||
|
#define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef struct object##_T *object;
|
||||||
|
#else
|
||||||
|
#define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef uint64_t object;
|
||||||
|
#endif
|
||||||
|
VK_DEFINE_HANDLE(VkInstance)
|
||||||
|
VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSurfaceKHR)
|
||||||
|
struct VkAllocationCallbacks;
|
||||||
|
enum VkResult { VK_RESULT_MAX_ENUM = 0x7FFFFFFF };
|
||||||
|
#endif // VULKAN_H_
|
||||||
|
extern "C" { extern GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface); }
|
||||||
|
static int ImGui_ImplGlfw_CreateVkSurface(ImGuiViewport* viewport, ImU64 vk_instance, const void* vk_allocator, ImU64* out_vk_surface)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
|
ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData;
|
||||||
|
IM_UNUSED(bd);
|
||||||
|
IM_ASSERT(bd->ClientApi == GlfwClientApi_Vulkan);
|
||||||
|
VkResult err = glfwCreateWindowSurface((VkInstance)vk_instance, vd->Window, (const VkAllocationCallbacks*)vk_allocator, (VkSurfaceKHR*)out_vk_surface);
|
||||||
|
return (int)err;
|
||||||
|
}
|
||||||
|
#endif // GLFW_HAS_VULKAN
|
||||||
|
|
||||||
|
static void ImGui_ImplGlfw_InitPlatformInterface()
|
||||||
|
{
|
||||||
|
// Register platform interface (will be coupled with a renderer interface)
|
||||||
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
platform_io.Platform_CreateWindow = ImGui_ImplGlfw_CreateWindow;
|
||||||
|
platform_io.Platform_DestroyWindow = ImGui_ImplGlfw_DestroyWindow;
|
||||||
|
platform_io.Platform_ShowWindow = ImGui_ImplGlfw_ShowWindow;
|
||||||
|
platform_io.Platform_SetWindowPos = ImGui_ImplGlfw_SetWindowPos;
|
||||||
|
platform_io.Platform_GetWindowPos = ImGui_ImplGlfw_GetWindowPos;
|
||||||
|
platform_io.Platform_SetWindowSize = ImGui_ImplGlfw_SetWindowSize;
|
||||||
|
platform_io.Platform_GetWindowSize = ImGui_ImplGlfw_GetWindowSize;
|
||||||
|
platform_io.Platform_SetWindowFocus = ImGui_ImplGlfw_SetWindowFocus;
|
||||||
|
platform_io.Platform_GetWindowFocus = ImGui_ImplGlfw_GetWindowFocus;
|
||||||
|
platform_io.Platform_GetWindowMinimized = ImGui_ImplGlfw_GetWindowMinimized;
|
||||||
|
platform_io.Platform_SetWindowTitle = ImGui_ImplGlfw_SetWindowTitle;
|
||||||
|
platform_io.Platform_RenderWindow = ImGui_ImplGlfw_RenderWindow;
|
||||||
|
platform_io.Platform_SwapBuffers = ImGui_ImplGlfw_SwapBuffers;
|
||||||
|
#if GLFW_HAS_WINDOW_ALPHA
|
||||||
|
platform_io.Platform_SetWindowAlpha = ImGui_ImplGlfw_SetWindowAlpha;
|
||||||
|
#endif
|
||||||
|
#if GLFW_HAS_VULKAN
|
||||||
|
platform_io.Platform_CreateVkSurface = ImGui_ImplGlfw_CreateVkSurface;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Register main window handle (which is owned by the main application, not by us)
|
||||||
|
// This is mostly for simplicity and consistency, so that our code (e.g. mouse handling etc.) can use same logic for main and secondary viewports.
|
||||||
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
|
ImGui_ImplGlfw_ViewportData* vd = IM_NEW(ImGui_ImplGlfw_ViewportData)();
|
||||||
|
vd->Window = bd->Window;
|
||||||
|
vd->WindowOwned = false;
|
||||||
|
main_viewport->PlatformUserData = vd;
|
||||||
|
main_viewport->PlatformHandle = (void*)bd->Window;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplGlfw_ShutdownPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGui::DestroyPlatformWindows();
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// WndProc hook (declared here because we will need access to ImGui_ImplGlfw_ViewportData)
|
||||||
|
#ifdef _WIN32
|
||||||
|
static ImGuiMouseSource GetMouseSourceFromMessageExtraInfo()
|
||||||
|
{
|
||||||
|
LPARAM extra_info = ::GetMessageExtraInfo();
|
||||||
|
if ((extra_info & 0xFFFFFF80) == 0xFF515700)
|
||||||
|
return ImGuiMouseSource_Pen;
|
||||||
|
if ((extra_info & 0xFFFFFF80) == 0xFF515780)
|
||||||
|
return ImGuiMouseSource_TouchScreen;
|
||||||
|
return ImGuiMouseSource_Mouse;
|
||||||
|
}
|
||||||
|
static LRESULT CALLBACK ImGui_ImplGlfw_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
|
WNDPROC prev_wndproc = bd->PrevWndProc;
|
||||||
|
ImGuiViewport* viewport = (ImGuiViewport*)::GetPropA(hWnd, "IMGUI_VIEWPORT");
|
||||||
|
if (viewport != NULL)
|
||||||
|
if (ImGui_ImplGlfw_ViewportData* vd = (ImGui_ImplGlfw_ViewportData*)viewport->PlatformUserData)
|
||||||
|
prev_wndproc = vd->PrevWndProc;
|
||||||
|
|
||||||
|
switch (msg)
|
||||||
|
{
|
||||||
|
// GLFW doesn't allow to distinguish Mouse vs TouchScreen vs Pen.
|
||||||
|
// Add support for Win32 (based on imgui_impl_win32), because we rely on _TouchScreen info to trickle inputs differently.
|
||||||
|
case WM_MOUSEMOVE: case WM_NCMOUSEMOVE:
|
||||||
|
case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK: case WM_LBUTTONUP:
|
||||||
|
case WM_RBUTTONDOWN: case WM_RBUTTONDBLCLK: case WM_RBUTTONUP:
|
||||||
|
case WM_MBUTTONDOWN: case WM_MBUTTONDBLCLK: case WM_MBUTTONUP:
|
||||||
|
case WM_XBUTTONDOWN: case WM_XBUTTONDBLCLK: case WM_XBUTTONUP:
|
||||||
|
ImGui::GetIO().AddMouseSourceEvent(GetMouseSourceFromMessageExtraInfo());
|
||||||
|
break;
|
||||||
|
|
||||||
|
// We have submitted https://github.com/glfw/glfw/pull/1568 to allow GLFW to support "transparent inputs".
|
||||||
|
// In the meanwhile we implement custom per-platform workarounds here (FIXME-VIEWPORT: Implement same work-around for Linux/OSX!)
|
||||||
|
#if !GLFW_HAS_MOUSE_PASSTHROUGH && GLFW_HAS_WINDOW_HOVERED
|
||||||
|
case WM_NCHITTEST:
|
||||||
|
{
|
||||||
|
// Let mouse pass-through the window. This will allow the backend to call io.AddMouseViewportEvent() properly (which is OPTIONAL).
|
||||||
|
// The ImGuiViewportFlags_NoInputs flag is set while dragging a viewport, as want to detect the window behind the one we are dragging.
|
||||||
|
// If you cannot easily access those viewport flags from your windowing/event code: you may manually synchronize its state e.g. in
|
||||||
|
// your main loop after calling UpdatePlatformWindows(). Iterate all viewports/platform windows and pass the flag to your windowing system.
|
||||||
|
if (viewport && (viewport->Flags & ImGuiViewportFlags_NoInputs))
|
||||||
|
return HTTRANSPARENT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
return ::CallWindowProcW(prev_wndproc, hWnd, msg, wParam, lParam);
|
||||||
|
}
|
||||||
|
#endif // #ifdef _WIN32
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// dear imgui: Platform Backend for GLFW
|
// dear imgui: Platform Backend for GLFW
|
||||||
// This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan, WebGPU..)
|
// This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan, WebGPU..)
|
||||||
// (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
|
// (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
|
||||||
|
// (Requires: GLFW 3.1+. Prefer GLFW 3.3+ for full feature support.)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Platform: Clipboard support.
|
// [X] Platform: Clipboard support.
|
||||||
@ -8,6 +9,9 @@
|
|||||||
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLFW_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLFW_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange' (note: the resizing cursors requires GLFW 3.4+).
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange' (note: the resizing cursors requires GLFW 3.4+).
|
||||||
|
// [X] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
// Issues:
|
||||||
|
// [ ] Platform: Multi-viewport: ParentViewportID not honored, and so io.ConfigViewportsNoDefaultParent has no effect (minor).
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Platform: Partial keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLUT values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
// [X] Platform: Partial keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLUT values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// Issues:
|
// Missing features:
|
||||||
// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
|
// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
|
||||||
// [ ] Platform: Missing horizontal mouse wheel support.
|
// [ ] Platform: Missing horizontal mouse wheel support.
|
||||||
// [ ] Platform: Missing mouse cursor shape/visibility support.
|
// [ ] Platform: Missing mouse cursor shape/visibility support.
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Platform: Partial keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLUT values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
// [X] Platform: Partial keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLUT values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// Issues:
|
// Missing features:
|
||||||
// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
|
// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
|
||||||
// [ ] Platform: Missing horizontal mouse wheel support.
|
// [ ] Platform: Missing horizontal mouse wheel support.
|
||||||
// [ ] Platform: Missing mouse cursor shape/visibility support.
|
// [ ] Platform: Missing mouse cursor shape/visibility support.
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'MTLTexture' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'MTLTexture' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'MTLTexture' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'MTLTexture' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
@ -15,6 +16,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2024-XX-XX: Metal: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
// 2022-08-23: Metal: Update deprecated property 'sampleCount'->'rasterSampleCount'.
|
// 2022-08-23: Metal: Update deprecated property 'sampleCount'->'rasterSampleCount'.
|
||||||
// 2022-07-05: Metal: Add dispatch synchronization.
|
// 2022-07-05: Metal: Add dispatch synchronization.
|
||||||
// 2022-06-30: Metal: Use __bridge for ARC based systems.
|
// 2022-06-30: Metal: Use __bridge for ARC based systems.
|
||||||
@ -38,6 +40,12 @@
|
|||||||
#import <time.h>
|
#import <time.h>
|
||||||
#import <Metal/Metal.h>
|
#import <Metal/Metal.h>
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
static void ImGui_ImplMetal_InitPlatformInterface();
|
||||||
|
static void ImGui_ImplMetal_ShutdownPlatformInterface();
|
||||||
|
static void ImGui_ImplMetal_CreateDeviceObjectsForPlatformWindows();
|
||||||
|
static void ImGui_ImplMetal_InvalidateDeviceObjectsForPlatformWindows();
|
||||||
|
|
||||||
#pragma mark - Support classes
|
#pragma mark - Support classes
|
||||||
|
|
||||||
// A wrapper around a MTLBuffer object that knows the last time it was reused
|
// A wrapper around a MTLBuffer object that knows the last time it was reused
|
||||||
@ -132,10 +140,14 @@ bool ImGui_ImplMetal_Init(id<MTLDevice> device)
|
|||||||
io.BackendRendererUserData = (void*)bd;
|
io.BackendRendererUserData = (void*)bd;
|
||||||
io.BackendRendererName = "imgui_impl_metal";
|
io.BackendRendererName = "imgui_impl_metal";
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasViewports; // We can create multi-viewports on the Renderer side (optional)
|
||||||
|
|
||||||
bd->SharedMetalContext = [[MetalContext alloc] init];
|
bd->SharedMetalContext = [[MetalContext alloc] init];
|
||||||
bd->SharedMetalContext.device = device;
|
bd->SharedMetalContext.device = device;
|
||||||
|
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
ImGui_ImplMetal_InitPlatformInterface();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,13 +155,14 @@ void ImGui_ImplMetal_Shutdown()
|
|||||||
{
|
{
|
||||||
ImGui_ImplMetal_Data* bd = ImGui_ImplMetal_GetBackendData();
|
ImGui_ImplMetal_Data* bd = ImGui_ImplMetal_GetBackendData();
|
||||||
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
||||||
|
ImGui_ImplMetal_ShutdownPlatformInterface();
|
||||||
ImGui_ImplMetal_DestroyDeviceObjects();
|
ImGui_ImplMetal_DestroyDeviceObjects();
|
||||||
ImGui_ImplMetal_DestroyBackendData();
|
ImGui_ImplMetal_DestroyBackendData();
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.BackendRendererName = nullptr;
|
io.BackendRendererName = nullptr;
|
||||||
io.BackendRendererUserData = nullptr;
|
io.BackendRendererUserData = nullptr;
|
||||||
io.BackendFlags &= ~ImGuiBackendFlags_RendererHasVtxOffset;
|
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasViewports);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor* renderPassDescriptor)
|
void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor* renderPassDescriptor)
|
||||||
@ -367,6 +380,7 @@ bool ImGui_ImplMetal_CreateDeviceObjects(id<MTLDevice> device)
|
|||||||
depthStencilDescriptor.depthWriteEnabled = NO;
|
depthStencilDescriptor.depthWriteEnabled = NO;
|
||||||
depthStencilDescriptor.depthCompareFunction = MTLCompareFunctionAlways;
|
depthStencilDescriptor.depthCompareFunction = MTLCompareFunctionAlways;
|
||||||
bd->SharedMetalContext.depthStencilState = [device newDepthStencilStateWithDescriptor:depthStencilDescriptor];
|
bd->SharedMetalContext.depthStencilState = [device newDepthStencilStateWithDescriptor:depthStencilDescriptor];
|
||||||
|
ImGui_ImplMetal_CreateDeviceObjectsForPlatformWindows();
|
||||||
ImGui_ImplMetal_CreateFontsTexture(device);
|
ImGui_ImplMetal_CreateFontsTexture(device);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -376,9 +390,155 @@ void ImGui_ImplMetal_DestroyDeviceObjects()
|
|||||||
{
|
{
|
||||||
ImGui_ImplMetal_Data* bd = ImGui_ImplMetal_GetBackendData();
|
ImGui_ImplMetal_Data* bd = ImGui_ImplMetal_GetBackendData();
|
||||||
ImGui_ImplMetal_DestroyFontsTexture();
|
ImGui_ImplMetal_DestroyFontsTexture();
|
||||||
|
ImGui_ImplMetal_InvalidateDeviceObjectsForPlatformWindows();
|
||||||
[bd->SharedMetalContext.renderPipelineStateCache removeAllObjects];
|
[bd->SharedMetalContext.renderPipelineStateCache removeAllObjects];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma mark - Multi-viewport support
|
||||||
|
|
||||||
|
#import <QuartzCore/CAMetalLayer.h>
|
||||||
|
|
||||||
|
#if TARGET_OS_OSX
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
|
||||||
|
// This is an _advanced_ and _optional_ feature, allowing the back-end to create and handle multiple viewports simultaneously.
|
||||||
|
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
struct ImGuiViewportDataMetal
|
||||||
|
{
|
||||||
|
CAMetalLayer* MetalLayer;
|
||||||
|
id<MTLCommandQueue> CommandQueue;
|
||||||
|
MTLRenderPassDescriptor* RenderPassDescriptor;
|
||||||
|
void* Handle = nullptr;
|
||||||
|
bool FirstFrame = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void ImGui_ImplMetal_CreateWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplMetal_Data* bd = ImGui_ImplMetal_GetBackendData();
|
||||||
|
ImGuiViewportDataMetal* data = IM_NEW(ImGuiViewportDataMetal)();
|
||||||
|
viewport->RendererUserData = data;
|
||||||
|
|
||||||
|
// PlatformHandleRaw should always be a NSWindow*, whereas PlatformHandle might be a higher-level handle (e.g. GLFWWindow*, SDL_Window*).
|
||||||
|
// Some back-ends will leave PlatformHandleRaw == 0, in which case we assume PlatformHandle will contain the NSWindow*.
|
||||||
|
void* handle = viewport->PlatformHandleRaw ? viewport->PlatformHandleRaw : viewport->PlatformHandle;
|
||||||
|
IM_ASSERT(handle != nullptr);
|
||||||
|
|
||||||
|
id<MTLDevice> device = bd->SharedMetalContext.device;
|
||||||
|
CAMetalLayer* layer = [CAMetalLayer layer];
|
||||||
|
layer.device = device;
|
||||||
|
layer.framebufferOnly = YES;
|
||||||
|
layer.pixelFormat = bd->SharedMetalContext.framebufferDescriptor.colorPixelFormat;
|
||||||
|
#if TARGET_OS_OSX
|
||||||
|
NSWindow* window = (__bridge NSWindow*)handle;
|
||||||
|
NSView* view = window.contentView;
|
||||||
|
view.layer = layer;
|
||||||
|
view.wantsLayer = YES;
|
||||||
|
#endif
|
||||||
|
data->MetalLayer = layer;
|
||||||
|
data->CommandQueue = [device newCommandQueue];
|
||||||
|
data->RenderPassDescriptor = [[MTLRenderPassDescriptor alloc] init];
|
||||||
|
data->Handle = handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplMetal_DestroyWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
// The main viewport (owned by the application) will always have RendererUserData == 0 since we didn't create the data for it.
|
||||||
|
if (ImGuiViewportDataMetal* data = (ImGuiViewportDataMetal*)viewport->RendererUserData)
|
||||||
|
IM_DELETE(data);
|
||||||
|
viewport->RendererUserData = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline static CGSize MakeScaledSize(CGSize size, CGFloat scale)
|
||||||
|
{
|
||||||
|
return CGSizeMake(size.width * scale, size.height * scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplMetal_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||||
|
{
|
||||||
|
ImGuiViewportDataMetal* data = (ImGuiViewportDataMetal*)viewport->RendererUserData;
|
||||||
|
data->MetalLayer.drawableSize = MakeScaledSize(CGSizeMake(size.x, size.y), viewport->DpiScale);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplMetal_RenderWindow(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGuiViewportDataMetal* data = (ImGuiViewportDataMetal*)viewport->RendererUserData;
|
||||||
|
|
||||||
|
#if TARGET_OS_OSX
|
||||||
|
void* handle = viewport->PlatformHandleRaw ? viewport->PlatformHandleRaw : viewport->PlatformHandle;
|
||||||
|
NSWindow* window = (__bridge NSWindow*)handle;
|
||||||
|
|
||||||
|
// Always render the first frame, regardless of occlusionState, to avoid an initial flicker
|
||||||
|
if ((window.occlusionState & NSWindowOcclusionStateVisible) == 0 && !data->FirstFrame)
|
||||||
|
{
|
||||||
|
// Do not render windows which are completely occluded. Calling -[CAMetalLayer nextDrawable] will hang for
|
||||||
|
// approximately 1 second if the Metal layer is completely occluded.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data->FirstFrame = false;
|
||||||
|
|
||||||
|
viewport->DpiScale = (float)window.backingScaleFactor;
|
||||||
|
if (data->MetalLayer.contentsScale != viewport->DpiScale)
|
||||||
|
{
|
||||||
|
data->MetalLayer.contentsScale = viewport->DpiScale;
|
||||||
|
data->MetalLayer.drawableSize = MakeScaledSize(window.frame.size, viewport->DpiScale);
|
||||||
|
}
|
||||||
|
viewport->DrawData->FramebufferScale = ImVec2(viewport->DpiScale, viewport->DpiScale);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
id <CAMetalDrawable> drawable = [data->MetalLayer nextDrawable];
|
||||||
|
if (drawable == nil)
|
||||||
|
return;
|
||||||
|
|
||||||
|
MTLRenderPassDescriptor* renderPassDescriptor = data->RenderPassDescriptor;
|
||||||
|
renderPassDescriptor.colorAttachments[0].texture = drawable.texture;
|
||||||
|
renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColorMake(0, 0, 0, 0);
|
||||||
|
if ((viewport->Flags & ImGuiViewportFlags_NoRendererClear) == 0)
|
||||||
|
renderPassDescriptor.colorAttachments[0].loadAction = MTLLoadActionClear;
|
||||||
|
|
||||||
|
id <MTLCommandBuffer> commandBuffer = [data->CommandQueue commandBuffer];
|
||||||
|
id <MTLRenderCommandEncoder> renderEncoder = [commandBuffer renderCommandEncoderWithDescriptor:renderPassDescriptor];
|
||||||
|
ImGui_ImplMetal_RenderDrawData(viewport->DrawData, commandBuffer, renderEncoder);
|
||||||
|
[renderEncoder endEncoding];
|
||||||
|
|
||||||
|
[commandBuffer presentDrawable:drawable];
|
||||||
|
[commandBuffer commit];
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplMetal_InitPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
platform_io.Renderer_CreateWindow = ImGui_ImplMetal_CreateWindow;
|
||||||
|
platform_io.Renderer_DestroyWindow = ImGui_ImplMetal_DestroyWindow;
|
||||||
|
platform_io.Renderer_SetWindowSize = ImGui_ImplMetal_SetWindowSize;
|
||||||
|
platform_io.Renderer_RenderWindow = ImGui_ImplMetal_RenderWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplMetal_ShutdownPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGui::DestroyPlatformWindows();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplMetal_CreateDeviceObjectsForPlatformWindows()
|
||||||
|
{
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
for (int i = 1; i < platform_io.Viewports.Size; i++)
|
||||||
|
if (!platform_io.Viewports[i]->RendererUserData)
|
||||||
|
ImGui_ImplMetal_CreateWindow(platform_io.Viewports[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplMetal_InvalidateDeviceObjectsForPlatformWindows()
|
||||||
|
{
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
for (int i = 1; i < platform_io.Viewports.Size; i++)
|
||||||
|
if (platform_io.Viewports[i]->RendererUserData)
|
||||||
|
ImGui_ImplMetal_DestroyWindow(platform_io.Viewports[i]);
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - MetalBuffer implementation
|
#pragma mark - MetalBuffer implementation
|
||||||
|
|
||||||
@implementation MetalBuffer
|
@implementation MetalBuffer
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
|
||||||
|
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
@ -22,6 +23,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
// 2024-06-28: OpenGL: ImGui_ImplOpenGL2_NewFrame() recreates font texture if it has been destroyed by ImGui_ImplOpenGL2_DestroyFontsTexture(). (#7748)
|
// 2024-06-28: OpenGL: ImGui_ImplOpenGL2_NewFrame() recreates font texture if it has been destroyed by ImGui_ImplOpenGL2_DestroyFontsTexture(). (#7748)
|
||||||
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
||||||
// 2021-12-08: OpenGL: Fixed mishandling of the ImDrawCmd::IdxOffset field! This is an old bug but it never had an effect until some internal rendering changes in 1.86.
|
// 2021-12-08: OpenGL: Fixed mishandling of the ImDrawCmd::IdxOffset field! This is an old bug but it never had an effect until some internal rendering changes in 1.86.
|
||||||
@ -80,6 +82,10 @@ static ImGui_ImplOpenGL2_Data* ImGui_ImplOpenGL2_GetBackendData()
|
|||||||
return ImGui::GetCurrentContext() ? (ImGui_ImplOpenGL2_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
return ImGui::GetCurrentContext() ? (ImGui_ImplOpenGL2_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
static void ImGui_ImplOpenGL2_InitPlatformInterface();
|
||||||
|
static void ImGui_ImplOpenGL2_ShutdownPlatformInterface();
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
bool ImGui_ImplOpenGL2_Init()
|
bool ImGui_ImplOpenGL2_Init()
|
||||||
{
|
{
|
||||||
@ -91,6 +97,10 @@ bool ImGui_ImplOpenGL2_Init()
|
|||||||
ImGui_ImplOpenGL2_Data* bd = IM_NEW(ImGui_ImplOpenGL2_Data)();
|
ImGui_ImplOpenGL2_Data* bd = IM_NEW(ImGui_ImplOpenGL2_Data)();
|
||||||
io.BackendRendererUserData = (void*)bd;
|
io.BackendRendererUserData = (void*)bd;
|
||||||
io.BackendRendererName = "imgui_impl_opengl2";
|
io.BackendRendererName = "imgui_impl_opengl2";
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasViewports; // We can create multi-viewports on the Renderer side (optional)
|
||||||
|
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
ImGui_ImplOpenGL2_InitPlatformInterface();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -101,9 +111,11 @@ void ImGui_ImplOpenGL2_Shutdown()
|
|||||||
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
ImGui_ImplOpenGL2_ShutdownPlatformInterface();
|
||||||
ImGui_ImplOpenGL2_DestroyDeviceObjects();
|
ImGui_ImplOpenGL2_DestroyDeviceObjects();
|
||||||
io.BackendRendererName = nullptr;
|
io.BackendRendererName = nullptr;
|
||||||
io.BackendRendererUserData = nullptr;
|
io.BackendRendererUserData = nullptr;
|
||||||
|
io.BackendFlags &= ~ImGuiBackendFlags_RendererHasViewports;
|
||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,6 +309,35 @@ void ImGui_ImplOpenGL2_DestroyDeviceObjects()
|
|||||||
ImGui_ImplOpenGL2_DestroyFontsTexture();
|
ImGui_ImplOpenGL2_DestroyFontsTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
|
||||||
|
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
|
||||||
|
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static void ImGui_ImplOpenGL2_RenderWindow(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
|
||||||
|
{
|
||||||
|
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
}
|
||||||
|
ImGui_ImplOpenGL2_RenderDrawData(viewport->DrawData);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplOpenGL2_InitPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
platform_io.Renderer_RenderWindow = ImGui_ImplOpenGL2_RenderWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplOpenGL2_ShutdownPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGui::DestroyPlatformWindows();
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
|
||||||
|
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
|
@ -5,7 +5,8 @@
|
|||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [x] Renderer: Large meshes support (64k+ vertices) with 16-bit indices (Desktop OpenGL only).
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices (Desktop OpenGL only).
|
||||||
|
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
|
||||||
// About WebGL/ES:
|
// About WebGL/ES:
|
||||||
// - You need to '#define IMGUI_IMPL_OPENGL_ES2' or '#define IMGUI_IMPL_OPENGL_ES3' to use WebGL or OpenGL ES.
|
// - You need to '#define IMGUI_IMPL_OPENGL_ES2' or '#define IMGUI_IMPL_OPENGL_ES3' to use WebGL or OpenGL ES.
|
||||||
@ -22,6 +23,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
// 2024-06-28: OpenGL: ImGui_ImplOpenGL3_NewFrame() recreates font texture if it has been destroyed by ImGui_ImplOpenGL3_DestroyFontsTexture(). (#7748)
|
// 2024-06-28: OpenGL: ImGui_ImplOpenGL3_NewFrame() recreates font texture if it has been destroyed by ImGui_ImplOpenGL3_DestroyFontsTexture(). (#7748)
|
||||||
// 2024-05-07: OpenGL: Update loader for Linux to support EGL/GLVND. (#7562)
|
// 2024-05-07: OpenGL: Update loader for Linux to support EGL/GLVND. (#7562)
|
||||||
// 2024-04-16: OpenGL: Detect ES3 contexts on desktop based on version string, to e.g. avoid calling glPolygonMode() on them. (#7447)
|
// 2024-04-16: OpenGL: Detect ES3 contexts on desktop based on version string, to e.g. avoid calling glPolygonMode() on them. (#7447)
|
||||||
@ -249,6 +251,10 @@ static ImGui_ImplOpenGL3_Data* ImGui_ImplOpenGL3_GetBackendData()
|
|||||||
return ImGui::GetCurrentContext() ? (ImGui_ImplOpenGL3_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
return ImGui::GetCurrentContext() ? (ImGui_ImplOpenGL3_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
static void ImGui_ImplOpenGL3_InitPlatformInterface();
|
||||||
|
static void ImGui_ImplOpenGL3_ShutdownPlatformInterface();
|
||||||
|
|
||||||
// OpenGL vertex attribute state (for ES 1.0 and ES 2.0 only)
|
// OpenGL vertex attribute state (for ES 1.0 and ES 2.0 only)
|
||||||
#ifndef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
#ifndef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
||||||
struct ImGui_ImplOpenGL3_VtxAttribState
|
struct ImGui_ImplOpenGL3_VtxAttribState
|
||||||
@ -341,6 +347,7 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
|||||||
if (bd->GlVersion >= 320)
|
if (bd->GlVersion >= 320)
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
#endif
|
#endif
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasViewports; // We can create multi-viewports on the Renderer side (optional)
|
||||||
|
|
||||||
// Store GLSL version string so we can refer to it later in case we recreate shaders.
|
// Store GLSL version string so we can refer to it later in case we recreate shaders.
|
||||||
// Note: GLSL version is NOT the same as GL version. Leave this to nullptr if unsure.
|
// Note: GLSL version is NOT the same as GL version. Leave this to nullptr if unsure.
|
||||||
@ -381,6 +388,9 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
ImGui_ImplOpenGL3_InitPlatformInterface();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,10 +400,11 @@ void ImGui_ImplOpenGL3_Shutdown()
|
|||||||
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
ImGui_ImplOpenGL3_ShutdownPlatformInterface();
|
||||||
ImGui_ImplOpenGL3_DestroyDeviceObjects();
|
ImGui_ImplOpenGL3_DestroyDeviceObjects();
|
||||||
io.BackendRendererName = nullptr;
|
io.BackendRendererName = nullptr;
|
||||||
io.BackendRendererUserData = nullptr;
|
io.BackendRendererUserData = nullptr;
|
||||||
io.BackendFlags &= ~ImGuiBackendFlags_RendererHasVtxOffset;
|
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasViewports);
|
||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -949,6 +960,34 @@ void ImGui_ImplOpenGL3_DestroyDeviceObjects()
|
|||||||
ImGui_ImplOpenGL3_DestroyFontsTexture();
|
ImGui_ImplOpenGL3_DestroyFontsTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
|
||||||
|
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
|
||||||
|
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static void ImGui_ImplOpenGL3_RenderWindow(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
|
||||||
|
{
|
||||||
|
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
}
|
||||||
|
ImGui_ImplOpenGL3_RenderDrawData(viewport->DrawData);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplOpenGL3_InitPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
platform_io.Renderer_RenderWindow = ImGui_ImplOpenGL3_RenderWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplOpenGL3_ShutdownPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGui::DestroyPlatformWindows();
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
|
@ -5,7 +5,8 @@
|
|||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [x] Renderer: Large meshes support (64k+ vertices) with 16-bit indices (Desktop OpenGL only).
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices (Desktop OpenGL only).
|
||||||
|
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
|
||||||
// About WebGL/ES:
|
// About WebGL/ES:
|
||||||
// - You need to '#define IMGUI_IMPL_OPENGL_ES2' or '#define IMGUI_IMPL_OPENGL_ES3' to use WebGL or OpenGL ES.
|
// - You need to '#define IMGUI_IMPL_OPENGL_ES2' or '#define IMGUI_IMPL_OPENGL_ES3' to use WebGL or OpenGL ES.
|
||||||
|
@ -10,6 +10,10 @@
|
|||||||
// [X] Platform: OSX clipboard is supported within core Dear ImGui (no specific code in this backend).
|
// [X] Platform: OSX clipboard is supported within core Dear ImGui (no specific code in this backend).
|
||||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
// [X] Platform: IME support.
|
// [X] Platform: IME support.
|
||||||
|
// [x] Platform: Multi-viewport / platform windows.
|
||||||
|
// Issues:
|
||||||
|
// [ ] Platform: Multi-viewport: Window size not correctly reported when enabling io.ConfigViewportsNoDecoration
|
||||||
|
// [ ] Platform: Multi-viewport: ParentViewportID not honored, and so io.ConfigViewportsNoDefaultParent has no effect (minor).
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
|
@ -10,6 +10,10 @@
|
|||||||
// [X] Platform: OSX clipboard is supported within core Dear ImGui (no specific code in this backend).
|
// [X] Platform: OSX clipboard is supported within core Dear ImGui (no specific code in this backend).
|
||||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
// [X] Platform: IME support.
|
// [X] Platform: IME support.
|
||||||
|
// [x] Platform: Multi-viewport / platform windows.
|
||||||
|
// Issues:
|
||||||
|
// [ ] Platform: Multi-viewport: Window size not correctly reported when enabling io.ConfigViewportsNoDecoration
|
||||||
|
// [ ] Platform: Multi-viewport: ParentViewportID not honored, and so io.ConfigViewportsNoDefaultParent has no effect (minor).
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
@ -29,6 +33,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2024-XX-XX: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
// 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO:
|
// 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO:
|
||||||
// - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn
|
// - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn
|
||||||
// - io.SetClipboardTextFn -> platform_io.Platform_SetClipboardTextFn
|
// - io.SetClipboardTextFn -> platform_io.Platform_SetClipboardTextFn
|
||||||
@ -96,6 +101,9 @@ static void ImGui_ImplOSX_DestroyBackendData() { IM_DELETE(
|
|||||||
static inline CFTimeInterval GetMachAbsoluteTimeInSeconds() { return (CFTimeInterval)(double)(clock_gettime_nsec_np(CLOCK_UPTIME_RAW) / 1e9); }
|
static inline CFTimeInterval GetMachAbsoluteTimeInSeconds() { return (CFTimeInterval)(double)(clock_gettime_nsec_np(CLOCK_UPTIME_RAW) / 1e9); }
|
||||||
|
|
||||||
// Forward Declarations
|
// Forward Declarations
|
||||||
|
static void ImGui_ImplOSX_InitPlatformInterface();
|
||||||
|
static void ImGui_ImplOSX_ShutdownPlatformInterface();
|
||||||
|
static void ImGui_ImplOSX_UpdateMonitors();
|
||||||
static void ImGui_ImplOSX_AddTrackingArea(NSView* _Nonnull view);
|
static void ImGui_ImplOSX_AddTrackingArea(NSView* _Nonnull view);
|
||||||
static bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view);
|
static bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view);
|
||||||
|
|
||||||
@ -142,9 +150,25 @@ static bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view);
|
|||||||
NSWindow* window = view.window;
|
NSWindow* window = view.window;
|
||||||
if (!window)
|
if (!window)
|
||||||
return;
|
return;
|
||||||
NSRect contentRect = [window contentRectForFrameRect:window.frame];
|
|
||||||
NSRect rect = NSMakeRect(_posX, contentRect.size.height - _posY, 0, 0);
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
_imeRect = [window convertRectToScreen:rect];
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
NSRect frame = window.frame;
|
||||||
|
NSRect contentRect = window.contentLayoutRect;
|
||||||
|
if (window.styleMask & NSWindowStyleMaskFullSizeContentView) // No title bar windows should be considered.
|
||||||
|
contentRect = frame;
|
||||||
|
|
||||||
|
NSRect firstScreenFrame = NSScreen.screens[0].frame;
|
||||||
|
_imeRect = NSMakeRect(_posX, _posY, 0, 0);
|
||||||
|
_imeRect.origin.y = firstScreenFrame.size.height - _imeRect.size.height - _imeRect.origin.y; // Opposite of ConvertNSRect()
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSRect contentRect = [window contentRectForFrameRect:window.frame];
|
||||||
|
NSRect rect = NSMakeRect(_posX, contentRect.size.height - _posY, 0, 0);
|
||||||
|
_imeRect = [window convertRectToScreen:rect];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)viewDidMoveToWindow
|
- (void)viewDidMoveToWindow
|
||||||
@ -239,6 +263,7 @@ static bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view);
|
|||||||
|
|
||||||
- (void)onApplicationBecomeActive:(NSNotification*)aNotification;
|
- (void)onApplicationBecomeActive:(NSNotification*)aNotification;
|
||||||
- (void)onApplicationBecomeInactive:(NSNotification*)aNotification;
|
- (void)onApplicationBecomeInactive:(NSNotification*)aNotification;
|
||||||
|
- (void)displaysDidChange:(NSNotification*)aNotification;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@ -256,6 +281,11 @@ static bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view);
|
|||||||
io.AddFocusEvent(false);
|
io.AddFocusEvent(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)displaysDidChange:(NSNotification*)aNotification
|
||||||
|
{
|
||||||
|
ImGui_ImplOSX_UpdateMonitors();
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
@ -407,11 +437,16 @@ bool ImGui_ImplOSX_Init(NSView* view)
|
|||||||
io.BackendPlatformName = "imgui_impl_osx";
|
io.BackendPlatformName = "imgui_impl_osx";
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
||||||
//io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
//io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports; // We can create multi-viewports on the Platform side (optional)
|
||||||
|
//io.BackendFlags |= ImGuiBackendFlags_HasMouseHoveredViewport; // We can call io.AddMouseViewportEvent() with correct data (optional)
|
||||||
|
|
||||||
bd->Observer = [ImGuiObserver new];
|
bd->Observer = [ImGuiObserver new];
|
||||||
bd->Window = view.window ?: NSApp.orderedWindows.firstObject;
|
bd->Window = view.window ?: NSApp.orderedWindows.firstObject;
|
||||||
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
main_viewport->PlatformHandle = main_viewport->PlatformHandleRaw = (__bridge_retained void*)bd->Window;
|
main_viewport->PlatformHandle = main_viewport->PlatformHandleRaw = (__bridge_retained void*)bd->Window;
|
||||||
|
ImGui_ImplOSX_UpdateMonitors();
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
ImGui_ImplOSX_InitPlatformInterface();
|
||||||
|
|
||||||
// Load cursors. Some of them are undocumented.
|
// Load cursors. Some of them are undocumented.
|
||||||
bd->MouseCursorHidden = false;
|
bd->MouseCursorHidden = false;
|
||||||
@ -501,12 +536,12 @@ void ImGui_ImplOSX_Shutdown()
|
|||||||
bd->Monitor = nullptr;
|
bd->Monitor = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui_ImplOSX_ShutdownPlatformInterface();
|
||||||
ImGui_ImplOSX_DestroyBackendData();
|
ImGui_ImplOSX_DestroyBackendData();
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.BackendPlatformName = nullptr;
|
io.BackendPlatformName = nullptr;
|
||||||
io.BackendPlatformUserData = nullptr;
|
io.BackendPlatformUserData = nullptr;
|
||||||
io.BackendFlags &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasGamepad);
|
io.BackendFlags &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasGamepad | ImGuiBackendFlags_PlatformHasViewports);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplOSX_UpdateMouseCursor()
|
static void ImGui_ImplOSX_UpdateMouseCursor()
|
||||||
@ -683,14 +718,23 @@ static bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view)
|
|||||||
|
|
||||||
if (event.type == NSEventTypeMouseMoved || event.type == NSEventTypeLeftMouseDragged || event.type == NSEventTypeRightMouseDragged || event.type == NSEventTypeOtherMouseDragged)
|
if (event.type == NSEventTypeMouseMoved || event.type == NSEventTypeLeftMouseDragged || event.type == NSEventTypeRightMouseDragged || event.type == NSEventTypeOtherMouseDragged)
|
||||||
{
|
{
|
||||||
NSPoint mousePoint = event.locationInWindow;
|
NSPoint mousePoint;
|
||||||
if (event.window == nil)
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
mousePoint = [[view window] convertPointFromScreen:mousePoint];
|
{
|
||||||
mousePoint = [view convertPoint:mousePoint fromView:nil];
|
mousePoint = NSEvent.mouseLocation;
|
||||||
if ([view isFlipped])
|
mousePoint.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - mousePoint.y; // Normalize y coordinate to top-left of main display.
|
||||||
mousePoint = NSMakePoint(mousePoint.x, mousePoint.y);
|
}
|
||||||
else
|
else
|
||||||
mousePoint = NSMakePoint(mousePoint.x, view.bounds.size.height - mousePoint.y);
|
{
|
||||||
|
mousePoint = event.locationInWindow;
|
||||||
|
if (event.window == nil)
|
||||||
|
mousePoint = [[view window] convertPointFromScreen:mousePoint];
|
||||||
|
mousePoint = [view convertPoint:mousePoint fromView:nil]; // Convert to local coordinates of view
|
||||||
|
if ([view isFlipped])
|
||||||
|
mousePoint = NSMakePoint(mousePoint.x, mousePoint.y);
|
||||||
|
else
|
||||||
|
mousePoint = NSMakePoint(mousePoint.x, view.bounds.size.height - mousePoint.y);
|
||||||
|
}
|
||||||
io.AddMouseSourceEvent(GetMouseSource(event));
|
io.AddMouseSourceEvent(GetMouseSource(event));
|
||||||
io.AddMousePosEvent((float)mousePoint.x, (float)mousePoint.y);
|
io.AddMousePosEvent((float)mousePoint.x, (float)mousePoint.y);
|
||||||
return io.WantCaptureMouse;
|
return io.WantCaptureMouse;
|
||||||
@ -818,6 +862,294 @@ static void ImGui_ImplOSX_AddTrackingArea(NSView* _Nonnull view)
|
|||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
|
||||||
|
// This is an _advanced_ and _optional_ feature, allowing the back-end to create and handle multiple viewports simultaneously.
|
||||||
|
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
struct ImGuiViewportDataOSX
|
||||||
|
{
|
||||||
|
NSWindow* Window;
|
||||||
|
bool WindowOwned;
|
||||||
|
|
||||||
|
ImGuiViewportDataOSX() { WindowOwned = false; }
|
||||||
|
~ImGuiViewportDataOSX() { IM_ASSERT(Window == nil); }
|
||||||
|
};
|
||||||
|
|
||||||
|
@interface ImGui_ImplOSX_Window: NSWindow
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation ImGui_ImplOSX_Window
|
||||||
|
|
||||||
|
- (BOOL)canBecomeKeyWindow
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
static void ConvertNSRect(NSRect* r)
|
||||||
|
{
|
||||||
|
NSRect firstScreenFrame = NSScreen.screens[0].frame;
|
||||||
|
IM_ASSERT(firstScreenFrame.origin.x == 0 && firstScreenFrame.origin.y == 0);
|
||||||
|
r->origin.y = firstScreenFrame.size.height - r->origin.y - r->size.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplOSX_CreateWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplOSX_Data* bd = ImGui_ImplOSX_GetBackendData();
|
||||||
|
ImGuiViewportDataOSX* data = IM_NEW(ImGuiViewportDataOSX)();
|
||||||
|
viewport->PlatformUserData = data;
|
||||||
|
|
||||||
|
NSScreen* screen = bd->Window.screen;
|
||||||
|
NSRect rect = NSMakeRect(viewport->Pos.x, viewport->Pos.y, viewport->Size.x, viewport->Size.y);
|
||||||
|
ConvertNSRect(&rect);
|
||||||
|
|
||||||
|
NSWindowStyleMask styleMask = 0;
|
||||||
|
if (viewport->Flags & ImGuiViewportFlags_NoDecoration)
|
||||||
|
styleMask |= NSWindowStyleMaskBorderless;
|
||||||
|
else
|
||||||
|
styleMask |= NSWindowStyleMaskTitled | NSWindowStyleMaskResizable | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable;
|
||||||
|
|
||||||
|
NSWindow* window = [[ImGui_ImplOSX_Window alloc] initWithContentRect:rect
|
||||||
|
styleMask:styleMask
|
||||||
|
backing:NSBackingStoreBuffered
|
||||||
|
defer:YES
|
||||||
|
screen:screen];
|
||||||
|
if (viewport->Flags & ImGuiViewportFlags_TopMost)
|
||||||
|
[window setLevel:NSFloatingWindowLevel];
|
||||||
|
|
||||||
|
window.title = @"Untitled";
|
||||||
|
window.opaque = YES;
|
||||||
|
|
||||||
|
KeyEventResponder* view = [[KeyEventResponder alloc] initWithFrame:rect];
|
||||||
|
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6 && ceil(NSAppKitVersionNumber) < NSAppKitVersionNumber10_15)
|
||||||
|
[view setWantsBestResolutionOpenGLSurface:YES];
|
||||||
|
|
||||||
|
window.contentView = view;
|
||||||
|
|
||||||
|
data->Window = window;
|
||||||
|
data->WindowOwned = true;
|
||||||
|
viewport->PlatformRequestResize = false;
|
||||||
|
viewport->PlatformHandle = viewport->PlatformHandleRaw = (__bridge_retained void*)window;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplOSX_DestroyWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
NSWindow* window = (__bridge_transfer NSWindow*)viewport->PlatformHandleRaw;
|
||||||
|
window = nil;
|
||||||
|
|
||||||
|
if (ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData)
|
||||||
|
{
|
||||||
|
NSWindow* window = data->Window;
|
||||||
|
if (window != nil && data->WindowOwned)
|
||||||
|
{
|
||||||
|
window.contentView = nil;
|
||||||
|
window.contentViewController = nil;
|
||||||
|
[window orderOut:nil];
|
||||||
|
}
|
||||||
|
data->Window = nil;
|
||||||
|
IM_DELETE(data);
|
||||||
|
}
|
||||||
|
viewport->PlatformUserData = viewport->PlatformHandle = viewport->PlatformHandleRaw = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplOSX_ShowWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(data->Window != 0);
|
||||||
|
|
||||||
|
if (viewport->Flags & ImGuiViewportFlags_NoFocusOnAppearing)
|
||||||
|
[data->Window orderFront:nil];
|
||||||
|
else
|
||||||
|
[data->Window makeKeyAndOrderFront:nil];
|
||||||
|
|
||||||
|
[data->Window setIsVisible:YES];
|
||||||
|
}
|
||||||
|
|
||||||
|
static ImVec2 ImGui_ImplOSX_GetWindowPos(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(data->Window != 0);
|
||||||
|
|
||||||
|
NSWindow* window = data->Window;
|
||||||
|
NSRect frame = window.frame;
|
||||||
|
NSRect contentRect = window.contentLayoutRect;
|
||||||
|
if (window.styleMask & NSWindowStyleMaskFullSizeContentView) // No title bar windows should be considered.
|
||||||
|
contentRect = frame;
|
||||||
|
|
||||||
|
NSRect firstScreenFrame = NSScreen.screens[0].frame;
|
||||||
|
return ImVec2(frame.origin.x, firstScreenFrame.size.height - frame.origin.y - contentRect.size.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplOSX_SetWindowPos(ImGuiViewport* viewport, ImVec2 pos)
|
||||||
|
{
|
||||||
|
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(data->Window != 0);
|
||||||
|
|
||||||
|
NSWindow* window = data->Window;
|
||||||
|
NSSize size = window.frame.size;
|
||||||
|
|
||||||
|
NSRect r = NSMakeRect(pos.x, pos.y, size.width, size.height);
|
||||||
|
ConvertNSRect(&r);
|
||||||
|
[window setFrameOrigin:r.origin];
|
||||||
|
}
|
||||||
|
|
||||||
|
static ImVec2 ImGui_ImplOSX_GetWindowSize(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(data->Window != 0);
|
||||||
|
|
||||||
|
NSWindow* window = data->Window;
|
||||||
|
NSSize size = window.contentLayoutRect.size;
|
||||||
|
return ImVec2(size.width, size.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplOSX_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||||
|
{
|
||||||
|
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(data->Window != 0);
|
||||||
|
|
||||||
|
NSWindow* window = data->Window;
|
||||||
|
NSRect rect = window.frame;
|
||||||
|
rect.origin.y -= (size.y - rect.size.height);
|
||||||
|
rect.size.width = size.x;
|
||||||
|
rect.size.height = size.y;
|
||||||
|
[window setFrame:rect display:YES];
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplOSX_SetWindowFocus(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplOSX_Data* bd = ImGui_ImplOSX_GetBackendData();
|
||||||
|
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(data->Window != 0);
|
||||||
|
[data->Window makeKeyAndOrderFront:bd->Window];
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ImGui_ImplOSX_GetWindowFocus(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(data->Window != 0);
|
||||||
|
|
||||||
|
return data->Window.isKeyWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ImGui_ImplOSX_GetWindowMinimized(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(data->Window != 0);
|
||||||
|
|
||||||
|
return data->Window.isMiniaturized;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplOSX_SetWindowTitle(ImGuiViewport* viewport, const char* title)
|
||||||
|
{
|
||||||
|
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(data->Window != 0);
|
||||||
|
|
||||||
|
data->Window.title = [NSString stringWithUTF8String:title];
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplOSX_SetWindowAlpha(ImGuiViewport* viewport, float alpha)
|
||||||
|
{
|
||||||
|
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(data->Window != 0);
|
||||||
|
IM_ASSERT(alpha >= 0.0f && alpha <= 1.0f);
|
||||||
|
|
||||||
|
data->Window.alphaValue = alpha;
|
||||||
|
}
|
||||||
|
|
||||||
|
static float ImGui_ImplOSX_GetWindowDpiScale(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(data->Window != 0);
|
||||||
|
|
||||||
|
return data->Window.backingScaleFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplOSX_UpdateMonitors()
|
||||||
|
{
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
platform_io.Monitors.resize(0);
|
||||||
|
|
||||||
|
NSRect firstScreenFrame = NSScreen.screens[0].frame;
|
||||||
|
IM_ASSERT(firstScreenFrame.origin.x == 0 && firstScreenFrame.origin.y == 0);
|
||||||
|
|
||||||
|
for (NSScreen* screen in NSScreen.screens)
|
||||||
|
{
|
||||||
|
NSRect frame = screen.frame;
|
||||||
|
NSRect visibleFrame = screen.visibleFrame;
|
||||||
|
ConvertNSRect(&frame);
|
||||||
|
ConvertNSRect(&visibleFrame);
|
||||||
|
|
||||||
|
ImGuiPlatformMonitor imgui_monitor;
|
||||||
|
imgui_monitor.MainPos = ImVec2(frame.origin.x, frame.origin.y);
|
||||||
|
imgui_monitor.MainSize = ImVec2(frame.size.width, frame.size.height);
|
||||||
|
imgui_monitor.WorkPos = ImVec2(visibleFrame.origin.x, visibleFrame.origin.y);
|
||||||
|
imgui_monitor.WorkSize = ImVec2(visibleFrame.size.width, visibleFrame.size.height);
|
||||||
|
imgui_monitor.DpiScale = screen.backingScaleFactor;
|
||||||
|
imgui_monitor.PlatformHandle = (__bridge_retained void*)screen;
|
||||||
|
|
||||||
|
platform_io.Monitors.push_back(imgui_monitor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplOSX_InitPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGui_ImplOSX_Data* bd = ImGui_ImplOSX_GetBackendData();
|
||||||
|
|
||||||
|
// Register platform interface (will be coupled with a renderer interface)
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
platform_io.Platform_CreateWindow = ImGui_ImplOSX_CreateWindow;
|
||||||
|
platform_io.Platform_DestroyWindow = ImGui_ImplOSX_DestroyWindow;
|
||||||
|
platform_io.Platform_ShowWindow = ImGui_ImplOSX_ShowWindow;
|
||||||
|
platform_io.Platform_SetWindowPos = ImGui_ImplOSX_SetWindowPos;
|
||||||
|
platform_io.Platform_GetWindowPos = ImGui_ImplOSX_GetWindowPos;
|
||||||
|
platform_io.Platform_SetWindowSize = ImGui_ImplOSX_SetWindowSize;
|
||||||
|
platform_io.Platform_GetWindowSize = ImGui_ImplOSX_GetWindowSize;
|
||||||
|
platform_io.Platform_SetWindowFocus = ImGui_ImplOSX_SetWindowFocus;
|
||||||
|
platform_io.Platform_GetWindowFocus = ImGui_ImplOSX_GetWindowFocus;
|
||||||
|
platform_io.Platform_GetWindowMinimized = ImGui_ImplOSX_GetWindowMinimized;
|
||||||
|
platform_io.Platform_SetWindowTitle = ImGui_ImplOSX_SetWindowTitle;
|
||||||
|
platform_io.Platform_SetWindowAlpha = ImGui_ImplOSX_SetWindowAlpha;
|
||||||
|
platform_io.Platform_GetWindowDpiScale = ImGui_ImplOSX_GetWindowDpiScale; // FIXME-DPI
|
||||||
|
|
||||||
|
// Register main window handle (which is owned by the main application, not by us)
|
||||||
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
|
ImGuiViewportDataOSX* data = IM_NEW(ImGuiViewportDataOSX)();
|
||||||
|
data->Window = bd->Window;
|
||||||
|
data->WindowOwned = false;
|
||||||
|
main_viewport->PlatformUserData = data;
|
||||||
|
main_viewport->PlatformHandle = (__bridge void*)bd->Window;
|
||||||
|
|
||||||
|
[NSNotificationCenter.defaultCenter addObserver:bd->Observer
|
||||||
|
selector:@selector(displaysDidChange:)
|
||||||
|
name:NSApplicationDidChangeScreenParametersNotification
|
||||||
|
object:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplOSX_ShutdownPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGui_ImplOSX_Data* bd = ImGui_ImplOSX_GetBackendData();
|
||||||
|
[NSNotificationCenter.defaultCenter removeObserver:bd->Observer
|
||||||
|
name:NSApplicationDidChangeScreenParametersNotification
|
||||||
|
object:nil];
|
||||||
|
bd->Observer = nullptr;
|
||||||
|
bd->Window = nullptr;
|
||||||
|
if (bd->Monitor != nullptr)
|
||||||
|
{
|
||||||
|
[NSEvent removeMonitor:bd->Monitor];
|
||||||
|
bd->Monitor = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
|
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)main_viewport->PlatformUserData;
|
||||||
|
IM_DELETE(data);
|
||||||
|
main_viewport->PlatformUserData = nullptr;
|
||||||
|
ImGui::DestroyPlatformWindows();
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#endif // #ifndef IMGUI_DISABLE
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
@ -9,7 +9,11 @@
|
|||||||
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
// [X] Platform: Basic IME support. App needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!.
|
// [X] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
// Issues:
|
||||||
|
// [ ] Platform: Multi-viewport: Minimized windows seems to break mouse wheel events (at least under Windows).
|
||||||
|
// [ ] Platform: Multi-viewport: ParentViewportID not honored, and so io.ConfigViewportsNoDefaultParent has no effect (minor).
|
||||||
|
// [x] Platform: Basic IME support. App needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
@ -21,6 +25,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
// 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO:
|
// 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO:
|
||||||
// - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn
|
// - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn
|
||||||
// - io.SetClipboardTextFn -> platform_io.Platform_SetClipboardTextFn
|
// - io.SetClipboardTextFn -> platform_io.Platform_SetClipboardTextFn
|
||||||
@ -56,7 +61,7 @@
|
|||||||
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
|
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
|
||||||
// 2021-08-17: Calling io.AddFocusEvent() on SDL_WINDOWEVENT_FOCUS_GAINED/SDL_WINDOWEVENT_FOCUS_LOST.
|
// 2021-08-17: Calling io.AddFocusEvent() on SDL_WINDOWEVENT_FOCUS_GAINED/SDL_WINDOWEVENT_FOCUS_LOST.
|
||||||
// 2021-07-29: Inputs: MousePos is correctly reported when the host platform window is hovered but not focused (using SDL_GetMouseFocus() + SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, requires SDL 2.0.5+)
|
// 2021-07-29: Inputs: MousePos is correctly reported when the host platform window is hovered but not focused (using SDL_GetMouseFocus() + SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, requires SDL 2.0.5+)
|
||||||
// 2021-06-29: *BREAKING CHANGE* Removed 'SDL_Window* window' parameter to ImGui_ImplSDL2_NewFrame() which was unnecessary.
|
// 2021-06:29: *BREAKING CHANGE* Removed 'SDL_Window* window' parameter to ImGui_ImplSDL2_NewFrame() which was unnecessary.
|
||||||
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
||||||
// 2021-03-22: Rework global mouse pos availability check listing supported platforms explicitly, effectively fixing mouse access on Raspberry Pi. (#2837, #3950)
|
// 2021-03-22: Rework global mouse pos availability check listing supported platforms explicitly, effectively fixing mouse access on Raspberry Pi. (#2837, #3950)
|
||||||
// 2020-05-25: Misc: Report a zero display-size when window is minimized, to be consistent with other backends.
|
// 2020-05-25: Misc: Report a zero display-size when window is minimized, to be consistent with other backends.
|
||||||
@ -97,6 +102,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// SDL
|
// SDL
|
||||||
|
// (the multi-viewports feature requires SDL features supported from SDL 2.0.4+. SDL 2.0.5+ is highly recommended)
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <SDL_syswm.h>
|
#include <SDL_syswm.h>
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
@ -111,7 +117,16 @@
|
|||||||
#else
|
#else
|
||||||
#define SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE 0
|
#define SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE 0
|
||||||
#endif
|
#endif
|
||||||
|
#define SDL_HAS_WINDOW_ALPHA SDL_VERSION_ATLEAST(2,0,5)
|
||||||
|
#define SDL_HAS_ALWAYS_ON_TOP SDL_VERSION_ATLEAST(2,0,5)
|
||||||
|
#define SDL_HAS_USABLE_DISPLAY_BOUNDS SDL_VERSION_ATLEAST(2,0,5)
|
||||||
|
#define SDL_HAS_PER_MONITOR_DPI SDL_VERSION_ATLEAST(2,0,4)
|
||||||
#define SDL_HAS_VULKAN SDL_VERSION_ATLEAST(2,0,6)
|
#define SDL_HAS_VULKAN SDL_VERSION_ATLEAST(2,0,6)
|
||||||
|
#define SDL_HAS_DISPLAY_EVENT SDL_VERSION_ATLEAST(2,0,9)
|
||||||
|
#define SDL_HAS_SHOW_WINDOW_ACTIVATION_HINT SDL_VERSION_ATLEAST(2,0,18)
|
||||||
|
#if !SDL_HAS_VULKAN
|
||||||
|
static const Uint32 SDL_WINDOW_VULKAN = 0x10000000;
|
||||||
|
#endif
|
||||||
|
|
||||||
// SDL Data
|
// SDL Data
|
||||||
struct ImGui_ImplSDL2_Data
|
struct ImGui_ImplSDL2_Data
|
||||||
@ -121,6 +136,8 @@ struct ImGui_ImplSDL2_Data
|
|||||||
SDL_Renderer* Renderer;
|
SDL_Renderer* Renderer;
|
||||||
Uint64 Time;
|
Uint64 Time;
|
||||||
char* ClipboardTextData;
|
char* ClipboardTextData;
|
||||||
|
bool UseVulkan;
|
||||||
|
bool WantUpdateMonitors;
|
||||||
|
|
||||||
// Mouse handling
|
// Mouse handling
|
||||||
Uint32 MouseWindowID;
|
Uint32 MouseWindowID;
|
||||||
@ -129,6 +146,7 @@ struct ImGui_ImplSDL2_Data
|
|||||||
SDL_Cursor* MouseLastCursor;
|
SDL_Cursor* MouseLastCursor;
|
||||||
int MouseLastLeaveFrame;
|
int MouseLastLeaveFrame;
|
||||||
bool MouseCanUseGlobalState;
|
bool MouseCanUseGlobalState;
|
||||||
|
bool MouseCanReportHoveredViewport; // This is hard to use/unreliable on SDL so we'll set ImGuiBackendFlags_HasMouseHoveredViewport dynamically based on state.
|
||||||
|
|
||||||
// Gamepad handling
|
// Gamepad handling
|
||||||
ImVector<SDL_GameController*> Gamepads;
|
ImVector<SDL_GameController*> Gamepads;
|
||||||
@ -147,6 +165,11 @@ static ImGui_ImplSDL2_Data* ImGui_ImplSDL2_GetBackendData()
|
|||||||
return ImGui::GetCurrentContext() ? (ImGui_ImplSDL2_Data*)ImGui::GetIO().BackendPlatformUserData : nullptr;
|
return ImGui::GetCurrentContext() ? (ImGui_ImplSDL2_Data*)ImGui::GetIO().BackendPlatformUserData : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
static void ImGui_ImplSDL2_UpdateMonitors();
|
||||||
|
static void ImGui_ImplSDL2_InitPlatformInterface(SDL_Window* window, void* sdl_gl_context);
|
||||||
|
static void ImGui_ImplSDL2_ShutdownPlatformInterface();
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
static const char* ImGui_ImplSDL2_GetClipboardText(ImGuiContext*)
|
static const char* ImGui_ImplSDL2_GetClipboardText(ImGuiContext*)
|
||||||
{
|
{
|
||||||
@ -163,13 +186,13 @@ static void ImGui_ImplSDL2_SetClipboardText(ImGuiContext*, const char* text)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Note: native IME will only display if user calls SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1") _before_ SDL_CreateWindow().
|
// Note: native IME will only display if user calls SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1") _before_ SDL_CreateWindow().
|
||||||
static void ImGui_ImplSDL2_PlatformSetImeData(ImGuiContext*, ImGuiViewport*, ImGuiPlatformImeData* data)
|
static void ImGui_ImplSDL2_PlatformSetImeData(ImGuiContext*, ImGuiViewport* viewport, ImGuiPlatformImeData* data)
|
||||||
{
|
{
|
||||||
if (data->WantVisible)
|
if (data->WantVisible)
|
||||||
{
|
{
|
||||||
SDL_Rect r;
|
SDL_Rect r;
|
||||||
r.x = (int)data->InputPos.x;
|
r.x = (int)(data->InputPos.x - viewport->Pos.x);
|
||||||
r.y = (int)data->InputPos.y;
|
r.y = (int)(data->InputPos.y - viewport->Pos.y + data->InputLineHeight);
|
||||||
r.w = 1;
|
r.w = 1;
|
||||||
r.h = (int)data->InputLineHeight;
|
r.h = (int)data->InputLineHeight;
|
||||||
SDL_SetTextInputRect(&r);
|
SDL_SetTextInputRect(&r);
|
||||||
@ -316,15 +339,13 @@ static void ImGui_ImplSDL2_UpdateKeyModifiers(SDL_Keymod sdl_key_mods)
|
|||||||
|
|
||||||
static ImGuiViewport* ImGui_ImplSDL2_GetViewportForWindowID(Uint32 window_id)
|
static ImGuiViewport* ImGui_ImplSDL2_GetViewportForWindowID(Uint32 window_id)
|
||||||
{
|
{
|
||||||
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
return ImGui::FindViewportByPlatformHandle((void*)(intptr_t)window_id);
|
||||||
return (window_id == bd->WindowID) ? ImGui::GetMainViewport() : NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
|
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
|
||||||
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application, or clear/overwrite your copy of the mouse data.
|
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application, or clear/overwrite your copy of the mouse data.
|
||||||
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application, or clear/overwrite your copy of the keyboard data.
|
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application, or clear/overwrite your copy of the keyboard data.
|
||||||
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
|
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
|
||||||
// If you have multiple SDL events and some of them are not meant to be used by dear imgui, you may need to filter events based on their windowID field.
|
|
||||||
bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
|
bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
|
||||||
{
|
{
|
||||||
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
||||||
@ -338,6 +359,13 @@ bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
|
|||||||
if (ImGui_ImplSDL2_GetViewportForWindowID(event->motion.windowID) == NULL)
|
if (ImGui_ImplSDL2_GetViewportForWindowID(event->motion.windowID) == NULL)
|
||||||
return false;
|
return false;
|
||||||
ImVec2 mouse_pos((float)event->motion.x, (float)event->motion.y);
|
ImVec2 mouse_pos((float)event->motion.x, (float)event->motion.y);
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
int window_x, window_y;
|
||||||
|
SDL_GetWindowPosition(SDL_GetWindowFromID(event->motion.windowID), &window_x, &window_y);
|
||||||
|
mouse_pos.x += window_x;
|
||||||
|
mouse_pos.y += window_y;
|
||||||
|
}
|
||||||
io.AddMouseSourceEvent(event->motion.which == SDL_TOUCH_MOUSEID ? ImGuiMouseSource_TouchScreen : ImGuiMouseSource_Mouse);
|
io.AddMouseSourceEvent(event->motion.which == SDL_TOUCH_MOUSEID ? ImGuiMouseSource_TouchScreen : ImGuiMouseSource_Mouse);
|
||||||
io.AddMousePosEvent(mouse_pos.x, mouse_pos.y);
|
io.AddMousePosEvent(mouse_pos.x, mouse_pos.y);
|
||||||
return true;
|
return true;
|
||||||
@ -397,10 +425,21 @@ bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
|
|||||||
io.SetKeyEventNativeData(key, event->key.keysym.sym, event->key.keysym.scancode, event->key.keysym.scancode); // To support legacy indexing (<1.87 user code). Legacy backend uses SDLK_*** as indices to IsKeyXXX() functions.
|
io.SetKeyEventNativeData(key, event->key.keysym.sym, event->key.keysym.scancode, event->key.keysym.scancode); // To support legacy indexing (<1.87 user code). Legacy backend uses SDLK_*** as indices to IsKeyXXX() functions.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#if SDL_HAS_DISPLAY_EVENT
|
||||||
|
case SDL_DISPLAYEVENT:
|
||||||
|
{
|
||||||
|
// 2.0.26 has SDL_DISPLAYEVENT_CONNECTED/SDL_DISPLAYEVENT_DISCONNECTED/SDL_DISPLAYEVENT_ORIENTATION,
|
||||||
|
// so change of DPI/Scaling are not reflected in this event. (SDL3 has it)
|
||||||
|
bd->WantUpdateMonitors = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
case SDL_WINDOWEVENT:
|
case SDL_WINDOWEVENT:
|
||||||
{
|
{
|
||||||
if (ImGui_ImplSDL2_GetViewportForWindowID(event->window.windowID) == NULL)
|
ImGuiViewport* viewport = ImGui_ImplSDL2_GetViewportForWindowID(event->window.windowID);
|
||||||
|
if (viewport == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// - When capturing mouse, SDL will send a bunch of conflicting LEAVE/ENTER event on every mouse move, but the final ENTER tends to be right.
|
// - When capturing mouse, SDL will send a bunch of conflicting LEAVE/ENTER event on every mouse move, but the final ENTER tends to be right.
|
||||||
// - However we won't get a correct LEAVE event for a captured window.
|
// - However we won't get a correct LEAVE event for a captured window.
|
||||||
// - In some cases, when detaching a window from main viewport SDL may send SDL_WINDOWEVENT_ENTER one frame too late,
|
// - In some cases, when detaching a window from main viewport SDL may send SDL_WINDOWEVENT_ENTER one frame too late,
|
||||||
@ -416,8 +455,14 @@ bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
|
|||||||
bd->MouseLastLeaveFrame = ImGui::GetFrameCount() + 1;
|
bd->MouseLastLeaveFrame = ImGui::GetFrameCount() + 1;
|
||||||
if (window_event == SDL_WINDOWEVENT_FOCUS_GAINED)
|
if (window_event == SDL_WINDOWEVENT_FOCUS_GAINED)
|
||||||
io.AddFocusEvent(true);
|
io.AddFocusEvent(true);
|
||||||
else if (event->window.event == SDL_WINDOWEVENT_FOCUS_LOST)
|
else if (window_event == SDL_WINDOWEVENT_FOCUS_LOST)
|
||||||
io.AddFocusEvent(false);
|
io.AddFocusEvent(false);
|
||||||
|
else if (window_event == SDL_WINDOWEVENT_CLOSE)
|
||||||
|
viewport->PlatformRequestClose = true;
|
||||||
|
else if (window_event == SDL_WINDOWEVENT_MOVED)
|
||||||
|
viewport->PlatformRequestMove = true;
|
||||||
|
else if (window_event == SDL_WINDOWEVENT_RESIZED)
|
||||||
|
viewport->PlatformRequestResize = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case SDL_CONTROLLERDEVICEADDED:
|
case SDL_CONTROLLERDEVICEADDED:
|
||||||
@ -455,13 +500,24 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window, SDL_Renderer* renderer, void
|
|||||||
ImGui_ImplSDL2_Data* bd = IM_NEW(ImGui_ImplSDL2_Data)();
|
ImGui_ImplSDL2_Data* bd = IM_NEW(ImGui_ImplSDL2_Data)();
|
||||||
io.BackendPlatformUserData = (void*)bd;
|
io.BackendPlatformUserData = (void*)bd;
|
||||||
io.BackendPlatformName = "imgui_impl_sdl2";
|
io.BackendPlatformName = "imgui_impl_sdl2";
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
||||||
|
if (mouse_can_use_global_state)
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports; // We can create multi-viewports on the Platform side (optional)
|
||||||
|
|
||||||
bd->Window = window;
|
bd->Window = window;
|
||||||
bd->WindowID = SDL_GetWindowID(window);
|
bd->WindowID = SDL_GetWindowID(window);
|
||||||
bd->Renderer = renderer;
|
bd->Renderer = renderer;
|
||||||
|
|
||||||
|
// SDL on Linux/OSX doesn't report events for unfocused windows (see https://github.com/ocornut/imgui/issues/4960)
|
||||||
|
// We will use 'MouseCanReportHoveredViewport' to set 'ImGuiBackendFlags_HasMouseHoveredViewport' dynamically each frame.
|
||||||
bd->MouseCanUseGlobalState = mouse_can_use_global_state;
|
bd->MouseCanUseGlobalState = mouse_can_use_global_state;
|
||||||
|
#ifndef __APPLE__
|
||||||
|
bd->MouseCanReportHoveredViewport = bd->MouseCanUseGlobalState;
|
||||||
|
#else
|
||||||
|
bd->MouseCanReportHoveredViewport = false;
|
||||||
|
#endif
|
||||||
|
bd->WantUpdateMonitors = true;
|
||||||
|
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
platform_io.Platform_SetClipboardTextFn = ImGui_ImplSDL2_SetClipboardText;
|
platform_io.Platform_SetClipboardTextFn = ImGui_ImplSDL2_SetClipboardText;
|
||||||
@ -524,7 +580,11 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window, SDL_Renderer* renderer, void
|
|||||||
SDL_SetHint(SDL_HINT_MOUSE_AUTO_CAPTURE, "0");
|
SDL_SetHint(SDL_HINT_MOUSE_AUTO_CAPTURE, "0");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
(void)sdl_gl_context; // Unused in 'master' branch.
|
// We need SDL_CaptureMouse(), SDL_GetGlobalMouseState() from SDL 2.0.4+ to support multiple viewports.
|
||||||
|
// We left the call to ImGui_ImplSDL2_InitPlatformInterface() outside of #ifdef to avoid unused-function warnings.
|
||||||
|
if ((io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) && (io.BackendFlags & ImGuiBackendFlags_PlatformHasViewports))
|
||||||
|
ImGui_ImplSDL2_InitPlatformInterface(window, sdl_gl_context);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -538,7 +598,11 @@ bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window)
|
|||||||
#if !SDL_HAS_VULKAN
|
#if !SDL_HAS_VULKAN
|
||||||
IM_ASSERT(0 && "Unsupported");
|
IM_ASSERT(0 && "Unsupported");
|
||||||
#endif
|
#endif
|
||||||
return ImGui_ImplSDL2_Init(window, nullptr, nullptr);
|
if (!ImGui_ImplSDL2_Init(window, nullptr, nullptr))
|
||||||
|
return false;
|
||||||
|
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
||||||
|
bd->UseVulkan = true;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window)
|
bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window)
|
||||||
@ -572,6 +636,8 @@ void ImGui_ImplSDL2_Shutdown()
|
|||||||
IM_ASSERT(bd != nullptr && "No platform backend to shutdown, or already shutdown?");
|
IM_ASSERT(bd != nullptr && "No platform backend to shutdown, or already shutdown?");
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
ImGui_ImplSDL2_ShutdownPlatformInterface();
|
||||||
|
|
||||||
if (bd->ClipboardTextData)
|
if (bd->ClipboardTextData)
|
||||||
SDL_free(bd->ClipboardTextData);
|
SDL_free(bd->ClipboardTextData);
|
||||||
for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++)
|
for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++)
|
||||||
@ -580,10 +646,11 @@ void ImGui_ImplSDL2_Shutdown()
|
|||||||
|
|
||||||
io.BackendPlatformName = nullptr;
|
io.BackendPlatformName = nullptr;
|
||||||
io.BackendPlatformUserData = nullptr;
|
io.BackendPlatformUserData = nullptr;
|
||||||
io.BackendFlags &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasSetMousePos | ImGuiBackendFlags_HasGamepad);
|
io.BackendFlags &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasSetMousePos | ImGuiBackendFlags_HasGamepad | ImGuiBackendFlags_PlatformHasViewports | ImGuiBackendFlags_HasMouseHoveredViewport);
|
||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This code is incredibly messy because some of the functions we need for full viewport support are not available in SDL < 2.0.4.
|
||||||
static void ImGui_ImplSDL2_UpdateMouseData()
|
static void ImGui_ImplSDL2_UpdateMouseData()
|
||||||
{
|
{
|
||||||
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
||||||
@ -594,25 +661,56 @@ static void ImGui_ImplSDL2_UpdateMouseData()
|
|||||||
// SDL_CaptureMouse() let the OS know e.g. that our imgui drag outside the SDL window boundaries shouldn't e.g. trigger other operations outside
|
// SDL_CaptureMouse() let the OS know e.g. that our imgui drag outside the SDL window boundaries shouldn't e.g. trigger other operations outside
|
||||||
SDL_CaptureMouse((bd->MouseButtonsDown != 0) ? SDL_TRUE : SDL_FALSE);
|
SDL_CaptureMouse((bd->MouseButtonsDown != 0) ? SDL_TRUE : SDL_FALSE);
|
||||||
SDL_Window* focused_window = SDL_GetKeyboardFocus();
|
SDL_Window* focused_window = SDL_GetKeyboardFocus();
|
||||||
const bool is_app_focused = (bd->Window == focused_window);
|
const bool is_app_focused = (focused_window && (bd->Window == focused_window || ImGui_ImplSDL2_GetViewportForWindowID(SDL_GetWindowID(focused_window)) != NULL));
|
||||||
#else
|
#else
|
||||||
|
SDL_Window* focused_window = bd->Window;
|
||||||
const bool is_app_focused = (SDL_GetWindowFlags(bd->Window) & SDL_WINDOW_INPUT_FOCUS) != 0; // SDL 2.0.3 and non-windowed systems: single-viewport only
|
const bool is_app_focused = (SDL_GetWindowFlags(bd->Window) & SDL_WINDOW_INPUT_FOCUS) != 0; // SDL 2.0.3 and non-windowed systems: single-viewport only
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (is_app_focused)
|
if (is_app_focused)
|
||||||
{
|
{
|
||||||
// (Optional) Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
|
// (Optional) Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
|
||||||
if (io.WantSetMousePos)
|
if (io.WantSetMousePos)
|
||||||
SDL_WarpMouseInWindow(bd->Window, (int)io.MousePos.x, (int)io.MousePos.y);
|
{
|
||||||
|
#if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
SDL_WarpMouseGlobal((int)io.MousePos.x, (int)io.MousePos.y);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
SDL_WarpMouseInWindow(bd->Window, (int)io.MousePos.x, (int)io.MousePos.y);
|
||||||
|
}
|
||||||
|
|
||||||
// (Optional) Fallback to provide mouse position when focused (SDL_MOUSEMOTION already provides this when hovered or captured)
|
// (Optional) Fallback to provide mouse position when focused (SDL_MOUSEMOTION already provides this when hovered or captured)
|
||||||
if (bd->MouseCanUseGlobalState && bd->MouseButtonsDown == 0)
|
if (bd->MouseCanUseGlobalState && bd->MouseButtonsDown == 0)
|
||||||
{
|
{
|
||||||
int window_x, window_y, mouse_x_global, mouse_y_global;
|
// Single-viewport mode: mouse position in client window coordinates (io.MousePos is (0,0) when the mouse is on the upper-left corner of the app window)
|
||||||
SDL_GetGlobalMouseState(&mouse_x_global, &mouse_y_global);
|
// Multi-viewport mode: mouse position in OS absolute coordinates (io.MousePos is (0,0) when the mouse is on the upper-left of the primary monitor)
|
||||||
SDL_GetWindowPosition(bd->Window, &window_x, &window_y);
|
int mouse_x, mouse_y, window_x, window_y;
|
||||||
io.AddMousePosEvent((float)(mouse_x_global - window_x), (float)(mouse_y_global - window_y));
|
SDL_GetGlobalMouseState(&mouse_x, &mouse_y);
|
||||||
|
if (!(io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable))
|
||||||
|
{
|
||||||
|
SDL_GetWindowPosition(focused_window, &window_x, &window_y);
|
||||||
|
mouse_x -= window_x;
|
||||||
|
mouse_y -= window_y;
|
||||||
|
}
|
||||||
|
io.AddMousePosEvent((float)mouse_x, (float)mouse_y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// (Optional) When using multiple viewports: call io.AddMouseViewportEvent() with the viewport the OS mouse cursor is hovering.
|
||||||
|
// If ImGuiBackendFlags_HasMouseHoveredViewport is not set by the backend, Dear imGui will ignore this field and infer the information using its flawed heuristic.
|
||||||
|
// - [!] SDL backend does NOT correctly ignore viewports with the _NoInputs flag.
|
||||||
|
// Some backend are not able to handle that correctly. If a backend report an hovered viewport that has the _NoInputs flag (e.g. when dragging a window
|
||||||
|
// for docking, the viewport has the _NoInputs flag in order to allow us to find the viewport under), then Dear ImGui is forced to ignore the value reported
|
||||||
|
// by the backend, and use its flawed heuristic to guess the viewport behind.
|
||||||
|
// - [X] SDL backend correctly reports this regardless of another viewport behind focused and dragged from (we need this to find a useful drag and drop target).
|
||||||
|
if (io.BackendFlags & ImGuiBackendFlags_HasMouseHoveredViewport)
|
||||||
|
{
|
||||||
|
ImGuiID mouse_viewport_id = 0;
|
||||||
|
if (ImGuiViewport* mouse_viewport = ImGui_ImplSDL2_GetViewportForWindowID(bd->MouseWindowID))
|
||||||
|
mouse_viewport_id = mouse_viewport->ID;
|
||||||
|
io.AddMouseViewportEvent(mouse_viewport_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplSDL2_UpdateMouseCursor()
|
static void ImGui_ImplSDL2_UpdateMouseCursor()
|
||||||
@ -746,6 +844,43 @@ static void ImGui_ImplSDL2_UpdateGamepads()
|
|||||||
ImGui_ImplSDL2_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadRStickDown, SDL_CONTROLLER_AXIS_RIGHTY, +thumb_dead_zone, +32767);
|
ImGui_ImplSDL2_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadRStickDown, SDL_CONTROLLER_AXIS_RIGHTY, +thumb_dead_zone, +32767);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: Note that doesn't update with DPI/Scaling change only as SDL2 doesn't have an event for it (SDL3 has).
|
||||||
|
static void ImGui_ImplSDL2_UpdateMonitors()
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
platform_io.Monitors.resize(0);
|
||||||
|
bd->WantUpdateMonitors = false;
|
||||||
|
int display_count = SDL_GetNumVideoDisplays();
|
||||||
|
for (int n = 0; n < display_count; n++)
|
||||||
|
{
|
||||||
|
// Warning: the validity of monitor DPI information on Windows depends on the application DPI awareness settings, which generally needs to be set in the manifest or at runtime.
|
||||||
|
ImGuiPlatformMonitor monitor;
|
||||||
|
SDL_Rect r;
|
||||||
|
SDL_GetDisplayBounds(n, &r);
|
||||||
|
monitor.MainPos = monitor.WorkPos = ImVec2((float)r.x, (float)r.y);
|
||||||
|
monitor.MainSize = monitor.WorkSize = ImVec2((float)r.w, (float)r.h);
|
||||||
|
#if SDL_HAS_USABLE_DISPLAY_BOUNDS
|
||||||
|
SDL_GetDisplayUsableBounds(n, &r);
|
||||||
|
monitor.WorkPos = ImVec2((float)r.x, (float)r.y);
|
||||||
|
monitor.WorkSize = ImVec2((float)r.w, (float)r.h);
|
||||||
|
#endif
|
||||||
|
#if SDL_HAS_PER_MONITOR_DPI
|
||||||
|
// FIXME-VIEWPORT: On MacOS SDL reports actual monitor DPI scale, ignoring OS configuration. We may want to set
|
||||||
|
// DpiScale to cocoa_window.backingScaleFactor here.
|
||||||
|
float dpi = 0.0f;
|
||||||
|
if (!SDL_GetDisplayDPI(n, &dpi, nullptr, nullptr))
|
||||||
|
{
|
||||||
|
if (dpi <= 0.0f)
|
||||||
|
continue; // Some accessibility applications are declaring virtual monitors with a DPI of 0, see #7902.
|
||||||
|
monitor.DpiScale = dpi / 96.0f;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
monitor.PlatformHandle = (void*)(intptr_t)n;
|
||||||
|
platform_io.Monitors.push_back(monitor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ImGui_ImplSDL2_NewFrame()
|
void ImGui_ImplSDL2_NewFrame()
|
||||||
{
|
{
|
||||||
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
||||||
@ -766,6 +901,10 @@ void ImGui_ImplSDL2_NewFrame()
|
|||||||
if (w > 0 && h > 0)
|
if (w > 0 && h > 0)
|
||||||
io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h);
|
io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h);
|
||||||
|
|
||||||
|
// Update monitors
|
||||||
|
if (bd->WantUpdateMonitors)
|
||||||
|
ImGui_ImplSDL2_UpdateMonitors();
|
||||||
|
|
||||||
// Setup time step (we don't use SDL_GetTicks() because it is using millisecond resolution)
|
// Setup time step (we don't use SDL_GetTicks() because it is using millisecond resolution)
|
||||||
// (Accept SDL_GetPerformanceCounter() not returning a monotonically increasing value. Happens in VMs and Emscripten, see #6189, #6114, #3644)
|
// (Accept SDL_GetPerformanceCounter() not returning a monotonically increasing value. Happens in VMs and Emscripten, see #6189, #6114, #3644)
|
||||||
static Uint64 frequency = SDL_GetPerformanceFrequency();
|
static Uint64 frequency = SDL_GetPerformanceFrequency();
|
||||||
@ -782,6 +921,13 @@ void ImGui_ImplSDL2_NewFrame()
|
|||||||
io.AddMousePosEvent(-FLT_MAX, -FLT_MAX);
|
io.AddMousePosEvent(-FLT_MAX, -FLT_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Our io.AddMouseViewportEvent() calls will only be valid when not capturing.
|
||||||
|
// Technically speaking testing for 'bd->MouseButtonsDown == 0' would be more rigorous, but testing for payload reduces noise and potential side-effects.
|
||||||
|
if (bd->MouseCanReportHoveredViewport && ImGui::GetDragDropPayload() == nullptr)
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_HasMouseHoveredViewport;
|
||||||
|
else
|
||||||
|
io.BackendFlags &= ~ImGuiBackendFlags_HasMouseHoveredViewport;
|
||||||
|
|
||||||
ImGui_ImplSDL2_UpdateMouseData();
|
ImGui_ImplSDL2_UpdateMouseData();
|
||||||
ImGui_ImplSDL2_UpdateMouseCursor();
|
ImGui_ImplSDL2_UpdateMouseCursor();
|
||||||
|
|
||||||
@ -789,6 +935,256 @@ void ImGui_ImplSDL2_NewFrame()
|
|||||||
ImGui_ImplSDL2_UpdateGamepads();
|
ImGui_ImplSDL2_UpdateGamepads();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
|
||||||
|
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
|
||||||
|
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
|
||||||
|
struct ImGui_ImplSDL2_ViewportData
|
||||||
|
{
|
||||||
|
SDL_Window* Window;
|
||||||
|
Uint32 WindowID;
|
||||||
|
bool WindowOwned;
|
||||||
|
SDL_GLContext GLContext;
|
||||||
|
|
||||||
|
ImGui_ImplSDL2_ViewportData() { Window = nullptr; WindowID = 0; WindowOwned = false; GLContext = nullptr; }
|
||||||
|
~ImGui_ImplSDL2_ViewportData() { IM_ASSERT(Window == nullptr && GLContext == nullptr); }
|
||||||
|
};
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL2_CreateWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
||||||
|
ImGui_ImplSDL2_ViewportData* vd = IM_NEW(ImGui_ImplSDL2_ViewportData)();
|
||||||
|
viewport->PlatformUserData = vd;
|
||||||
|
|
||||||
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
|
ImGui_ImplSDL2_ViewportData* main_viewport_data = (ImGui_ImplSDL2_ViewportData*)main_viewport->PlatformUserData;
|
||||||
|
|
||||||
|
// Share GL resources with main context
|
||||||
|
bool use_opengl = (main_viewport_data->GLContext != nullptr);
|
||||||
|
SDL_GLContext backup_context = nullptr;
|
||||||
|
if (use_opengl)
|
||||||
|
{
|
||||||
|
backup_context = SDL_GL_GetCurrentContext();
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);
|
||||||
|
SDL_GL_MakeCurrent(main_viewport_data->Window, main_viewport_data->GLContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
Uint32 sdl_flags = 0;
|
||||||
|
sdl_flags |= use_opengl ? SDL_WINDOW_OPENGL : (bd->UseVulkan ? SDL_WINDOW_VULKAN : 0);
|
||||||
|
sdl_flags |= SDL_GetWindowFlags(bd->Window) & SDL_WINDOW_ALLOW_HIGHDPI;
|
||||||
|
sdl_flags |= SDL_WINDOW_HIDDEN;
|
||||||
|
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_NoDecoration) ? SDL_WINDOW_BORDERLESS : 0;
|
||||||
|
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_NoDecoration) ? 0 : SDL_WINDOW_RESIZABLE;
|
||||||
|
#if !defined(_WIN32)
|
||||||
|
// See SDL hack in ImGui_ImplSDL2_ShowWindow().
|
||||||
|
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_NoTaskBarIcon) ? SDL_WINDOW_SKIP_TASKBAR : 0;
|
||||||
|
#endif
|
||||||
|
#if SDL_HAS_ALWAYS_ON_TOP
|
||||||
|
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_TopMost) ? SDL_WINDOW_ALWAYS_ON_TOP : 0;
|
||||||
|
#endif
|
||||||
|
vd->Window = SDL_CreateWindow("No Title Yet", (int)viewport->Pos.x, (int)viewport->Pos.y, (int)viewport->Size.x, (int)viewport->Size.y, sdl_flags);
|
||||||
|
vd->WindowOwned = true;
|
||||||
|
if (use_opengl)
|
||||||
|
{
|
||||||
|
vd->GLContext = SDL_GL_CreateContext(vd->Window);
|
||||||
|
SDL_GL_SetSwapInterval(0);
|
||||||
|
}
|
||||||
|
if (use_opengl && backup_context)
|
||||||
|
SDL_GL_MakeCurrent(vd->Window, backup_context);
|
||||||
|
|
||||||
|
viewport->PlatformHandle = (void*)(intptr_t)SDL_GetWindowID(vd->Window);
|
||||||
|
viewport->PlatformHandleRaw = nullptr;
|
||||||
|
SDL_SysWMinfo info;
|
||||||
|
SDL_VERSION(&info.version);
|
||||||
|
if (SDL_GetWindowWMInfo(vd->Window, &info))
|
||||||
|
{
|
||||||
|
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
|
||||||
|
viewport->PlatformHandleRaw = info.info.win.window;
|
||||||
|
#elif defined(__APPLE__) && defined(SDL_VIDEO_DRIVER_COCOA)
|
||||||
|
viewport->PlatformHandleRaw = (void*)info.info.cocoa.window;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL2_DestroyWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
if (ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData)
|
||||||
|
{
|
||||||
|
if (vd->GLContext && vd->WindowOwned)
|
||||||
|
SDL_GL_DeleteContext(vd->GLContext);
|
||||||
|
if (vd->Window && vd->WindowOwned)
|
||||||
|
SDL_DestroyWindow(vd->Window);
|
||||||
|
vd->GLContext = nullptr;
|
||||||
|
vd->Window = nullptr;
|
||||||
|
IM_DELETE(vd);
|
||||||
|
}
|
||||||
|
viewport->PlatformUserData = viewport->PlatformHandle = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL2_ShowWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
|
||||||
|
#if defined(_WIN32)
|
||||||
|
HWND hwnd = (HWND)viewport->PlatformHandleRaw;
|
||||||
|
|
||||||
|
// SDL hack: Hide icon from task bar
|
||||||
|
// Note: SDL 2.0.6+ has a SDL_WINDOW_SKIP_TASKBAR flag which is supported under Windows but the way it create the window breaks our seamless transition.
|
||||||
|
if (viewport->Flags & ImGuiViewportFlags_NoTaskBarIcon)
|
||||||
|
{
|
||||||
|
LONG ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE);
|
||||||
|
ex_style &= ~WS_EX_APPWINDOW;
|
||||||
|
ex_style |= WS_EX_TOOLWINDOW;
|
||||||
|
::SetWindowLong(hwnd, GWL_EXSTYLE, ex_style);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if SDL_HAS_SHOW_WINDOW_ACTIVATION_HINT
|
||||||
|
SDL_SetHint(SDL_HINT_WINDOW_NO_ACTIVATION_WHEN_SHOWN, (viewport->Flags & ImGuiViewportFlags_NoFocusOnAppearing) ? "1" : "0");
|
||||||
|
#elif defined(_WIN32)
|
||||||
|
// SDL hack: SDL always activate/focus windows :/
|
||||||
|
if (viewport->Flags & ImGuiViewportFlags_NoFocusOnAppearing)
|
||||||
|
{
|
||||||
|
::ShowWindow(hwnd, SW_SHOWNA);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
SDL_ShowWindow(vd->Window);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ImVec2 ImGui_ImplSDL2_GetWindowPos(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
|
||||||
|
int x = 0, y = 0;
|
||||||
|
SDL_GetWindowPosition(vd->Window, &x, &y);
|
||||||
|
return ImVec2((float)x, (float)y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL2_SetWindowPos(ImGuiViewport* viewport, ImVec2 pos)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
|
||||||
|
SDL_SetWindowPosition(vd->Window, (int)pos.x, (int)pos.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ImVec2 ImGui_ImplSDL2_GetWindowSize(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
|
||||||
|
int w = 0, h = 0;
|
||||||
|
SDL_GetWindowSize(vd->Window, &w, &h);
|
||||||
|
return ImVec2((float)w, (float)h);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL2_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
|
||||||
|
SDL_SetWindowSize(vd->Window, (int)size.x, (int)size.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL2_SetWindowTitle(ImGuiViewport* viewport, const char* title)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
|
||||||
|
SDL_SetWindowTitle(vd->Window, title);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if SDL_HAS_WINDOW_ALPHA
|
||||||
|
static void ImGui_ImplSDL2_SetWindowAlpha(ImGuiViewport* viewport, float alpha)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
|
||||||
|
SDL_SetWindowOpacity(vd->Window, alpha);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL2_SetWindowFocus(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
|
||||||
|
SDL_RaiseWindow(vd->Window);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ImGui_ImplSDL2_GetWindowFocus(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
|
||||||
|
return (SDL_GetWindowFlags(vd->Window) & SDL_WINDOW_INPUT_FOCUS) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ImGui_ImplSDL2_GetWindowMinimized(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
|
||||||
|
return (SDL_GetWindowFlags(vd->Window) & SDL_WINDOW_MINIMIZED) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL2_RenderWindow(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
|
||||||
|
if (vd->GLContext)
|
||||||
|
SDL_GL_MakeCurrent(vd->Window, vd->GLContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL2_SwapBuffers(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
|
||||||
|
if (vd->GLContext)
|
||||||
|
{
|
||||||
|
SDL_GL_MakeCurrent(vd->Window, vd->GLContext);
|
||||||
|
SDL_GL_SwapWindow(vd->Window);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Vulkan support (the Vulkan renderer needs to call a platform-side support function to create the surface)
|
||||||
|
// SDL is graceful enough to _not_ need <vulkan/vulkan.h> so we can safely include this.
|
||||||
|
#if SDL_HAS_VULKAN
|
||||||
|
#include <SDL_vulkan.h>
|
||||||
|
static int ImGui_ImplSDL2_CreateVkSurface(ImGuiViewport* viewport, ImU64 vk_instance, const void* vk_allocator, ImU64* out_vk_surface)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
|
||||||
|
(void)vk_allocator;
|
||||||
|
SDL_bool ret = SDL_Vulkan_CreateSurface(vd->Window, (VkInstance)vk_instance, (VkSurfaceKHR*)out_vk_surface);
|
||||||
|
return ret ? 0 : 1; // ret ? VK_SUCCESS : VK_NOT_READY
|
||||||
|
}
|
||||||
|
#endif // SDL_HAS_VULKAN
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL2_InitPlatformInterface(SDL_Window* window, void* sdl_gl_context)
|
||||||
|
{
|
||||||
|
// Register platform interface (will be coupled with a renderer interface)
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
platform_io.Platform_CreateWindow = ImGui_ImplSDL2_CreateWindow;
|
||||||
|
platform_io.Platform_DestroyWindow = ImGui_ImplSDL2_DestroyWindow;
|
||||||
|
platform_io.Platform_ShowWindow = ImGui_ImplSDL2_ShowWindow;
|
||||||
|
platform_io.Platform_SetWindowPos = ImGui_ImplSDL2_SetWindowPos;
|
||||||
|
platform_io.Platform_GetWindowPos = ImGui_ImplSDL2_GetWindowPos;
|
||||||
|
platform_io.Platform_SetWindowSize = ImGui_ImplSDL2_SetWindowSize;
|
||||||
|
platform_io.Platform_GetWindowSize = ImGui_ImplSDL2_GetWindowSize;
|
||||||
|
platform_io.Platform_SetWindowFocus = ImGui_ImplSDL2_SetWindowFocus;
|
||||||
|
platform_io.Platform_GetWindowFocus = ImGui_ImplSDL2_GetWindowFocus;
|
||||||
|
platform_io.Platform_GetWindowMinimized = ImGui_ImplSDL2_GetWindowMinimized;
|
||||||
|
platform_io.Platform_SetWindowTitle = ImGui_ImplSDL2_SetWindowTitle;
|
||||||
|
platform_io.Platform_RenderWindow = ImGui_ImplSDL2_RenderWindow;
|
||||||
|
platform_io.Platform_SwapBuffers = ImGui_ImplSDL2_SwapBuffers;
|
||||||
|
#if SDL_HAS_WINDOW_ALPHA
|
||||||
|
platform_io.Platform_SetWindowAlpha = ImGui_ImplSDL2_SetWindowAlpha;
|
||||||
|
#endif
|
||||||
|
#if SDL_HAS_VULKAN
|
||||||
|
platform_io.Platform_CreateVkSurface = ImGui_ImplSDL2_CreateVkSurface;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Register main window handle (which is owned by the main application, not by us)
|
||||||
|
// This is mostly for simplicity and consistency, so that our code (e.g. mouse handling etc.) can use same logic for main and secondary viewports.
|
||||||
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
|
ImGui_ImplSDL2_ViewportData* vd = IM_NEW(ImGui_ImplSDL2_ViewportData)();
|
||||||
|
vd->Window = window;
|
||||||
|
vd->WindowID = SDL_GetWindowID(window);
|
||||||
|
vd->WindowOwned = false;
|
||||||
|
vd->GLContext = sdl_gl_context;
|
||||||
|
main_viewport->PlatformUserData = vd;
|
||||||
|
main_viewport->PlatformHandle = (void*)(intptr_t)vd->WindowID;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL2_ShutdownPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGui::DestroyPlatformWindows();
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
|
@ -8,7 +8,11 @@
|
|||||||
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
// [X] Platform: Basic IME support. App needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!.
|
// [X] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
// Issues:
|
||||||
|
// [ ] Platform: Multi-viewport: Minimized windows seems to break mouse wheel events (at least under Windows).
|
||||||
|
// [ ] Platform: Multi-viewport: ParentViewportID not honored, and so io.ConfigViewportsNoDefaultParent has no effect (minor).
|
||||||
|
// [x] Platform: Basic IME support. App needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
|
@ -10,6 +10,10 @@
|
|||||||
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
|
// [x] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable' -> the OS animation effect when window gets created/destroyed is problematic. SDL2 backend doesn't have issue.
|
||||||
|
// Issues:
|
||||||
|
// [ ] Platform: Multi-viewport: Minimized windows seems to break mouse wheel events (at least under Windows).
|
||||||
|
// [ ] Platform: Multi-viewport: ParentViewportID not honored, and so io.ConfigViewportsNoDefaultParent has no effect (minor).
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
@ -21,6 +25,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
// 2024-09-03: Update for SDL3 api changes: SDL_GetGamepads() memory ownership revert. (#7918, #7898, #7807)
|
// 2024-09-03: Update for SDL3 api changes: SDL_GetGamepads() memory ownership revert. (#7918, #7898, #7807)
|
||||||
// 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO:
|
// 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO:
|
||||||
// - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn
|
// - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn
|
||||||
@ -91,6 +96,8 @@ struct ImGui_ImplSDL3_Data
|
|||||||
SDL_Renderer* Renderer;
|
SDL_Renderer* Renderer;
|
||||||
Uint64 Time;
|
Uint64 Time;
|
||||||
char* ClipboardTextData;
|
char* ClipboardTextData;
|
||||||
|
bool UseVulkan;
|
||||||
|
bool WantUpdateMonitors;
|
||||||
|
|
||||||
// IME handling
|
// IME handling
|
||||||
SDL_Window* ImeWindow;
|
SDL_Window* ImeWindow;
|
||||||
@ -102,11 +109,12 @@ struct ImGui_ImplSDL3_Data
|
|||||||
SDL_Cursor* MouseLastCursor;
|
SDL_Cursor* MouseLastCursor;
|
||||||
int MousePendingLeaveFrame;
|
int MousePendingLeaveFrame;
|
||||||
bool MouseCanUseGlobalState;
|
bool MouseCanUseGlobalState;
|
||||||
|
bool MouseCanReportHoveredViewport; // This is hard to use/unreliable on SDL so we'll set ImGuiBackendFlags_HasMouseHoveredViewport dynamically based on state.
|
||||||
|
|
||||||
// Gamepad handling
|
// Gamepad handling
|
||||||
ImVector<SDL_Gamepad*> Gamepads;
|
ImVector<SDL_Gamepad*> Gamepads;
|
||||||
ImGui_ImplSDL3_GamepadMode GamepadMode;
|
ImGui_ImplSDL3_GamepadMode GamepadMode;
|
||||||
bool WantUpdateGamepadsList;
|
bool WantUpdateGamepadsList;
|
||||||
|
|
||||||
ImGui_ImplSDL3_Data() { memset((void*)this, 0, sizeof(*this)); }
|
ImGui_ImplSDL3_Data() { memset((void*)this, 0, sizeof(*this)); }
|
||||||
};
|
};
|
||||||
@ -120,6 +128,11 @@ static ImGui_ImplSDL3_Data* ImGui_ImplSDL3_GetBackendData()
|
|||||||
return ImGui::GetCurrentContext() ? (ImGui_ImplSDL3_Data*)ImGui::GetIO().BackendPlatformUserData : nullptr;
|
return ImGui::GetCurrentContext() ? (ImGui_ImplSDL3_Data*)ImGui::GetIO().BackendPlatformUserData : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
static void ImGui_ImplSDL3_UpdateMonitors();
|
||||||
|
static void ImGui_ImplSDL3_InitPlatformInterface(SDL_Window* window, void* sdl_gl_context);
|
||||||
|
static void ImGui_ImplSDL3_ShutdownPlatformInterface();
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
static const char* ImGui_ImplSDL3_GetClipboardText(ImGuiContext*)
|
static const char* ImGui_ImplSDL3_GetClipboardText(ImGuiContext*)
|
||||||
{
|
{
|
||||||
@ -149,8 +162,8 @@ static void ImGui_ImplSDL3_PlatformSetImeData(ImGuiContext*, ImGuiViewport* view
|
|||||||
if (data->WantVisible)
|
if (data->WantVisible)
|
||||||
{
|
{
|
||||||
SDL_Rect r;
|
SDL_Rect r;
|
||||||
r.x = (int)data->InputPos.x;
|
r.x = (int)(data->InputPos.x - viewport->Pos.x);
|
||||||
r.y = (int)data->InputPos.y;
|
r.y = (int)(data->InputPos.y - viewport->Pos.y + data->InputLineHeight);
|
||||||
r.w = 1;
|
r.w = 1;
|
||||||
r.h = (int)data->InputLineHeight;
|
r.h = (int)data->InputLineHeight;
|
||||||
SDL_SetTextInputArea(window, &r, 0);
|
SDL_SetTextInputArea(window, &r, 0);
|
||||||
@ -301,18 +314,15 @@ static void ImGui_ImplSDL3_UpdateKeyModifiers(SDL_Keymod sdl_key_mods)
|
|||||||
io.AddKeyEvent(ImGuiMod_Super, (sdl_key_mods & SDL_KMOD_GUI) != 0);
|
io.AddKeyEvent(ImGuiMod_Super, (sdl_key_mods & SDL_KMOD_GUI) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ImGuiViewport* ImGui_ImplSDL3_GetViewportForWindowID(SDL_WindowID window_id)
|
static ImGuiViewport* ImGui_ImplSDL3_GetViewportForWindowID(SDL_WindowID window_id)
|
||||||
{
|
{
|
||||||
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
return ImGui::FindViewportByPlatformHandle((void*)(intptr_t)window_id);
|
||||||
return (window_id == bd->WindowID) ? ImGui::GetMainViewport() : NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
|
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
|
||||||
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application, or clear/overwrite your copy of the mouse data.
|
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application, or clear/overwrite your copy of the mouse data.
|
||||||
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application, or clear/overwrite your copy of the keyboard data.
|
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application, or clear/overwrite your copy of the keyboard data.
|
||||||
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
|
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
|
||||||
// If you have multiple SDL events and some of them are not meant to be used by dear imgui, you may need to filter events based on their windowID field.
|
|
||||||
bool ImGui_ImplSDL3_ProcessEvent(const SDL_Event* event)
|
bool ImGui_ImplSDL3_ProcessEvent(const SDL_Event* event)
|
||||||
{
|
{
|
||||||
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
||||||
@ -326,6 +336,13 @@ bool ImGui_ImplSDL3_ProcessEvent(const SDL_Event* event)
|
|||||||
if (ImGui_ImplSDL3_GetViewportForWindowID(event->motion.windowID) == NULL)
|
if (ImGui_ImplSDL3_GetViewportForWindowID(event->motion.windowID) == NULL)
|
||||||
return false;
|
return false;
|
||||||
ImVec2 mouse_pos((float)event->motion.x, (float)event->motion.y);
|
ImVec2 mouse_pos((float)event->motion.x, (float)event->motion.y);
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
int window_x, window_y;
|
||||||
|
SDL_GetWindowPosition(SDL_GetWindowFromID(event->motion.windowID), &window_x, &window_y);
|
||||||
|
mouse_pos.x += window_x;
|
||||||
|
mouse_pos.y += window_y;
|
||||||
|
}
|
||||||
io.AddMouseSourceEvent(event->motion.which == SDL_TOUCH_MOUSEID ? ImGuiMouseSource_TouchScreen : ImGuiMouseSource_Mouse);
|
io.AddMouseSourceEvent(event->motion.which == SDL_TOUCH_MOUSEID ? ImGuiMouseSource_TouchScreen : ImGuiMouseSource_Mouse);
|
||||||
io.AddMousePosEvent(mouse_pos.x, mouse_pos.y);
|
io.AddMousePosEvent(mouse_pos.x, mouse_pos.y);
|
||||||
return true;
|
return true;
|
||||||
@ -381,6 +398,15 @@ bool ImGui_ImplSDL3_ProcessEvent(const SDL_Event* event)
|
|||||||
io.SetKeyEventNativeData(key, event->key.key, event->key.scancode, event->key.scancode); // To support legacy indexing (<1.87 user code). Legacy backend uses SDLK_*** as indices to IsKeyXXX() functions.
|
io.SetKeyEventNativeData(key, event->key.key, event->key.scancode, event->key.scancode); // To support legacy indexing (<1.87 user code). Legacy backend uses SDLK_*** as indices to IsKeyXXX() functions.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
case SDL_EVENT_DISPLAY_ORIENTATION:
|
||||||
|
case SDL_EVENT_DISPLAY_ADDED:
|
||||||
|
case SDL_EVENT_DISPLAY_REMOVED:
|
||||||
|
case SDL_EVENT_DISPLAY_MOVED:
|
||||||
|
case SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED:
|
||||||
|
{
|
||||||
|
bd->WantUpdateMonitors = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
case SDL_EVENT_WINDOW_MOUSE_ENTER:
|
case SDL_EVENT_WINDOW_MOUSE_ENTER:
|
||||||
{
|
{
|
||||||
if (ImGui_ImplSDL3_GetViewportForWindowID(event->window.windowID) == NULL)
|
if (ImGui_ImplSDL3_GetViewportForWindowID(event->window.windowID) == NULL)
|
||||||
@ -408,6 +434,21 @@ bool ImGui_ImplSDL3_ProcessEvent(const SDL_Event* event)
|
|||||||
io.AddFocusEvent(event->type == SDL_EVENT_WINDOW_FOCUS_GAINED);
|
io.AddFocusEvent(event->type == SDL_EVENT_WINDOW_FOCUS_GAINED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
case SDL_EVENT_WINDOW_CLOSE_REQUESTED:
|
||||||
|
case SDL_EVENT_WINDOW_MOVED:
|
||||||
|
case SDL_EVENT_WINDOW_RESIZED:
|
||||||
|
{
|
||||||
|
ImGuiViewport* viewport = ImGui_ImplSDL3_GetViewportForWindowID(event->window.windowID);
|
||||||
|
if (viewport == NULL)
|
||||||
|
return false;
|
||||||
|
if (event->type == SDL_EVENT_WINDOW_CLOSE_REQUESTED)
|
||||||
|
viewport->PlatformRequestClose = true;
|
||||||
|
if (event->type == SDL_EVENT_WINDOW_MOVED)
|
||||||
|
viewport->PlatformRequestMove = true;
|
||||||
|
if (event->type == SDL_EVENT_WINDOW_RESIZED)
|
||||||
|
viewport->PlatformRequestResize = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
case SDL_EVENT_GAMEPAD_ADDED:
|
case SDL_EVENT_GAMEPAD_ADDED:
|
||||||
case SDL_EVENT_GAMEPAD_REMOVED:
|
case SDL_EVENT_GAMEPAD_REMOVED:
|
||||||
{
|
{
|
||||||
@ -453,11 +494,22 @@ static bool ImGui_ImplSDL3_Init(SDL_Window* window, SDL_Renderer* renderer, void
|
|||||||
io.BackendPlatformName = "imgui_impl_sdl3";
|
io.BackendPlatformName = "imgui_impl_sdl3";
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
||||||
|
if (mouse_can_use_global_state)
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports; // We can create multi-viewports on the Platform side (optional)
|
||||||
|
|
||||||
bd->Window = window;
|
bd->Window = window;
|
||||||
bd->WindowID = SDL_GetWindowID(window);
|
bd->WindowID = SDL_GetWindowID(window);
|
||||||
bd->Renderer = renderer;
|
bd->Renderer = renderer;
|
||||||
|
|
||||||
|
// SDL on Linux/OSX doesn't report events for unfocused windows (see https://github.com/ocornut/imgui/issues/4960)
|
||||||
|
// We will use 'MouseCanReportHoveredViewport' to set 'ImGuiBackendFlags_HasMouseHoveredViewport' dynamically each frame.
|
||||||
bd->MouseCanUseGlobalState = mouse_can_use_global_state;
|
bd->MouseCanUseGlobalState = mouse_can_use_global_state;
|
||||||
|
#ifndef __APPLE__
|
||||||
|
bd->MouseCanReportHoveredViewport = bd->MouseCanUseGlobalState;
|
||||||
|
#else
|
||||||
|
bd->MouseCanReportHoveredViewport = false;
|
||||||
|
#endif
|
||||||
|
bd->WantUpdateMonitors = true;
|
||||||
|
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
platform_io.Platform_SetClipboardTextFn = ImGui_ImplSDL3_SetClipboardText;
|
platform_io.Platform_SetClipboardTextFn = ImGui_ImplSDL3_SetClipboardText;
|
||||||
@ -489,27 +541,35 @@ static bool ImGui_ImplSDL3_Init(SDL_Window* window, SDL_Renderer* renderer, void
|
|||||||
// (This is unfortunately a global SDL setting, so enabling it might have a side-effect on your application.
|
// (This is unfortunately a global SDL setting, so enabling it might have a side-effect on your application.
|
||||||
// It is unlikely to make a difference, but if your app absolutely needs to ignore the initial on-focus click:
|
// It is unlikely to make a difference, but if your app absolutely needs to ignore the initial on-focus click:
|
||||||
// you can ignore SDL_EVENT_MOUSE_BUTTON_DOWN events coming right after a SDL_WINDOWEVENT_FOCUS_GAINED)
|
// you can ignore SDL_EVENT_MOUSE_BUTTON_DOWN events coming right after a SDL_WINDOWEVENT_FOCUS_GAINED)
|
||||||
#ifdef SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH
|
|
||||||
SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1");
|
SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1");
|
||||||
#endif
|
|
||||||
|
|
||||||
// From 2.0.22: Disable auto-capture, this is preventing drag and drop across multiple windows (see #5710)
|
// From 2.0.22: Disable auto-capture, this is preventing drag and drop across multiple windows (see #5710)
|
||||||
#ifdef SDL_HINT_MOUSE_AUTO_CAPTURE
|
|
||||||
SDL_SetHint(SDL_HINT_MOUSE_AUTO_CAPTURE, "0");
|
SDL_SetHint(SDL_HINT_MOUSE_AUTO_CAPTURE, "0");
|
||||||
#endif
|
|
||||||
|
// SDL 3.x : see https://github.com/libsdl-org/SDL/issues/6659
|
||||||
|
SDL_SetHint("SDL_BORDERLESS_WINDOWED_STYLE", "0");
|
||||||
|
|
||||||
|
// We need SDL_CaptureMouse(), SDL_GetGlobalMouseState() from SDL 2.0.4+ to support multiple viewports.
|
||||||
|
// We left the call to ImGui_ImplSDL3_InitPlatformInterface() outside of #ifdef to avoid unused-function warnings.
|
||||||
|
if ((io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) && (io.BackendFlags & ImGuiBackendFlags_PlatformHasViewports))
|
||||||
|
ImGui_ImplSDL3_InitPlatformInterface(window, sdl_gl_context);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Should technically be a SDL_GLContext but due to typedef it is sane to keep it void* in public interface.
|
||||||
bool ImGui_ImplSDL3_InitForOpenGL(SDL_Window* window, void* sdl_gl_context)
|
bool ImGui_ImplSDL3_InitForOpenGL(SDL_Window* window, void* sdl_gl_context)
|
||||||
{
|
{
|
||||||
IM_UNUSED(sdl_gl_context); // Viewport branch will need this.
|
|
||||||
return ImGui_ImplSDL3_Init(window, nullptr, sdl_gl_context);
|
return ImGui_ImplSDL3_Init(window, nullptr, sdl_gl_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplSDL3_InitForVulkan(SDL_Window* window)
|
bool ImGui_ImplSDL3_InitForVulkan(SDL_Window* window)
|
||||||
{
|
{
|
||||||
return ImGui_ImplSDL3_Init(window, nullptr, nullptr);
|
if (!ImGui_ImplSDL3_Init(window, nullptr, nullptr))
|
||||||
|
return false;
|
||||||
|
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
||||||
|
bd->UseVulkan = true;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplSDL3_InitForD3D(SDL_Window* window)
|
bool ImGui_ImplSDL3_InitForD3D(SDL_Window* window)
|
||||||
@ -543,6 +603,8 @@ void ImGui_ImplSDL3_Shutdown()
|
|||||||
IM_ASSERT(bd != nullptr && "No platform backend to shutdown, or already shutdown?");
|
IM_ASSERT(bd != nullptr && "No platform backend to shutdown, or already shutdown?");
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
ImGui_ImplSDL3_ShutdownPlatformInterface();
|
||||||
|
|
||||||
if (bd->ClipboardTextData)
|
if (bd->ClipboardTextData)
|
||||||
SDL_free(bd->ClipboardTextData);
|
SDL_free(bd->ClipboardTextData);
|
||||||
for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++)
|
for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++)
|
||||||
@ -551,10 +613,11 @@ void ImGui_ImplSDL3_Shutdown()
|
|||||||
|
|
||||||
io.BackendPlatformName = nullptr;
|
io.BackendPlatformName = nullptr;
|
||||||
io.BackendPlatformUserData = nullptr;
|
io.BackendPlatformUserData = nullptr;
|
||||||
io.BackendFlags &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasSetMousePos | ImGuiBackendFlags_HasGamepad);
|
io.BackendFlags &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasSetMousePos | ImGuiBackendFlags_HasGamepad | ImGuiBackendFlags_PlatformHasViewports | ImGuiBackendFlags_HasMouseHoveredViewport);
|
||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This code is incredibly messy because some of the functions we need for full viewport support are not available in SDL < 2.0.4.
|
||||||
static void ImGui_ImplSDL3_UpdateMouseData()
|
static void ImGui_ImplSDL3_UpdateMouseData()
|
||||||
{
|
{
|
||||||
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
||||||
@ -565,7 +628,7 @@ static void ImGui_ImplSDL3_UpdateMouseData()
|
|||||||
// SDL_CaptureMouse() let the OS know e.g. that our imgui drag outside the SDL window boundaries shouldn't e.g. trigger other operations outside
|
// SDL_CaptureMouse() let the OS know e.g. that our imgui drag outside the SDL window boundaries shouldn't e.g. trigger other operations outside
|
||||||
SDL_CaptureMouse((bd->MouseButtonsDown != 0) ? SDL_TRUE : SDL_FALSE);
|
SDL_CaptureMouse((bd->MouseButtonsDown != 0) ? SDL_TRUE : SDL_FALSE);
|
||||||
SDL_Window* focused_window = SDL_GetKeyboardFocus();
|
SDL_Window* focused_window = SDL_GetKeyboardFocus();
|
||||||
const bool is_app_focused = (bd->Window == focused_window);
|
const bool is_app_focused = (focused_window && (bd->Window == focused_window || ImGui_ImplSDL3_GetViewportForWindowID(SDL_GetWindowID(focused_window)) != NULL));
|
||||||
#else
|
#else
|
||||||
SDL_Window* focused_window = bd->Window;
|
SDL_Window* focused_window = bd->Window;
|
||||||
const bool is_app_focused = (SDL_GetWindowFlags(bd->Window) & SDL_WINDOW_INPUT_FOCUS) != 0; // SDL 2.0.3 and non-windowed systems: single-viewport only
|
const bool is_app_focused = (SDL_GetWindowFlags(bd->Window) & SDL_WINDOW_INPUT_FOCUS) != 0; // SDL 2.0.3 and non-windowed systems: single-viewport only
|
||||||
@ -574,19 +637,47 @@ static void ImGui_ImplSDL3_UpdateMouseData()
|
|||||||
{
|
{
|
||||||
// (Optional) Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
|
// (Optional) Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
|
||||||
if (io.WantSetMousePos)
|
if (io.WantSetMousePos)
|
||||||
SDL_WarpMouseInWindow(bd->Window, io.MousePos.x, io.MousePos.y);
|
{
|
||||||
|
#if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
SDL_WarpMouseGlobal(io.MousePos.x, io.MousePos.y);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
SDL_WarpMouseInWindow(bd->Window, io.MousePos.x, io.MousePos.y);
|
||||||
|
}
|
||||||
|
|
||||||
// (Optional) Fallback to provide mouse position when focused (SDL_EVENT_MOUSE_MOTION already provides this when hovered or captured)
|
// (Optional) Fallback to provide mouse position when focused (SDL_EVENT_MOUSE_MOTION already provides this when hovered or captured)
|
||||||
if (bd->MouseCanUseGlobalState && bd->MouseButtonsDown == 0)
|
if (bd->MouseCanUseGlobalState && bd->MouseButtonsDown == 0)
|
||||||
{
|
{
|
||||||
// Single-viewport mode: mouse position in client window coordinates (io.MousePos is (0,0) when the mouse is on the upper-left corner of the app window)
|
// Single-viewport mode: mouse position in client window coordinates (io.MousePos is (0,0) when the mouse is on the upper-left corner of the app window)
|
||||||
float mouse_x_global, mouse_y_global;
|
// Multi-viewport mode: mouse position in OS absolute coordinates (io.MousePos is (0,0) when the mouse is on the upper-left of the primary monitor)
|
||||||
|
float mouse_x, mouse_y;
|
||||||
int window_x, window_y;
|
int window_x, window_y;
|
||||||
SDL_GetGlobalMouseState(&mouse_x_global, &mouse_y_global);
|
SDL_GetGlobalMouseState(&mouse_x, &mouse_y);
|
||||||
SDL_GetWindowPosition(focused_window, &window_x, &window_y);
|
if (!(io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable))
|
||||||
io.AddMousePosEvent(mouse_x_global - window_x, mouse_y_global - window_y);
|
{
|
||||||
|
SDL_GetWindowPosition(focused_window, &window_x, &window_y);
|
||||||
|
mouse_x -= window_x;
|
||||||
|
mouse_y -= window_y;
|
||||||
|
}
|
||||||
|
io.AddMousePosEvent((float)mouse_x, (float)mouse_y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// (Optional) When using multiple viewports: call io.AddMouseViewportEvent() with the viewport the OS mouse cursor is hovering.
|
||||||
|
// If ImGuiBackendFlags_HasMouseHoveredViewport is not set by the backend, Dear imGui will ignore this field and infer the information using its flawed heuristic.
|
||||||
|
// - [!] SDL backend does NOT correctly ignore viewports with the _NoInputs flag.
|
||||||
|
// Some backend are not able to handle that correctly. If a backend report an hovered viewport that has the _NoInputs flag (e.g. when dragging a window
|
||||||
|
// for docking, the viewport has the _NoInputs flag in order to allow us to find the viewport under), then Dear ImGui is forced to ignore the value reported
|
||||||
|
// by the backend, and use its flawed heuristic to guess the viewport behind.
|
||||||
|
// - [X] SDL backend correctly reports this regardless of another viewport behind focused and dragged from (we need this to find a useful drag and drop target).
|
||||||
|
if (io.BackendFlags & ImGuiBackendFlags_HasMouseHoveredViewport)
|
||||||
|
{
|
||||||
|
ImGuiID mouse_viewport_id = 0;
|
||||||
|
if (ImGuiViewport* mouse_viewport = ImGui_ImplSDL3_GetViewportForWindowID(bd->MouseWindowID))
|
||||||
|
mouse_viewport_id = mouse_viewport->ID;
|
||||||
|
io.AddMouseViewportEvent(mouse_viewport_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplSDL3_UpdateMouseCursor()
|
static void ImGui_ImplSDL3_UpdateMouseCursor()
|
||||||
@ -721,6 +812,38 @@ static void ImGui_ImplSDL3_UpdateGamepads()
|
|||||||
ImGui_ImplSDL3_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadRStickDown, SDL_GAMEPAD_AXIS_RIGHTY, +thumb_dead_zone, +32767);
|
ImGui_ImplSDL3_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadRStickDown, SDL_GAMEPAD_AXIS_RIGHTY, +thumb_dead_zone, +32767);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL3_UpdateMonitors()
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
platform_io.Monitors.resize(0);
|
||||||
|
bd->WantUpdateMonitors = false;
|
||||||
|
|
||||||
|
int display_count;
|
||||||
|
SDL_DisplayID* displays = SDL_GetDisplays(&display_count);
|
||||||
|
for (int n = 0; n < display_count; n++)
|
||||||
|
{
|
||||||
|
// Warning: the validity of monitor DPI information on Windows depends on the application DPI awareness settings, which generally needs to be set in the manifest or at runtime.
|
||||||
|
SDL_DisplayID display_id = displays[n];
|
||||||
|
ImGuiPlatformMonitor monitor;
|
||||||
|
SDL_Rect r;
|
||||||
|
SDL_GetDisplayBounds(display_id, &r);
|
||||||
|
monitor.MainPos = monitor.WorkPos = ImVec2((float)r.x, (float)r.y);
|
||||||
|
monitor.MainSize = monitor.WorkSize = ImVec2((float)r.w, (float)r.h);
|
||||||
|
SDL_GetDisplayUsableBounds(display_id, &r);
|
||||||
|
monitor.WorkPos = ImVec2((float)r.x, (float)r.y);
|
||||||
|
monitor.WorkSize = ImVec2((float)r.w, (float)r.h);
|
||||||
|
// FIXME-VIEWPORT: On MacOS SDL reports actual monitor DPI scale, ignoring OS configuration. We may want to set
|
||||||
|
// DpiScale to cocoa_window.backingScaleFactor here.
|
||||||
|
monitor.DpiScale = SDL_GetDisplayContentScale(display_id);
|
||||||
|
monitor.PlatformHandle = (void*)(intptr_t)n;
|
||||||
|
if (monitor.DpiScale <= 0.0f)
|
||||||
|
continue; // Some accessibility applications are declaring virtual monitors with a DPI of 0, see #7902.
|
||||||
|
platform_io.Monitors.push_back(monitor);
|
||||||
|
}
|
||||||
|
SDL_free(displays);
|
||||||
|
}
|
||||||
|
|
||||||
void ImGui_ImplSDL3_NewFrame()
|
void ImGui_ImplSDL3_NewFrame()
|
||||||
{
|
{
|
||||||
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
||||||
@ -738,6 +861,10 @@ void ImGui_ImplSDL3_NewFrame()
|
|||||||
if (w > 0 && h > 0)
|
if (w > 0 && h > 0)
|
||||||
io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h);
|
io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h);
|
||||||
|
|
||||||
|
// Update monitors
|
||||||
|
if (bd->WantUpdateMonitors)
|
||||||
|
ImGui_ImplSDL3_UpdateMonitors();
|
||||||
|
|
||||||
// Setup time step (we don't use SDL_GetTicks() because it is using millisecond resolution)
|
// Setup time step (we don't use SDL_GetTicks() because it is using millisecond resolution)
|
||||||
// (Accept SDL_GetPerformanceCounter() not returning a monotonically increasing value. Happens in VMs and Emscripten, see #6189, #6114, #3644)
|
// (Accept SDL_GetPerformanceCounter() not returning a monotonically increasing value. Happens in VMs and Emscripten, see #6189, #6114, #3644)
|
||||||
static Uint64 frequency = SDL_GetPerformanceFrequency();
|
static Uint64 frequency = SDL_GetPerformanceFrequency();
|
||||||
@ -754,6 +881,13 @@ void ImGui_ImplSDL3_NewFrame()
|
|||||||
io.AddMousePosEvent(-FLT_MAX, -FLT_MAX);
|
io.AddMousePosEvent(-FLT_MAX, -FLT_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Our io.AddMouseViewportEvent() calls will only be valid when not capturing.
|
||||||
|
// Technically speaking testing for 'bd->MouseButtonsDown == 0' would be more rigorous, but testing for payload reduces noise and potential side-effects.
|
||||||
|
if (bd->MouseCanReportHoveredViewport && ImGui::GetDragDropPayload() == nullptr)
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_HasMouseHoveredViewport;
|
||||||
|
else
|
||||||
|
io.BackendFlags &= ~ImGuiBackendFlags_HasMouseHoveredViewport;
|
||||||
|
|
||||||
ImGui_ImplSDL3_UpdateMouseData();
|
ImGui_ImplSDL3_UpdateMouseData();
|
||||||
ImGui_ImplSDL3_UpdateMouseCursor();
|
ImGui_ImplSDL3_UpdateMouseCursor();
|
||||||
|
|
||||||
@ -761,6 +895,226 @@ void ImGui_ImplSDL3_NewFrame()
|
|||||||
ImGui_ImplSDL3_UpdateGamepads();
|
ImGui_ImplSDL3_UpdateGamepads();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
|
||||||
|
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
|
||||||
|
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
|
||||||
|
struct ImGui_ImplSDL3_ViewportData
|
||||||
|
{
|
||||||
|
SDL_Window* Window;
|
||||||
|
Uint32 WindowID;
|
||||||
|
bool WindowOwned;
|
||||||
|
SDL_GLContext GLContext;
|
||||||
|
|
||||||
|
ImGui_ImplSDL3_ViewportData() { Window = nullptr; WindowID = 0; WindowOwned = false; GLContext = nullptr; }
|
||||||
|
~ImGui_ImplSDL3_ViewportData() { IM_ASSERT(Window == nullptr && GLContext == nullptr); }
|
||||||
|
};
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL3_CreateWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
||||||
|
ImGui_ImplSDL3_ViewportData* vd = IM_NEW(ImGui_ImplSDL3_ViewportData)();
|
||||||
|
viewport->PlatformUserData = vd;
|
||||||
|
|
||||||
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
|
ImGui_ImplSDL3_ViewportData* main_viewport_data = (ImGui_ImplSDL3_ViewportData*)main_viewport->PlatformUserData;
|
||||||
|
|
||||||
|
// Share GL resources with main context
|
||||||
|
bool use_opengl = (main_viewport_data->GLContext != nullptr);
|
||||||
|
SDL_GLContext backup_context = nullptr;
|
||||||
|
if (use_opengl)
|
||||||
|
{
|
||||||
|
backup_context = SDL_GL_GetCurrentContext();
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);
|
||||||
|
SDL_GL_MakeCurrent(main_viewport_data->Window, main_viewport_data->GLContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
Uint32 sdl_flags = 0;
|
||||||
|
sdl_flags |= use_opengl ? SDL_WINDOW_OPENGL : (bd->UseVulkan ? SDL_WINDOW_VULKAN : 0);
|
||||||
|
sdl_flags |= SDL_GetWindowFlags(bd->Window);
|
||||||
|
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_NoDecoration) ? SDL_WINDOW_BORDERLESS : 0;
|
||||||
|
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_NoDecoration) ? 0 : SDL_WINDOW_RESIZABLE;
|
||||||
|
#if !defined(_WIN32)
|
||||||
|
// See SDL hack in ImGui_ImplSDL3_ShowWindow().
|
||||||
|
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_NoTaskBarIcon) ? SDL_WINDOW_UTILITY : 0;
|
||||||
|
#endif
|
||||||
|
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_TopMost) ? SDL_WINDOW_ALWAYS_ON_TOP : 0;
|
||||||
|
vd->Window = SDL_CreateWindow("No Title Yet", (int)viewport->Size.x, (int)viewport->Size.y, sdl_flags);
|
||||||
|
SDL_SetWindowPosition(vd->Window, (int)viewport->Pos.x, (int)viewport->Pos.y);
|
||||||
|
vd->WindowOwned = true;
|
||||||
|
if (use_opengl)
|
||||||
|
{
|
||||||
|
vd->GLContext = SDL_GL_CreateContext(vd->Window);
|
||||||
|
SDL_GL_SetSwapInterval(0);
|
||||||
|
}
|
||||||
|
if (use_opengl && backup_context)
|
||||||
|
SDL_GL_MakeCurrent(vd->Window, backup_context);
|
||||||
|
|
||||||
|
ImGui_ImplSDL3_SetupPlatformHandles(viewport, vd->Window);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL3_DestroyWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
if (ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData)
|
||||||
|
{
|
||||||
|
if (vd->GLContext && vd->WindowOwned)
|
||||||
|
SDL_GL_DestroyContext(vd->GLContext);
|
||||||
|
if (vd->Window && vd->WindowOwned)
|
||||||
|
SDL_DestroyWindow(vd->Window);
|
||||||
|
vd->GLContext = nullptr;
|
||||||
|
vd->Window = nullptr;
|
||||||
|
IM_DELETE(vd);
|
||||||
|
}
|
||||||
|
viewport->PlatformUserData = viewport->PlatformHandle = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL3_ShowWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
|
||||||
|
#if defined(_WIN32)
|
||||||
|
HWND hwnd = (HWND)viewport->PlatformHandleRaw;
|
||||||
|
|
||||||
|
// SDL hack: Hide icon from task bar
|
||||||
|
// Note: SDL 3.0.0+ has a SDL_WINDOW_UTILITY flag which is supported under Windows but the way it create the window breaks our seamless transition.
|
||||||
|
if (viewport->Flags & ImGuiViewportFlags_NoTaskBarIcon)
|
||||||
|
{
|
||||||
|
LONG ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE);
|
||||||
|
ex_style &= ~WS_EX_APPWINDOW;
|
||||||
|
ex_style |= WS_EX_TOOLWINDOW;
|
||||||
|
::SetWindowLong(hwnd, GWL_EXSTYLE, ex_style);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
SDL_SetHint(SDL_HINT_WINDOW_ACTIVATE_WHEN_SHOWN, (viewport->Flags & ImGuiViewportFlags_NoFocusOnAppearing) ? "0" : "1");
|
||||||
|
SDL_ShowWindow(vd->Window);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ImVec2 ImGui_ImplSDL3_GetWindowPos(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
|
||||||
|
int x = 0, y = 0;
|
||||||
|
SDL_GetWindowPosition(vd->Window, &x, &y);
|
||||||
|
return ImVec2((float)x, (float)y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL3_SetWindowPos(ImGuiViewport* viewport, ImVec2 pos)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
|
||||||
|
SDL_SetWindowPosition(vd->Window, (int)pos.x, (int)pos.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ImVec2 ImGui_ImplSDL3_GetWindowSize(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
|
||||||
|
int w = 0, h = 0;
|
||||||
|
SDL_GetWindowSize(vd->Window, &w, &h);
|
||||||
|
return ImVec2((float)w, (float)h);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL3_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
|
||||||
|
SDL_SetWindowSize(vd->Window, (int)size.x, (int)size.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL3_SetWindowTitle(ImGuiViewport* viewport, const char* title)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
|
||||||
|
SDL_SetWindowTitle(vd->Window, title);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL3_SetWindowAlpha(ImGuiViewport* viewport, float alpha)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
|
||||||
|
SDL_SetWindowOpacity(vd->Window, alpha);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL3_SetWindowFocus(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
|
||||||
|
SDL_RaiseWindow(vd->Window);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ImGui_ImplSDL3_GetWindowFocus(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
|
||||||
|
return (SDL_GetWindowFlags(vd->Window) & SDL_WINDOW_INPUT_FOCUS) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ImGui_ImplSDL3_GetWindowMinimized(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
|
||||||
|
return (SDL_GetWindowFlags(vd->Window) & SDL_WINDOW_MINIMIZED) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL3_RenderWindow(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
|
||||||
|
if (vd->GLContext)
|
||||||
|
SDL_GL_MakeCurrent(vd->Window, vd->GLContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL3_SwapBuffers(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
|
||||||
|
if (vd->GLContext)
|
||||||
|
{
|
||||||
|
SDL_GL_MakeCurrent(vd->Window, vd->GLContext);
|
||||||
|
SDL_GL_SwapWindow(vd->Window);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Vulkan support (the Vulkan renderer needs to call a platform-side support function to create the surface)
|
||||||
|
// SDL is graceful enough to _not_ need <vulkan/vulkan.h> so we can safely include this.
|
||||||
|
#include <SDL3/SDL_vulkan.h>
|
||||||
|
static int ImGui_ImplSDL3_CreateVkSurface(ImGuiViewport* viewport, ImU64 vk_instance, const void* vk_allocator, ImU64* out_vk_surface)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL3_ViewportData* vd = (ImGui_ImplSDL3_ViewportData*)viewport->PlatformUserData;
|
||||||
|
(void)vk_allocator;
|
||||||
|
SDL_bool ret = SDL_Vulkan_CreateSurface(vd->Window, (VkInstance)vk_instance, (VkAllocationCallbacks*)vk_allocator, (VkSurfaceKHR*)out_vk_surface);
|
||||||
|
return ret ? 0 : 1; // ret ? VK_SUCCESS : VK_NOT_READY
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL3_InitPlatformInterface(SDL_Window* window, void* sdl_gl_context)
|
||||||
|
{
|
||||||
|
// Register platform interface (will be coupled with a renderer interface)
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
platform_io.Platform_CreateWindow = ImGui_ImplSDL3_CreateWindow;
|
||||||
|
platform_io.Platform_DestroyWindow = ImGui_ImplSDL3_DestroyWindow;
|
||||||
|
platform_io.Platform_ShowWindow = ImGui_ImplSDL3_ShowWindow;
|
||||||
|
platform_io.Platform_SetWindowPos = ImGui_ImplSDL3_SetWindowPos;
|
||||||
|
platform_io.Platform_GetWindowPos = ImGui_ImplSDL3_GetWindowPos;
|
||||||
|
platform_io.Platform_SetWindowSize = ImGui_ImplSDL3_SetWindowSize;
|
||||||
|
platform_io.Platform_GetWindowSize = ImGui_ImplSDL3_GetWindowSize;
|
||||||
|
platform_io.Platform_SetWindowFocus = ImGui_ImplSDL3_SetWindowFocus;
|
||||||
|
platform_io.Platform_GetWindowFocus = ImGui_ImplSDL3_GetWindowFocus;
|
||||||
|
platform_io.Platform_GetWindowMinimized = ImGui_ImplSDL3_GetWindowMinimized;
|
||||||
|
platform_io.Platform_SetWindowTitle = ImGui_ImplSDL3_SetWindowTitle;
|
||||||
|
platform_io.Platform_RenderWindow = ImGui_ImplSDL3_RenderWindow;
|
||||||
|
platform_io.Platform_SwapBuffers = ImGui_ImplSDL3_SwapBuffers;
|
||||||
|
platform_io.Platform_SetWindowAlpha = ImGui_ImplSDL3_SetWindowAlpha;
|
||||||
|
platform_io.Platform_CreateVkSurface = ImGui_ImplSDL3_CreateVkSurface;
|
||||||
|
|
||||||
|
// Register main window handle (which is owned by the main application, not by us)
|
||||||
|
// This is mostly for simplicity and consistency, so that our code (e.g. mouse handling etc.) can use same logic for main and secondary viewports.
|
||||||
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
|
ImGui_ImplSDL3_ViewportData* vd = IM_NEW(ImGui_ImplSDL3_ViewportData)();
|
||||||
|
vd->Window = window;
|
||||||
|
vd->WindowID = SDL_GetWindowID(window);
|
||||||
|
vd->WindowOwned = false;
|
||||||
|
vd->GLContext = (SDL_GLContext)sdl_gl_context;
|
||||||
|
main_viewport->PlatformUserData = vd;
|
||||||
|
main_viewport->PlatformHandle = (void*)(intptr_t)vd->WindowID;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDL3_ShutdownPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGui::DestroyPlatformWindows();
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
|
@ -10,6 +10,11 @@
|
|||||||
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
|
// [x] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable' -> the OS animation effect when window gets created/destroyed is problematic. SDL2 backend doesn't have issue.
|
||||||
|
// Issues:
|
||||||
|
// [ ] Platform: Multi-viewport: Minimized windows seems to break mouse wheel events (at least under Windows).
|
||||||
|
// [ ] Platform: Multi-viewport: ParentViewportID not honored, and so io.ConfigViewportsNoDefaultParent has no effect (minor).
|
||||||
|
// [x] Platform: Basic IME support. Position somehow broken in SDL3 + app needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'SDL_Texture*' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'SDL_Texture*' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// Missing features:
|
||||||
|
// [ ] Renderer: Multi-viewport support (multiple windows).
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'SDL_Texture*' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'SDL_Texture*' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// Missing features:
|
||||||
|
// [ ] Renderer: Multi-viewport support (multiple windows).
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
|
@ -12,6 +12,9 @@
|
|||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'SDL_Texture*' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'SDL_Texture*' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// [X] Renderer: Multi-viewport support (multiple windows).
|
||||||
|
// FIXME: Missing way to share textures betweens renderers: shttps://github.com/libsdl-org/SDL/issues/6742
|
||||||
|
// FIXME: Missing way to specify a projection matrix, so our vertices in absolute coordinates are not displayed correctly in multi-viewports mode.
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
@ -22,6 +25,7 @@
|
|||||||
// - Introduction, links and more at the top of imgui.cpp
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
|
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface. (#5835)
|
||||||
// 2024-07-01: Update for SDL3 api changes: SDL_RenderGeometryRaw() uint32 version was removed (SDL#9009).
|
// 2024-07-01: Update for SDL3 api changes: SDL_RenderGeometryRaw() uint32 version was removed (SDL#9009).
|
||||||
// 2024-05-14: *BREAKING CHANGE* ImGui_ImplSDLRenderer3_RenderDrawData() requires SDL_Renderer* passed as parameter.
|
// 2024-05-14: *BREAKING CHANGE* ImGui_ImplSDLRenderer3_RenderDrawData() requires SDL_Renderer* passed as parameter.
|
||||||
// 2024-02-12: Amend to query SDL_RenderViewportSet() and restore viewport accordingly.
|
// 2024-02-12: Amend to query SDL_RenderViewportSet() and restore viewport accordingly.
|
||||||
@ -49,7 +53,8 @@ struct ImGui_ImplSDLRenderer3_Data
|
|||||||
{
|
{
|
||||||
SDL_Renderer* Renderer; // Main viewport's renderer
|
SDL_Renderer* Renderer; // Main viewport's renderer
|
||||||
SDL_Texture* FontTexture;
|
SDL_Texture* FontTexture;
|
||||||
ImVector<SDL_FColor> ColorBuffer;
|
ImVector<SDL_FColor> ColorBuffer; // Transformed color buffer
|
||||||
|
ImVector<ImVec2> PosBuffer; // Transformed pos buffer (for multi-viewports only)
|
||||||
|
|
||||||
ImGui_ImplSDLRenderer3_Data() { memset((void*)this, 0, sizeof(*this)); }
|
ImGui_ImplSDLRenderer3_Data() { memset((void*)this, 0, sizeof(*this)); }
|
||||||
};
|
};
|
||||||
@ -61,6 +66,10 @@ static ImGui_ImplSDLRenderer3_Data* ImGui_ImplSDLRenderer3_GetBackendData()
|
|||||||
return ImGui::GetCurrentContext() ? (ImGui_ImplSDLRenderer3_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
return ImGui::GetCurrentContext() ? (ImGui_ImplSDLRenderer3_Data*)ImGui::GetIO().BackendRendererUserData : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
static void ImGui_ImplSDLRenderer3_InitPlatformInterface();
|
||||||
|
static void ImGui_ImplSDLRenderer3_ShutdownPlatformInterface();
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
bool ImGui_ImplSDLRenderer3_Init(SDL_Renderer* renderer)
|
bool ImGui_ImplSDLRenderer3_Init(SDL_Renderer* renderer)
|
||||||
{
|
{
|
||||||
@ -74,9 +83,13 @@ bool ImGui_ImplSDLRenderer3_Init(SDL_Renderer* renderer)
|
|||||||
io.BackendRendererUserData = (void*)bd;
|
io.BackendRendererUserData = (void*)bd;
|
||||||
io.BackendRendererName = "imgui_impl_sdlrenderer3";
|
io.BackendRendererName = "imgui_impl_sdlrenderer3";
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasViewports; // We can create multi-viewports on the Renderer side (optional)
|
||||||
|
|
||||||
bd->Renderer = renderer;
|
bd->Renderer = renderer;
|
||||||
|
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
ImGui_ImplSDLRenderer3_InitPlatformInterface();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,6 +99,7 @@ void ImGui_ImplSDLRenderer3_Shutdown()
|
|||||||
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
ImGui_ImplSDLRenderer3_ShutdownPlatformInterface();
|
||||||
ImGui_ImplSDLRenderer3_DestroyDeviceObjects();
|
ImGui_ImplSDLRenderer3_DestroyDeviceObjects();
|
||||||
|
|
||||||
io.BackendRendererName = nullptr;
|
io.BackendRendererName = nullptr;
|
||||||
@ -203,13 +217,32 @@ void ImGui_ImplSDLRenderer3_RenderDrawData(ImDrawData* draw_data, SDL_Renderer*
|
|||||||
SDL_SetRenderClipRect(renderer, &r);
|
SDL_SetRenderClipRect(renderer, &r);
|
||||||
|
|
||||||
const float* xy = (const float*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, pos));
|
const float* xy = (const float*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, pos));
|
||||||
|
int xy_stride = (int)sizeof(ImDrawVert);
|
||||||
const float* uv = (const float*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, uv));
|
const float* uv = (const float*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, uv));
|
||||||
const SDL_Color* color = (const SDL_Color*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, col)); // SDL 2.0.19+
|
const SDL_Color* color = (const SDL_Color*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, col)); // SDL 2.0.19+
|
||||||
|
|
||||||
|
// FIXME-OPT: Transform position manually
|
||||||
|
// FIXME-OPT: Note that SDL_RenderGeometryRaw() does another transform for colors..
|
||||||
|
if (draw_data->DisplayPos.x != 0.0f || draw_data->DisplayPos.y != 0.0f)
|
||||||
|
{
|
||||||
|
const float off_x = draw_data->DisplayPos.x;
|
||||||
|
const float off_y = draw_data->DisplayPos.y;
|
||||||
|
bd->PosBuffer.resize(pcmd->ElemCount);
|
||||||
|
const ImDrawVert* p_in = vtx_buffer + pcmd->VtxOffset;
|
||||||
|
ImVec2* p_out = bd->PosBuffer.Data;
|
||||||
|
for (int remaining = pcmd->ElemCount; remaining > 0; remaining--, p_out++, p_in++)
|
||||||
|
{
|
||||||
|
p_out->x = p_in->pos.x - off_x;
|
||||||
|
p_out->y = p_in->pos.y - off_y;
|
||||||
|
}
|
||||||
|
xy = (const float*)bd->PosBuffer.Data;
|
||||||
|
xy_stride = (int)sizeof(ImVec2);
|
||||||
|
}
|
||||||
|
|
||||||
// Bind texture, Draw
|
// Bind texture, Draw
|
||||||
SDL_Texture* tex = (SDL_Texture*)pcmd->GetTexID();
|
SDL_Texture* tex = (SDL_Texture*)pcmd->GetTexID();
|
||||||
SDL_RenderGeometryRaw8BitColor(renderer, bd->ColorBuffer, tex,
|
SDL_RenderGeometryRaw8BitColor(renderer, bd->ColorBuffer, tex,
|
||||||
xy, (int)sizeof(ImDrawVert),
|
xy, xy_stride,
|
||||||
color, (int)sizeof(ImDrawVert),
|
color, (int)sizeof(ImDrawVert),
|
||||||
uv, (int)sizeof(ImDrawVert),
|
uv, (int)sizeof(ImDrawVert),
|
||||||
cmd_list->VtxBuffer.Size - pcmd->VtxOffset,
|
cmd_list->VtxBuffer.Size - pcmd->VtxOffset,
|
||||||
@ -274,6 +307,77 @@ void ImGui_ImplSDLRenderer3_DestroyDeviceObjects()
|
|||||||
ImGui_ImplSDLRenderer3_DestroyFontsTexture();
|
ImGui_ImplSDLRenderer3_DestroyFontsTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
|
||||||
|
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
|
||||||
|
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
|
||||||
|
struct ImGui_ImplSDLRenderer3_ViewportData
|
||||||
|
{
|
||||||
|
SDL_Renderer* Renderer;
|
||||||
|
|
||||||
|
ImGui_ImplSDLRenderer3_ViewportData() { Renderer = nullptr; }
|
||||||
|
~ImGui_ImplSDLRenderer3_ViewportData() { IM_ASSERT(Renderer == nullptr); }
|
||||||
|
};
|
||||||
|
|
||||||
|
static void ImGui_ImplSDLRenderer3_CreateWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
//ImGui_ImplSDLRenderer3_Data* bd = ImGui_ImplSDLRenderer3_GetBackendData();
|
||||||
|
ImGui_ImplSDLRenderer3_ViewportData* vd = IM_NEW(ImGui_ImplSDLRenderer3_ViewportData)();
|
||||||
|
viewport->RendererUserData = vd;
|
||||||
|
|
||||||
|
SDL_Window* window = (SDL_Window*)viewport->PlatformHandle;
|
||||||
|
vd->Renderer = SDL_CreateRenderer(window, nullptr);
|
||||||
|
SDL_SetRenderVSync(vd->Renderer, 0);
|
||||||
|
IM_ASSERT(vd->Renderer != NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDLRenderer3_DestroyWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
// The main viewport (owned by the application) will always have RendererUserData == nullptr since we didn't create the data for it.
|
||||||
|
if (ImGui_ImplSDLRenderer3_ViewportData* vd = (ImGui_ImplSDLRenderer3_ViewportData*)viewport->RendererUserData)
|
||||||
|
{
|
||||||
|
SDL_DestroyRenderer(vd->Renderer);
|
||||||
|
vd->Renderer = nullptr;
|
||||||
|
IM_DELETE(vd);
|
||||||
|
}
|
||||||
|
viewport->RendererUserData = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDLRenderer3_RenderWindow(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDLRenderer3_ViewportData* vd = (ImGui_ImplSDLRenderer3_ViewportData*)viewport->RendererUserData;
|
||||||
|
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
|
||||||
|
{
|
||||||
|
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
SDL_SetRenderDrawColor(vd->Renderer, (Uint8)(clear_color.x * 255), (Uint8)(clear_color.y * 255), (Uint8)(clear_color.z * 255), (Uint8)(clear_color.w * 255));
|
||||||
|
SDL_RenderClear(vd->Renderer);
|
||||||
|
}
|
||||||
|
ImGui_ImplSDLRenderer3_RenderDrawData(viewport->DrawData, vd->Renderer);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDLRenderer3_SwapBuffers(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGui_ImplSDLRenderer3_ViewportData* vd = (ImGui_ImplSDLRenderer3_ViewportData*)viewport->RendererUserData;
|
||||||
|
SDL_RenderPresent(vd->Renderer);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDLRenderer3_InitPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
platform_io.Renderer_CreateWindow = ImGui_ImplSDLRenderer3_CreateWindow;
|
||||||
|
platform_io.Renderer_DestroyWindow = ImGui_ImplSDLRenderer3_DestroyWindow;
|
||||||
|
platform_io.Renderer_RenderWindow = ImGui_ImplSDLRenderer3_RenderWindow;
|
||||||
|
platform_io.Renderer_SwapBuffers = ImGui_ImplSDLRenderer3_SwapBuffers;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplSDLRenderer3_ShutdownPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGui::DestroyPlatformWindows();
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'SDL_Texture*' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'SDL_Texture*' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// [X] Renderer: Multi-viewport support (multiple windows).
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
|
@ -2,8 +2,9 @@
|
|||||||
// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..)
|
// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [!] Renderer: User texture binding. Use 'VkDescriptorSet' as ImTextureID. Read the FAQ about ImTextureID! See https://github.com/ocornut/imgui/pull/914 for discussions.
|
// [x] Renderer: User texture binding. Use 'VkDescriptorSet' as ImTextureID. Read the FAQ about ImTextureID! See https://github.com/ocornut/imgui/pull/914 for discussions.
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// [x] Renderer: Multi-viewport / platform windows. With issues (flickering when creating a new viewport).
|
||||||
|
|
||||||
// Important: on 32-bit systems, user texture binding is only supported if your imconfig file has '#define ImTextureID ImU64'.
|
// Important: on 32-bit systems, user texture binding is only supported if your imconfig file has '#define ImTextureID ImU64'.
|
||||||
// This is because we need ImTextureID to carry a 64-bit value and by default ImTextureID is defined as void*.
|
// This is because we need ImTextureID to carry a 64-bit value and by default ImTextureID is defined as void*.
|
||||||
@ -33,6 +34,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
// 2024-04-19: Vulkan: Added convenience support for Volk via IMGUI_IMPL_VULKAN_USE_VOLK define (you can also use IMGUI_IMPL_VULKAN_NO_PROTOTYPES + wrap Volk via ImGui_ImplVulkan_LoadFunctions().)
|
// 2024-04-19: Vulkan: Added convenience support for Volk via IMGUI_IMPL_VULKAN_USE_VOLK define (you can also use IMGUI_IMPL_VULKAN_NO_PROTOTYPES + wrap Volk via ImGui_ImplVulkan_LoadFunctions().)
|
||||||
// 2024-02-14: *BREAKING CHANGE*: Moved RenderPass parameter from ImGui_ImplVulkan_Init() function to ImGui_ImplVulkan_InitInfo structure. Not required when using dynamic rendering.
|
// 2024-02-14: *BREAKING CHANGE*: Moved RenderPass parameter from ImGui_ImplVulkan_Init() function to ImGui_ImplVulkan_InitInfo structure. Not required when using dynamic rendering.
|
||||||
// 2024-02-12: *BREAKING CHANGE*: Dynamic rendering now require filling PipelineRenderingCreateInfo structure.
|
// 2024-02-12: *BREAKING CHANGE*: Dynamic rendering now require filling PipelineRenderingCreateInfo structure.
|
||||||
@ -104,6 +106,7 @@ void ImGui_ImplVulkan_DestroyFrameRenderBuffers(VkDevice device, ImGui_ImplVulka
|
|||||||
void ImGui_ImplVulkan_DestroyWindowRenderBuffers(VkDevice device, ImGui_ImplVulkan_WindowRenderBuffers* buffers, const VkAllocationCallbacks* allocator);
|
void ImGui_ImplVulkan_DestroyWindowRenderBuffers(VkDevice device, ImGui_ImplVulkan_WindowRenderBuffers* buffers, const VkAllocationCallbacks* allocator);
|
||||||
void ImGui_ImplVulkanH_DestroyFrame(VkDevice device, ImGui_ImplVulkanH_Frame* fd, const VkAllocationCallbacks* allocator);
|
void ImGui_ImplVulkanH_DestroyFrame(VkDevice device, ImGui_ImplVulkanH_Frame* fd, const VkAllocationCallbacks* allocator);
|
||||||
void ImGui_ImplVulkanH_DestroyFrameSemaphores(VkDevice device, ImGui_ImplVulkanH_FrameSemaphores* fsd, const VkAllocationCallbacks* allocator);
|
void ImGui_ImplVulkanH_DestroyFrameSemaphores(VkDevice device, ImGui_ImplVulkanH_FrameSemaphores* fsd, const VkAllocationCallbacks* allocator);
|
||||||
|
void ImGui_ImplVulkanH_DestroyAllViewportsRenderBuffers(VkDevice device, const VkAllocationCallbacks* allocator);
|
||||||
void ImGui_ImplVulkanH_CreateWindowSwapChain(VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wd, const VkAllocationCallbacks* allocator, int w, int h, uint32_t min_image_count);
|
void ImGui_ImplVulkanH_CreateWindowSwapChain(VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wd, const VkAllocationCallbacks* allocator, int w, int h, uint32_t min_image_count);
|
||||||
void ImGui_ImplVulkanH_CreateWindowCommandBuffers(VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wd, uint32_t queue_family, const VkAllocationCallbacks* allocator);
|
void ImGui_ImplVulkanH_CreateWindowCommandBuffers(VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wd, uint32_t queue_family, const VkAllocationCallbacks* allocator);
|
||||||
|
|
||||||
@ -120,15 +123,18 @@ static bool g_FunctionsLoaded = true;
|
|||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkAllocateCommandBuffers) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkAllocateCommandBuffers) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkAllocateDescriptorSets) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkAllocateDescriptorSets) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkAllocateMemory) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkAllocateMemory) \
|
||||||
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkAcquireNextImageKHR) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkBeginCommandBuffer) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkBeginCommandBuffer) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkBindBufferMemory) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkBindBufferMemory) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkBindImageMemory) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkBindImageMemory) \
|
||||||
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdBeginRenderPass) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdBindDescriptorSets) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdBindDescriptorSets) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdBindIndexBuffer) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdBindIndexBuffer) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdBindPipeline) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdBindPipeline) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdBindVertexBuffers) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdBindVertexBuffers) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdCopyBufferToImage) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdCopyBufferToImage) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdDrawIndexed) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdDrawIndexed) \
|
||||||
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdEndRenderPass) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdPipelineBarrier) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdPipelineBarrier) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdPushConstants) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdPushConstants) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdSetScissor) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdSetScissor) \
|
||||||
@ -174,13 +180,17 @@ static bool g_FunctionsLoaded = true;
|
|||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkGetPhysicalDeviceSurfaceCapabilitiesKHR) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkGetPhysicalDeviceSurfaceCapabilitiesKHR) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkGetPhysicalDeviceSurfaceFormatsKHR) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkGetPhysicalDeviceSurfaceFormatsKHR) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkGetPhysicalDeviceSurfacePresentModesKHR) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkGetPhysicalDeviceSurfacePresentModesKHR) \
|
||||||
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkGetPhysicalDeviceSurfaceSupportKHR) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkGetSwapchainImagesKHR) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkGetSwapchainImagesKHR) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkMapMemory) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkMapMemory) \
|
||||||
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkQueuePresentKHR) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkQueueSubmit) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkQueueSubmit) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkQueueWaitIdle) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkQueueWaitIdle) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkResetCommandPool) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkResetCommandPool) \
|
||||||
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkResetFences) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkUnmapMemory) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkUnmapMemory) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkUpdateDescriptorSets)
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkUpdateDescriptorSets) \
|
||||||
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkWaitForFences)
|
||||||
|
|
||||||
// Define function pointers
|
// Define function pointers
|
||||||
#define IMGUI_VULKAN_FUNC_DEF(func) static PFN_##func func;
|
#define IMGUI_VULKAN_FUNC_DEF(func) static PFN_##func func;
|
||||||
@ -214,6 +224,19 @@ struct ImGui_ImplVulkan_WindowRenderBuffers
|
|||||||
ImGui_ImplVulkan_FrameRenderBuffers* FrameRenderBuffers;
|
ImGui_ImplVulkan_FrameRenderBuffers* FrameRenderBuffers;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// For multi-viewport support:
|
||||||
|
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
|
||||||
|
struct ImGui_ImplVulkan_ViewportData
|
||||||
|
{
|
||||||
|
ImGui_ImplVulkanH_Window Window; // Used by secondary viewports only
|
||||||
|
ImGui_ImplVulkan_WindowRenderBuffers RenderBuffers; // Used by all viewports
|
||||||
|
bool WindowOwned;
|
||||||
|
bool SwapChainNeedRebuild; // Flag when viewport swapchain resized in the middle of processing a frame
|
||||||
|
|
||||||
|
ImGui_ImplVulkan_ViewportData() { WindowOwned = SwapChainNeedRebuild = false; memset(&RenderBuffers, 0, sizeof(RenderBuffers)); }
|
||||||
|
~ImGui_ImplVulkan_ViewportData() { }
|
||||||
|
};
|
||||||
|
|
||||||
// Vulkan data
|
// Vulkan data
|
||||||
struct ImGui_ImplVulkan_Data
|
struct ImGui_ImplVulkan_Data
|
||||||
{
|
{
|
||||||
@ -222,7 +245,8 @@ struct ImGui_ImplVulkan_Data
|
|||||||
VkPipelineCreateFlags PipelineCreateFlags;
|
VkPipelineCreateFlags PipelineCreateFlags;
|
||||||
VkDescriptorSetLayout DescriptorSetLayout;
|
VkDescriptorSetLayout DescriptorSetLayout;
|
||||||
VkPipelineLayout PipelineLayout;
|
VkPipelineLayout PipelineLayout;
|
||||||
VkPipeline Pipeline;
|
VkPipeline Pipeline; // pipeline for main render pass (created by app)
|
||||||
|
VkPipeline PipelineForViewports; // pipeline for secondary viewports (created by backend)
|
||||||
VkShaderModule ShaderModuleVert;
|
VkShaderModule ShaderModuleVert;
|
||||||
VkShaderModule ShaderModuleFrag;
|
VkShaderModule ShaderModuleFrag;
|
||||||
|
|
||||||
@ -249,6 +273,10 @@ struct ImGui_ImplVulkan_Data
|
|||||||
// SHADERS
|
// SHADERS
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
static void ImGui_ImplVulkan_InitPlatformInterface();
|
||||||
|
static void ImGui_ImplVulkan_ShutdownPlatformInterface();
|
||||||
|
|
||||||
// backends/vulkan/glsl_shader.vert, compiled with:
|
// backends/vulkan/glsl_shader.vert, compiled with:
|
||||||
// # glslangValidator -V -x -o glsl_shader.vert.u32 glsl_shader.vert
|
// # glslangValidator -V -x -o glsl_shader.vert.u32 glsl_shader.vert
|
||||||
/*
|
/*
|
||||||
@ -486,8 +514,10 @@ void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer comm
|
|||||||
if (pipeline == VK_NULL_HANDLE)
|
if (pipeline == VK_NULL_HANDLE)
|
||||||
pipeline = bd->Pipeline;
|
pipeline = bd->Pipeline;
|
||||||
|
|
||||||
// Allocate array to store enough vertex/index buffers
|
// Allocate array to store enough vertex/index buffers. Each unique viewport gets its own storage.
|
||||||
ImGui_ImplVulkan_WindowRenderBuffers* wrb = &bd->MainWindowRenderBuffers;
|
ImGui_ImplVulkan_ViewportData* viewport_renderer_data = (ImGui_ImplVulkan_ViewportData*)draw_data->OwnerViewport->RendererUserData;
|
||||||
|
IM_ASSERT(viewport_renderer_data != nullptr);
|
||||||
|
ImGui_ImplVulkan_WindowRenderBuffers* wrb = &viewport_renderer_data->RenderBuffers;
|
||||||
if (wrb->FrameRenderBuffers == nullptr)
|
if (wrb->FrameRenderBuffers == nullptr)
|
||||||
{
|
{
|
||||||
wrb->Index = 0;
|
wrb->Index = 0;
|
||||||
@ -1032,7 +1062,7 @@ void ImGui_ImplVulkan_DestroyDeviceObjects()
|
|||||||
{
|
{
|
||||||
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
||||||
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
||||||
ImGui_ImplVulkan_DestroyWindowRenderBuffers(v->Device, &bd->MainWindowRenderBuffers, v->Allocator);
|
ImGui_ImplVulkanH_DestroyAllViewportsRenderBuffers(v->Device, v->Allocator);
|
||||||
ImGui_ImplVulkan_DestroyFontsTexture();
|
ImGui_ImplVulkan_DestroyFontsTexture();
|
||||||
|
|
||||||
if (bd->FontCommandBuffer) { vkFreeCommandBuffers(v->Device, bd->FontCommandPool, 1, &bd->FontCommandBuffer); bd->FontCommandBuffer = VK_NULL_HANDLE; }
|
if (bd->FontCommandBuffer) { vkFreeCommandBuffers(v->Device, bd->FontCommandPool, 1, &bd->FontCommandBuffer); bd->FontCommandBuffer = VK_NULL_HANDLE; }
|
||||||
@ -1043,6 +1073,7 @@ void ImGui_ImplVulkan_DestroyDeviceObjects()
|
|||||||
if (bd->DescriptorSetLayout) { vkDestroyDescriptorSetLayout(v->Device, bd->DescriptorSetLayout, v->Allocator); bd->DescriptorSetLayout = VK_NULL_HANDLE; }
|
if (bd->DescriptorSetLayout) { vkDestroyDescriptorSetLayout(v->Device, bd->DescriptorSetLayout, v->Allocator); bd->DescriptorSetLayout = VK_NULL_HANDLE; }
|
||||||
if (bd->PipelineLayout) { vkDestroyPipelineLayout(v->Device, bd->PipelineLayout, v->Allocator); bd->PipelineLayout = VK_NULL_HANDLE; }
|
if (bd->PipelineLayout) { vkDestroyPipelineLayout(v->Device, bd->PipelineLayout, v->Allocator); bd->PipelineLayout = VK_NULL_HANDLE; }
|
||||||
if (bd->Pipeline) { vkDestroyPipeline(v->Device, bd->Pipeline, v->Allocator); bd->Pipeline = VK_NULL_HANDLE; }
|
if (bd->Pipeline) { vkDestroyPipeline(v->Device, bd->Pipeline, v->Allocator); bd->Pipeline = VK_NULL_HANDLE; }
|
||||||
|
if (bd->PipelineForViewports) { vkDestroyPipeline(v->Device, bd->PipelineForViewports, v->Allocator); bd->PipelineForViewports = VK_NULL_HANDLE; }
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplVulkan_LoadFunctions(PFN_vkVoidFunction(*loader_func)(const char* function_name, void* user_data), void* user_data)
|
bool ImGui_ImplVulkan_LoadFunctions(PFN_vkVoidFunction(*loader_func)(const char* function_name, void* user_data), void* user_data)
|
||||||
@ -1100,6 +1131,7 @@ bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info)
|
|||||||
io.BackendRendererUserData = (void*)bd;
|
io.BackendRendererUserData = (void*)bd;
|
||||||
io.BackendRendererName = "imgui_impl_vulkan";
|
io.BackendRendererName = "imgui_impl_vulkan";
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasViewports; // We can create multi-viewports on the Renderer side (optional)
|
||||||
|
|
||||||
IM_ASSERT(info->Instance != VK_NULL_HANDLE);
|
IM_ASSERT(info->Instance != VK_NULL_HANDLE);
|
||||||
IM_ASSERT(info->PhysicalDevice != VK_NULL_HANDLE);
|
IM_ASSERT(info->PhysicalDevice != VK_NULL_HANDLE);
|
||||||
@ -1115,6 +1147,13 @@ bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info)
|
|||||||
|
|
||||||
ImGui_ImplVulkan_CreateDeviceObjects();
|
ImGui_ImplVulkan_CreateDeviceObjects();
|
||||||
|
|
||||||
|
// Our render function expect RendererUserData to be storing the window render buffer we need (for the main viewport we won't use ->Window)
|
||||||
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
|
main_viewport->RendererUserData = IM_NEW(ImGui_ImplVulkan_ViewportData)();
|
||||||
|
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
ImGui_ImplVulkan_InitPlatformInterface();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1124,10 +1163,21 @@ void ImGui_ImplVulkan_Shutdown()
|
|||||||
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
IM_ASSERT(bd != nullptr && "No renderer backend to shutdown, or already shutdown?");
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
// First destroy objects in all viewports
|
||||||
ImGui_ImplVulkan_DestroyDeviceObjects();
|
ImGui_ImplVulkan_DestroyDeviceObjects();
|
||||||
|
|
||||||
|
// Manually delete main viewport render data in-case we haven't initialized for viewports
|
||||||
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
|
if (ImGui_ImplVulkan_ViewportData* vd = (ImGui_ImplVulkan_ViewportData*)main_viewport->RendererUserData)
|
||||||
|
IM_DELETE(vd);
|
||||||
|
main_viewport->RendererUserData = nullptr;
|
||||||
|
|
||||||
|
// Clean up windows
|
||||||
|
ImGui_ImplVulkan_ShutdownPlatformInterface();
|
||||||
|
|
||||||
io.BackendRendererName = nullptr;
|
io.BackendRendererName = nullptr;
|
||||||
io.BackendRendererUserData = nullptr;
|
io.BackendRendererUserData = nullptr;
|
||||||
io.BackendFlags &= ~ImGuiBackendFlags_RendererHasVtxOffset;
|
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasViewports);
|
||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1147,10 +1197,12 @@ void ImGui_ImplVulkan_SetMinImageCount(uint32_t min_image_count)
|
|||||||
if (bd->VulkanInitInfo.MinImageCount == min_image_count)
|
if (bd->VulkanInitInfo.MinImageCount == min_image_count)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
IM_ASSERT(0); // FIXME-VIEWPORT: Unsupported. Need to recreate all swap chains!
|
||||||
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
||||||
VkResult err = vkDeviceWaitIdle(v->Device);
|
VkResult err = vkDeviceWaitIdle(v->Device);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
ImGui_ImplVulkan_DestroyWindowRenderBuffers(v->Device, &bd->MainWindowRenderBuffers, v->Allocator);
|
ImGui_ImplVulkanH_DestroyAllViewportsRenderBuffers(v->Device, v->Allocator);
|
||||||
|
|
||||||
bd->VulkanInitInfo.MinImageCount = min_image_count;
|
bd->VulkanInitInfo.MinImageCount = min_image_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1385,8 +1437,6 @@ void ImGui_ImplVulkanH_CreateWindowSwapChain(VkPhysicalDevice physical_device, V
|
|||||||
wd->ImageCount = 0;
|
wd->ImageCount = 0;
|
||||||
if (wd->RenderPass)
|
if (wd->RenderPass)
|
||||||
vkDestroyRenderPass(device, wd->RenderPass, allocator);
|
vkDestroyRenderPass(device, wd->RenderPass, allocator);
|
||||||
if (wd->Pipeline)
|
|
||||||
vkDestroyPipeline(device, wd->Pipeline, allocator);
|
|
||||||
|
|
||||||
// If min image count was not specified, request different count of images dependent on selected present mode
|
// If min image count was not specified, request different count of images dependent on selected present mode
|
||||||
if (min_image_count == 0)
|
if (min_image_count == 0)
|
||||||
@ -1539,6 +1589,7 @@ void ImGui_ImplVulkanH_CreateOrResizeWindow(VkInstance instance, VkPhysicalDevic
|
|||||||
IM_ASSERT(g_FunctionsLoaded && "Need to call ImGui_ImplVulkan_LoadFunctions() if IMGUI_IMPL_VULKAN_NO_PROTOTYPES or VK_NO_PROTOTYPES are set!");
|
IM_ASSERT(g_FunctionsLoaded && "Need to call ImGui_ImplVulkan_LoadFunctions() if IMGUI_IMPL_VULKAN_NO_PROTOTYPES or VK_NO_PROTOTYPES are set!");
|
||||||
(void)instance;
|
(void)instance;
|
||||||
ImGui_ImplVulkanH_CreateWindowSwapChain(physical_device, device, wd, allocator, width, height, min_image_count);
|
ImGui_ImplVulkanH_CreateWindowSwapChain(physical_device, device, wd, allocator, width, height, min_image_count);
|
||||||
|
//ImGui_ImplVulkan_CreatePipeline(device, allocator, VK_NULL_HANDLE, wd->RenderPass, VK_SAMPLE_COUNT_1_BIT, &wd->Pipeline, g_VulkanInitInfo.Subpass);
|
||||||
ImGui_ImplVulkanH_CreateWindowCommandBuffers(physical_device, device, wd, queue_family, allocator);
|
ImGui_ImplVulkanH_CreateWindowCommandBuffers(physical_device, device, wd, queue_family, allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1555,7 +1606,6 @@ void ImGui_ImplVulkanH_DestroyWindow(VkInstance instance, VkDevice device, ImGui
|
|||||||
IM_FREE(wd->FrameSemaphores);
|
IM_FREE(wd->FrameSemaphores);
|
||||||
wd->Frames = nullptr;
|
wd->Frames = nullptr;
|
||||||
wd->FrameSemaphores = nullptr;
|
wd->FrameSemaphores = nullptr;
|
||||||
vkDestroyPipeline(device, wd->Pipeline, allocator);
|
|
||||||
vkDestroyRenderPass(device, wd->RenderPass, allocator);
|
vkDestroyRenderPass(device, wd->RenderPass, allocator);
|
||||||
vkDestroySwapchainKHR(device, wd->Swapchain, allocator);
|
vkDestroySwapchainKHR(device, wd->Swapchain, allocator);
|
||||||
vkDestroySurfaceKHR(instance, wd->Surface, allocator);
|
vkDestroySurfaceKHR(instance, wd->Surface, allocator);
|
||||||
@ -1583,6 +1633,297 @@ void ImGui_ImplVulkanH_DestroyFrameSemaphores(VkDevice device, ImGui_ImplVulkanH
|
|||||||
fsd->ImageAcquiredSemaphore = fsd->RenderCompleteSemaphore = VK_NULL_HANDLE;
|
fsd->ImageAcquiredSemaphore = fsd->RenderCompleteSemaphore = VK_NULL_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplVulkanH_DestroyAllViewportsRenderBuffers(VkDevice device, const VkAllocationCallbacks* allocator)
|
||||||
|
{
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
for (int n = 0; n < platform_io.Viewports.Size; n++)
|
||||||
|
if (ImGui_ImplVulkan_ViewportData* vd = (ImGui_ImplVulkan_ViewportData*)platform_io.Viewports[n]->RendererUserData)
|
||||||
|
ImGui_ImplVulkan_DestroyWindowRenderBuffers(device, &vd->RenderBuffers, allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
|
||||||
|
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
|
||||||
|
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static void ImGui_ImplVulkan_CreateWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
||||||
|
ImGui_ImplVulkan_ViewportData* vd = IM_NEW(ImGui_ImplVulkan_ViewportData)();
|
||||||
|
viewport->RendererUserData = vd;
|
||||||
|
ImGui_ImplVulkanH_Window* wd = &vd->Window;
|
||||||
|
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
||||||
|
|
||||||
|
// Create surface
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
VkResult err = (VkResult)platform_io.Platform_CreateVkSurface(viewport, (ImU64)v->Instance, (const void*)v->Allocator, (ImU64*)&wd->Surface);
|
||||||
|
check_vk_result(err);
|
||||||
|
|
||||||
|
// Check for WSI support
|
||||||
|
VkBool32 res;
|
||||||
|
vkGetPhysicalDeviceSurfaceSupportKHR(v->PhysicalDevice, v->QueueFamily, wd->Surface, &res);
|
||||||
|
if (res != VK_TRUE)
|
||||||
|
{
|
||||||
|
IM_ASSERT(0); // Error: no WSI support on physical device
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Select Surface Format
|
||||||
|
ImVector<VkFormat> requestSurfaceImageFormats;
|
||||||
|
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
|
for (uint32_t n = 0; n < v->PipelineRenderingCreateInfo.colorAttachmentCount; n++)
|
||||||
|
requestSurfaceImageFormats.push_back(v->PipelineRenderingCreateInfo.pColorAttachmentFormats[n]);
|
||||||
|
#endif
|
||||||
|
const VkFormat defaultFormats[] = { VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_B8G8R8_UNORM, VK_FORMAT_R8G8B8_UNORM };
|
||||||
|
for (VkFormat format : defaultFormats)
|
||||||
|
requestSurfaceImageFormats.push_back(format);
|
||||||
|
|
||||||
|
const VkColorSpaceKHR requestSurfaceColorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR;
|
||||||
|
wd->SurfaceFormat = ImGui_ImplVulkanH_SelectSurfaceFormat(v->PhysicalDevice, wd->Surface, requestSurfaceImageFormats.Data, (size_t)requestSurfaceImageFormats.Size, requestSurfaceColorSpace);
|
||||||
|
|
||||||
|
// Select Present Mode
|
||||||
|
// FIXME-VULKAN: Even thought mailbox seems to get us maximum framerate with a single window, it halves framerate with a second window etc. (w/ Nvidia and SDK 1.82.1)
|
||||||
|
VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_MAILBOX_KHR, VK_PRESENT_MODE_IMMEDIATE_KHR, VK_PRESENT_MODE_FIFO_KHR };
|
||||||
|
wd->PresentMode = ImGui_ImplVulkanH_SelectPresentMode(v->PhysicalDevice, wd->Surface, &present_modes[0], IM_ARRAYSIZE(present_modes));
|
||||||
|
//printf("[vulkan] Secondary window selected PresentMode = %d\n", wd->PresentMode);
|
||||||
|
|
||||||
|
// Create SwapChain, RenderPass, Framebuffer, etc.
|
||||||
|
wd->ClearEnable = (viewport->Flags & ImGuiViewportFlags_NoRendererClear) ? false : true;
|
||||||
|
wd->UseDynamicRendering = v->UseDynamicRendering;
|
||||||
|
ImGui_ImplVulkanH_CreateOrResizeWindow(v->Instance, v->PhysicalDevice, v->Device, wd, v->QueueFamily, v->Allocator, (int)viewport->Size.x, (int)viewport->Size.y, v->MinImageCount);
|
||||||
|
vd->WindowOwned = true;
|
||||||
|
|
||||||
|
// Create pipeline (shared by all secondary viewports)
|
||||||
|
if (bd->PipelineForViewports == VK_NULL_HANDLE)
|
||||||
|
ImGui_ImplVulkan_CreatePipeline(v->Device, v->Allocator, VK_NULL_HANDLE, wd->RenderPass, VK_SAMPLE_COUNT_1_BIT, &bd->PipelineForViewports, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplVulkan_DestroyWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
// The main viewport (owned by the application) will always have RendererUserData == 0 since we didn't create the data for it.
|
||||||
|
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
||||||
|
if (ImGui_ImplVulkan_ViewportData* vd = (ImGui_ImplVulkan_ViewportData*)viewport->RendererUserData)
|
||||||
|
{
|
||||||
|
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
||||||
|
if (vd->WindowOwned)
|
||||||
|
ImGui_ImplVulkanH_DestroyWindow(v->Instance, v->Device, &vd->Window, v->Allocator);
|
||||||
|
ImGui_ImplVulkan_DestroyWindowRenderBuffers(v->Device, &vd->RenderBuffers, v->Allocator);
|
||||||
|
IM_DELETE(vd);
|
||||||
|
}
|
||||||
|
viewport->RendererUserData = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplVulkan_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||||
|
{
|
||||||
|
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
||||||
|
ImGui_ImplVulkan_ViewportData* vd = (ImGui_ImplVulkan_ViewportData*)viewport->RendererUserData;
|
||||||
|
if (vd == nullptr) // This is nullptr for the main viewport (which is left to the user/app to handle)
|
||||||
|
return;
|
||||||
|
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
||||||
|
vd->Window.ClearEnable = (viewport->Flags & ImGuiViewportFlags_NoRendererClear) ? false : true;
|
||||||
|
ImGui_ImplVulkanH_CreateOrResizeWindow(v->Instance, v->PhysicalDevice, v->Device, &vd->Window, v->QueueFamily, v->Allocator, (int)size.x, (int)size.y, v->MinImageCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplVulkan_RenderWindow(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
||||||
|
ImGui_ImplVulkan_ViewportData* vd = (ImGui_ImplVulkan_ViewportData*)viewport->RendererUserData;
|
||||||
|
ImGui_ImplVulkanH_Window* wd = &vd->Window;
|
||||||
|
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
||||||
|
VkResult err;
|
||||||
|
|
||||||
|
if (vd->SwapChainNeedRebuild)
|
||||||
|
{
|
||||||
|
ImGui_ImplVulkanH_CreateOrResizeWindow(v->Instance, v->PhysicalDevice, v->Device, wd, v->QueueFamily, v->Allocator, (int)viewport->Size.x, (int)viewport->Size.y, v->MinImageCount);
|
||||||
|
vd->SwapChainNeedRebuild = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui_ImplVulkanH_Frame* fd = &wd->Frames[wd->FrameIndex];
|
||||||
|
ImGui_ImplVulkanH_FrameSemaphores* fsd = &wd->FrameSemaphores[wd->SemaphoreIndex];
|
||||||
|
{
|
||||||
|
{
|
||||||
|
err = vkAcquireNextImageKHR(v->Device, wd->Swapchain, UINT64_MAX, fsd->ImageAcquiredSemaphore, VK_NULL_HANDLE, &wd->FrameIndex);
|
||||||
|
if (err == VK_ERROR_OUT_OF_DATE_KHR)
|
||||||
|
{
|
||||||
|
// Since we are not going to swap this frame anyway, it's ok that recreation happens on next frame.
|
||||||
|
vd->SwapChainNeedRebuild = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
check_vk_result(err);
|
||||||
|
fd = &wd->Frames[wd->FrameIndex];
|
||||||
|
}
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
err = vkWaitForFences(v->Device, 1, &fd->Fence, VK_TRUE, 100);
|
||||||
|
if (err == VK_SUCCESS) break;
|
||||||
|
if (err == VK_TIMEOUT) continue;
|
||||||
|
check_vk_result(err);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
err = vkResetCommandPool(v->Device, fd->CommandPool, 0);
|
||||||
|
check_vk_result(err);
|
||||||
|
VkCommandBufferBeginInfo info = {};
|
||||||
|
info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
|
||||||
|
info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
|
||||||
|
err = vkBeginCommandBuffer(fd->CommandBuffer, &info);
|
||||||
|
check_vk_result(err);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
|
||||||
|
}
|
||||||
|
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
|
if (v->UseDynamicRendering)
|
||||||
|
{
|
||||||
|
// Transition swapchain image to a layout suitable for drawing.
|
||||||
|
VkImageMemoryBarrier barrier = {};
|
||||||
|
barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
||||||
|
barrier.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
||||||
|
barrier.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||||
|
barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||||
|
barrier.image = fd->Backbuffer;
|
||||||
|
barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||||
|
barrier.subresourceRange.levelCount = 1;
|
||||||
|
barrier.subresourceRange.layerCount = 1;
|
||||||
|
vkCmdPipelineBarrier(fd->CommandBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, 0, 0, nullptr, 0, nullptr, 1, &barrier);
|
||||||
|
|
||||||
|
VkRenderingAttachmentInfo attachmentInfo = {};
|
||||||
|
attachmentInfo.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR;
|
||||||
|
attachmentInfo.imageView = fd->BackbufferView;
|
||||||
|
attachmentInfo.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||||
|
attachmentInfo.resolveMode = VK_RESOLVE_MODE_NONE;
|
||||||
|
attachmentInfo.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
|
||||||
|
attachmentInfo.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
||||||
|
attachmentInfo.clearValue = wd->ClearValue;
|
||||||
|
|
||||||
|
VkRenderingInfo renderingInfo = {};
|
||||||
|
renderingInfo.sType = VK_STRUCTURE_TYPE_RENDERING_INFO_KHR;
|
||||||
|
renderingInfo.renderArea.extent.width = wd->Width;
|
||||||
|
renderingInfo.renderArea.extent.height = wd->Height;
|
||||||
|
renderingInfo.layerCount = 1;
|
||||||
|
renderingInfo.viewMask = 0;
|
||||||
|
renderingInfo.colorAttachmentCount = 1;
|
||||||
|
renderingInfo.pColorAttachments = &attachmentInfo;
|
||||||
|
|
||||||
|
ImGuiImplVulkanFuncs_vkCmdBeginRenderingKHR(fd->CommandBuffer, &renderingInfo);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
VkRenderPassBeginInfo info = {};
|
||||||
|
info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
|
||||||
|
info.renderPass = wd->RenderPass;
|
||||||
|
info.framebuffer = fd->Framebuffer;
|
||||||
|
info.renderArea.extent.width = wd->Width;
|
||||||
|
info.renderArea.extent.height = wd->Height;
|
||||||
|
info.clearValueCount = (viewport->Flags & ImGuiViewportFlags_NoRendererClear) ? 0 : 1;
|
||||||
|
info.pClearValues = (viewport->Flags & ImGuiViewportFlags_NoRendererClear) ? nullptr : &wd->ClearValue;
|
||||||
|
vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui_ImplVulkan_RenderDrawData(viewport->DrawData, fd->CommandBuffer, bd->PipelineForViewports);
|
||||||
|
|
||||||
|
{
|
||||||
|
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
|
if (v->UseDynamicRendering)
|
||||||
|
{
|
||||||
|
ImGuiImplVulkanFuncs_vkCmdEndRenderingKHR(fd->CommandBuffer);
|
||||||
|
|
||||||
|
// Transition image to a layout suitable for presentation
|
||||||
|
VkImageMemoryBarrier barrier = {};
|
||||||
|
barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
||||||
|
barrier.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
||||||
|
barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||||
|
barrier.newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
|
||||||
|
barrier.image = fd->Backbuffer;
|
||||||
|
barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||||
|
barrier.subresourceRange.levelCount = 1;
|
||||||
|
barrier.subresourceRange.layerCount = 1;
|
||||||
|
vkCmdPipelineBarrier(fd->CommandBuffer, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, 0, nullptr, 0, nullptr, 1, &barrier);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
vkCmdEndRenderPass(fd->CommandBuffer);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
||||||
|
VkSubmitInfo info = {};
|
||||||
|
info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
|
||||||
|
info.waitSemaphoreCount = 1;
|
||||||
|
info.pWaitSemaphores = &fsd->ImageAcquiredSemaphore;
|
||||||
|
info.pWaitDstStageMask = &wait_stage;
|
||||||
|
info.commandBufferCount = 1;
|
||||||
|
info.pCommandBuffers = &fd->CommandBuffer;
|
||||||
|
info.signalSemaphoreCount = 1;
|
||||||
|
info.pSignalSemaphores = &fsd->RenderCompleteSemaphore;
|
||||||
|
|
||||||
|
err = vkEndCommandBuffer(fd->CommandBuffer);
|
||||||
|
check_vk_result(err);
|
||||||
|
err = vkResetFences(v->Device, 1, &fd->Fence);
|
||||||
|
check_vk_result(err);
|
||||||
|
err = vkQueueSubmit(v->Queue, 1, &info, fd->Fence);
|
||||||
|
check_vk_result(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplVulkan_SwapBuffers(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
||||||
|
ImGui_ImplVulkan_ViewportData* vd = (ImGui_ImplVulkan_ViewportData*)viewport->RendererUserData;
|
||||||
|
ImGui_ImplVulkanH_Window* wd = &vd->Window;
|
||||||
|
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
||||||
|
|
||||||
|
if (vd->SwapChainNeedRebuild) // Frame data became invalid in the middle of rendering
|
||||||
|
return;
|
||||||
|
|
||||||
|
VkResult err;
|
||||||
|
uint32_t present_index = wd->FrameIndex;
|
||||||
|
|
||||||
|
ImGui_ImplVulkanH_FrameSemaphores* fsd = &wd->FrameSemaphores[wd->SemaphoreIndex];
|
||||||
|
VkPresentInfoKHR info = {};
|
||||||
|
info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
|
||||||
|
info.waitSemaphoreCount = 1;
|
||||||
|
info.pWaitSemaphores = &fsd->RenderCompleteSemaphore;
|
||||||
|
info.swapchainCount = 1;
|
||||||
|
info.pSwapchains = &wd->Swapchain;
|
||||||
|
info.pImageIndices = &present_index;
|
||||||
|
err = vkQueuePresentKHR(v->Queue, &info);
|
||||||
|
if (err == VK_ERROR_OUT_OF_DATE_KHR || err == VK_SUBOPTIMAL_KHR)
|
||||||
|
{
|
||||||
|
vd->SwapChainNeedRebuild = true;
|
||||||
|
if (err == VK_ERROR_OUT_OF_DATE_KHR)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
check_vk_result(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
wd->FrameIndex = (wd->FrameIndex + 1) % wd->ImageCount; // This is for the next vkWaitForFences()
|
||||||
|
wd->SemaphoreIndex = (wd->SemaphoreIndex + 1) % wd->SemaphoreCount; // Now we can use the next set of semaphores
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplVulkan_InitPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
IM_ASSERT(platform_io.Platform_CreateVkSurface != nullptr && "Platform needs to setup the CreateVkSurface handler.");
|
||||||
|
platform_io.Renderer_CreateWindow = ImGui_ImplVulkan_CreateWindow;
|
||||||
|
platform_io.Renderer_DestroyWindow = ImGui_ImplVulkan_DestroyWindow;
|
||||||
|
platform_io.Renderer_SetWindowSize = ImGui_ImplVulkan_SetWindowSize;
|
||||||
|
platform_io.Renderer_RenderWindow = ImGui_ImplVulkan_RenderWindow;
|
||||||
|
platform_io.Renderer_SwapBuffers = ImGui_ImplVulkan_SwapBuffers;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplVulkan_ShutdownPlatformInterface()
|
||||||
|
{
|
||||||
|
ImGui::DestroyPlatformWindows();
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#endif // #ifndef IMGUI_DISABLE
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
@ -2,8 +2,9 @@
|
|||||||
// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..)
|
// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [!] Renderer: User texture binding. Use 'VkDescriptorSet' as ImTextureID. Read the FAQ about ImTextureID! See https://github.com/ocornut/imgui/pull/914 for discussions.
|
// [x] Renderer: User texture binding. Use 'VkDescriptorSet' as ImTextureID. Read the FAQ about ImTextureID! See https://github.com/ocornut/imgui/pull/914 for discussions.
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// [x] Renderer: Multi-viewport / platform windows. With issues (flickering when creating a new viewport).
|
||||||
|
|
||||||
// Important: on 32-bit systems, user texture binding is only supported if your imconfig file has '#define ImTextureID ImU64'.
|
// Important: on 32-bit systems, user texture binding is only supported if your imconfig file has '#define ImTextureID ImU64'.
|
||||||
// See imgui_impl_vulkan.cpp file for details.
|
// See imgui_impl_vulkan.cpp file for details.
|
||||||
@ -137,8 +138,8 @@ struct ImGui_ImplVulkanH_Frame;
|
|||||||
struct ImGui_ImplVulkanH_Window;
|
struct ImGui_ImplVulkanH_Window;
|
||||||
|
|
||||||
// Helpers
|
// Helpers
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkanH_CreateOrResizeWindow(VkInstance instance, VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wnd, uint32_t queue_family, const VkAllocationCallbacks* allocator, int w, int h, uint32_t min_image_count);
|
IMGUI_IMPL_API void ImGui_ImplVulkanH_CreateOrResizeWindow(VkInstance instance, VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wd, uint32_t queue_family, const VkAllocationCallbacks* allocator, int w, int h, uint32_t min_image_count);
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkanH_DestroyWindow(VkInstance instance, VkDevice device, ImGui_ImplVulkanH_Window* wnd, const VkAllocationCallbacks* allocator);
|
IMGUI_IMPL_API void ImGui_ImplVulkanH_DestroyWindow(VkInstance instance, VkDevice device, ImGui_ImplVulkanH_Window* wd, const VkAllocationCallbacks* allocator);
|
||||||
IMGUI_IMPL_API VkSurfaceFormatKHR ImGui_ImplVulkanH_SelectSurfaceFormat(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const VkFormat* request_formats, int request_formats_count, VkColorSpaceKHR request_color_space);
|
IMGUI_IMPL_API VkSurfaceFormatKHR ImGui_ImplVulkanH_SelectSurfaceFormat(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const VkFormat* request_formats, int request_formats_count, VkColorSpaceKHR request_color_space);
|
||||||
IMGUI_IMPL_API VkPresentModeKHR ImGui_ImplVulkanH_SelectPresentMode(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const VkPresentModeKHR* request_modes, int request_modes_count);
|
IMGUI_IMPL_API VkPresentModeKHR ImGui_ImplVulkanH_SelectPresentMode(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const VkPresentModeKHR* request_modes, int request_modes_count);
|
||||||
IMGUI_IMPL_API int ImGui_ImplVulkanH_GetMinImageCountFromPresentMode(VkPresentModeKHR present_mode);
|
IMGUI_IMPL_API int ImGui_ImplVulkanH_GetMinImageCountFromPresentMode(VkPresentModeKHR present_mode);
|
||||||
@ -173,7 +174,6 @@ struct ImGui_ImplVulkanH_Window
|
|||||||
VkSurfaceFormatKHR SurfaceFormat;
|
VkSurfaceFormatKHR SurfaceFormat;
|
||||||
VkPresentModeKHR PresentMode;
|
VkPresentModeKHR PresentMode;
|
||||||
VkRenderPass RenderPass;
|
VkRenderPass RenderPass;
|
||||||
VkPipeline Pipeline; // The window pipeline may uses a different VkRenderPass than the one passed in ImGui_ImplVulkan_InitInfo
|
|
||||||
bool UseDynamicRendering;
|
bool UseDynamicRendering;
|
||||||
bool ClearEnable;
|
bool ClearEnable;
|
||||||
VkClearValue ClearValue;
|
VkClearValue ClearValue;
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'WGPUTextureView' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'WGPUTextureView' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// Missing features:
|
||||||
|
// [ ] Renderer: Multi-viewport support (multiple windows). Not meaningful on the web.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'WGPUTextureView' as ImTextureID. Read the FAQ about ImTextureID!
|
// [X] Renderer: User texture binding. Use 'WGPUTextureView' as ImTextureID. Read the FAQ about ImTextureID!
|
||||||
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
|
// Missing features:
|
||||||
|
// [ ] Renderer: Multi-viewport support (multiple windows). Not meaningful on the web.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy VK_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy VK_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
|
// [X] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
@ -21,6 +22,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
// 2024-07-08: Inputs: Fixed ImGuiMod_Super being mapped to VK_APPS instead of VK_LWIN||VK_RWIN. (#7768)
|
// 2024-07-08: Inputs: Fixed ImGuiMod_Super being mapped to VK_APPS instead of VK_LWIN||VK_RWIN. (#7768)
|
||||||
// 2023-10-05: Inputs: Added support for extra ImGuiKey values: F13 to F24 function keys, app back/forward keys.
|
// 2023-10-05: Inputs: Added support for extra ImGuiKey values: F13 to F24 function keys, app back/forward keys.
|
||||||
// 2023-09-25: Inputs: Synthesize key-down event on key-up for VK_SNAPSHOT / ImGuiKey_PrintScreen as Windows doesn't emit it (same behavior as GLFW/SDL).
|
// 2023-09-25: Inputs: Synthesize key-down event on key-up for VK_SNAPSHOT / ImGuiKey_PrintScreen as Windows doesn't emit it (same behavior as GLFW/SDL).
|
||||||
@ -103,6 +105,11 @@ typedef DWORD(WINAPI* PFN_XInputGetState)(DWORD, XINPUT_STATE*);
|
|||||||
#pragma GCC diagnostic ignored "-Wcast-function-type" // warning: cast between incompatible function types (for loader)
|
#pragma GCC diagnostic ignored "-Wcast-function-type" // warning: cast between incompatible function types (for loader)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
static void ImGui_ImplWin32_InitPlatformInterface(bool platform_has_own_dc);
|
||||||
|
static void ImGui_ImplWin32_ShutdownPlatformInterface();
|
||||||
|
static void ImGui_ImplWin32_UpdateMonitors();
|
||||||
|
|
||||||
struct ImGui_ImplWin32_Data
|
struct ImGui_ImplWin32_Data
|
||||||
{
|
{
|
||||||
HWND hWnd;
|
HWND hWnd;
|
||||||
@ -113,6 +120,7 @@ struct ImGui_ImplWin32_Data
|
|||||||
INT64 TicksPerSecond;
|
INT64 TicksPerSecond;
|
||||||
ImGuiMouseCursor LastMouseCursor;
|
ImGuiMouseCursor LastMouseCursor;
|
||||||
UINT32 KeyboardCodePage;
|
UINT32 KeyboardCodePage;
|
||||||
|
bool WantUpdateMonitors;
|
||||||
|
|
||||||
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
||||||
bool HasGamepad;
|
bool HasGamepad;
|
||||||
@ -163,17 +171,21 @@ static bool ImGui_ImplWin32_InitEx(void* hwnd, bool platform_has_own_dc)
|
|||||||
io.BackendPlatformName = "imgui_impl_win32";
|
io.BackendPlatformName = "imgui_impl_win32";
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports; // We can create multi-viewports on the Platform side (optional)
|
||||||
|
io.BackendFlags |= ImGuiBackendFlags_HasMouseHoveredViewport; // We can call io.AddMouseViewportEvent() with correct data (optional)
|
||||||
|
|
||||||
bd->hWnd = (HWND)hwnd;
|
bd->hWnd = (HWND)hwnd;
|
||||||
|
bd->WantUpdateMonitors = true;
|
||||||
bd->TicksPerSecond = perf_frequency;
|
bd->TicksPerSecond = perf_frequency;
|
||||||
bd->Time = perf_counter;
|
bd->Time = perf_counter;
|
||||||
bd->LastMouseCursor = ImGuiMouseCursor_COUNT;
|
bd->LastMouseCursor = ImGuiMouseCursor_COUNT;
|
||||||
ImGui_ImplWin32_UpdateKeyboardCodePage();
|
ImGui_ImplWin32_UpdateKeyboardCodePage();
|
||||||
|
|
||||||
// Set platform dependent data in viewport
|
// Our mouse update function expect PlatformHandle to be filled for the main viewport
|
||||||
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
main_viewport->PlatformHandle = main_viewport->PlatformHandleRaw = (void*)bd->hWnd;
|
main_viewport->PlatformHandle = main_viewport->PlatformHandleRaw = (void*)bd->hWnd;
|
||||||
IM_UNUSED(platform_has_own_dc); // Used in 'docking' branch
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
ImGui_ImplWin32_InitPlatformInterface(platform_has_own_dc);
|
||||||
|
|
||||||
// Dynamically load XInput library
|
// Dynamically load XInput library
|
||||||
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
||||||
@ -216,6 +228,8 @@ void ImGui_ImplWin32_Shutdown()
|
|||||||
IM_ASSERT(bd != nullptr && "No platform backend to shutdown, or already shutdown?");
|
IM_ASSERT(bd != nullptr && "No platform backend to shutdown, or already shutdown?");
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
ImGui_ImplWin32_ShutdownPlatformInterface();
|
||||||
|
|
||||||
// Unload XInput library
|
// Unload XInput library
|
||||||
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
||||||
if (bd->XInputDLL)
|
if (bd->XInputDLL)
|
||||||
@ -224,7 +238,7 @@ void ImGui_ImplWin32_Shutdown()
|
|||||||
|
|
||||||
io.BackendPlatformName = nullptr;
|
io.BackendPlatformName = nullptr;
|
||||||
io.BackendPlatformUserData = nullptr;
|
io.BackendPlatformUserData = nullptr;
|
||||||
io.BackendFlags &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasSetMousePos | ImGuiBackendFlags_HasGamepad);
|
io.BackendFlags &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasSetMousePos | ImGuiBackendFlags_HasGamepad | ImGuiBackendFlags_PlatformHasViewports | ImGuiBackendFlags_HasMouseHoveredViewport);
|
||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,33 +312,59 @@ static void ImGui_ImplWin32_UpdateKeyModifiers()
|
|||||||
io.AddKeyEvent(ImGuiMod_Super, IsVkDown(VK_LWIN) || IsVkDown(VK_RWIN));
|
io.AddKeyEvent(ImGuiMod_Super, IsVkDown(VK_LWIN) || IsVkDown(VK_RWIN));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This code supports multi-viewports (multiple OS Windows mapped into different Dear ImGui viewports)
|
||||||
|
// Because of that, it is a little more complicated than your typical single-viewport binding code!
|
||||||
static void ImGui_ImplWin32_UpdateMouseData()
|
static void ImGui_ImplWin32_UpdateMouseData()
|
||||||
{
|
{
|
||||||
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
|
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
IM_ASSERT(bd->hWnd != 0);
|
IM_ASSERT(bd->hWnd != 0);
|
||||||
|
|
||||||
|
POINT mouse_screen_pos;
|
||||||
|
bool has_mouse_screen_pos = ::GetCursorPos(&mouse_screen_pos) != 0;
|
||||||
|
|
||||||
HWND focused_window = ::GetForegroundWindow();
|
HWND focused_window = ::GetForegroundWindow();
|
||||||
const bool is_app_focused = (focused_window == bd->hWnd);
|
const bool is_app_focused = (focused_window && (focused_window == bd->hWnd || ::IsChild(focused_window, bd->hWnd) || ImGui::FindViewportByPlatformHandle((void*)focused_window)));
|
||||||
if (is_app_focused)
|
if (is_app_focused)
|
||||||
{
|
{
|
||||||
// (Optional) Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
|
// (Optional) Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
|
||||||
|
// When multi-viewports are enabled, all Dear ImGui positions are same as OS positions.
|
||||||
if (io.WantSetMousePos)
|
if (io.WantSetMousePos)
|
||||||
{
|
{
|
||||||
POINT pos = { (int)io.MousePos.x, (int)io.MousePos.y };
|
POINT pos = { (int)io.MousePos.x, (int)io.MousePos.y };
|
||||||
if (::ClientToScreen(bd->hWnd, &pos))
|
if ((io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) == 0)
|
||||||
::SetCursorPos(pos.x, pos.y);
|
::ClientToScreen(focused_window, &pos);
|
||||||
|
::SetCursorPos(pos.x, pos.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// (Optional) Fallback to provide mouse position when focused (WM_MOUSEMOVE already provides this when hovered or captured)
|
// (Optional) Fallback to provide mouse position when focused (WM_MOUSEMOVE already provides this when hovered or captured)
|
||||||
// This also fills a short gap when clicking non-client area: WM_NCMOUSELEAVE -> modal OS move -> gap -> WM_NCMOUSEMOVE
|
// This also fills a short gap when clicking non-client area: WM_NCMOUSELEAVE -> modal OS move -> gap -> WM_NCMOUSEMOVE
|
||||||
if (!io.WantSetMousePos && bd->MouseTrackedArea == 0)
|
if (!io.WantSetMousePos && bd->MouseTrackedArea == 0 && has_mouse_screen_pos)
|
||||||
{
|
{
|
||||||
POINT pos;
|
// Single viewport mode: mouse position in client window coordinates (io.MousePos is (0,0) when the mouse is on the upper-left corner of the app window)
|
||||||
if (::GetCursorPos(&pos) && ::ScreenToClient(bd->hWnd, &pos))
|
// (This is the position you can get with ::GetCursorPos() + ::ScreenToClient() or WM_MOUSEMOVE.)
|
||||||
io.AddMousePosEvent((float)pos.x, (float)pos.y);
|
// Multi-viewport mode: mouse position in OS absolute coordinates (io.MousePos is (0,0) when the mouse is on the upper-left of the primary monitor)
|
||||||
|
// (This is the position you can get with ::GetCursorPos() or WM_MOUSEMOVE + ::ClientToScreen(). In theory adding viewport->Pos to a client position would also be the same.)
|
||||||
|
POINT mouse_pos = mouse_screen_pos;
|
||||||
|
if (!(io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable))
|
||||||
|
::ScreenToClient(bd->hWnd, &mouse_pos);
|
||||||
|
io.AddMousePosEvent((float)mouse_pos.x, (float)mouse_pos.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// (Optional) When using multiple viewports: call io.AddMouseViewportEvent() with the viewport the OS mouse cursor is hovering.
|
||||||
|
// If ImGuiBackendFlags_HasMouseHoveredViewport is not set by the backend, Dear imGui will ignore this field and infer the information using its flawed heuristic.
|
||||||
|
// - [X] Win32 backend correctly ignore viewports with the _NoInputs flag (here using ::WindowFromPoint with WM_NCHITTEST + HTTRANSPARENT in WndProc does that)
|
||||||
|
// Some backend are not able to handle that correctly. If a backend report an hovered viewport that has the _NoInputs flag (e.g. when dragging a window
|
||||||
|
// for docking, the viewport has the _NoInputs flag in order to allow us to find the viewport under), then Dear ImGui is forced to ignore the value reported
|
||||||
|
// by the backend, and use its flawed heuristic to guess the viewport behind.
|
||||||
|
// - [X] Win32 backend correctly reports this regardless of another viewport behind focused and dragged from (we need this to find a useful drag and drop target).
|
||||||
|
ImGuiID mouse_viewport_id = 0;
|
||||||
|
if (has_mouse_screen_pos)
|
||||||
|
if (HWND hovered_hwnd = ::WindowFromPoint(mouse_screen_pos))
|
||||||
|
if (ImGuiViewport* viewport = ImGui::FindViewportByPlatformHandle((void*)hovered_hwnd))
|
||||||
|
mouse_viewport_id = viewport->ID;
|
||||||
|
io.AddMouseViewportEvent(mouse_viewport_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gamepad navigation mapping
|
// Gamepad navigation mapping
|
||||||
@ -384,6 +424,37 @@ static void ImGui_ImplWin32_UpdateGamepads()
|
|||||||
#endif // #ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
#endif // #ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BOOL CALLBACK ImGui_ImplWin32_UpdateMonitors_EnumFunc(HMONITOR monitor, HDC, LPRECT, LPARAM)
|
||||||
|
{
|
||||||
|
MONITORINFO info = {};
|
||||||
|
info.cbSize = sizeof(MONITORINFO);
|
||||||
|
if (!::GetMonitorInfo(monitor, &info))
|
||||||
|
return TRUE;
|
||||||
|
ImGuiPlatformMonitor imgui_monitor;
|
||||||
|
imgui_monitor.MainPos = ImVec2((float)info.rcMonitor.left, (float)info.rcMonitor.top);
|
||||||
|
imgui_monitor.MainSize = ImVec2((float)(info.rcMonitor.right - info.rcMonitor.left), (float)(info.rcMonitor.bottom - info.rcMonitor.top));
|
||||||
|
imgui_monitor.WorkPos = ImVec2((float)info.rcWork.left, (float)info.rcWork.top);
|
||||||
|
imgui_monitor.WorkSize = ImVec2((float)(info.rcWork.right - info.rcWork.left), (float)(info.rcWork.bottom - info.rcWork.top));
|
||||||
|
imgui_monitor.DpiScale = ImGui_ImplWin32_GetDpiScaleForMonitor(monitor);
|
||||||
|
imgui_monitor.PlatformHandle = (void*)monitor;
|
||||||
|
if (imgui_monitor.DpiScale <= 0.0f)
|
||||||
|
return TRUE; // Some accessibility applications are declaring virtual monitors with a DPI of 0, see #7902.
|
||||||
|
ImGuiPlatformIO& io = ImGui::GetPlatformIO();
|
||||||
|
if (info.dwFlags & MONITORINFOF_PRIMARY)
|
||||||
|
io.Monitors.push_front(imgui_monitor);
|
||||||
|
else
|
||||||
|
io.Monitors.push_back(imgui_monitor);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplWin32_UpdateMonitors()
|
||||||
|
{
|
||||||
|
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
|
||||||
|
ImGui::GetPlatformIO().Monitors.resize(0);
|
||||||
|
::EnumDisplayMonitors(nullptr, nullptr, ImGui_ImplWin32_UpdateMonitors_EnumFunc, 0);
|
||||||
|
bd->WantUpdateMonitors = false;
|
||||||
|
}
|
||||||
|
|
||||||
void ImGui_ImplWin32_NewFrame()
|
void ImGui_ImplWin32_NewFrame()
|
||||||
{
|
{
|
||||||
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
|
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
|
||||||
@ -394,6 +465,8 @@ void ImGui_ImplWin32_NewFrame()
|
|||||||
RECT rect = { 0, 0, 0, 0 };
|
RECT rect = { 0, 0, 0, 0 };
|
||||||
::GetClientRect(bd->hWnd, &rect);
|
::GetClientRect(bd->hWnd, &rect);
|
||||||
io.DisplaySize = ImVec2((float)(rect.right - rect.left), (float)(rect.bottom - rect.top));
|
io.DisplaySize = ImVec2((float)(rect.right - rect.left), (float)(rect.bottom - rect.top));
|
||||||
|
if (bd->WantUpdateMonitors)
|
||||||
|
ImGui_ImplWin32_UpdateMonitors();
|
||||||
|
|
||||||
// Setup time step
|
// Setup time step
|
||||||
INT64 current_time = 0;
|
INT64 current_time = 0;
|
||||||
@ -610,8 +683,11 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARA
|
|||||||
bd->MouseTrackedArea = area;
|
bd->MouseTrackedArea = area;
|
||||||
}
|
}
|
||||||
POINT mouse_pos = { (LONG)GET_X_LPARAM(lParam), (LONG)GET_Y_LPARAM(lParam) };
|
POINT mouse_pos = { (LONG)GET_X_LPARAM(lParam), (LONG)GET_Y_LPARAM(lParam) };
|
||||||
if (msg == WM_NCMOUSEMOVE && ::ScreenToClient(hwnd, &mouse_pos) == FALSE) // WM_NCMOUSEMOVE are provided in absolute coordinates.
|
bool want_absolute_pos = (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) != 0;
|
||||||
return 0;
|
if (msg == WM_MOUSEMOVE && want_absolute_pos) // WM_MOUSEMOVE are client-relative coordinates.
|
||||||
|
::ClientToScreen(hwnd, &mouse_pos);
|
||||||
|
if (msg == WM_NCMOUSEMOVE && !want_absolute_pos) // WM_NCMOUSEMOVE are absolute coordinates.
|
||||||
|
::ScreenToClient(hwnd, &mouse_pos);
|
||||||
io.AddMouseSourceEvent(mouse_source);
|
io.AddMouseSourceEvent(mouse_source);
|
||||||
io.AddMousePosEvent((float)mouse_pos.x, (float)mouse_pos.y);
|
io.AddMousePosEvent((float)mouse_pos.x, (float)mouse_pos.y);
|
||||||
return 0;
|
return 0;
|
||||||
@ -750,6 +826,9 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARA
|
|||||||
bd->WantUpdateHasGamepad = true;
|
bd->WantUpdateHasGamepad = true;
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
|
case WM_DISPLAYCHANGE:
|
||||||
|
bd->WantUpdateMonitors = true;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -814,6 +893,10 @@ typedef DPI_AWARENESS_CONTEXT(WINAPI* PFN_SetThreadDpiAwarenessContext)(DPI_AWAR
|
|||||||
// Helper function to enable DPI awareness without setting up a manifest
|
// Helper function to enable DPI awareness without setting up a manifest
|
||||||
void ImGui_ImplWin32_EnableDpiAwareness()
|
void ImGui_ImplWin32_EnableDpiAwareness()
|
||||||
{
|
{
|
||||||
|
// Make sure monitors will be updated with latest correct scaling
|
||||||
|
if (ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData())
|
||||||
|
bd->WantUpdateMonitors = true;
|
||||||
|
|
||||||
if (_IsWindows10OrGreater())
|
if (_IsWindows10OrGreater())
|
||||||
{
|
{
|
||||||
static HINSTANCE user32_dll = ::LoadLibraryA("user32.dll"); // Reference counted per-process
|
static HINSTANCE user32_dll = ::LoadLibraryA("user32.dll"); // Reference counted per-process
|
||||||
@ -913,6 +996,370 @@ void ImGui_ImplWin32_EnableAlphaCompositing(void* hwnd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------
|
||||||
|
// MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT
|
||||||
|
// This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously.
|
||||||
|
// If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first..
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Helper structure we store in the void* RendererUserData field of each ImGuiViewport to easily retrieve our backend data.
|
||||||
|
struct ImGui_ImplWin32_ViewportData
|
||||||
|
{
|
||||||
|
HWND Hwnd;
|
||||||
|
HWND HwndParent;
|
||||||
|
bool HwndOwned;
|
||||||
|
DWORD DwStyle;
|
||||||
|
DWORD DwExStyle;
|
||||||
|
|
||||||
|
ImGui_ImplWin32_ViewportData() { Hwnd = HwndParent = nullptr; HwndOwned = false; DwStyle = DwExStyle = 0; }
|
||||||
|
~ImGui_ImplWin32_ViewportData() { IM_ASSERT(Hwnd == nullptr); }
|
||||||
|
};
|
||||||
|
|
||||||
|
static void ImGui_ImplWin32_GetWin32StyleFromViewportFlags(ImGuiViewportFlags flags, DWORD* out_style, DWORD* out_ex_style)
|
||||||
|
{
|
||||||
|
if (flags & ImGuiViewportFlags_NoDecoration)
|
||||||
|
*out_style = WS_POPUP;
|
||||||
|
else
|
||||||
|
*out_style = WS_OVERLAPPEDWINDOW;
|
||||||
|
|
||||||
|
if (flags & ImGuiViewportFlags_NoTaskBarIcon)
|
||||||
|
*out_ex_style = WS_EX_TOOLWINDOW;
|
||||||
|
else
|
||||||
|
*out_ex_style = WS_EX_APPWINDOW;
|
||||||
|
|
||||||
|
if (flags & ImGuiViewportFlags_TopMost)
|
||||||
|
*out_ex_style |= WS_EX_TOPMOST;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HWND ImGui_ImplWin32_GetHwndFromViewportID(ImGuiID viewport_id)
|
||||||
|
{
|
||||||
|
if (viewport_id != 0)
|
||||||
|
if (ImGuiViewport* viewport = ImGui::FindViewportByID(viewport_id))
|
||||||
|
return (HWND)viewport->PlatformHandle;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplWin32_CreateWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplWin32_ViewportData* vd = IM_NEW(ImGui_ImplWin32_ViewportData)();
|
||||||
|
viewport->PlatformUserData = vd;
|
||||||
|
|
||||||
|
// Select style and parent window
|
||||||
|
ImGui_ImplWin32_GetWin32StyleFromViewportFlags(viewport->Flags, &vd->DwStyle, &vd->DwExStyle);
|
||||||
|
vd->HwndParent = ImGui_ImplWin32_GetHwndFromViewportID(viewport->ParentViewportId);
|
||||||
|
|
||||||
|
// Create window
|
||||||
|
RECT rect = { (LONG)viewport->Pos.x, (LONG)viewport->Pos.y, (LONG)(viewport->Pos.x + viewport->Size.x), (LONG)(viewport->Pos.y + viewport->Size.y) };
|
||||||
|
::AdjustWindowRectEx(&rect, vd->DwStyle, FALSE, vd->DwExStyle);
|
||||||
|
vd->Hwnd = ::CreateWindowEx(
|
||||||
|
vd->DwExStyle, _T("ImGui Platform"), _T("Untitled"), vd->DwStyle, // Style, class name, window name
|
||||||
|
rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, // Window area
|
||||||
|
vd->HwndParent, nullptr, ::GetModuleHandle(nullptr), nullptr); // Owner window, Menu, Instance, Param
|
||||||
|
vd->HwndOwned = true;
|
||||||
|
viewport->PlatformRequestResize = false;
|
||||||
|
viewport->PlatformHandle = viewport->PlatformHandleRaw = vd->Hwnd;
|
||||||
|
|
||||||
|
// Secondary viewports store their imgui context
|
||||||
|
::SetPropA(vd->Hwnd, "IMGUI_CONTEXT", ImGui::GetCurrentContext());
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplWin32_DestroyWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
|
||||||
|
if (ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData)
|
||||||
|
{
|
||||||
|
if (::GetCapture() == vd->Hwnd)
|
||||||
|
{
|
||||||
|
// Transfer capture so if we started dragging from a window that later disappears, we'll still receive the MOUSEUP event.
|
||||||
|
::ReleaseCapture();
|
||||||
|
::SetCapture(bd->hWnd);
|
||||||
|
}
|
||||||
|
if (vd->Hwnd && vd->HwndOwned)
|
||||||
|
::DestroyWindow(vd->Hwnd);
|
||||||
|
vd->Hwnd = nullptr;
|
||||||
|
IM_DELETE(vd);
|
||||||
|
}
|
||||||
|
viewport->PlatformUserData = viewport->PlatformHandle = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplWin32_ShowWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(vd->Hwnd != 0);
|
||||||
|
|
||||||
|
// ShowParent() also brings parent to front, which is not always desirable,
|
||||||
|
// so we temporarily disable parenting. (#7354)
|
||||||
|
if (vd->HwndParent != NULL)
|
||||||
|
::SetWindowLongPtr(vd->Hwnd, GWLP_HWNDPARENT, (LONG_PTR)nullptr);
|
||||||
|
|
||||||
|
if (viewport->Flags & ImGuiViewportFlags_NoFocusOnAppearing)
|
||||||
|
::ShowWindow(vd->Hwnd, SW_SHOWNA);
|
||||||
|
else
|
||||||
|
::ShowWindow(vd->Hwnd, SW_SHOW);
|
||||||
|
|
||||||
|
// Restore
|
||||||
|
if (vd->HwndParent != NULL)
|
||||||
|
::SetWindowLongPtr(vd->Hwnd, GWLP_HWNDPARENT, (LONG_PTR)vd->HwndParent);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplWin32_UpdateWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(vd->Hwnd != 0);
|
||||||
|
|
||||||
|
// Update Win32 parent if it changed _after_ creation
|
||||||
|
// Unlike style settings derived from configuration flags, this is more likely to change for advanced apps that are manipulating ParentViewportID manually.
|
||||||
|
HWND new_parent = ImGui_ImplWin32_GetHwndFromViewportID(viewport->ParentViewportId);
|
||||||
|
if (new_parent != vd->HwndParent)
|
||||||
|
{
|
||||||
|
// Win32 windows can either have a "Parent" (for WS_CHILD window) or an "Owner" (which among other thing keeps window above its owner).
|
||||||
|
// Our Dear Imgui-side concept of parenting only mostly care about what Win32 call "Owner".
|
||||||
|
// The parent parameter of CreateWindowEx() sets up Parent OR Owner depending on WS_CHILD flag. In our case an Owner as we never use WS_CHILD.
|
||||||
|
// Calling ::SetParent() here would be incorrect: it will create a full child relation, alter coordinate system and clipping.
|
||||||
|
// Calling ::SetWindowLongPtr() with GWLP_HWNDPARENT seems correct although poorly documented.
|
||||||
|
// https://devblogs.microsoft.com/oldnewthing/20100315-00/?p=14613
|
||||||
|
vd->HwndParent = new_parent;
|
||||||
|
::SetWindowLongPtr(vd->Hwnd, GWLP_HWNDPARENT, (LONG_PTR)vd->HwndParent);
|
||||||
|
}
|
||||||
|
|
||||||
|
// (Optional) Update Win32 style if it changed _after_ creation.
|
||||||
|
// Generally they won't change unless configuration flags are changed, but advanced uses (such as manually rewriting viewport flags) make this useful.
|
||||||
|
DWORD new_style;
|
||||||
|
DWORD new_ex_style;
|
||||||
|
ImGui_ImplWin32_GetWin32StyleFromViewportFlags(viewport->Flags, &new_style, &new_ex_style);
|
||||||
|
|
||||||
|
// Only reapply the flags that have been changed from our point of view (as other flags are being modified by Windows)
|
||||||
|
if (vd->DwStyle != new_style || vd->DwExStyle != new_ex_style)
|
||||||
|
{
|
||||||
|
// (Optional) Update TopMost state if it changed _after_ creation
|
||||||
|
bool top_most_changed = (vd->DwExStyle & WS_EX_TOPMOST) != (new_ex_style & WS_EX_TOPMOST);
|
||||||
|
HWND insert_after = top_most_changed ? ((viewport->Flags & ImGuiViewportFlags_TopMost) ? HWND_TOPMOST : HWND_NOTOPMOST) : 0;
|
||||||
|
UINT swp_flag = top_most_changed ? 0 : SWP_NOZORDER;
|
||||||
|
|
||||||
|
// Apply flags and position (since it is affected by flags)
|
||||||
|
vd->DwStyle = new_style;
|
||||||
|
vd->DwExStyle = new_ex_style;
|
||||||
|
::SetWindowLong(vd->Hwnd, GWL_STYLE, vd->DwStyle);
|
||||||
|
::SetWindowLong(vd->Hwnd, GWL_EXSTYLE, vd->DwExStyle);
|
||||||
|
RECT rect = { (LONG)viewport->Pos.x, (LONG)viewport->Pos.y, (LONG)(viewport->Pos.x + viewport->Size.x), (LONG)(viewport->Pos.y + viewport->Size.y) };
|
||||||
|
::AdjustWindowRectEx(&rect, vd->DwStyle, FALSE, vd->DwExStyle); // Client to Screen
|
||||||
|
::SetWindowPos(vd->Hwnd, insert_after, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, swp_flag | SWP_NOACTIVATE | SWP_FRAMECHANGED);
|
||||||
|
::ShowWindow(vd->Hwnd, SW_SHOWNA); // This is necessary when we alter the style
|
||||||
|
viewport->PlatformRequestMove = viewport->PlatformRequestResize = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static ImVec2 ImGui_ImplWin32_GetWindowPos(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(vd->Hwnd != 0);
|
||||||
|
POINT pos = { 0, 0 };
|
||||||
|
::ClientToScreen(vd->Hwnd, &pos);
|
||||||
|
return ImVec2((float)pos.x, (float)pos.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplWin32_SetWindowPos(ImGuiViewport* viewport, ImVec2 pos)
|
||||||
|
{
|
||||||
|
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(vd->Hwnd != 0);
|
||||||
|
RECT rect = { (LONG)pos.x, (LONG)pos.y, (LONG)pos.x, (LONG)pos.y };
|
||||||
|
::AdjustWindowRectEx(&rect, vd->DwStyle, FALSE, vd->DwExStyle);
|
||||||
|
::SetWindowPos(vd->Hwnd, nullptr, rect.left, rect.top, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ImVec2 ImGui_ImplWin32_GetWindowSize(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(vd->Hwnd != 0);
|
||||||
|
RECT rect;
|
||||||
|
::GetClientRect(vd->Hwnd, &rect);
|
||||||
|
return ImVec2(float(rect.right - rect.left), float(rect.bottom - rect.top));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplWin32_SetWindowSize(ImGuiViewport* viewport, ImVec2 size)
|
||||||
|
{
|
||||||
|
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(vd->Hwnd != 0);
|
||||||
|
RECT rect = { 0, 0, (LONG)size.x, (LONG)size.y };
|
||||||
|
::AdjustWindowRectEx(&rect, vd->DwStyle, FALSE, vd->DwExStyle); // Client to Screen
|
||||||
|
::SetWindowPos(vd->Hwnd, nullptr, 0, 0, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplWin32_SetWindowFocus(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(vd->Hwnd != 0);
|
||||||
|
::BringWindowToTop(vd->Hwnd);
|
||||||
|
::SetForegroundWindow(vd->Hwnd);
|
||||||
|
::SetFocus(vd->Hwnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ImGui_ImplWin32_GetWindowFocus(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(vd->Hwnd != 0);
|
||||||
|
return ::GetForegroundWindow() == vd->Hwnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ImGui_ImplWin32_GetWindowMinimized(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(vd->Hwnd != 0);
|
||||||
|
return ::IsIconic(vd->Hwnd) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplWin32_SetWindowTitle(ImGuiViewport* viewport, const char* title)
|
||||||
|
{
|
||||||
|
// ::SetWindowTextA() doesn't properly handle UTF-8 so we explicitely convert our string.
|
||||||
|
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(vd->Hwnd != 0);
|
||||||
|
int n = ::MultiByteToWideChar(CP_UTF8, 0, title, -1, nullptr, 0);
|
||||||
|
ImVector<wchar_t> title_w;
|
||||||
|
title_w.resize(n);
|
||||||
|
::MultiByteToWideChar(CP_UTF8, 0, title, -1, title_w.Data, n);
|
||||||
|
::SetWindowTextW(vd->Hwnd, title_w.Data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplWin32_SetWindowAlpha(ImGuiViewport* viewport, float alpha)
|
||||||
|
{
|
||||||
|
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(vd->Hwnd != 0);
|
||||||
|
IM_ASSERT(alpha >= 0.0f && alpha <= 1.0f);
|
||||||
|
if (alpha < 1.0f)
|
||||||
|
{
|
||||||
|
DWORD style = ::GetWindowLongW(vd->Hwnd, GWL_EXSTYLE) | WS_EX_LAYERED;
|
||||||
|
::SetWindowLongW(vd->Hwnd, GWL_EXSTYLE, style);
|
||||||
|
::SetLayeredWindowAttributes(vd->Hwnd, 0, (BYTE)(255 * alpha), LWA_ALPHA);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DWORD style = ::GetWindowLongW(vd->Hwnd, GWL_EXSTYLE) & ~WS_EX_LAYERED;
|
||||||
|
::SetWindowLongW(vd->Hwnd, GWL_EXSTYLE, style);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static float ImGui_ImplWin32_GetWindowDpiScale(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
ImGui_ImplWin32_ViewportData* vd = (ImGui_ImplWin32_ViewportData*)viewport->PlatformUserData;
|
||||||
|
IM_ASSERT(vd->Hwnd != 0);
|
||||||
|
return ImGui_ImplWin32_GetDpiScaleForHwnd(vd->Hwnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME-DPI: Testing DPI related ideas
|
||||||
|
static void ImGui_ImplWin32_OnChangedViewport(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
(void)viewport;
|
||||||
|
#if 0
|
||||||
|
ImGuiStyle default_style;
|
||||||
|
//default_style.WindowPadding = ImVec2(0, 0);
|
||||||
|
//default_style.WindowBorderSize = 0.0f;
|
||||||
|
//default_style.ItemSpacing.y = 3.0f;
|
||||||
|
//default_style.FramePadding = ImVec2(0, 0);
|
||||||
|
default_style.ScaleAllSizes(viewport->DpiScale);
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
style = default_style;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static LRESULT CALLBACK ImGui_ImplWin32_WndProcHandler_PlatformWindow(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
// Allow secondary viewport WndProc to be called regardless of current context
|
||||||
|
ImGuiContext* hwnd_ctx = (ImGuiContext*)::GetPropA(hWnd, "IMGUI_CONTEXT");
|
||||||
|
ImGuiContext* prev_ctx = ImGui::GetCurrentContext();
|
||||||
|
if (hwnd_ctx != prev_ctx && hwnd_ctx != NULL)
|
||||||
|
ImGui::SetCurrentContext(hwnd_ctx);
|
||||||
|
|
||||||
|
LRESULT result = 0;
|
||||||
|
if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam))
|
||||||
|
result = true;
|
||||||
|
else if (ImGuiViewport* viewport = ImGui::FindViewportByPlatformHandle((void*)hWnd))
|
||||||
|
{
|
||||||
|
switch (msg)
|
||||||
|
{
|
||||||
|
case WM_CLOSE:
|
||||||
|
viewport->PlatformRequestClose = true;
|
||||||
|
break;
|
||||||
|
case WM_MOVE:
|
||||||
|
viewport->PlatformRequestMove = true;
|
||||||
|
break;
|
||||||
|
case WM_SIZE:
|
||||||
|
viewport->PlatformRequestResize = true;
|
||||||
|
break;
|
||||||
|
case WM_MOUSEACTIVATE:
|
||||||
|
if (viewport->Flags & ImGuiViewportFlags_NoFocusOnClick)
|
||||||
|
result = MA_NOACTIVATE;
|
||||||
|
break;
|
||||||
|
case WM_NCHITTEST:
|
||||||
|
// Let mouse pass-through the window. This will allow the backend to call io.AddMouseViewportEvent() correctly. (which is optional).
|
||||||
|
// The ImGuiViewportFlags_NoInputs flag is set while dragging a viewport, as want to detect the window behind the one we are dragging.
|
||||||
|
// If you cannot easily access those viewport flags from your windowing/event code: you may manually synchronize its state e.g. in
|
||||||
|
// your main loop after calling UpdatePlatformWindows(). Iterate all viewports/platform windows and pass the flag to your windowing system.
|
||||||
|
if (viewport->Flags & ImGuiViewportFlags_NoInputs)
|
||||||
|
result = HTTRANSPARENT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (result == 0)
|
||||||
|
result = DefWindowProc(hWnd, msg, wParam, lParam);
|
||||||
|
if (hwnd_ctx != prev_ctx && hwnd_ctx != NULL)
|
||||||
|
ImGui::SetCurrentContext(prev_ctx);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplWin32_InitPlatformInterface(bool platform_has_own_dc)
|
||||||
|
{
|
||||||
|
WNDCLASSEX wcex;
|
||||||
|
wcex.cbSize = sizeof(WNDCLASSEX);
|
||||||
|
wcex.style = CS_HREDRAW | CS_VREDRAW | (platform_has_own_dc ? CS_OWNDC : 0);
|
||||||
|
wcex.lpfnWndProc = ImGui_ImplWin32_WndProcHandler_PlatformWindow;
|
||||||
|
wcex.cbClsExtra = 0;
|
||||||
|
wcex.cbWndExtra = 0;
|
||||||
|
wcex.hInstance = ::GetModuleHandle(nullptr);
|
||||||
|
wcex.hIcon = nullptr;
|
||||||
|
wcex.hCursor = nullptr;
|
||||||
|
wcex.hbrBackground = (HBRUSH)(COLOR_BACKGROUND + 1);
|
||||||
|
wcex.lpszMenuName = nullptr;
|
||||||
|
wcex.lpszClassName = _T("ImGui Platform");
|
||||||
|
wcex.hIconSm = nullptr;
|
||||||
|
::RegisterClassEx(&wcex);
|
||||||
|
|
||||||
|
ImGui_ImplWin32_UpdateMonitors();
|
||||||
|
|
||||||
|
// Register platform interface (will be coupled with a renderer interface)
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
platform_io.Platform_CreateWindow = ImGui_ImplWin32_CreateWindow;
|
||||||
|
platform_io.Platform_DestroyWindow = ImGui_ImplWin32_DestroyWindow;
|
||||||
|
platform_io.Platform_ShowWindow = ImGui_ImplWin32_ShowWindow;
|
||||||
|
platform_io.Platform_SetWindowPos = ImGui_ImplWin32_SetWindowPos;
|
||||||
|
platform_io.Platform_GetWindowPos = ImGui_ImplWin32_GetWindowPos;
|
||||||
|
platform_io.Platform_SetWindowSize = ImGui_ImplWin32_SetWindowSize;
|
||||||
|
platform_io.Platform_GetWindowSize = ImGui_ImplWin32_GetWindowSize;
|
||||||
|
platform_io.Platform_SetWindowFocus = ImGui_ImplWin32_SetWindowFocus;
|
||||||
|
platform_io.Platform_GetWindowFocus = ImGui_ImplWin32_GetWindowFocus;
|
||||||
|
platform_io.Platform_GetWindowMinimized = ImGui_ImplWin32_GetWindowMinimized;
|
||||||
|
platform_io.Platform_SetWindowTitle = ImGui_ImplWin32_SetWindowTitle;
|
||||||
|
platform_io.Platform_SetWindowAlpha = ImGui_ImplWin32_SetWindowAlpha;
|
||||||
|
platform_io.Platform_UpdateWindow = ImGui_ImplWin32_UpdateWindow;
|
||||||
|
platform_io.Platform_GetWindowDpiScale = ImGui_ImplWin32_GetWindowDpiScale; // FIXME-DPI
|
||||||
|
platform_io.Platform_OnChangedViewport = ImGui_ImplWin32_OnChangedViewport; // FIXME-DPI
|
||||||
|
|
||||||
|
// Register main window handle (which is owned by the main application, not by us)
|
||||||
|
// This is mostly for simplicity and consistency, so that our code (e.g. mouse handling etc.) can use same logic for main and secondary viewports.
|
||||||
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
|
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
|
||||||
|
ImGui_ImplWin32_ViewportData* vd = IM_NEW(ImGui_ImplWin32_ViewportData)();
|
||||||
|
vd->Hwnd = bd->hWnd;
|
||||||
|
vd->HwndOwned = false;
|
||||||
|
main_viewport->PlatformUserData = vd;
|
||||||
|
main_viewport->PlatformHandle = (void*)bd->hWnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui_ImplWin32_ShutdownPlatformInterface()
|
||||||
|
{
|
||||||
|
::UnregisterClass(_T("ImGui Platform"), ::GetModuleHandle(nullptr));
|
||||||
|
ImGui::DestroyPlatformWindows();
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy VK_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy VK_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
|
// [X] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
|
@ -118,6 +118,16 @@ Other changes:
|
|||||||
to handle minimization without burning CPU or GPU by running unthrottled code. (#7844)
|
to handle minimization without burning CPU or GPU by running unthrottled code. (#7844)
|
||||||
- Examples: SDL3: Update for API changes: SDL_Init() returns 0 on failure.
|
- Examples: SDL3: Update for API changes: SDL_Init() returns 0 on failure.
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Viewports: added optional platform_io.Platform_GetWindowWorkAreaInsets() hook
|
||||||
|
to allow backends to alter the default per-viewport work-area. (#7823)
|
||||||
|
- Backends: don't report monitors with DpiScale of 0, which seemed to be reported for
|
||||||
|
virtual monitors instead by accessibility drivers. (#7902) [@nicolasnoble, @ocornut]
|
||||||
|
- Backends: SDL2, SDL3: using SDL_HINT_WINDOW_NO_ACTIVATION_WHEN_SHOWN to support the
|
||||||
|
ImGuiViewportFlags_NoFocusOnAppearing flag, instead of using a Win32-specific hack.
|
||||||
|
(#7896) [@RT2Code]
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.91.0 (Released 2024-07-30)
|
VERSION 1.91.0 (Released 2024-07-30)
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
@ -277,6 +287,16 @@ Other changes:
|
|||||||
- Backends: GLFW+Emscripten: Fixed Emscripten warning when using mouse wheel on some setups
|
- Backends: GLFW+Emscripten: Fixed Emscripten warning when using mouse wheel on some setups
|
||||||
"Unable to preventDefault inside passive event listener". (#7647, #7600) [@ypujante]
|
"Unable to preventDefault inside passive event listener". (#7647, #7600) [@ypujante]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Viewports: Always update fallback monitor to primary monitor if there's one.
|
||||||
|
- Backends: OSX: Fixed NSAppKitVersion version limit for setWantsBestResolutionOpenGLSurface
|
||||||
|
usage. (#7814) [@YGXXD]
|
||||||
|
- Backends: SDL3: Fixed a bug preventing ImGuiViewportFlags_NoFocusOnAppearing support from
|
||||||
|
working (Windows only).
|
||||||
|
- Backends: Vulkan: ImGui_ImplVulkan_SwapBuffers() used by secondary viewports still proceeds
|
||||||
|
increasing frame counters on VK_SUBOPTIMAL_KHR. (#7825, #3881) [@NostraMagister]
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.90.9 (Released 2024-07-01)
|
VERSION 1.90.9 (Released 2024-07-01)
|
||||||
@ -357,6 +377,19 @@ Other changes:
|
|||||||
returning VK_SUBOPTIMAL_KHR, which doesn't seem to happen on Wayland. (#7671)
|
returning VK_SUBOPTIMAL_KHR, which doesn't seem to happen on Wayland. (#7671)
|
||||||
[@AndreiNego, @ocornut]
|
[@AndreiNego, @ocornut]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Windows, Menus: Fixed an issue where the size of sub-menu in their own viewport
|
||||||
|
would be erroneously clamped to the size of main viewport. (#7730)
|
||||||
|
- Merged GetBackgroundDrawList() and GetBackgroundDrawList(ImGuiViewport* viewport)
|
||||||
|
api entry points into a same one GetBackgroundDrawList(ImGuiViewport* viewport = NULL);
|
||||||
|
- Merged GetForegroundDrawList() and GetForegroundDrawList(ImGuiViewport* viewport)
|
||||||
|
api entry points into a same one GetForegroundDrawList(ImGuiViewport* viewport = NULL);
|
||||||
|
- Backends: SDL3: Update for introduction of SDL_GLContext from void*. (#7701, #7702)
|
||||||
|
[@bcsanches]
|
||||||
|
- Backends: Win32: Secondary viewports WndProc handler retrieve/set imgui context from
|
||||||
|
the HWND, allowing WndProc dispatch to work in multi-context setups.
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.90.8 (Released 2024-06-06)
|
VERSION 1.90.8 (Released 2024-06-06)
|
||||||
@ -507,6 +540,15 @@ versions of IsKeyPressed(), IsKeyChordPressed(), IsMouseClicked() prior to this
|
|||||||
those API public. Only past users of imgui_internal.h with the extra parameters will be affected.
|
those API public. Only past users of imgui_internal.h with the extra parameters will be affected.
|
||||||
Added asserts for valid flags in various functions to detect _some_ misuses, BUT NOT ALL.
|
Added asserts for valid flags in various functions to detect _some_ misuses, BUT NOT ALL.
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking: *BREAKING* changed signature of DockSpaceOverViewport() to allow passing
|
||||||
|
an explicit dockspace id if desired. (#7611)
|
||||||
|
Before: DockSpaceOverViewport(const ImGuiViewport* viewport = NULL, ImGuiDockNodeFlags flags = 0, ...);
|
||||||
|
After: DockSpaceOverViewport(ImGuiID dockspace_id = 0, const ImGuiViewport* viewport = NULL, ImGuiDockNodeFlags flags = 0, ...);
|
||||||
|
Simply add a leading 0 to your existing calls to DockSpaceOverViewport() if you have any.
|
||||||
|
- Tables: resizing border hit-rect scales according to current monitor dpi scale.
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.90.6 (Released 2024-05-08)
|
VERSION 1.90.6 (Released 2024-05-08)
|
||||||
@ -565,6 +607,18 @@ Other changes:
|
|||||||
- Examples: GLFW+WebGPU: Added support for WebGPU-native/Dawn (#7435, #7132) [@eliasdaler, @Zelif]
|
- Examples: GLFW+WebGPU: Added support for WebGPU-native/Dawn (#7435, #7132) [@eliasdaler, @Zelif]
|
||||||
- Examples: GLFW+WebGPU: Renamed example_emscripten_wgpu/ to example_glfw_wgpu/. (#7435, #7132)
|
- Examples: GLFW+WebGPU: Renamed example_emscripten_wgpu/ to example_glfw_wgpu/. (#7435, #7132)
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking: when io.ConfigDockingWithShift is enabled, fixed help tooltip erroneously
|
||||||
|
reading SetNextWindowXXX() data. (#6709, #4643, #7491) [@ocornut, @cfillion]
|
||||||
|
- Viewports: fixed outer-right edge of MenuBar clipping rectangle off by one when window
|
||||||
|
is located on a monitor with negative coordinates. (#6861, #2884) [@cfillion]
|
||||||
|
- Backends: Vulkan: reworked swap-chain resize handling for secondary viewports, fix for
|
||||||
|
typical Linux setups. (#2626, #3390, #3758, #7508, #7513) [@RoryO, @InsideBSITheSecond]
|
||||||
|
- Backends: Vulkan: create a custom pipeline for secondary viewports. Fixes issues
|
||||||
|
when user created main viewport uses a different renderpass. (#6325, #6305, #7398,
|
||||||
|
#3459, #3253, #3522) [@skaman, @FunMiles]
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.90.5 (Released 2024-04-11)
|
VERSION 1.90.5 (Released 2024-04-11)
|
||||||
@ -621,6 +675,11 @@ Other changes:
|
|||||||
Adding a link to the crawlable version, even though it is not intended for humans,
|
Adding a link to the crawlable version, even though it is not intended for humans,
|
||||||
to increase its search rank.
|
to increase its search rank.
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Backends: Win32: made it so that an appearing viewport showing up doesn't bring
|
||||||
|
its parent to front. (#7354)
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.90.4 (Released 2024-02-22)
|
VERSION 1.90.4 (Released 2024-02-22)
|
||||||
@ -654,6 +713,13 @@ Other changes:
|
|||||||
- Demo: Custom Rendering: better demonstrate PathArcTo(), PathBezierQuadraticCurveTo(),
|
- Demo: Custom Rendering: better demonstrate PathArcTo(), PathBezierQuadraticCurveTo(),
|
||||||
PathBezierCubicCurveTo(), PathStroke(), PathFillConvex() functions.
|
PathBezierCubicCurveTo(), PathStroke(), PathFillConvex() functions.
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Backends: GLFW: enable ImGuiBackendFlags_HasMouseHoveredViewport support with GLFW 3.3.x,
|
||||||
|
as required specs for it was relaxed in 1.87. This enable better viewport hovering detection
|
||||||
|
without GLFW 3.4's GLFW_MOUSE_PASSTHROUGH, with less reliance on dear imgui's own heuristic
|
||||||
|
of platform windows order. (#7316)
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.90.3 (Released 2024-02-14)
|
VERSION 1.90.3 (Released 2024-02-14)
|
||||||
@ -742,6 +808,18 @@ Other changes:
|
|||||||
Often requested in some form (#6962, #5219, #3290, #4627, #5054, #3878, #2881, #1506, #1216, #968),
|
Often requested in some form (#6962, #5219, #3290, #4627, #5054, #3878, #2881, #1506, #1216, #968),
|
||||||
and useful for interactive completion/suggestions popups (#2057, #718)
|
and useful for interactive completion/suggestions popups (#2057, #718)
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Added ImGuiWindowClass::FocusRouteParentWindowId as a way to connect the focus route between
|
||||||
|
a tool window to a parent document window, so that Shortcuts in the documents are routed when the
|
||||||
|
tool is focused (regardless of whether the tool is docked or in a floating viewport, etc.) (#6798)
|
||||||
|
- Added ImGuiDockNodeFlags_DockedWindowsInFocusRoute to automatically make a dockspace connect
|
||||||
|
the focus route of its docked window. This is provided a convenience in case you have windows
|
||||||
|
where a connection is not explicit. (#6798)
|
||||||
|
- Viewports: Fixed moving accross monitors when io.ConfigWindowsMoveFromTitleBarOnly is set. (#7299, #3071)
|
||||||
|
- Backends: OSX: Fixed not submitting Monitors info when viewports are not enabled, leading to
|
||||||
|
missing e.g. DpiScale info. (#7257) [@actboy168]
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.90.1 (Released 2024-01-10)
|
VERSION 1.90.1 (Released 2024-01-10)
|
||||||
@ -846,6 +924,15 @@ Other changes:
|
|||||||
(#6751) [@Traveller23, @ypujante]
|
(#6751) [@Traveller23, @ypujante]
|
||||||
- Examples: SDL3: Minor fixes following recent SDL3 in-progress development.
|
- Examples: SDL3: Minor fixes following recent SDL3 in-progress development.
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Windows: Fixed ImGuiCol_TitleBg/Active alpha being used for viewport-owned windows. (#7181) [@PathogenDavid]
|
||||||
|
- Backends: DX12: Changed swapchain scaling mode to DXGI_SCALING_NONE to reduce artifacts as
|
||||||
|
queued frames aren't synchronized with platform window resizes. (#7152, #7153) [@SuperWangKai]
|
||||||
|
- Backends: OSX: Fixed monitor and window position by correctly transforming Y origin on multi-viewports
|
||||||
|
multi-monitor setups. (#7028, #7101, #6009, #6432) [@dmirty-kuzmenko, @734vin]
|
||||||
|
- Backends: OSX: Fixed IME position in multi-monitor multi-viewports setups. (#7028) [@734vin]
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.90.0 (Released 2023-11-15)
|
VERSION 1.90.0 (Released 2023-11-15)
|
||||||
@ -1040,6 +1127,8 @@ Other changes:
|
|||||||
Fixed leaks, and added ImGui_ImplVulkan_DestroyFontsTexture() (probably no need to call this directly).
|
Fixed leaks, and added ImGui_ImplVulkan_DestroyFontsTexture() (probably no need to call this directly).
|
||||||
(#6943, #6715, #6327, #3743, #4618)
|
(#6943, #6715, #6327, #3743, #4618)
|
||||||
[@helynranta, @thomasherzog, @guybrush77, @albin-johansson, @MiroKaku, @benbatya-fb, @ocornut]
|
[@helynranta, @thomasherzog, @guybrush77, @albin-johansson, @MiroKaku, @benbatya-fb, @ocornut]
|
||||||
|
- Backends: Vulkan: use specified ColorAttachmentFormat when creating a secondary window when enabling
|
||||||
|
UseDynamicRendering option. (#6999, #5446, #5037) [@raaaviol]
|
||||||
- Backends: GLFW: Clear emscripten's MouseWheel callback before shutdown. (#6790, #6096, #4019) [@halx99]
|
- Backends: GLFW: Clear emscripten's MouseWheel callback before shutdown. (#6790, #6096, #4019) [@halx99]
|
||||||
- Backends: GLFW: Added support for F13 to F24 function keys. (#6891)
|
- Backends: GLFW: Added support for F13 to F24 function keys. (#6891)
|
||||||
- Backends: SDL2, SDL3: Added support for F13 to F24 function keys, AppBack, AppForward. (#6891)
|
- Backends: SDL2, SDL3: Added support for F13 to F24 function keys, AppBack, AppForward. (#6891)
|
||||||
@ -1057,6 +1146,31 @@ Other changes:
|
|||||||
- Examples: GLFW+Vulkan, SDL+Vulkan: Simplified and removed code due to backend improvements.
|
- Examples: GLFW+Vulkan, SDL+Vulkan: Simplified and removed code due to backend improvements.
|
||||||
- Internals: Renamed ImFloor() to ImTrunc(). Renamed ImFloorSigned() to ImFloor(). (#6861)
|
- Internals: Renamed ImFloor() to ImTrunc(). Renamed ImFloorSigned() to ImFloor(). (#6861)
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Viewports: Fixed window inner clipping rectangle off by one when window is located on a monitor
|
||||||
|
with negative coordinates. While it is expected that other small issues with arise from this
|
||||||
|
situation, at the moment we are fixing the most noticeable one. (#6861, #2884) [@Vuhdo, @alektron]
|
||||||
|
- Docking: revised undocking to reduce accidental whole-node undocking:
|
||||||
|
- cannot undock a whole node by dragging from empty space in tab-bar.
|
||||||
|
- can undock whole node by dragging from window/collapse menu button.
|
||||||
|
- can undock single window by dragging from its tab.
|
||||||
|
- can still move (but not undock) whole node or whole hierarchy when node is part of a
|
||||||
|
floating hierarchy.
|
||||||
|
- added tooltip when hovering the collapse/window menu button, to faciliate understanding
|
||||||
|
that whole dock node may be undocked or grabbed from here.
|
||||||
|
- Docking: Fixed an issue leading to incorrect restoration of selected tab in dock nodes that
|
||||||
|
don't carry the currently focused window. (#2304)
|
||||||
|
- Docking: added ImGuiDockNodeFlags_NoUndocking. (#2999, #6823, #6780, #3492)
|
||||||
|
- Docking: renamed ImGuiDockNodeFlags_NoSplit to ImGuiDockNodeFlags_NoDockingSplit.
|
||||||
|
- Docking: renamed ImGuiDockNodeFlags_NoDockingInCentralNode to ImGuiDockNodeFlags_NoDockingOverCentralNode.
|
||||||
|
- Docking: Internals: renamed ImGuiDockNodeFlags_NoDockingSplitMe to ImGuiDockNodeFlags_NoDockingSplit.
|
||||||
|
- Docking: Fixed a bug where ClassId compare tests (when using SetNextWindowClass) on success would
|
||||||
|
prevent further filter from running, namely the one that prevent docking over a popup.
|
||||||
|
- Backends: GLFW: Fixed an assertion in situation where the WndProc handler is different between
|
||||||
|
main and secondary viewport (may happen due to third-party hooks). (#6889)
|
||||||
|
- Backends: DX9: Fixed incorrect assert triggering on reopening session with minimized windows. (#3424)
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.89.9 (Released 2023-09-04)
|
VERSION 1.89.9 (Released 2023-09-04)
|
||||||
@ -1114,6 +1228,11 @@ Other changes:
|
|||||||
- Examples: Emscripten+WebGPU: Fixed WGPUInstance creation process + use preferred
|
- Examples: Emscripten+WebGPU: Fixed WGPUInstance creation process + use preferred
|
||||||
framebuffer format. (#6640, #6748) [@smileorigin]
|
framebuffer format. (#6640, #6748) [@smileorigin]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking: when io.ConfigDockingWithShift is enabled, staying stationary while moving
|
||||||
|
a window displays an help tooltip to increase affordance. (#6709, #4643)
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.89.8 (Released 2023-08-01)
|
VERSION 1.89.8 (Released 2023-08-01)
|
||||||
@ -1182,6 +1301,16 @@ Other changes:
|
|||||||
- Examples: Vulkan: Creating minimal descriptor pools to fit only what is needed by
|
- Examples: Vulkan: Creating minimal descriptor pools to fit only what is needed by
|
||||||
example. (#6642) [@SaschaWillem]
|
example. (#6642) [@SaschaWillem]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking, Style: resizing separators use same colors as window borders (ImGuiCol_Border)
|
||||||
|
for consistency. With default styles it doesn't make a big difference. (#2522) [@rmitton]
|
||||||
|
In the future if we promote using thick value for inner/outer docking padding we may
|
||||||
|
need to introduce new colors for it.
|
||||||
|
- Docking: added style.DockingSeparatorSize, ImGuiStyleVar_DockingSeparatorSize. Now
|
||||||
|
also scaled by style.ScaleAllSizes(). (#3481, #4721, #2522) [@PossiblyAShrub, @wobbier]
|
||||||
|
- Docking: fixed rendering of docked-window scrollbar above outer border. (#2522)
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.89.7 (Released 2023-07-04)
|
VERSION 1.89.7 (Released 2023-07-04)
|
||||||
@ -1277,6 +1406,23 @@ Other changes:
|
|||||||
- Examples: Win32+OpenGL3: Changed DefWindowProc() to DefWindowProcW() to match other examples
|
- Examples: Win32+OpenGL3: Changed DefWindowProc() to DefWindowProcW() to match other examples
|
||||||
and support the example app being compiled without UNICODE. (#6516, #5725, #5961, #5975) [@yenixing]
|
and support the example app being compiled without UNICODE. (#6516, #5725, #5961, #5975) [@yenixing]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Viewports+Docking: Fixed extraneous viewport+platform-window recreation in various
|
||||||
|
combination of showing or hiding windows, docking with/without split, undocking.
|
||||||
|
While with some backends and without OS decorations, some extraneous window recreation
|
||||||
|
were visibly not noticeable, they would typically become noticeable when enabling
|
||||||
|
OS decorations on those windows (e.g. Windows title bar fade-in/animation).
|
||||||
|
- Viewports: Closing a viewport via OS/platform means (e.g. OS close button or task-bar menu),
|
||||||
|
mark all windows in this viewport as closed.
|
||||||
|
- Docking: Fixed one-frame flickering on reappearing windows binding to a dock node
|
||||||
|
where a later-submitted window was already bound.
|
||||||
|
- Docking: Fixed dragging from title-bar empty space (regression from 1.88 related to
|
||||||
|
keeping ID alive when calling low-level ButtonBehavior() directly). (#5181, #2645)
|
||||||
|
- Docking: [Internal] DockBuilderDockWindow() API calls don't clear docking order
|
||||||
|
if the target node is same as existing one.
|
||||||
|
- Backends: Win32: Added support for changing ParentViewportID after viewport creation.
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.89.6 (Released 2023-05-31)
|
VERSION 1.89.6 (Released 2023-05-31)
|
||||||
@ -1346,6 +1492,23 @@ Other changes:
|
|||||||
- Examples: Added SDL3+SDL_Renderer example. (#6286)
|
- Examples: Added SDL3+SDL_Renderer example. (#6286)
|
||||||
- Examples: Updated all Visual Studio projects and batches to use /utf-8 argument.
|
- Examples: Updated all Visual Studio projects and batches to use /utf-8 argument.
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Viewports: Fixed platform-side focus (e.g. Alt+Tab) from leading to accidental
|
||||||
|
closure of Modal windows. Regression from 1.89.5. (#6357, #6299)
|
||||||
|
- Viewports: Fixed loss of imgui-side focus when dragging a secondary viewport back in
|
||||||
|
main viewport, due to platform-side handling changes. Regression from 1.89.5 (#6299)
|
||||||
|
- Viewports: Avoid applying imgui-side focus when focus change is due to a viewport
|
||||||
|
destruction. Fixes erroneous popup closure on closing a previous popup. (#6462, #6299)
|
||||||
|
- Viewports: Added void* ImGuiPlatformMonitor::PlatformHandle field (backend-dependant),
|
||||||
|
for usage by user code.
|
||||||
|
- Backends: GLFW: Preserve monitor list when there are no monitor, may briefly
|
||||||
|
happen when recovering from macOS sleeping mode. (#5683) [@Guistac]
|
||||||
|
- Backends: SDL2: Update monitor list when receiving a display event. (#6348)
|
||||||
|
Note however that SDL2 currently doesn't have an event for a DPI/Scaling change,
|
||||||
|
so monitor data won't be updated in this situation.
|
||||||
|
- Backends: SDL3: Update monitor list when receiving a display event. (#6348)
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.89.5 (Released 2023-04-13)
|
VERSION 1.89.5 (Released 2023-04-13)
|
||||||
@ -1403,7 +1566,6 @@ Other changes:
|
|||||||
is to other IME function such as SDL_SetTextInputRect(). (#6306, #6071, #1953)
|
is to other IME function such as SDL_SetTextInputRect(). (#6306, #6071, #1953)
|
||||||
- Backends: GLFW: Added support on Win32 only for io.AddMouseSourceEvent() to discriminate
|
- Backends: GLFW: Added support on Win32 only for io.AddMouseSourceEvent() to discriminate
|
||||||
Mouse/TouchScreen/Pen. (#2334, #2702)
|
Mouse/TouchScreen/Pen. (#2334, #2702)
|
||||||
- Backends: GLFW: Fixed key modifiers handling on secondary viewports. (#6248, #6034) [@aiekick]
|
|
||||||
- Backends: Android: Added support for io.AddMouseSourceEvent() to discriminate Mouse/TouchScreen/Pen.
|
- Backends: Android: Added support for io.AddMouseSourceEvent() to discriminate Mouse/TouchScreen/Pen.
|
||||||
(#6315) [@PathogenDavid]
|
(#6315) [@PathogenDavid]
|
||||||
- Backends: OSX: Added support for io.AddMouseSourceEvent() to discriminate Mouse/Pen.
|
- Backends: OSX: Added support for io.AddMouseSourceEvent() to discriminate Mouse/Pen.
|
||||||
@ -1419,6 +1581,16 @@ Other changes:
|
|||||||
- TestSuite: Added variety of new regression tests and improved/amended existing ones
|
- TestSuite: Added variety of new regression tests and improved/amended existing ones
|
||||||
in imgui_test_engine/ repo. [@PathogenDavid, @ocornut]
|
in imgui_test_engine/ repo. [@PathogenDavid, @ocornut]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Viewports: Setting focus from Platform/OS (e.g. via decoration, or Alt-Tab) sets corresponding
|
||||||
|
focus at Dear ImGui level (generally last focused window in the viewport). (#6299)
|
||||||
|
- Docking: Fixed using GetItemXXX() or IsItemXXX() functions after a DockSpace(). (#6217)
|
||||||
|
- Backends: GLFW: Fixed key modifiers handling on secondary viewports. (#6248, #6034) [@aiekick]
|
||||||
|
- Backends: GLFW: Fixed Emscripten erroneously enabling multi-viewport support, leading to assert. (#5683)
|
||||||
|
- Backends: SDL2/SDL3: Fixed IME text input rectangle position with viewports. (#6071, #1953)
|
||||||
|
- Backends: SDL3: Fixed for compilation with multi-viewports. (#6255) [@P3RK4N]
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.89.4 (Released 2023-03-14)
|
VERSION 1.89.4 (Released 2023-03-14)
|
||||||
@ -1493,7 +1665,6 @@ Other changes:
|
|||||||
and ImGuiConfigFlags_NavEnableGamepad by default. (#787)
|
and ImGuiConfigFlags_NavEnableGamepad by default. (#787)
|
||||||
- Internals: Misc tweaks to facilitate applying an explicit-context patch. (#5856) [@Dragnalith]
|
- Internals: Misc tweaks to facilitate applying an explicit-context patch. (#5856) [@Dragnalith]
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.89.3 (Released 2023-02-14)
|
VERSION 1.89.3 (Released 2023-02-14)
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
@ -1594,6 +1765,10 @@ Other changes:
|
|||||||
- Examples: SDL2+SDL_Renderer: Added call to SDL_RenderSetScale() to fix display on a
|
- Examples: SDL2+SDL_Renderer: Added call to SDL_RenderSetScale() to fix display on a
|
||||||
Retina display (albeit lower-res as our other unmodified examples). (#6121, #6065, #5931).
|
Retina display (albeit lower-res as our other unmodified examples). (#6121, #6065, #5931).
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Backends: GLFW: Handle unsupported glfwGetVideoMode() for Emscripten. (#6096)
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.89.2 (Released 2023-01-05)
|
VERSION 1.89.2 (Released 2023-01-05)
|
||||||
@ -1644,6 +1819,17 @@ All changes:
|
|||||||
- Backends: Vulkan: Fixed sampler passed to ImGui_ImplVulkan_AddTexture() not being honored as we were using
|
- Backends: Vulkan: Fixed sampler passed to ImGui_ImplVulkan_AddTexture() not being honored as we were using
|
||||||
an immutable sampler. (#5502, #6001, #914) [@martin-ejdestig, @rytisss]
|
an immutable sampler. (#5502, #6001, #914) [@martin-ejdestig, @rytisss]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking: Internals: fixed DockBuilderCopyDockSpace() crashing when windows not in the
|
||||||
|
remapping list are docked on the left or top side of a split. (#6035)
|
||||||
|
- Docking: fixed DockSpace() with ImGuiDockNodeFlags_KeepAliveOnly marking current window
|
||||||
|
as written to, even if it doesn't technically submit an item. This allow using KeepAliveOnly
|
||||||
|
from any window location. (#6037)
|
||||||
|
- Backends: OSX: fixed typo in ImGui_ImplOSX_GetWindowSize that would cause issues when resiing
|
||||||
|
from OS decorations, if they are enabled on secondary viewports. (#6009) [@sivu]
|
||||||
|
- Backends: Metal: fixed secondary viewport rendering. (#6015) [@dmirty-kuzmenko]
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.89.1 (Released 2022-11-24)
|
VERSION 1.89.1 (Released 2022-11-24)
|
||||||
@ -1670,6 +1856,13 @@ Other changes:
|
|||||||
- Backends: GLFW: cancel out errors emitted by glfwGetKeyName() when a name is missing. (#5908)
|
- Backends: GLFW: cancel out errors emitted by glfwGetKeyName() when a name is missing. (#5908)
|
||||||
- Backends: WebGPU: fixed validation error with default depth buffer settings. (#5869, #5914) [@kdchambers]
|
- Backends: WebGPU: fixed validation error with default depth buffer settings. (#5869, #5914) [@kdchambers]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Viewports: Fixed collapsed windows setting ImGuiViewportFlags_NoRendererClear without
|
||||||
|
making title bar color opaque, leading to potential texture/fb garbage being visible.
|
||||||
|
Right now as we don't fully support transparent viewports (#2766), so we turn that
|
||||||
|
'TitleBgCollapsed' color opaque just lke we do for 'WindowBG' on uncollapsed windows.
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.89 (Released 2022-11-15)
|
VERSION 1.89 (Released 2022-11-15)
|
||||||
@ -1861,6 +2054,23 @@ Other Changes:
|
|||||||
- Backends: Vulkan: Added experimental ImGui_ImplVulkan_RemoveTexture() for api symmetry. (#914, #5738).
|
- Backends: Vulkan: Added experimental ImGui_ImplVulkan_RemoveTexture() for api symmetry. (#914, #5738).
|
||||||
- Backends: WebGPU: fixed rendering when a depth buffer is enabled. (#5869) [@brainlag]
|
- Backends: WebGPU: fixed rendering when a depth buffer is enabled. (#5869) [@brainlag]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking: Fixed incorrect focus highlight on docking node when focusing a menu. (#5702)
|
||||||
|
- Docking, Nav: Fixed using gamepad/keyboard navigation not being able enter menu layer when
|
||||||
|
it only contained the standard Collapse/Close buttons and no actual menu. (#5463, #4792)
|
||||||
|
- Docking: Fixed regression introduced in v1.87 when docked window content not rendered
|
||||||
|
while switching between with CTRL+Tab. [@rokups]
|
||||||
|
- Docking: Fixed amending into an existing tab bar from rendering invisible items. (#5515)
|
||||||
|
- Docking: Made spacing between dock nodes not a dropping gap. When hovering it only
|
||||||
|
outer-docking drop markers are visible.
|
||||||
|
- Docking+Viewports: Fixed undocking window node causing parent viewports to become unresponsive
|
||||||
|
in certain situation (e.g. hidden tab bar). (#5503) [@rokups]
|
||||||
|
- Backends: SDL: Fixed building backend under non-OSX Apple targets (e.g. iPhone). (#5665)
|
||||||
|
- Backends: SDL: Fixed drag'n drop crossing a viewport border losing mouse coordinates. (#5710, #5012)
|
||||||
|
- Backends: GLFW: Fixed leftover static variable preventing from changing or
|
||||||
|
reinitializing backend while application is running. (#4616, #5434) [@rtoumazet]
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.88 (Released 2022-06-21)
|
VERSION 1.88 (Released 2022-06-21)
|
||||||
@ -1995,6 +2205,26 @@ Other Changes:
|
|||||||
- Examples: Emscripten+WebGPU: Fix building for latest WebGPU specs. (#3632)
|
- Examples: Emscripten+WebGPU: Fix building for latest WebGPU specs. (#3632)
|
||||||
- Examples: OSX+Metal, OSX+OpenGL: Removed now-unnecessary calls to ImGui_ImplOSX_HandleEvent(). (#4821)
|
- Examples: OSX+Metal, OSX+OpenGL: Removed now-unnecessary calls to ImGui_ImplOSX_HandleEvent(). (#4821)
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking: Fixed floating docked nodes not being clamped into viewport workrect to stay reachable
|
||||||
|
when io.ConfigWindowsMoveFromTitleBarOnly is true and multi-viewports are disabled. (#5044)
|
||||||
|
- Docking: Fixed a regression where moving window would be interrupted after undocking a tab
|
||||||
|
when io.ConfigDockingAlwaysTabBar is true. (#5324) [@rokups]
|
||||||
|
- Docking: Fixed incorrect focus highlight on docking node when focusing empty central node
|
||||||
|
or a child window which was manually injected into a dockspace window.
|
||||||
|
- Docking, Modal: Fixed a crash when opening popup from a parent which is being docked on the same frame. (#5401)
|
||||||
|
- Viewports: Fixed an issue where MouseViewport was lagging by a frame when using 1.87 Input Queue.
|
||||||
|
A common side-effect would be that when releasing a window drag the underlying window would highlight
|
||||||
|
for a frame. (#5837, #4921) [@cfillion]
|
||||||
|
- Viewports: Fixed translating a host viewport from briefly altering the size of AlwaysAutoResize windows. (#5057)
|
||||||
|
- Viewports: Fixed main viewport size not matching ImDrawData::DisplaySize for one frame during resize
|
||||||
|
when multi-viewports are disabled. (#4900)
|
||||||
|
- Backends: SDL: Fixed dragging out main viewport broken on some SDL setups. (#5012) [@rokups]
|
||||||
|
- Backends: OSX: Added support for multi-viewports. [@stuartcarnie, @metarutaiga] (#4821, #2778)
|
||||||
|
- Backends: Metal: Added support for multi-viewports. [@stuartcarnie, @metarutaiga] (#4821, #2778)
|
||||||
|
- Examples: OSX+Metal, SDL+Metal, GLFW+Metal: Added support for multi-viewports. [@rokups]
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.87 (Released 2022-02-07)
|
VERSION 1.87 (Released 2022-02-07)
|
||||||
@ -2137,6 +2367,29 @@ Other Changes:
|
|||||||
- Backends: WebGPU: Fixed incorrect size parameters in wgpuRenderPassEncoderSetIndexBuffer() and
|
- Backends: WebGPU: Fixed incorrect size parameters in wgpuRenderPassEncoderSetIndexBuffer() and
|
||||||
wgpuRenderPassEncoderSetVertexBuffer() calls. (#4891) [@FeepsDev]
|
wgpuRenderPassEncoderSetVertexBuffer() calls. (#4891) [@FeepsDev]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking: Fixed a CTRL+TAB crash when aiming at an empty docked window. (#4792)
|
||||||
|
- Docking: Tabs use their own identifier instead of the Window identifier.
|
||||||
|
(This will invalidate some stored .ini data such as last selected tab, sorry!)
|
||||||
|
- Docking: Fixed size constraints not working on single window holding on a dock id (still doesn't work on docked windows).
|
||||||
|
- Docking: Fixed CTRL+TAB back into a docked window not selecting menu layer when no item are on main layer.
|
||||||
|
- Viewports, IO: Added io.AddMouseViewportEvent() function to queue hovered viewport change (when known by backend).
|
||||||
|
- Viewports: Relaxed specs for backend supporting ImGuiBackendFlags_HasMouseHoveredViewport: it is now _optional_
|
||||||
|
for the backend to have to ignore viewports with the _NoInputs flag when call io.AddMouseViewportEvent(). It is
|
||||||
|
much better if they can (Win32 and GLFW 3.3+ backends can, SDL and GLFW 3.2 backends cannot, they are lacking data).
|
||||||
|
A concrete example is: when dragging a viewport for docking, the viewport is marked with _NoInputs to allow us
|
||||||
|
to pick the target viewports for docking. If the backend reports a viewport with _NoInputs when calling the
|
||||||
|
io.AddMouseViewportEvent() function, then Dear ImGui will revert to its flawed heuristic to find the viewport under.
|
||||||
|
By lowering those specs, we allow the SDL and more backend to support this, only relying on the heuristic in a few
|
||||||
|
drag and drop situations rather that relying on it everywhere.
|
||||||
|
- Viewports: Fixed a CTRL+TAB crash with viewports enabled when the window list needs to appears in
|
||||||
|
its own viewport (regression from 1.86). (#4023, #787)
|
||||||
|
- Viewports: Fixed active InputText() from preventing viewports to merge. (#4212)
|
||||||
|
- Backends: SDL: Added support for ImGuiBackendFlags_HasMouseHoveredViewport now that its specs have been lowered.
|
||||||
|
- (Breaking) Removed ImGuiPlatformIO::Platform_SetImeInputPos() in favor of newly standardized
|
||||||
|
io.SetPlatformImeDataFn() function. Should not affect more than default backends.
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.86 (Released 2021-12-22)
|
VERSION 1.86 (Released 2021-12-22)
|
||||||
@ -2235,6 +2488,24 @@ Other Changes:
|
|||||||
wgpuRenderPassEncoderSetIndexBuffer() functions as validation layers appears to not do what the
|
wgpuRenderPassEncoderSetIndexBuffer() functions as validation layers appears to not do what the
|
||||||
in-flux specs says. (#4766) [@meshula]
|
in-flux specs says. (#4766) [@meshula]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking: Revert removal of io.ConfigDockingWithShift config option (removed in 1.83). (#4643)
|
||||||
|
- Docking: Fixed a bug undocking windows docked into a non-visible or _KeepAliveOnly dockspace
|
||||||
|
when unrelated windows submitted before the dockspace have dynamic visibility. (#4757)
|
||||||
|
- Docking, Style: Docked windows honor ImGuiCol_WindowBg. (#2700, #2539)
|
||||||
|
- Docking, Style: Docked windows honor display their border properly. (#2522)
|
||||||
|
- Docking: Fixed incorrectly rounded tab bars for dock node that are not at the top of their dock tree.
|
||||||
|
- Docking: Fixed single-frame node pos/size inconsistencies when window stop or start being submitted.
|
||||||
|
- Docking: Prevent docking any window created above a popup/modal. (#4317)
|
||||||
|
- Viewports: Made it possible to explicitly assign ImGuiWindowClass::ParentViewportId to 0 in order
|
||||||
|
to ensure a window is not parented. Previously this would use the global default (which might be 0,
|
||||||
|
but not always as it would depend on io.ConfigViewportsNoDefaultParent). (#3152, #2871)
|
||||||
|
- Viewports: Fixed tooltip in own viewport over modal from being incorrectly dimmed. (#4729)
|
||||||
|
- Viewports: Fixed CTRL+TAB highlight outline on docked windows not always fitting in host viewport.
|
||||||
|
- Backends: Made it possible to shutdown default Platform Backends before the Renderer backends. (#4656)
|
||||||
|
- Disabled: Fixed nested BeginDisabled()/EndDisabled() bug in Docking branch due to bad merge. (#4655, #4452, #4453, #4462)
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.85 (Released 2021-10-12)
|
VERSION 1.85 (Released 2021-10-12)
|
||||||
@ -2253,6 +2524,10 @@ Breaking Changes:
|
|||||||
Can use 'GetWindowContentRegionMax().x - GetWindowContentRegionMin().x' instead but it's not
|
Can use 'GetWindowContentRegionMax().x - GetWindowContentRegionMin().x' instead but it's not
|
||||||
very useful in practice, and the only use of it in the demo was illfit.
|
very useful in practice, and the only use of it in the demo was illfit.
|
||||||
Using 'GetContentRegionAvail().x' is generally a better choice.
|
Using 'GetContentRegionAvail().x' is generally a better choice.
|
||||||
|
- (Docking branch) IsWindowFocused() and IsWindowHovered() with only the _ChildWindows flag
|
||||||
|
and without the _RootWindow flag used to leak docking hierarchy, so a docked window would
|
||||||
|
return as the child of the window hosting the dockspace. This was inconsistent and incorrect
|
||||||
|
with other behaviors so we fixed it. Added a new _DockHierarchy flag to opt-in this behavior.
|
||||||
|
|
||||||
Other Changes:
|
Other Changes:
|
||||||
|
|
||||||
@ -2326,6 +2601,29 @@ Other Changes:
|
|||||||
- Backends: All renderers: Normalize clipping rect handling across backends. (#4464)
|
- Backends: All renderers: Normalize clipping rect handling across backends. (#4464)
|
||||||
- Examples: Added SDL + SDL_Renderer example in "examples/example_sdl_sdlrenderer/" folder. (#3926) [@1bsyl]
|
- Examples: Added SDL + SDL_Renderer example in "examples/example_sdl_sdlrenderer/" folder. (#3926) [@1bsyl]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- IsWindowFocused: Fixed using ImGuiFocusedFlags_ChildWindows (without _RootWindow) from leaking the
|
||||||
|
docking hierarchy. Added ImGuiFocusedFlags_DockHierarchy flag to consider docking hierarchy in the test.
|
||||||
|
- IsWindowHovered: Fixed using ImGuiHoveredFlags_ChildWindows (without _RootWindow) from leaking the
|
||||||
|
docking hierarchy. Added ImGuiHoveredFlags_DockHierarchy flag to consider docking hierarchy in the test.
|
||||||
|
- Nav: Fixed an issue with losing focus on docked windows when pressing Alt while keyboard navigation
|
||||||
|
is disabled. (#4547, #4439) [@PathogenDavid]
|
||||||
|
- Docking: Fixed IsItemHovered() and functions depending on it (e.g. BeginPopupContextItem()) when
|
||||||
|
called after Begin() on a docked window (broken 2021/03/04). (#3851)
|
||||||
|
- Docking: Improved resizing system so that non-central zone are better at keeping their fixed size.
|
||||||
|
The algorithm is still not handling the allocation of size ideally for nested sibling, but it got better.
|
||||||
|
- Docking: Fixed settings load issue when mouse wheeling. (#4310)
|
||||||
|
- Docking: Fixed manually created floating node with a central node from not hiding when windows are gone.
|
||||||
|
- Docking + Drag and Drop: Fixed using BeginDragDropSource() or BeginDragDropTarget() inside a Begin()
|
||||||
|
that returned false because the window is docked. (#4515)
|
||||||
|
- Viewports: Fixed a crash while a window owning its viewport disappear while being dragged.
|
||||||
|
It would manifest when e.g. reconfiguring dock nodes while dragging.
|
||||||
|
- Viewports: Fixed unnecessary creation of temporary viewports when multiple docked windows
|
||||||
|
got reassigned to a new node (created mid-frame) which already has a HostWindow.
|
||||||
|
- Viewports: Fixed window with viewport ini data immediately merged into a host viewport from
|
||||||
|
leaving a temporary viewport alive for a frame (would leak into backend).
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.84.2 (Released 2021-08-23)
|
VERSION 1.84.2 (Released 2021-08-23)
|
||||||
@ -2462,6 +2760,25 @@ Other Changes:
|
|||||||
- Examples: Updated all .vcxproj to VS2015 (toolset v140) to facilitate usage with vcpkg.
|
- Examples: Updated all .vcxproj to VS2015 (toolset v140) to facilitate usage with vcpkg.
|
||||||
- Examples: SDL2: Accommodate for vcpkg install having headers in SDL2/SDL.h vs SDL.h.
|
- Examples: SDL2: Accommodate for vcpkg install having headers in SDL2/SDL.h vs SDL.h.
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking: Clicking on the right-most close button of a docking node closes all windows. (#4186)
|
||||||
|
- Docking: Fix IsWindowAppearing() and ImGuiCond_Appearing on docked windows. (#4177, #3982, #1497, #1061)
|
||||||
|
- Docking: Fix crash using DockBuilderRemoveNode() in some situations. (#3111, #3179, #3203, #4295) [@hsimyu]
|
||||||
|
- Docking: Fix crash when a dock node gets re-qualified as dockspace>floating>dockspace, which tends to happen
|
||||||
|
when incorrectly calling DockBuilderAddNode() without ImGuiDockNodeFlags_Dockspace and using it as a Dockspace
|
||||||
|
on the next frame after the floating window hosting the node has been automatically created. (#3203, #4295)
|
||||||
|
- Docking: Reworked node flags saving/inheritance so that flags enforced by docked windows via the
|
||||||
|
DockNodeFlagsOverrideSet mechanism are are not left in empty dockspace nodes once the windows gets undocked.
|
||||||
|
(#4292, #3834, #3633, #3521, #3492, #3335, #2999, #2648)
|
||||||
|
- Docking: (Internal/Experimental) Removed DockNodeFlagsOverrideClear flags from ImGuiWindowClass as
|
||||||
|
it is ambiguous how to apply them and we haven't got a use out of them yet.
|
||||||
|
- Docking: Fixed ImGuiWindowFlags_UnsavedDocument clipping label in docked windows when there are
|
||||||
|
no close button. (#5745)
|
||||||
|
- Viewports: Fix popup/tooltip created without a parent window from being given a ParentViewportId value
|
||||||
|
from the implicit/fallback window. (#4236, #2409)
|
||||||
|
- Backends: Vulkan: Fix the use of the incorrect fence for secondary viewports. (#4208) [@FunMiles]
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.83 (Released 2021-05-24)
|
VERSION 1.83 (Released 2021-05-24)
|
||||||
@ -2546,6 +2863,22 @@ Other Changes:
|
|||||||
- Docs: Improvements to description of using colored glyphs/emojis. (#4169, #3369)
|
- Docs: Improvements to description of using colored glyphs/emojis. (#4169, #3369)
|
||||||
- Docs: Improvements to minor mistakes in documentation comments (#3923) [@ANF-Studios]
|
- Docs: Improvements to minor mistakes in documentation comments (#3923) [@ANF-Studios]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- [Breaking] Removed io.ConfigDockingWithShift config option. Behavior always equivalent to having the
|
||||||
|
option set to false (dock/undock by default, hold shift to avoid docking). (#2109)
|
||||||
|
- Docking: DockSpace() returns its node ID.
|
||||||
|
- Docking: Dockspace() never draws a background. (#3924)
|
||||||
|
- Docking: Undocking nodes/windows covering most of the monitor max their size down to 90% to ease manipulations.
|
||||||
|
- Docking: Docking node tab bar honors ItemInnerSpacing.x before first tab. (#4130)
|
||||||
|
- Docking: Tweak rendering and alignment of dock node menu marker. (#4130)
|
||||||
|
- Docking: Fixed restoring of tab order within a dockspace or a split node.
|
||||||
|
- Docking: Fixed reappearing docked windows with no close button showing a tab with extraneous space for one frame.
|
||||||
|
- Docking: Fixed multiple simultaneously reappearing window from appearing undocked for one frame.
|
||||||
|
- Viewports: Hotfix for crash in monitor array access, caused by 4b9bc4902. (#3967)
|
||||||
|
- Backends, Viewports: GLFW: Add a workaround for stuck keys after closing a GLFW window (#3837).
|
||||||
|
- Backends, Viewports: Vulkan: Rebuild swapchain on VK_SUBOPTIMAL_KHR. (#3881)
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.82 (Released 2021-02-15)
|
VERSION 1.82 (Released 2021-02-15)
|
||||||
@ -2641,6 +2974,13 @@ Other Changes:
|
|||||||
scheduled builds builds are not required. [@rokups]
|
scheduled builds builds are not required. [@rokups]
|
||||||
- Log/Capture: Added LogTextV, a va_list variant of LogText. [@PathogenDavid]
|
- Log/Capture: Added LogTextV, a va_list variant of LogText. [@PathogenDavid]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Viewports: Fix setting of ImGuiViewportFlags_NoRendererClear. (#3213)
|
||||||
|
- Viewports: Added GetViewportPlatformMonitor() with a safety net to keep code portable.
|
||||||
|
- Viewports, Backends: SDL: Fix missing ImGuiBackendFlags_HasSetMousePos flag in docking branch.
|
||||||
|
- Viewports, Backends: GLFW: Fix application of WantSetMousePos. (#1542, #787)
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.81 (Released 2021-02-10)
|
VERSION 1.81 (Released 2021-02-10)
|
||||||
@ -2722,6 +3062,17 @@ Other Changes:
|
|||||||
- Examples: WebGPU: Added Emscripten+WebGPU example. (#3632) [@bfierz]
|
- Examples: WebGPU: Added Emscripten+WebGPU example. (#3632) [@bfierz]
|
||||||
- Backends: GLFW: Added ImGui_ImplGlfw_InitForOther() initialization call to use with non OpenGL API. (#3632)
|
- Backends: GLFW: Added ImGui_ImplGlfw_InitForOther() initialization call to use with non OpenGL API. (#3632)
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking: Fix losing docking information on closed windows for which the hosting node was split. (#3716) [@GamingMinds-DanielC]
|
||||||
|
- Docking: Fix gap in hit test hole when using ImGuiDockNodeFlags_PassthruCentralNode touching the edge of a viewport. (#3733)
|
||||||
|
- Viewports: (Breaking) removed ImGuiPlatformIO::MainViewport which is now pretty much unused and duplicate
|
||||||
|
(and misleading as we will evolve the concept).
|
||||||
|
- Viewports: (Breaking) turned ImGuiViewport::GetWorkPos(), ImGuiViewport::GetWorkSize() into regular fields
|
||||||
|
(WorkPos, WorkSize) before exposing in master branch.
|
||||||
|
- Viewports: Fix issue inferring viewport z-order when new popups gets created. (#3734) + Metrics updates.
|
||||||
|
- Viewports, Backends: Vulkan: handle VK_ERROR_OUT_OF_DATE_KHR when resizing secondary viewport (#3766, #3758)
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.80 (Released 2021-01-21)
|
VERSION 1.80 (Released 2021-01-21)
|
||||||
@ -2841,6 +3192,14 @@ Other Changes:
|
|||||||
- Docs: Split examples/README.txt into docs/BACKENDS.md and docs/EXAMPLES.md, and improved them.
|
- Docs: Split examples/README.txt into docs/BACKENDS.md and docs/EXAMPLES.md, and improved them.
|
||||||
- Docs: Consistently renamed all occurrences of "binding" and "back-end" to "backend" in comments and docs.
|
- Docs: Consistently renamed all occurrences of "binding" and "back-end" to "backend" in comments and docs.
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking: Docked windows honor change of tab and text colors. (#2771)
|
||||||
|
- Docking: Support for appending into existing tab-bar made to work with Docking + internal helper DockNodeBeginAmendTabBar().
|
||||||
|
- Docking: Added experimental TabItemFlagsOverrideSet to ImGuiWindowClass.
|
||||||
|
- Viewports: Fixed incorrect whitening of popups above a modal if both use their own viewport.
|
||||||
|
- Viewports: Backends: Vulkan: Fixed build, removed extraneous pipeline creation. (#3459, #3579)
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.79 (Released 2020-10-08)
|
VERSION 1.79 (Released 2020-10-08)
|
||||||
@ -2935,6 +3294,21 @@ Other Changes:
|
|||||||
- Examples: DX12: Added '#define ImTextureID ImU64' in project and build files to also allow building
|
- Examples: DX12: Added '#define ImTextureID ImU64' in project and build files to also allow building
|
||||||
on 32-bit systems. Added project to default Visual Studio solution file. (#301)
|
on 32-bit systems. Added project to default Visual Studio solution file. (#301)
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking: DockSpace() emits ItemSize() properly (useful when not filling all space).
|
||||||
|
- Docking: Fixed docking while hovering a child window. (#3420) broken by 85a661d. Improve metrics debugging.
|
||||||
|
- Docking: Fix honoring payload filter with overlapping nodes (we incorrectly over-relied on g.HoveredDockNode
|
||||||
|
when making change for #3398).
|
||||||
|
- Docking: Fix handling of WindowMenuButtonPosition == ImGuiDir_None in Docking Nodes. (#3499)
|
||||||
|
- Viewports: Fixed a rare edge-case if the window targeted by CTRL+Tab stops being rendered.
|
||||||
|
- Viewports, Backends: DX12: Make secondary viewport format match main viewport one (#3462) {@BeastLe9enD]
|
||||||
|
- Viewports: Backends: Vulkan: Removed unused shader code. Fix leaks. Avoid unnecessary pipeline creation for main
|
||||||
|
viewport. (#3459) + Add ImGui_ImplVulkanH_CreateWindowSwapChain in ImGui_ImplVulkanH_CreateOrResizeWindow().
|
||||||
|
- Viewports: Backends: DirectX9: Recover from D3DERR_DEVICELOST on secondary viewports. (#3424)
|
||||||
|
- Viewports, Backends: Win32: Fix toggling of ImGuiViewportFlags_TopMost (#3477) [@Kodokuna]
|
||||||
|
- Viewports: Backends: GLFW: Workaround for cases where glfwGetMonitorWorkarea fails (#3457) [@dougbinks]
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.78 (Released 2020-08-18)
|
VERSION 1.78 (Released 2020-08-18)
|
||||||
@ -3036,6 +3410,23 @@ Other Changes:
|
|||||||
- Examples: Vulkan: Fixed GLFW+Vulkan and SDL+Vulkan clear color not being set. (#3390) [@RoryO]
|
- Examples: Vulkan: Fixed GLFW+Vulkan and SDL+Vulkan clear color not being set. (#3390) [@RoryO]
|
||||||
- CI: Emscripten has stopped their support for their fastcomp backend, switching to latest sdk [@Xipiryon]
|
- CI: Emscripten has stopped their support for their fastcomp backend, switching to latest sdk [@Xipiryon]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking: Made DockBuilderAddNode() automatically call DockBuilderRemoveNode(). (#3399, #2109)
|
||||||
|
- Docking: Storing HoveredDockNode in context which can be useful for easily detecting e.g. hovering an
|
||||||
|
empty node. (#3398)
|
||||||
|
- Docking: Fixed docking overlay bits appearing at (0,0), because of 43bd80a. Most typically noticeable
|
||||||
|
when disabling multi-viewport.
|
||||||
|
- Docking: Workaround recovery for node created without the _DockSpace flags later becoming a DockSpace. (#3340)
|
||||||
|
- Docking: Rework size allocations to recover when there's no enough room for nodes + do not hold on
|
||||||
|
_WantLockSizeOnce forever. (#3328)
|
||||||
|
- Docking: Rework size allocation to allow user code to override node sizes. Not all edge cases will be
|
||||||
|
properly handled but this is a step toward toolbar emitting size constraints.
|
||||||
|
- Docking: Added experimental flags to perform more docking filtering and disable resize per axis.
|
||||||
|
Designed for toolbar patterns.
|
||||||
|
- Viewports, Backends, GLFW: Use GLFW_MOUSE_PASSTHROUGH when available.
|
||||||
|
- Viewports, Backends: DX12: Fixed issue on shutdown when viewports are disabled. (#3347)
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.77 (Released 2020-06-29)
|
VERSION 1.77 (Released 2020-06-29)
|
||||||
@ -3127,6 +3518,17 @@ Other Changes:
|
|||||||
- Examples: Apple: Fixed example_apple_metal and example_apple_opengl2 using imgui_impl_osx.mm
|
- Examples: Apple: Fixed example_apple_metal and example_apple_opengl2 using imgui_impl_osx.mm
|
||||||
not forwarding right and center mouse clicks. (#3260) [@nburrus]
|
not forwarding right and center mouse clicks. (#3260) [@nburrus]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Viewports: Don't set ImGuiViewportFlags_NoRendererClear when ImGuiWindowFlags_NoBackground is set. (#3213)
|
||||||
|
- Viewports: Report minimized viewports as zero DisplaySize to be consistent with main branch. (#1542)
|
||||||
|
- Docking, Settings: Allow reload of settings data at runtime. (#2573)
|
||||||
|
- Backends, GLFW: Fix windows resizing incorrectly on Linux due to GLFW firing window positioning
|
||||||
|
callbacks on next frame after window is resized manually. (#2117)
|
||||||
|
- Backends: DX12: Fix OBJECT_DELETED_WHILE_STILL_IN_USE on viewport resizing. (#3210)
|
||||||
|
- Backends: DX12: Fix for crash caused by early resource release. (#3121)
|
||||||
|
- Backends, Win32: Request monitor update when DPI awareness is enabled to make sure they have the correct DPI settings.
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.76 (Released 2020-04-12)
|
VERSION 1.76 (Released 2020-04-12)
|
||||||
@ -3199,6 +3601,20 @@ Other Changes:
|
|||||||
- Examples: SDL+DX11: Fixed resizing main window. (#3057) [@joeslay]
|
- Examples: SDL+DX11: Fixed resizing main window. (#3057) [@joeslay]
|
||||||
- Examples: Added SDL+Metal example application. (#3017) [@coding-jackalope]
|
- Examples: Added SDL+Metal example application. (#3017) [@coding-jackalope]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking: Fixed assert preventing dockspace from being created instead a hidden tab. (#3101)
|
||||||
|
- Viewports: Fixed secondary viewports accidentally merging into a minimized host viewport. (#3118)
|
||||||
|
- Viewports, Docking: Added per-viewport work area system for e.g. menu-bars. Fixed DockspaceOverViewport()
|
||||||
|
and demo code (overlay etc) accordingly. (#3035, #2889, #2474, #1542, #2109)
|
||||||
|
- Viewports: Improve menu positioning in multi-monitor setups. [@rokups]
|
||||||
|
- Viewports: Software mouse cursor is also scaled by current DpiScale. (amend #939)
|
||||||
|
- Viewports: Avoid manually clipping resize grips and borders, which messes up with automation ability
|
||||||
|
to locate those items. Also simpler and more standard.
|
||||||
|
- Viewports: Fix for UWP in the imgui_impl_win32.cpp IME handler. (#2895, #2892).
|
||||||
|
- Viewports: Bunch of extra of comments to facilitate setting up multi-viewports.
|
||||||
|
- Viewports, GLFW: Avoid using window positioning workaround for GLFW 3.3+ versions that have it fixed.
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.75 (Released 2020-02-10)
|
VERSION 1.75 (Released 2020-02-10)
|
||||||
@ -3297,6 +3713,21 @@ Other Changes:
|
|||||||
- Examples: Metal: Wrapped main loop in @autoreleasepool block to ensure allocations get freed
|
- Examples: Metal: Wrapped main loop in @autoreleasepool block to ensure allocations get freed
|
||||||
even if underlying system event loop gets paused due to app nap. (#2910, #2917) [@bear24rw]
|
even if underlying system event loop gets paused due to app nap. (#2910, #2917) [@bear24rw]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking + Nav: Fixed messed up Ctrl+Tab order with docked windows.
|
||||||
|
- Docking + Nav: Fixed failing to restore NavId when refocusing a child within a docked window.
|
||||||
|
- Docking + Nav: Fixed failing to restore NavId when refocusing due to missing nav window (when
|
||||||
|
it stops being submitted).
|
||||||
|
- Docking: Fixed a bug where the tab bar of a hidden dockspace would keep requesting focus. (#2960)
|
||||||
|
- Docking: Added experimental DockNodeFlagsOverrideSet/DockNodeFlagsOverrideClear flags in ImGuiWindowClass
|
||||||
|
(currently experimenting with toolbar idioms).
|
||||||
|
- Viewports: Fix resizing viewport-owning windows when mouse pos is outside the InnerClipRect
|
||||||
|
(can happen with OS decoration enabled).
|
||||||
|
- Viewports: Preserve last known size for minimized main viewport to be consistent with secondary viewports.
|
||||||
|
- Backends: SDL: Honor NoTaskBarIcon flag under non Win32 OS. (#2117)
|
||||||
|
- Backends: GLFW, SDL: Platform monitors declared properly even if multi-viewport is not enabled.
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.74 (Released 2019-11-25)
|
VERSION 1.74 (Released 2019-11-25)
|
||||||
@ -3376,6 +3807,14 @@ Other Changes:
|
|||||||
- CI: Set up a bunch of continuous-integration tests using GitHub Actions. We now compile many of the example
|
- CI: Set up a bunch of continuous-integration tests using GitHub Actions. We now compile many of the example
|
||||||
applications on Windows, Linux, MacOS, iOS, Emscripten. Removed Travis integration. (#2865) [@rokups]
|
applications on Windows, Linux, MacOS, iOS, Emscripten. Removed Travis integration. (#2865) [@rokups]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking: Can undock from the small triangle button. (#2109,. #2645)
|
||||||
|
- Docking: Fixed node->HasCloseButton not honoring ImGuiDockNodeFlags_NoCloseButton in a floating node,
|
||||||
|
leading to empty space at the right of tab-bars with those flags. (#2109)
|
||||||
|
- Docking: Made docked windows not use style.ChildRounding.
|
||||||
|
- Multi-viewports: Added multi-viewport support in the DX12 back-end. (#2851) [@obfuscate]
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.73 (Released 2019-09-24)
|
VERSION 1.73 (Released 2019-09-24)
|
||||||
@ -3438,6 +3877,28 @@ Other Changes:
|
|||||||
- Misc: Updated stb_rect_pack.h from 0.99 to 1.00 (fixes by @rygorous: off-by-1 bug in best-fit heuristic,
|
- Misc: Updated stb_rect_pack.h from 0.99 to 1.00 (fixes by @rygorous: off-by-1 bug in best-fit heuristic,
|
||||||
fix handling of rectangles too large to fit inside texture). (#2762) [@tido64]
|
fix handling of rectangles too large to fit inside texture). (#2762) [@tido64]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking: Fix BeginDocked() path that creates node so that SetNextWindowDockID() doesn't immediately discard the node. (#2109)
|
||||||
|
- Docking: Fix for node created at the same time as windows that are still resizing (typically with
|
||||||
|
io.ConfigDockingAlwaysTabBar) to not be zero/min sized. (#2109). The fix delays their visibility by one frame,
|
||||||
|
which is not ideal but not very problematic as the .ini data gets populated after that.
|
||||||
|
- Docking: Fix a crash that could occur with a malformed ini file (DockNode Parent value pointing to a missing node).
|
||||||
|
- Viewport: Fix modal/popup window being stuck in unowned hidden viewport associated to fallback window without stealing
|
||||||
|
it back. Fix modal reference viewport when opened outside of another window. (#1542)
|
||||||
|
- Viewport: Modals don't need to set ImGuiViewportFlags_NoFocusOnClick, this also mitigate the issue described by #2445,
|
||||||
|
which becomes particularly bad with unfocused modal. (#1542)
|
||||||
|
- Viewport: better case case where host window gets moved and resized simultaneous (toggling maximized state).
|
||||||
|
There's no perfect solution there, than using io.ConfigViewportsNoAutoMerge = false. (#1542)
|
||||||
|
- Viewport, Docking: Fixed incorrect assignment of IsFallbackWindow which would tag dock node host windows created
|
||||||
|
in NewFrame() as such, messing with popup viewport inheritance.
|
||||||
|
- Viewport: Fixed issue where resize grip would display as hovered while mouse is still off the OS bounds so a click
|
||||||
|
would miss it and focus the OS window behind expected one. (#1542)
|
||||||
|
- Viewport: Fix to allow multiple shutdown / calls to DestroyPlatformWindows(). (#2769)
|
||||||
|
- Viewport: Backends: GLFW: Fix setting window size on macOS (#2767, #2117) [@rokups]
|
||||||
|
- Viewport: Backends: GLFW+Linux: Fix window having incorrect size after uncollapse. (#2756, #2117) [@rokups]
|
||||||
|
- Viewport: Backends: DirectX9: Workaround for windows not refreshing when main viewport has no draw call. (#2560)
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.72b (Released 2019-07-31)
|
VERSION 1.72b (Released 2019-07-31)
|
||||||
@ -3540,6 +4001,25 @@ Other Changes:
|
|||||||
(#2482, #2632) [@josiahmanson]
|
(#2482, #2632) [@josiahmanson]
|
||||||
- Examples: Added SDL2+DirectX11 example application. (#2632, #2612, #2482) [@vincenthamm]
|
- Examples: Added SDL2+DirectX11 example application. (#2632, #2612, #2482) [@vincenthamm]
|
||||||
|
|
||||||
|
Docking+Viewports Branch:
|
||||||
|
|
||||||
|
- Docking: Making it possible to undock a node by clicking on the tab bar / title bar for the node. (#2645).
|
||||||
|
- Docking: Explicitly inhibit constraint when docked for now. Fix clipping issue related to constraints. (#2690).
|
||||||
|
- Docking: Fixed dragging/resizing from OS decoration not marking settings as dirty.
|
||||||
|
- Docking: Renamed io.ConfigDockingTabBarOnSingleWindows to io.ConfigDockingAlwaysTabBar.
|
||||||
|
Added ImGuiWindowClass::DockingAlwaysTabBar to set on individual windows.
|
||||||
|
- Docking: Perform simple check: assert if Docking or Viewport are enabled exactly on frame 1 (instead of frame 0
|
||||||
|
or later), which is a common user error leading to loss of .ini data on load.
|
||||||
|
- Docking: Fix so that an appearing window making a dock node reappear won't have a zero-size on its first frame.
|
||||||
|
- Docking: Fixed using ImGuiDockNodeFlags_AutoHideTabBar with io.ConfigDockingTabBarOnSingleWindows.
|
||||||
|
- Docking: Added ImGuiDockNode to .natvis file.
|
||||||
|
- Docking: Fixed support for large meshes in GetBackgroundDrawList(), GetForegroundDrawList(). (#2638)
|
||||||
|
- Viewport: Fix monitor dpi info not being copied to main viewport when multi-viewports are not enabled. (#2621, #1676)
|
||||||
|
- Viewport: Refactored ImGuiWindowClass's ViewportFlagsOverrideMask + ViewportFlagsOverrideValue into
|
||||||
|
ViewportFlagsOverrideSet + ViewportFlagsOverrideClear which appears easier to grasp. (#1542)
|
||||||
|
- Viewport: Added ImGuiViewportFlags_NoAutoMerge to prevent merging into host viewport in a per-window basis
|
||||||
|
via the ImGuiWindowClass override mechanism. (#1542)
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.71 (Released 2019-06-12)
|
VERSION 1.71 (Released 2019-06-12)
|
||||||
@ -3879,6 +4359,7 @@ Breaking Changes:
|
|||||||
- Renamed ImFontAtlas::GlyphRangesBuilder to ImFontGlyphRangesBuilder. Kept redirection typedef (will obsolete).
|
- Renamed ImFontAtlas::GlyphRangesBuilder to ImFontGlyphRangesBuilder. Kept redirection typedef (will obsolete).
|
||||||
|
|
||||||
Other Changes:
|
Other Changes:
|
||||||
|
|
||||||
- Added BETA api for Tab Bar/Tabs widgets: (#261, #351)
|
- Added BETA api for Tab Bar/Tabs widgets: (#261, #351)
|
||||||
- Added BeginTabBar(), EndTabBar(), BeginTabItem(), EndTabItem(), SetTabItemClosed() API.
|
- Added BeginTabBar(), EndTabBar(), BeginTabItem(), EndTabItem(), SetTabItemClosed() API.
|
||||||
- Added ImGuiTabBarFlags flags for BeginTabBar().
|
- Added ImGuiTabBarFlags flags for BeginTabBar().
|
||||||
|
@ -129,7 +129,35 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- separator: width, thickness, centering (#1643, #2657)
|
- separator: width, thickness, centering (#1643, #2657)
|
||||||
- splitter: formalize the splitter idiom into an official api (we want to handle n-way split) (#319)
|
- splitter: formalize the splitter idiom into an official api (we want to handle n-way split) (#319)
|
||||||
|
|
||||||
- docking: merge docking branch (#2109)
|
- docking: B: ordering currently held in tab bar should be implicitly held by windows themselves (also see #2304)
|
||||||
|
- docking: B- tab bar: the order/focus restoring code could be part of TabBar and not DockNode? (#8)
|
||||||
|
- docking: B~ rework code to be able to lazily create tab bar instance in a single place. The _Unsorted tab flag could be replacing a trailing-counter in DockNode?
|
||||||
|
- docking: B~ fully track windows/settings reference in dock nodes. perhaps find a representation that allows facilitate use of dock builder functions.
|
||||||
|
- docking: B~ Unreal style document system (requires low-level controls of dockspace serialization fork/copy/delete). this is mostly working but the DockBuilderXXX api are not exposed/finished.
|
||||||
|
- docking: B: when docking outer, perform size locking on neighbors nodes the same way we do it with splitters, so other nodes are not resized.
|
||||||
|
- docking: B~ central node resizing behavior incorrect.
|
||||||
|
- docking: B: changing title font/style per-window is not supported as dock nodes are created in NewFrame.
|
||||||
|
- docking: B- dock node inside its own viewports creates 1 temporary viewport per window on startup before ditching them (doesn't affect the user nor request platform windows to be created, but unnecessary)
|
||||||
|
- docking: B- resize sibling locking behavior may be less desirable if we merged same-axis sibling in a same node level?
|
||||||
|
- docking: B- single visible node part of a hidden split hierarchy (OnlyNodeWithWindows != NULL) should show a normal title bar (not a tab bar)
|
||||||
|
- docking: B~ SetNextWindowDock() calls (with conditional) -> defer everything to DockContextUpdate (repro: Documents->[X]Windows->Dock 1 elsewhere->Click Redock All
|
||||||
|
- docking: B~ tidy up tab list popup buttons features (available with manual tab-bar, see ImGuiTabBarFlags_NoTabListPopupButton code, not used by docking nodes)
|
||||||
|
- docking: B- SetNextWindowDockId(0) with a second Begin() in the frame will asserts
|
||||||
|
- docking: B: resize grip drawn in host window typically appears under scrollbar.
|
||||||
|
- docking: B: resize grip auto-resize on multiple node hierarchy doesn't make much sense or should be improved?
|
||||||
|
- docking: B- SetNextWindowFocus() doesn't seem to apply if the window is hidden this frame, need repro (#4)
|
||||||
|
- docking: B- resizing a dock tree small currently has glitches (overlapping collapse and close button, etc.)
|
||||||
|
- docking: B- dpi: look at interaction with the hi-dpi and multi-dpi stuff.
|
||||||
|
- docking: B- tab bar: appearing on first frame with a dumb layout would do less harm that not appearing? (when behind dynamic branch) or store titles + render in EndTabBar()
|
||||||
|
- docking: B- tab bar: make selected tab always shows its full title?
|
||||||
|
- docking: B- hide close button on single tab bar?
|
||||||
|
- docking: B- nav: design interactions so nav controls can dock/undock
|
||||||
|
- docking: B- dockspace: flag to lock the dock tree and/or sizes (ImGuiDockNodeFlags_Locked?)
|
||||||
|
- docking: B- reintroduce collapsing a floating dock node. also collapsing a docked dock node!
|
||||||
|
- docking: B- allow dragging a non-floating dock node by clicking on the title-bar-looking section (not just the collapse/menu button)
|
||||||
|
- docking: B- option to remember undocked window size? (instead of keeping their docked size) (relate to #2104)
|
||||||
|
- docking: C- nav: CTRL+TAB highlighting tabs shows the mismatch between focus-stack and tab-order (not visible in VS because it doesn't highlight the tabs)
|
||||||
|
- docking: C- after a dock/undock, the Scrollbar Status update in Begin() should use an updated e.g. size_y_for_scrollbars to avoid a 1 frame scrollbar flicker.
|
||||||
|
|
||||||
- tabs: "there is currently a problem because TabItem() will try to submit their own tooltip after 0.50 second, and this will have the effect of making your tooltip flicker once." -> tooltip priority work (WIP branch)
|
- tabs: "there is currently a problem because TabItem() will try to submit their own tooltip after 0.50 second, and this will have the effect of making your tooltip flicker once." -> tooltip priority work (WIP branch)
|
||||||
- tabs: make EndTabBar fail if users doesn't respect BeginTabBar return value, for consistency/future-proofing.
|
- tabs: make EndTabBar fail if users doesn't respect BeginTabBar return value, for consistency/future-proofing.
|
||||||
@ -302,6 +330,20 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- nav/windowing: Resizing window will currently fail with certain types of resizing constraints/callback applied
|
- nav/windowing: Resizing window will currently fail with certain types of resizing constraints/callback applied
|
||||||
- focus: preserve ActiveId/focus stack state, e.g. when opening a menu and close it, previously selected InputText() focus gets restored (#622)
|
- focus: preserve ActiveId/focus stack state, e.g. when opening a menu and close it, previously selected InputText() focus gets restored (#622)
|
||||||
|
|
||||||
|
- viewport: make it possible to have no main/hosting viewport
|
||||||
|
- viewport: We set ImGuiViewportFlags_NoFocusOnAppearing in a way that is required for GLFW/SDL binding, but could be handled better without
|
||||||
|
on a custom e.g. Win32 bindings. It prevents newly dragged-out viewports from taking the focus, which makes ALT+F4 more ambiguous.
|
||||||
|
- viewport: not focusing newly undocked viewport means clicking back on previous one doesn't bring OS window to front.
|
||||||
|
- viewport: with platform decoration enabled, platform may force constraint (e.g. minimum size)
|
||||||
|
- viewport: use getfocus/setfocus api to synchronize imgui<>platform focus better (e.g imgui-side ctrl-tab can focus os window, OS initial setup and alt-tab can focus imgui window etc.)
|
||||||
|
- viewport: store per-viewport/monitor DPI in .ini file so an application reload or main window changing DPI on reload can be properly patched for.
|
||||||
|
- viewport: implicit/fallback Debug window can hog a zombie viewport (harmless, noisy?) > could at least clear out the reference on a per session basis?
|
||||||
|
- viewport: need to clarify how to use GetMousePos() from a user point of view.
|
||||||
|
- platform: glfw: no support for ImGuiBackendFlags_HasMouseHoveredViewport.
|
||||||
|
- platform: sdl: no support for ImGuiBackendFlags_HasMouseHoveredViewport. maybe we could use SDL_GetMouseFocus() / SDL_WINDOW_MOUSE_FOCUS if imgui could fallback on its heuristic when NoInputs is set
|
||||||
|
- platform: sdl: no refresh of monitor/display (SDL doesn't seem to have an event for it).
|
||||||
|
- platform: sdl: multi-viewport + minimized window seems to break mouse wheel events (at least under Win32).
|
||||||
|
|
||||||
- inputs: support track pad style scrolling & slider edit.
|
- inputs: support track pad style scrolling & slider edit.
|
||||||
- inputs/io: backspace and arrows in the context of a text input could use system repeat rate.
|
- inputs/io: backspace and arrows in the context of a text input could use system repeat rate.
|
||||||
- inputs/io: clarify/standardize/expose repeat rate and repeat delays (#1808)
|
- inputs/io: clarify/standardize/expose repeat rate and repeat delays (#1808)
|
||||||
|
@ -40,6 +40,7 @@ int main(int, char**)
|
|||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
|
@ -7,7 +7,10 @@
|
|||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
|
050450AB2768052600AB6805 /* imgui_tables.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5079822D257677DB0038A28D /* imgui_tables.cpp */; };
|
||||||
|
050450AD276863B000AB6805 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 050450AC276863B000AB6805 /* QuartzCore.framework */; };
|
||||||
05318E0F274C397200A8DE2E /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 05318E0E274C397200A8DE2E /* GameController.framework */; };
|
05318E0F274C397200A8DE2E /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 05318E0E274C397200A8DE2E /* GameController.framework */; };
|
||||||
|
05A275442773BEA20084EF39 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 05A275432773BEA20084EF39 /* QuartzCore.framework */; };
|
||||||
07A82ED82139413D0078D120 /* imgui_widgets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07A82ED72139413C0078D120 /* imgui_widgets.cpp */; };
|
07A82ED82139413D0078D120 /* imgui_widgets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07A82ED72139413C0078D120 /* imgui_widgets.cpp */; };
|
||||||
07A82ED92139418F0078D120 /* imgui_widgets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07A82ED72139413C0078D120 /* imgui_widgets.cpp */; };
|
07A82ED92139418F0078D120 /* imgui_widgets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07A82ED72139413C0078D120 /* imgui_widgets.cpp */; };
|
||||||
5079822E257677DB0038A28D /* imgui_tables.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5079822D257677DB0038A28D /* imgui_tables.cpp */; };
|
5079822E257677DB0038A28D /* imgui_tables.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5079822D257677DB0038A28D /* imgui_tables.cpp */; };
|
||||||
@ -33,7 +36,11 @@
|
|||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
|
050450AC276863B000AB6805 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
|
||||||
05318E0E274C397200A8DE2E /* GameController.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameController.framework; path = System/Library/Frameworks/GameController.framework; sourceTree = SDKROOT; };
|
05318E0E274C397200A8DE2E /* GameController.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameController.framework; path = System/Library/Frameworks/GameController.framework; sourceTree = SDKROOT; };
|
||||||
|
05A2754027728F5B0084EF39 /* imgui_impl_metal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_impl_metal.h; path = ../../backends/imgui_impl_metal.h; sourceTree = "<group>"; };
|
||||||
|
05A2754127728F5B0084EF39 /* imgui_impl_osx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_impl_osx.h; path = ../../backends/imgui_impl_osx.h; sourceTree = "<group>"; };
|
||||||
|
05A275432773BEA20084EF39 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.2.sdk/System/Library/Frameworks/QuartzCore.framework; sourceTree = DEVELOPER_DIR; };
|
||||||
07A82ED62139413C0078D120 /* imgui_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_internal.h; path = ../../imgui_internal.h; sourceTree = "<group>"; };
|
07A82ED62139413C0078D120 /* imgui_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_internal.h; path = ../../imgui_internal.h; sourceTree = "<group>"; };
|
||||||
07A82ED72139413C0078D120 /* imgui_widgets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_widgets.cpp; path = ../../imgui_widgets.cpp; sourceTree = "<group>"; };
|
07A82ED72139413C0078D120 /* imgui_widgets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_widgets.cpp; path = ../../imgui_widgets.cpp; sourceTree = "<group>"; };
|
||||||
5079822D257677DB0038A28D /* imgui_tables.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_tables.cpp; path = ../../imgui_tables.cpp; sourceTree = "<group>"; };
|
5079822D257677DB0038A28D /* imgui_tables.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_tables.cpp; path = ../../imgui_tables.cpp; sourceTree = "<group>"; };
|
||||||
@ -66,6 +73,7 @@
|
|||||||
isa = PBXFrameworksBuildPhase;
|
isa = PBXFrameworksBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
05A275442773BEA20084EF39 /* QuartzCore.framework in Frameworks */,
|
||||||
8309BD8F253CCAAA0045E2A1 /* UIKit.framework in Frameworks */,
|
8309BD8F253CCAAA0045E2A1 /* UIKit.framework in Frameworks */,
|
||||||
83BBE9E720EB46BD00295997 /* MetalKit.framework in Frameworks */,
|
83BBE9E720EB46BD00295997 /* MetalKit.framework in Frameworks */,
|
||||||
83BBE9E520EB46B900295997 /* Metal.framework in Frameworks */,
|
83BBE9E520EB46B900295997 /* Metal.framework in Frameworks */,
|
||||||
@ -76,6 +84,7 @@
|
|||||||
isa = PBXFrameworksBuildPhase;
|
isa = PBXFrameworksBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
050450AD276863B000AB6805 /* QuartzCore.framework in Frameworks */,
|
||||||
8309BDC6253CCCFE0045E2A1 /* AppKit.framework in Frameworks */,
|
8309BDC6253CCCFE0045E2A1 /* AppKit.framework in Frameworks */,
|
||||||
83BBE9EC20EB471700295997 /* MetalKit.framework in Frameworks */,
|
83BBE9EC20EB471700295997 /* MetalKit.framework in Frameworks */,
|
||||||
05318E0F274C397200A8DE2E /* GameController.framework in Frameworks */,
|
05318E0F274C397200A8DE2E /* GameController.framework in Frameworks */,
|
||||||
@ -136,6 +145,8 @@
|
|||||||
83BBE9E320EB46B800295997 /* Frameworks */ = {
|
83BBE9E320EB46B800295997 /* Frameworks */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
050450AC276863B000AB6805 /* QuartzCore.framework */,
|
||||||
|
05A275432773BEA20084EF39 /* QuartzCore.framework */,
|
||||||
05318E0E274C397200A8DE2E /* GameController.framework */,
|
05318E0E274C397200A8DE2E /* GameController.framework */,
|
||||||
8309BDC5253CCCFE0045E2A1 /* AppKit.framework */,
|
8309BDC5253CCCFE0045E2A1 /* AppKit.framework */,
|
||||||
8309BD8E253CCAAA0045E2A1 /* UIKit.framework */,
|
8309BD8E253CCAAA0045E2A1 /* UIKit.framework */,
|
||||||
@ -153,7 +164,9 @@
|
|||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
5079822D257677DB0038A28D /* imgui_tables.cpp */,
|
5079822D257677DB0038A28D /* imgui_tables.cpp */,
|
||||||
|
05A2754027728F5B0084EF39 /* imgui_impl_metal.h */,
|
||||||
8309BDB5253CCC9D0045E2A1 /* imgui_impl_metal.mm */,
|
8309BDB5253CCC9D0045E2A1 /* imgui_impl_metal.mm */,
|
||||||
|
05A2754127728F5B0084EF39 /* imgui_impl_osx.h */,
|
||||||
8309BDB6253CCC9D0045E2A1 /* imgui_impl_osx.mm */,
|
8309BDB6253CCC9D0045E2A1 /* imgui_impl_osx.mm */,
|
||||||
83BBEA0420EB54E700295997 /* imconfig.h */,
|
83BBEA0420EB54E700295997 /* imconfig.h */,
|
||||||
83BBEA0320EB54E700295997 /* imgui.cpp */,
|
83BBEA0320EB54E700295997 /* imgui.cpp */,
|
||||||
@ -268,9 +281,9 @@
|
|||||||
8309BDBB253CCCAD0045E2A1 /* imgui_impl_metal.mm in Sources */,
|
8309BDBB253CCCAD0045E2A1 /* imgui_impl_metal.mm in Sources */,
|
||||||
83BBEA0920EB54E700295997 /* imgui.cpp in Sources */,
|
83BBEA0920EB54E700295997 /* imgui.cpp in Sources */,
|
||||||
83BBEA0720EB54E700295997 /* imgui_demo.cpp in Sources */,
|
83BBEA0720EB54E700295997 /* imgui_demo.cpp in Sources */,
|
||||||
83BBEA0520EB54E700295997 /* imgui_draw.cpp in Sources */,
|
83BBEA0520EB54E700295997 /* imgui_draw.cpp in Sources */,
|
||||||
5079822E257677DB0038A28D /* imgui_tables.cpp in Sources */,
|
5079822E257677DB0038A28D /* imgui_tables.cpp in Sources */,
|
||||||
07A82ED82139413D0078D120 /* imgui_widgets.cpp in Sources */,
|
07A82ED82139413D0078D120 /* imgui_widgets.cpp in Sources */,
|
||||||
8309BDA5253CCC070045E2A1 /* main.mm in Sources */,
|
8309BDA5253CCC070045E2A1 /* main.mm in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
@ -281,10 +294,10 @@
|
|||||||
files = (
|
files = (
|
||||||
8309BDBE253CCCB60045E2A1 /* imgui_impl_metal.mm in Sources */,
|
8309BDBE253CCCB60045E2A1 /* imgui_impl_metal.mm in Sources */,
|
||||||
8309BDBF253CCCB60045E2A1 /* imgui_impl_osx.mm in Sources */,
|
8309BDBF253CCCB60045E2A1 /* imgui_impl_osx.mm in Sources */,
|
||||||
83BBEA0A20EB54E700295997 /* imgui.cpp in Sources */,
|
83BBEA0A20EB54E700295997 /* imgui.cpp in Sources */,
|
||||||
83BBEA0820EB54E700295997 /* imgui_demo.cpp in Sources */,
|
83BBEA0820EB54E700295997 /* imgui_demo.cpp in Sources */,
|
||||||
83BBEA0620EB54E700295997 /* imgui_draw.cpp in Sources */,
|
83BBEA0620EB54E700295997 /* imgui_draw.cpp in Sources */,
|
||||||
5079822E257677DB0038A28D /* imgui_tables.cpp in Sources */,
|
050450AB2768052600AB6805 /* imgui_tables.cpp in Sources */,
|
||||||
07A82ED92139418F0078D120 /* imgui_widgets.cpp in Sources */,
|
07A82ED92139418F0078D120 /* imgui_widgets.cpp in Sources */,
|
||||||
8309BDA8253CCC080045E2A1 /* main.mm in Sources */,
|
8309BDA8253CCC080045E2A1 /* main.mm in Sources */,
|
||||||
);
|
);
|
||||||
|
@ -60,11 +60,21 @@
|
|||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
|
|
||||||
|
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
style.WindowRounding = 0.0f;
|
||||||
|
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup Renderer backend
|
// Setup Renderer backend
|
||||||
ImGui_ImplMetal_Init(_device);
|
ImGui_ImplMetal_Init(_device);
|
||||||
|
|
||||||
@ -195,6 +205,13 @@
|
|||||||
// Present
|
// Present
|
||||||
[commandBuffer presentDrawable:view.currentDrawable];
|
[commandBuffer presentDrawable:view.currentDrawable];
|
||||||
[commandBuffer commit];
|
[commandBuffer commit];
|
||||||
|
|
||||||
|
// Update and Render additional Platform Windows
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
ImGui::UpdatePlatformWindows();
|
||||||
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)mtkView:(MTKView*)view drawableSizeWillChange:(CGSize)size
|
-(void)mtkView:(MTKView*)view drawableSizeWillChange:(CGSize)size
|
||||||
|
@ -47,11 +47,21 @@
|
|||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
|
|
||||||
|
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
style.WindowRounding = 0.0f;
|
||||||
|
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
// Setup Platform/Renderer backends
|
||||||
ImGui_ImplOSX_Init(self);
|
ImGui_ImplOSX_Init(self);
|
||||||
ImGui_ImplOpenGL2_Init();
|
ImGui_ImplOpenGL2_Init();
|
||||||
@ -136,6 +146,13 @@
|
|||||||
|
|
||||||
ImGui_ImplOpenGL2_RenderDrawData(draw_data);
|
ImGui_ImplOpenGL2_RenderDrawData(draw_data);
|
||||||
|
|
||||||
|
// Update and Render additional Platform Windows
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
ImGui::UpdatePlatformWindows();
|
||||||
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
}
|
||||||
|
|
||||||
// Present
|
// Present
|
||||||
[[self openGLContext] flushBuffer];
|
[[self openGLContext] flushBuffer];
|
||||||
|
|
||||||
|
@ -33,11 +33,21 @@ int main(int, char**)
|
|||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||||
|
|
||||||
// Setup style
|
// Setup style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
|
|
||||||
|
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
style.WindowRounding = 0.0f;
|
||||||
|
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
||||||
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
||||||
@ -69,7 +79,7 @@ int main(int, char**)
|
|||||||
id <MTLCommandQueue> commandQueue = [device newCommandQueue];
|
id <MTLCommandQueue> commandQueue = [device newCommandQueue];
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
// Setup Platform/Renderer backends
|
||||||
ImGui_ImplGlfw_InitForOpenGL(window, true);
|
ImGui_ImplGlfw_InitForOther(window, true);
|
||||||
ImGui_ImplMetal_Init(device);
|
ImGui_ImplMetal_Init(device);
|
||||||
|
|
||||||
NSWindow *nswin = glfwGetCocoaWindow(window);
|
NSWindow *nswin = glfwGetCocoaWindow(window);
|
||||||
@ -157,6 +167,13 @@ int main(int, char**)
|
|||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
ImGui_ImplMetal_RenderDrawData(ImGui::GetDrawData(), commandBuffer, renderEncoder);
|
ImGui_ImplMetal_RenderDrawData(ImGui::GetDrawData(), commandBuffer, renderEncoder);
|
||||||
|
|
||||||
|
// Update and Render additional Platform Windows
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
ImGui::UpdatePlatformWindows();
|
||||||
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
}
|
||||||
|
|
||||||
[renderEncoder popDebugGroup];
|
[renderEncoder popDebugGroup];
|
||||||
[renderEncoder endEncoding];
|
[renderEncoder endEncoding];
|
||||||
|
|
||||||
|
@ -52,11 +52,23 @@ int main(int, char**)
|
|||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||||
|
//io.ConfigViewportsNoAutoMerge = true;
|
||||||
|
//io.ConfigViewportsNoTaskBarIcon = true;
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
|
|
||||||
|
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
style.WindowRounding = 0.0f;
|
||||||
|
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
// Setup Platform/Renderer backends
|
||||||
ImGui_ImplGlfw_InitForOpenGL(window, true);
|
ImGui_ImplGlfw_InitForOpenGL(window, true);
|
||||||
ImGui_ImplOpenGL2_Init();
|
ImGui_ImplOpenGL2_Init();
|
||||||
@ -155,6 +167,17 @@ int main(int, char**)
|
|||||||
ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
|
||||||
//glUseProgram(last_program);
|
//glUseProgram(last_program);
|
||||||
|
|
||||||
|
// Update and Render additional Platform Windows
|
||||||
|
// (Platform functions may change the current OpenGL context, so we save/restore it to make it easier to paste this code elsewhere.
|
||||||
|
// For this specific demo app we could also call glfwMakeContextCurrent(window) directly)
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
GLFWwindow* backup_current_context = glfwGetCurrentContext();
|
||||||
|
ImGui::UpdatePlatformWindows();
|
||||||
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
glfwMakeContextCurrent(backup_current_context);
|
||||||
|
}
|
||||||
|
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
glfwSwapBuffers(window);
|
glfwSwapBuffers(window);
|
||||||
}
|
}
|
||||||
|
@ -77,11 +77,23 @@ int main(int, char**)
|
|||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||||
|
//io.ConfigViewportsNoAutoMerge = true;
|
||||||
|
//io.ConfigViewportsNoTaskBarIcon = true;
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
|
|
||||||
|
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
style.WindowRounding = 0.0f;
|
||||||
|
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
// Setup Platform/Renderer backends
|
||||||
ImGui_ImplGlfw_InitForOpenGL(window, true);
|
ImGui_ImplGlfw_InitForOpenGL(window, true);
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
@ -184,6 +196,17 @@ int main(int, char**)
|
|||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
|
||||||
|
// Update and Render additional Platform Windows
|
||||||
|
// (Platform functions may change the current OpenGL context, so we save/restore it to make it easier to paste this code elsewhere.
|
||||||
|
// For this specific demo app we could also call glfwMakeContextCurrent(window) directly)
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
GLFWwindow* backup_current_context = glfwGetCurrentContext();
|
||||||
|
ImGui::UpdatePlatformWindows();
|
||||||
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
glfwMakeContextCurrent(backup_current_context);
|
||||||
|
}
|
||||||
|
|
||||||
glfwSwapBuffers(window);
|
glfwSwapBuffers(window);
|
||||||
}
|
}
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
|
@ -429,11 +429,23 @@ int main(int, char**)
|
|||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||||
|
//io.ConfigViewportsNoAutoMerge = true;
|
||||||
|
//io.ConfigViewportsNoTaskBarIcon = true;
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
|
|
||||||
|
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
style.WindowRounding = 0.0f;
|
||||||
|
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
// Setup Platform/Renderer backends
|
||||||
ImGui_ImplGlfw_InitForVulkan(window, true);
|
ImGui_ImplGlfw_InitForVulkan(window, true);
|
||||||
ImGui_ImplVulkan_InitInfo init_info = {};
|
ImGui_ImplVulkan_InitInfo init_info = {};
|
||||||
@ -544,17 +556,25 @@ int main(int, char**)
|
|||||||
|
|
||||||
// Rendering
|
// Rendering
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
ImDrawData* draw_data = ImGui::GetDrawData();
|
ImDrawData* main_draw_data = ImGui::GetDrawData();
|
||||||
const bool is_minimized = (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f);
|
const bool main_is_minimized = (main_draw_data->DisplaySize.x <= 0.0f || main_draw_data->DisplaySize.y <= 0.0f);
|
||||||
if (!is_minimized)
|
wd->ClearValue.color.float32[0] = clear_color.x * clear_color.w;
|
||||||
|
wd->ClearValue.color.float32[1] = clear_color.y * clear_color.w;
|
||||||
|
wd->ClearValue.color.float32[2] = clear_color.z * clear_color.w;
|
||||||
|
wd->ClearValue.color.float32[3] = clear_color.w;
|
||||||
|
if (!main_is_minimized)
|
||||||
|
FrameRender(wd, main_draw_data);
|
||||||
|
|
||||||
|
// Update and Render additional Platform Windows
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
{
|
{
|
||||||
wd->ClearValue.color.float32[0] = clear_color.x * clear_color.w;
|
ImGui::UpdatePlatformWindows();
|
||||||
wd->ClearValue.color.float32[1] = clear_color.y * clear_color.w;
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
wd->ClearValue.color.float32[2] = clear_color.z * clear_color.w;
|
|
||||||
wd->ClearValue.color.float32[3] = clear_color.w;
|
|
||||||
FrameRender(wd, draw_data);
|
|
||||||
FramePresent(wd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Present Main Platform Window
|
||||||
|
if (!main_is_minimized)
|
||||||
|
FramePresent(wd);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
|
@ -93,6 +93,7 @@ int main(int, char**)
|
|||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
|
@ -61,6 +61,7 @@ int main(int argc, char** argv)
|
|||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
@ -78,7 +79,6 @@ int main(int argc, char** argv)
|
|||||||
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
|
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
|
||||||
ImGui_ImplGLUT_InstallFuncs();
|
ImGui_ImplGLUT_InstallFuncs();
|
||||||
|
|
||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
||||||
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
||||||
|
@ -71,11 +71,23 @@ int main(int, char**)
|
|||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||||
|
//io.ConfigViewportsNoAutoMerge = true;
|
||||||
|
//io.ConfigViewportsNoTaskBarIcon = true;
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
|
|
||||||
|
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
style.WindowRounding = 0.0f;
|
||||||
|
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
// Setup Platform/Renderer backends
|
||||||
ImGui_ImplSDL2_InitForD3D(window);
|
ImGui_ImplSDL2_InitForD3D(window);
|
||||||
ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext);
|
ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext);
|
||||||
@ -181,6 +193,13 @@ int main(int, char**)
|
|||||||
g_pd3dDeviceContext->ClearRenderTargetView(g_mainRenderTargetView, clear_color_with_alpha);
|
g_pd3dDeviceContext->ClearRenderTargetView(g_mainRenderTargetView, clear_color_with_alpha);
|
||||||
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
|
||||||
|
// Update and Render additional Platform Windows
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
ImGui::UpdatePlatformWindows();
|
||||||
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
}
|
||||||
|
|
||||||
g_pSwapChain->Present(1, 0); // Present with vsync
|
g_pSwapChain->Present(1, 0); // Present with vsync
|
||||||
//g_pSwapChain->Present(0, 0); // Present without vsync
|
//g_pSwapChain->Present(0, 0); // Present without vsync
|
||||||
}
|
}
|
||||||
|
@ -24,11 +24,21 @@ int main(int, char**)
|
|||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||||
|
|
||||||
// Setup style
|
// Setup style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
|
|
||||||
|
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
style.WindowRounding = 0.0f;
|
||||||
|
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
||||||
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
||||||
@ -168,6 +178,13 @@ int main(int, char**)
|
|||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
ImGui_ImplMetal_RenderDrawData(ImGui::GetDrawData(), commandBuffer, renderEncoder);
|
ImGui_ImplMetal_RenderDrawData(ImGui::GetDrawData(), commandBuffer, renderEncoder);
|
||||||
|
|
||||||
|
// Update and Render additional Platform Windows
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
ImGui::UpdatePlatformWindows();
|
||||||
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
}
|
||||||
|
|
||||||
[renderEncoder popDebugGroup];
|
[renderEncoder popDebugGroup];
|
||||||
[renderEncoder endEncoding];
|
[renderEncoder endEncoding];
|
||||||
|
|
||||||
|
@ -57,11 +57,23 @@ int main(int, char**)
|
|||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||||
|
//io.ConfigViewportsNoAutoMerge = true;
|
||||||
|
//io.ConfigViewportsNoTaskBarIcon = true;
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
|
|
||||||
|
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
style.WindowRounding = 0.0f;
|
||||||
|
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
// Setup Platform/Renderer backends
|
||||||
ImGui_ImplSDL2_InitForOpenGL(window, gl_context);
|
ImGui_ImplSDL2_InitForOpenGL(window, gl_context);
|
||||||
ImGui_ImplOpenGL2_Init();
|
ImGui_ImplOpenGL2_Init();
|
||||||
@ -160,6 +172,19 @@ int main(int, char**)
|
|||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
//glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound
|
//glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound
|
||||||
ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
|
||||||
|
// Update and Render additional Platform Windows
|
||||||
|
// (Platform functions may change the current OpenGL context, so we save/restore it to make it easier to paste this code elsewhere.
|
||||||
|
// For this specific demo app we could also call SDL_GL_MakeCurrent(window, gl_context) directly)
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
SDL_Window* backup_current_window = SDL_GL_GetCurrentWindow();
|
||||||
|
SDL_GLContext backup_current_context = SDL_GL_GetCurrentContext();
|
||||||
|
ImGui::UpdatePlatformWindows();
|
||||||
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
SDL_GL_MakeCurrent(backup_current_window, backup_current_context);
|
||||||
|
}
|
||||||
|
|
||||||
SDL_GL_SwapWindow(window);
|
SDL_GL_SwapWindow(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,11 +84,23 @@ int main(int, char**)
|
|||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||||
|
//io.ConfigViewportsNoAutoMerge = true;
|
||||||
|
//io.ConfigViewportsNoTaskBarIcon = true;
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
|
|
||||||
|
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
style.WindowRounding = 0.0f;
|
||||||
|
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
// Setup Platform/Renderer backends
|
||||||
ImGui_ImplSDL2_InitForOpenGL(window, gl_context);
|
ImGui_ImplSDL2_InitForOpenGL(window, gl_context);
|
||||||
ImGui_ImplOpenGL3_Init(glsl_version);
|
ImGui_ImplOpenGL3_Init(glsl_version);
|
||||||
@ -194,6 +206,19 @@ int main(int, char**)
|
|||||||
glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w);
|
glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
|
||||||
|
// Update and Render additional Platform Windows
|
||||||
|
// (Platform functions may change the current OpenGL context, so we save/restore it to make it easier to paste this code elsewhere.
|
||||||
|
// For this specific demo app we could also call SDL_GL_MakeCurrent(window, gl_context) directly)
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
SDL_Window* backup_current_window = SDL_GL_GetCurrentWindow();
|
||||||
|
SDL_GLContext backup_current_context = SDL_GL_GetCurrentContext();
|
||||||
|
ImGui::UpdatePlatformWindows();
|
||||||
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
SDL_GL_MakeCurrent(backup_current_window, backup_current_context);
|
||||||
|
}
|
||||||
|
|
||||||
SDL_GL_SwapWindow(window);
|
SDL_GL_SwapWindow(window);
|
||||||
}
|
}
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
|
@ -59,6 +59,7 @@ int main(int, char**)
|
|||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
|
@ -429,11 +429,23 @@ int main(int, char**)
|
|||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||||
|
//io.ConfigFlags |= ImGuiConfigFlags_ViewportsNoTaskBarIcons;
|
||||||
|
//io.ConfigFlags |= ImGuiConfigFlags_ViewportsNoMerge;
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
|
|
||||||
|
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
style.WindowRounding = 0.0f;
|
||||||
|
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
// Setup Platform/Renderer backends
|
||||||
ImGui_ImplSDL2_InitForVulkan(window);
|
ImGui_ImplSDL2_InitForVulkan(window);
|
||||||
ImGui_ImplVulkan_InitInfo init_info = {};
|
ImGui_ImplVulkan_InitInfo init_info = {};
|
||||||
@ -553,17 +565,25 @@ int main(int, char**)
|
|||||||
|
|
||||||
// Rendering
|
// Rendering
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
ImDrawData* draw_data = ImGui::GetDrawData();
|
ImDrawData* main_draw_data = ImGui::GetDrawData();
|
||||||
const bool is_minimized = (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f);
|
const bool main_is_minimized = (main_draw_data->DisplaySize.x <= 0.0f || main_draw_data->DisplaySize.y <= 0.0f);
|
||||||
if (!is_minimized)
|
wd->ClearValue.color.float32[0] = clear_color.x * clear_color.w;
|
||||||
|
wd->ClearValue.color.float32[1] = clear_color.y * clear_color.w;
|
||||||
|
wd->ClearValue.color.float32[2] = clear_color.z * clear_color.w;
|
||||||
|
wd->ClearValue.color.float32[3] = clear_color.w;
|
||||||
|
if (!main_is_minimized)
|
||||||
|
FrameRender(wd, main_draw_data);
|
||||||
|
|
||||||
|
// Update and Render additional Platform Windows
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
{
|
{
|
||||||
wd->ClearValue.color.float32[0] = clear_color.x * clear_color.w;
|
ImGui::UpdatePlatformWindows();
|
||||||
wd->ClearValue.color.float32[1] = clear_color.y * clear_color.w;
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
wd->ClearValue.color.float32[2] = clear_color.z * clear_color.w;
|
|
||||||
wd->ClearValue.color.float32[3] = clear_color.w;
|
|
||||||
FrameRender(wd, draw_data);
|
|
||||||
FramePresent(wd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Present Main Platform Window
|
||||||
|
if (!main_is_minimized)
|
||||||
|
FramePresent(wd);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
|
@ -80,11 +80,23 @@ int main(int, char**)
|
|||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||||
|
//io.ConfigViewportsNoAutoMerge = true;
|
||||||
|
//io.ConfigViewportsNoTaskBarIcon = true;
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
|
|
||||||
|
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
style.WindowRounding = 0.0f;
|
||||||
|
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
// Setup Platform/Renderer backends
|
||||||
ImGui_ImplSDL3_InitForOpenGL(window, gl_context);
|
ImGui_ImplSDL3_InitForOpenGL(window, gl_context);
|
||||||
ImGui_ImplOpenGL3_Init(glsl_version);
|
ImGui_ImplOpenGL3_Init(glsl_version);
|
||||||
@ -190,6 +202,19 @@ int main(int, char**)
|
|||||||
glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w);
|
glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
|
||||||
|
// Update and Render additional Platform Windows
|
||||||
|
// (Platform functions may change the current OpenGL context, so we save/restore it to make it easier to paste this code elsewhere.
|
||||||
|
// For this specific demo app we could also call SDL_GL_MakeCurrent(window, gl_context) directly)
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
SDL_Window* backup_current_window = SDL_GL_GetCurrentWindow();
|
||||||
|
SDL_GLContext backup_current_context = SDL_GL_GetCurrentContext();
|
||||||
|
ImGui::UpdatePlatformWindows();
|
||||||
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
SDL_GL_MakeCurrent(backup_current_window, backup_current_context);
|
||||||
|
}
|
||||||
|
|
||||||
SDL_GL_SwapWindow(window);
|
SDL_GL_SwapWindow(window);
|
||||||
}
|
}
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
|
@ -32,13 +32,17 @@ int main(int, char**)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create window with SDL_Renderer graphics context
|
// Create window with SDL_Renderer graphics context
|
||||||
Uint32 window_flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN;
|
Uint32 window_flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN;
|
||||||
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL3+SDL_Renderer example", 1280, 720, window_flags);
|
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL3+SDL_Renderer example", 1280, 720, window_flags);
|
||||||
if (window == nullptr)
|
if (window == nullptr)
|
||||||
{
|
{
|
||||||
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int n = 0; n < SDL_GetNumRenderDrivers(); n++)
|
||||||
|
printf("- render driver %d: %s\n", n, SDL_GetRenderDriver(n));
|
||||||
|
|
||||||
SDL_Renderer* renderer = SDL_CreateRenderer(window, nullptr);
|
SDL_Renderer* renderer = SDL_CreateRenderer(window, nullptr);
|
||||||
SDL_SetRenderVSync(renderer, 1);
|
SDL_SetRenderVSync(renderer, 1);
|
||||||
if (renderer == nullptr)
|
if (renderer == nullptr)
|
||||||
@ -55,6 +59,8 @@ int main(int, char**)
|
|||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
@ -165,6 +171,14 @@ int main(int, char**)
|
|||||||
SDL_SetRenderDrawColorFloat(renderer, clear_color.x, clear_color.y, clear_color.z, clear_color.w);
|
SDL_SetRenderDrawColorFloat(renderer, clear_color.x, clear_color.y, clear_color.z, clear_color.w);
|
||||||
SDL_RenderClear(renderer);
|
SDL_RenderClear(renderer);
|
||||||
ImGui_ImplSDLRenderer3_RenderDrawData(ImGui::GetDrawData(), renderer);
|
ImGui_ImplSDLRenderer3_RenderDrawData(ImGui::GetDrawData(), renderer);
|
||||||
|
|
||||||
|
// Update and Render additional Platform Windows
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
ImGui::UpdatePlatformWindows();
|
||||||
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
}
|
||||||
|
|
||||||
SDL_RenderPresent(renderer);
|
SDL_RenderPresent(renderer);
|
||||||
}
|
}
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
|
@ -54,11 +54,23 @@ int main(int, char**)
|
|||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||||
|
//io.ConfigViewportsNoAutoMerge = true;
|
||||||
|
//io.ConfigViewportsNoTaskBarIcon = true;
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
|
|
||||||
|
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
style.WindowRounding = 0.0f;
|
||||||
|
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
// Setup Platform/Renderer backends
|
||||||
ImGui_ImplWin32_Init(hwnd);
|
ImGui_ImplWin32_Init(hwnd);
|
||||||
ImGui_ImplDX10_Init(g_pd3dDevice);
|
ImGui_ImplDX10_Init(g_pd3dDevice);
|
||||||
@ -167,6 +179,13 @@ int main(int, char**)
|
|||||||
g_pd3dDevice->ClearRenderTargetView(g_mainRenderTargetView, clear_color_with_alpha);
|
g_pd3dDevice->ClearRenderTargetView(g_mainRenderTargetView, clear_color_with_alpha);
|
||||||
ImGui_ImplDX10_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplDX10_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
|
||||||
|
// Update and Render additional Platform Windows
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
ImGui::UpdatePlatformWindows();
|
||||||
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
}
|
||||||
|
|
||||||
// Present
|
// Present
|
||||||
HRESULT hr = g_pSwapChain->Present(1, 0); // Present with vsync
|
HRESULT hr = g_pSwapChain->Present(1, 0); // Present with vsync
|
||||||
//HRESULT hr = g_pSwapChain->Present(0, 0); // Present without vsync
|
//HRESULT hr = g_pSwapChain->Present(0, 0); // Present without vsync
|
||||||
@ -186,7 +205,6 @@ int main(int, char**)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper functions
|
// Helper functions
|
||||||
|
|
||||||
bool CreateDeviceD3D(HWND hWnd)
|
bool CreateDeviceD3D(HWND hWnd)
|
||||||
{
|
{
|
||||||
// Setup swap chain
|
// Setup swap chain
|
||||||
|
@ -54,11 +54,28 @@ int main(int, char**)
|
|||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||||
|
//io.ConfigViewportsNoAutoMerge = true;
|
||||||
|
//io.ConfigViewportsNoTaskBarIcon = true;
|
||||||
|
//io.ConfigViewportsNoDefaultParent = true;
|
||||||
|
//io.ConfigDockingAlwaysTabBar = true;
|
||||||
|
//io.ConfigDockingTransparentPayload = true;
|
||||||
|
//io.ConfigFlags |= ImGuiConfigFlags_DpiEnableScaleFonts; // FIXME-DPI: Experimental. THIS CURRENTLY DOESN'T WORK AS EXPECTED. DON'T USE IN USER APP!
|
||||||
|
//io.ConfigFlags |= ImGuiConfigFlags_DpiEnableScaleViewports; // FIXME-DPI: Experimental.
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
|
|
||||||
|
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
style.WindowRounding = 0.0f;
|
||||||
|
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
// Setup Platform/Renderer backends
|
||||||
ImGui_ImplWin32_Init(hwnd);
|
ImGui_ImplWin32_Init(hwnd);
|
||||||
ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext);
|
ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext);
|
||||||
@ -167,6 +184,13 @@ int main(int, char**)
|
|||||||
g_pd3dDeviceContext->ClearRenderTargetView(g_mainRenderTargetView, clear_color_with_alpha);
|
g_pd3dDeviceContext->ClearRenderTargetView(g_mainRenderTargetView, clear_color_with_alpha);
|
||||||
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
|
||||||
|
// Update and Render additional Platform Windows
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
ImGui::UpdatePlatformWindows();
|
||||||
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
}
|
||||||
|
|
||||||
// Present
|
// Present
|
||||||
HRESULT hr = g_pSwapChain->Present(1, 0); // Present with vsync
|
HRESULT hr = g_pSwapChain->Present(1, 0); // Present with vsync
|
||||||
//HRESULT hr = g_pSwapChain->Present(0, 0); // Present without vsync
|
//HRESULT hr = g_pSwapChain->Present(0, 0); // Present without vsync
|
||||||
@ -186,7 +210,6 @@ int main(int, char**)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper functions
|
// Helper functions
|
||||||
|
|
||||||
bool CreateDeviceD3D(HWND hWnd)
|
bool CreateDeviceD3D(HWND hWnd)
|
||||||
{
|
{
|
||||||
// Setup swap chain
|
// Setup swap chain
|
||||||
@ -241,6 +264,10 @@ void CleanupRenderTarget()
|
|||||||
if (g_mainRenderTargetView) { g_mainRenderTargetView->Release(); g_mainRenderTargetView = nullptr; }
|
if (g_mainRenderTargetView) { g_mainRenderTargetView->Release(); g_mainRenderTargetView = nullptr; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef WM_DPICHANGED
|
||||||
|
#define WM_DPICHANGED 0x02E0 // From Windows SDK 8.1+ headers
|
||||||
|
#endif
|
||||||
|
|
||||||
// Forward declare message handler from imgui_impl_win32.cpp
|
// Forward declare message handler from imgui_impl_win32.cpp
|
||||||
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
@ -269,6 +296,15 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
::PostQuitMessage(0);
|
::PostQuitMessage(0);
|
||||||
return 0;
|
return 0;
|
||||||
|
case WM_DPICHANGED:
|
||||||
|
if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_DpiEnableScaleViewports)
|
||||||
|
{
|
||||||
|
//const int dpi = HIWORD(wParam);
|
||||||
|
//printf("WM_DPICHANGED to %d (%.0f%%)\n", dpi, (float)dpi / 96.0f * 100.0f);
|
||||||
|
const RECT* suggested_rect = (RECT*)lParam;
|
||||||
|
::SetWindowPos(hWnd, nullptr, suggested_rect->left, suggested_rect->top, suggested_rect->right - suggested_rect->left, suggested_rect->bottom - suggested_rect->top, SWP_NOZORDER | SWP_NOACTIVATE);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return ::DefWindowProcW(hWnd, msg, wParam, lParam);
|
return ::DefWindowProcW(hWnd, msg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
@ -90,11 +90,23 @@ int main(int, char**)
|
|||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||||
|
//io.ConfigViewportsNoAutoMerge = true;
|
||||||
|
//io.ConfigViewportsNoTaskBarIcon = true;
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
|
|
||||||
|
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
style.WindowRounding = 0.0f;
|
||||||
|
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
// Setup Platform/Renderer backends
|
||||||
ImGui_ImplWin32_Init(hwnd);
|
ImGui_ImplWin32_Init(hwnd);
|
||||||
ImGui_ImplDX12_Init(g_pd3dDevice, NUM_FRAMES_IN_FLIGHT,
|
ImGui_ImplDX12_Init(g_pd3dDevice, NUM_FRAMES_IN_FLIGHT,
|
||||||
@ -220,6 +232,13 @@ int main(int, char**)
|
|||||||
|
|
||||||
g_pd3dCommandQueue->ExecuteCommandLists(1, (ID3D12CommandList* const*)&g_pd3dCommandList);
|
g_pd3dCommandQueue->ExecuteCommandLists(1, (ID3D12CommandList* const*)&g_pd3dCommandList);
|
||||||
|
|
||||||
|
// Update and Render additional Platform Windows
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
ImGui::UpdatePlatformWindows();
|
||||||
|
ImGui::RenderPlatformWindowsDefault(nullptr, (void*)g_pd3dCommandList);
|
||||||
|
}
|
||||||
|
|
||||||
// Present
|
// Present
|
||||||
HRESULT hr = g_pSwapChain->Present(1, 0); // Present with vsync
|
HRESULT hr = g_pSwapChain->Present(1, 0); // Present with vsync
|
||||||
//HRESULT hr = g_pSwapChain->Present(0, 0); // Present without vsync
|
//HRESULT hr = g_pSwapChain->Present(0, 0); // Present without vsync
|
||||||
@ -246,7 +265,6 @@ int main(int, char**)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper functions
|
// Helper functions
|
||||||
|
|
||||||
bool CreateDeviceD3D(HWND hWnd)
|
bool CreateDeviceD3D(HWND hWnd)
|
||||||
{
|
{
|
||||||
// Setup swap chain
|
// Setup swap chain
|
||||||
|
@ -52,11 +52,23 @@ int main(int, char**)
|
|||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||||
|
//io.ConfigViewportsNoAutoMerge = true;
|
||||||
|
//io.ConfigViewportsNoTaskBarIcon = true;
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
|
|
||||||
|
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
style.WindowRounding = 0.0f;
|
||||||
|
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
// Setup Platform/Renderer backends
|
||||||
ImGui_ImplWin32_Init(hwnd);
|
ImGui_ImplWin32_Init(hwnd);
|
||||||
ImGui_ImplDX9_Init(g_pd3dDevice);
|
ImGui_ImplDX9_Init(g_pd3dDevice);
|
||||||
@ -177,6 +189,14 @@ int main(int, char**)
|
|||||||
ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData());
|
||||||
g_pd3dDevice->EndScene();
|
g_pd3dDevice->EndScene();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update and Render additional Platform Windows
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
ImGui::UpdatePlatformWindows();
|
||||||
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
}
|
||||||
|
|
||||||
HRESULT result = g_pd3dDevice->Present(nullptr, nullptr, nullptr, nullptr);
|
HRESULT result = g_pd3dDevice->Present(nullptr, nullptr, nullptr, nullptr);
|
||||||
if (result == D3DERR_DEVICELOST)
|
if (result == D3DERR_DEVICELOST)
|
||||||
g_DeviceLost = true;
|
g_DeviceLost = true;
|
||||||
@ -195,7 +215,6 @@ int main(int, char**)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper functions
|
// Helper functions
|
||||||
|
|
||||||
bool CreateDeviceD3D(HWND hWnd)
|
bool CreateDeviceD3D(HWND hWnd)
|
||||||
{
|
{
|
||||||
if ((g_pD3D = Direct3DCreate9(D3D_SDK_VERSION)) == nullptr)
|
if ((g_pD3D = Direct3DCreate9(D3D_SDK_VERSION)) == nullptr)
|
||||||
@ -231,6 +250,10 @@ void ResetDevice()
|
|||||||
ImGui_ImplDX9_CreateDeviceObjects();
|
ImGui_ImplDX9_CreateDeviceObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef WM_DPICHANGED
|
||||||
|
#define WM_DPICHANGED 0x02E0 // From Windows SDK 8.1+ headers
|
||||||
|
#endif
|
||||||
|
|
||||||
// Forward declare message handler from imgui_impl_win32.cpp
|
// Forward declare message handler from imgui_impl_win32.cpp
|
||||||
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
@ -259,6 +282,15 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
::PostQuitMessage(0);
|
::PostQuitMessage(0);
|
||||||
return 0;
|
return 0;
|
||||||
|
case WM_DPICHANGED:
|
||||||
|
if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_DpiEnableScaleViewports)
|
||||||
|
{
|
||||||
|
//const int dpi = HIWORD(wParam);
|
||||||
|
//printf("WM_DPICHANGED to %d (%.0f%%)\n", dpi, (float)dpi / 96.0f * 100.0f);
|
||||||
|
const RECT* suggested_rect = (RECT*)lParam;
|
||||||
|
::SetWindowPos(hWnd, nullptr, suggested_rect->left, suggested_rect->top, suggested_rect->right - suggested_rect->left, suggested_rect->bottom - suggested_rect->top, SWP_NOZORDER | SWP_NOACTIVATE);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return ::DefWindowProcW(hWnd, msg, wParam, lParam);
|
return ::DefWindowProcW(hWnd, msg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,42 @@ void CleanupDeviceWGL(HWND hWnd, WGL_WindowData* data);
|
|||||||
void ResetDeviceWGL();
|
void ResetDeviceWGL();
|
||||||
LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
|
// Support function for multi-viewports
|
||||||
|
// Unlike most other backend combination, we need specific hooks to combine Win32+OpenGL.
|
||||||
|
// We could in theory decide to support Win32-specific code in OpenGL backend via e.g. an hypothetical ImGui_ImplOpenGL3_InitForRawWin32().
|
||||||
|
static void Hook_Renderer_CreateWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
assert(viewport->RendererUserData == NULL);
|
||||||
|
|
||||||
|
WGL_WindowData* data = IM_NEW(WGL_WindowData);
|
||||||
|
CreateDeviceWGL((HWND)viewport->PlatformHandle, data);
|
||||||
|
viewport->RendererUserData = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Hook_Renderer_DestroyWindow(ImGuiViewport* viewport)
|
||||||
|
{
|
||||||
|
if (viewport->RendererUserData != NULL)
|
||||||
|
{
|
||||||
|
WGL_WindowData* data = (WGL_WindowData*)viewport->RendererUserData;
|
||||||
|
CleanupDeviceWGL((HWND)viewport->PlatformHandle, data);
|
||||||
|
IM_DELETE(data);
|
||||||
|
viewport->RendererUserData = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Hook_Platform_RenderWindow(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
// Activate the platform window DC in the OpenGL rendering context
|
||||||
|
if (WGL_WindowData* data = (WGL_WindowData*)viewport->RendererUserData)
|
||||||
|
wglMakeCurrent(data->hDC, g_hRC);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Hook_Renderer_SwapBuffers(ImGuiViewport* viewport, void*)
|
||||||
|
{
|
||||||
|
if (WGL_WindowData* data = (WGL_WindowData*)viewport->RendererUserData)
|
||||||
|
::SwapBuffers(data->hDC);
|
||||||
|
}
|
||||||
|
|
||||||
// Main code
|
// Main code
|
||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
@ -62,15 +98,39 @@ int main(int, char**)
|
|||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsClassic();
|
//ImGui::StyleColorsClassic();
|
||||||
|
|
||||||
|
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
style.WindowRounding = 0.0f;
|
||||||
|
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
// Setup Platform/Renderer backends
|
||||||
ImGui_ImplWin32_InitForOpenGL(hwnd);
|
ImGui_ImplWin32_InitForOpenGL(hwnd);
|
||||||
ImGui_ImplOpenGL3_Init();
|
ImGui_ImplOpenGL3_Init();
|
||||||
|
|
||||||
|
// Win32+GL needs specific hooks for viewport, as there are specific things needed to tie Win32 and GL api.
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
|
IM_ASSERT(platform_io.Renderer_CreateWindow == NULL);
|
||||||
|
IM_ASSERT(platform_io.Renderer_DestroyWindow == NULL);
|
||||||
|
IM_ASSERT(platform_io.Renderer_SwapBuffers == NULL);
|
||||||
|
IM_ASSERT(platform_io.Platform_RenderWindow == NULL);
|
||||||
|
platform_io.Renderer_CreateWindow = Hook_Renderer_CreateWindow;
|
||||||
|
platform_io.Renderer_DestroyWindow = Hook_Renderer_DestroyWindow;
|
||||||
|
platform_io.Renderer_SwapBuffers = Hook_Renderer_SwapBuffers;
|
||||||
|
platform_io.Platform_RenderWindow = Hook_Platform_RenderWindow;
|
||||||
|
}
|
||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
||||||
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
||||||
@ -163,6 +223,16 @@ int main(int, char**)
|
|||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
|
||||||
|
// Update and Render additional Platform Windows
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
ImGui::UpdatePlatformWindows();
|
||||||
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
|
||||||
|
// Restore the OpenGL rendering context to the main window DC, since platform windows might have changed it.
|
||||||
|
wglMakeCurrent(g_MainWindow.hDC, g_hRC);
|
||||||
|
}
|
||||||
|
|
||||||
// Present
|
// Present
|
||||||
::SwapBuffers(g_MainWindow.hDC);
|
::SwapBuffers(g_MainWindow.hDC);
|
||||||
}
|
}
|
||||||
|
286
imgui.h
286
imgui.h
@ -31,6 +31,8 @@
|
|||||||
#define IMGUI_VERSION "1.91.1"
|
#define IMGUI_VERSION "1.91.1"
|
||||||
#define IMGUI_VERSION_NUM 19110
|
#define IMGUI_VERSION_NUM 19110
|
||||||
#define IMGUI_HAS_TABLE
|
#define IMGUI_HAS_TABLE
|
||||||
|
#define IMGUI_HAS_VIEWPORT // Viewport WIP branch
|
||||||
|
#define IMGUI_HAS_DOCK // Docking WIP branch
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
@ -43,13 +45,13 @@ Index of this file:
|
|||||||
// [SECTION] Helpers: Debug log, Memory allocations macros, ImVector<>
|
// [SECTION] Helpers: Debug log, Memory allocations macros, ImVector<>
|
||||||
// [SECTION] ImGuiStyle
|
// [SECTION] ImGuiStyle
|
||||||
// [SECTION] ImGuiIO
|
// [SECTION] ImGuiIO
|
||||||
// [SECTION] Misc data structures (ImGuiInputTextCallbackData, ImGuiSizeCallbackData, ImGuiPayload)
|
// [SECTION] Misc data structures (ImGuiInputTextCallbackData, ImGuiSizeCallbackData, ImGuiWindowClass, ImGuiPayload)
|
||||||
// [SECTION] Helpers (ImGuiOnceUponAFrame, ImGuiTextFilter, ImGuiTextBuffer, ImGuiStorage, ImGuiListClipper, Math Operators, ImColor)
|
// [SECTION] Helpers (ImGuiOnceUponAFrame, ImGuiTextFilter, ImGuiTextBuffer, ImGuiStorage, ImGuiListClipper, Math Operators, ImColor)
|
||||||
// [SECTION] Multi-Select API flags and structures (ImGuiMultiSelectFlags, ImGuiMultiSelectIO, ImGuiSelectionRequest, ImGuiSelectionBasicStorage, ImGuiSelectionExternalStorage)
|
// [SECTION] Multi-Select API flags and structures (ImGuiMultiSelectFlags, ImGuiMultiSelectIO, ImGuiSelectionRequest, ImGuiSelectionBasicStorage, ImGuiSelectionExternalStorage)
|
||||||
// [SECTION] Drawing API (ImDrawCallback, ImDrawCmd, ImDrawIdx, ImDrawVert, ImDrawChannel, ImDrawListSplitter, ImDrawFlags, ImDrawListFlags, ImDrawList, ImDrawData)
|
// [SECTION] Drawing API (ImDrawCallback, ImDrawCmd, ImDrawIdx, ImDrawVert, ImDrawChannel, ImDrawListSplitter, ImDrawFlags, ImDrawListFlags, ImDrawList, ImDrawData)
|
||||||
// [SECTION] Font API (ImFontConfig, ImFontGlyph, ImFontGlyphRangesBuilder, ImFontAtlasFlags, ImFontAtlas, ImFont)
|
// [SECTION] Font API (ImFontConfig, ImFontGlyph, ImFontGlyphRangesBuilder, ImFontAtlasFlags, ImFontAtlas, ImFont)
|
||||||
// [SECTION] Viewports (ImGuiViewportFlags, ImGuiViewport)
|
// [SECTION] Viewports (ImGuiViewportFlags, ImGuiViewport)
|
||||||
// [SECTION] ImGuiPlatformIO + other Platform Dependent Interfaces (ImGuiPlatformImeData)
|
// [SECTION] ImGuiPlatformIO + other Platform Dependent Interfaces (ImGuiPlatformMonitor, ImGuiPlatformImeData)
|
||||||
// [SECTION] Obsolete functions and types
|
// [SECTION] Obsolete functions and types
|
||||||
|
|
||||||
*/
|
*/
|
||||||
@ -179,8 +181,9 @@ struct ImGuiListClipper; // Helper to manually clip large list of ite
|
|||||||
struct ImGuiMultiSelectIO; // Structure to interact with a BeginMultiSelect()/EndMultiSelect() block
|
struct ImGuiMultiSelectIO; // Structure to interact with a BeginMultiSelect()/EndMultiSelect() block
|
||||||
struct ImGuiOnceUponAFrame; // Helper for running a block of code not more than once a frame
|
struct ImGuiOnceUponAFrame; // Helper for running a block of code not more than once a frame
|
||||||
struct ImGuiPayload; // User data payload for drag and drop operations
|
struct ImGuiPayload; // User data payload for drag and drop operations
|
||||||
struct ImGuiPlatformIO; // Interface between platform/renderer backends and ImGui (e.g. Clipboard, IME hooks). Extends ImGuiIO. In docking branch, this gets extended to support multi-viewports.
|
struct ImGuiPlatformIO; // Interface between platform/renderer backends and ImGui (e.g. Clipboard, IME, Multi-Viewport support). Extends ImGuiIO.
|
||||||
struct ImGuiPlatformImeData; // Platform IME data for io.PlatformSetImeDataFn() function.
|
struct ImGuiPlatformImeData; // Platform IME data for io.PlatformSetImeDataFn() function.
|
||||||
|
struct ImGuiPlatformMonitor; // Multi-viewport support: user-provided bounds for each connected monitor/display. Used when positioning popups and tooltips to avoid them straddling monitors
|
||||||
struct ImGuiSelectionBasicStorage; // Optional helper to store multi-selection state + apply multi-selection requests.
|
struct ImGuiSelectionBasicStorage; // Optional helper to store multi-selection state + apply multi-selection requests.
|
||||||
struct ImGuiSelectionExternalStorage;//Optional helper to apply multi-selection requests to existing randomly accessible storage.
|
struct ImGuiSelectionExternalStorage;//Optional helper to apply multi-selection requests to existing randomly accessible storage.
|
||||||
struct ImGuiSelectionRequest; // A selection request (stored in ImGuiMultiSelectIO)
|
struct ImGuiSelectionRequest; // A selection request (stored in ImGuiMultiSelectIO)
|
||||||
@ -192,7 +195,8 @@ struct ImGuiTableSortSpecs; // Sorting specifications for a table (often
|
|||||||
struct ImGuiTableColumnSortSpecs; // Sorting specification for one column of a table
|
struct ImGuiTableColumnSortSpecs; // Sorting specification for one column of a table
|
||||||
struct ImGuiTextBuffer; // Helper to hold and append into a text buffer (~string builder)
|
struct ImGuiTextBuffer; // Helper to hold and append into a text buffer (~string builder)
|
||||||
struct ImGuiTextFilter; // Helper to parse and apply text filters (e.g. "aaaaa[,bbbbb][,ccccc]")
|
struct ImGuiTextFilter; // Helper to parse and apply text filters (e.g. "aaaaa[,bbbbb][,ccccc]")
|
||||||
struct ImGuiViewport; // A Platform Window (always only one in 'master' branch), in the future may represent Platform Monitor
|
struct ImGuiViewport; // A Platform Window (always 1 unless multi-viewport are enabled. One per platform window to output to). In the future may represent Platform Monitor
|
||||||
|
struct ImGuiWindowClass; // Window class (rare/advanced uses: provide hints to the platform backend via altered viewport flags and parent/child info)
|
||||||
|
|
||||||
// Enumerations
|
// Enumerations
|
||||||
// - We don't use strongly typed enums much because they add constraints (can't extend in private code, can't store typed in bit fields, extra casting on iteration)
|
// - We don't use strongly typed enums much because they add constraints (can't extend in private code, can't store typed in bit fields, extra casting on iteration)
|
||||||
@ -226,6 +230,7 @@ typedef int ImGuiChildFlags; // -> enum ImGuiChildFlags_ // Flags: f
|
|||||||
typedef int ImGuiColorEditFlags; // -> enum ImGuiColorEditFlags_ // Flags: for ColorEdit4(), ColorPicker4() etc.
|
typedef int ImGuiColorEditFlags; // -> enum ImGuiColorEditFlags_ // Flags: for ColorEdit4(), ColorPicker4() etc.
|
||||||
typedef int ImGuiConfigFlags; // -> enum ImGuiConfigFlags_ // Flags: for io.ConfigFlags
|
typedef int ImGuiConfigFlags; // -> enum ImGuiConfigFlags_ // Flags: for io.ConfigFlags
|
||||||
typedef int ImGuiComboFlags; // -> enum ImGuiComboFlags_ // Flags: for BeginCombo()
|
typedef int ImGuiComboFlags; // -> enum ImGuiComboFlags_ // Flags: for BeginCombo()
|
||||||
|
typedef int ImGuiDockNodeFlags; // -> enum ImGuiDockNodeFlags_ // Flags: for DockSpace()
|
||||||
typedef int ImGuiDragDropFlags; // -> enum ImGuiDragDropFlags_ // Flags: for BeginDragDropSource(), AcceptDragDropPayload()
|
typedef int ImGuiDragDropFlags; // -> enum ImGuiDragDropFlags_ // Flags: for BeginDragDropSource(), AcceptDragDropPayload()
|
||||||
typedef int ImGuiFocusedFlags; // -> enum ImGuiFocusedFlags_ // Flags: for IsWindowFocused()
|
typedef int ImGuiFocusedFlags; // -> enum ImGuiFocusedFlags_ // Flags: for IsWindowFocused()
|
||||||
typedef int ImGuiHoveredFlags; // -> enum ImGuiHoveredFlags_ // Flags: for IsItemHovered(), IsWindowHovered() etc.
|
typedef int ImGuiHoveredFlags; // -> enum ImGuiHoveredFlags_ // Flags: for IsItemHovered(), IsWindowHovered() etc.
|
||||||
@ -395,10 +400,12 @@ namespace ImGui
|
|||||||
IMGUI_API bool IsWindowFocused(ImGuiFocusedFlags flags=0); // is current window focused? or its root/child, depending on flags. see flags for options.
|
IMGUI_API bool IsWindowFocused(ImGuiFocusedFlags flags=0); // is current window focused? or its root/child, depending on flags. see flags for options.
|
||||||
IMGUI_API bool IsWindowHovered(ImGuiHoveredFlags flags=0); // is current window hovered and hoverable (e.g. not blocked by a popup/modal)? See ImGuiHoveredFlags_ for options. IMPORTANT: If you are trying to check whether your mouse should be dispatched to Dear ImGui or to your underlying app, you should not use this function! Use the 'io.WantCaptureMouse' boolean for that! Refer to FAQ entry "How can I tell whether to dispatch mouse/keyboard to Dear ImGui or my application?" for details.
|
IMGUI_API bool IsWindowHovered(ImGuiHoveredFlags flags=0); // is current window hovered and hoverable (e.g. not blocked by a popup/modal)? See ImGuiHoveredFlags_ for options. IMPORTANT: If you are trying to check whether your mouse should be dispatched to Dear ImGui or to your underlying app, you should not use this function! Use the 'io.WantCaptureMouse' boolean for that! Refer to FAQ entry "How can I tell whether to dispatch mouse/keyboard to Dear ImGui or my application?" for details.
|
||||||
IMGUI_API ImDrawList* GetWindowDrawList(); // get draw list associated to the current window, to append your own drawing primitives
|
IMGUI_API ImDrawList* GetWindowDrawList(); // get draw list associated to the current window, to append your own drawing primitives
|
||||||
|
IMGUI_API float GetWindowDpiScale(); // get DPI scale currently associated to the current window's viewport.
|
||||||
IMGUI_API ImVec2 GetWindowPos(); // get current window position in screen space (IT IS UNLIKELY YOU EVER NEED TO USE THIS. Consider always using GetCursorScreenPos() and GetContentRegionAvail() instead)
|
IMGUI_API ImVec2 GetWindowPos(); // get current window position in screen space (IT IS UNLIKELY YOU EVER NEED TO USE THIS. Consider always using GetCursorScreenPos() and GetContentRegionAvail() instead)
|
||||||
IMGUI_API ImVec2 GetWindowSize(); // get current window size (IT IS UNLIKELY YOU EVER NEED TO USE THIS. Consider always using GetCursorScreenPos() and GetContentRegionAvail() instead)
|
IMGUI_API ImVec2 GetWindowSize(); // get current window size (IT IS UNLIKELY YOU EVER NEED TO USE THIS. Consider always using GetCursorScreenPos() and GetContentRegionAvail() instead)
|
||||||
IMGUI_API float GetWindowWidth(); // get current window width (IT IS UNLIKELY YOU EVER NEED TO USE THIS). Shortcut for GetWindowSize().x.
|
IMGUI_API float GetWindowWidth(); // get current window width (IT IS UNLIKELY YOU EVER NEED TO USE THIS). Shortcut for GetWindowSize().x.
|
||||||
IMGUI_API float GetWindowHeight(); // get current window height (IT IS UNLIKELY YOU EVER NEED TO USE THIS). Shortcut for GetWindowSize().y.
|
IMGUI_API float GetWindowHeight(); // get current window height (IT IS UNLIKELY YOU EVER NEED TO USE THIS). Shortcut for GetWindowSize().y.
|
||||||
|
IMGUI_API ImGuiViewport*GetWindowViewport(); // get viewport currently associated to the current window.
|
||||||
|
|
||||||
// Window manipulation
|
// Window manipulation
|
||||||
// - Prefer using SetNextXXX functions (before Begin) rather that SetXXX functions (after Begin).
|
// - Prefer using SetNextXXX functions (before Begin) rather that SetXXX functions (after Begin).
|
||||||
@ -410,6 +417,7 @@ namespace ImGui
|
|||||||
IMGUI_API void SetNextWindowFocus(); // set next window to be focused / top-most. call before Begin()
|
IMGUI_API void SetNextWindowFocus(); // set next window to be focused / top-most. call before Begin()
|
||||||
IMGUI_API void SetNextWindowScroll(const ImVec2& scroll); // set next window scrolling value (use < 0.0f to not affect a given axis).
|
IMGUI_API void SetNextWindowScroll(const ImVec2& scroll); // set next window scrolling value (use < 0.0f to not affect a given axis).
|
||||||
IMGUI_API void SetNextWindowBgAlpha(float alpha); // set next window background color alpha. helper to easily override the Alpha component of ImGuiCol_WindowBg/ChildBg/PopupBg. you may also use ImGuiWindowFlags_NoBackground.
|
IMGUI_API void SetNextWindowBgAlpha(float alpha); // set next window background color alpha. helper to easily override the Alpha component of ImGuiCol_WindowBg/ChildBg/PopupBg. you may also use ImGuiWindowFlags_NoBackground.
|
||||||
|
IMGUI_API void SetNextWindowViewport(ImGuiID viewport_id); // set next window viewport
|
||||||
IMGUI_API void SetWindowPos(const ImVec2& pos, ImGuiCond cond = 0); // (not recommended) set current window position - call within Begin()/End(). prefer using SetNextWindowPos(), as this may incur tearing and side-effects.
|
IMGUI_API void SetWindowPos(const ImVec2& pos, ImGuiCond cond = 0); // (not recommended) set current window position - call within Begin()/End(). prefer using SetNextWindowPos(), as this may incur tearing and side-effects.
|
||||||
IMGUI_API void SetWindowSize(const ImVec2& size, ImGuiCond cond = 0); // (not recommended) set current window size - call within Begin()/End(). set to ImVec2(0, 0) to force an auto-fit. prefer using SetNextWindowSize(), as this may incur tearing and minor side-effects.
|
IMGUI_API void SetWindowSize(const ImVec2& size, ImGuiCond cond = 0); // (not recommended) set current window size - call within Begin()/End(). set to ImVec2(0, 0) to force an auto-fit. prefer using SetNextWindowSize(), as this may incur tearing and minor side-effects.
|
||||||
IMGUI_API void SetWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // (not recommended) set current window collapsed state. prefer using SetNextWindowCollapsed().
|
IMGUI_API void SetWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // (not recommended) set current window collapsed state. prefer using SetNextWindowCollapsed().
|
||||||
@ -861,6 +869,26 @@ namespace ImGui
|
|||||||
IMGUI_API bool TabItemButton(const char* label, ImGuiTabItemFlags flags = 0); // create a Tab behaving like a button. return true when clicked. cannot be selected in the tab bar.
|
IMGUI_API bool TabItemButton(const char* label, ImGuiTabItemFlags flags = 0); // create a Tab behaving like a button. return true when clicked. cannot be selected in the tab bar.
|
||||||
IMGUI_API void SetTabItemClosed(const char* tab_or_docked_window_label); // notify TabBar or Docking system of a closed tab/window ahead (useful to reduce visual flicker on reorderable tab bars). For tab-bar: call after BeginTabBar() and before Tab submissions. Otherwise call with a window name.
|
IMGUI_API void SetTabItemClosed(const char* tab_or_docked_window_label); // notify TabBar or Docking system of a closed tab/window ahead (useful to reduce visual flicker on reorderable tab bars). For tab-bar: call after BeginTabBar() and before Tab submissions. Otherwise call with a window name.
|
||||||
|
|
||||||
|
// Docking
|
||||||
|
// [BETA API] Enable with io.ConfigFlags |= ImGuiConfigFlags_DockingEnable.
|
||||||
|
// Note: You can use most Docking facilities without calling any API. You DO NOT need to call DockSpace() to use Docking!
|
||||||
|
// - Drag from window title bar or their tab to dock/undock. Hold SHIFT to disable docking.
|
||||||
|
// - Drag from window menu button (upper-left button) to undock an entire node (all windows).
|
||||||
|
// - When io.ConfigDockingWithShift == true, you instead need to hold SHIFT to enable docking.
|
||||||
|
// About dockspaces:
|
||||||
|
// - Use DockSpaceOverViewport() to create a window covering the screen or a specific viewport + a dockspace inside it.
|
||||||
|
// This is often used with ImGuiDockNodeFlags_PassthruCentralNode to make it transparent.
|
||||||
|
// - Use DockSpace() to create an explicit dock node _within_ an existing window. See Docking demo for details.
|
||||||
|
// - Important: Dockspaces need to be submitted _before_ any window they can host. Submit it early in your frame!
|
||||||
|
// - Important: Dockspaces need to be kept alive if hidden, otherwise windows docked into it will be undocked.
|
||||||
|
// e.g. if you have multiple tabs with a dockspace inside each tab: submit the non-visible dockspaces with ImGuiDockNodeFlags_KeepAliveOnly.
|
||||||
|
IMGUI_API ImGuiID DockSpace(ImGuiID dockspace_id, const ImVec2& size = ImVec2(0, 0), ImGuiDockNodeFlags flags = 0, const ImGuiWindowClass* window_class = NULL);
|
||||||
|
IMGUI_API ImGuiID DockSpaceOverViewport(ImGuiID dockspace_id = 0, const ImGuiViewport* viewport = NULL, ImGuiDockNodeFlags flags = 0, const ImGuiWindowClass* window_class = NULL);
|
||||||
|
IMGUI_API void SetNextWindowDockID(ImGuiID dock_id, ImGuiCond cond = 0); // set next window dock id
|
||||||
|
IMGUI_API void SetNextWindowClass(const ImGuiWindowClass* window_class); // set next window class (control docking compatibility + provide hints to platform backend via custom viewport flags and platform parent/child relationship)
|
||||||
|
IMGUI_API ImGuiID GetWindowDockID();
|
||||||
|
IMGUI_API bool IsWindowDocked(); // is current window docked into another window?
|
||||||
|
|
||||||
// Logging/Capture
|
// Logging/Capture
|
||||||
// - All text output from the interface can be captured into tty/file/clipboard. By default, tree nodes are automatically opened during logging.
|
// - All text output from the interface can be captured into tty/file/clipboard. By default, tree nodes are automatically opened during logging.
|
||||||
IMGUI_API void LogToTTY(int auto_open_depth = -1); // start logging to tty (stdout)
|
IMGUI_API void LogToTTY(int auto_open_depth = -1); // start logging to tty (stdout)
|
||||||
@ -933,8 +961,8 @@ namespace ImGui
|
|||||||
IMGUI_API ImGuiViewport* GetMainViewport(); // return primary/default viewport. This can never be NULL.
|
IMGUI_API ImGuiViewport* GetMainViewport(); // return primary/default viewport. This can never be NULL.
|
||||||
|
|
||||||
// Background/Foreground Draw Lists
|
// Background/Foreground Draw Lists
|
||||||
IMGUI_API ImDrawList* GetBackgroundDrawList(); // this draw list will be the first rendered one. Useful to quickly draw shapes/text behind dear imgui contents.
|
IMGUI_API ImDrawList* GetBackgroundDrawList(ImGuiViewport* viewport = NULL); // get background draw list for the given viewport or viewport associated to the current window. this draw list will be the first rendering one. Useful to quickly draw shapes/text behind dear imgui contents.
|
||||||
IMGUI_API ImDrawList* GetForegroundDrawList(); // this draw list will be the last rendered one. Useful to quickly draw shapes/text over dear imgui contents.
|
IMGUI_API ImDrawList* GetForegroundDrawList(ImGuiViewport* viewport = NULL); // get foreground draw list for the given viewport or viewport associated to the current window. this draw list will be the top-most rendered one. Useful to quickly draw shapes/text over dear imgui contents.
|
||||||
|
|
||||||
// Miscellaneous Utilities
|
// Miscellaneous Utilities
|
||||||
IMGUI_API bool IsRectVisible(const ImVec2& size); // test if rectangle (of given size, starting from cursor position) is visible / not clipped.
|
IMGUI_API bool IsRectVisible(const ImVec2& size); // test if rectangle (of given size, starting from cursor position) is visible / not clipped.
|
||||||
@ -1049,6 +1077,15 @@ namespace ImGui
|
|||||||
IMGUI_API void* MemAlloc(size_t size);
|
IMGUI_API void* MemAlloc(size_t size);
|
||||||
IMGUI_API void MemFree(void* ptr);
|
IMGUI_API void MemFree(void* ptr);
|
||||||
|
|
||||||
|
// (Optional) Platform/OS interface for multi-viewport support
|
||||||
|
// Read comments around the ImGuiPlatformIO structure for more details.
|
||||||
|
// Note: You may use GetWindowViewport() to get the current viewport of the current window.
|
||||||
|
IMGUI_API void UpdatePlatformWindows(); // call in main loop. will call CreateWindow/ResizeWindow/etc. platform functions for each secondary viewport, and DestroyWindow for each inactive viewport.
|
||||||
|
IMGUI_API void RenderPlatformWindowsDefault(void* platform_render_arg = NULL, void* renderer_render_arg = NULL); // call in main loop. will call RenderWindow/SwapBuffers platform functions for each secondary viewport which doesn't have the ImGuiViewportFlags_Minimized flag set. May be reimplemented by user for custom rendering needs.
|
||||||
|
IMGUI_API void DestroyPlatformWindows(); // call DestroyWindow platform functions for all viewports. call from backend Shutdown() if you need to close platform windows before imgui shutdown. otherwise will be called by DestroyContext().
|
||||||
|
IMGUI_API ImGuiViewport* FindViewportByID(ImGuiID id); // this is a helper for backends.
|
||||||
|
IMGUI_API ImGuiViewport* FindViewportByPlatformHandle(void* platform_handle); // this is a helper for backends. the type platform_handle is decided by the backend (e.g. HWND, MyWindow*, GLFWwindow* etc.)
|
||||||
|
|
||||||
} // namespace ImGui
|
} // namespace ImGui
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -1079,6 +1116,7 @@ enum ImGuiWindowFlags_
|
|||||||
ImGuiWindowFlags_NoNavInputs = 1 << 16, // No gamepad/keyboard navigation within the window
|
ImGuiWindowFlags_NoNavInputs = 1 << 16, // No gamepad/keyboard navigation within the window
|
||||||
ImGuiWindowFlags_NoNavFocus = 1 << 17, // No focusing toward this window with gamepad/keyboard navigation (e.g. skipped by CTRL+TAB)
|
ImGuiWindowFlags_NoNavFocus = 1 << 17, // No focusing toward this window with gamepad/keyboard navigation (e.g. skipped by CTRL+TAB)
|
||||||
ImGuiWindowFlags_UnsavedDocument = 1 << 18, // Display a dot next to the title. When used in a tab/docking context, tab is selected when clicking the X + closure is not assumed (will wait for user to stop submitting the tab). Otherwise closure is assumed when pressing the X, so if you keep submitting the tab may reappear at end of tab bar.
|
ImGuiWindowFlags_UnsavedDocument = 1 << 18, // Display a dot next to the title. When used in a tab/docking context, tab is selected when clicking the X + closure is not assumed (will wait for user to stop submitting the tab). Otherwise closure is assumed when pressing the X, so if you keep submitting the tab may reappear at end of tab bar.
|
||||||
|
ImGuiWindowFlags_NoDocking = 1 << 19, // Disable docking of this window
|
||||||
ImGuiWindowFlags_NoNav = ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus,
|
ImGuiWindowFlags_NoNav = ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus,
|
||||||
ImGuiWindowFlags_NoDecoration = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse,
|
ImGuiWindowFlags_NoDecoration = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse,
|
||||||
ImGuiWindowFlags_NoInputs = ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus,
|
ImGuiWindowFlags_NoInputs = ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus,
|
||||||
@ -1089,6 +1127,7 @@ enum ImGuiWindowFlags_
|
|||||||
ImGuiWindowFlags_Popup = 1 << 26, // Don't use! For internal use by BeginPopup()
|
ImGuiWindowFlags_Popup = 1 << 26, // Don't use! For internal use by BeginPopup()
|
||||||
ImGuiWindowFlags_Modal = 1 << 27, // Don't use! For internal use by BeginPopupModal()
|
ImGuiWindowFlags_Modal = 1 << 27, // Don't use! For internal use by BeginPopupModal()
|
||||||
ImGuiWindowFlags_ChildMenu = 1 << 28, // Don't use! For internal use by BeginMenu()
|
ImGuiWindowFlags_ChildMenu = 1 << 28, // Don't use! For internal use by BeginMenu()
|
||||||
|
ImGuiWindowFlags_DockNodeHost = 1 << 29, // Don't use! For internal use by Begin()/NewFrame()
|
||||||
|
|
||||||
// Obsolete names
|
// Obsolete names
|
||||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
@ -1302,7 +1341,7 @@ enum ImGuiFocusedFlags_
|
|||||||
ImGuiFocusedFlags_RootWindow = 1 << 1, // Test from root window (top most parent of the current hierarchy)
|
ImGuiFocusedFlags_RootWindow = 1 << 1, // Test from root window (top most parent of the current hierarchy)
|
||||||
ImGuiFocusedFlags_AnyWindow = 1 << 2, // Return true if any window is focused. Important: If you are trying to tell how to dispatch your low-level inputs, do NOT use this. Use 'io.WantCaptureMouse' instead! Please read the FAQ!
|
ImGuiFocusedFlags_AnyWindow = 1 << 2, // Return true if any window is focused. Important: If you are trying to tell how to dispatch your low-level inputs, do NOT use this. Use 'io.WantCaptureMouse' instead! Please read the FAQ!
|
||||||
ImGuiFocusedFlags_NoPopupHierarchy = 1 << 3, // Do not consider popup hierarchy (do not treat popup emitter as parent of popup) (when used with _ChildWindows or _RootWindow)
|
ImGuiFocusedFlags_NoPopupHierarchy = 1 << 3, // Do not consider popup hierarchy (do not treat popup emitter as parent of popup) (when used with _ChildWindows or _RootWindow)
|
||||||
//ImGuiFocusedFlags_DockHierarchy = 1 << 4, // Consider docking hierarchy (treat dockspace host as parent of docked window) (when used with _ChildWindows or _RootWindow)
|
ImGuiFocusedFlags_DockHierarchy = 1 << 4, // Consider docking hierarchy (treat dockspace host as parent of docked window) (when used with _ChildWindows or _RootWindow)
|
||||||
ImGuiFocusedFlags_RootAndChildWindows = ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows,
|
ImGuiFocusedFlags_RootAndChildWindows = ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1316,7 +1355,7 @@ enum ImGuiHoveredFlags_
|
|||||||
ImGuiHoveredFlags_RootWindow = 1 << 1, // IsWindowHovered() only: Test from root window (top most parent of the current hierarchy)
|
ImGuiHoveredFlags_RootWindow = 1 << 1, // IsWindowHovered() only: Test from root window (top most parent of the current hierarchy)
|
||||||
ImGuiHoveredFlags_AnyWindow = 1 << 2, // IsWindowHovered() only: Return true if any window is hovered
|
ImGuiHoveredFlags_AnyWindow = 1 << 2, // IsWindowHovered() only: Return true if any window is hovered
|
||||||
ImGuiHoveredFlags_NoPopupHierarchy = 1 << 3, // IsWindowHovered() only: Do not consider popup hierarchy (do not treat popup emitter as parent of popup) (when used with _ChildWindows or _RootWindow)
|
ImGuiHoveredFlags_NoPopupHierarchy = 1 << 3, // IsWindowHovered() only: Do not consider popup hierarchy (do not treat popup emitter as parent of popup) (when used with _ChildWindows or _RootWindow)
|
||||||
//ImGuiHoveredFlags_DockHierarchy = 1 << 4, // IsWindowHovered() only: Consider docking hierarchy (treat dockspace host as parent of docked window) (when used with _ChildWindows or _RootWindow)
|
ImGuiHoveredFlags_DockHierarchy = 1 << 4, // IsWindowHovered() only: Consider docking hierarchy (treat dockspace host as parent of docked window) (when used with _ChildWindows or _RootWindow)
|
||||||
ImGuiHoveredFlags_AllowWhenBlockedByPopup = 1 << 5, // Return true even if a popup window is normally blocking access to this item/window
|
ImGuiHoveredFlags_AllowWhenBlockedByPopup = 1 << 5, // Return true even if a popup window is normally blocking access to this item/window
|
||||||
//ImGuiHoveredFlags_AllowWhenBlockedByModal = 1 << 6, // Return true even if a modal popup window is normally blocking access to this item/window. FIXME-TODO: Unavailable yet.
|
//ImGuiHoveredFlags_AllowWhenBlockedByModal = 1 << 6, // Return true even if a modal popup window is normally blocking access to this item/window. FIXME-TODO: Unavailable yet.
|
||||||
ImGuiHoveredFlags_AllowWhenBlockedByActiveItem = 1 << 7, // Return true even if an active item is blocking access to this item/window. Useful for Drag and Drop patterns.
|
ImGuiHoveredFlags_AllowWhenBlockedByActiveItem = 1 << 7, // Return true even if an active item is blocking access to this item/window. Useful for Drag and Drop patterns.
|
||||||
@ -1346,6 +1385,27 @@ enum ImGuiHoveredFlags_
|
|||||||
ImGuiHoveredFlags_NoSharedDelay = 1 << 17, // IsItemHovered() only: Disable shared delay system where moving from one item to the next keeps the previous timer for a short time (standard for tooltips with long delays)
|
ImGuiHoveredFlags_NoSharedDelay = 1 << 17, // IsItemHovered() only: Disable shared delay system where moving from one item to the next keeps the previous timer for a short time (standard for tooltips with long delays)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Flags for ImGui::DockSpace(), shared/inherited by child nodes.
|
||||||
|
// (Some flags can be applied to individual nodes directly)
|
||||||
|
// FIXME-DOCK: Also see ImGuiDockNodeFlagsPrivate_ which may involve using the WIP and internal DockBuilder api.
|
||||||
|
enum ImGuiDockNodeFlags_
|
||||||
|
{
|
||||||
|
ImGuiDockNodeFlags_None = 0,
|
||||||
|
ImGuiDockNodeFlags_KeepAliveOnly = 1 << 0, // // Don't display the dockspace node but keep it alive. Windows docked into this dockspace node won't be undocked.
|
||||||
|
//ImGuiDockNodeFlags_NoCentralNode = 1 << 1, // // Disable Central Node (the node which can stay empty)
|
||||||
|
ImGuiDockNodeFlags_NoDockingOverCentralNode = 1 << 2, // // Disable docking over the Central Node, which will be always kept empty.
|
||||||
|
ImGuiDockNodeFlags_PassthruCentralNode = 1 << 3, // // Enable passthru dockspace: 1) DockSpace() will render a ImGuiCol_WindowBg background covering everything excepted the Central Node when empty. Meaning the host window should probably use SetNextWindowBgAlpha(0.0f) prior to Begin() when using this. 2) When Central Node is empty: let inputs pass-through + won't display a DockingEmptyBg background. See demo for details.
|
||||||
|
ImGuiDockNodeFlags_NoDockingSplit = 1 << 4, // // Disable other windows/nodes from splitting this node.
|
||||||
|
ImGuiDockNodeFlags_NoResize = 1 << 5, // Saved // Disable resizing node using the splitter/separators. Useful with programmatically setup dockspaces.
|
||||||
|
ImGuiDockNodeFlags_AutoHideTabBar = 1 << 6, // // Tab bar will automatically hide when there is a single window in the dock node.
|
||||||
|
ImGuiDockNodeFlags_NoUndocking = 1 << 7, // // Disable undocking this node.
|
||||||
|
|
||||||
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
|
ImGuiDockNodeFlags_NoSplit = ImGuiDockNodeFlags_NoDockingSplit, // Renamed in 1.90
|
||||||
|
ImGuiDockNodeFlags_NoDockingInCentralNode = ImGuiDockNodeFlags_NoDockingOverCentralNode, // Renamed in 1.90
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
// Flags for ImGui::BeginDragDropSource(), ImGui::AcceptDragDropPayload()
|
// Flags for ImGui::BeginDragDropSource(), ImGui::AcceptDragDropPayload()
|
||||||
enum ImGuiDragDropFlags_
|
enum ImGuiDragDropFlags_
|
||||||
{
|
{
|
||||||
@ -1600,6 +1660,15 @@ enum ImGuiConfigFlags_
|
|||||||
ImGuiConfigFlags_NoMouseCursorChange = 1 << 5, // Instruct backend to not alter mouse cursor shape and visibility. Use if the backend cursor changes are interfering with yours and you don't want to use SetMouseCursor() to change mouse cursor. You may want to honor requests from imgui by reading GetMouseCursor() yourself instead.
|
ImGuiConfigFlags_NoMouseCursorChange = 1 << 5, // Instruct backend to not alter mouse cursor shape and visibility. Use if the backend cursor changes are interfering with yours and you don't want to use SetMouseCursor() to change mouse cursor. You may want to honor requests from imgui by reading GetMouseCursor() yourself instead.
|
||||||
ImGuiConfigFlags_NoKeyboard = 1 << 6, // Instruct dear imgui to disable keyboard inputs and interactions. This is done by ignoring keyboard events and clearing existing states.
|
ImGuiConfigFlags_NoKeyboard = 1 << 6, // Instruct dear imgui to disable keyboard inputs and interactions. This is done by ignoring keyboard events and clearing existing states.
|
||||||
|
|
||||||
|
// [BETA] Docking
|
||||||
|
ImGuiConfigFlags_DockingEnable = 1 << 7, // Docking enable flags.
|
||||||
|
|
||||||
|
// [BETA] Viewports
|
||||||
|
// When using viewports it is recommended that your default value for ImGuiCol_WindowBg is opaque (Alpha=1.0) so transition to a viewport won't be noticeable.
|
||||||
|
ImGuiConfigFlags_ViewportsEnable = 1 << 10, // Viewport enable flags (require both ImGuiBackendFlags_PlatformHasViewports + ImGuiBackendFlags_RendererHasViewports set by the respective backends)
|
||||||
|
ImGuiConfigFlags_DpiEnableScaleViewports= 1 << 14, // [BETA: Don't use] FIXME-DPI: Reposition and resize imgui windows when the DpiScale of a viewport changed (mostly useful for the main viewport hosting other window). Note that resizing the main window itself is up to your application.
|
||||||
|
ImGuiConfigFlags_DpiEnableScaleFonts = 1 << 15, // [BETA: Don't use] FIXME-DPI: Request bitmap-scaled fonts to match DpiScale. This is a very low-quality workaround. The correct way to handle DPI is _currently_ to replace the atlas and/or fonts in the Platform_OnChangedViewport callback, but this is all early work in progress.
|
||||||
|
|
||||||
// User storage (to allow your backend/engine to communicate to code that may be shared between multiple projects. Those flags are NOT used by core Dear ImGui)
|
// User storage (to allow your backend/engine to communicate to code that may be shared between multiple projects. Those flags are NOT used by core Dear ImGui)
|
||||||
ImGuiConfigFlags_IsSRGB = 1 << 20, // Application is SRGB-aware.
|
ImGuiConfigFlags_IsSRGB = 1 << 20, // Application is SRGB-aware.
|
||||||
ImGuiConfigFlags_IsTouchScreen = 1 << 21, // Application is using a touch screen instead of a mouse.
|
ImGuiConfigFlags_IsTouchScreen = 1 << 21, // Application is using a touch screen instead of a mouse.
|
||||||
@ -1613,6 +1682,11 @@ enum ImGuiBackendFlags_
|
|||||||
ImGuiBackendFlags_HasMouseCursors = 1 << 1, // Backend Platform supports honoring GetMouseCursor() value to change the OS cursor shape.
|
ImGuiBackendFlags_HasMouseCursors = 1 << 1, // Backend Platform supports honoring GetMouseCursor() value to change the OS cursor shape.
|
||||||
ImGuiBackendFlags_HasSetMousePos = 1 << 2, // Backend Platform supports io.WantSetMousePos requests to reposition the OS mouse position (only used if ImGuiConfigFlags_NavEnableSetMousePos is set).
|
ImGuiBackendFlags_HasSetMousePos = 1 << 2, // Backend Platform supports io.WantSetMousePos requests to reposition the OS mouse position (only used if ImGuiConfigFlags_NavEnableSetMousePos is set).
|
||||||
ImGuiBackendFlags_RendererHasVtxOffset = 1 << 3, // Backend Renderer supports ImDrawCmd::VtxOffset. This enables output of large meshes (64K+ vertices) while still using 16-bit indices.
|
ImGuiBackendFlags_RendererHasVtxOffset = 1 << 3, // Backend Renderer supports ImDrawCmd::VtxOffset. This enables output of large meshes (64K+ vertices) while still using 16-bit indices.
|
||||||
|
|
||||||
|
// [BETA] Viewports
|
||||||
|
ImGuiBackendFlags_PlatformHasViewports = 1 << 10, // Backend Platform supports multiple viewports.
|
||||||
|
ImGuiBackendFlags_HasMouseHoveredViewport=1 << 11, // Backend Platform supports calling io.AddMouseViewportEvent() with the viewport under the mouse. IF POSSIBLE, ignore viewports with the ImGuiViewportFlags_NoInputs flag (Win32 backend, GLFW 3.30+ backend can do this, SDL backend cannot). If this cannot be done, Dear ImGui needs to use a flawed heuristic to find the viewport under.
|
||||||
|
ImGuiBackendFlags_RendererHasViewports = 1 << 12, // Backend Renderer supports multiple viewports.
|
||||||
};
|
};
|
||||||
|
|
||||||
// Enumeration for PushStyleColor() / PopStyleColor()
|
// Enumeration for PushStyleColor() / PopStyleColor()
|
||||||
@ -1658,6 +1732,8 @@ enum ImGuiCol_
|
|||||||
ImGuiCol_TabDimmed, // Tab background, when tab-bar is unfocused & tab is unselected
|
ImGuiCol_TabDimmed, // Tab background, when tab-bar is unfocused & tab is unselected
|
||||||
ImGuiCol_TabDimmedSelected, // Tab background, when tab-bar is unfocused & tab is selected
|
ImGuiCol_TabDimmedSelected, // Tab background, when tab-bar is unfocused & tab is selected
|
||||||
ImGuiCol_TabDimmedSelectedOverline,//..horizontal overline, when tab-bar is unfocused & tab is selected
|
ImGuiCol_TabDimmedSelectedOverline,//..horizontal overline, when tab-bar is unfocused & tab is selected
|
||||||
|
ImGuiCol_DockingPreview, // Preview overlay color when about to docking something
|
||||||
|
ImGuiCol_DockingEmptyBg, // Background color for empty node (e.g. CentralNode with no window docked into it)
|
||||||
ImGuiCol_PlotLines,
|
ImGuiCol_PlotLines,
|
||||||
ImGuiCol_PlotLinesHovered,
|
ImGuiCol_PlotLinesHovered,
|
||||||
ImGuiCol_PlotHistogram,
|
ImGuiCol_PlotHistogram,
|
||||||
@ -1727,6 +1803,7 @@ enum ImGuiStyleVar_
|
|||||||
ImGuiStyleVar_SeparatorTextBorderSize, // float SeparatorTextBorderSize
|
ImGuiStyleVar_SeparatorTextBorderSize, // float SeparatorTextBorderSize
|
||||||
ImGuiStyleVar_SeparatorTextAlign, // ImVec2 SeparatorTextAlign
|
ImGuiStyleVar_SeparatorTextAlign, // ImVec2 SeparatorTextAlign
|
||||||
ImGuiStyleVar_SeparatorTextPadding, // ImVec2 SeparatorTextPadding
|
ImGuiStyleVar_SeparatorTextPadding, // ImVec2 SeparatorTextPadding
|
||||||
|
ImGuiStyleVar_DockingSeparatorSize, // float DockingSeparatorSize
|
||||||
ImGuiStyleVar_COUNT
|
ImGuiStyleVar_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2174,6 +2251,7 @@ struct ImGuiStyle
|
|||||||
ImVec2 SeparatorTextPadding; // Horizontal offset of text from each edge of the separator + spacing on other axis. Generally small values. .y is recommended to be == FramePadding.y.
|
ImVec2 SeparatorTextPadding; // Horizontal offset of text from each edge of the separator + spacing on other axis. Generally small values. .y is recommended to be == FramePadding.y.
|
||||||
ImVec2 DisplayWindowPadding; // Apply to regular windows: amount which we enforce to keep visible when moving near edges of your screen.
|
ImVec2 DisplayWindowPadding; // Apply to regular windows: amount which we enforce to keep visible when moving near edges of your screen.
|
||||||
ImVec2 DisplaySafeAreaPadding; // Apply to every windows, menus, popups, tooltips: amount where we avoid displaying contents. Adjust if you cannot see the edges of your screen (e.g. on a TV where scaling has not been configured).
|
ImVec2 DisplaySafeAreaPadding; // Apply to every windows, menus, popups, tooltips: amount where we avoid displaying contents. Adjust if you cannot see the edges of your screen (e.g. on a TV where scaling has not been configured).
|
||||||
|
float DockingSeparatorSize; // Thickness of resizing border between docked windows
|
||||||
float MouseCursorScale; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). We apply per-monitor DPI scaling over this scale. May be removed later.
|
float MouseCursorScale; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). We apply per-monitor DPI scaling over this scale. May be removed later.
|
||||||
bool AntiAliasedLines; // Enable anti-aliased lines/borders. Disable if you are really tight on CPU/GPU. Latched at the beginning of the frame (copied to ImDrawList).
|
bool AntiAliasedLines; // Enable anti-aliased lines/borders. Disable if you are really tight on CPU/GPU. Latched at the beginning of the frame (copied to ImDrawList).
|
||||||
bool AntiAliasedLinesUseTex; // Enable anti-aliased lines/borders using textures where possible. Require backend to render with bilinear filtering (NOT point/nearest filtering). Latched at the beginning of the frame (copied to ImDrawList).
|
bool AntiAliasedLinesUseTex; // Enable anti-aliased lines/borders using textures where possible. Require backend to render with bilinear filtering (NOT point/nearest filtering). Latched at the beginning of the frame (copied to ImDrawList).
|
||||||
@ -2237,6 +2315,18 @@ struct ImGuiIO
|
|||||||
ImFont* FontDefault; // = NULL // Font to use on NewFrame(). Use NULL to uses Fonts->Fonts[0].
|
ImFont* FontDefault; // = NULL // Font to use on NewFrame(). Use NULL to uses Fonts->Fonts[0].
|
||||||
ImVec2 DisplayFramebufferScale; // = (1, 1) // For retina display or other situations where window coordinates are different from framebuffer coordinates. This generally ends up in ImDrawData::FramebufferScale.
|
ImVec2 DisplayFramebufferScale; // = (1, 1) // For retina display or other situations where window coordinates are different from framebuffer coordinates. This generally ends up in ImDrawData::FramebufferScale.
|
||||||
|
|
||||||
|
// Docking options (when ImGuiConfigFlags_DockingEnable is set)
|
||||||
|
bool ConfigDockingNoSplit; // = false // Simplified docking mode: disable window splitting, so docking is limited to merging multiple windows together into tab-bars.
|
||||||
|
bool ConfigDockingWithShift; // = false // Enable docking with holding Shift key (reduce visual noise, allows dropping in wider space)
|
||||||
|
bool ConfigDockingAlwaysTabBar; // = false // [BETA] [FIXME: This currently creates regression with auto-sizing and general overhead] Make every single floating window display within a docking node.
|
||||||
|
bool ConfigDockingTransparentPayload;// = false // [BETA] Make window or viewport transparent when docking and only display docking boxes on the target viewport. Useful if rendering of multiple viewport cannot be synced. Best used with ConfigViewportsNoAutoMerge.
|
||||||
|
|
||||||
|
// Viewport options (when ImGuiConfigFlags_ViewportsEnable is set)
|
||||||
|
bool ConfigViewportsNoAutoMerge; // = false; // Set to make all floating imgui windows always create their own viewport. Otherwise, they are merged into the main host viewports when overlapping it. May also set ImGuiViewportFlags_NoAutoMerge on individual viewport.
|
||||||
|
bool ConfigViewportsNoTaskBarIcon; // = false // Disable default OS task bar icon flag for secondary viewports. When a viewport doesn't want a task bar icon, ImGuiViewportFlags_NoTaskBarIcon will be set on it.
|
||||||
|
bool ConfigViewportsNoDecoration; // = true // Disable default OS window decoration flag for secondary viewports. When a viewport doesn't want window decorations, ImGuiViewportFlags_NoDecoration will be set on it. Enabling decoration can create subsequent issues at OS levels (e.g. minimum window size).
|
||||||
|
bool ConfigViewportsNoDefaultParent; // = false // Disable default OS parenting to main viewport for secondary viewports. By default, viewports are marked with ParentViewportId = <main_viewport>, expecting the platform backend to setup a parent/child relationship between the OS windows (some backend may ignore this). Set to true if you want the default to be 0, then all viewports will be top-level OS windows.
|
||||||
|
|
||||||
// Miscellaneous options
|
// Miscellaneous options
|
||||||
bool MouseDrawCursor; // = false // Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor). Cannot be easily renamed to 'io.ConfigXXX' because this is frequently used by backend implementations.
|
bool MouseDrawCursor; // = false // Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor). Cannot be easily renamed to 'io.ConfigXXX' because this is frequently used by backend implementations.
|
||||||
bool ConfigMacOSXBehaviors; // = defined(__APPLE__) // Swap Cmd<>Ctrl keys + OS X style text editing cursor movement using Alt instead of Ctrl, Shortcuts using Cmd/Super instead of Ctrl, Line/Text Start and End using Cmd+Arrows instead of Home/End, Double click selects by word instead of selecting whole text, Multi-selection in lists uses Cmd/Super instead of Ctrl.
|
bool ConfigMacOSXBehaviors; // = defined(__APPLE__) // Swap Cmd<>Ctrl keys + OS X style text editing cursor movement using Alt instead of Ctrl, Shortcuts using Cmd/Super instead of Ctrl, Line/Text Start and End using Cmd+Arrows instead of Home/End, Double click selects by word instead of selecting whole text, Multi-selection in lists uses Cmd/Super instead of Ctrl.
|
||||||
@ -2305,6 +2395,7 @@ struct ImGuiIO
|
|||||||
IMGUI_API void AddMouseButtonEvent(int button, bool down); // Queue a mouse button change
|
IMGUI_API void AddMouseButtonEvent(int button, bool down); // Queue a mouse button change
|
||||||
IMGUI_API void AddMouseWheelEvent(float wheel_x, float wheel_y); // Queue a mouse wheel update. wheel_y<0: scroll down, wheel_y>0: scroll up, wheel_x<0: scroll right, wheel_x>0: scroll left.
|
IMGUI_API void AddMouseWheelEvent(float wheel_x, float wheel_y); // Queue a mouse wheel update. wheel_y<0: scroll down, wheel_y>0: scroll up, wheel_x<0: scroll right, wheel_x>0: scroll left.
|
||||||
IMGUI_API void AddMouseSourceEvent(ImGuiMouseSource source); // Queue a mouse source change (Mouse/TouchScreen/Pen)
|
IMGUI_API void AddMouseSourceEvent(ImGuiMouseSource source); // Queue a mouse source change (Mouse/TouchScreen/Pen)
|
||||||
|
IMGUI_API void AddMouseViewportEvent(ImGuiID id); // Queue a mouse hovered viewport. Requires backend to set ImGuiBackendFlags_HasMouseHoveredViewport to call this (for multi-viewport support).
|
||||||
IMGUI_API void AddFocusEvent(bool focused); // Queue a gain/loss of focus for the application (generally based on OS/platform focus of your window)
|
IMGUI_API void AddFocusEvent(bool focused); // Queue a gain/loss of focus for the application (generally based on OS/platform focus of your window)
|
||||||
IMGUI_API void AddInputCharacter(unsigned int c); // Queue a new character input
|
IMGUI_API void AddInputCharacter(unsigned int c); // Queue a new character input
|
||||||
IMGUI_API void AddInputCharacterUTF16(ImWchar16 c); // Queue a new character input from a UTF-16 character, it can be a surrogate
|
IMGUI_API void AddInputCharacterUTF16(ImWchar16 c); // Queue a new character input from a UTF-16 character, it can be a surrogate
|
||||||
@ -2353,6 +2444,7 @@ struct ImGuiIO
|
|||||||
float MouseWheel; // Mouse wheel Vertical: 1 unit scrolls about 5 lines text. >0 scrolls Up, <0 scrolls Down. Hold SHIFT to turn vertical scroll into horizontal scroll.
|
float MouseWheel; // Mouse wheel Vertical: 1 unit scrolls about 5 lines text. >0 scrolls Up, <0 scrolls Down. Hold SHIFT to turn vertical scroll into horizontal scroll.
|
||||||
float MouseWheelH; // Mouse wheel Horizontal. >0 scrolls Left, <0 scrolls Right. Most users don't have a mouse with a horizontal wheel, may not be filled by all backends.
|
float MouseWheelH; // Mouse wheel Horizontal. >0 scrolls Left, <0 scrolls Right. Most users don't have a mouse with a horizontal wheel, may not be filled by all backends.
|
||||||
ImGuiMouseSource MouseSource; // Mouse actual input peripheral (Mouse/TouchScreen/Pen).
|
ImGuiMouseSource MouseSource; // Mouse actual input peripheral (Mouse/TouchScreen/Pen).
|
||||||
|
ImGuiID MouseHoveredViewport; // (Optional) Modify using io.AddMouseViewportEvent(). With multi-viewports: viewport the OS mouse is hovering. If possible _IGNORING_ viewports with the ImGuiViewportFlags_NoInputs flag is much better (few backends can handle that). Set io.BackendFlags |= ImGuiBackendFlags_HasMouseHoveredViewport if you can provide this info. If you don't imgui will infer the value using the rectangles and last focused time of the viewports it knows about (ignoring other OS windows).
|
||||||
bool KeyCtrl; // Keyboard modifier down: Control
|
bool KeyCtrl; // Keyboard modifier down: Control
|
||||||
bool KeyShift; // Keyboard modifier down: Shift
|
bool KeyShift; // Keyboard modifier down: Shift
|
||||||
bool KeyAlt; // Keyboard modifier down: Alt
|
bool KeyAlt; // Keyboard modifier down: Alt
|
||||||
@ -2376,6 +2468,7 @@ struct ImGuiIO
|
|||||||
bool MouseCtrlLeftAsRightClick; // (OSX) Set to true when the current click was a ctrl-click that spawned a simulated right click
|
bool MouseCtrlLeftAsRightClick; // (OSX) Set to true when the current click was a ctrl-click that spawned a simulated right click
|
||||||
float MouseDownDuration[5]; // Duration the mouse button has been down (0.0f == just clicked)
|
float MouseDownDuration[5]; // Duration the mouse button has been down (0.0f == just clicked)
|
||||||
float MouseDownDurationPrev[5]; // Previous time the mouse button has been down
|
float MouseDownDurationPrev[5]; // Previous time the mouse button has been down
|
||||||
|
ImVec2 MouseDragMaxDistanceAbs[5]; // Maximum distance, absolute, on each axis, of how much mouse has traveled from the clicking point
|
||||||
float MouseDragMaxDistanceSqr[5]; // Squared maximum distance of how much mouse has traveled from the clicking point (used for moving thresholds)
|
float MouseDragMaxDistanceSqr[5]; // Squared maximum distance of how much mouse has traveled from the clicking point (used for moving thresholds)
|
||||||
float PenPressure; // Touch/Pen pressure (0.0f to 1.0f, should be >0.0f only when MouseDown[0] == true). Helper storage currently unused by Dear ImGui.
|
float PenPressure; // Touch/Pen pressure (0.0f to 1.0f, should be >0.0f only when MouseDown[0] == true). Helper storage currently unused by Dear ImGui.
|
||||||
bool AppFocusLost; // Only modify via AddFocusEvent()
|
bool AppFocusLost; // Only modify via AddFocusEvent()
|
||||||
@ -2461,6 +2554,28 @@ struct ImGuiSizeCallbackData
|
|||||||
ImVec2 DesiredSize; // Read-write. Desired size, based on user's mouse position. Write to this field to restrain resizing.
|
ImVec2 DesiredSize; // Read-write. Desired size, based on user's mouse position. Write to this field to restrain resizing.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// [ALPHA] Rarely used / very advanced uses only. Use with SetNextWindowClass() and DockSpace() functions.
|
||||||
|
// Important: the content of this class is still highly WIP and likely to change and be refactored
|
||||||
|
// before we stabilize Docking features. Please be mindful if using this.
|
||||||
|
// Provide hints:
|
||||||
|
// - To the platform backend via altered viewport flags (enable/disable OS decoration, OS task bar icons, etc.)
|
||||||
|
// - To the platform backend for OS level parent/child relationships of viewport.
|
||||||
|
// - To the docking system for various options and filtering.
|
||||||
|
struct ImGuiWindowClass
|
||||||
|
{
|
||||||
|
ImGuiID ClassId; // User data. 0 = Default class (unclassed). Windows of different classes cannot be docked with each others.
|
||||||
|
ImGuiID ParentViewportId; // Hint for the platform backend. -1: use default. 0: request platform backend to not parent the platform. != 0: request platform backend to create a parent<>child relationship between the platform windows. Not conforming backends are free to e.g. parent every viewport to the main viewport or not.
|
||||||
|
ImGuiID FocusRouteParentWindowId; // ID of parent window for shortcut focus route evaluation, e.g. Shortcut() call from Parent Window will succeed when this window is focused.
|
||||||
|
ImGuiViewportFlags ViewportFlagsOverrideSet; // Viewport flags to set when a window of this class owns a viewport. This allows you to enforce OS decoration or task bar icon, override the defaults on a per-window basis.
|
||||||
|
ImGuiViewportFlags ViewportFlagsOverrideClear; // Viewport flags to clear when a window of this class owns a viewport. This allows you to enforce OS decoration or task bar icon, override the defaults on a per-window basis.
|
||||||
|
ImGuiTabItemFlags TabItemFlagsOverrideSet; // [EXPERIMENTAL] TabItem flags to set when a window of this class gets submitted into a dock node tab bar. May use with ImGuiTabItemFlags_Leading or ImGuiTabItemFlags_Trailing.
|
||||||
|
ImGuiDockNodeFlags DockNodeFlagsOverrideSet; // [EXPERIMENTAL] Dock node flags to set when a window of this class is hosted by a dock node (it doesn't have to be selected!)
|
||||||
|
bool DockingAlwaysTabBar; // Set to true to enforce single floating windows of this class always having their own docking node (equivalent of setting the global io.ConfigDockingAlwaysTabBar)
|
||||||
|
bool DockingAllowUnclassed; // Set to true to allow windows of this class to be docked/merged with an unclassed window. // FIXME-DOCK: Move to DockNodeFlags override?
|
||||||
|
|
||||||
|
ImGuiWindowClass() { memset(this, 0, sizeof(*this)); ParentViewportId = (ImGuiID)-1; DockingAllowUnclassed = true; }
|
||||||
|
};
|
||||||
|
|
||||||
// Data payload for Drag and Drop operations: AcceptDragDropPayload(), GetDragDropPayload()
|
// Data payload for Drag and Drop operations: AcceptDragDropPayload(), GetDragDropPayload()
|
||||||
struct ImGuiPayload
|
struct ImGuiPayload
|
||||||
{
|
{
|
||||||
@ -3164,7 +3279,7 @@ struct ImDrawList
|
|||||||
struct ImDrawData
|
struct ImDrawData
|
||||||
{
|
{
|
||||||
bool Valid; // Only valid after Render() is called and before the next NewFrame() is called.
|
bool Valid; // Only valid after Render() is called and before the next NewFrame() is called.
|
||||||
int CmdListsCount; // Number of ImDrawList* to render (should always be == CmdLists.size)
|
int CmdListsCount; // Number of ImDrawList* to render
|
||||||
int TotalIdxCount; // For convenience, sum of all ImDrawList's IdxBuffer.Size
|
int TotalIdxCount; // For convenience, sum of all ImDrawList's IdxBuffer.Size
|
||||||
int TotalVtxCount; // For convenience, sum of all ImDrawList's VtxBuffer.Size
|
int TotalVtxCount; // For convenience, sum of all ImDrawList's VtxBuffer.Size
|
||||||
ImVector<ImDrawList*> CmdLists; // Array of ImDrawList* to render. The ImDrawLists are owned by ImGuiContext and only pointed to from here.
|
ImVector<ImDrawList*> CmdLists; // Array of ImDrawList* to render. The ImDrawLists are owned by ImGuiContext and only pointed to from here.
|
||||||
@ -3447,11 +3562,24 @@ enum ImGuiViewportFlags_
|
|||||||
ImGuiViewportFlags_None = 0,
|
ImGuiViewportFlags_None = 0,
|
||||||
ImGuiViewportFlags_IsPlatformWindow = 1 << 0, // Represent a Platform Window
|
ImGuiViewportFlags_IsPlatformWindow = 1 << 0, // Represent a Platform Window
|
||||||
ImGuiViewportFlags_IsPlatformMonitor = 1 << 1, // Represent a Platform Monitor (unused yet)
|
ImGuiViewportFlags_IsPlatformMonitor = 1 << 1, // Represent a Platform Monitor (unused yet)
|
||||||
ImGuiViewportFlags_OwnedByApp = 1 << 2, // Platform Window: Is created/managed by the application (rather than a dear imgui backend)
|
ImGuiViewportFlags_OwnedByApp = 1 << 2, // Platform Window: Is created/managed by the user application? (rather than our backend)
|
||||||
|
ImGuiViewportFlags_NoDecoration = 1 << 3, // Platform Window: Disable platform decorations: title bar, borders, etc. (generally set all windows, but if ImGuiConfigFlags_ViewportsDecoration is set we only set this on popups/tooltips)
|
||||||
|
ImGuiViewportFlags_NoTaskBarIcon = 1 << 4, // Platform Window: Disable platform task bar icon (generally set on popups/tooltips, or all windows if ImGuiConfigFlags_ViewportsNoTaskBarIcon is set)
|
||||||
|
ImGuiViewportFlags_NoFocusOnAppearing = 1 << 5, // Platform Window: Don't take focus when created.
|
||||||
|
ImGuiViewportFlags_NoFocusOnClick = 1 << 6, // Platform Window: Don't take focus when clicked on.
|
||||||
|
ImGuiViewportFlags_NoInputs = 1 << 7, // Platform Window: Make mouse pass through so we can drag this window while peaking behind it.
|
||||||
|
ImGuiViewportFlags_NoRendererClear = 1 << 8, // Platform Window: Renderer doesn't need to clear the framebuffer ahead (because we will fill it entirely).
|
||||||
|
ImGuiViewportFlags_NoAutoMerge = 1 << 9, // Platform Window: Avoid merging this window into another host window. This can only be set via ImGuiWindowClass viewport flags override (because we need to now ahead if we are going to create a viewport in the first place!).
|
||||||
|
ImGuiViewportFlags_TopMost = 1 << 10, // Platform Window: Display on top (for tooltips only).
|
||||||
|
ImGuiViewportFlags_CanHostOtherWindows = 1 << 11, // Viewport can host multiple imgui windows (secondary viewports are associated to a single window). // FIXME: In practice there's still probably code making the assumption that this is always and only on the MainViewport. Will fix once we add support for "no main viewport".
|
||||||
|
|
||||||
|
// Output status flags (from Platform)
|
||||||
|
ImGuiViewportFlags_IsMinimized = 1 << 12, // Platform Window: Window is minimized, can skip render. When minimized we tend to avoid using the viewport pos/size for clipping window or testing if they are contained in the viewport.
|
||||||
|
ImGuiViewportFlags_IsFocused = 1 << 13, // Platform Window: Window is focused (last call to Platform_GetWindowFocus() returned true)
|
||||||
};
|
};
|
||||||
|
|
||||||
// - Currently represents the Platform Window created by the application which is hosting our Dear ImGui windows.
|
// - Currently represents the Platform Window created by the application which is hosting our Dear ImGui windows.
|
||||||
// - In 'docking' branch with multi-viewport enabled, we extend this concept to have multiple active viewports.
|
// - With multi-viewport enabled, we extend this concept to have multiple active viewports.
|
||||||
// - In the future we will extend this concept further to also represent Platform Monitor and support a "no main platform window" operation mode.
|
// - In the future we will extend this concept further to also represent Platform Monitor and support a "no main platform window" operation mode.
|
||||||
// - About Main Area vs Work Area:
|
// - About Main Area vs Work Area:
|
||||||
// - Main Area = entire viewport.
|
// - Main Area = entire viewport.
|
||||||
@ -3465,12 +3593,26 @@ struct ImGuiViewport
|
|||||||
ImVec2 Size; // Main Area: Size of the viewport.
|
ImVec2 Size; // Main Area: Size of the viewport.
|
||||||
ImVec2 WorkPos; // Work Area: Position of the viewport minus task bars, menus bars, status bars (>= Pos)
|
ImVec2 WorkPos; // Work Area: Position of the viewport minus task bars, menus bars, status bars (>= Pos)
|
||||||
ImVec2 WorkSize; // Work Area: Size of the viewport minus task bars, menu bars, status bars (<= Size)
|
ImVec2 WorkSize; // Work Area: Size of the viewport minus task bars, menu bars, status bars (<= Size)
|
||||||
|
float DpiScale; // 1.0f = 96 DPI = No extra scale.
|
||||||
|
ImGuiID ParentViewportId; // (Advanced) 0: no parent. Instruct the platform backend to setup a parent/child relationship between platform windows.
|
||||||
|
ImDrawData* DrawData; // The ImDrawData corresponding to this viewport. Valid after Render() and until the next call to NewFrame().
|
||||||
|
|
||||||
// Platform/Backend Dependent Data
|
// Platform/Backend Dependent Data
|
||||||
void* PlatformHandle; // void* to hold higher-level, platform window handle (e.g. HWND, GLFWWindow*, SDL_Window*)
|
// Our design separate the Renderer and Platform backends to facilitate combining default backends with each others.
|
||||||
void* PlatformHandleRaw; // void* to hold lower-level, platform-native window handle (under Win32 this is expected to be a HWND, unused for other platforms)
|
// When our create your own backend for a custom engine, it is possible that both Renderer and Platform will be handled
|
||||||
|
// by the same system and you may not need to use all the UserData/Handle fields.
|
||||||
|
// The library never uses those fields, they are merely storage to facilitate backend implementation.
|
||||||
|
void* RendererUserData; // void* to hold custom data structure for the renderer (e.g. swap chain, framebuffers etc.). generally set by your Renderer_CreateWindow function.
|
||||||
|
void* PlatformUserData; // void* to hold custom data structure for the OS / platform (e.g. windowing info, render context). generally set by your Platform_CreateWindow function.
|
||||||
|
void* PlatformHandle; // void* to hold higher-level, platform window handle (e.g. HWND, GLFWWindow*, SDL_Window*), for FindViewportByPlatformHandle().
|
||||||
|
void* PlatformHandleRaw; // void* to hold lower-level, platform-native window handle (under Win32 this is expected to be a HWND, unused for other platforms), when using an abstraction layer like GLFW or SDL (where PlatformHandle would be a SDL_Window*)
|
||||||
|
bool PlatformWindowCreated; // Platform window has been created (Platform_CreateWindow() has been called). This is false during the first frame where a viewport is being created.
|
||||||
|
bool PlatformRequestMove; // Platform window requested move (e.g. window was moved by the OS / host window manager, authoritative position will be OS window position)
|
||||||
|
bool PlatformRequestResize; // Platform window requested resize (e.g. window was resized by the OS / host window manager, authoritative size will be OS window size)
|
||||||
|
bool PlatformRequestClose; // Platform window requested closure (e.g. window was moved by the OS / host window manager, e.g. pressing ALT-F4)
|
||||||
|
|
||||||
ImGuiViewport() { memset(this, 0, sizeof(*this)); }
|
ImGuiViewport() { memset(this, 0, sizeof(*this)); }
|
||||||
|
~ImGuiViewport() { IM_ASSERT(PlatformUserData == NULL && RendererUserData == NULL); }
|
||||||
|
|
||||||
// Helpers
|
// Helpers
|
||||||
ImVec2 GetCenter() const { return ImVec2(Pos.x + Size.x * 0.5f, Pos.y + Size.y * 0.5f); }
|
ImVec2 GetCenter() const { return ImVec2(Pos.x + Size.x * 0.5f, Pos.y + Size.y * 0.5f); }
|
||||||
@ -3478,7 +3620,53 @@ struct ImGuiViewport
|
|||||||
};
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Platform Dependent Interfaces
|
// [SECTION] ImGuiPlatformIO + other Platform Dependent Interfaces (ImGuiPlatformMonitor, ImGuiPlatformImeData)
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// [BETA] (Optional) Multi-Viewport Support!
|
||||||
|
// If you are new to Dear ImGui and trying to integrate it into your engine, you can probably ignore this for now.
|
||||||
|
//
|
||||||
|
// This feature allows you to seamlessly drag Dear ImGui windows outside of your application viewport.
|
||||||
|
// This is achieved by creating new Platform/OS windows on the fly, and rendering into them.
|
||||||
|
// Dear ImGui manages the viewport structures, and the backend create and maintain one Platform/OS window for each of those viewports.
|
||||||
|
//
|
||||||
|
// See Recap: https://github.com/ocornut/imgui/wiki/Multi-Viewports
|
||||||
|
// See Glossary https://github.com/ocornut/imgui/wiki/Glossary for details about some of the terminology.
|
||||||
|
//
|
||||||
|
// About the coordinates system:
|
||||||
|
// - When multi-viewports are enabled, all Dear ImGui coordinates become absolute coordinates (same as OS coordinates!)
|
||||||
|
// - So e.g. ImGui::SetNextWindowPos(ImVec2(0,0)) will position a window relative to your primary monitor!
|
||||||
|
// - If you want to position windows relative to your main application viewport, use ImGui::GetMainViewport()->Pos as a base position.
|
||||||
|
//
|
||||||
|
// Steps to use multi-viewports in your application, when using a default backend from the examples/ folder:
|
||||||
|
// - Application: Enable feature with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
// - Backend: The backend initialization will setup all necessary ImGuiPlatformIO's functions and update monitors info every frame.
|
||||||
|
// - Application: In your main loop, call ImGui::UpdatePlatformWindows(), ImGui::RenderPlatformWindowsDefault() after EndFrame() or Render().
|
||||||
|
// - Application: Fix absolute coordinates used in ImGui::SetWindowPos() or ImGui::SetNextWindowPos() calls.
|
||||||
|
//
|
||||||
|
// Steps to use multi-viewports in your application, when using a custom backend:
|
||||||
|
// - Important: THIS IS NOT EASY TO DO and comes with many subtleties not described here!
|
||||||
|
// It's also an experimental feature, so some of the requirements may evolve.
|
||||||
|
// Consider using default backends if you can. Either way, carefully follow and refer to examples/ backends for details.
|
||||||
|
// - Application: Enable feature with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
|
||||||
|
// - Backend: Hook ImGuiPlatformIO's Platform_* and Renderer_* callbacks (see below).
|
||||||
|
// Set 'io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports' and 'io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports'.
|
||||||
|
// Update ImGuiPlatformIO's Monitors list every frame.
|
||||||
|
// Update MousePos every frame, in absolute coordinates.
|
||||||
|
// - Application: In your main loop, call ImGui::UpdatePlatformWindows(), ImGui::RenderPlatformWindowsDefault() after EndFrame() or Render().
|
||||||
|
// You may skip calling RenderPlatformWindowsDefault() if its API is not convenient for your needs. Read comments below.
|
||||||
|
// - Application: Fix absolute coordinates used in ImGui::SetWindowPos() or ImGui::SetNextWindowPos() calls.
|
||||||
|
//
|
||||||
|
// About ImGui::RenderPlatformWindowsDefault():
|
||||||
|
// - This function is a mostly a _helper_ for the common-most cases, and to facilitate using default backends.
|
||||||
|
// - You can check its simple source code to understand what it does.
|
||||||
|
// It basically iterates secondary viewports and call 4 functions that are setup in ImGuiPlatformIO, if available:
|
||||||
|
// Platform_RenderWindow(), Renderer_RenderWindow(), Platform_SwapBuffers(), Renderer_SwapBuffers()
|
||||||
|
// Those functions pointers exists only for the benefit of RenderPlatformWindowsDefault().
|
||||||
|
// - If you have very specific rendering needs (e.g. flipping multiple swap-chain simultaneously, unusual sync/threading issues, etc.),
|
||||||
|
// you may be tempted to ignore RenderPlatformWindowsDefault() and write customized code to perform your renderingg.
|
||||||
|
// You may decide to setup the platform_io's *RenderWindow and *SwapBuffers pointers and call your functions through those pointers,
|
||||||
|
// or you may decide to never setup those pointers and call your code directly. They are a convenience, not an obligatory interface.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Access via ImGui::GetPlatformIO()
|
// Access via ImGui::GetPlatformIO()
|
||||||
@ -3487,7 +3675,7 @@ struct ImGuiPlatformIO
|
|||||||
IMGUI_API ImGuiPlatformIO();
|
IMGUI_API ImGuiPlatformIO();
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Input - Interface with OS/backends
|
// Input - Interface with OS/backends (basic)
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
// Optional: Access OS clipboard
|
// Optional: Access OS clipboard
|
||||||
@ -3510,6 +3698,74 @@ struct ImGuiPlatformIO
|
|||||||
// Optional: Platform locale
|
// Optional: Platform locale
|
||||||
// [Experimental] Configure decimal point e.g. '.' or ',' useful for some languages (e.g. German), generally pulled from *localeconv()->decimal_point
|
// [Experimental] Configure decimal point e.g. '.' or ',' useful for some languages (e.g. German), generally pulled from *localeconv()->decimal_point
|
||||||
ImWchar Platform_LocaleDecimalPoint; // '.'
|
ImWchar Platform_LocaleDecimalPoint; // '.'
|
||||||
|
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
// Input - Interface with OS/backends (Multi-Viewport support!)
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
|
// For reference, the second column shows which function are generally calling the Platform Functions:
|
||||||
|
// N = ImGui::NewFrame() ~ beginning of the dear imgui frame: read info from platform/OS windows (latest size/position)
|
||||||
|
// F = ImGui::Begin(), ImGui::EndFrame() ~ during the dear imgui frame
|
||||||
|
// U = ImGui::UpdatePlatformWindows() ~ after the dear imgui frame: create and update all platform/OS windows
|
||||||
|
// R = ImGui::RenderPlatformWindowsDefault() ~ render
|
||||||
|
// D = ImGui::DestroyPlatformWindows() ~ shutdown
|
||||||
|
// The general idea is that NewFrame() we will read the current Platform/OS state, and UpdatePlatformWindows() will write to it.
|
||||||
|
|
||||||
|
// The handlers are designed so we can mix and match two imgui_impl_xxxx files, one Platform backend and one Renderer backend.
|
||||||
|
// Custom engine backends will often provide both Platform and Renderer interfaces together and so may not need to use all functions.
|
||||||
|
// Platform functions are typically called _before_ their Renderer counterpart, apart from Destroy which are called the other way.
|
||||||
|
|
||||||
|
// Platform Backend functions (e.g. Win32, GLFW, SDL) ------------------- Called by -----
|
||||||
|
void (*Platform_CreateWindow)(ImGuiViewport* vp); // . . U . . // Create a new platform window for the given viewport
|
||||||
|
void (*Platform_DestroyWindow)(ImGuiViewport* vp); // N . U . D //
|
||||||
|
void (*Platform_ShowWindow)(ImGuiViewport* vp); // . . U . . // Newly created windows are initially hidden so SetWindowPos/Size/Title can be called on them before showing the window
|
||||||
|
void (*Platform_SetWindowPos)(ImGuiViewport* vp, ImVec2 pos); // . . U . . // Set platform window position (given the upper-left corner of client area)
|
||||||
|
ImVec2 (*Platform_GetWindowPos)(ImGuiViewport* vp); // N . . . . //
|
||||||
|
void (*Platform_SetWindowSize)(ImGuiViewport* vp, ImVec2 size); // . . U . . // Set platform window client area size (ignoring OS decorations such as OS title bar etc.)
|
||||||
|
ImVec2 (*Platform_GetWindowSize)(ImGuiViewport* vp); // N . . . . // Get platform window client area size
|
||||||
|
void (*Platform_SetWindowFocus)(ImGuiViewport* vp); // N . . . . // Move window to front and set input focus
|
||||||
|
bool (*Platform_GetWindowFocus)(ImGuiViewport* vp); // . . U . . //
|
||||||
|
bool (*Platform_GetWindowMinimized)(ImGuiViewport* vp); // N . . . . // Get platform window minimized state. When minimized, we generally won't attempt to get/set size and contents will be culled more easily
|
||||||
|
void (*Platform_SetWindowTitle)(ImGuiViewport* vp, const char* str); // . . U . . // Set platform window title (given an UTF-8 string)
|
||||||
|
void (*Platform_SetWindowAlpha)(ImGuiViewport* vp, float alpha); // . . U . . // (Optional) Setup global transparency (not per-pixel transparency)
|
||||||
|
void (*Platform_UpdateWindow)(ImGuiViewport* vp); // . . U . . // (Optional) Called by UpdatePlatformWindows(). Optional hook to allow the platform backend from doing general book-keeping every frame.
|
||||||
|
void (*Platform_RenderWindow)(ImGuiViewport* vp, void* render_arg); // . . . R . // (Optional) Main rendering (platform side! This is often unused, or just setting a "current" context for OpenGL bindings). 'render_arg' is the value passed to RenderPlatformWindowsDefault().
|
||||||
|
void (*Platform_SwapBuffers)(ImGuiViewport* vp, void* render_arg); // . . . R . // (Optional) Call Present/SwapBuffers (platform side! This is often unused!). 'render_arg' is the value passed to RenderPlatformWindowsDefault().
|
||||||
|
float (*Platform_GetWindowDpiScale)(ImGuiViewport* vp); // N . . . . // (Optional) [BETA] FIXME-DPI: DPI handling: Return DPI scale for this viewport. 1.0f = 96 DPI.
|
||||||
|
void (*Platform_OnChangedViewport)(ImGuiViewport* vp); // . F . . . // (Optional) [BETA] FIXME-DPI: DPI handling: Called during Begin() every time the viewport we are outputting into changes, so backend has a chance to swap fonts to adjust style.
|
||||||
|
ImVec4 (*Platform_GetWindowWorkAreaInsets)(ImGuiViewport* vp); // N . . . . // (Optional) [BETA] Get initial work area inset for the viewport (won't be covered by main menu bar, dockspace over viewport etc.). Default to (0,0),(0,0). 'safeAreaInsets' in iOS land, 'DisplayCutout' in Android land.
|
||||||
|
int (*Platform_CreateVkSurface)(ImGuiViewport* vp, ImU64 vk_inst, const void* vk_allocators, ImU64* out_vk_surface); // (Optional) For a Vulkan Renderer to call into Platform code (since the surface creation needs to tie them both).
|
||||||
|
|
||||||
|
// Renderer Backend functions (e.g. DirectX, OpenGL, Vulkan) ------------ Called by -----
|
||||||
|
void (*Renderer_CreateWindow)(ImGuiViewport* vp); // . . U . . // Create swap chain, frame buffers etc. (called after Platform_CreateWindow)
|
||||||
|
void (*Renderer_DestroyWindow)(ImGuiViewport* vp); // N . U . D // Destroy swap chain, frame buffers etc. (called before Platform_DestroyWindow)
|
||||||
|
void (*Renderer_SetWindowSize)(ImGuiViewport* vp, ImVec2 size); // . . U . . // Resize swap chain, frame buffers etc. (called after Platform_SetWindowSize)
|
||||||
|
void (*Renderer_RenderWindow)(ImGuiViewport* vp, void* render_arg); // . . . R . // (Optional) Clear framebuffer, setup render target, then render the viewport->DrawData. 'render_arg' is the value passed to RenderPlatformWindowsDefault().
|
||||||
|
void (*Renderer_SwapBuffers)(ImGuiViewport* vp, void* render_arg); // . . . R . // (Optional) Call Present/SwapBuffers. 'render_arg' is the value passed to RenderPlatformWindowsDefault().
|
||||||
|
|
||||||
|
// (Optional) Monitor list
|
||||||
|
// - Updated by: app/backend. Update every frame to dynamically support changing monitor or DPI configuration.
|
||||||
|
// - Used by: dear imgui to query DPI info, clamp popups/tooltips within same monitor and not have them straddle monitors.
|
||||||
|
ImVector<ImGuiPlatformMonitor> Monitors;
|
||||||
|
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
// Output - List of viewports to render into platform windows
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Viewports list (the list is updated by calling ImGui::EndFrame or ImGui::Render)
|
||||||
|
// (in the future we will attempt to organize this feature to remove the need for a "main viewport")
|
||||||
|
ImVector<ImGuiViewport*> Viewports; // Main viewports, followed by all secondary viewports.
|
||||||
|
};
|
||||||
|
|
||||||
|
// (Optional) This is required when enabling multi-viewport. Represent the bounds of each connected monitor/display and their DPI.
|
||||||
|
// We use this information for multiple DPI support + clamping the position of popups and tooltips so they don't straddle multiple monitors.
|
||||||
|
struct ImGuiPlatformMonitor
|
||||||
|
{
|
||||||
|
ImVec2 MainPos, MainSize; // Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
|
||||||
|
ImVec2 WorkPos, WorkSize; // Coordinates without task bars / side bars / menu bars. Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
|
||||||
|
float DpiScale; // 1.0f = 96 DPI
|
||||||
|
void* PlatformHandle; // Backend dependant data (e.g. HMONITOR, GLFWmonitor*, SDL Display Index, NSScreen*)
|
||||||
|
ImGuiPlatformMonitor() { MainPos = MainSize = WorkPos = WorkSize = ImVec2(0, 0); DpiScale = 1.0f; PlatformHandle = NULL; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// (Optional) Support for IME (Input Method Editor) via the platform_io.Platform_SetImeDataFn() function.
|
// (Optional) Support for IME (Input Method Editor) via the platform_io.Platform_SetImeDataFn() function.
|
||||||
|
314
imgui_demo.cpp
314
imgui_demo.cpp
@ -94,6 +94,7 @@ Index of this file:
|
|||||||
// [SECTION] Example App: Fullscreen window / ShowExampleAppFullscreen()
|
// [SECTION] Example App: Fullscreen window / ShowExampleAppFullscreen()
|
||||||
// [SECTION] Example App: Manipulating window titles / ShowExampleAppWindowTitles()
|
// [SECTION] Example App: Manipulating window titles / ShowExampleAppWindowTitles()
|
||||||
// [SECTION] Example App: Custom Rendering using ImDrawList API / ShowExampleAppCustomRendering()
|
// [SECTION] Example App: Custom Rendering using ImDrawList API / ShowExampleAppCustomRendering()
|
||||||
|
// [SECTION] Example App: Docking, DockSpace / ShowExampleAppDockSpace()
|
||||||
// [SECTION] Example App: Documents Handling / ShowExampleAppDocuments()
|
// [SECTION] Example App: Documents Handling / ShowExampleAppDocuments()
|
||||||
// [SECTION] Example App: Assets Browser / ShowExampleAppAssetsBrowser()
|
// [SECTION] Example App: Assets Browser / ShowExampleAppAssetsBrowser()
|
||||||
|
|
||||||
@ -207,6 +208,7 @@ static void ShowExampleAppMainMenuBar();
|
|||||||
static void ShowExampleAppAssetsBrowser(bool* p_open);
|
static void ShowExampleAppAssetsBrowser(bool* p_open);
|
||||||
static void ShowExampleAppConsole(bool* p_open);
|
static void ShowExampleAppConsole(bool* p_open);
|
||||||
static void ShowExampleAppCustomRendering(bool* p_open);
|
static void ShowExampleAppCustomRendering(bool* p_open);
|
||||||
|
static void ShowExampleAppDockSpace(bool* p_open);
|
||||||
static void ShowExampleAppDocuments(bool* p_open);
|
static void ShowExampleAppDocuments(bool* p_open);
|
||||||
static void ShowExampleAppLog(bool* p_open);
|
static void ShowExampleAppLog(bool* p_open);
|
||||||
static void ShowExampleAppLayout(bool* p_open);
|
static void ShowExampleAppLayout(bool* p_open);
|
||||||
@ -248,6 +250,16 @@ static void HelpMarker(const char* desc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ShowDockingDisabledMessage()
|
||||||
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
ImGui::Text("ERROR: Docking is not enabled! See Demo > Configuration.");
|
||||||
|
ImGui::Text("Set io.ConfigFlags |= ImGuiConfigFlags_DockingEnable in your code, or ");
|
||||||
|
ImGui::SameLine(0.0f, 0.0f);
|
||||||
|
if (ImGui::SmallButton("click here"))
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
|
||||||
|
}
|
||||||
|
|
||||||
// Helper to wire demo markers located in code to an interactive browser
|
// Helper to wire demo markers located in code to an interactive browser
|
||||||
typedef void (*ImGuiDemoMarkerCallback)(const char* file, int line, const char* section, void* user_data);
|
typedef void (*ImGuiDemoMarkerCallback)(const char* file, int line, const char* section, void* user_data);
|
||||||
extern ImGuiDemoMarkerCallback GImGuiDemoMarkerCallback;
|
extern ImGuiDemoMarkerCallback GImGuiDemoMarkerCallback;
|
||||||
@ -352,6 +364,7 @@ struct ImGuiDemoWindowData
|
|||||||
bool ShowAppConsole = false;
|
bool ShowAppConsole = false;
|
||||||
bool ShowAppCustomRendering = false;
|
bool ShowAppCustomRendering = false;
|
||||||
bool ShowAppDocuments = false;
|
bool ShowAppDocuments = false;
|
||||||
|
bool ShowAppDockSpace = false;
|
||||||
bool ShowAppLog = false;
|
bool ShowAppLog = false;
|
||||||
bool ShowAppLayout = false;
|
bool ShowAppLayout = false;
|
||||||
bool ShowAppPropertyEditor = false;
|
bool ShowAppPropertyEditor = false;
|
||||||
@ -390,7 +403,8 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||||||
|
|
||||||
// Examples Apps (accessible from the "Examples" menu)
|
// Examples Apps (accessible from the "Examples" menu)
|
||||||
if (demo_data.ShowMainMenuBar) { ShowExampleAppMainMenuBar(); }
|
if (demo_data.ShowMainMenuBar) { ShowExampleAppMainMenuBar(); }
|
||||||
if (demo_data.ShowAppDocuments) { ShowExampleAppDocuments(&demo_data.ShowAppDocuments); }
|
if (demo_data.ShowAppDockSpace) { ShowExampleAppDockSpace(&demo_data.ShowAppDockSpace); } // Important: Process the Docking app first, as explicit DockSpace() nodes needs to be submitted early (read comments near the DockSpace function)
|
||||||
|
if (demo_data.ShowAppDocuments) { ShowExampleAppDocuments(&demo_data.ShowAppDocuments); } // ...process the Document app next, as it may also use a DockSpace()
|
||||||
if (demo_data.ShowAppAssetsBrowser) { ShowExampleAppAssetsBrowser(&demo_data.ShowAppAssetsBrowser); }
|
if (demo_data.ShowAppAssetsBrowser) { ShowExampleAppAssetsBrowser(&demo_data.ShowAppAssetsBrowser); }
|
||||||
if (demo_data.ShowAppConsole) { ShowExampleAppConsole(&demo_data.ShowAppConsole); }
|
if (demo_data.ShowAppConsole) { ShowExampleAppConsole(&demo_data.ShowAppConsole); }
|
||||||
if (demo_data.ShowAppCustomRendering) { ShowExampleAppCustomRendering(&demo_data.ShowAppCustomRendering); }
|
if (demo_data.ShowAppCustomRendering) { ShowExampleAppCustomRendering(&demo_data.ShowAppCustomRendering); }
|
||||||
@ -427,6 +441,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||||||
static bool no_nav = false;
|
static bool no_nav = false;
|
||||||
static bool no_background = false;
|
static bool no_background = false;
|
||||||
static bool no_bring_to_front = false;
|
static bool no_bring_to_front = false;
|
||||||
|
static bool no_docking = false;
|
||||||
static bool unsaved_document = false;
|
static bool unsaved_document = false;
|
||||||
|
|
||||||
ImGuiWindowFlags window_flags = 0;
|
ImGuiWindowFlags window_flags = 0;
|
||||||
@ -439,6 +454,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||||||
if (no_nav) window_flags |= ImGuiWindowFlags_NoNav;
|
if (no_nav) window_flags |= ImGuiWindowFlags_NoNav;
|
||||||
if (no_background) window_flags |= ImGuiWindowFlags_NoBackground;
|
if (no_background) window_flags |= ImGuiWindowFlags_NoBackground;
|
||||||
if (no_bring_to_front) window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus;
|
if (no_bring_to_front) window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus;
|
||||||
|
if (no_docking) window_flags |= ImGuiWindowFlags_NoDocking;
|
||||||
if (unsaved_document) window_flags |= ImGuiWindowFlags_UnsavedDocument;
|
if (unsaved_document) window_flags |= ImGuiWindowFlags_UnsavedDocument;
|
||||||
if (no_close) p_open = NULL; // Don't pass our bool* to Begin
|
if (no_close) p_open = NULL; // Don't pass our bool* to Begin
|
||||||
|
|
||||||
@ -529,6 +545,44 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||||||
ImGui::Checkbox("io.MouseDrawCursor", &io.MouseDrawCursor);
|
ImGui::Checkbox("io.MouseDrawCursor", &io.MouseDrawCursor);
|
||||||
ImGui::SameLine(); HelpMarker("Instruct Dear ImGui to render a mouse cursor itself. Note that a mouse cursor rendered via your application GPU rendering path will feel more laggy than hardware cursor, but will be more in sync with your other visuals.\n\nSome desktop applications may use both kinds of cursors (e.g. enable software cursor only when resizing/dragging something).");
|
ImGui::SameLine(); HelpMarker("Instruct Dear ImGui to render a mouse cursor itself. Note that a mouse cursor rendered via your application GPU rendering path will feel more laggy than hardware cursor, but will be more in sync with your other visuals.\n\nSome desktop applications may use both kinds of cursors (e.g. enable software cursor only when resizing/dragging something).");
|
||||||
|
|
||||||
|
ImGui::SeparatorText("Docking");
|
||||||
|
ImGui::CheckboxFlags("io.ConfigFlags: DockingEnable", &io.ConfigFlags, ImGuiConfigFlags_DockingEnable);
|
||||||
|
ImGui::SameLine();
|
||||||
|
if (io.ConfigDockingWithShift)
|
||||||
|
HelpMarker("Drag from window title bar or their tab to dock/undock. Hold SHIFT to enable docking.\n\nDrag from window menu button (upper-left button) to undock an entire node (all windows).");
|
||||||
|
else
|
||||||
|
HelpMarker("Drag from window title bar or their tab to dock/undock. Hold SHIFT to disable docking.\n\nDrag from window menu button (upper-left button) to undock an entire node (all windows).");
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_DockingEnable)
|
||||||
|
{
|
||||||
|
ImGui::Indent();
|
||||||
|
ImGui::Checkbox("io.ConfigDockingNoSplit", &io.ConfigDockingNoSplit);
|
||||||
|
ImGui::SameLine(); HelpMarker("Simplified docking mode: disable window splitting, so docking is limited to merging multiple windows together into tab-bars.");
|
||||||
|
ImGui::Checkbox("io.ConfigDockingWithShift", &io.ConfigDockingWithShift);
|
||||||
|
ImGui::SameLine(); HelpMarker("Enable docking when holding Shift only (allow to drop in wider space, reduce visual noise)");
|
||||||
|
ImGui::Checkbox("io.ConfigDockingAlwaysTabBar", &io.ConfigDockingAlwaysTabBar);
|
||||||
|
ImGui::SameLine(); HelpMarker("Create a docking node and tab-bar on single floating windows.");
|
||||||
|
ImGui::Checkbox("io.ConfigDockingTransparentPayload", &io.ConfigDockingTransparentPayload);
|
||||||
|
ImGui::SameLine(); HelpMarker("Make window or viewport transparent when docking and only display docking boxes on the target viewport. Useful if rendering of multiple viewport cannot be synced. Best used with ConfigViewportsNoAutoMerge.");
|
||||||
|
ImGui::Unindent();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::SeparatorText("Multi-viewports");
|
||||||
|
ImGui::CheckboxFlags("io.ConfigFlags: ViewportsEnable", &io.ConfigFlags, ImGuiConfigFlags_ViewportsEnable);
|
||||||
|
ImGui::SameLine(); HelpMarker("[beta] Enable beta multi-viewports support. See ImGuiPlatformIO for details.");
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
ImGui::Indent();
|
||||||
|
ImGui::Checkbox("io.ConfigViewportsNoAutoMerge", &io.ConfigViewportsNoAutoMerge);
|
||||||
|
ImGui::SameLine(); HelpMarker("Set to make all floating imgui windows always create their own viewport. Otherwise, they are merged into the main host viewports when overlapping it.");
|
||||||
|
ImGui::Checkbox("io.ConfigViewportsNoTaskBarIcon", &io.ConfigViewportsNoTaskBarIcon);
|
||||||
|
ImGui::SameLine(); HelpMarker("Toggling this at runtime is normally unsupported (most platform backends won't refresh the task bar icon state right away).");
|
||||||
|
ImGui::Checkbox("io.ConfigViewportsNoDecoration", &io.ConfigViewportsNoDecoration);
|
||||||
|
ImGui::SameLine(); HelpMarker("Toggling this at runtime is normally unsupported (most platform backends won't refresh the decoration right away).");
|
||||||
|
ImGui::Checkbox("io.ConfigViewportsNoDefaultParent", &io.ConfigViewportsNoDefaultParent);
|
||||||
|
ImGui::SameLine(); HelpMarker("Toggling this at runtime is normally unsupported (most platform backends won't refresh the parenting right away).");
|
||||||
|
ImGui::Unindent();
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::SeparatorText("Widgets");
|
ImGui::SeparatorText("Widgets");
|
||||||
ImGui::Checkbox("io.ConfigInputTextCursorBlink", &io.ConfigInputTextCursorBlink);
|
ImGui::Checkbox("io.ConfigInputTextCursorBlink", &io.ConfigInputTextCursorBlink);
|
||||||
ImGui::SameLine(); HelpMarker("Enable blinking cursor (optional as some users consider it to be distracting).");
|
ImGui::SameLine(); HelpMarker("Enable blinking cursor (optional as some users consider it to be distracting).");
|
||||||
@ -568,12 +622,16 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||||||
"Those flags are set by the backends (imgui_impl_xxx files) to specify their capabilities.\n"
|
"Those flags are set by the backends (imgui_impl_xxx files) to specify their capabilities.\n"
|
||||||
"Here we expose them as read-only fields to avoid breaking interactions with your backend.");
|
"Here we expose them as read-only fields to avoid breaking interactions with your backend.");
|
||||||
|
|
||||||
|
// Make a local copy to avoid modifying actual backend flags.
|
||||||
// FIXME: Maybe we need a BeginReadonly() equivalent to keep label bright?
|
// FIXME: Maybe we need a BeginReadonly() equivalent to keep label bright?
|
||||||
ImGui::BeginDisabled();
|
ImGui::BeginDisabled();
|
||||||
ImGui::CheckboxFlags("io.BackendFlags: HasGamepad", &io.BackendFlags, ImGuiBackendFlags_HasGamepad);
|
ImGui::CheckboxFlags("io.BackendFlags: HasGamepad", &io.BackendFlags, ImGuiBackendFlags_HasGamepad);
|
||||||
ImGui::CheckboxFlags("io.BackendFlags: HasMouseCursors", &io.BackendFlags, ImGuiBackendFlags_HasMouseCursors);
|
ImGui::CheckboxFlags("io.BackendFlags: HasMouseCursors", &io.BackendFlags, ImGuiBackendFlags_HasMouseCursors);
|
||||||
ImGui::CheckboxFlags("io.BackendFlags: HasSetMousePos", &io.BackendFlags, ImGuiBackendFlags_HasSetMousePos);
|
ImGui::CheckboxFlags("io.BackendFlags: HasSetMousePos", &io.BackendFlags, ImGuiBackendFlags_HasSetMousePos);
|
||||||
ImGui::CheckboxFlags("io.BackendFlags: RendererHasVtxOffset", &io.BackendFlags, ImGuiBackendFlags_RendererHasVtxOffset);
|
ImGui::CheckboxFlags("io.BackendFlags: PlatformHasViewports", &io.BackendFlags, ImGuiBackendFlags_PlatformHasViewports);
|
||||||
|
ImGui::CheckboxFlags("io.BackendFlags: HasMouseHoveredViewport",&io.BackendFlags, ImGuiBackendFlags_HasMouseHoveredViewport);
|
||||||
|
ImGui::CheckboxFlags("io.BackendFlags: RendererHasVtxOffset", &io.BackendFlags, ImGuiBackendFlags_RendererHasVtxOffset);
|
||||||
|
ImGui::CheckboxFlags("io.BackendFlags: RendererHasViewports", &io.BackendFlags, ImGuiBackendFlags_RendererHasViewports);
|
||||||
ImGui::EndDisabled();
|
ImGui::EndDisabled();
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
@ -624,6 +682,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||||||
ImGui::TableNextColumn(); ImGui::Checkbox("No nav", &no_nav);
|
ImGui::TableNextColumn(); ImGui::Checkbox("No nav", &no_nav);
|
||||||
ImGui::TableNextColumn(); ImGui::Checkbox("No background", &no_background);
|
ImGui::TableNextColumn(); ImGui::Checkbox("No background", &no_background);
|
||||||
ImGui::TableNextColumn(); ImGui::Checkbox("No bring to front", &no_bring_to_front);
|
ImGui::TableNextColumn(); ImGui::Checkbox("No bring to front", &no_bring_to_front);
|
||||||
|
ImGui::TableNextColumn(); ImGui::Checkbox("No docking", &no_docking);
|
||||||
ImGui::TableNextColumn(); ImGui::Checkbox("Unsaved document", &unsaved_document);
|
ImGui::TableNextColumn(); ImGui::Checkbox("Unsaved document", &unsaved_document);
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
@ -666,6 +725,7 @@ static void ShowDemoWindowMenuBar(ImGuiDemoWindowData* demo_data)
|
|||||||
ImGui::MenuItem("Console", NULL, &demo_data->ShowAppConsole);
|
ImGui::MenuItem("Console", NULL, &demo_data->ShowAppConsole);
|
||||||
ImGui::MenuItem("Custom rendering", NULL, &demo_data->ShowAppCustomRendering);
|
ImGui::MenuItem("Custom rendering", NULL, &demo_data->ShowAppCustomRendering);
|
||||||
ImGui::MenuItem("Documents", NULL, &demo_data->ShowAppDocuments);
|
ImGui::MenuItem("Documents", NULL, &demo_data->ShowAppDocuments);
|
||||||
|
ImGui::MenuItem("Dockspace", NULL, &demo_data->ShowAppDockSpace);
|
||||||
ImGui::MenuItem("Log", NULL, &demo_data->ShowAppLog);
|
ImGui::MenuItem("Log", NULL, &demo_data->ShowAppLog);
|
||||||
ImGui::MenuItem("Property editor", NULL, &demo_data->ShowAppPropertyEditor);
|
ImGui::MenuItem("Property editor", NULL, &demo_data->ShowAppPropertyEditor);
|
||||||
ImGui::MenuItem("Simple layout", NULL, &demo_data->ShowAppLayout);
|
ImGui::MenuItem("Simple layout", NULL, &demo_data->ShowAppLayout);
|
||||||
@ -2776,18 +2836,24 @@ static void ShowDemoWindowWidgets(ImGuiDemoWindowData* demo_data)
|
|||||||
"IsWindowFocused() = %d\n"
|
"IsWindowFocused() = %d\n"
|
||||||
"IsWindowFocused(_ChildWindows) = %d\n"
|
"IsWindowFocused(_ChildWindows) = %d\n"
|
||||||
"IsWindowFocused(_ChildWindows|_NoPopupHierarchy) = %d\n"
|
"IsWindowFocused(_ChildWindows|_NoPopupHierarchy) = %d\n"
|
||||||
|
"IsWindowFocused(_ChildWindows|_DockHierarchy) = %d\n"
|
||||||
"IsWindowFocused(_ChildWindows|_RootWindow) = %d\n"
|
"IsWindowFocused(_ChildWindows|_RootWindow) = %d\n"
|
||||||
"IsWindowFocused(_ChildWindows|_RootWindow|_NoPopupHierarchy) = %d\n"
|
"IsWindowFocused(_ChildWindows|_RootWindow|_NoPopupHierarchy) = %d\n"
|
||||||
|
"IsWindowFocused(_ChildWindows|_RootWindow|_DockHierarchy) = %d\n"
|
||||||
"IsWindowFocused(_RootWindow) = %d\n"
|
"IsWindowFocused(_RootWindow) = %d\n"
|
||||||
"IsWindowFocused(_RootWindow|_NoPopupHierarchy) = %d\n"
|
"IsWindowFocused(_RootWindow|_NoPopupHierarchy) = %d\n"
|
||||||
|
"IsWindowFocused(_RootWindow|_DockHierarchy) = %d\n"
|
||||||
"IsWindowFocused(_AnyWindow) = %d\n",
|
"IsWindowFocused(_AnyWindow) = %d\n",
|
||||||
ImGui::IsWindowFocused(),
|
ImGui::IsWindowFocused(),
|
||||||
ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows),
|
ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows),
|
||||||
ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows | ImGuiFocusedFlags_NoPopupHierarchy),
|
ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows | ImGuiFocusedFlags_NoPopupHierarchy),
|
||||||
|
ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows | ImGuiFocusedFlags_DockHierarchy),
|
||||||
ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows | ImGuiFocusedFlags_RootWindow),
|
ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows | ImGuiFocusedFlags_RootWindow),
|
||||||
ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows | ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_NoPopupHierarchy),
|
ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows | ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_NoPopupHierarchy),
|
||||||
|
ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows | ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_DockHierarchy),
|
||||||
ImGui::IsWindowFocused(ImGuiFocusedFlags_RootWindow),
|
ImGui::IsWindowFocused(ImGuiFocusedFlags_RootWindow),
|
||||||
ImGui::IsWindowFocused(ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_NoPopupHierarchy),
|
ImGui::IsWindowFocused(ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_NoPopupHierarchy),
|
||||||
|
ImGui::IsWindowFocused(ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_DockHierarchy),
|
||||||
ImGui::IsWindowFocused(ImGuiFocusedFlags_AnyWindow));
|
ImGui::IsWindowFocused(ImGuiFocusedFlags_AnyWindow));
|
||||||
|
|
||||||
// Testing IsWindowHovered() function with its various flags.
|
// Testing IsWindowHovered() function with its various flags.
|
||||||
@ -2797,10 +2863,13 @@ static void ShowDemoWindowWidgets(ImGuiDemoWindowData* demo_data)
|
|||||||
"IsWindowHovered(_AllowWhenBlockedByActiveItem) = %d\n"
|
"IsWindowHovered(_AllowWhenBlockedByActiveItem) = %d\n"
|
||||||
"IsWindowHovered(_ChildWindows) = %d\n"
|
"IsWindowHovered(_ChildWindows) = %d\n"
|
||||||
"IsWindowHovered(_ChildWindows|_NoPopupHierarchy) = %d\n"
|
"IsWindowHovered(_ChildWindows|_NoPopupHierarchy) = %d\n"
|
||||||
|
"IsWindowHovered(_ChildWindows|_DockHierarchy) = %d\n"
|
||||||
"IsWindowHovered(_ChildWindows|_RootWindow) = %d\n"
|
"IsWindowHovered(_ChildWindows|_RootWindow) = %d\n"
|
||||||
"IsWindowHovered(_ChildWindows|_RootWindow|_NoPopupHierarchy) = %d\n"
|
"IsWindowHovered(_ChildWindows|_RootWindow|_NoPopupHierarchy) = %d\n"
|
||||||
|
"IsWindowHovered(_ChildWindows|_RootWindow|_DockHierarchy) = %d\n"
|
||||||
"IsWindowHovered(_RootWindow) = %d\n"
|
"IsWindowHovered(_RootWindow) = %d\n"
|
||||||
"IsWindowHovered(_RootWindow|_NoPopupHierarchy) = %d\n"
|
"IsWindowHovered(_RootWindow|_NoPopupHierarchy) = %d\n"
|
||||||
|
"IsWindowHovered(_RootWindow|_DockHierarchy) = %d\n"
|
||||||
"IsWindowHovered(_ChildWindows|_AllowWhenBlockedByPopup) = %d\n"
|
"IsWindowHovered(_ChildWindows|_AllowWhenBlockedByPopup) = %d\n"
|
||||||
"IsWindowHovered(_AnyWindow) = %d\n"
|
"IsWindowHovered(_AnyWindow) = %d\n"
|
||||||
"IsWindowHovered(_Stationary) = %d\n",
|
"IsWindowHovered(_Stationary) = %d\n",
|
||||||
@ -2809,10 +2878,13 @@ static void ShowDemoWindowWidgets(ImGuiDemoWindowData* demo_data)
|
|||||||
ImGui::IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem),
|
ImGui::IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem),
|
||||||
ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows),
|
ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows),
|
||||||
ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_NoPopupHierarchy),
|
ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_NoPopupHierarchy),
|
||||||
|
ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_DockHierarchy),
|
||||||
ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_RootWindow),
|
ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_RootWindow),
|
||||||
ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_NoPopupHierarchy),
|
ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_NoPopupHierarchy),
|
||||||
|
ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_DockHierarchy),
|
||||||
ImGui::IsWindowHovered(ImGuiHoveredFlags_RootWindow),
|
ImGui::IsWindowHovered(ImGuiHoveredFlags_RootWindow),
|
||||||
ImGui::IsWindowHovered(ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_NoPopupHierarchy),
|
ImGui::IsWindowHovered(ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_NoPopupHierarchy),
|
||||||
|
ImGui::IsWindowHovered(ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_DockHierarchy),
|
||||||
ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_AllowWhenBlockedByPopup),
|
ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_AllowWhenBlockedByPopup),
|
||||||
ImGui::IsWindowHovered(ImGuiHoveredFlags_AnyWindow),
|
ImGui::IsWindowHovered(ImGuiHoveredFlags_AnyWindow),
|
||||||
ImGui::IsWindowHovered(ImGuiHoveredFlags_Stationary));
|
ImGui::IsWindowHovered(ImGuiHoveredFlags_Stationary));
|
||||||
@ -2825,10 +2897,13 @@ static void ShowDemoWindowWidgets(ImGuiDemoWindowData* demo_data)
|
|||||||
|
|
||||||
// Calling IsItemHovered() after begin returns the hovered status of the title bar.
|
// Calling IsItemHovered() after begin returns the hovered status of the title bar.
|
||||||
// This is useful in particular if you want to create a context menu associated to the title bar of a window.
|
// This is useful in particular if you want to create a context menu associated to the title bar of a window.
|
||||||
|
// This will also work when docked into a Tab (the Tab replace the Title Bar and guarantee the same properties).
|
||||||
static bool test_window = false;
|
static bool test_window = false;
|
||||||
ImGui::Checkbox("Hovered/Active tests after Begin() for title bar testing", &test_window);
|
ImGui::Checkbox("Hovered/Active tests after Begin() for title bar testing", &test_window);
|
||||||
if (test_window)
|
if (test_window)
|
||||||
{
|
{
|
||||||
|
// FIXME-DOCK: This window cannot be docked within the ImGui Demo window, this will cause a feedback loop and get them stuck.
|
||||||
|
// Could we fix this through an ImGuiWindowClass feature? Or an API call to tag our parent as "don't skip items"?
|
||||||
ImGui::Begin("Title bar Hovered/Active tests", &test_window);
|
ImGui::Begin("Title bar Hovered/Active tests", &test_window);
|
||||||
if (ImGui::BeginPopupContextItem()) // <-- This is using IsItemHovered()
|
if (ImGui::BeginPopupContextItem()) // <-- This is using IsItemHovered()
|
||||||
{
|
{
|
||||||
@ -7702,6 +7777,12 @@ void ImGui::ShowAboutWindow(bool* p_open)
|
|||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
ImGui::Text("define: __EMSCRIPTEN__");
|
ImGui::Text("define: __EMSCRIPTEN__");
|
||||||
ImGui::Text("Emscripten: %d.%d.%d", __EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__);
|
ImGui::Text("Emscripten: %d.%d.%d", __EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__);
|
||||||
|
#endif
|
||||||
|
#ifdef IMGUI_HAS_VIEWPORT
|
||||||
|
ImGui::Text("define: IMGUI_HAS_VIEWPORT");
|
||||||
|
#endif
|
||||||
|
#ifdef IMGUI_HAS_DOCK
|
||||||
|
ImGui::Text("define: IMGUI_HAS_DOCK");
|
||||||
#endif
|
#endif
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
ImGui::Text("io.BackendPlatformName: %s", io.BackendPlatformName ? io.BackendPlatformName : "NULL");
|
ImGui::Text("io.BackendPlatformName: %s", io.BackendPlatformName ? io.BackendPlatformName : "NULL");
|
||||||
@ -7713,7 +7794,19 @@ void ImGui::ShowAboutWindow(bool* p_open)
|
|||||||
if (io.ConfigFlags & ImGuiConfigFlags_NavNoCaptureKeyboard) ImGui::Text(" NavNoCaptureKeyboard");
|
if (io.ConfigFlags & ImGuiConfigFlags_NavNoCaptureKeyboard) ImGui::Text(" NavNoCaptureKeyboard");
|
||||||
if (io.ConfigFlags & ImGuiConfigFlags_NoMouse) ImGui::Text(" NoMouse");
|
if (io.ConfigFlags & ImGuiConfigFlags_NoMouse) ImGui::Text(" NoMouse");
|
||||||
if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange) ImGui::Text(" NoMouseCursorChange");
|
if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange) ImGui::Text(" NoMouseCursorChange");
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_DockingEnable) ImGui::Text(" DockingEnable");
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) ImGui::Text(" ViewportsEnable");
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_DpiEnableScaleViewports) ImGui::Text(" DpiEnableScaleViewports");
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_DpiEnableScaleFonts) ImGui::Text(" DpiEnableScaleFonts");
|
||||||
if (io.MouseDrawCursor) ImGui::Text("io.MouseDrawCursor");
|
if (io.MouseDrawCursor) ImGui::Text("io.MouseDrawCursor");
|
||||||
|
if (io.ConfigViewportsNoAutoMerge) ImGui::Text("io.ConfigViewportsNoAutoMerge");
|
||||||
|
if (io.ConfigViewportsNoTaskBarIcon) ImGui::Text("io.ConfigViewportsNoTaskBarIcon");
|
||||||
|
if (io.ConfigViewportsNoDecoration) ImGui::Text("io.ConfigViewportsNoDecoration");
|
||||||
|
if (io.ConfigViewportsNoDefaultParent) ImGui::Text("io.ConfigViewportsNoDefaultParent");
|
||||||
|
if (io.ConfigDockingNoSplit) ImGui::Text("io.ConfigDockingNoSplit");
|
||||||
|
if (io.ConfigDockingWithShift) ImGui::Text("io.ConfigDockingWithShift");
|
||||||
|
if (io.ConfigDockingAlwaysTabBar) ImGui::Text("io.ConfigDockingAlwaysTabBar");
|
||||||
|
if (io.ConfigDockingTransparentPayload) ImGui::Text("io.ConfigDockingTransparentPayload");
|
||||||
if (io.ConfigMacOSXBehaviors) ImGui::Text("io.ConfigMacOSXBehaviors");
|
if (io.ConfigMacOSXBehaviors) ImGui::Text("io.ConfigMacOSXBehaviors");
|
||||||
if (io.ConfigInputTextCursorBlink) ImGui::Text("io.ConfigInputTextCursorBlink");
|
if (io.ConfigInputTextCursorBlink) ImGui::Text("io.ConfigInputTextCursorBlink");
|
||||||
if (io.ConfigWindowsResizeFromEdges) ImGui::Text("io.ConfigWindowsResizeFromEdges");
|
if (io.ConfigWindowsResizeFromEdges) ImGui::Text("io.ConfigWindowsResizeFromEdges");
|
||||||
@ -7723,7 +7816,10 @@ void ImGui::ShowAboutWindow(bool* p_open)
|
|||||||
if (io.BackendFlags & ImGuiBackendFlags_HasGamepad) ImGui::Text(" HasGamepad");
|
if (io.BackendFlags & ImGuiBackendFlags_HasGamepad) ImGui::Text(" HasGamepad");
|
||||||
if (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) ImGui::Text(" HasMouseCursors");
|
if (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) ImGui::Text(" HasMouseCursors");
|
||||||
if (io.BackendFlags & ImGuiBackendFlags_HasSetMousePos) ImGui::Text(" HasSetMousePos");
|
if (io.BackendFlags & ImGuiBackendFlags_HasSetMousePos) ImGui::Text(" HasSetMousePos");
|
||||||
|
if (io.BackendFlags & ImGuiBackendFlags_PlatformHasViewports) ImGui::Text(" PlatformHasViewports");
|
||||||
|
if (io.BackendFlags & ImGuiBackendFlags_HasMouseHoveredViewport)ImGui::Text(" HasMouseHoveredViewport");
|
||||||
if (io.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset) ImGui::Text(" RendererHasVtxOffset");
|
if (io.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset) ImGui::Text(" RendererHasVtxOffset");
|
||||||
|
if (io.BackendFlags & ImGuiBackendFlags_RendererHasViewports) ImGui::Text(" RendererHasViewports");
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
ImGui::Text("io.Fonts: %d fonts, Flags: 0x%08X, TexSize: %d,%d", io.Fonts->Fonts.Size, io.Fonts->Flags, io.Fonts->TexWidth, io.Fonts->TexHeight);
|
ImGui::Text("io.Fonts: %d fonts, Flags: 0x%08X, TexSize: %d,%d", io.Fonts->Fonts.Size, io.Fonts->Flags, io.Fonts->TexWidth, io.Fonts->TexHeight);
|
||||||
ImGui::Text("io.DisplaySize: %.2f,%.2f", io.DisplaySize.x, io.DisplaySize.y);
|
ImGui::Text("io.DisplaySize: %.2f,%.2f", io.DisplaySize.x, io.DisplaySize.y);
|
||||||
@ -7899,6 +7995,9 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
|||||||
ImGui::SliderFloat2("SeparatorTextPadding", (float*)&style.SeparatorTextPadding, 0.0f, 40.0f, "%.0f");
|
ImGui::SliderFloat2("SeparatorTextPadding", (float*)&style.SeparatorTextPadding, 0.0f, 40.0f, "%.0f");
|
||||||
ImGui::SliderFloat("LogSliderDeadzone", &style.LogSliderDeadzone, 0.0f, 12.0f, "%.0f");
|
ImGui::SliderFloat("LogSliderDeadzone", &style.LogSliderDeadzone, 0.0f, 12.0f, "%.0f");
|
||||||
|
|
||||||
|
ImGui::SeparatorText("Docking");
|
||||||
|
ImGui::SliderFloat("DockingSplitterSize", &style.DockingSeparatorSize, 0.0f, 12.0f, "%.0f");
|
||||||
|
|
||||||
ImGui::SeparatorText("Tooltips");
|
ImGui::SeparatorText("Tooltips");
|
||||||
for (int n = 0; n < 2; n++)
|
for (int n = 0; n < 2; n++)
|
||||||
if (ImGui::TreeNodeEx(n == 0 ? "HoverFlagsForTooltipMouse" : "HoverFlagsForTooltipNav"))
|
if (ImGui::TreeNodeEx(n == 0 ? "HoverFlagsForTooltipMouse" : "HoverFlagsForTooltipNav"))
|
||||||
@ -9145,6 +9244,8 @@ static void ShowExampleAppConstrainedResize(bool* p_open)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
ImGui::Text("(Hold SHIFT to display a dummy viewport)");
|
ImGui::Text("(Hold SHIFT to display a dummy viewport)");
|
||||||
|
if (ImGui::IsWindowDocked())
|
||||||
|
ImGui::Text("Warning: Sizing Constraints won't work if the window is docked!");
|
||||||
if (ImGui::Button("Set 200x200")) { ImGui::SetWindowSize(ImVec2(200, 200)); } ImGui::SameLine();
|
if (ImGui::Button("Set 200x200")) { ImGui::SetWindowSize(ImVec2(200, 200)); } ImGui::SameLine();
|
||||||
if (ImGui::Button("Set 500x500")) { ImGui::SetWindowSize(ImVec2(500, 500)); } ImGui::SameLine();
|
if (ImGui::Button("Set 500x500")) { ImGui::SetWindowSize(ImVec2(500, 500)); } ImGui::SameLine();
|
||||||
if (ImGui::Button("Set 800x200")) { ImGui::SetWindowSize(ImVec2(800, 200)); }
|
if (ImGui::Button("Set 800x200")) { ImGui::SetWindowSize(ImVec2(800, 200)); }
|
||||||
@ -9171,7 +9272,7 @@ static void ShowExampleAppSimpleOverlay(bool* p_open)
|
|||||||
{
|
{
|
||||||
static int location = 0;
|
static int location = 0;
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav;
|
ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav;
|
||||||
if (location >= 0)
|
if (location >= 0)
|
||||||
{
|
{
|
||||||
const float PAD = 10.0f;
|
const float PAD = 10.0f;
|
||||||
@ -9184,6 +9285,7 @@ static void ShowExampleAppSimpleOverlay(bool* p_open)
|
|||||||
window_pos_pivot.x = (location & 1) ? 1.0f : 0.0f;
|
window_pos_pivot.x = (location & 1) ? 1.0f : 0.0f;
|
||||||
window_pos_pivot.y = (location & 2) ? 1.0f : 0.0f;
|
window_pos_pivot.y = (location & 2) ? 1.0f : 0.0f;
|
||||||
ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot);
|
ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot);
|
||||||
|
ImGui::SetNextWindowViewport(viewport->ID);
|
||||||
window_flags |= ImGuiWindowFlags_NoMove;
|
window_flags |= ImGuiWindowFlags_NoMove;
|
||||||
}
|
}
|
||||||
else if (location == -2)
|
else if (location == -2)
|
||||||
@ -9603,6 +9705,134 @@ static void ShowExampleAppCustomRendering(bool* p_open)
|
|||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// [SECTION] Example App: Docking, DockSpace / ShowExampleAppDockSpace()
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Demonstrate using DockSpace() to create an explicit docking node within an existing window.
|
||||||
|
// Note: You can use most Docking facilities without calling any API. You DO NOT need to call DockSpace() to use Docking!
|
||||||
|
// - Drag from window title bar or their tab to dock/undock. Hold SHIFT to disable docking.
|
||||||
|
// - Drag from window menu button (upper-left button) to undock an entire node (all windows).
|
||||||
|
// - When io.ConfigDockingWithShift == true, you instead need to hold SHIFT to enable docking.
|
||||||
|
// About dockspaces:
|
||||||
|
// - Use DockSpace() to create an explicit dock node _within_ an existing window.
|
||||||
|
// - Use DockSpaceOverViewport() to create an explicit dock node covering the screen or a specific viewport.
|
||||||
|
// This is often used with ImGuiDockNodeFlags_PassthruCentralNode.
|
||||||
|
// - Important: Dockspaces need to be submitted _before_ any window they can host. Submit it early in your frame! (*)
|
||||||
|
// - Important: Dockspaces need to be kept alive if hidden, otherwise windows docked into it will be undocked.
|
||||||
|
// e.g. if you have multiple tabs with a dockspace inside each tab: submit the non-visible dockspaces with ImGuiDockNodeFlags_KeepAliveOnly.
|
||||||
|
// (*) because of this constraint, the implicit \"Debug\" window can not be docked into an explicit DockSpace() node,
|
||||||
|
// because that window is submitted as part of the part of the NewFrame() call. An easy workaround is that you can create
|
||||||
|
// your own implicit "Debug##2" window after calling DockSpace() and leave it in the window stack for anyone to use.
|
||||||
|
void ShowExampleAppDockSpace(bool* p_open)
|
||||||
|
{
|
||||||
|
// READ THIS !!!
|
||||||
|
// TL;DR; this demo is more complicated than what most users you would normally use.
|
||||||
|
// If we remove all options we are showcasing, this demo would become:
|
||||||
|
// void ShowExampleAppDockSpace()
|
||||||
|
// {
|
||||||
|
// ImGui::DockSpaceOverViewport(0, ImGui::GetMainViewport());
|
||||||
|
// }
|
||||||
|
// In most cases you should be able to just call DockSpaceOverViewport() and ignore all the code below!
|
||||||
|
// In this specific demo, we are not using DockSpaceOverViewport() because:
|
||||||
|
// - (1) we allow the host window to be floating/moveable instead of filling the viewport (when opt_fullscreen == false)
|
||||||
|
// - (2) we allow the host window to have padding (when opt_padding == true)
|
||||||
|
// - (3) we expose many flags and need a way to have them visible.
|
||||||
|
// - (4) we have a local menu bar in the host window (vs. you could use BeginMainMenuBar() + DockSpaceOverViewport()
|
||||||
|
// in your code, but we don't here because we allow the window to be floating)
|
||||||
|
|
||||||
|
static bool opt_fullscreen = true;
|
||||||
|
static bool opt_padding = false;
|
||||||
|
static ImGuiDockNodeFlags dockspace_flags = ImGuiDockNodeFlags_None;
|
||||||
|
|
||||||
|
// We are using the ImGuiWindowFlags_NoDocking flag to make the parent window not dockable into,
|
||||||
|
// because it would be confusing to have two docking targets within each others.
|
||||||
|
ImGuiWindowFlags window_flags = ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking;
|
||||||
|
if (opt_fullscreen)
|
||||||
|
{
|
||||||
|
const ImGuiViewport* viewport = ImGui::GetMainViewport();
|
||||||
|
ImGui::SetNextWindowPos(viewport->WorkPos);
|
||||||
|
ImGui::SetNextWindowSize(viewport->WorkSize);
|
||||||
|
ImGui::SetNextWindowViewport(viewport->ID);
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
|
||||||
|
window_flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove;
|
||||||
|
window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dockspace_flags &= ~ImGuiDockNodeFlags_PassthruCentralNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
// When using ImGuiDockNodeFlags_PassthruCentralNode, DockSpace() will render our background
|
||||||
|
// and handle the pass-thru hole, so we ask Begin() to not render a background.
|
||||||
|
if (dockspace_flags & ImGuiDockNodeFlags_PassthruCentralNode)
|
||||||
|
window_flags |= ImGuiWindowFlags_NoBackground;
|
||||||
|
|
||||||
|
// Important: note that we proceed even if Begin() returns false (aka window is collapsed).
|
||||||
|
// This is because we want to keep our DockSpace() active. If a DockSpace() is inactive,
|
||||||
|
// all active windows docked into it will lose their parent and become undocked.
|
||||||
|
// We cannot preserve the docking relationship between an active window and an inactive docking, otherwise
|
||||||
|
// any change of dockspace/settings would lead to windows being stuck in limbo and never being visible.
|
||||||
|
if (!opt_padding)
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
|
||||||
|
ImGui::Begin("DockSpace Demo", p_open, window_flags);
|
||||||
|
if (!opt_padding)
|
||||||
|
ImGui::PopStyleVar();
|
||||||
|
|
||||||
|
if (opt_fullscreen)
|
||||||
|
ImGui::PopStyleVar(2);
|
||||||
|
|
||||||
|
// Submit the DockSpace
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_DockingEnable)
|
||||||
|
{
|
||||||
|
ImGuiID dockspace_id = ImGui::GetID("MyDockSpace");
|
||||||
|
ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ShowDockingDisabledMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui::BeginMenuBar())
|
||||||
|
{
|
||||||
|
if (ImGui::BeginMenu("Options"))
|
||||||
|
{
|
||||||
|
// Disabling fullscreen would allow the window to be moved to the front of other windows,
|
||||||
|
// which we can't undo at the moment without finer window depth/z control.
|
||||||
|
ImGui::MenuItem("Fullscreen", NULL, &opt_fullscreen);
|
||||||
|
ImGui::MenuItem("Padding", NULL, &opt_padding);
|
||||||
|
ImGui::Separator();
|
||||||
|
|
||||||
|
if (ImGui::MenuItem("Flag: NoDockingOverCentralNode", "", (dockspace_flags & ImGuiDockNodeFlags_NoDockingOverCentralNode) != 0)) { dockspace_flags ^= ImGuiDockNodeFlags_NoDockingOverCentralNode; }
|
||||||
|
if (ImGui::MenuItem("Flag: NoDockingSplit", "", (dockspace_flags & ImGuiDockNodeFlags_NoDockingSplit) != 0)) { dockspace_flags ^= ImGuiDockNodeFlags_NoDockingSplit; }
|
||||||
|
if (ImGui::MenuItem("Flag: NoUndocking", "", (dockspace_flags & ImGuiDockNodeFlags_NoUndocking) != 0)) { dockspace_flags ^= ImGuiDockNodeFlags_NoUndocking; }
|
||||||
|
if (ImGui::MenuItem("Flag: NoResize", "", (dockspace_flags & ImGuiDockNodeFlags_NoResize) != 0)) { dockspace_flags ^= ImGuiDockNodeFlags_NoResize; }
|
||||||
|
if (ImGui::MenuItem("Flag: AutoHideTabBar", "", (dockspace_flags & ImGuiDockNodeFlags_AutoHideTabBar) != 0)) { dockspace_flags ^= ImGuiDockNodeFlags_AutoHideTabBar; }
|
||||||
|
if (ImGui::MenuItem("Flag: PassthruCentralNode", "", (dockspace_flags & ImGuiDockNodeFlags_PassthruCentralNode) != 0, opt_fullscreen)) { dockspace_flags ^= ImGuiDockNodeFlags_PassthruCentralNode; }
|
||||||
|
ImGui::Separator();
|
||||||
|
|
||||||
|
if (ImGui::MenuItem("Close", NULL, false, p_open != NULL))
|
||||||
|
*p_open = false;
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
|
HelpMarker(
|
||||||
|
"When docking is enabled, you can ALWAYS dock MOST window into another! Try it now!" "\n"
|
||||||
|
"- Drag from window title bar or their tab to dock/undock." "\n"
|
||||||
|
"- Drag from window menu button (upper-left button) to undock an entire node (all windows)." "\n"
|
||||||
|
"- Hold SHIFT to disable docking (if io.ConfigDockingWithShift == false, default)" "\n"
|
||||||
|
"- Hold SHIFT to enable docking (if io.ConfigDockingWithShift == true)" "\n"
|
||||||
|
"This demo app has nothing to do with enabling docking!" "\n\n"
|
||||||
|
"This demo app only demonstrate the use of ImGui::DockSpace() which allows you to manually create a docking node _within_ another window." "\n\n"
|
||||||
|
"Read comments in ShowExampleAppDockSpace() for more details.");
|
||||||
|
|
||||||
|
ImGui::EndMenuBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Example App: Documents Handling / ShowExampleAppDocuments()
|
// [SECTION] Example App: Documents Handling / ShowExampleAppDocuments()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -9728,11 +9958,25 @@ void ShowExampleAppDocuments(bool* p_open)
|
|||||||
static ExampleAppDocuments app;
|
static ExampleAppDocuments app;
|
||||||
|
|
||||||
// Options
|
// Options
|
||||||
|
enum Target
|
||||||
|
{
|
||||||
|
Target_None,
|
||||||
|
Target_Tab, // Create documents as local tab into a local tab bar
|
||||||
|
Target_DockSpaceAndWindow // Create documents as regular windows, and create an embedded dockspace
|
||||||
|
};
|
||||||
|
static Target opt_target = Target_Tab;
|
||||||
static bool opt_reorderable = true;
|
static bool opt_reorderable = true;
|
||||||
static ImGuiTabBarFlags opt_fitting_flags = ImGuiTabBarFlags_FittingPolicyDefault_;
|
static ImGuiTabBarFlags opt_fitting_flags = ImGuiTabBarFlags_FittingPolicyDefault_;
|
||||||
|
|
||||||
|
// When (opt_target == Target_DockSpaceAndWindow) there is the possibily that one of our child Document window (e.g. "Eggplant")
|
||||||
|
// that we emit gets docked into the same spot as the parent window ("Example: Documents").
|
||||||
|
// This would create a problematic feedback loop because selecting the "Eggplant" tab would make the "Example: Documents" tab
|
||||||
|
// not visible, which in turn would stop submitting the "Eggplant" window.
|
||||||
|
// We avoid this problem by submitting our documents window even if our parent window is not currently visible.
|
||||||
|
// Another solution may be to make the "Example: Documents" window use the ImGuiWindowFlags_NoDocking.
|
||||||
|
|
||||||
bool window_contents_visible = ImGui::Begin("Example: Documents", p_open, ImGuiWindowFlags_MenuBar);
|
bool window_contents_visible = ImGui::Begin("Example: Documents", p_open, ImGuiWindowFlags_MenuBar);
|
||||||
if (!window_contents_visible)
|
if (!window_contents_visible && opt_target != Target_DockSpaceAndWindow)
|
||||||
{
|
{
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
return;
|
return;
|
||||||
@ -9776,6 +10020,12 @@ void ShowExampleAppDocuments(bool* p_open)
|
|||||||
doc.DoForceClose();
|
doc.DoForceClose();
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
|
ImGui::PushItemWidth(ImGui::GetFontSize() * 12);
|
||||||
|
ImGui::Combo("Output", (int*)&opt_target, "None\0TabBar+Tabs\0DockSpace+Window\0");
|
||||||
|
ImGui::PopItemWidth();
|
||||||
|
bool redock_all = false;
|
||||||
|
if (opt_target == Target_Tab) { ImGui::SameLine(); ImGui::Checkbox("Reorderable Tabs", &opt_reorderable); }
|
||||||
|
if (opt_target == Target_DockSpaceAndWindow) { ImGui::SameLine(); redock_all = ImGui::Button("Redock all"); }
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
@ -9789,7 +10039,8 @@ void ShowExampleAppDocuments(bool* p_open)
|
|||||||
// hole for one-frame, both in the tab-bar and in tab-contents when closing a tab/window.
|
// hole for one-frame, both in the tab-bar and in tab-contents when closing a tab/window.
|
||||||
// The rarely used SetTabItemClosed() function is a way to notify of programmatic closure to avoid the one-frame hole.
|
// The rarely used SetTabItemClosed() function is a way to notify of programmatic closure to avoid the one-frame hole.
|
||||||
|
|
||||||
// Submit Tab Bar and Tabs
|
// Tabs
|
||||||
|
if (opt_target == Target_Tab)
|
||||||
{
|
{
|
||||||
ImGuiTabBarFlags tab_bar_flags = (opt_fitting_flags) | (opt_reorderable ? ImGuiTabBarFlags_Reorderable : 0);
|
ImGuiTabBarFlags tab_bar_flags = (opt_fitting_flags) | (opt_reorderable ? ImGuiTabBarFlags_Reorderable : 0);
|
||||||
tab_bar_flags |= ImGuiTabBarFlags_DrawSelectedOverline;
|
tab_bar_flags |= ImGuiTabBarFlags_DrawSelectedOverline;
|
||||||
@ -9832,6 +10083,53 @@ void ShowExampleAppDocuments(bool* p_open)
|
|||||||
ImGui::EndTabBar();
|
ImGui::EndTabBar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (opt_target == Target_DockSpaceAndWindow)
|
||||||
|
{
|
||||||
|
if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_DockingEnable)
|
||||||
|
{
|
||||||
|
app.NotifyOfDocumentsClosedElsewhere();
|
||||||
|
|
||||||
|
// Create a DockSpace node where any window can be docked
|
||||||
|
ImGuiID dockspace_id = ImGui::GetID("MyDockSpace");
|
||||||
|
ImGui::DockSpace(dockspace_id);
|
||||||
|
|
||||||
|
// Create Windows
|
||||||
|
for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
|
||||||
|
{
|
||||||
|
MyDocument* doc = &app.Documents[doc_n];
|
||||||
|
if (!doc->Open)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
ImGui::SetNextWindowDockID(dockspace_id, redock_all ? ImGuiCond_Always : ImGuiCond_FirstUseEver);
|
||||||
|
ImGuiWindowFlags window_flags = (doc->Dirty ? ImGuiWindowFlags_UnsavedDocument : 0);
|
||||||
|
bool visible = ImGui::Begin(doc->Name, &doc->Open, window_flags);
|
||||||
|
|
||||||
|
// Cancel attempt to close when unsaved add to save queue so we can display a popup.
|
||||||
|
if (!doc->Open && doc->Dirty)
|
||||||
|
{
|
||||||
|
doc->Open = true;
|
||||||
|
app.CloseQueue.push_back(doc);
|
||||||
|
}
|
||||||
|
|
||||||
|
app.DisplayDocContextMenu(doc);
|
||||||
|
if (visible)
|
||||||
|
app.DisplayDocContents(doc);
|
||||||
|
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ShowDockingDisabledMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Early out other contents
|
||||||
|
if (!window_contents_visible)
|
||||||
|
{
|
||||||
|
ImGui::End();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Display renaming UI
|
// Display renaming UI
|
||||||
if (app.RenamingDoc != NULL)
|
if (app.RenamingDoc != NULL)
|
||||||
|
@ -218,6 +218,8 @@ void ImGui::StyleColorsDark(ImGuiStyle* dst)
|
|||||||
colors[ImGuiCol_TabDimmed] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
|
colors[ImGuiCol_TabDimmed] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
|
||||||
colors[ImGuiCol_TabDimmedSelected] = ImLerp(colors[ImGuiCol_TabSelected], colors[ImGuiCol_TitleBg], 0.40f);
|
colors[ImGuiCol_TabDimmedSelected] = ImLerp(colors[ImGuiCol_TabSelected], colors[ImGuiCol_TitleBg], 0.40f);
|
||||||
colors[ImGuiCol_TabDimmedSelectedOverline] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f);
|
colors[ImGuiCol_TabDimmedSelectedOverline] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f);
|
||||||
|
colors[ImGuiCol_DockingPreview] = colors[ImGuiCol_HeaderActive] * ImVec4(1.0f, 1.0f, 1.0f, 0.7f);
|
||||||
|
colors[ImGuiCol_DockingEmptyBg] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
|
||||||
colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f);
|
colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f);
|
||||||
colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f);
|
colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f);
|
||||||
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
||||||
@ -281,6 +283,8 @@ void ImGui::StyleColorsClassic(ImGuiStyle* dst)
|
|||||||
colors[ImGuiCol_TabDimmed] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
|
colors[ImGuiCol_TabDimmed] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
|
||||||
colors[ImGuiCol_TabDimmedSelected] = ImLerp(colors[ImGuiCol_TabSelected], colors[ImGuiCol_TitleBg], 0.40f);
|
colors[ImGuiCol_TabDimmedSelected] = ImLerp(colors[ImGuiCol_TabSelected], colors[ImGuiCol_TitleBg], 0.40f);
|
||||||
colors[ImGuiCol_TabDimmedSelectedOverline] = colors[ImGuiCol_HeaderActive];
|
colors[ImGuiCol_TabDimmedSelectedOverline] = colors[ImGuiCol_HeaderActive];
|
||||||
|
colors[ImGuiCol_DockingPreview] = colors[ImGuiCol_Header] * ImVec4(1.0f, 1.0f, 1.0f, 0.7f);
|
||||||
|
colors[ImGuiCol_DockingEmptyBg] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
|
||||||
colors[ImGuiCol_PlotLines] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
|
colors[ImGuiCol_PlotLines] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
|
||||||
colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
||||||
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
||||||
@ -345,6 +349,8 @@ void ImGui::StyleColorsLight(ImGuiStyle* dst)
|
|||||||
colors[ImGuiCol_TabDimmed] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
|
colors[ImGuiCol_TabDimmed] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
|
||||||
colors[ImGuiCol_TabDimmedSelected] = ImLerp(colors[ImGuiCol_TabSelected], colors[ImGuiCol_TitleBg], 0.40f);
|
colors[ImGuiCol_TabDimmedSelected] = ImLerp(colors[ImGuiCol_TabSelected], colors[ImGuiCol_TitleBg], 0.40f);
|
||||||
colors[ImGuiCol_TabDimmedSelectedOverline] = ImVec4(0.26f, 0.59f, 1.00f, 1.00f);
|
colors[ImGuiCol_TabDimmedSelectedOverline] = ImVec4(0.26f, 0.59f, 1.00f, 1.00f);
|
||||||
|
colors[ImGuiCol_DockingPreview] = colors[ImGuiCol_Header] * ImVec4(1.0f, 1.0f, 1.0f, 0.7f);
|
||||||
|
colors[ImGuiCol_DockingEmptyBg] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
|
||||||
colors[ImGuiCol_PlotLines] = ImVec4(0.39f, 0.39f, 0.39f, 1.00f);
|
colors[ImGuiCol_PlotLines] = ImVec4(0.39f, 0.39f, 0.39f, 1.00f);
|
||||||
colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f);
|
colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f);
|
||||||
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
||||||
@ -4213,6 +4219,7 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, const ImVec2& pos, Im
|
|||||||
// - RenderArrow()
|
// - RenderArrow()
|
||||||
// - RenderBullet()
|
// - RenderBullet()
|
||||||
// - RenderCheckMark()
|
// - RenderCheckMark()
|
||||||
|
// - RenderArrowDockMenu()
|
||||||
// - RenderArrowPointingAt()
|
// - RenderArrowPointingAt()
|
||||||
// - RenderRectFilledRangeH()
|
// - RenderRectFilledRangeH()
|
||||||
// - RenderRectFilledWithHole()
|
// - RenderRectFilledWithHole()
|
||||||
@ -4287,6 +4294,14 @@ void ImGui::RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is less wide than RenderArrow() and we use in dock nodes instead of the regular RenderArrow() to denote a change of functionality,
|
||||||
|
// and because the saved space means that the left-most tab label can stay at exactly the same position as the label of a loose window.
|
||||||
|
void ImGui::RenderArrowDockMenu(ImDrawList* draw_list, ImVec2 p_min, float sz, ImU32 col)
|
||||||
|
{
|
||||||
|
draw_list->AddRectFilled(p_min + ImVec2(sz * 0.20f, sz * 0.15f), p_min + ImVec2(sz * 0.80f, sz * 0.30f), col);
|
||||||
|
RenderArrowPointingAt(draw_list, p_min + ImVec2(sz * 0.50f, sz * 0.85f), ImVec2(sz * 0.30f, sz * 0.40f), ImGuiDir_Down, col);
|
||||||
|
}
|
||||||
|
|
||||||
static inline float ImAcos01(float x)
|
static inline float ImAcos01(float x)
|
||||||
{
|
{
|
||||||
if (x <= 0.0f) return IM_PI * 0.5f;
|
if (x <= 0.0f) return IM_PI * 0.5f;
|
||||||
@ -4372,6 +4387,17 @@ void ImGui::RenderRectFilledWithHole(ImDrawList* draw_list, const ImRect& outer,
|
|||||||
if (fill_R && fill_D) draw_list->AddRectFilled(ImVec2(inner.Max.x, inner.Max.y), ImVec2(outer.Max.x, outer.Max.y), col, rounding, ImDrawFlags_RoundCornersBottomRight);
|
if (fill_R && fill_D) draw_list->AddRectFilled(ImVec2(inner.Max.x, inner.Max.y), ImVec2(outer.Max.x, outer.Max.y), col, rounding, ImDrawFlags_RoundCornersBottomRight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImDrawFlags ImGui::CalcRoundingFlagsForRectInRect(const ImRect& r_in, const ImRect& r_outer, float threshold)
|
||||||
|
{
|
||||||
|
bool round_l = r_in.Min.x <= r_outer.Min.x + threshold;
|
||||||
|
bool round_r = r_in.Max.x >= r_outer.Max.x - threshold;
|
||||||
|
bool round_t = r_in.Min.y <= r_outer.Min.y + threshold;
|
||||||
|
bool round_b = r_in.Max.y >= r_outer.Max.y - threshold;
|
||||||
|
return ImDrawFlags_RoundCornersNone
|
||||||
|
| ((round_t && round_l) ? ImDrawFlags_RoundCornersTopLeft : 0) | ((round_t && round_r) ? ImDrawFlags_RoundCornersTopRight : 0)
|
||||||
|
| ((round_b && round_l) ? ImDrawFlags_RoundCornersBottomLeft : 0) | ((round_b && round_r) ? ImDrawFlags_RoundCornersBottomRight : 0);
|
||||||
|
}
|
||||||
|
|
||||||
// Helper for ColorPicker4()
|
// Helper for ColorPicker4()
|
||||||
// NB: This is rather brittle and will show artifact when rounding this enabled if rounded corners overlap multiple cells. Caller currently responsible for avoiding that.
|
// NB: This is rather brittle and will show artifact when rounding this enabled if rounded corners overlap multiple cells. Caller currently responsible for avoiding that.
|
||||||
// Spent a non reasonable amount of time trying to getting this right for ColorButton with rounding+anti-aliasing+ImGuiColorEditFlags_HalfAlphaPreview flag + various grid sizes and offsets, and eventually gave up... probably more reasonable to disable rounding altogether.
|
// Spent a non reasonable amount of time trying to getting this right for ColorButton with rounding+anti-aliasing+ImGuiColorEditFlags_HalfAlphaPreview flag + various grid sizes and offsets, and eventually gave up... probably more reasonable to disable rounding altogether.
|
||||||
|
357
imgui_internal.h
357
imgui_internal.h
@ -92,8 +92,8 @@ Index of this file:
|
|||||||
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" // warning: 'xxx' is an unsafe pointer used for buffer access
|
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" // warning: 'xxx' is an unsafe pointer used for buffer access
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
||||||
#pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead
|
#pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead
|
||||||
#pragma GCC diagnostic ignored "-Wdeprecated-enum-enum-conversion" // warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_') is deprecated
|
#pragma GCC diagnostic ignored "-Wdeprecated-enum-enum-conversion" // warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_') is deprecated
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -131,6 +131,10 @@ struct ImGuiContext; // Main Dear ImGui context
|
|||||||
struct ImGuiContextHook; // Hook for extensions like ImGuiTestEngine
|
struct ImGuiContextHook; // Hook for extensions like ImGuiTestEngine
|
||||||
struct ImGuiDataVarInfo; // Variable information (e.g. to access style variables from an enum)
|
struct ImGuiDataVarInfo; // Variable information (e.g. to access style variables from an enum)
|
||||||
struct ImGuiDataTypeInfo; // Type information associated to a ImGuiDataType enum
|
struct ImGuiDataTypeInfo; // Type information associated to a ImGuiDataType enum
|
||||||
|
struct ImGuiDockContext; // Docking system context
|
||||||
|
struct ImGuiDockRequest; // Docking system dock/undock queued request
|
||||||
|
struct ImGuiDockNode; // Docking system node (hold a list of Windows OR two child dock nodes)
|
||||||
|
struct ImGuiDockNodeSettings; // Storage for a dock node in .ini file (we preserve those even if the associated dock node isn't active during the session)
|
||||||
struct ImGuiGroupData; // Stacked storage data for BeginGroup()/EndGroup()
|
struct ImGuiGroupData; // Stacked storage data for BeginGroup()/EndGroup()
|
||||||
struct ImGuiInputTextState; // Internal state of the currently focused/edited text input box
|
struct ImGuiInputTextState; // Internal state of the currently focused/edited text input box
|
||||||
struct ImGuiInputTextDeactivateData;// Short term storage to backup text of a deactivating InputText() while another is stealing active id
|
struct ImGuiInputTextDeactivateData;// Short term storage to backup text of a deactivating InputText() while another is stealing active id
|
||||||
@ -162,12 +166,14 @@ struct ImGuiTreeNodeStackData; // Temporary storage for TreeNode().
|
|||||||
struct ImGuiTypingSelectState; // Storage for GetTypingSelectRequest()
|
struct ImGuiTypingSelectState; // Storage for GetTypingSelectRequest()
|
||||||
struct ImGuiTypingSelectRequest; // Storage for GetTypingSelectRequest() (aimed to be public)
|
struct ImGuiTypingSelectRequest; // Storage for GetTypingSelectRequest() (aimed to be public)
|
||||||
struct ImGuiWindow; // Storage for one window
|
struct ImGuiWindow; // Storage for one window
|
||||||
|
struct ImGuiWindowDockStyle; // Storage for window-style data which needs to be stored for docking purpose
|
||||||
struct ImGuiWindowTempData; // Temporary storage for one window (that's the data which in theory we could ditch at the end of the frame, in practice we currently keep it for each window)
|
struct ImGuiWindowTempData; // Temporary storage for one window (that's the data which in theory we could ditch at the end of the frame, in practice we currently keep it for each window)
|
||||||
struct ImGuiWindowSettings; // Storage for a window .ini settings (we keep one of those even if the actual window wasn't instanced during this session)
|
struct ImGuiWindowSettings; // Storage for a window .ini settings (we keep one of those even if the actual window wasn't instanced during this session)
|
||||||
|
|
||||||
// Enumerations
|
// Enumerations
|
||||||
// Use your programming IDE "Go to definition" facility on the names of the center columns to find the actual flags/enum lists.
|
// Use your programming IDE "Go to definition" facility on the names of the center columns to find the actual flags/enum lists.
|
||||||
enum ImGuiLocKey : int; // -> enum ImGuiLocKey // Enum: a localization entry for translation.
|
enum ImGuiLocKey : int; // -> enum ImGuiLocKey // Enum: a localization entry for translation.
|
||||||
|
typedef int ImGuiDataAuthority; // -> enum ImGuiDataAuthority_ // Enum: for storing the source authority (dock node vs window) of a field
|
||||||
typedef int ImGuiLayoutType; // -> enum ImGuiLayoutType_ // Enum: Horizontal or vertical
|
typedef int ImGuiLayoutType; // -> enum ImGuiLayoutType_ // Enum: Horizontal or vertical
|
||||||
|
|
||||||
// Flags
|
// Flags
|
||||||
@ -220,6 +226,9 @@ namespace ImStb
|
|||||||
// [SECTION] Macros
|
// [SECTION] Macros
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Internal Drag and Drop payload types. String starting with '_' are reserved for Dear ImGui.
|
||||||
|
#define IMGUI_PAYLOAD_TYPE_WINDOW "_IMWINDOW" // Payload == ImGuiWindow*
|
||||||
|
|
||||||
// Debug Printing Into TTY
|
// Debug Printing Into TTY
|
||||||
// (since IMGUI_VERSION_NUM >= 18729: IMGUI_DEBUG_LOG was reworked into IMGUI_DEBUG_PRINTF (and removed framecount from it). If you were using a #define IMGUI_DEBUG_LOG please rename)
|
// (since IMGUI_VERSION_NUM >= 18729: IMGUI_DEBUG_LOG was reworked into IMGUI_DEBUG_PRINTF (and removed framecount from it). If you were using a #define IMGUI_DEBUG_LOG please rename)
|
||||||
#ifndef IMGUI_DEBUG_PRINTF
|
#ifndef IMGUI_DEBUG_PRINTF
|
||||||
@ -244,6 +253,8 @@ namespace ImStb
|
|||||||
#define IMGUI_DEBUG_LOG_CLIPPER(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventClipper) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
#define IMGUI_DEBUG_LOG_CLIPPER(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventClipper) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
||||||
#define IMGUI_DEBUG_LOG_IO(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventIO) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
#define IMGUI_DEBUG_LOG_IO(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventIO) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
||||||
#define IMGUI_DEBUG_LOG_INPUTROUTING(...) do{if (g.DebugLogFlags & ImGuiDebugLogFlags_EventInputRouting)IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
#define IMGUI_DEBUG_LOG_INPUTROUTING(...) do{if (g.DebugLogFlags & ImGuiDebugLogFlags_EventInputRouting)IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
||||||
|
#define IMGUI_DEBUG_LOG_DOCKING(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventDocking) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
||||||
|
#define IMGUI_DEBUG_LOG_VIEWPORT(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventViewport) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
||||||
|
|
||||||
// Static Asserts
|
// Static Asserts
|
||||||
#define IM_STATIC_ASSERT(_COND) static_assert(_COND, "")
|
#define IM_STATIC_ASSERT(_COND) static_assert(_COND, "")
|
||||||
@ -900,7 +911,7 @@ enum ImGuiItemStatusFlags_
|
|||||||
enum ImGuiHoveredFlagsPrivate_
|
enum ImGuiHoveredFlagsPrivate_
|
||||||
{
|
{
|
||||||
ImGuiHoveredFlags_DelayMask_ = ImGuiHoveredFlags_DelayNone | ImGuiHoveredFlags_DelayShort | ImGuiHoveredFlags_DelayNormal | ImGuiHoveredFlags_NoSharedDelay,
|
ImGuiHoveredFlags_DelayMask_ = ImGuiHoveredFlags_DelayNone | ImGuiHoveredFlags_DelayShort | ImGuiHoveredFlags_DelayNormal | ImGuiHoveredFlags_NoSharedDelay,
|
||||||
ImGuiHoveredFlags_AllowedMaskForIsWindowHovered = ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_AnyWindow | ImGuiHoveredFlags_NoPopupHierarchy | ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem | ImGuiHoveredFlags_ForTooltip | ImGuiHoveredFlags_Stationary,
|
ImGuiHoveredFlags_AllowedMaskForIsWindowHovered = ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_AnyWindow | ImGuiHoveredFlags_NoPopupHierarchy | ImGuiHoveredFlags_DockHierarchy | ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem | ImGuiHoveredFlags_ForTooltip | ImGuiHoveredFlags_Stationary,
|
||||||
ImGuiHoveredFlags_AllowedMaskForIsItemHovered = ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem | ImGuiHoveredFlags_AllowWhenOverlapped | ImGuiHoveredFlags_AllowWhenDisabled | ImGuiHoveredFlags_NoNavOverride | ImGuiHoveredFlags_ForTooltip | ImGuiHoveredFlags_Stationary | ImGuiHoveredFlags_DelayMask_,
|
ImGuiHoveredFlags_AllowedMaskForIsItemHovered = ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem | ImGuiHoveredFlags_AllowWhenOverlapped | ImGuiHoveredFlags_AllowWhenDisabled | ImGuiHoveredFlags_NoNavOverride | ImGuiHoveredFlags_ForTooltip | ImGuiHoveredFlags_Stationary | ImGuiHoveredFlags_DelayMask_,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1183,6 +1194,9 @@ enum ImGuiNextWindowDataFlags_
|
|||||||
ImGuiNextWindowDataFlags_HasScroll = 1 << 7,
|
ImGuiNextWindowDataFlags_HasScroll = 1 << 7,
|
||||||
ImGuiNextWindowDataFlags_HasChildFlags = 1 << 8,
|
ImGuiNextWindowDataFlags_HasChildFlags = 1 << 8,
|
||||||
ImGuiNextWindowDataFlags_HasRefreshPolicy = 1 << 9,
|
ImGuiNextWindowDataFlags_HasRefreshPolicy = 1 << 9,
|
||||||
|
ImGuiNextWindowDataFlags_HasViewport = 1 << 10,
|
||||||
|
ImGuiNextWindowDataFlags_HasDock = 1 << 11,
|
||||||
|
ImGuiNextWindowDataFlags_HasWindowClass = 1 << 12,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Storage for SetNexWindow** functions
|
// Storage for SetNexWindow** functions
|
||||||
@ -1192,17 +1206,22 @@ struct ImGuiNextWindowData
|
|||||||
ImGuiCond PosCond;
|
ImGuiCond PosCond;
|
||||||
ImGuiCond SizeCond;
|
ImGuiCond SizeCond;
|
||||||
ImGuiCond CollapsedCond;
|
ImGuiCond CollapsedCond;
|
||||||
|
ImGuiCond DockCond;
|
||||||
ImVec2 PosVal;
|
ImVec2 PosVal;
|
||||||
ImVec2 PosPivotVal;
|
ImVec2 PosPivotVal;
|
||||||
ImVec2 SizeVal;
|
ImVec2 SizeVal;
|
||||||
ImVec2 ContentSizeVal;
|
ImVec2 ContentSizeVal;
|
||||||
ImVec2 ScrollVal;
|
ImVec2 ScrollVal;
|
||||||
ImGuiChildFlags ChildFlags;
|
ImGuiChildFlags ChildFlags;
|
||||||
|
bool PosUndock;
|
||||||
bool CollapsedVal;
|
bool CollapsedVal;
|
||||||
ImRect SizeConstraintRect;
|
ImRect SizeConstraintRect;
|
||||||
ImGuiSizeCallback SizeCallback;
|
ImGuiSizeCallback SizeCallback;
|
||||||
void* SizeCallbackUserData;
|
void* SizeCallbackUserData;
|
||||||
float BgAlphaVal; // Override background alpha
|
float BgAlphaVal; // Override background alpha
|
||||||
|
ImGuiID ViewportId;
|
||||||
|
ImGuiID DockId;
|
||||||
|
ImGuiWindowClass WindowClass;
|
||||||
ImVec2 MenuBarOffsetMinVal; // (Always on) This is not exposed publicly, so we don't clear it and it doesn't have a corresponding flag (could we? for consistency?)
|
ImVec2 MenuBarOffsetMinVal; // (Always on) This is not exposed publicly, so we don't clear it and it doesn't have a corresponding flag (could we? for consistency?)
|
||||||
ImGuiWindowRefreshFlags RefreshFlagsVal;
|
ImGuiWindowRefreshFlags RefreshFlagsVal;
|
||||||
|
|
||||||
@ -1370,6 +1389,7 @@ enum ImGuiInputEventType
|
|||||||
ImGuiInputEventType_MousePos,
|
ImGuiInputEventType_MousePos,
|
||||||
ImGuiInputEventType_MouseWheel,
|
ImGuiInputEventType_MouseWheel,
|
||||||
ImGuiInputEventType_MouseButton,
|
ImGuiInputEventType_MouseButton,
|
||||||
|
ImGuiInputEventType_MouseViewport,
|
||||||
ImGuiInputEventType_Key,
|
ImGuiInputEventType_Key,
|
||||||
ImGuiInputEventType_Text,
|
ImGuiInputEventType_Text,
|
||||||
ImGuiInputEventType_Focus,
|
ImGuiInputEventType_Focus,
|
||||||
@ -1390,6 +1410,7 @@ enum ImGuiInputSource
|
|||||||
struct ImGuiInputEventMousePos { float PosX, PosY; ImGuiMouseSource MouseSource; };
|
struct ImGuiInputEventMousePos { float PosX, PosY; ImGuiMouseSource MouseSource; };
|
||||||
struct ImGuiInputEventMouseWheel { float WheelX, WheelY; ImGuiMouseSource MouseSource; };
|
struct ImGuiInputEventMouseWheel { float WheelX, WheelY; ImGuiMouseSource MouseSource; };
|
||||||
struct ImGuiInputEventMouseButton { int Button; bool Down; ImGuiMouseSource MouseSource; };
|
struct ImGuiInputEventMouseButton { int Button; bool Down; ImGuiMouseSource MouseSource; };
|
||||||
|
struct ImGuiInputEventMouseViewport { ImGuiID HoveredViewportID; };
|
||||||
struct ImGuiInputEventKey { ImGuiKey Key; bool Down; float AnalogValue; };
|
struct ImGuiInputEventKey { ImGuiKey Key; bool Down; float AnalogValue; };
|
||||||
struct ImGuiInputEventText { unsigned int Char; };
|
struct ImGuiInputEventText { unsigned int Char; };
|
||||||
struct ImGuiInputEventAppFocused { bool Focused; };
|
struct ImGuiInputEventAppFocused { bool Focused; };
|
||||||
@ -1404,6 +1425,7 @@ struct ImGuiInputEvent
|
|||||||
ImGuiInputEventMousePos MousePos; // if Type == ImGuiInputEventType_MousePos
|
ImGuiInputEventMousePos MousePos; // if Type == ImGuiInputEventType_MousePos
|
||||||
ImGuiInputEventMouseWheel MouseWheel; // if Type == ImGuiInputEventType_MouseWheel
|
ImGuiInputEventMouseWheel MouseWheel; // if Type == ImGuiInputEventType_MouseWheel
|
||||||
ImGuiInputEventMouseButton MouseButton; // if Type == ImGuiInputEventType_MouseButton
|
ImGuiInputEventMouseButton MouseButton; // if Type == ImGuiInputEventType_MouseButton
|
||||||
|
ImGuiInputEventMouseViewport MouseViewport; // if Type == ImGuiInputEventType_MouseViewport
|
||||||
ImGuiInputEventKey Key; // if Type == ImGuiInputEventType_Key
|
ImGuiInputEventKey Key; // if Type == ImGuiInputEventType_Key
|
||||||
ImGuiInputEventText Text; // if Type == ImGuiInputEventType_Text
|
ImGuiInputEventText Text; // if Type == ImGuiInputEventType_Text
|
||||||
ImGuiInputEventAppFocused AppFocused; // if Type == ImGuiInputEventType_Focus
|
ImGuiInputEventAppFocused AppFocused; // if Type == ImGuiInputEventType_Focus
|
||||||
@ -1791,8 +1813,153 @@ struct IMGUI_API ImGuiMultiSelectState
|
|||||||
// [SECTION] Docking support
|
// [SECTION] Docking support
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#define DOCKING_HOST_DRAW_CHANNEL_BG 0 // Dock host: background fill
|
||||||
|
#define DOCKING_HOST_DRAW_CHANNEL_FG 1 // Dock host: decorations and contents
|
||||||
|
|
||||||
#ifdef IMGUI_HAS_DOCK
|
#ifdef IMGUI_HAS_DOCK
|
||||||
// <this is filled in 'docking' branch>
|
|
||||||
|
// Extend ImGuiDockNodeFlags_
|
||||||
|
enum ImGuiDockNodeFlagsPrivate_
|
||||||
|
{
|
||||||
|
// [Internal]
|
||||||
|
ImGuiDockNodeFlags_DockSpace = 1 << 10, // Saved // A dockspace is a node that occupy space within an existing user window. Otherwise the node is floating and create its own window.
|
||||||
|
ImGuiDockNodeFlags_CentralNode = 1 << 11, // Saved // The central node has 2 main properties: stay visible when empty, only use "remaining" spaces from its neighbor.
|
||||||
|
ImGuiDockNodeFlags_NoTabBar = 1 << 12, // Saved // Tab bar is completely unavailable. No triangle in the corner to enable it back.
|
||||||
|
ImGuiDockNodeFlags_HiddenTabBar = 1 << 13, // Saved // Tab bar is hidden, with a triangle in the corner to show it again (NB: actual tab-bar instance may be destroyed as this is only used for single-window tab bar)
|
||||||
|
ImGuiDockNodeFlags_NoWindowMenuButton = 1 << 14, // Saved // Disable window/docking menu (that one that appears instead of the collapse button)
|
||||||
|
ImGuiDockNodeFlags_NoCloseButton = 1 << 15, // Saved // Disable close button
|
||||||
|
ImGuiDockNodeFlags_NoResizeX = 1 << 16, // //
|
||||||
|
ImGuiDockNodeFlags_NoResizeY = 1 << 17, // //
|
||||||
|
ImGuiDockNodeFlags_DockedWindowsInFocusRoute= 1 << 18, // // Any docked window will be automatically be focus-route chained (window->ParentWindowForFocusRoute set to this) so Shortcut() in this window can run when any docked window is focused.
|
||||||
|
// Disable docking/undocking actions in this dockspace or individual node (existing docked nodes will be preserved)
|
||||||
|
// Those are not exposed in public because the desirable sharing/inheriting/copy-flag-on-split behaviors are quite difficult to design and understand.
|
||||||
|
// The two public flags ImGuiDockNodeFlags_NoDockingOverCentralNode/ImGuiDockNodeFlags_NoDockingSplit don't have those issues.
|
||||||
|
ImGuiDockNodeFlags_NoDockingSplitOther = 1 << 19, // // Disable this node from splitting other windows/nodes.
|
||||||
|
ImGuiDockNodeFlags_NoDockingOverMe = 1 << 20, // // Disable other windows/nodes from being docked over this node.
|
||||||
|
ImGuiDockNodeFlags_NoDockingOverOther = 1 << 21, // // Disable this node from being docked over another window or non-empty node.
|
||||||
|
ImGuiDockNodeFlags_NoDockingOverEmpty = 1 << 22, // // Disable this node from being docked over an empty node (e.g. DockSpace with no other windows)
|
||||||
|
ImGuiDockNodeFlags_NoDocking = ImGuiDockNodeFlags_NoDockingOverMe | ImGuiDockNodeFlags_NoDockingOverOther | ImGuiDockNodeFlags_NoDockingOverEmpty | ImGuiDockNodeFlags_NoDockingSplit | ImGuiDockNodeFlags_NoDockingSplitOther,
|
||||||
|
// Masks
|
||||||
|
ImGuiDockNodeFlags_SharedFlagsInheritMask_ = ~0,
|
||||||
|
ImGuiDockNodeFlags_NoResizeFlagsMask_ = (int)ImGuiDockNodeFlags_NoResize | ImGuiDockNodeFlags_NoResizeX | ImGuiDockNodeFlags_NoResizeY,
|
||||||
|
|
||||||
|
// When splitting, those local flags are moved to the inheriting child, never duplicated
|
||||||
|
ImGuiDockNodeFlags_LocalFlagsTransferMask_ = (int)ImGuiDockNodeFlags_NoDockingSplit | ImGuiDockNodeFlags_NoResizeFlagsMask_ | (int)ImGuiDockNodeFlags_AutoHideTabBar | ImGuiDockNodeFlags_CentralNode | ImGuiDockNodeFlags_NoTabBar | ImGuiDockNodeFlags_HiddenTabBar | ImGuiDockNodeFlags_NoWindowMenuButton | ImGuiDockNodeFlags_NoCloseButton,
|
||||||
|
ImGuiDockNodeFlags_SavedFlagsMask_ = ImGuiDockNodeFlags_NoResizeFlagsMask_ | ImGuiDockNodeFlags_DockSpace | ImGuiDockNodeFlags_CentralNode | ImGuiDockNodeFlags_NoTabBar | ImGuiDockNodeFlags_HiddenTabBar | ImGuiDockNodeFlags_NoWindowMenuButton | ImGuiDockNodeFlags_NoCloseButton,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Store the source authority (dock node vs window) of a field
|
||||||
|
enum ImGuiDataAuthority_
|
||||||
|
{
|
||||||
|
ImGuiDataAuthority_Auto,
|
||||||
|
ImGuiDataAuthority_DockNode,
|
||||||
|
ImGuiDataAuthority_Window,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ImGuiDockNodeState
|
||||||
|
{
|
||||||
|
ImGuiDockNodeState_Unknown,
|
||||||
|
ImGuiDockNodeState_HostWindowHiddenBecauseSingleWindow,
|
||||||
|
ImGuiDockNodeState_HostWindowHiddenBecauseWindowsAreResizing,
|
||||||
|
ImGuiDockNodeState_HostWindowVisible,
|
||||||
|
};
|
||||||
|
|
||||||
|
// sizeof() 156~192
|
||||||
|
struct IMGUI_API ImGuiDockNode
|
||||||
|
{
|
||||||
|
ImGuiID ID;
|
||||||
|
ImGuiDockNodeFlags SharedFlags; // (Write) Flags shared by all nodes of a same dockspace hierarchy (inherited from the root node)
|
||||||
|
ImGuiDockNodeFlags LocalFlags; // (Write) Flags specific to this node
|
||||||
|
ImGuiDockNodeFlags LocalFlagsInWindows; // (Write) Flags specific to this node, applied from windows
|
||||||
|
ImGuiDockNodeFlags MergedFlags; // (Read) Effective flags (== SharedFlags | LocalFlagsInNode | LocalFlagsInWindows)
|
||||||
|
ImGuiDockNodeState State;
|
||||||
|
ImGuiDockNode* ParentNode;
|
||||||
|
ImGuiDockNode* ChildNodes[2]; // [Split node only] Child nodes (left/right or top/bottom). Consider switching to an array.
|
||||||
|
ImVector<ImGuiWindow*> Windows; // Note: unordered list! Iterate TabBar->Tabs for user-order.
|
||||||
|
ImGuiTabBar* TabBar;
|
||||||
|
ImVec2 Pos; // Current position
|
||||||
|
ImVec2 Size; // Current size
|
||||||
|
ImVec2 SizeRef; // [Split node only] Last explicitly written-to size (overridden when using a splitter affecting the node), used to calculate Size.
|
||||||
|
ImGuiAxis SplitAxis; // [Split node only] Split axis (X or Y)
|
||||||
|
ImGuiWindowClass WindowClass; // [Root node only]
|
||||||
|
ImU32 LastBgColor;
|
||||||
|
|
||||||
|
ImGuiWindow* HostWindow;
|
||||||
|
ImGuiWindow* VisibleWindow; // Generally point to window which is ID is == SelectedTabID, but when CTRL+Tabbing this can be a different window.
|
||||||
|
ImGuiDockNode* CentralNode; // [Root node only] Pointer to central node.
|
||||||
|
ImGuiDockNode* OnlyNodeWithWindows; // [Root node only] Set when there is a single visible node within the hierarchy.
|
||||||
|
int CountNodeWithWindows; // [Root node only]
|
||||||
|
int LastFrameAlive; // Last frame number the node was updated or kept alive explicitly with DockSpace() + ImGuiDockNodeFlags_KeepAliveOnly
|
||||||
|
int LastFrameActive; // Last frame number the node was updated.
|
||||||
|
int LastFrameFocused; // Last frame number the node was focused.
|
||||||
|
ImGuiID LastFocusedNodeId; // [Root node only] Which of our child docking node (any ancestor in the hierarchy) was last focused.
|
||||||
|
ImGuiID SelectedTabId; // [Leaf node only] Which of our tab/window is selected.
|
||||||
|
ImGuiID WantCloseTabId; // [Leaf node only] Set when closing a specific tab/window.
|
||||||
|
ImGuiID RefViewportId; // Reference viewport ID from visible window when HostWindow == NULL.
|
||||||
|
ImGuiDataAuthority AuthorityForPos :3;
|
||||||
|
ImGuiDataAuthority AuthorityForSize :3;
|
||||||
|
ImGuiDataAuthority AuthorityForViewport :3;
|
||||||
|
bool IsVisible :1; // Set to false when the node is hidden (usually disabled as it has no active window)
|
||||||
|
bool IsFocused :1;
|
||||||
|
bool IsBgDrawnThisFrame :1;
|
||||||
|
bool HasCloseButton :1; // Provide space for a close button (if any of the docked window has one). Note that button may be hidden on window without one.
|
||||||
|
bool HasWindowMenuButton :1;
|
||||||
|
bool HasCentralNodeChild :1;
|
||||||
|
bool WantCloseAll :1; // Set when closing all tabs at once.
|
||||||
|
bool WantLockSizeOnce :1;
|
||||||
|
bool WantMouseMove :1; // After a node extraction we need to transition toward moving the newly created host window
|
||||||
|
bool WantHiddenTabBarUpdate :1;
|
||||||
|
bool WantHiddenTabBarToggle :1;
|
||||||
|
|
||||||
|
ImGuiDockNode(ImGuiID id);
|
||||||
|
~ImGuiDockNode();
|
||||||
|
bool IsRootNode() const { return ParentNode == NULL; }
|
||||||
|
bool IsDockSpace() const { return (MergedFlags & ImGuiDockNodeFlags_DockSpace) != 0; }
|
||||||
|
bool IsFloatingNode() const { return ParentNode == NULL && (MergedFlags & ImGuiDockNodeFlags_DockSpace) == 0; }
|
||||||
|
bool IsCentralNode() const { return (MergedFlags & ImGuiDockNodeFlags_CentralNode) != 0; }
|
||||||
|
bool IsHiddenTabBar() const { return (MergedFlags & ImGuiDockNodeFlags_HiddenTabBar) != 0; } // Hidden tab bar can be shown back by clicking the small triangle
|
||||||
|
bool IsNoTabBar() const { return (MergedFlags & ImGuiDockNodeFlags_NoTabBar) != 0; } // Never show a tab bar
|
||||||
|
bool IsSplitNode() const { return ChildNodes[0] != NULL; }
|
||||||
|
bool IsLeafNode() const { return ChildNodes[0] == NULL; }
|
||||||
|
bool IsEmpty() const { return ChildNodes[0] == NULL && Windows.Size == 0; }
|
||||||
|
ImRect Rect() const { return ImRect(Pos.x, Pos.y, Pos.x + Size.x, Pos.y + Size.y); }
|
||||||
|
|
||||||
|
void SetLocalFlags(ImGuiDockNodeFlags flags) { LocalFlags = flags; UpdateMergedFlags(); }
|
||||||
|
void UpdateMergedFlags() { MergedFlags = SharedFlags | LocalFlags | LocalFlagsInWindows; }
|
||||||
|
};
|
||||||
|
|
||||||
|
// List of colors that are stored at the time of Begin() into Docked Windows.
|
||||||
|
// We currently store the packed colors in a simple array window->DockStyle.Colors[].
|
||||||
|
// A better solution may involve appending into a log of colors in ImGuiContext + store offsets into those arrays in ImGuiWindow,
|
||||||
|
// but it would be more complex as we'd need to double-buffer both as e.g. drop target may refer to window from last frame.
|
||||||
|
enum ImGuiWindowDockStyleCol
|
||||||
|
{
|
||||||
|
ImGuiWindowDockStyleCol_Text,
|
||||||
|
ImGuiWindowDockStyleCol_TabHovered,
|
||||||
|
ImGuiWindowDockStyleCol_TabFocused,
|
||||||
|
ImGuiWindowDockStyleCol_TabSelected,
|
||||||
|
ImGuiWindowDockStyleCol_TabSelectedOverline,
|
||||||
|
ImGuiWindowDockStyleCol_TabDimmed,
|
||||||
|
ImGuiWindowDockStyleCol_TabDimmedSelected,
|
||||||
|
ImGuiWindowDockStyleCol_TabDimmedSelectedOverline,
|
||||||
|
ImGuiWindowDockStyleCol_COUNT
|
||||||
|
};
|
||||||
|
|
||||||
|
// We don't store style.Alpha: dock_node->LastBgColor embeds it and otherwise it would only affect the docking tab, which intuitively I would say we don't want to.
|
||||||
|
struct ImGuiWindowDockStyle
|
||||||
|
{
|
||||||
|
ImU32 Colors[ImGuiWindowDockStyleCol_COUNT];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ImGuiDockContext
|
||||||
|
{
|
||||||
|
ImGuiStorage Nodes; // Map ID -> ImGuiDockNode*: Active nodes
|
||||||
|
ImVector<ImGuiDockRequest> Requests;
|
||||||
|
ImVector<ImGuiDockNodeSettings> NodesSettings;
|
||||||
|
bool WantFullRebuild;
|
||||||
|
ImGuiDockContext() { memset(this, 0, sizeof(*this)); }
|
||||||
|
};
|
||||||
|
|
||||||
#endif // #ifdef IMGUI_HAS_DOCK
|
#endif // #ifdef IMGUI_HAS_DOCK
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -1803,10 +1970,23 @@ struct IMGUI_API ImGuiMultiSelectState
|
|||||||
// Every instance of ImGuiViewport is in fact a ImGuiViewportP.
|
// Every instance of ImGuiViewport is in fact a ImGuiViewportP.
|
||||||
struct ImGuiViewportP : public ImGuiViewport
|
struct ImGuiViewportP : public ImGuiViewport
|
||||||
{
|
{
|
||||||
|
ImGuiWindow* Window; // Set when the viewport is owned by a window (and ImGuiViewportFlags_CanHostOtherWindows is NOT set)
|
||||||
|
int Idx;
|
||||||
|
int LastFrameActive; // Last frame number this viewport was activated by a window
|
||||||
|
int LastFocusedStampCount; // Last stamp number from when a window hosted by this viewport was focused (by comparing this value between two viewport we have an implicit viewport z-order we use as fallback)
|
||||||
|
ImGuiID LastNameHash;
|
||||||
|
ImVec2 LastPos;
|
||||||
|
float Alpha; // Window opacity (when dragging dockable windows/viewports we make them transparent)
|
||||||
|
float LastAlpha;
|
||||||
|
bool LastFocusedHadNavWindow;// Instead of maintaining a LastFocusedWindow (which may harder to correctly maintain), we merely store weither NavWindow != NULL last time the viewport was focused.
|
||||||
|
short PlatformMonitor;
|
||||||
int BgFgDrawListsLastFrame[2]; // Last frame number the background (0) and foreground (1) draw lists were used
|
int BgFgDrawListsLastFrame[2]; // Last frame number the background (0) and foreground (1) draw lists were used
|
||||||
ImDrawList* BgFgDrawLists[2]; // Convenience background (0) and foreground (1) draw lists. We use them to draw software mouser cursor when io.MouseDrawCursor is set and to draw most debug overlays.
|
ImDrawList* BgFgDrawLists[2]; // Convenience background (0) and foreground (1) draw lists. We use them to draw software mouser cursor when io.MouseDrawCursor is set and to draw most debug overlays.
|
||||||
ImDrawData DrawDataP;
|
ImDrawData DrawDataP;
|
||||||
ImDrawDataBuilder DrawDataBuilder; // Temporary data while building final ImDrawData
|
ImDrawDataBuilder DrawDataBuilder; // Temporary data while building final ImDrawData
|
||||||
|
ImVec2 LastPlatformPos;
|
||||||
|
ImVec2 LastPlatformSize;
|
||||||
|
ImVec2 LastRendererSize;
|
||||||
|
|
||||||
// Per-viewport work area
|
// Per-viewport work area
|
||||||
// - Insets are >= 0.0f values, distance from viewport corners to work area.
|
// - Insets are >= 0.0f values, distance from viewport corners to work area.
|
||||||
@ -1817,8 +1997,9 @@ struct ImGuiViewportP : public ImGuiViewport
|
|||||||
ImVec2 BuildWorkInsetMin; // Work Area inset accumulator for current frame, to become next frame's WorkInset
|
ImVec2 BuildWorkInsetMin; // Work Area inset accumulator for current frame, to become next frame's WorkInset
|
||||||
ImVec2 BuildWorkInsetMax; // "
|
ImVec2 BuildWorkInsetMax; // "
|
||||||
|
|
||||||
ImGuiViewportP() { BgFgDrawListsLastFrame[0] = BgFgDrawListsLastFrame[1] = -1; BgFgDrawLists[0] = BgFgDrawLists[1] = NULL; }
|
ImGuiViewportP() { Window = NULL; Idx = -1; LastFrameActive = BgFgDrawListsLastFrame[0] = BgFgDrawListsLastFrame[1] = LastFocusedStampCount = -1; LastNameHash = 0; Alpha = LastAlpha = 1.0f; LastFocusedHadNavWindow = false; PlatformMonitor = -1; BgFgDrawLists[0] = BgFgDrawLists[1] = NULL; LastPlatformPos = LastPlatformSize = LastRendererSize = ImVec2(FLT_MAX, FLT_MAX); }
|
||||||
~ImGuiViewportP() { if (BgFgDrawLists[0]) IM_DELETE(BgFgDrawLists[0]); if (BgFgDrawLists[1]) IM_DELETE(BgFgDrawLists[1]); }
|
~ImGuiViewportP() { if (BgFgDrawLists[0]) IM_DELETE(BgFgDrawLists[0]); if (BgFgDrawLists[1]) IM_DELETE(BgFgDrawLists[1]); }
|
||||||
|
void ClearRequestFlags() { PlatformRequestClose = PlatformRequestMove = PlatformRequestResize = false; }
|
||||||
|
|
||||||
// Calculate work rect pos/size given a set of offset (we have 1 pair of offset for rect locked from last frame data, and 1 pair for currently building rect)
|
// Calculate work rect pos/size given a set of offset (we have 1 pair of offset for rect locked from last frame data, and 1 pair for currently building rect)
|
||||||
ImVec2 CalcWorkRectPos(const ImVec2& inset_min) const { return ImVec2(Pos.x + inset_min.x, Pos.y + inset_min.y); }
|
ImVec2 CalcWorkRectPos(const ImVec2& inset_min) const { return ImVec2(Pos.x + inset_min.x, Pos.y + inset_min.y); }
|
||||||
@ -1841,14 +2022,19 @@ struct ImGuiViewportP : public ImGuiViewport
|
|||||||
struct ImGuiWindowSettings
|
struct ImGuiWindowSettings
|
||||||
{
|
{
|
||||||
ImGuiID ID;
|
ImGuiID ID;
|
||||||
ImVec2ih Pos;
|
ImVec2ih Pos; // NB: Settings position are stored RELATIVE to the viewport! Whereas runtime ones are absolute positions.
|
||||||
ImVec2ih Size;
|
ImVec2ih Size;
|
||||||
|
ImVec2ih ViewportPos;
|
||||||
|
ImGuiID ViewportId;
|
||||||
|
ImGuiID DockId; // ID of last known DockNode (even if the DockNode is invisible because it has only 1 active window), or 0 if none.
|
||||||
|
ImGuiID ClassId; // ID of window class if specified
|
||||||
|
short DockOrder; // Order of the last time the window was visible within its DockNode. This is used to reorder windows that are reappearing on the same frame. Same value between windows that were active and windows that were none are possible.
|
||||||
bool Collapsed;
|
bool Collapsed;
|
||||||
bool IsChild;
|
bool IsChild;
|
||||||
bool WantApply; // Set when loaded from .ini data (to enable merging/loading .ini data into an already running context)
|
bool WantApply; // Set when loaded from .ini data (to enable merging/loading .ini data into an already running context)
|
||||||
bool WantDelete; // Set to invalidate/delete the settings entry
|
bool WantDelete; // Set to invalidate/delete the settings entry
|
||||||
|
|
||||||
ImGuiWindowSettings() { memset(this, 0, sizeof(*this)); }
|
ImGuiWindowSettings() { memset(this, 0, sizeof(*this)); DockOrder = -1; }
|
||||||
char* GetName() { return (char*)(this + 1); }
|
char* GetName() { return (char*)(this + 1); }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1883,6 +2069,9 @@ enum ImGuiLocKey : int
|
|||||||
ImGuiLocKey_WindowingPopup,
|
ImGuiLocKey_WindowingPopup,
|
||||||
ImGuiLocKey_WindowingUntitled,
|
ImGuiLocKey_WindowingUntitled,
|
||||||
ImGuiLocKey_CopyLink,
|
ImGuiLocKey_CopyLink,
|
||||||
|
ImGuiLocKey_DockingHideTabBar,
|
||||||
|
ImGuiLocKey_DockingHoldShiftToDock,
|
||||||
|
ImGuiLocKey_DockingDragToUndockOrMoveNode,
|
||||||
ImGuiLocKey_COUNT
|
ImGuiLocKey_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1909,8 +2098,10 @@ enum ImGuiDebugLogFlags_
|
|||||||
ImGuiDebugLogFlags_EventSelection = 1 << 5,
|
ImGuiDebugLogFlags_EventSelection = 1 << 5,
|
||||||
ImGuiDebugLogFlags_EventIO = 1 << 6,
|
ImGuiDebugLogFlags_EventIO = 1 << 6,
|
||||||
ImGuiDebugLogFlags_EventInputRouting = 1 << 7,
|
ImGuiDebugLogFlags_EventInputRouting = 1 << 7,
|
||||||
|
ImGuiDebugLogFlags_EventDocking = 1 << 8,
|
||||||
|
ImGuiDebugLogFlags_EventViewport = 1 << 9,
|
||||||
|
|
||||||
ImGuiDebugLogFlags_EventMask_ = ImGuiDebugLogFlags_EventActiveId | ImGuiDebugLogFlags_EventFocus | ImGuiDebugLogFlags_EventPopup | ImGuiDebugLogFlags_EventNav | ImGuiDebugLogFlags_EventClipper | ImGuiDebugLogFlags_EventSelection | ImGuiDebugLogFlags_EventIO | ImGuiDebugLogFlags_EventInputRouting,
|
ImGuiDebugLogFlags_EventMask_ = ImGuiDebugLogFlags_EventActiveId | ImGuiDebugLogFlags_EventFocus | ImGuiDebugLogFlags_EventPopup | ImGuiDebugLogFlags_EventNav | ImGuiDebugLogFlags_EventClipper | ImGuiDebugLogFlags_EventSelection | ImGuiDebugLogFlags_EventIO | ImGuiDebugLogFlags_EventInputRouting | ImGuiDebugLogFlags_EventDocking | ImGuiDebugLogFlags_EventViewport,
|
||||||
ImGuiDebugLogFlags_OutputToTTY = 1 << 20, // Also send output to TTY
|
ImGuiDebugLogFlags_OutputToTTY = 1 << 20, // Also send output to TTY
|
||||||
ImGuiDebugLogFlags_OutputToTestEngine = 1 << 21, // Also send output to Test Engine
|
ImGuiDebugLogFlags_OutputToTestEngine = 1 << 21, // Also send output to Test Engine
|
||||||
};
|
};
|
||||||
@ -1943,6 +2134,7 @@ struct ImGuiMetricsConfig
|
|||||||
bool ShowDrawCmdBoundingBoxes = true;
|
bool ShowDrawCmdBoundingBoxes = true;
|
||||||
bool ShowTextEncodingViewer = false;
|
bool ShowTextEncodingViewer = false;
|
||||||
bool ShowAtlasTintedWithTextColor = false;
|
bool ShowAtlasTintedWithTextColor = false;
|
||||||
|
bool ShowDockingNodes = false;
|
||||||
int ShowWindowsRectsType = -1;
|
int ShowWindowsRectsType = -1;
|
||||||
int ShowTablesRectsType = -1;
|
int ShowTablesRectsType = -1;
|
||||||
int HighlightMonitorIdx = -1;
|
int HighlightMonitorIdx = -1;
|
||||||
@ -2002,15 +2194,18 @@ struct ImGuiContext
|
|||||||
ImGuiIO IO;
|
ImGuiIO IO;
|
||||||
ImGuiPlatformIO PlatformIO;
|
ImGuiPlatformIO PlatformIO;
|
||||||
ImGuiStyle Style;
|
ImGuiStyle Style;
|
||||||
|
ImGuiConfigFlags ConfigFlagsCurrFrame; // = g.IO.ConfigFlags at the time of NewFrame()
|
||||||
|
ImGuiConfigFlags ConfigFlagsLastFrame;
|
||||||
ImFont* Font; // (Shortcut) == FontStack.empty() ? IO.Font : FontStack.back()
|
ImFont* Font; // (Shortcut) == FontStack.empty() ? IO.Font : FontStack.back()
|
||||||
float FontSize; // (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize(). Text height for current window.
|
float FontSize; // (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize(). Text height for current window.
|
||||||
float FontBaseSize; // (Shortcut) == IO.FontGlobalScale * Font->Scale * Font->FontSize. Base text height.
|
float FontBaseSize; // (Shortcut) == IO.FontGlobalScale * Font->Scale * Font->FontSize. Base text height.
|
||||||
float FontScale; // == FontSize / Font->FontSize
|
float FontScale; // == FontSize / Font->FontSize
|
||||||
float CurrentDpiScale; // Current window/viewport DpiScale
|
float CurrentDpiScale; // Current window/viewport DpiScale == CurrentViewport->DpiScale
|
||||||
ImDrawListSharedData DrawListSharedData;
|
ImDrawListSharedData DrawListSharedData;
|
||||||
double Time;
|
double Time;
|
||||||
int FrameCount;
|
int FrameCount;
|
||||||
int FrameCountEnded;
|
int FrameCountEnded;
|
||||||
|
int FrameCountPlatformEnded;
|
||||||
int FrameCountRendered;
|
int FrameCountRendered;
|
||||||
bool WithinFrameScope; // Set by NewFrame(), cleared by EndFrame()
|
bool WithinFrameScope; // Set by NewFrame(), cleared by EndFrame()
|
||||||
bool WithinFrameScopeWithImplicitWindow; // Set by NewFrame(), cleared by EndFrame() when the implicit debug window has been pushed
|
bool WithinFrameScopeWithImplicitWindow; // Set by NewFrame(), cleared by EndFrame() when the implicit debug window has been pushed
|
||||||
@ -2039,7 +2234,7 @@ struct ImGuiContext
|
|||||||
ImGuiWindow* HoveredWindow; // Window the mouse is hovering. Will typically catch mouse inputs.
|
ImGuiWindow* HoveredWindow; // Window the mouse is hovering. Will typically catch mouse inputs.
|
||||||
ImGuiWindow* HoveredWindowUnderMovingWindow; // Hovered window ignoring MovingWindow. Only set if MovingWindow is set.
|
ImGuiWindow* HoveredWindowUnderMovingWindow; // Hovered window ignoring MovingWindow. Only set if MovingWindow is set.
|
||||||
ImGuiWindow* HoveredWindowBeforeClear; // Window the mouse is hovering. Filled even with _NoMouse. This is currently useful for multi-context compositors.
|
ImGuiWindow* HoveredWindowBeforeClear; // Window the mouse is hovering. Filled even with _NoMouse. This is currently useful for multi-context compositors.
|
||||||
ImGuiWindow* MovingWindow; // Track the window we clicked on (in order to preserve focus). The actual window that is moved is generally MovingWindow->RootWindow.
|
ImGuiWindow* MovingWindow; // Track the window we clicked on (in order to preserve focus). The actual window that is moved is generally MovingWindow->RootWindowDockTree.
|
||||||
ImGuiWindow* WheelingWindow; // Track the window we started mouse-wheeling on. Until a timer elapse or mouse has moved, generally keep scrolling the same window even if during the course of scrolling the mouse ends up hovering a child window.
|
ImGuiWindow* WheelingWindow; // Track the window we started mouse-wheeling on. Until a timer elapse or mouse has moved, generally keep scrolling the same window even if during the course of scrolling the mouse ends up hovering a child window.
|
||||||
ImVec2 WheelingWindowRefMousePos;
|
ImVec2 WheelingWindowRefMousePos;
|
||||||
int WheelingWindowStartFrame; // This may be set one frame before WheelingWindow is != NULL
|
int WheelingWindowStartFrame; // This may be set one frame before WheelingWindow is != NULL
|
||||||
@ -2115,7 +2310,16 @@ struct ImGuiContext
|
|||||||
ImVector<ImGuiTreeNodeStackData>TreeNodeStack; // Stack for TreeNode()
|
ImVector<ImGuiTreeNodeStackData>TreeNodeStack; // Stack for TreeNode()
|
||||||
|
|
||||||
// Viewports
|
// Viewports
|
||||||
ImVector<ImGuiViewportP*> Viewports; // Active viewports (Size==1 in 'master' branch). Each viewports hold their copy of ImDrawData.
|
ImVector<ImGuiViewportP*> Viewports; // Active viewports (always 1+, and generally 1 unless multi-viewports are enabled). Each viewports hold their copy of ImDrawData.
|
||||||
|
ImGuiViewportP* CurrentViewport; // We track changes of viewport (happening in Begin) so we can call Platform_OnChangedViewport()
|
||||||
|
ImGuiViewportP* MouseViewport;
|
||||||
|
ImGuiViewportP* MouseLastHoveredViewport; // Last known viewport that was hovered by mouse (even if we are not hovering any viewport any more) + honoring the _NoInputs flag.
|
||||||
|
ImGuiID PlatformLastFocusedViewportId;
|
||||||
|
ImGuiPlatformMonitor FallbackMonitor; // Virtual monitor used as fallback if backend doesn't provide monitor information.
|
||||||
|
ImRect PlatformMonitorsFullWorkRect; // Bounding box of all platform monitors
|
||||||
|
int ViewportCreatedCount; // Unique sequential creation counter (mostly for testing/debugging)
|
||||||
|
int PlatformWindowsCreatedCount; // Unique sequential creation counter (mostly for testing/debugging)
|
||||||
|
int ViewportFocusedStampCount; // Every time the front-most window changes, we stamp its viewport with an incrementing counter
|
||||||
|
|
||||||
// Gamepad/keyboard Navigation
|
// Gamepad/keyboard Navigation
|
||||||
ImGuiWindow* NavWindow; // Focused window for navigation. Could be called 'FocusedWindow'
|
ImGuiWindow* NavWindow; // Focused window for navigation. Could be called 'FocusedWindow'
|
||||||
@ -2282,6 +2486,12 @@ struct ImGuiContext
|
|||||||
// Platform support
|
// Platform support
|
||||||
ImGuiPlatformImeData PlatformImeData; // Data updated by current frame
|
ImGuiPlatformImeData PlatformImeData; // Data updated by current frame
|
||||||
ImGuiPlatformImeData PlatformImeDataPrev; // Previous frame data. When changed we call the platform_io.Platform_SetImeDataFn() handler.
|
ImGuiPlatformImeData PlatformImeDataPrev; // Previous frame data. When changed we call the platform_io.Platform_SetImeDataFn() handler.
|
||||||
|
ImGuiID PlatformImeViewport;
|
||||||
|
|
||||||
|
// Extensions
|
||||||
|
// FIXME: We could provide an API to register one slot in an array held in ImGuiContext?
|
||||||
|
ImGuiDockContext DockContext;
|
||||||
|
void (*DockNodeWindowMenuHandler)(ImGuiContext* ctx, ImGuiDockNode* node, ImGuiTabBar* tab_bar);
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
bool SettingsLoaded;
|
bool SettingsLoaded;
|
||||||
@ -2328,6 +2538,7 @@ struct ImGuiContext
|
|||||||
ImGuiMetricsConfig DebugMetricsConfig;
|
ImGuiMetricsConfig DebugMetricsConfig;
|
||||||
ImGuiIDStackTool DebugIDStackTool;
|
ImGuiIDStackTool DebugIDStackTool;
|
||||||
ImGuiDebugAllocInfo DebugAllocInfo;
|
ImGuiDebugAllocInfo DebugAllocInfo;
|
||||||
|
ImGuiDockNode* DebugHoveredDockNode; // Hovered dock node.
|
||||||
|
|
||||||
// Misc
|
// Misc
|
||||||
float FramerateSecPerFrame[60]; // Calculate estimate of framerate for user over the last 60 frames..
|
float FramerateSecPerFrame[60]; // Calculate estimate of framerate for user over the last 60 frames..
|
||||||
@ -2346,13 +2557,14 @@ struct ImGuiContext
|
|||||||
InputTextState.Ctx = this;
|
InputTextState.Ctx = this;
|
||||||
|
|
||||||
Initialized = false;
|
Initialized = false;
|
||||||
|
ConfigFlagsCurrFrame = ConfigFlagsLastFrame = ImGuiConfigFlags_None;
|
||||||
FontAtlasOwnedByContext = shared_font_atlas ? false : true;
|
FontAtlasOwnedByContext = shared_font_atlas ? false : true;
|
||||||
Font = NULL;
|
Font = NULL;
|
||||||
FontSize = FontBaseSize = FontScale = CurrentDpiScale = 0.0f;
|
FontSize = FontBaseSize = FontScale = CurrentDpiScale = 0.0f;
|
||||||
IO.Fonts = shared_font_atlas ? shared_font_atlas : IM_NEW(ImFontAtlas)();
|
IO.Fonts = shared_font_atlas ? shared_font_atlas : IM_NEW(ImFontAtlas)();
|
||||||
Time = 0.0f;
|
Time = 0.0f;
|
||||||
FrameCount = 0;
|
FrameCount = 0;
|
||||||
FrameCountEnded = FrameCountRendered = -1;
|
FrameCountEnded = FrameCountPlatformEnded = FrameCountRendered = -1;
|
||||||
WithinFrameScope = WithinFrameScopeWithImplicitWindow = WithinEndChild = false;
|
WithinFrameScope = WithinFrameScopeWithImplicitWindow = WithinEndChild = false;
|
||||||
GcCompactAll = false;
|
GcCompactAll = false;
|
||||||
TestEngineHookItems = false;
|
TestEngineHookItems = false;
|
||||||
@ -2408,6 +2620,12 @@ struct ImGuiContext
|
|||||||
CurrentItemFlags = ImGuiItemFlags_None;
|
CurrentItemFlags = ImGuiItemFlags_None;
|
||||||
DebugShowGroupRects = false;
|
DebugShowGroupRects = false;
|
||||||
|
|
||||||
|
CurrentViewport = NULL;
|
||||||
|
MouseViewport = MouseLastHoveredViewport = NULL;
|
||||||
|
PlatformLastFocusedViewportId = 0;
|
||||||
|
ViewportCreatedCount = PlatformWindowsCreatedCount = 0;
|
||||||
|
ViewportFocusedStampCount = 0;
|
||||||
|
|
||||||
NavWindow = NULL;
|
NavWindow = NULL;
|
||||||
NavId = NavFocusScopeId = NavActivateId = NavActivateDownId = NavActivatePressedId = 0;
|
NavId = NavFocusScopeId = NavActivateId = NavActivateDownId = NavActivatePressedId = 0;
|
||||||
NavLayer = ImGuiNavLayer_Main;
|
NavLayer = ImGuiNavLayer_Main;
|
||||||
@ -2501,6 +2719,9 @@ struct ImGuiContext
|
|||||||
|
|
||||||
PlatformImeData.InputPos = ImVec2(0.0f, 0.0f);
|
PlatformImeData.InputPos = ImVec2(0.0f, 0.0f);
|
||||||
PlatformImeDataPrev.InputPos = ImVec2(-1.0f, -1.0f); // Different to ensure initial submission
|
PlatformImeDataPrev.InputPos = ImVec2(-1.0f, -1.0f); // Different to ensure initial submission
|
||||||
|
PlatformImeViewport = 0;
|
||||||
|
|
||||||
|
DockNodeWindowMenuHandler = NULL;
|
||||||
|
|
||||||
SettingsLoaded = false;
|
SettingsLoaded = false;
|
||||||
SettingsDirtyTimer = 0.0f;
|
SettingsDirtyTimer = 0.0f;
|
||||||
@ -2528,6 +2749,7 @@ struct ImGuiContext
|
|||||||
DebugItemPickerBreakId = 0;
|
DebugItemPickerBreakId = 0;
|
||||||
DebugFlashStyleColorTime = 0.0f;
|
DebugFlashStyleColorTime = 0.0f;
|
||||||
DebugFlashStyleColorIdx = ImGuiCol_COUNT;
|
DebugFlashStyleColorIdx = ImGuiCol_COUNT;
|
||||||
|
DebugHoveredDockNode = NULL;
|
||||||
|
|
||||||
// Same as DebugBreakClearData(). Those fields are scattered in their respective subsystem to stay in hot-data locations
|
// Same as DebugBreakClearData(). Those fields are scattered in their respective subsystem to stay in hot-data locations
|
||||||
DebugBreakInWindow = 0;
|
DebugBreakInWindow = 0;
|
||||||
@ -2606,9 +2828,13 @@ struct IMGUI_API ImGuiWindow
|
|||||||
ImGuiContext* Ctx; // Parent UI context (needs to be set explicitly by parent).
|
ImGuiContext* Ctx; // Parent UI context (needs to be set explicitly by parent).
|
||||||
char* Name; // Window name, owned by the window.
|
char* Name; // Window name, owned by the window.
|
||||||
ImGuiID ID; // == ImHashStr(Name)
|
ImGuiID ID; // == ImHashStr(Name)
|
||||||
ImGuiWindowFlags Flags; // See enum ImGuiWindowFlags_
|
ImGuiWindowFlags Flags, FlagsPreviousFrame; // See enum ImGuiWindowFlags_
|
||||||
ImGuiChildFlags ChildFlags; // Set when window is a child window. See enum ImGuiChildFlags_
|
ImGuiChildFlags ChildFlags; // Set when window is a child window. See enum ImGuiChildFlags_
|
||||||
|
ImGuiWindowClass WindowClass; // Advanced users only. Set with SetNextWindowClass()
|
||||||
ImGuiViewportP* Viewport; // Always set in Begin(). Inactive windows may have a NULL value here if their viewport was discarded.
|
ImGuiViewportP* Viewport; // Always set in Begin(). Inactive windows may have a NULL value here if their viewport was discarded.
|
||||||
|
ImGuiID ViewportId; // We backup the viewport id (since the viewport may disappear or never be created if the window is inactive)
|
||||||
|
ImVec2 ViewportPos; // We backup the viewport position (since the viewport may disappear or never be created if the window is inactive)
|
||||||
|
int ViewportAllowPlatformMonitorExtend; // Reset to -1 every frame (index is guaranteed to be valid between NewFrame..EndFrame), only used in the Appearing frame of a tooltip/popup to enforce clamping to a given monitor
|
||||||
ImVec2 Pos; // Position (always rounded-up to nearest pixel)
|
ImVec2 Pos; // Position (always rounded-up to nearest pixel)
|
||||||
ImVec2 Size; // Current size (==SizeFull or collapsed title bar size)
|
ImVec2 Size; // Current size (==SizeFull or collapsed title bar size)
|
||||||
ImVec2 SizeFull; // Size when non collapsed
|
ImVec2 SizeFull; // Size when non collapsed
|
||||||
@ -2624,6 +2850,7 @@ struct IMGUI_API ImGuiWindow
|
|||||||
float DecoInnerSizeX1, DecoInnerSizeY1; // Applied AFTER/OVER InnerRect. Specialized for Tables as they use specialized form of clipping and frozen rows/columns are inside InnerRect (and not part of regular decoration sizes).
|
float DecoInnerSizeX1, DecoInnerSizeY1; // Applied AFTER/OVER InnerRect. Specialized for Tables as they use specialized form of clipping and frozen rows/columns are inside InnerRect (and not part of regular decoration sizes).
|
||||||
int NameBufLen; // Size of buffer storing Name. May be larger than strlen(Name)!
|
int NameBufLen; // Size of buffer storing Name. May be larger than strlen(Name)!
|
||||||
ImGuiID MoveId; // == window->GetID("#MOVE")
|
ImGuiID MoveId; // == window->GetID("#MOVE")
|
||||||
|
ImGuiID TabId; // == window->GetID("#TAB")
|
||||||
ImGuiID ChildId; // ID of corresponding item in parent window (for navigation to return from child window to parent window)
|
ImGuiID ChildId; // ID of corresponding item in parent window (for navigation to return from child window to parent window)
|
||||||
ImGuiID PopupId; // ID in the popup stack when this window is used as a popup/menu (because we use generic Name/ID for recycling)
|
ImGuiID PopupId; // ID in the popup stack when this window is used as a popup/menu (because we use generic Name/ID for recycling)
|
||||||
ImVec2 Scroll;
|
ImVec2 Scroll;
|
||||||
@ -2633,6 +2860,7 @@ struct IMGUI_API ImGuiWindow
|
|||||||
ImVec2 ScrollTargetEdgeSnapDist; // 0.0f = no snapping, >0.0f snapping threshold
|
ImVec2 ScrollTargetEdgeSnapDist; // 0.0f = no snapping, >0.0f snapping threshold
|
||||||
ImVec2 ScrollbarSizes; // Size taken by each scrollbars on their smaller axis. Pay attention! ScrollbarSizes.x == width of the vertical scrollbar, ScrollbarSizes.y = height of the horizontal scrollbar.
|
ImVec2 ScrollbarSizes; // Size taken by each scrollbars on their smaller axis. Pay attention! ScrollbarSizes.x == width of the vertical scrollbar, ScrollbarSizes.y = height of the horizontal scrollbar.
|
||||||
bool ScrollbarX, ScrollbarY; // Are scrollbars visible?
|
bool ScrollbarX, ScrollbarY; // Are scrollbars visible?
|
||||||
|
bool ViewportOwned;
|
||||||
bool Active; // Set to true on Begin(), unless Collapsed
|
bool Active; // Set to true on Begin(), unless Collapsed
|
||||||
bool WasActive;
|
bool WasActive;
|
||||||
bool WriteAccessed; // Set to true when any widget access the current window
|
bool WriteAccessed; // Set to true when any widget access the current window
|
||||||
@ -2662,6 +2890,7 @@ struct IMGUI_API ImGuiWindow
|
|||||||
ImGuiCond SetWindowPosAllowFlags : 8; // store acceptable condition flags for SetNextWindowPos() use.
|
ImGuiCond SetWindowPosAllowFlags : 8; // store acceptable condition flags for SetNextWindowPos() use.
|
||||||
ImGuiCond SetWindowSizeAllowFlags : 8; // store acceptable condition flags for SetNextWindowSize() use.
|
ImGuiCond SetWindowSizeAllowFlags : 8; // store acceptable condition flags for SetNextWindowSize() use.
|
||||||
ImGuiCond SetWindowCollapsedAllowFlags : 8; // store acceptable condition flags for SetNextWindowCollapsed() use.
|
ImGuiCond SetWindowCollapsedAllowFlags : 8; // store acceptable condition flags for SetNextWindowCollapsed() use.
|
||||||
|
ImGuiCond SetWindowDockAllowFlags : 8; // store acceptable condition flags for SetNextWindowDock() use.
|
||||||
ImVec2 SetWindowPosVal; // store window position when using a non-zero Pivot (position set needs to be processed when we know the window size)
|
ImVec2 SetWindowPosVal; // store window position when using a non-zero Pivot (position set needs to be processed when we know the window size)
|
||||||
ImVec2 SetWindowPosPivot; // store window pivot for positioning. ImVec2(0, 0) when positioning from top-left corner; ImVec2(0.5f, 0.5f) for centering; ImVec2(1, 1) for bottom right.
|
ImVec2 SetWindowPosPivot; // store window pivot for positioning. ImVec2(0, 0) when positioning from top-left corner; ImVec2(0.5f, 0.5f) for centering; ImVec2(1, 1) for bottom right.
|
||||||
|
|
||||||
@ -2681,11 +2910,13 @@ struct IMGUI_API ImGuiWindow
|
|||||||
ImVec2ih HitTestHoleOffset;
|
ImVec2ih HitTestHoleOffset;
|
||||||
|
|
||||||
int LastFrameActive; // Last frame number the window was Active.
|
int LastFrameActive; // Last frame number the window was Active.
|
||||||
|
int LastFrameJustFocused; // Last frame number the window was made Focused.
|
||||||
float LastTimeActive; // Last timestamp the window was Active (using float as we don't need high precision there)
|
float LastTimeActive; // Last timestamp the window was Active (using float as we don't need high precision there)
|
||||||
float ItemWidthDefault;
|
float ItemWidthDefault;
|
||||||
ImGuiStorage StateStorage;
|
ImGuiStorage StateStorage;
|
||||||
ImVector<ImGuiOldColumns> ColumnsStorage;
|
ImVector<ImGuiOldColumns> ColumnsStorage;
|
||||||
float FontWindowScale; // User scale multiplier per-window, via SetWindowFontScale()
|
float FontWindowScale; // User scale multiplier per-window, via SetWindowFontScale()
|
||||||
|
float FontDpiScale;
|
||||||
int SettingsOffset; // Offset into SettingsWindows[] (offsets are always valid as we only grow the array from the back)
|
int SettingsOffset; // Offset into SettingsWindows[] (offsets are always valid as we only grow the array from the back)
|
||||||
|
|
||||||
ImDrawList* DrawList; // == &DrawListInst (for backward compatibility reason with code using imgui_internal.h we keep this a pointer)
|
ImDrawList* DrawList; // == &DrawListInst (for backward compatibility reason with code using imgui_internal.h we keep this a pointer)
|
||||||
@ -2694,6 +2925,7 @@ struct IMGUI_API ImGuiWindow
|
|||||||
ImGuiWindow* ParentWindowInBeginStack;
|
ImGuiWindow* ParentWindowInBeginStack;
|
||||||
ImGuiWindow* RootWindow; // Point to ourself or first ancestor that is not a child window. Doesn't cross through popups/dock nodes.
|
ImGuiWindow* RootWindow; // Point to ourself or first ancestor that is not a child window. Doesn't cross through popups/dock nodes.
|
||||||
ImGuiWindow* RootWindowPopupTree; // Point to ourself or first ancestor that is not a child window. Cross through popups parent<>child.
|
ImGuiWindow* RootWindowPopupTree; // Point to ourself or first ancestor that is not a child window. Cross through popups parent<>child.
|
||||||
|
ImGuiWindow* RootWindowDockTree; // Point to ourself or first ancestor that is not a child window. Cross through dock nodes.
|
||||||
ImGuiWindow* RootWindowForTitleBarHighlight; // Point to ourself or first ancestor which will display TitleBgActive color when this window is active.
|
ImGuiWindow* RootWindowForTitleBarHighlight; // Point to ourself or first ancestor which will display TitleBgActive color when this window is active.
|
||||||
ImGuiWindow* RootWindowForNav; // Point to ourself or first ancestor which doesn't have the NavFlattened flag.
|
ImGuiWindow* RootWindowForNav; // Point to ourself or first ancestor which doesn't have the NavFlattened flag.
|
||||||
ImGuiWindow* ParentWindowForFocusRoute; // Set to manual link a window to its logical parent so that Shortcut() chain are honoerd (e.g. Tool linked to Document)
|
ImGuiWindow* ParentWindowForFocusRoute; // Set to manual link a window to its logical parent so that Shortcut() chain are honoerd (e.g. Tool linked to Document)
|
||||||
@ -2708,6 +2940,19 @@ struct IMGUI_API ImGuiWindow
|
|||||||
int MemoryDrawListVtxCapacity;
|
int MemoryDrawListVtxCapacity;
|
||||||
bool MemoryCompacted; // Set when window extraneous data have been garbage collected
|
bool MemoryCompacted; // Set when window extraneous data have been garbage collected
|
||||||
|
|
||||||
|
// Docking
|
||||||
|
bool DockIsActive :1; // When docking artifacts are actually visible. When this is set, DockNode is guaranteed to be != NULL. ~~ (DockNode != NULL) && (DockNode->Windows.Size > 1).
|
||||||
|
bool DockNodeIsVisible :1;
|
||||||
|
bool DockTabIsVisible :1; // Is our window visible this frame? ~~ is the corresponding tab selected?
|
||||||
|
bool DockTabWantClose :1;
|
||||||
|
short DockOrder; // Order of the last time the window was visible within its DockNode. This is used to reorder windows that are reappearing on the same frame. Same value between windows that were active and windows that were none are possible.
|
||||||
|
ImGuiWindowDockStyle DockStyle;
|
||||||
|
ImGuiDockNode* DockNode; // Which node are we docked into. Important: Prefer testing DockIsActive in many cases as this will still be set when the dock node is hidden.
|
||||||
|
ImGuiDockNode* DockNodeAsHost; // Which node are we owning (for parent windows)
|
||||||
|
ImGuiID DockId; // Backup of last valid DockNode->ID, so single window remember their dock node id even when they are not bound any more
|
||||||
|
ImGuiItemStatusFlags DockTabItemStatusFlags;
|
||||||
|
ImRect DockTabItemRect;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ImGuiWindow(ImGuiContext* context, const char* name);
|
ImGuiWindow(ImGuiContext* context, const char* name);
|
||||||
~ImGuiWindow();
|
~ImGuiWindow();
|
||||||
@ -2720,7 +2965,7 @@ public:
|
|||||||
|
|
||||||
// We don't use g.FontSize because the window may be != g.CurrentWindow.
|
// We don't use g.FontSize because the window may be != g.CurrentWindow.
|
||||||
ImRect Rect() const { return ImRect(Pos.x, Pos.y, Pos.x + Size.x, Pos.y + Size.y); }
|
ImRect Rect() const { return ImRect(Pos.x, Pos.y, Pos.x + Size.x, Pos.y + Size.y); }
|
||||||
float CalcFontSize() const { ImGuiContext& g = *Ctx; float scale = g.FontBaseSize * FontWindowScale; if (ParentWindow) scale *= ParentWindow->FontWindowScale; return scale; }
|
float CalcFontSize() const { ImGuiContext& g = *Ctx; float scale = g.FontBaseSize * FontWindowScale * FontDpiScale; if (ParentWindow) scale *= ParentWindow->FontWindowScale; return scale; }
|
||||||
ImRect TitleBarRect() const { return ImRect(Pos, ImVec2(Pos.x + SizeFull.x, Pos.y + TitleBarHeight)); }
|
ImRect TitleBarRect() const { return ImRect(Pos, ImVec2(Pos.x + SizeFull.x, Pos.y + TitleBarHeight)); }
|
||||||
ImRect MenuBarRect() const { float y1 = Pos.y + TitleBarHeight; return ImRect(Pos.x, y1, Pos.x + SizeFull.x, y1 + MenuBarHeight); }
|
ImRect MenuBarRect() const { float y1 = Pos.y + TitleBarHeight; return ImRect(Pos.x, y1, Pos.x + SizeFull.x, y1 + MenuBarHeight); }
|
||||||
};
|
};
|
||||||
@ -2743,13 +2988,15 @@ enum ImGuiTabItemFlagsPrivate_
|
|||||||
ImGuiTabItemFlags_SectionMask_ = ImGuiTabItemFlags_Leading | ImGuiTabItemFlags_Trailing,
|
ImGuiTabItemFlags_SectionMask_ = ImGuiTabItemFlags_Leading | ImGuiTabItemFlags_Trailing,
|
||||||
ImGuiTabItemFlags_NoCloseButton = 1 << 20, // Track whether p_open was set or not (we'll need this info on the next frame to recompute ContentWidth during layout)
|
ImGuiTabItemFlags_NoCloseButton = 1 << 20, // Track whether p_open was set or not (we'll need this info on the next frame to recompute ContentWidth during layout)
|
||||||
ImGuiTabItemFlags_Button = 1 << 21, // Used by TabItemButton, change the tab item behavior to mimic a button
|
ImGuiTabItemFlags_Button = 1 << 21, // Used by TabItemButton, change the tab item behavior to mimic a button
|
||||||
|
ImGuiTabItemFlags_Unsorted = 1 << 22, // [Docking] Trailing tabs with the _Unsorted flag will be sorted based on the DockOrder of their Window.
|
||||||
};
|
};
|
||||||
|
|
||||||
// Storage for one active tab item (sizeof() 40 bytes)
|
// Storage for one active tab item (sizeof() 48 bytes)
|
||||||
struct ImGuiTabItem
|
struct ImGuiTabItem
|
||||||
{
|
{
|
||||||
ImGuiID ID;
|
ImGuiID ID;
|
||||||
ImGuiTabItemFlags Flags;
|
ImGuiTabItemFlags Flags;
|
||||||
|
ImGuiWindow* Window; // When TabItem is part of a DockNode's TabBar, we hold on to a window.
|
||||||
int LastFrameVisible;
|
int LastFrameVisible;
|
||||||
int LastFrameSelected; // This allows us to infer an ordered list of the last activated tabs with little maintenance
|
int LastFrameSelected; // This allows us to infer an ordered list of the last activated tabs with little maintenance
|
||||||
float Offset; // Position relative to beginning of tab
|
float Offset; // Position relative to beginning of tab
|
||||||
@ -3114,7 +3361,7 @@ namespace ImGui
|
|||||||
IMGUI_API void UpdateWindowParentAndRootLinks(ImGuiWindow* window, ImGuiWindowFlags flags, ImGuiWindow* parent_window);
|
IMGUI_API void UpdateWindowParentAndRootLinks(ImGuiWindow* window, ImGuiWindowFlags flags, ImGuiWindow* parent_window);
|
||||||
IMGUI_API void UpdateWindowSkipRefresh(ImGuiWindow* window);
|
IMGUI_API void UpdateWindowSkipRefresh(ImGuiWindow* window);
|
||||||
IMGUI_API ImVec2 CalcWindowNextAutoFitSize(ImGuiWindow* window);
|
IMGUI_API ImVec2 CalcWindowNextAutoFitSize(ImGuiWindow* window);
|
||||||
IMGUI_API bool IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent, bool popup_hierarchy);
|
IMGUI_API bool IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent, bool popup_hierarchy, bool dock_hierarchy);
|
||||||
IMGUI_API bool IsWindowWithinBeginStackOf(ImGuiWindow* window, ImGuiWindow* potential_parent);
|
IMGUI_API bool IsWindowWithinBeginStackOf(ImGuiWindow* window, ImGuiWindow* potential_parent);
|
||||||
IMGUI_API bool IsWindowAbove(ImGuiWindow* potential_above, ImGuiWindow* potential_below);
|
IMGUI_API bool IsWindowAbove(ImGuiWindow* potential_above, ImGuiWindow* potential_below);
|
||||||
IMGUI_API bool IsWindowNavFocusable(ImGuiWindow* window);
|
IMGUI_API bool IsWindowNavFocusable(ImGuiWindow* window);
|
||||||
@ -3123,7 +3370,7 @@ namespace ImGui
|
|||||||
IMGUI_API void SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond cond = 0);
|
IMGUI_API void SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond cond = 0);
|
||||||
IMGUI_API void SetWindowHitTestHole(ImGuiWindow* window, const ImVec2& pos, const ImVec2& size);
|
IMGUI_API void SetWindowHitTestHole(ImGuiWindow* window, const ImVec2& pos, const ImVec2& size);
|
||||||
IMGUI_API void SetWindowHiddenAndSkipItemsForCurrentFrame(ImGuiWindow* window);
|
IMGUI_API void SetWindowHiddenAndSkipItemsForCurrentFrame(ImGuiWindow* window);
|
||||||
inline void SetWindowParentWindowForFocusRoute(ImGuiWindow* window, ImGuiWindow* parent_window) { window->ParentWindowForFocusRoute = parent_window; }
|
inline void SetWindowParentWindowForFocusRoute(ImGuiWindow* window, ImGuiWindow* parent_window) { window->ParentWindowForFocusRoute = parent_window; } // You may also use SetNextWindowClass()'s FocusRouteParentWindowId field.
|
||||||
inline ImRect WindowRectAbsToRel(ImGuiWindow* window, const ImRect& r) { ImVec2 off = window->DC.CursorStartPos; return ImRect(r.Min.x - off.x, r.Min.y - off.y, r.Max.x - off.x, r.Max.y - off.y); }
|
inline ImRect WindowRectAbsToRel(ImGuiWindow* window, const ImRect& r) { ImVec2 off = window->DC.CursorStartPos; return ImRect(r.Min.x - off.x, r.Min.y - off.y, r.Max.x - off.x, r.Max.y - off.y); }
|
||||||
inline ImRect WindowRectRelToAbs(ImGuiWindow* window, const ImRect& r) { ImVec2 off = window->DC.CursorStartPos; return ImRect(r.Min.x + off.x, r.Min.y + off.y, r.Max.x + off.x, r.Max.y + off.y); }
|
inline ImRect WindowRectRelToAbs(ImGuiWindow* window, const ImRect& r) { ImVec2 off = window->DC.CursorStartPos; return ImRect(r.Min.x + off.x, r.Min.y + off.y, r.Max.x + off.x, r.Max.y + off.y); }
|
||||||
inline ImVec2 WindowPosAbsToRel(ImGuiWindow* window, const ImVec2& p) { ImVec2 off = window->DC.CursorStartPos; return ImVec2(p.x - off.x, p.y - off.y); }
|
inline ImVec2 WindowPosAbsToRel(ImGuiWindow* window, const ImVec2& p) { ImVec2 off = window->DC.CursorStartPos; return ImVec2(p.x - off.x, p.y - off.y); }
|
||||||
@ -3145,9 +3392,7 @@ namespace ImGui
|
|||||||
// Fonts, drawing
|
// Fonts, drawing
|
||||||
IMGUI_API void SetCurrentFont(ImFont* font);
|
IMGUI_API void SetCurrentFont(ImFont* font);
|
||||||
inline ImFont* GetDefaultFont() { ImGuiContext& g = *GImGui; return g.IO.FontDefault ? g.IO.FontDefault : g.IO.Fonts->Fonts[0]; }
|
inline ImFont* GetDefaultFont() { ImGuiContext& g = *GImGui; return g.IO.FontDefault ? g.IO.FontDefault : g.IO.Fonts->Fonts[0]; }
|
||||||
inline ImDrawList* GetForegroundDrawList(ImGuiWindow* window) { IM_UNUSED(window); return GetForegroundDrawList(); } // This seemingly unnecessary wrapper simplifies compatibility between the 'master' and 'docking' branches.
|
inline ImDrawList* GetForegroundDrawList(ImGuiWindow* window) { return GetForegroundDrawList(window->Viewport); }
|
||||||
IMGUI_API ImDrawList* GetBackgroundDrawList(ImGuiViewport* viewport); // get background draw list for the given viewport. this draw list will be the first rendering one. Useful to quickly draw shapes/text behind dear imgui contents.
|
|
||||||
IMGUI_API ImDrawList* GetForegroundDrawList(ImGuiViewport* viewport); // get foreground draw list for the given viewport. this draw list will be the last rendered one. Useful to quickly draw shapes/text over dear imgui contents.
|
|
||||||
IMGUI_API void AddDrawListToDrawDataEx(ImDrawData* draw_data, ImVector<ImDrawList*>* out_list, ImDrawList* draw_list);
|
IMGUI_API void AddDrawListToDrawDataEx(ImDrawData* draw_data, ImVector<ImDrawList*>* out_list, ImDrawList* draw_list);
|
||||||
|
|
||||||
// Init
|
// Init
|
||||||
@ -3159,6 +3404,7 @@ namespace ImGui
|
|||||||
IMGUI_API void UpdateHoveredWindowAndCaptureFlags();
|
IMGUI_API void UpdateHoveredWindowAndCaptureFlags();
|
||||||
IMGUI_API void FindHoveredWindowEx(const ImVec2& pos, bool find_first_and_in_any_viewport, ImGuiWindow** out_hovered_window, ImGuiWindow** out_hovered_window_under_moving_window);
|
IMGUI_API void FindHoveredWindowEx(const ImVec2& pos, bool find_first_and_in_any_viewport, ImGuiWindow** out_hovered_window, ImGuiWindow** out_hovered_window_under_moving_window);
|
||||||
IMGUI_API void StartMouseMovingWindow(ImGuiWindow* window);
|
IMGUI_API void StartMouseMovingWindow(ImGuiWindow* window);
|
||||||
|
IMGUI_API void StartMouseMovingWindowOrNode(ImGuiWindow* window, ImGuiDockNode* node, bool undock);
|
||||||
IMGUI_API void UpdateMouseMovingWindowNewFrame();
|
IMGUI_API void UpdateMouseMovingWindowNewFrame();
|
||||||
IMGUI_API void UpdateMouseMovingWindowEndFrame();
|
IMGUI_API void UpdateMouseMovingWindowEndFrame();
|
||||||
|
|
||||||
@ -3168,7 +3414,13 @@ namespace ImGui
|
|||||||
IMGUI_API void CallContextHooks(ImGuiContext* context, ImGuiContextHookType type);
|
IMGUI_API void CallContextHooks(ImGuiContext* context, ImGuiContextHookType type);
|
||||||
|
|
||||||
// Viewports
|
// Viewports
|
||||||
|
IMGUI_API void TranslateWindowsInViewport(ImGuiViewportP* viewport, const ImVec2& old_pos, const ImVec2& new_pos);
|
||||||
|
IMGUI_API void ScaleWindowsInViewport(ImGuiViewportP* viewport, float scale);
|
||||||
|
IMGUI_API void DestroyPlatformWindow(ImGuiViewportP* viewport);
|
||||||
IMGUI_API void SetWindowViewport(ImGuiWindow* window, ImGuiViewportP* viewport);
|
IMGUI_API void SetWindowViewport(ImGuiWindow* window, ImGuiViewportP* viewport);
|
||||||
|
IMGUI_API void SetCurrentViewport(ImGuiWindow* window, ImGuiViewportP* viewport);
|
||||||
|
IMGUI_API const ImGuiPlatformMonitor* GetViewportPlatformMonitor(ImGuiViewport* viewport);
|
||||||
|
IMGUI_API ImGuiViewportP* FindHoveredViewportFromPlatformWindowStack(const ImVec2& mouse_platform_pos);
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
IMGUI_API void MarkIniSettingsDirty();
|
IMGUI_API void MarkIniSettingsDirty();
|
||||||
@ -3383,6 +3635,61 @@ namespace ImGui
|
|||||||
IMGUI_API bool TestShortcutRouting(ImGuiKeyChord key_chord, ImGuiID owner_id);
|
IMGUI_API bool TestShortcutRouting(ImGuiKeyChord key_chord, ImGuiID owner_id);
|
||||||
IMGUI_API ImGuiKeyRoutingData* GetShortcutRoutingData(ImGuiKeyChord key_chord);
|
IMGUI_API ImGuiKeyRoutingData* GetShortcutRoutingData(ImGuiKeyChord key_chord);
|
||||||
|
|
||||||
|
// Docking
|
||||||
|
// (some functions are only declared in imgui.cpp, see Docking section)
|
||||||
|
IMGUI_API void DockContextInitialize(ImGuiContext* ctx);
|
||||||
|
IMGUI_API void DockContextShutdown(ImGuiContext* ctx);
|
||||||
|
IMGUI_API void DockContextClearNodes(ImGuiContext* ctx, ImGuiID root_id, bool clear_settings_refs); // Use root_id==0 to clear all
|
||||||
|
IMGUI_API void DockContextRebuildNodes(ImGuiContext* ctx);
|
||||||
|
IMGUI_API void DockContextNewFrameUpdateUndocking(ImGuiContext* ctx);
|
||||||
|
IMGUI_API void DockContextNewFrameUpdateDocking(ImGuiContext* ctx);
|
||||||
|
IMGUI_API void DockContextEndFrame(ImGuiContext* ctx);
|
||||||
|
IMGUI_API ImGuiID DockContextGenNodeID(ImGuiContext* ctx);
|
||||||
|
IMGUI_API void DockContextQueueDock(ImGuiContext* ctx, ImGuiWindow* target, ImGuiDockNode* target_node, ImGuiWindow* payload, ImGuiDir split_dir, float split_ratio, bool split_outer);
|
||||||
|
IMGUI_API void DockContextQueueUndockWindow(ImGuiContext* ctx, ImGuiWindow* window);
|
||||||
|
IMGUI_API void DockContextQueueUndockNode(ImGuiContext* ctx, ImGuiDockNode* node);
|
||||||
|
IMGUI_API void DockContextProcessUndockWindow(ImGuiContext* ctx, ImGuiWindow* window, bool clear_persistent_docking_ref = true);
|
||||||
|
IMGUI_API void DockContextProcessUndockNode(ImGuiContext* ctx, ImGuiDockNode* node);
|
||||||
|
IMGUI_API bool DockContextCalcDropPosForDocking(ImGuiWindow* target, ImGuiDockNode* target_node, ImGuiWindow* payload_window, ImGuiDockNode* payload_node, ImGuiDir split_dir, bool split_outer, ImVec2* out_pos);
|
||||||
|
IMGUI_API ImGuiDockNode*DockContextFindNodeByID(ImGuiContext* ctx, ImGuiID id);
|
||||||
|
IMGUI_API void DockNodeWindowMenuHandler_Default(ImGuiContext* ctx, ImGuiDockNode* node, ImGuiTabBar* tab_bar);
|
||||||
|
IMGUI_API bool DockNodeBeginAmendTabBar(ImGuiDockNode* node);
|
||||||
|
IMGUI_API void DockNodeEndAmendTabBar();
|
||||||
|
inline ImGuiDockNode* DockNodeGetRootNode(ImGuiDockNode* node) { while (node->ParentNode) node = node->ParentNode; return node; }
|
||||||
|
inline bool DockNodeIsInHierarchyOf(ImGuiDockNode* node, ImGuiDockNode* parent) { while (node) { if (node == parent) return true; node = node->ParentNode; } return false; }
|
||||||
|
inline int DockNodeGetDepth(const ImGuiDockNode* node) { int depth = 0; while (node->ParentNode) { node = node->ParentNode; depth++; } return depth; }
|
||||||
|
inline ImGuiID DockNodeGetWindowMenuButtonId(const ImGuiDockNode* node) { return ImHashStr("#COLLAPSE", 0, node->ID); }
|
||||||
|
inline ImGuiDockNode* GetWindowDockNode() { ImGuiContext& g = *GImGui; return g.CurrentWindow->DockNode; }
|
||||||
|
IMGUI_API bool GetWindowAlwaysWantOwnTabBar(ImGuiWindow* window);
|
||||||
|
IMGUI_API void BeginDocked(ImGuiWindow* window, bool* p_open);
|
||||||
|
IMGUI_API void BeginDockableDragDropSource(ImGuiWindow* window);
|
||||||
|
IMGUI_API void BeginDockableDragDropTarget(ImGuiWindow* window);
|
||||||
|
IMGUI_API void SetWindowDock(ImGuiWindow* window, ImGuiID dock_id, ImGuiCond cond);
|
||||||
|
|
||||||
|
// Docking - Builder function needs to be generally called before the node is used/submitted.
|
||||||
|
// - The DockBuilderXXX functions are designed to _eventually_ become a public API, but it is too early to expose it and guarantee stability.
|
||||||
|
// - Do not hold on ImGuiDockNode* pointers! They may be invalidated by any split/merge/remove operation and every frame.
|
||||||
|
// - To create a DockSpace() node, make sure to set the ImGuiDockNodeFlags_DockSpace flag when calling DockBuilderAddNode().
|
||||||
|
// You can create dockspace nodes (attached to a window) _or_ floating nodes (carry its own window) with this API.
|
||||||
|
// - DockBuilderSplitNode() create 2 child nodes within 1 node. The initial node becomes a parent node.
|
||||||
|
// - If you intend to split the node immediately after creation using DockBuilderSplitNode(), make sure
|
||||||
|
// to call DockBuilderSetNodeSize() beforehand. If you don't, the resulting split sizes may not be reliable.
|
||||||
|
// - Call DockBuilderFinish() after you are done.
|
||||||
|
IMGUI_API void DockBuilderDockWindow(const char* window_name, ImGuiID node_id);
|
||||||
|
IMGUI_API ImGuiDockNode*DockBuilderGetNode(ImGuiID node_id);
|
||||||
|
inline ImGuiDockNode* DockBuilderGetCentralNode(ImGuiID node_id) { ImGuiDockNode* node = DockBuilderGetNode(node_id); if (!node) return NULL; return DockNodeGetRootNode(node)->CentralNode; }
|
||||||
|
IMGUI_API ImGuiID DockBuilderAddNode(ImGuiID node_id = 0, ImGuiDockNodeFlags flags = 0);
|
||||||
|
IMGUI_API void DockBuilderRemoveNode(ImGuiID node_id); // Remove node and all its child, undock all windows
|
||||||
|
IMGUI_API void DockBuilderRemoveNodeDockedWindows(ImGuiID node_id, bool clear_settings_refs = true);
|
||||||
|
IMGUI_API void DockBuilderRemoveNodeChildNodes(ImGuiID node_id); // Remove all split/hierarchy. All remaining docked windows will be re-docked to the remaining root node (node_id).
|
||||||
|
IMGUI_API void DockBuilderSetNodePos(ImGuiID node_id, ImVec2 pos);
|
||||||
|
IMGUI_API void DockBuilderSetNodeSize(ImGuiID node_id, ImVec2 size);
|
||||||
|
IMGUI_API ImGuiID DockBuilderSplitNode(ImGuiID node_id, ImGuiDir split_dir, float size_ratio_for_node_at_dir, ImGuiID* out_id_at_dir, ImGuiID* out_id_at_opposite_dir); // Create 2 child nodes in this parent node.
|
||||||
|
IMGUI_API void DockBuilderCopyDockSpace(ImGuiID src_dockspace_id, ImGuiID dst_dockspace_id, ImVector<const char*>* in_window_remap_pairs);
|
||||||
|
IMGUI_API void DockBuilderCopyNode(ImGuiID src_node_id, ImGuiID dst_node_id, ImVector<ImGuiID>* out_node_remap_pairs);
|
||||||
|
IMGUI_API void DockBuilderCopyWindowSettings(const char* src_name, const char* dst_name);
|
||||||
|
IMGUI_API void DockBuilderFinish(ImGuiID node_id);
|
||||||
|
|
||||||
// [EXPERIMENTAL] Focus Scope
|
// [EXPERIMENTAL] Focus Scope
|
||||||
// This is generally used to identify a unique input location (for e.g. a selection set)
|
// This is generally used to identify a unique input location (for e.g. a selection set)
|
||||||
// There is one per window (automatically set in Begin), but:
|
// There is one per window (automatically set in Begin), but:
|
||||||
@ -3493,9 +3800,11 @@ namespace ImGui
|
|||||||
IMGUI_API bool BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& bb, ImGuiTabBarFlags flags);
|
IMGUI_API bool BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& bb, ImGuiTabBarFlags flags);
|
||||||
IMGUI_API ImGuiTabItem* TabBarFindTabByID(ImGuiTabBar* tab_bar, ImGuiID tab_id);
|
IMGUI_API ImGuiTabItem* TabBarFindTabByID(ImGuiTabBar* tab_bar, ImGuiID tab_id);
|
||||||
IMGUI_API ImGuiTabItem* TabBarFindTabByOrder(ImGuiTabBar* tab_bar, int order);
|
IMGUI_API ImGuiTabItem* TabBarFindTabByOrder(ImGuiTabBar* tab_bar, int order);
|
||||||
|
IMGUI_API ImGuiTabItem* TabBarFindMostRecentlySelectedTabForActiveWindow(ImGuiTabBar* tab_bar);
|
||||||
IMGUI_API ImGuiTabItem* TabBarGetCurrentTab(ImGuiTabBar* tab_bar);
|
IMGUI_API ImGuiTabItem* TabBarGetCurrentTab(ImGuiTabBar* tab_bar);
|
||||||
inline int TabBarGetTabOrder(ImGuiTabBar* tab_bar, ImGuiTabItem* tab) { return tab_bar->Tabs.index_from_ptr(tab); }
|
inline int TabBarGetTabOrder(ImGuiTabBar* tab_bar, ImGuiTabItem* tab) { return tab_bar->Tabs.index_from_ptr(tab); }
|
||||||
IMGUI_API const char* TabBarGetTabName(ImGuiTabBar* tab_bar, ImGuiTabItem* tab);
|
IMGUI_API const char* TabBarGetTabName(ImGuiTabBar* tab_bar, ImGuiTabItem* tab);
|
||||||
|
IMGUI_API void TabBarAddTab(ImGuiTabBar* tab_bar, ImGuiTabItemFlags tab_flags, ImGuiWindow* window);
|
||||||
IMGUI_API void TabBarRemoveTab(ImGuiTabBar* tab_bar, ImGuiID tab_id);
|
IMGUI_API void TabBarRemoveTab(ImGuiTabBar* tab_bar, ImGuiID tab_id);
|
||||||
IMGUI_API void TabBarCloseTab(ImGuiTabBar* tab_bar, ImGuiTabItem* tab);
|
IMGUI_API void TabBarCloseTab(ImGuiTabBar* tab_bar, ImGuiTabItem* tab);
|
||||||
IMGUI_API void TabBarQueueFocus(ImGuiTabBar* tab_bar, ImGuiTabItem* tab);
|
IMGUI_API void TabBarQueueFocus(ImGuiTabBar* tab_bar, ImGuiTabItem* tab);
|
||||||
@ -3528,8 +3837,10 @@ namespace ImGui
|
|||||||
IMGUI_API void RenderBullet(ImDrawList* draw_list, ImVec2 pos, ImU32 col);
|
IMGUI_API void RenderBullet(ImDrawList* draw_list, ImVec2 pos, ImU32 col);
|
||||||
IMGUI_API void RenderCheckMark(ImDrawList* draw_list, ImVec2 pos, ImU32 col, float sz);
|
IMGUI_API void RenderCheckMark(ImDrawList* draw_list, ImVec2 pos, ImU32 col, float sz);
|
||||||
IMGUI_API void RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, ImGuiDir direction, ImU32 col);
|
IMGUI_API void RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, ImGuiDir direction, ImU32 col);
|
||||||
|
IMGUI_API void RenderArrowDockMenu(ImDrawList* draw_list, ImVec2 p_min, float sz, ImU32 col);
|
||||||
IMGUI_API void RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, ImU32 col, float x_start_norm, float x_end_norm, float rounding);
|
IMGUI_API void RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, ImU32 col, float x_start_norm, float x_end_norm, float rounding);
|
||||||
IMGUI_API void RenderRectFilledWithHole(ImDrawList* draw_list, const ImRect& outer, const ImRect& inner, ImU32 col, float rounding);
|
IMGUI_API void RenderRectFilledWithHole(ImDrawList* draw_list, const ImRect& outer, const ImRect& inner, ImU32 col, float rounding);
|
||||||
|
IMGUI_API ImDrawFlags CalcRoundingFlagsForRectInRect(const ImRect& r_in, const ImRect& r_outer, float threshold);
|
||||||
|
|
||||||
// Widgets
|
// Widgets
|
||||||
IMGUI_API void TextEx(const char* text, const char* text_end = NULL, ImGuiTextFlags flags = 0);
|
IMGUI_API void TextEx(const char* text, const char* text_end = NULL, ImGuiTextFlags flags = 0);
|
||||||
@ -3543,7 +3854,7 @@ namespace ImGui
|
|||||||
|
|
||||||
// Widgets: Window Decorations
|
// Widgets: Window Decorations
|
||||||
IMGUI_API bool CloseButton(ImGuiID id, const ImVec2& pos);
|
IMGUI_API bool CloseButton(ImGuiID id, const ImVec2& pos);
|
||||||
IMGUI_API bool CollapseButton(ImGuiID id, const ImVec2& pos);
|
IMGUI_API bool CollapseButton(ImGuiID id, const ImVec2& pos, ImGuiDockNode* dock_node);
|
||||||
IMGUI_API void Scrollbar(ImGuiAxis axis);
|
IMGUI_API void Scrollbar(ImGuiAxis axis);
|
||||||
IMGUI_API bool ScrollbarEx(const ImRect& bb, ImGuiID id, ImGuiAxis axis, ImS64* p_scroll_v, ImS64 avail_v, ImS64 contents_v, ImDrawFlags flags);
|
IMGUI_API bool ScrollbarEx(const ImRect& bb, ImGuiID id, ImGuiAxis axis, ImS64* p_scroll_v, ImS64 avail_v, ImS64 contents_v, ImDrawFlags flags);
|
||||||
IMGUI_API ImRect GetWindowScrollbarRect(ImGuiWindow* window, ImGuiAxis axis);
|
IMGUI_API ImRect GetWindowScrollbarRect(ImGuiWindow* window, ImGuiAxis axis);
|
||||||
@ -3627,6 +3938,7 @@ namespace ImGui
|
|||||||
IMGUI_API void ShowFontAtlas(ImFontAtlas* atlas);
|
IMGUI_API void ShowFontAtlas(ImFontAtlas* atlas);
|
||||||
IMGUI_API void DebugHookIdInfo(ImGuiID id, ImGuiDataType data_type, const void* data_id, const void* data_id_end);
|
IMGUI_API void DebugHookIdInfo(ImGuiID id, ImGuiDataType data_type, const void* data_id, const void* data_id_end);
|
||||||
IMGUI_API void DebugNodeColumns(ImGuiOldColumns* columns);
|
IMGUI_API void DebugNodeColumns(ImGuiOldColumns* columns);
|
||||||
|
IMGUI_API void DebugNodeDockNode(ImGuiDockNode* node, const char* label);
|
||||||
IMGUI_API void DebugNodeDrawList(ImGuiWindow* window, ImGuiViewportP* viewport, const ImDrawList* draw_list, const char* label);
|
IMGUI_API void DebugNodeDrawList(ImGuiWindow* window, ImGuiViewportP* viewport, const ImDrawList* draw_list, const char* label);
|
||||||
IMGUI_API void DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list, const ImDrawList* draw_list, const ImDrawCmd* draw_cmd, bool show_mesh, bool show_aabb);
|
IMGUI_API void DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list, const ImDrawList* draw_list, const ImDrawCmd* draw_cmd, bool show_mesh, bool show_aabb);
|
||||||
IMGUI_API void DebugNodeFont(ImFont* font);
|
IMGUI_API void DebugNodeFont(ImFont* font);
|
||||||
@ -3643,6 +3955,7 @@ namespace ImGui
|
|||||||
IMGUI_API void DebugNodeWindowsList(ImVector<ImGuiWindow*>* windows, const char* label);
|
IMGUI_API void DebugNodeWindowsList(ImVector<ImGuiWindow*>* windows, const char* label);
|
||||||
IMGUI_API void DebugNodeWindowsListByBeginStackParent(ImGuiWindow** windows, int windows_size, ImGuiWindow* parent_in_begin_stack);
|
IMGUI_API void DebugNodeWindowsListByBeginStackParent(ImGuiWindow** windows, int windows_size, ImGuiWindow* parent_in_begin_stack);
|
||||||
IMGUI_API void DebugNodeViewport(ImGuiViewportP* viewport);
|
IMGUI_API void DebugNodeViewport(ImGuiViewportP* viewport);
|
||||||
|
IMGUI_API void DebugNodePlatformMonitor(ImGuiPlatformMonitor* monitor, const char* label, int idx);
|
||||||
IMGUI_API void DebugRenderKeyboardPreview(ImDrawList* draw_list);
|
IMGUI_API void DebugRenderKeyboardPreview(ImDrawList* draw_list);
|
||||||
IMGUI_API void DebugRenderViewportThumbnail(ImDrawList* draw_list, ImGuiViewportP* viewport, const ImRect& bb);
|
IMGUI_API void DebugRenderViewportThumbnail(ImDrawList* draw_list, ImGuiViewportP* viewport, const ImRect& bb);
|
||||||
|
|
||||||
|
@ -507,7 +507,7 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
|||||||
item_flags |= ImGuiItemFlags_ButtonRepeat;
|
item_flags |= ImGuiItemFlags_ButtonRepeat;
|
||||||
|
|
||||||
ImGuiWindow* backup_hovered_window = g.HoveredWindow;
|
ImGuiWindow* backup_hovered_window = g.HoveredWindow;
|
||||||
const bool flatten_hovered_children = (flags & ImGuiButtonFlags_FlattenChildren) && g.HoveredWindow && g.HoveredWindow->RootWindow == window;
|
const bool flatten_hovered_children = (flags & ImGuiButtonFlags_FlattenChildren) && g.HoveredWindow && g.HoveredWindow->RootWindowDockTree == window->RootWindowDockTree;
|
||||||
if (flatten_hovered_children)
|
if (flatten_hovered_children)
|
||||||
g.HoveredWindow = window;
|
g.HoveredWindow = window;
|
||||||
|
|
||||||
@ -863,7 +863,8 @@ bool ImGui::CloseButton(ImGuiID id, const ImVec2& pos)
|
|||||||
return pressed;
|
return pressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui::CollapseButton(ImGuiID id, const ImVec2& pos)
|
// The Collapse button also functions as a Dock Menu button.
|
||||||
|
bool ImGui::CollapseButton(ImGuiID id, const ImVec2& pos, ImGuiDockNode* dock_node)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiWindow* window = g.CurrentWindow;
|
ImGuiWindow* window = g.CurrentWindow;
|
||||||
@ -876,16 +877,21 @@ bool ImGui::CollapseButton(ImGuiID id, const ImVec2& pos)
|
|||||||
return pressed;
|
return pressed;
|
||||||
|
|
||||||
// Render
|
// Render
|
||||||
|
//bool is_dock_menu = (window->DockNodeAsHost && !window->Collapsed);
|
||||||
ImU32 bg_col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
|
ImU32 bg_col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
|
||||||
ImU32 text_col = GetColorU32(ImGuiCol_Text);
|
ImU32 text_col = GetColorU32(ImGuiCol_Text);
|
||||||
if (hovered || held)
|
if (hovered || held)
|
||||||
window->DrawList->AddRectFilled(bb.Min, bb.Max, bg_col);
|
window->DrawList->AddRectFilled(bb.Min, bb.Max, bg_col);
|
||||||
RenderNavHighlight(bb, id, ImGuiNavHighlightFlags_Compact);
|
RenderNavHighlight(bb, id, ImGuiNavHighlightFlags_Compact);
|
||||||
RenderArrow(window->DrawList, bb.Min, text_col, window->Collapsed ? ImGuiDir_Right : ImGuiDir_Down, 1.0f);
|
|
||||||
|
if (dock_node)
|
||||||
|
RenderArrowDockMenu(window->DrawList, bb.Min, g.FontSize, text_col);
|
||||||
|
else
|
||||||
|
RenderArrow(window->DrawList, bb.Min, text_col, window->Collapsed ? ImGuiDir_Right : ImGuiDir_Down, 1.0f);
|
||||||
|
|
||||||
// Switch to moving the window after mouse is moved beyond the initial drag threshold
|
// Switch to moving the window after mouse is moved beyond the initial drag threshold
|
||||||
if (IsItemActive() && IsMouseDragging(0))
|
if (IsItemActive() && IsMouseDragging(0))
|
||||||
StartMouseMovingWindow(window);
|
StartMouseMovingWindowOrNode(window, dock_node, true); // Undock from window/collapse menu button
|
||||||
|
|
||||||
return pressed;
|
return pressed;
|
||||||
}
|
}
|
||||||
@ -1627,7 +1633,7 @@ void ImGui::SeparatorTextEx(ImGuiID id, const char* label, const char* label_end
|
|||||||
const float separator_thickness = style.SeparatorTextBorderSize;
|
const float separator_thickness = style.SeparatorTextBorderSize;
|
||||||
const ImVec2 min_size(label_size.x + extra_w + padding.x * 2.0f, ImMax(label_size.y + padding.y * 2.0f, separator_thickness));
|
const ImVec2 min_size(label_size.x + extra_w + padding.x * 2.0f, ImMax(label_size.y + padding.y * 2.0f, separator_thickness));
|
||||||
const ImRect bb(pos, ImVec2(window->WorkRect.Max.x, pos.y + min_size.y));
|
const ImRect bb(pos, ImVec2(window->WorkRect.Max.x, pos.y + min_size.y));
|
||||||
const float text_baseline_y = ImTrunc((bb.GetHeight() - label_size.y) * style.SeparatorTextAlign.y + 0.99999f); //ImMax(padding.y, ImFloor((style.SeparatorTextSize - label_size.y) * 0.5f));
|
const float text_baseline_y = ImTrunc((bb.GetHeight() - label_size.y) * style.SeparatorTextAlign.y + 0.99999f); //ImMax(padding.y, ImTrunc((style.SeparatorTextSize - label_size.y) * 0.5f));
|
||||||
ItemSize(min_size, text_baseline_y);
|
ItemSize(min_size, text_baseline_y);
|
||||||
if (!ItemAdd(bb, id))
|
if (!ItemAdd(bb, id))
|
||||||
return;
|
return;
|
||||||
@ -5169,6 +5175,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
g.PlatformImeData.WantVisible = true;
|
g.PlatformImeData.WantVisible = true;
|
||||||
g.PlatformImeData.InputPos = ImVec2(cursor_screen_pos.x - 1.0f, cursor_screen_pos.y - g.FontSize);
|
g.PlatformImeData.InputPos = ImVec2(cursor_screen_pos.x - 1.0f, cursor_screen_pos.y - g.FontSize);
|
||||||
g.PlatformImeData.InputLineHeight = g.FontSize;
|
g.PlatformImeData.InputLineHeight = g.FontSize;
|
||||||
|
g.PlatformImeViewport = window->Viewport->ID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8472,7 +8479,7 @@ bool ImGui::BeginMenuBar()
|
|||||||
// We don't clip with current window clipping rectangle as it is already set to the area below. However we clip with window full rect.
|
// We don't clip with current window clipping rectangle as it is already set to the area below. However we clip with window full rect.
|
||||||
// We remove 1 worth of rounding to Max.x to that text in long menus and small windows don't tend to display over the lower-right rounded area, which looks particularly glitchy.
|
// We remove 1 worth of rounding to Max.x to that text in long menus and small windows don't tend to display over the lower-right rounded area, which looks particularly glitchy.
|
||||||
ImRect bar_rect = window->MenuBarRect();
|
ImRect bar_rect = window->MenuBarRect();
|
||||||
ImRect clip_rect(IM_ROUND(bar_rect.Min.x + window->WindowBorderSize), IM_ROUND(bar_rect.Min.y + window->WindowBorderSize), IM_ROUND(ImMax(bar_rect.Min.x, bar_rect.Max.x - ImMax(window->WindowRounding, window->WindowBorderSize))), IM_ROUND(bar_rect.Max.y));
|
ImRect clip_rect(ImFloor(bar_rect.Min.x + window->WindowBorderSize), ImFloor(bar_rect.Min.y + window->WindowBorderSize), ImFloor(ImMax(bar_rect.Min.x, bar_rect.Max.x - ImMax(window->WindowRounding, window->WindowBorderSize))), ImFloor(bar_rect.Max.y));
|
||||||
clip_rect.ClipWith(window->OuterRectClipped);
|
clip_rect.ClipWith(window->OuterRectClipped);
|
||||||
PushClipRect(clip_rect.Min, clip_rect.Max, false);
|
PushClipRect(clip_rect.Min, clip_rect.Max, false);
|
||||||
|
|
||||||
@ -8542,10 +8549,10 @@ bool ImGui::BeginViewportSideBar(const char* name, ImGuiViewport* viewport_p, Im
|
|||||||
IM_ASSERT(dir != ImGuiDir_None);
|
IM_ASSERT(dir != ImGuiDir_None);
|
||||||
|
|
||||||
ImGuiWindow* bar_window = FindWindowByName(name);
|
ImGuiWindow* bar_window = FindWindowByName(name);
|
||||||
|
ImGuiViewportP* viewport = (ImGuiViewportP*)(void*)(viewport_p ? viewport_p : GetMainViewport());
|
||||||
if (bar_window == NULL || bar_window->BeginCount == 0)
|
if (bar_window == NULL || bar_window->BeginCount == 0)
|
||||||
{
|
{
|
||||||
// Calculate and set window size/position
|
// Calculate and set window size/position
|
||||||
ImGuiViewportP* viewport = (ImGuiViewportP*)(void*)(viewport_p ? viewport_p : GetMainViewport());
|
|
||||||
ImRect avail_rect = viewport->GetBuildWorkRect();
|
ImRect avail_rect = viewport->GetBuildWorkRect();
|
||||||
ImGuiAxis axis = (dir == ImGuiDir_Up || dir == ImGuiDir_Down) ? ImGuiAxis_Y : ImGuiAxis_X;
|
ImGuiAxis axis = (dir == ImGuiDir_Up || dir == ImGuiDir_Down) ? ImGuiAxis_Y : ImGuiAxis_X;
|
||||||
ImVec2 pos = avail_rect.Min;
|
ImVec2 pos = avail_rect.Min;
|
||||||
@ -8563,7 +8570,8 @@ bool ImGui::BeginViewportSideBar(const char* name, ImGuiViewport* viewport_p, Im
|
|||||||
viewport->BuildWorkInsetMax[axis] += axis_size;
|
viewport->BuildWorkInsetMax[axis] += axis_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
window_flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove;
|
window_flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDocking;
|
||||||
|
SetNextWindowViewport(viewport->ID); // Enforce viewport so we don't create our own viewport when ImGuiConfigFlags_ViewportsNoMerge is set.
|
||||||
PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||||||
PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(0, 0)); // Lift normal size constraint
|
PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(0, 0)); // Lift normal size constraint
|
||||||
bool is_open = Begin(name, NULL, window_flags);
|
bool is_open = Begin(name, NULL, window_flags);
|
||||||
@ -8577,6 +8585,9 @@ bool ImGui::BeginMainMenuBar()
|
|||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiViewportP* viewport = (ImGuiViewportP*)(void*)GetMainViewport();
|
ImGuiViewportP* viewport = (ImGuiViewportP*)(void*)GetMainViewport();
|
||||||
|
|
||||||
|
// Notify of viewport change so GetFrameHeight() can be accurate in case of DPI change
|
||||||
|
SetCurrentViewport(NULL, viewport);
|
||||||
|
|
||||||
// For the main menu bar, which cannot be moved, we honor g.Style.DisplaySafeAreaPadding to ensure text can be visible on a TV set.
|
// For the main menu bar, which cannot be moved, we honor g.Style.DisplaySafeAreaPadding to ensure text can be visible on a TV set.
|
||||||
// FIXME: This could be generalized as an opt-in way to clamp window->DC.CursorStartPos to avoid SafeArea?
|
// FIXME: This could be generalized as an opt-in way to clamp window->DC.CursorStartPos to avoid SafeArea?
|
||||||
// FIXME: Consider removing support for safe area down the line... it's messy. Nowadays consoles have support for TV calibration in OS settings.
|
// FIXME: Consider removing support for safe area down the line... it's messy. Nowadays consoles have support for TV calibration in OS settings.
|
||||||
@ -8627,7 +8638,7 @@ static bool IsRootOfOpenMenuSet()
|
|||||||
const ImGuiPopupData* upper_popup = &g.OpenPopupStack[g.BeginPopupStack.Size];
|
const ImGuiPopupData* upper_popup = &g.OpenPopupStack[g.BeginPopupStack.Size];
|
||||||
if (window->DC.NavLayerCurrent != upper_popup->ParentNavLayer)
|
if (window->DC.NavLayerCurrent != upper_popup->ParentNavLayer)
|
||||||
return false;
|
return false;
|
||||||
return upper_popup->Window && (upper_popup->Window->Flags & ImGuiWindowFlags_ChildMenu) && ImGui::IsWindowChildOf(upper_popup->Window, window, true);
|
return upper_popup->Window && (upper_popup->Window->Flags & ImGuiWindowFlags_ChildMenu) && ImGui::IsWindowChildOf(upper_popup->Window, window, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled)
|
bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled)
|
||||||
@ -8966,8 +8977,10 @@ bool ImGui::MenuItem(const char* label, const char* shortcut, bool* p_selected,
|
|||||||
// - TabBarCalcMaxTabWidth() [Internal]
|
// - TabBarCalcMaxTabWidth() [Internal]
|
||||||
// - TabBarFindTabById() [Internal]
|
// - TabBarFindTabById() [Internal]
|
||||||
// - TabBarFindTabByOrder() [Internal]
|
// - TabBarFindTabByOrder() [Internal]
|
||||||
|
// - TabBarFindMostRecentlySelectedTabForActiveWindow() [Internal]
|
||||||
// - TabBarGetCurrentTab() [Internal]
|
// - TabBarGetCurrentTab() [Internal]
|
||||||
// - TabBarGetTabName() [Internal]
|
// - TabBarGetTabName() [Internal]
|
||||||
|
// - TabBarAddTab() [Internal]
|
||||||
// - TabBarRemoveTab() [Internal]
|
// - TabBarRemoveTab() [Internal]
|
||||||
// - TabBarCloseTab() [Internal]
|
// - TabBarCloseTab() [Internal]
|
||||||
// - TabBarScrollClamp() [Internal]
|
// - TabBarScrollClamp() [Internal]
|
||||||
@ -9088,7 +9101,8 @@ bool ImGui::BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& tab_bar_bb, ImG
|
|||||||
|
|
||||||
// Ensure correct ordering when toggling ImGuiTabBarFlags_Reorderable flag, or when a new tab was added while being not reorderable
|
// Ensure correct ordering when toggling ImGuiTabBarFlags_Reorderable flag, or when a new tab was added while being not reorderable
|
||||||
if ((flags & ImGuiTabBarFlags_Reorderable) != (tab_bar->Flags & ImGuiTabBarFlags_Reorderable) || (tab_bar->TabsAddedNew && !(flags & ImGuiTabBarFlags_Reorderable)))
|
if ((flags & ImGuiTabBarFlags_Reorderable) != (tab_bar->Flags & ImGuiTabBarFlags_Reorderable) || (tab_bar->TabsAddedNew && !(flags & ImGuiTabBarFlags_Reorderable)))
|
||||||
ImQsort(tab_bar->Tabs.Data, tab_bar->Tabs.Size, sizeof(ImGuiTabItem), TabItemComparerByBeginOrder);
|
if ((flags & ImGuiTabBarFlags_DockNode) == 0) // FIXME: TabBar with DockNode can now be hybrid
|
||||||
|
ImQsort(tab_bar->Tabs.Data, tab_bar->Tabs.Size, sizeof(ImGuiTabItem), TabItemComparerByBeginOrder);
|
||||||
tab_bar->TabsAddedNew = false;
|
tab_bar->TabsAddedNew = false;
|
||||||
|
|
||||||
// Flags
|
// Flags
|
||||||
@ -9370,6 +9384,10 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
|
|||||||
tab_bar->VisibleTabId = tab_bar->SelectedTabId;
|
tab_bar->VisibleTabId = tab_bar->SelectedTabId;
|
||||||
tab_bar->VisibleTabWasSubmitted = false;
|
tab_bar->VisibleTabWasSubmitted = false;
|
||||||
|
|
||||||
|
// CTRL+TAB can override visible tab temporarily
|
||||||
|
if (g.NavWindowingTarget != NULL && g.NavWindowingTarget->DockNode && g.NavWindowingTarget->DockNode->TabBar == tab_bar)
|
||||||
|
tab_bar->VisibleTabId = scroll_to_tab_id = g.NavWindowingTarget->TabId;
|
||||||
|
|
||||||
// Apply request requests
|
// Apply request requests
|
||||||
if (scroll_to_tab_id != 0)
|
if (scroll_to_tab_id != 0)
|
||||||
TabBarScrollToTab(tab_bar, scroll_to_tab_id, sections);
|
TabBarScrollToTab(tab_bar, scroll_to_tab_id, sections);
|
||||||
@ -9415,11 +9433,11 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
|
|||||||
// Dockable windows uses Name/ID in the global namespace. Non-dockable items use the ID stack.
|
// Dockable windows uses Name/ID in the global namespace. Non-dockable items use the ID stack.
|
||||||
static ImU32 ImGui::TabBarCalcTabID(ImGuiTabBar* tab_bar, const char* label, ImGuiWindow* docked_window)
|
static ImU32 ImGui::TabBarCalcTabID(ImGuiTabBar* tab_bar, const char* label, ImGuiWindow* docked_window)
|
||||||
{
|
{
|
||||||
IM_ASSERT(docked_window == NULL); // master branch only
|
if (docked_window != NULL)
|
||||||
IM_UNUSED(docked_window);
|
|
||||||
if (tab_bar->Flags & ImGuiTabBarFlags_DockNode)
|
|
||||||
{
|
{
|
||||||
ImGuiID id = ImHashStr(label);
|
IM_UNUSED(tab_bar);
|
||||||
|
IM_ASSERT(tab_bar->Flags & ImGuiTabBarFlags_DockNode);
|
||||||
|
ImGuiID id = docked_window->TabId;
|
||||||
KeepAliveID(id);
|
KeepAliveID(id);
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@ -9453,6 +9471,20 @@ ImGuiTabItem* ImGui::TabBarFindTabByOrder(ImGuiTabBar* tab_bar, int order)
|
|||||||
return &tab_bar->Tabs[order];
|
return &tab_bar->Tabs[order];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: See references to #2304 in TODO.txt
|
||||||
|
ImGuiTabItem* ImGui::TabBarFindMostRecentlySelectedTabForActiveWindow(ImGuiTabBar* tab_bar)
|
||||||
|
{
|
||||||
|
ImGuiTabItem* most_recently_selected_tab = NULL;
|
||||||
|
for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++)
|
||||||
|
{
|
||||||
|
ImGuiTabItem* tab = &tab_bar->Tabs[tab_n];
|
||||||
|
if (most_recently_selected_tab == NULL || most_recently_selected_tab->LastFrameSelected < tab->LastFrameSelected)
|
||||||
|
if (tab->Window && tab->Window->WasActive)
|
||||||
|
most_recently_selected_tab = tab;
|
||||||
|
}
|
||||||
|
return most_recently_selected_tab;
|
||||||
|
}
|
||||||
|
|
||||||
ImGuiTabItem* ImGui::TabBarGetCurrentTab(ImGuiTabBar* tab_bar)
|
ImGuiTabItem* ImGui::TabBarGetCurrentTab(ImGuiTabBar* tab_bar)
|
||||||
{
|
{
|
||||||
if (tab_bar->LastTabItemIdx < 0 || tab_bar->LastTabItemIdx >= tab_bar->Tabs.Size)
|
if (tab_bar->LastTabItemIdx < 0 || tab_bar->LastTabItemIdx >= tab_bar->Tabs.Size)
|
||||||
@ -9462,12 +9494,35 @@ ImGuiTabItem* ImGui::TabBarGetCurrentTab(ImGuiTabBar* tab_bar)
|
|||||||
|
|
||||||
const char* ImGui::TabBarGetTabName(ImGuiTabBar* tab_bar, ImGuiTabItem* tab)
|
const char* ImGui::TabBarGetTabName(ImGuiTabBar* tab_bar, ImGuiTabItem* tab)
|
||||||
{
|
{
|
||||||
|
if (tab->Window)
|
||||||
|
return tab->Window->Name;
|
||||||
if (tab->NameOffset == -1)
|
if (tab->NameOffset == -1)
|
||||||
return "N/A";
|
return "N/A";
|
||||||
IM_ASSERT(tab->NameOffset < tab_bar->TabsNames.Buf.Size);
|
IM_ASSERT(tab->NameOffset < tab_bar->TabsNames.Buf.Size);
|
||||||
return tab_bar->TabsNames.Buf.Data + tab->NameOffset;
|
return tab_bar->TabsNames.Buf.Data + tab->NameOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The purpose of this call is to register tab in advance so we can control their order at the time they appear.
|
||||||
|
// Otherwise calling this is unnecessary as tabs are appending as needed by the BeginTabItem() function.
|
||||||
|
void ImGui::TabBarAddTab(ImGuiTabBar* tab_bar, ImGuiTabItemFlags tab_flags, ImGuiWindow* window)
|
||||||
|
{
|
||||||
|
ImGuiContext& g = *GImGui;
|
||||||
|
IM_ASSERT(TabBarFindTabByID(tab_bar, window->TabId) == NULL);
|
||||||
|
IM_ASSERT(g.CurrentTabBar != tab_bar); // Can't work while the tab bar is active as our tab doesn't have an X offset yet, in theory we could/should test something like (tab_bar->CurrFrameVisible < g.FrameCount) but we'd need to solve why triggers the commented early-out assert in BeginTabBarEx() (probably dock node going from implicit to explicit in same frame)
|
||||||
|
|
||||||
|
if (!window->HasCloseButton)
|
||||||
|
tab_flags |= ImGuiTabItemFlags_NoCloseButton; // Set _NoCloseButton immediately because it will be used for first-frame width calculation.
|
||||||
|
|
||||||
|
ImGuiTabItem new_tab;
|
||||||
|
new_tab.ID = window->TabId;
|
||||||
|
new_tab.Flags = tab_flags;
|
||||||
|
new_tab.LastFrameVisible = tab_bar->CurrFrameVisible; // Required so BeginTabBar() doesn't ditch the tab
|
||||||
|
if (new_tab.LastFrameVisible == -1)
|
||||||
|
new_tab.LastFrameVisible = g.FrameCount - 1;
|
||||||
|
new_tab.Window = window; // Required so tab bar layout can compute the tab width before tab submission
|
||||||
|
tab_bar->Tabs.push_back(new_tab);
|
||||||
|
}
|
||||||
|
|
||||||
// The *TabId fields are already set by the docking system _before_ the actual TabItem was created, so we clear them regardless.
|
// The *TabId fields are already set by the docking system _before_ the actual TabItem was created, so we clear them regardless.
|
||||||
void ImGui::TabBarRemoveTab(ImGuiTabBar* tab_bar, ImGuiID tab_id)
|
void ImGui::TabBarRemoveTab(ImGuiTabBar* tab_bar, ImGuiID tab_id)
|
||||||
{
|
{
|
||||||
@ -9748,7 +9803,7 @@ bool ImGui::BeginTabItem(const char* label, bool* p_open, ImGuiTabItemFlags f
|
|||||||
IM_ASSERT_USER_ERROR(tab_bar, "Needs to be called between BeginTabBar() and EndTabBar()!");
|
IM_ASSERT_USER_ERROR(tab_bar, "Needs to be called between BeginTabBar() and EndTabBar()!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
IM_ASSERT(!(flags & ImGuiTabItemFlags_Button)); // BeginTabItem() Can't be used with button flags, use TabItemButton() instead!
|
IM_ASSERT((flags & ImGuiTabItemFlags_Button) == 0); // BeginTabItem() Can't be used with button flags, use TabItemButton() instead!
|
||||||
|
|
||||||
bool ret = TabItemEx(tab_bar, label, p_open, flags, NULL);
|
bool ret = TabItemEx(tab_bar, label, p_open, flags, NULL);
|
||||||
if (ret && !(flags & ImGuiTabItemFlags_NoPushId))
|
if (ret && !(flags & ImGuiTabItemFlags_NoPushId))
|
||||||
@ -9858,11 +9913,14 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
|
|||||||
const bool is_tab_button = (flags & ImGuiTabItemFlags_Button) != 0;
|
const bool is_tab_button = (flags & ImGuiTabItemFlags_Button) != 0;
|
||||||
tab->LastFrameVisible = g.FrameCount;
|
tab->LastFrameVisible = g.FrameCount;
|
||||||
tab->Flags = flags;
|
tab->Flags = flags;
|
||||||
|
tab->Window = docked_window;
|
||||||
|
|
||||||
// Append name _WITH_ the zero-terminator
|
// Append name _WITH_ the zero-terminator
|
||||||
|
// (regular tabs are permitted in a DockNode tab bar, but window tabs not permitted in a non-DockNode tab bar)
|
||||||
if (docked_window != NULL)
|
if (docked_window != NULL)
|
||||||
{
|
{
|
||||||
IM_ASSERT(docked_window == NULL); // master branch only
|
IM_ASSERT(tab_bar->Flags & ImGuiTabBarFlags_DockNode);
|
||||||
|
tab->NameOffset = -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -9887,7 +9945,7 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
|
|||||||
tab_bar->VisibleTabWasSubmitted = true;
|
tab_bar->VisibleTabWasSubmitted = true;
|
||||||
|
|
||||||
// On the very first frame of a tab bar we let first tab contents be visible to minimize appearing glitches
|
// On the very first frame of a tab bar we let first tab contents be visible to minimize appearing glitches
|
||||||
if (!tab_contents_visible && tab_bar->SelectedTabId == 0 && tab_bar_appearing)
|
if (!tab_contents_visible && tab_bar->SelectedTabId == 0 && tab_bar_appearing && docked_window == NULL)
|
||||||
if (tab_bar->Tabs.Size == 1 && !(tab_bar->Flags & ImGuiTabBarFlags_AutoSelectNewTabs))
|
if (tab_bar->Tabs.Size == 1 && !(tab_bar->Flags & ImGuiTabBarFlags_AutoSelectNewTabs))
|
||||||
tab_contents_visible = true;
|
tab_contents_visible = true;
|
||||||
|
|
||||||
@ -9935,30 +9993,82 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Click to Select a tab
|
// Click to Select a tab
|
||||||
// Allow the close button to overlap
|
|
||||||
ImGuiButtonFlags button_flags = ((is_tab_button ? ImGuiButtonFlags_PressedOnClickRelease : ImGuiButtonFlags_PressedOnClick) | ImGuiButtonFlags_AllowOverlap);
|
ImGuiButtonFlags button_flags = ((is_tab_button ? ImGuiButtonFlags_PressedOnClickRelease : ImGuiButtonFlags_PressedOnClick) | ImGuiButtonFlags_AllowOverlap);
|
||||||
if (g.DragDropActive)
|
if (g.DragDropActive && !g.DragDropPayload.IsDataType(IMGUI_PAYLOAD_TYPE_WINDOW)) // FIXME: May be an opt-in property of the payload to disable this
|
||||||
button_flags |= ImGuiButtonFlags_PressedOnDragDropHold;
|
button_flags |= ImGuiButtonFlags_PressedOnDragDropHold;
|
||||||
bool hovered, held;
|
bool hovered, held;
|
||||||
bool pressed = ButtonBehavior(bb, id, &hovered, &held, button_flags);
|
bool pressed = ButtonBehavior(bb, id, &hovered, &held, button_flags);
|
||||||
if (pressed && !is_tab_button)
|
if (pressed && !is_tab_button)
|
||||||
TabBarQueueFocus(tab_bar, tab);
|
TabBarQueueFocus(tab_bar, tab);
|
||||||
|
|
||||||
// Drag and drop: re-order tabs
|
// Transfer active id window so the active id is not owned by the dock host (as StartMouseMovingWindow()
|
||||||
if (held && !tab_appearing && IsMouseDragging(0))
|
// will only do it on the drag). This allows FocusWindow() to be more conservative in how it clears active id.
|
||||||
|
if (held && docked_window && g.ActiveId == id && g.ActiveIdIsJustActivated)
|
||||||
|
g.ActiveIdWindow = docked_window;
|
||||||
|
|
||||||
|
// Drag and drop a single floating window node moves it
|
||||||
|
ImGuiDockNode* node = docked_window ? docked_window->DockNode : NULL;
|
||||||
|
const bool single_floating_window_node = node && node->IsFloatingNode() && (node->Windows.Size == 1);
|
||||||
|
if (held && single_floating_window_node && IsMouseDragging(0, 0.0f))
|
||||||
{
|
{
|
||||||
if (!g.DragDropActive && (tab_bar->Flags & ImGuiTabBarFlags_Reorderable))
|
// Move
|
||||||
|
StartMouseMovingWindow(docked_window);
|
||||||
|
}
|
||||||
|
else if (held && !tab_appearing && IsMouseDragging(0))
|
||||||
|
{
|
||||||
|
// Drag and drop: re-order tabs
|
||||||
|
int drag_dir = 0;
|
||||||
|
float drag_distance_from_edge_x = 0.0f;
|
||||||
|
if (!g.DragDropActive && ((tab_bar->Flags & ImGuiTabBarFlags_Reorderable) || (docked_window != NULL)))
|
||||||
{
|
{
|
||||||
// While moving a tab it will jump on the other side of the mouse, so we also test for MouseDelta.x
|
// While moving a tab it will jump on the other side of the mouse, so we also test for MouseDelta.x
|
||||||
if (g.IO.MouseDelta.x < 0.0f && g.IO.MousePos.x < bb.Min.x)
|
if (g.IO.MouseDelta.x < 0.0f && g.IO.MousePos.x < bb.Min.x)
|
||||||
{
|
{
|
||||||
|
drag_dir = -1;
|
||||||
|
drag_distance_from_edge_x = bb.Min.x - g.IO.MousePos.x;
|
||||||
TabBarQueueReorderFromMousePos(tab_bar, tab, g.IO.MousePos);
|
TabBarQueueReorderFromMousePos(tab_bar, tab, g.IO.MousePos);
|
||||||
}
|
}
|
||||||
else if (g.IO.MouseDelta.x > 0.0f && g.IO.MousePos.x > bb.Max.x)
|
else if (g.IO.MouseDelta.x > 0.0f && g.IO.MousePos.x > bb.Max.x)
|
||||||
{
|
{
|
||||||
|
drag_dir = +1;
|
||||||
|
drag_distance_from_edge_x = g.IO.MousePos.x - bb.Max.x;
|
||||||
TabBarQueueReorderFromMousePos(tab_bar, tab, g.IO.MousePos);
|
TabBarQueueReorderFromMousePos(tab_bar, tab, g.IO.MousePos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Extract a Dockable window out of it's tab bar
|
||||||
|
const bool can_undock = docked_window != NULL && !(docked_window->Flags & ImGuiWindowFlags_NoMove) && !(node->MergedFlags & ImGuiDockNodeFlags_NoUndocking);
|
||||||
|
if (can_undock)
|
||||||
|
{
|
||||||
|
// We use a variable threshold to distinguish dragging tabs within a tab bar and extracting them out of the tab bar
|
||||||
|
bool undocking_tab = (g.DragDropActive && g.DragDropPayload.SourceId == id);
|
||||||
|
if (!undocking_tab) //&& (!g.IO.ConfigDockingWithShift || g.IO.KeyShift)
|
||||||
|
{
|
||||||
|
float threshold_base = g.FontSize;
|
||||||
|
float threshold_x = (threshold_base * 2.2f);
|
||||||
|
float threshold_y = (threshold_base * 1.5f) + ImClamp((ImFabs(g.IO.MouseDragMaxDistanceAbs[0].x) - threshold_base * 2.0f) * 0.20f, 0.0f, threshold_base * 4.0f);
|
||||||
|
//GetForegroundDrawList()->AddRect(ImVec2(bb.Min.x - threshold_x, bb.Min.y - threshold_y), ImVec2(bb.Max.x + threshold_x, bb.Max.y + threshold_y), IM_COL32_WHITE); // [DEBUG]
|
||||||
|
|
||||||
|
float distance_from_edge_y = ImMax(bb.Min.y - g.IO.MousePos.y, g.IO.MousePos.y - bb.Max.y);
|
||||||
|
if (distance_from_edge_y >= threshold_y)
|
||||||
|
undocking_tab = true;
|
||||||
|
if (drag_distance_from_edge_x > threshold_x)
|
||||||
|
if ((drag_dir < 0 && TabBarGetTabOrder(tab_bar, tab) == 0) || (drag_dir > 0 && TabBarGetTabOrder(tab_bar, tab) == tab_bar->Tabs.Size - 1))
|
||||||
|
undocking_tab = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (undocking_tab)
|
||||||
|
{
|
||||||
|
// Undock
|
||||||
|
// FIXME: refactor to share more code with e.g. StartMouseMovingWindow
|
||||||
|
DockContextQueueUndockWindow(&g, docked_window);
|
||||||
|
g.MovingWindow = docked_window;
|
||||||
|
SetActiveID(g.MovingWindow->MoveId, g.MovingWindow);
|
||||||
|
g.ActiveIdClickOffset -= g.MovingWindow->Pos - bb.Min;
|
||||||
|
g.ActiveIdNoClearOnFocusLoss = true;
|
||||||
|
SetActiveIdUsingAllKeyboardKeys();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@ -9994,7 +10104,7 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
|
|||||||
flags |= ImGuiTabItemFlags_NoCloseWithMiddleMouseButton;
|
flags |= ImGuiTabItemFlags_NoCloseWithMiddleMouseButton;
|
||||||
|
|
||||||
// Render tab label, process close button
|
// Render tab label, process close button
|
||||||
const ImGuiID close_button_id = p_open ? GetIDWithSeed("#CLOSE", NULL, id) : 0;
|
const ImGuiID close_button_id = p_open ? GetIDWithSeed("#CLOSE", NULL, docked_window ? docked_window->ID : id) : 0;
|
||||||
bool just_closed;
|
bool just_closed;
|
||||||
bool text_clipped;
|
bool text_clipped;
|
||||||
TabItemLabelAndCloseButton(display_draw_list, bb, tab_just_unsaved ? (flags & ~ImGuiTabItemFlags_UnsavedDocument) : flags, tab_bar->FramePadding, label, id, close_button_id, tab_contents_visible, &just_closed, &text_clipped);
|
TabItemLabelAndCloseButton(display_draw_list, bb, tab_just_unsaved ? (flags & ~ImGuiTabItemFlags_UnsavedDocument) : flags, tab_bar->FramePadding, label, id, close_button_id, tab_contents_visible, &just_closed, &text_clipped);
|
||||||
@ -10004,6 +10114,11 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
|
|||||||
TabBarCloseTab(tab_bar, tab);
|
TabBarCloseTab(tab_bar, tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Forward Hovered state so IsItemHovered() after Begin() can work (even though we are technically hovering our parent)
|
||||||
|
// That state is copied to window->DockTabItemStatusFlags by our caller.
|
||||||
|
if (docked_window && (hovered || g.HoveredId == close_button_id))
|
||||||
|
g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_HoveredWindow;
|
||||||
|
|
||||||
// Restore main window position so user can draw there
|
// Restore main window position so user can draw there
|
||||||
if (want_clip_rect)
|
if (want_clip_rect)
|
||||||
PopClipRect();
|
PopClipRect();
|
||||||
@ -10038,6 +10153,16 @@ void ImGui::SetTabItemClosed(const char* label)
|
|||||||
if (ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, tab_id))
|
if (ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, tab_id))
|
||||||
tab->WantClose = true; // Will be processed by next call to TabBarLayout()
|
tab->WantClose = true; // Will be processed by next call to TabBarLayout()
|
||||||
}
|
}
|
||||||
|
else if (ImGuiWindow* window = FindWindowByName(label))
|
||||||
|
{
|
||||||
|
if (window->DockIsActive)
|
||||||
|
if (ImGuiDockNode* node = window->DockNode)
|
||||||
|
{
|
||||||
|
ImGuiID tab_id = TabBarCalcTabID(node->TabBar, label, window);
|
||||||
|
TabBarRemoveTab(node->TabBar, tab_id);
|
||||||
|
window->DockTabWantClose = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImVec2 ImGui::TabItemCalcSize(const char* label, bool has_close_button_or_unsaved_marker)
|
ImVec2 ImGui::TabItemCalcSize(const char* label, bool has_close_button_or_unsaved_marker)
|
||||||
@ -10052,10 +10177,9 @@ ImVec2 ImGui::TabItemCalcSize(const char* label, bool has_close_button_or_unsave
|
|||||||
return ImVec2(ImMin(size.x, TabBarCalcMaxTabWidth()), size.y);
|
return ImVec2(ImMin(size.x, TabBarCalcMaxTabWidth()), size.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImVec2 ImGui::TabItemCalcSize(ImGuiWindow*)
|
ImVec2 ImGui::TabItemCalcSize(ImGuiWindow* window)
|
||||||
{
|
{
|
||||||
IM_ASSERT(0); // This function exists to facilitate merge with 'docking' branch.
|
return TabItemCalcSize(window->Name, window->HasCloseButton || (window->Flags & ImGuiWindowFlags_UnsavedDocument));
|
||||||
return ImVec2(0.0f, 0.0f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::TabItemBackground(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImU32 col)
|
void ImGui::TabItemBackground(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImU32 col)
|
||||||
|
@ -55,4 +55,8 @@ More information at: https://docs.microsoft.com/en-us/visualstudio/debugger/crea
|
|||||||
<DisplayString>{{Name {Name,s} Active {(Active||WasActive)?1:0,d} Child {(Flags & 0x01000000)?1:0,d} Popup {(Flags & 0x04000000)?1:0,d} Hidden {(Hidden)?1:0,d}}</DisplayString>
|
<DisplayString>{{Name {Name,s} Active {(Active||WasActive)?1:0,d} Child {(Flags & 0x01000000)?1:0,d} Popup {(Flags & 0x04000000)?1:0,d} Hidden {(Hidden)?1:0,d}}</DisplayString>
|
||||||
</Type>
|
</Type>
|
||||||
|
|
||||||
|
<Type Name="ImGuiDockNode">
|
||||||
|
<DisplayString>{{ID {ID,x} Pos=({Pos.x,g} {Pos.y,g}) Size=({Size.x,g} {Size.y,g}) Parent {(ParentNode==0)?0:ParentNode->ID,x} Childs {(ChildNodes[0] != 0)+(ChildNodes[1] != 0)} Windows {Windows.Size} }</DisplayString>
|
||||||
|
</Type>
|
||||||
|
|
||||||
</AutoVisualizer>
|
</AutoVisualizer>
|
||||||
|
Loading…
Reference in New Issue
Block a user