mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-10 21:18:36 +00:00
Pull Io struct and related things from 0.1-dev
This commit is contained in:
parent
1cd8518036
commit
b1e1b4f910
@ -14,6 +14,7 @@ readme = "README.markdown"
|
||||
travis-ci = { repository = "Gekkio/imgui-rs" }
|
||||
|
||||
[dependencies]
|
||||
bitflags = "1.0"
|
||||
imgui-sys = { version = "0.0.24-pre", path = "imgui-sys" }
|
||||
lazy_static = "1.1"
|
||||
parking_lot = "0.8"
|
||||
|
||||
51
imgui-examples/Cargo.lock
generated
51
imgui-examples/Cargo.lock
generated
@ -355,9 +355,10 @@ dependencies = [
|
||||
name = "imgui"
|
||||
version = "0.0.24-pre"
|
||||
dependencies = [
|
||||
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"imgui-sys 0.0.24-pre",
|
||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -447,6 +448,14 @@ dependencies = [
|
||||
"scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.6"
|
||||
@ -535,6 +544,16 @@ dependencies = [
|
||||
"parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot_core"
|
||||
version = "0.4.0"
|
||||
@ -547,6 +566,21 @@ dependencies = [
|
||||
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot_core"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "percent-encoding"
|
||||
version = "1.0.1"
|
||||
@ -677,6 +711,11 @@ dependencies = [
|
||||
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.1.54"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.14"
|
||||
@ -714,6 +753,11 @@ name = "scopeguard"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "scopeguard"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "0.9.0"
|
||||
@ -980,6 +1024,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3ad660d7cb8c5822cd83d10897b0f1f1526792737a179e73896152f85b88c2"
|
||||
"checksum line_drawing 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5cc7ad3d82c845bdb5dde34ffdcc7a5fb4d2996e1e1ee0f19c33bc80e15196b9"
|
||||
"checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c"
|
||||
"checksum lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed946d4529956a20f2d63ebe1b69996d5a2137c91913fe3ebbeff957f5bca7ff"
|
||||
"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6"
|
||||
"checksum malloc_buf 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb"
|
||||
"checksum memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b"
|
||||
@ -991,7 +1036,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum osmesa-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "88cfece6e95d2e717e0872a7f53a8684712ad13822a7979bc760b9c77ec0013b"
|
||||
"checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13"
|
||||
"checksum parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337"
|
||||
"checksum parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa7767817701cce701d5585b9c4db3cdd02086398322c1d7e8bf5094a96a2ce7"
|
||||
"checksum parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9"
|
||||
"checksum parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cb88cb1cb3790baa6776844f968fea3be44956cf184fa1be5a03341f5491278c"
|
||||
"checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831"
|
||||
"checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c"
|
||||
"checksum proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)" = "4d317f9caece796be1980837fd5cb3dfec5613ebdb04ad0956deea83ce168915"
|
||||
@ -1007,11 +1054,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44"
|
||||
"checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c"
|
||||
"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
|
||||
"checksum redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)" = "12229c14a0f65c4f1cb046a3b52047cdd9da1f4b30f8a39c5063c8bae515e252"
|
||||
"checksum rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ccc78bfd5acd7bf3e89cffcf899e5cb1a52d6fafa8dec2739ad70c9577a57288"
|
||||
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
|
||||
"checksum rusttype 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "25951e85bb2647960969f72c559392245a5bd07446a589390bf427dda31cdc4a"
|
||||
"checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267"
|
||||
"checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27"
|
||||
"checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d"
|
||||
"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
|
||||
"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
||||
"checksum shared_library 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5a9e7e0f2bfae24d8a5b5a66c5b257a83c7412304311512a0c054cd5e619da11"
|
||||
|
||||
51
imgui-glium-examples/Cargo.lock
generated
51
imgui-glium-examples/Cargo.lock
generated
@ -371,9 +371,10 @@ dependencies = [
|
||||
name = "imgui"
|
||||
version = "0.0.24-pre"
|
||||
dependencies = [
|
||||
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"imgui-sys 0.0.24-pre",
|
||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -472,6 +473,14 @@ dependencies = [
|
||||
"scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.6"
|
||||
@ -614,6 +623,16 @@ dependencies = [
|
||||
"parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot_core"
|
||||
version = "0.4.0"
|
||||
@ -626,6 +645,21 @@ dependencies = [
|
||||
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot_core"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "percent-encoding"
|
||||
version = "1.0.1"
|
||||
@ -788,6 +822,11 @@ dependencies = [
|
||||
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.1.54"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.14"
|
||||
@ -830,6 +869,11 @@ name = "scopeguard"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "scopeguard"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "0.9.0"
|
||||
@ -1108,6 +1152,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3ad660d7cb8c5822cd83d10897b0f1f1526792737a179e73896152f85b88c2"
|
||||
"checksum line_drawing 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5cc7ad3d82c845bdb5dde34ffdcc7a5fb4d2996e1e1ee0f19c33bc80e15196b9"
|
||||
"checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c"
|
||||
"checksum lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed946d4529956a20f2d63ebe1b69996d5a2137c91913fe3ebbeff957f5bca7ff"
|
||||
"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6"
|
||||
"checksum lzw 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d947cbb889ed21c2a84be6ffbaebf5b4e0f4340638cba0444907e38b56be084"
|
||||
"checksum malloc_buf 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb"
|
||||
@ -1126,7 +1171,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum osmesa-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "88cfece6e95d2e717e0872a7f53a8684712ad13822a7979bc760b9c77ec0013b"
|
||||
"checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13"
|
||||
"checksum parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337"
|
||||
"checksum parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa7767817701cce701d5585b9c4db3cdd02086398322c1d7e8bf5094a96a2ce7"
|
||||
"checksum parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9"
|
||||
"checksum parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cb88cb1cb3790baa6776844f968fea3be44956cf184fa1be5a03341f5491278c"
|
||||
"checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831"
|
||||
"checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c"
|
||||
"checksum png 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9adebf7fb91ccf5eac9da1a8e00e83cb8ae882c3e8d8e4ad59da73cb8c82a2c9"
|
||||
@ -1145,12 +1192,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "373814f27745b2686b350dd261bfd24576a6fb0e2c5919b3a2b6005f820b0473"
|
||||
"checksum rayon-core 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b055d1e92aba6877574d8fe604a63c8b5df60f60e5982bf7ccbb1338ea527356"
|
||||
"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
|
||||
"checksum redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)" = "12229c14a0f65c4f1cb046a3b52047cdd9da1f4b30f8a39c5063c8bae515e252"
|
||||
"checksum rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ccc78bfd5acd7bf3e89cffcf899e5cb1a52d6fafa8dec2739ad70c9577a57288"
|
||||
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
|
||||
"checksum rusttype 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "25951e85bb2647960969f72c559392245a5bd07446a589390bf427dda31cdc4a"
|
||||
"checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267"
|
||||
"checksum scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8"
|
||||
"checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27"
|
||||
"checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d"
|
||||
"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
|
||||
"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
||||
"checksum shared_library 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5a9e7e0f2bfae24d8a5b5a66c5b257a83c7412304311512a0c054cd5e619da11"
|
||||
|
||||
@ -125,96 +125,3 @@ impl ImGuiMouseCursor {
|
||||
ImGuiMouseCursor::Hand,
|
||||
];
|
||||
}
|
||||
|
||||
/// An input identifier for navigation
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub enum ImGuiNavInput {
|
||||
/// activate / open / toggle / tweak value
|
||||
///
|
||||
/// e.g. Cross (PS4), A (Xbox), A (Switch), Space (Keyboard)
|
||||
Activate,
|
||||
/// cancel / close / exit
|
||||
///
|
||||
/// e.g. Circle (PS4), B (Xbox), B (Switch), Escape (Keyboard)
|
||||
Cancel,
|
||||
/// text input / on-screen keyboard
|
||||
///
|
||||
/// e.g. Triang.(PS4), Y (Xbox), X (Switch), Return (Keyboard)
|
||||
Input,
|
||||
/// tap: toggle menu / hold: focus, move, resize
|
||||
///
|
||||
/// e.g. Square (PS4), X (Xbox), Y (Switch), Alt (Keyboard)
|
||||
Menu,
|
||||
/// move / tweak / resize window (w/ PadMenu)
|
||||
///
|
||||
/// e.g. D-pad Left (Gamepads), Left arrow (Keyboard)
|
||||
DpadLeft,
|
||||
/// move / tweak / resize window (w/ PadMenu)
|
||||
///
|
||||
/// e.g. D-pad Right (Gamepads), Right arrow (Keyboard)
|
||||
DpadRight,
|
||||
/// move / tweak / resize window (w/ PadMenu)
|
||||
///
|
||||
/// e.g. D-pad Up (Gamepads), Up arrow (Keyboard)
|
||||
DpadUp,
|
||||
/// move / tweak / resize window (w/ PadMenu)
|
||||
///
|
||||
/// e.g. D-pad Down (Gamepads), Down arrow (Keyboard)
|
||||
DpadDown,
|
||||
/// scroll / move window (w/ PadMenu)
|
||||
///
|
||||
/// e.g. Left Analog Stick Left
|
||||
LStickLeft,
|
||||
/// scroll / move window (w/ PadMenu)
|
||||
///
|
||||
/// e.g. Left Analog Stick Right
|
||||
LStickRight,
|
||||
/// scroll / move window (w/ PadMenu)
|
||||
///
|
||||
/// e.g. Left Analog Stick Up
|
||||
LStickUp,
|
||||
/// scroll / move window (w/ PadMenu)
|
||||
///
|
||||
/// e.g. Left Analog Stick Down
|
||||
LStickDown,
|
||||
/// next window (w/ PadMenu)
|
||||
///
|
||||
/// e.g. L1 or L2 (PS4), LB or LT (Xbox), L or ZL (Switch)
|
||||
FocusPrev,
|
||||
/// prev window (w/ PadMenu)
|
||||
///
|
||||
/// e.g. R1 or R2 (PS4), RB or RT (Xbox), R or ZL (Switch)
|
||||
FocusNext,
|
||||
/// slower tweaks
|
||||
///
|
||||
/// e.g. L1 or L2 (PS4), LB or LT (Xbox), L or ZL (Switch)
|
||||
TweakSlow,
|
||||
/// faster tweaks
|
||||
///
|
||||
/// e.g. R1 or R2 (PS4), RB or RT (Xbox), R or ZL (Switch)
|
||||
TweakFast,
|
||||
}
|
||||
impl ImGuiNavInput {
|
||||
/// All possible `ImGuiNavInput` variants
|
||||
pub const VARIANTS: [ImGuiNavInput; 16] = [
|
||||
ImGuiNavInput::Activate,
|
||||
ImGuiNavInput::Cancel,
|
||||
ImGuiNavInput::Input,
|
||||
ImGuiNavInput::Menu,
|
||||
ImGuiNavInput::DpadLeft,
|
||||
ImGuiNavInput::DpadRight,
|
||||
ImGuiNavInput::DpadUp,
|
||||
ImGuiNavInput::DpadDown,
|
||||
ImGuiNavInput::LStickLeft,
|
||||
ImGuiNavInput::LStickRight,
|
||||
ImGuiNavInput::LStickUp,
|
||||
ImGuiNavInput::LStickDown,
|
||||
ImGuiNavInput::FocusPrev,
|
||||
ImGuiNavInput::FocusNext,
|
||||
ImGuiNavInput::TweakSlow,
|
||||
ImGuiNavInput::TweakFast,
|
||||
];
|
||||
pub const COUNT: usize = 16;
|
||||
pub(crate) const COUNT_INTERNAL: usize = 21;
|
||||
}
|
||||
|
||||
@ -1,19 +1,6 @@
|
||||
use bitflags::bitflags;
|
||||
use std::os::raw::c_int;
|
||||
|
||||
bitflags!(
|
||||
/// Back-end capability flags
|
||||
#[repr(C)]
|
||||
pub struct ImGuiBackendFlags: c_int {
|
||||
/// Back-end supports gamepad and currently has one connected.
|
||||
const HasGamepad = 1;
|
||||
/// Back-end supports honoring GetMouseCursor() value to change the OS cursor shape.
|
||||
const HasMouseCursors = 1 << 1;
|
||||
/// Back-end supports want_set_mouse_pos requests to reposition the OS mouse position.
|
||||
const HasSetMousePos = 1 << 2;
|
||||
}
|
||||
);
|
||||
|
||||
bitflags!(
|
||||
/// Color edit flags
|
||||
#[repr(C)]
|
||||
@ -96,31 +83,6 @@ bitflags!(
|
||||
}
|
||||
);
|
||||
|
||||
bitflags!(
|
||||
/// Configuration flags
|
||||
#[repr(C)]
|
||||
pub struct ImGuiConfigFlags: c_int {
|
||||
/// Master keyboard navigation enable flag.
|
||||
const NavEnableKeyboard = 1;
|
||||
/// Master gamepad navigation enable flag.
|
||||
const NavEnableGamepad = 1 << 1;
|
||||
/// Instruct navigation to move the mouse cursor. May be useful on TV/console systems where
|
||||
/// moving a virtual mouse is awkward.
|
||||
const NavEnableSetMousePos = 1 << 2;
|
||||
/// Instruct navigation to not set the want_capture_keyboard flag when nav_active is set.
|
||||
const NavNoCaptureKeyboard = 1 << 3;
|
||||
/// Instruct imgui to clear mouse position/buttons on a new frame. This allows ignoring the
|
||||
/// mouse information set by the back-end.
|
||||
const NoMouse = 1 << 4;
|
||||
/// Instruct back-end to not alter mouse cursor shape and visibility.
|
||||
const NoMouseCursorChange = 1 << 5;
|
||||
/// Application is SRGB-aware.
|
||||
const IsSRGB = 1 << 20;
|
||||
/// Application is using a touch screen instead of a mouse.
|
||||
const IsTouchScreen = 1 << 21;
|
||||
}
|
||||
);
|
||||
|
||||
bitflags!(
|
||||
/// Flags for igBeginDragDropSource(), igAcceptDragDropPayload()
|
||||
#[repr(C)]
|
||||
|
||||
@ -35,28 +35,42 @@ pub use bindings::{
|
||||
ImFontAtlas_GetGlyphRangesDefault, ImFontAtlas_GetGlyphRangesJapanese,
|
||||
ImFontAtlas_GetGlyphRangesKorean, ImFontAtlas_GetGlyphRangesThai,
|
||||
ImFontAtlas_GetGlyphRangesVietnamese, ImFontAtlas_GetTexDataAsRGBA32, ImFontConfig,
|
||||
ImFontGlyphRangesBuilder, ImGuiCol, ImGuiCol_, ImGuiCol_Border, ImGuiCol_BorderShadow,
|
||||
ImGuiCol_Button, ImGuiCol_ButtonActive, ImGuiCol_ButtonHovered, ImGuiCol_COUNT,
|
||||
ImGuiCol_CheckMark, ImGuiCol_ChildBg, ImGuiCol_DragDropTarget, ImGuiCol_FrameBg,
|
||||
ImGuiCol_FrameBgActive, ImGuiCol_FrameBgHovered, ImGuiCol_Header, ImGuiCol_HeaderActive,
|
||||
ImGuiCol_HeaderHovered, ImGuiCol_MenuBarBg, ImGuiCol_ModalWindowDimBg, ImGuiCol_NavHighlight,
|
||||
ImGuiCol_NavWindowingDimBg, ImGuiCol_NavWindowingHighlight, ImGuiCol_PlotHistogram,
|
||||
ImGuiCol_PlotHistogramHovered, ImGuiCol_PlotLines, ImGuiCol_PlotLinesHovered, ImGuiCol_PopupBg,
|
||||
ImGuiCol_ResizeGrip, ImGuiCol_ResizeGripActive, ImGuiCol_ResizeGripHovered,
|
||||
ImGuiCol_ScrollbarBg, ImGuiCol_ScrollbarGrab, ImGuiCol_ScrollbarGrabActive,
|
||||
ImGuiCol_ScrollbarGrabHovered, ImGuiCol_Separator, ImGuiCol_SeparatorActive,
|
||||
ImGuiCol_SeparatorHovered, ImGuiCol_SliderGrab, ImGuiCol_SliderGrabActive, ImGuiCol_Tab,
|
||||
ImGuiCol_TabActive, ImGuiCol_TabHovered, ImGuiCol_TabUnfocused, ImGuiCol_TabUnfocusedActive,
|
||||
ImGuiCol_Text, ImGuiCol_TextDisabled, ImGuiCol_TextSelectedBg, ImGuiCol_TitleBg,
|
||||
ImGuiCol_TitleBgActive, ImGuiCol_TitleBgCollapsed, ImGuiCol_WindowBg, ImGuiCond, ImGuiCond_,
|
||||
ImGuiCond_Always, ImGuiCond_Appearing, ImGuiCond_FirstUseEver, ImGuiCond_Once, ImGuiContext,
|
||||
ImGuiDir, ImGuiDir_, ImGuiDir_COUNT, ImGuiDir_Down, ImGuiDir_Left, ImGuiDir_None,
|
||||
ImGuiDir_Right, ImGuiDir_Up, ImGuiID, ImGuiIO, ImGuiIO_AddInputCharacter,
|
||||
ImGuiIO_AddInputCharactersUTF8, ImGuiIO_ClearInputCharacters, ImGuiInputTextCallback,
|
||||
ImGuiInputTextCallbackData, ImGuiInputTextCallbackData_DeleteChars,
|
||||
ImGuiInputTextCallbackData_HasSelection, ImGuiInputTextCallbackData_ImGuiInputTextCallbackData,
|
||||
ImGuiInputTextCallbackData_InsertChars, ImGuiInputTextCallbackData_destroy, ImGuiListClipper,
|
||||
ImGuiPayload, ImGuiSizeCallback, ImGuiStorage, ImGuiStyle, ImGuiStyleVar, ImGuiStyleVar_,
|
||||
ImFontGlyphRangesBuilder, ImGuiBackendFlags_, ImGuiBackendFlags_HasGamepad,
|
||||
ImGuiBackendFlags_HasMouseCursors, ImGuiBackendFlags_HasSetMousePos, ImGuiBackendFlags_None,
|
||||
ImGuiBackendFlags_RendererHasVtxOffset, ImGuiCol, ImGuiCol_, ImGuiCol_Border,
|
||||
ImGuiCol_BorderShadow, ImGuiCol_Button, ImGuiCol_ButtonActive, ImGuiCol_ButtonHovered,
|
||||
ImGuiCol_COUNT, ImGuiCol_CheckMark, ImGuiCol_ChildBg, ImGuiCol_DragDropTarget,
|
||||
ImGuiCol_FrameBg, ImGuiCol_FrameBgActive, ImGuiCol_FrameBgHovered, ImGuiCol_Header,
|
||||
ImGuiCol_HeaderActive, ImGuiCol_HeaderHovered, ImGuiCol_MenuBarBg, ImGuiCol_ModalWindowDimBg,
|
||||
ImGuiCol_NavHighlight, ImGuiCol_NavWindowingDimBg, ImGuiCol_NavWindowingHighlight,
|
||||
ImGuiCol_PlotHistogram, ImGuiCol_PlotHistogramHovered, ImGuiCol_PlotLines,
|
||||
ImGuiCol_PlotLinesHovered, ImGuiCol_PopupBg, ImGuiCol_ResizeGrip, ImGuiCol_ResizeGripActive,
|
||||
ImGuiCol_ResizeGripHovered, ImGuiCol_ScrollbarBg, ImGuiCol_ScrollbarGrab,
|
||||
ImGuiCol_ScrollbarGrabActive, ImGuiCol_ScrollbarGrabHovered, ImGuiCol_Separator,
|
||||
ImGuiCol_SeparatorActive, ImGuiCol_SeparatorHovered, ImGuiCol_SliderGrab,
|
||||
ImGuiCol_SliderGrabActive, ImGuiCol_Tab, ImGuiCol_TabActive, ImGuiCol_TabHovered,
|
||||
ImGuiCol_TabUnfocused, ImGuiCol_TabUnfocusedActive, ImGuiCol_Text, ImGuiCol_TextDisabled,
|
||||
ImGuiCol_TextSelectedBg, ImGuiCol_TitleBg, ImGuiCol_TitleBgActive, ImGuiCol_TitleBgCollapsed,
|
||||
ImGuiCol_WindowBg, ImGuiCond, ImGuiCond_, ImGuiCond_Always, ImGuiCond_Appearing,
|
||||
ImGuiCond_FirstUseEver, ImGuiCond_Once, ImGuiConfigFlags_, ImGuiConfigFlags_IsSRGB,
|
||||
ImGuiConfigFlags_IsTouchScreen, ImGuiConfigFlags_NavEnableGamepad,
|
||||
ImGuiConfigFlags_NavEnableKeyboard, ImGuiConfigFlags_NavEnableSetMousePos,
|
||||
ImGuiConfigFlags_NavNoCaptureKeyboard, ImGuiConfigFlags_NoMouse,
|
||||
ImGuiConfigFlags_NoMouseCursorChange, ImGuiConfigFlags_None, ImGuiContext, ImGuiDir, ImGuiDir_,
|
||||
ImGuiDir_COUNT, ImGuiDir_Down, ImGuiDir_Left, ImGuiDir_None, ImGuiDir_Right, ImGuiDir_Up,
|
||||
ImGuiID, ImGuiIO, ImGuiIO_AddInputCharacter, ImGuiIO_AddInputCharactersUTF8,
|
||||
ImGuiIO_ClearInputCharacters, ImGuiInputTextCallback, ImGuiInputTextCallbackData,
|
||||
ImGuiInputTextCallbackData_DeleteChars, ImGuiInputTextCallbackData_HasSelection,
|
||||
ImGuiInputTextCallbackData_ImGuiInputTextCallbackData, ImGuiInputTextCallbackData_InsertChars,
|
||||
ImGuiInputTextCallbackData_destroy, ImGuiKey_COUNT, ImGuiListClipper, ImGuiNavInput_,
|
||||
ImGuiNavInput_Activate, ImGuiNavInput_COUNT, ImGuiNavInput_Cancel, ImGuiNavInput_DpadDown,
|
||||
ImGuiNavInput_DpadLeft, ImGuiNavInput_DpadRight, ImGuiNavInput_DpadUp, ImGuiNavInput_FocusNext,
|
||||
ImGuiNavInput_FocusPrev, ImGuiNavInput_Input, ImGuiNavInput_InternalStart_,
|
||||
ImGuiNavInput_KeyDown_, ImGuiNavInput_KeyLeft_, ImGuiNavInput_KeyMenu_,
|
||||
ImGuiNavInput_KeyRight_, ImGuiNavInput_KeyTab_, ImGuiNavInput_KeyUp_, ImGuiNavInput_LStickDown,
|
||||
ImGuiNavInput_LStickLeft, ImGuiNavInput_LStickRight, ImGuiNavInput_LStickUp,
|
||||
ImGuiNavInput_Menu, ImGuiNavInput_TweakFast, ImGuiNavInput_TweakSlow, ImGuiPayload,
|
||||
ImGuiSizeCallback, ImGuiStorage, ImGuiStyle, ImGuiStyleVar, ImGuiStyleVar_,
|
||||
ImGuiStyleVar_Alpha, ImGuiStyleVar_ButtonTextAlign, ImGuiStyleVar_COUNT,
|
||||
ImGuiStyleVar_ChildBorderSize, ImGuiStyleVar_ChildRounding, ImGuiStyleVar_FrameBorderSize,
|
||||
ImGuiStyleVar_FramePadding, ImGuiStyleVar_FrameRounding, ImGuiStyleVar_GrabMinSize,
|
||||
|
||||
@ -5,6 +5,7 @@ use std::ops::Drop;
|
||||
use std::ptr;
|
||||
use std::rc::Rc;
|
||||
|
||||
use crate::io::Io;
|
||||
use crate::string::{ImStr, ImString};
|
||||
use crate::style::Style;
|
||||
use crate::sys;
|
||||
@ -90,15 +91,15 @@ impl Context {
|
||||
}
|
||||
pub fn ini_filename(&self) -> Option<&ImStr> {
|
||||
let io = self.io();
|
||||
if io.IniFilename.is_null() {
|
||||
if io.ini_filename.is_null() {
|
||||
None
|
||||
} else {
|
||||
unsafe { Some(ImStr::from_ptr_unchecked(io.IniFilename)) }
|
||||
unsafe { Some(ImStr::from_ptr_unchecked(io.ini_filename)) }
|
||||
}
|
||||
}
|
||||
pub fn set_ini_filename<T: Into<Option<ImString>>>(&mut self, ini_filename: T) {
|
||||
let ini_filename = ini_filename.into();
|
||||
self.io_mut().IniFilename = ini_filename
|
||||
self.io_mut().ini_filename = ini_filename
|
||||
.as_ref()
|
||||
.map(|x| x.as_ptr())
|
||||
.unwrap_or(ptr::null());
|
||||
@ -106,15 +107,15 @@ impl Context {
|
||||
}
|
||||
pub fn log_filename(&self) -> Option<&ImStr> {
|
||||
let io = self.io();
|
||||
if io.LogFilename.is_null() {
|
||||
if io.log_filename.is_null() {
|
||||
None
|
||||
} else {
|
||||
unsafe { Some(ImStr::from_ptr_unchecked(io.LogFilename)) }
|
||||
unsafe { Some(ImStr::from_ptr_unchecked(io.log_filename)) }
|
||||
}
|
||||
}
|
||||
pub fn set_log_filename<T: Into<Option<ImString>>>(&mut self, log_filename: T) {
|
||||
let log_filename = log_filename.into();
|
||||
self.io_mut().LogFilename = log_filename
|
||||
self.io_mut().log_filename = log_filename
|
||||
.as_ref()
|
||||
.map(|x| x.as_ptr())
|
||||
.unwrap_or(ptr::null());
|
||||
@ -122,15 +123,15 @@ impl Context {
|
||||
}
|
||||
pub fn platform_name(&self) -> Option<&ImStr> {
|
||||
let io = self.io();
|
||||
if io.BackendPlatformName.is_null() {
|
||||
if io.backend_platform_name.is_null() {
|
||||
None
|
||||
} else {
|
||||
unsafe { Some(ImStr::from_ptr_unchecked(io.BackendPlatformName)) }
|
||||
unsafe { Some(ImStr::from_ptr_unchecked(io.backend_platform_name)) }
|
||||
}
|
||||
}
|
||||
pub fn set_platform_name<T: Into<Option<ImString>>>(&mut self, platform_name: T) {
|
||||
let platform_name = platform_name.into();
|
||||
self.io_mut().BackendPlatformName = platform_name
|
||||
self.io_mut().backend_platform_name = platform_name
|
||||
.as_ref()
|
||||
.map(|x| x.as_ptr())
|
||||
.unwrap_or(ptr::null());
|
||||
@ -138,15 +139,15 @@ impl Context {
|
||||
}
|
||||
pub fn renderer_name(&self) -> Option<&ImStr> {
|
||||
let io = self.io();
|
||||
if io.BackendRendererName.is_null() {
|
||||
if io.backend_renderer_name.is_null() {
|
||||
None
|
||||
} else {
|
||||
unsafe { Some(ImStr::from_ptr_unchecked(io.BackendRendererName)) }
|
||||
unsafe { Some(ImStr::from_ptr_unchecked(io.backend_renderer_name)) }
|
||||
}
|
||||
}
|
||||
pub fn set_renderer_name<T: Into<Option<ImString>>>(&mut self, renderer_name: T) {
|
||||
let renderer_name = renderer_name.into();
|
||||
self.io_mut().BackendRendererName = renderer_name
|
||||
self.io_mut().backend_renderer_name = renderer_name
|
||||
.as_ref()
|
||||
.map(|x| x.as_ptr())
|
||||
.unwrap_or(ptr::null());
|
||||
@ -336,3 +337,34 @@ Collapsed=0";
|
||||
ctx.save_ini_settings(&mut buf);
|
||||
assert_eq!(data.trim(), buf.trim());
|
||||
}
|
||||
|
||||
impl Context {
|
||||
/// Returns an immutable reference to the inputs/outputs object
|
||||
pub fn io(&self) -> &Io {
|
||||
unsafe {
|
||||
// safe because Io is a transparent wrapper around sys::ImGuiIO
|
||||
&*(sys::igGetIO() as *const Io)
|
||||
}
|
||||
}
|
||||
/// Returns a mutable reference to the inputs/outputs object
|
||||
pub fn io_mut(&mut self) -> &mut Io {
|
||||
unsafe {
|
||||
// safe because Io is a transparent wrapper around sys::ImGuiIO
|
||||
&mut *(sys::igGetIO() as *mut Io)
|
||||
}
|
||||
}
|
||||
/// Returns an immutable reference to the user interface style
|
||||
pub fn style(&self) -> &Style {
|
||||
unsafe {
|
||||
// safe because Style is a transparent wrapper around sys::ImGuiStyle
|
||||
&*(sys::igGetStyle() as *const Style)
|
||||
}
|
||||
}
|
||||
/// Returns a mutable reference to the user interface style
|
||||
pub fn style_mut(&mut self) -> &mut Style {
|
||||
unsafe {
|
||||
// safe because Style is a transparent wrapper around sys::ImGuiStyle
|
||||
&mut *(sys::igGetStyle() as *mut Style)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
430
src/io.rs
Normal file
430
src/io.rs
Normal file
@ -0,0 +1,430 @@
|
||||
use bitflags::bitflags;
|
||||
use std::f32;
|
||||
use std::ops::{Index, IndexMut};
|
||||
use std::os::raw::{c_char, c_int, c_void};
|
||||
use std::time::Instant;
|
||||
|
||||
use crate::internal::{ImVector, RawCast};
|
||||
use crate::sys;
|
||||
|
||||
type FontAtlas = sys::ImFontAtlas;
|
||||
type Font = sys::ImFont;
|
||||
|
||||
bitflags! {
|
||||
/// Configuration flags
|
||||
#[repr(transparent)]
|
||||
pub struct ConfigFlags: u32 {
|
||||
/// Master keyboard navigation enable flag.
|
||||
///
|
||||
/// `frame()` will automatically fill `io.nav_inputs` based on `io.keys_down`.
|
||||
const NAV_ENABLE_KEYBOARD = sys::ImGuiConfigFlags_NavEnableKeyboard;
|
||||
/// Master gamepad navigation enable flag.
|
||||
///
|
||||
/// This is mostly to instruct the backend to fill `io.nav_inputs`. The backend
|
||||
/// also needs to set `BackendFlags::HasGamepad`.
|
||||
const NAV_ENABLE_GAMEPAD = sys::ImGuiConfigFlags_NavEnableGamepad;
|
||||
/// Instruction navigation to move the mouse cursor.
|
||||
///
|
||||
/// May be useful on TV/console systems where moving a virtual mouse is awkward.
|
||||
/// Will update `io.mouse_pos` and set `io.want_set_mouse_pos = true`. If enabled,
|
||||
/// you *must* honor `io.want_set_mouse_pos`, or imgui-rs will react as if the mouse is
|
||||
/// jumping around back and forth.
|
||||
const NAV_ENABLE_SET_MOUSE_POS = sys::ImGuiConfigFlags_NavEnableSetMousePos;
|
||||
/// Instruction navigation to not set the `io.want_capture_keyboard` flag when
|
||||
/// `io.nav_active` is set.
|
||||
const NAV_NO_CAPTURE_KEYBOARD = sys::ImGuiConfigFlags_NavNoCaptureKeyboard;
|
||||
/// Instruction imgui-rs to clear mouse position/buttons in `frame()`.
|
||||
///
|
||||
/// This allows ignoring the mouse information set by the backend.
|
||||
const NO_MOUSE = sys::ImGuiConfigFlags_NoMouse;
|
||||
/// Instruction 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
|
||||
/// `set_mouse_cursor` to change the mouse cursor. You may want to honor requests from
|
||||
/// imgui-rs by reading `get_mouse_cursor` yourself instead.
|
||||
const NO_MOUSE_CURSOR_CHANGE = sys::ImGuiConfigFlags_NoMouseCursorChange;
|
||||
/// Application is SRGB-aware.
|
||||
///
|
||||
/// Not used by core imgui-rs.
|
||||
const IS_SRGB = sys::ImGuiConfigFlags_IsSRGB;
|
||||
/// Application is using a touch screen instead of a mouse.
|
||||
///
|
||||
/// Not used by core imgui-rs.
|
||||
const IS_TOUCH_SCREEN = sys::ImGuiConfigFlags_IsTouchScreen;
|
||||
}
|
||||
}
|
||||
|
||||
bitflags! {
|
||||
/// Backend capabilities
|
||||
#[repr(transparent)]
|
||||
pub struct BackendFlags: u32 {
|
||||
/// Backend supports gamepad and currently has one connected
|
||||
const HAS_GAMEPAD = sys::ImGuiBackendFlags_HasGamepad;
|
||||
/// Backend supports honoring `get_mouse_cursor` value to change the OS cursor shape
|
||||
const HAS_MOUSE_CURSORS = sys::ImGuiBackendFlags_HasMouseCursors;
|
||||
/// Backend supports `io.want_set_mouse_pos` requests to reposition the OS mouse position.
|
||||
///
|
||||
/// Only used if `ConfigFlags::NavEnableSetMousePos` is set.
|
||||
const HAS_SET_MOUSE_POS = sys::ImGuiBackendFlags_HasSetMousePos;
|
||||
/// Backend renderer supports DrawCmd::vtx_offset.
|
||||
///
|
||||
/// This enables output of large meshes (64K+ vertices) while still using 16-bits indices.
|
||||
const RENDERER_HAS_VTX_OFFSET = sys::ImGuiBackendFlags_RendererHasVtxOffset;
|
||||
}
|
||||
}
|
||||
|
||||
/// An input identifier for navigation
|
||||
#[repr(u32)]
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
|
||||
pub enum NavInput {
|
||||
Activate = sys::ImGuiNavInput_Activate,
|
||||
Cancel = sys::ImGuiNavInput_Cancel,
|
||||
Input = sys::ImGuiNavInput_Input,
|
||||
Menu = sys::ImGuiNavInput_Menu,
|
||||
DpadLeft = sys::ImGuiNavInput_DpadLeft,
|
||||
DpadRight = sys::ImGuiNavInput_DpadRight,
|
||||
DpadUp = sys::ImGuiNavInput_DpadUp,
|
||||
DpadDown = sys::ImGuiNavInput_DpadDown,
|
||||
LStickLeft = sys::ImGuiNavInput_LStickLeft,
|
||||
LStickRight = sys::ImGuiNavInput_LStickRight,
|
||||
LStickUp = sys::ImGuiNavInput_LStickUp,
|
||||
LStickDown = sys::ImGuiNavInput_LStickDown,
|
||||
FocusPrev = sys::ImGuiNavInput_FocusPrev,
|
||||
FocusNext = sys::ImGuiNavInput_FocusNext,
|
||||
TweakSlow = sys::ImGuiNavInput_TweakSlow,
|
||||
TweakFast = sys::ImGuiNavInput_TweakFast,
|
||||
}
|
||||
|
||||
impl NavInput {
|
||||
/// All possible `NavInput` variants
|
||||
pub const VARIANTS: [NavInput; NavInput::COUNT] = [
|
||||
NavInput::Activate,
|
||||
NavInput::Cancel,
|
||||
NavInput::Input,
|
||||
NavInput::Menu,
|
||||
NavInput::DpadLeft,
|
||||
NavInput::DpadRight,
|
||||
NavInput::DpadUp,
|
||||
NavInput::DpadDown,
|
||||
NavInput::LStickLeft,
|
||||
NavInput::LStickRight,
|
||||
NavInput::LStickUp,
|
||||
NavInput::LStickDown,
|
||||
NavInput::FocusPrev,
|
||||
NavInput::FocusNext,
|
||||
NavInput::TweakSlow,
|
||||
NavInput::TweakFast,
|
||||
];
|
||||
/// Amount of internal/hidden variants (not exposed by imgui-rs)
|
||||
const INTERNAL_COUNT: usize = 6;
|
||||
/// Total count of `NavInput` variants
|
||||
pub const COUNT: usize = sys::ImGuiNavInput_COUNT as usize - NavInput::INTERNAL_COUNT;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_nav_input_variants() {
|
||||
for (idx, &value) in NavInput::VARIANTS.iter().enumerate() {
|
||||
assert_eq!(idx, value as usize);
|
||||
}
|
||||
}
|
||||
|
||||
/// Settings and inputs/outputs for imgui-rs
|
||||
#[repr(C)]
|
||||
pub struct Io {
|
||||
/// Flags set by user/application
|
||||
pub config_flags: ConfigFlags,
|
||||
/// Flags set by backend
|
||||
pub backend_flags: BackendFlags,
|
||||
/// Main display size in pixels
|
||||
pub display_size: [f32; 2],
|
||||
/// Time elapsed since last frame, in seconds
|
||||
pub delta_time: f32,
|
||||
/// Minimum time between saving positions/sizes to .ini file, in seconds
|
||||
pub ini_saving_rate: f32,
|
||||
|
||||
pub(crate) ini_filename: *const c_char,
|
||||
pub(crate) log_filename: *const c_char,
|
||||
|
||||
/// Time for a double-click, in seconds
|
||||
pub mouse_double_click_time: f32,
|
||||
/// Distance threshold to stay in to validate a double-click, in pixels
|
||||
pub mouse_double_click_max_dist: f32,
|
||||
/// Distance threshold before considering we are dragging
|
||||
pub mouse_drag_threshold: f32,
|
||||
/// Map of indices into the `keys_down` entries array, which represent your "native" keyboard
|
||||
/// state
|
||||
pub key_map: [u32; sys::ImGuiKey_COUNT as usize],
|
||||
/// When holding a key/button, time before it starts repeating, in seconds
|
||||
pub key_repeat_delay: f32,
|
||||
/// When holding a key/button, rate at which it repeats, in seconds
|
||||
pub key_repeat_rate: f32,
|
||||
|
||||
user_data: *mut c_void,
|
||||
pub(crate) fonts: *mut FontAtlas,
|
||||
|
||||
/// Global scale for all fonts
|
||||
pub font_global_scale: f32,
|
||||
/// Allow user to scale text of individual window with CTRL+wheel
|
||||
pub font_allow_user_scaling: bool,
|
||||
|
||||
pub(crate) font_default: *mut Font,
|
||||
|
||||
/// For retina display or other situations where window coordinates are different from
|
||||
/// framebuffer coordinates
|
||||
pub display_framebuffer_scale: [f32; 2],
|
||||
|
||||
/// Request imgui-rs to draw a mouse cursor for you
|
||||
pub mouse_draw_cursor: bool,
|
||||
/// macOS-style input behavior.
|
||||
///
|
||||
/// Defaults to true on Apple platforms. Changes in behavior:
|
||||
///
|
||||
/// * 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 the whole text
|
||||
/// * Multi-selection in lists uses Cmd/Super instead of Ctrl
|
||||
pub config_mac_os_behaviors: bool,
|
||||
/// Set to false to disable blinking cursor
|
||||
pub config_input_text_cursor_blink: bool,
|
||||
/// Enable resizing of windows from their edges and from the lower-left corner.
|
||||
///
|
||||
/// Requires `HasMouserCursors` in `backend_flags`, because it needs mouse cursor feedback.
|
||||
pub config_windows_resize_from_edges: bool,
|
||||
/// Set to true to only allow moving windows when clicked+dragged from the title bar.
|
||||
///
|
||||
/// Windows without a title bar are not affected.
|
||||
pub config_windows_move_from_title_bar_only: bool,
|
||||
|
||||
pub(crate) backend_platform_name: *const c_char,
|
||||
pub(crate) backend_renderer_name: *const c_char,
|
||||
backend_platform_user_data: *mut c_void,
|
||||
backend_renderer_user_data: *mut c_void,
|
||||
backend_language_user_data: *mut c_void,
|
||||
pub(crate) get_clipboard_text_fn:
|
||||
Option<unsafe extern "C" fn(user_data: *mut c_void) -> *const c_char>,
|
||||
pub(crate) set_clipboard_text_fn:
|
||||
Option<unsafe extern "C" fn(user_data: *mut c_void, text: *const c_char)>,
|
||||
pub(crate) clipboard_user_data: *mut c_void,
|
||||
ime_set_input_screen_pos_fn: Option<unsafe extern "C" fn(x: c_int, y: c_int)>,
|
||||
ime_window_handle: *mut c_void,
|
||||
render_draw_lists_fn_unused: *mut c_void,
|
||||
|
||||
/// Mouse position, in pixels.
|
||||
///
|
||||
/// Set to [f32::MAX, f32::MAX] if mouse is unavailable (on another screen, etc.).
|
||||
pub mouse_pos: [f32; 2],
|
||||
/// Mouse buttons: 0=left, 1=right, 2=middle + extras
|
||||
pub mouse_down: [bool; 5],
|
||||
/// Mouse wheel (vertical).
|
||||
///
|
||||
/// 1 unit scrolls about 5 lines of text.
|
||||
pub mouse_wheel: f32,
|
||||
/// Mouse wheel (horizontal).
|
||||
///
|
||||
/// Most users don't have a mouse with a horizontal wheel, and may not be filled by all
|
||||
/// backends.
|
||||
pub mouse_wheel_h: f32,
|
||||
/// Keyboard modifier pressed: Control
|
||||
pub key_ctrl: bool,
|
||||
/// Keyboard modifier pressed: Shift
|
||||
pub key_shift: bool,
|
||||
/// Keyboard modifier pressed: Alt
|
||||
pub key_alt: bool,
|
||||
/// Keyboard modifier pressed: Cmd/Super/Windows
|
||||
pub key_super: bool,
|
||||
/// Keyboard keys that are pressed (indexing defined by the user/application)
|
||||
pub keys_down: [bool; 512],
|
||||
/// Gamepad inputs.
|
||||
///
|
||||
/// Cleared back to zero after each frame. Keyboard keys will be auto-mapped and written
|
||||
/// here by `frame()`.
|
||||
pub nav_inputs: [f32; NavInput::COUNT + NavInput::INTERNAL_COUNT],
|
||||
/// When true, imgui-rs will use the mouse inputs, so do not dispatch them to your main
|
||||
/// game/application
|
||||
pub want_capture_mouse: bool,
|
||||
/// When true, imgui-rs will use the keyboard inputs, so do not dispatch them to your main
|
||||
/// game/application
|
||||
pub want_capture_keyboard: bool,
|
||||
/// Mobile/console: when true, you may display an on-screen keyboard.
|
||||
///
|
||||
/// This is set by imgui-rs when it wants textual keyboard input to happen.
|
||||
pub want_text_input: bool,
|
||||
/// Mouse position has been altered, so the backend should reposition the mouse on the next
|
||||
/// frame.
|
||||
///
|
||||
/// Set only when `ConfigFlags::NavEnableSetMousePos` is enabled.
|
||||
pub want_set_mouse_pos: bool,
|
||||
/// When manual .ini load/save is active (`ini_filename` is `None`), this will be set to notify
|
||||
/// your application that you can call `save_ini_settings` and save the settings yourself.
|
||||
///
|
||||
/// *Important*: You need to clear this flag yourself
|
||||
pub want_save_ini_settings: bool,
|
||||
/// Directional navigation is currently allowed
|
||||
pub nav_active: bool,
|
||||
/// Directional navigation is visible and allowed
|
||||
pub nav_visible: bool,
|
||||
/// Application framerate estimation, in frames per second.
|
||||
///
|
||||
/// Rolling average estimation based on `io.delta_time` over 120 frames.
|
||||
pub framerate: f32,
|
||||
/// Vertices output during last rendering
|
||||
pub metrics_render_vertices: i32,
|
||||
/// Indices output during last rendering (= number of triangles * 3)
|
||||
pub metrics_render_indices: i32,
|
||||
/// Number of visible windows
|
||||
pub metrics_render_windows: i32,
|
||||
/// Number of active windows
|
||||
pub metrics_active_windows: i32,
|
||||
/// Number of active internal imgui-rs allocations
|
||||
pub metrics_active_allocations: i32,
|
||||
/// Mouse delta.
|
||||
///
|
||||
/// Note that this is zero if either current or previous position is invalid ([f32::MAX,
|
||||
/// f32::MAX]), so a disappearing/reappearing mouse won't have a huge delta.
|
||||
pub mouse_delta: [f32; 2],
|
||||
|
||||
mouse_pos_prev: [f32; 2],
|
||||
mouse_clicked_pos: [[f32; 2]; 5],
|
||||
mouse_clicked_time: [f64; 5],
|
||||
mouse_clicked: [bool; 5],
|
||||
mouse_double_clicked: [bool; 5],
|
||||
mouse_released: [bool; 5],
|
||||
mouse_down_owned: [bool; 5],
|
||||
mouse_down_was_double_click: [bool; 5],
|
||||
mouse_down_duration: [f32; 5],
|
||||
mouse_down_duration_prev: [f32; 5],
|
||||
mouse_drag_max_distance_abs: [[f32; 2]; 5],
|
||||
mouse_drag_max_distance_sqr: [f32; 5],
|
||||
keys_down_duration: [f32; 512],
|
||||
keys_down_duration_prev: [f32; 512],
|
||||
nav_inputs_down_duration: [f32; NavInput::COUNT + NavInput::INTERNAL_COUNT],
|
||||
nav_inputs_down_duration_prev: [f32; NavInput::COUNT + NavInput::INTERNAL_COUNT],
|
||||
input_queue_characters: ImVector<sys::ImWchar>,
|
||||
}
|
||||
|
||||
unsafe impl RawCast<sys::ImGuiIO> for Io {}
|
||||
|
||||
impl Io {
|
||||
/// Queue new character input
|
||||
pub fn add_input_character(&mut self, character: char) {
|
||||
let mut buf = [0; 5];
|
||||
character.encode_utf8(&mut buf);
|
||||
unsafe {
|
||||
sys::ImGuiIO_AddInputCharactersUTF8(self.raw_mut(), buf.as_ptr() as *const _);
|
||||
}
|
||||
}
|
||||
/// Clear character input buffer
|
||||
pub fn clear_input_characters(&mut self) {
|
||||
unsafe {
|
||||
sys::ImGuiIO_ClearInputCharacters(self.raw_mut());
|
||||
}
|
||||
}
|
||||
pub fn update_delta_time(&mut self, previous: Instant) -> Instant {
|
||||
let now = Instant::now();
|
||||
let delta = now - previous;
|
||||
let delta_s = delta.as_secs() as f32 + delta.subsec_nanos() as f32 / 1_000_000_000.0;
|
||||
if delta_s > 0.0 {
|
||||
self.delta_time = delta_s;
|
||||
} else {
|
||||
self.delta_time = f32::MIN_POSITIVE;
|
||||
}
|
||||
self.delta_time = delta_s;
|
||||
now
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_io_memory_layout() {
|
||||
use std::mem;
|
||||
assert_eq!(mem::size_of::<Io>(), mem::size_of::<sys::ImGuiIO>());
|
||||
assert_eq!(mem::align_of::<Io>(), mem::align_of::<sys::ImGuiIO>());
|
||||
use memoffset::offset_of;
|
||||
macro_rules! assert_field_offset {
|
||||
($l:ident, $r:ident) => {
|
||||
assert_eq!(offset_of!(Io, $l), offset_of!(sys::ImGuiIO, $r));
|
||||
};
|
||||
};
|
||||
assert_field_offset!(config_flags, ConfigFlags);
|
||||
assert_field_offset!(backend_flags, BackendFlags);
|
||||
assert_field_offset!(display_size, DisplaySize);
|
||||
assert_field_offset!(delta_time, DeltaTime);
|
||||
assert_field_offset!(ini_saving_rate, IniSavingRate);
|
||||
assert_field_offset!(ini_filename, IniFilename);
|
||||
assert_field_offset!(log_filename, LogFilename);
|
||||
assert_field_offset!(mouse_double_click_time, MouseDoubleClickTime);
|
||||
assert_field_offset!(mouse_double_click_max_dist, MouseDoubleClickMaxDist);
|
||||
assert_field_offset!(mouse_drag_threshold, MouseDragThreshold);
|
||||
assert_field_offset!(key_map, KeyMap);
|
||||
assert_field_offset!(key_repeat_delay, KeyRepeatDelay);
|
||||
assert_field_offset!(key_repeat_rate, KeyRepeatRate);
|
||||
assert_field_offset!(user_data, UserData);
|
||||
assert_field_offset!(fonts, Fonts);
|
||||
assert_field_offset!(font_global_scale, FontGlobalScale);
|
||||
assert_field_offset!(font_allow_user_scaling, FontAllowUserScaling);
|
||||
assert_field_offset!(font_default, FontDefault);
|
||||
assert_field_offset!(display_framebuffer_scale, DisplayFramebufferScale);
|
||||
assert_field_offset!(mouse_draw_cursor, MouseDrawCursor);
|
||||
assert_field_offset!(config_mac_os_behaviors, ConfigMacOSXBehaviors);
|
||||
assert_field_offset!(config_input_text_cursor_blink, ConfigInputTextCursorBlink);
|
||||
assert_field_offset!(
|
||||
config_windows_resize_from_edges,
|
||||
ConfigWindowsResizeFromEdges
|
||||
);
|
||||
assert_field_offset!(
|
||||
config_windows_move_from_title_bar_only,
|
||||
ConfigWindowsMoveFromTitleBarOnly
|
||||
);
|
||||
assert_field_offset!(backend_platform_name, BackendPlatformName);
|
||||
assert_field_offset!(backend_renderer_name, BackendRendererName);
|
||||
assert_field_offset!(backend_platform_user_data, BackendPlatformUserData);
|
||||
assert_field_offset!(backend_renderer_user_data, BackendRendererUserData);
|
||||
assert_field_offset!(backend_language_user_data, BackendLanguageUserData);
|
||||
assert_field_offset!(get_clipboard_text_fn, GetClipboardTextFn);
|
||||
assert_field_offset!(set_clipboard_text_fn, SetClipboardTextFn);
|
||||
assert_field_offset!(clipboard_user_data, ClipboardUserData);
|
||||
assert_field_offset!(ime_set_input_screen_pos_fn, ImeSetInputScreenPosFn);
|
||||
assert_field_offset!(ime_window_handle, ImeWindowHandle);
|
||||
assert_field_offset!(render_draw_lists_fn_unused, RenderDrawListsFnUnused);
|
||||
assert_field_offset!(mouse_pos, MousePos);
|
||||
assert_field_offset!(mouse_down, MouseDown);
|
||||
assert_field_offset!(mouse_wheel, MouseWheel);
|
||||
assert_field_offset!(mouse_wheel_h, MouseWheelH);
|
||||
assert_field_offset!(key_ctrl, KeyCtrl);
|
||||
assert_field_offset!(key_shift, KeyShift);
|
||||
assert_field_offset!(key_alt, KeyAlt);
|
||||
assert_field_offset!(key_super, KeySuper);
|
||||
assert_field_offset!(keys_down, KeysDown);
|
||||
assert_field_offset!(nav_inputs, NavInputs);
|
||||
assert_field_offset!(want_capture_mouse, WantCaptureMouse);
|
||||
assert_field_offset!(want_capture_keyboard, WantCaptureKeyboard);
|
||||
assert_field_offset!(want_text_input, WantTextInput);
|
||||
assert_field_offset!(want_set_mouse_pos, WantSetMousePos);
|
||||
assert_field_offset!(want_save_ini_settings, WantSaveIniSettings);
|
||||
assert_field_offset!(nav_active, NavActive);
|
||||
assert_field_offset!(nav_visible, NavVisible);
|
||||
assert_field_offset!(framerate, Framerate);
|
||||
assert_field_offset!(metrics_render_vertices, MetricsRenderVertices);
|
||||
assert_field_offset!(metrics_render_indices, MetricsRenderIndices);
|
||||
assert_field_offset!(metrics_render_windows, MetricsRenderWindows);
|
||||
assert_field_offset!(metrics_active_windows, MetricsActiveWindows);
|
||||
assert_field_offset!(metrics_active_allocations, MetricsActiveAllocations);
|
||||
assert_field_offset!(mouse_delta, MouseDelta);
|
||||
assert_field_offset!(mouse_pos_prev, MousePosPrev);
|
||||
assert_field_offset!(mouse_clicked_pos, MouseClickedPos);
|
||||
assert_field_offset!(mouse_clicked_time, MouseClickedTime);
|
||||
assert_field_offset!(mouse_clicked, MouseClicked);
|
||||
assert_field_offset!(mouse_double_clicked, MouseDoubleClicked);
|
||||
assert_field_offset!(mouse_released, MouseReleased);
|
||||
assert_field_offset!(mouse_down_owned, MouseDownOwned);
|
||||
assert_field_offset!(mouse_down_was_double_click, MouseDownWasDoubleClick);
|
||||
assert_field_offset!(mouse_down_duration, MouseDownDuration);
|
||||
assert_field_offset!(mouse_down_duration_prev, MouseDownDurationPrev);
|
||||
assert_field_offset!(mouse_drag_max_distance_abs, MouseDragMaxDistanceAbs);
|
||||
assert_field_offset!(mouse_drag_max_distance_sqr, MouseDragMaxDistanceSqr);
|
||||
assert_field_offset!(keys_down_duration, KeysDownDuration);
|
||||
assert_field_offset!(keys_down_duration_prev, KeysDownDurationPrev);
|
||||
assert_field_offset!(nav_inputs_down_duration, NavInputsDownDuration);
|
||||
assert_field_offset!(nav_inputs_down_duration_prev, NavInputsDownDurationPrev);
|
||||
assert_field_offset!(input_queue_characters, InputQueueCharacters);
|
||||
}
|
||||
101
src/lib.rs
101
src/lib.rs
@ -26,6 +26,7 @@ pub use self::input::{
|
||||
InputFloat, InputFloat2, InputFloat3, InputFloat4, InputInt, InputInt2, InputInt3, InputInt4,
|
||||
InputText, InputTextMultiline,
|
||||
};
|
||||
pub use self::io::*;
|
||||
pub use self::menus::{Menu, MenuItem};
|
||||
pub use self::plothistogram::PlotHistogram;
|
||||
pub use self::plotlines::PlotLines;
|
||||
@ -55,6 +56,7 @@ mod fonts;
|
||||
mod image;
|
||||
mod input;
|
||||
mod internal;
|
||||
mod io;
|
||||
mod menus;
|
||||
mod plothistogram;
|
||||
mod plotlines;
|
||||
@ -108,20 +110,8 @@ impl FrameSize {
|
||||
}
|
||||
|
||||
impl Context {
|
||||
fn io(&self) -> &sys::ImGuiIO {
|
||||
unsafe { &*sys::igGetIO() }
|
||||
}
|
||||
fn io_mut(&mut self) -> &mut sys::ImGuiIO {
|
||||
unsafe { &mut *sys::igGetIO() }
|
||||
}
|
||||
pub fn style(&self) -> &Style {
|
||||
unsafe { Style::from_raw(&*sys::igGetStyle()) }
|
||||
}
|
||||
pub fn style_mut(&mut self) -> &mut Style {
|
||||
unsafe { Style::from_raw_mut(&mut *sys::igGetStyle()) }
|
||||
}
|
||||
pub fn fonts(&mut self) -> ImFontAtlas {
|
||||
unsafe { ImFontAtlas::from_ptr(self.io_mut().Fonts) }
|
||||
unsafe { ImFontAtlas::from_ptr(self.io_mut().fonts) }
|
||||
}
|
||||
pub fn prepare_texture<'a, F, T>(&mut self, f: F) -> T
|
||||
where
|
||||
@ -134,7 +124,7 @@ impl Context {
|
||||
let mut bytes_per_pixel: c_int = 0;
|
||||
unsafe {
|
||||
sys::ImFontAtlas_GetTexDataAsRGBA32(
|
||||
io.Fonts,
|
||||
io.fonts,
|
||||
&mut pixels,
|
||||
&mut width,
|
||||
&mut height,
|
||||
@ -152,70 +142,69 @@ impl Context {
|
||||
}
|
||||
pub fn set_ini_saving_rate(&mut self, value: f32) {
|
||||
let io = self.io_mut();
|
||||
io.IniSavingRate = value;
|
||||
io.ini_saving_rate = value;
|
||||
}
|
||||
pub fn set_font_global_scale(&mut self, value: f32) {
|
||||
let io = self.io_mut();
|
||||
io.FontGlobalScale = value;
|
||||
io.font_global_scale = value;
|
||||
}
|
||||
pub fn set_mouse_double_click_time(&mut self, value: f32) {
|
||||
let io = self.io_mut();
|
||||
io.MouseDoubleClickTime = value;
|
||||
io.mouse_double_click_time = value;
|
||||
}
|
||||
pub fn set_mouse_double_click_max_dist(&mut self, value: f32) {
|
||||
let io = self.io_mut();
|
||||
io.MouseDoubleClickMaxDist = value;
|
||||
io.mouse_double_click_max_dist = value;
|
||||
}
|
||||
pub fn set_mouse_drag_threshold(&mut self, value: f32) {
|
||||
let io = self.io_mut();
|
||||
io.MouseDragThreshold = value;
|
||||
io.mouse_drag_threshold = value;
|
||||
}
|
||||
pub fn set_key_repeat_delay(&mut self, value: f32) {
|
||||
let io = self.io_mut();
|
||||
io.KeyRepeatDelay = value;
|
||||
io.key_repeat_delay = value;
|
||||
}
|
||||
pub fn set_key_repeat_rate(&mut self, value: f32) {
|
||||
let io = self.io_mut();
|
||||
io.KeyRepeatRate = value;
|
||||
io.key_repeat_rate = value;
|
||||
}
|
||||
pub fn display_size(&self) -> (f32, f32) {
|
||||
let io = self.io();
|
||||
(io.DisplaySize.x, io.DisplaySize.y)
|
||||
(io.display_size[0], io.display_size[1])
|
||||
}
|
||||
pub fn display_framebuffer_scale(&self) -> (f32, f32) {
|
||||
let io = self.io();
|
||||
(io.DisplayFramebufferScale.x, io.DisplayFramebufferScale.y)
|
||||
(io.display_framebuffer_scale[0], io.display_framebuffer_scale[1])
|
||||
}
|
||||
pub fn mouse_pos(&self) -> (f32, f32) {
|
||||
let io = self.io();
|
||||
(io.MousePos.x, io.MousePos.y)
|
||||
(io.mouse_pos[0], io.mouse_pos[1])
|
||||
}
|
||||
pub fn set_mouse_pos(&mut self, x: f32, y: f32) {
|
||||
let io = self.io_mut();
|
||||
io.MousePos.x = x;
|
||||
io.MousePos.y = y;
|
||||
io.mouse_pos = [x, y];
|
||||
}
|
||||
/// Get mouse's position's delta between the current and the last frame.
|
||||
pub fn mouse_delta(&self) -> (f32, f32) {
|
||||
let io = self.io();
|
||||
(io.MouseDelta.x, io.MouseDelta.y)
|
||||
(io.mouse_delta[0], io.mouse_delta[1])
|
||||
}
|
||||
pub fn mouse_down(&self) -> [bool; 5] {
|
||||
let io = self.io();
|
||||
io.MouseDown
|
||||
io.mouse_down
|
||||
}
|
||||
pub fn set_mouse_down(&mut self, states: [bool; 5]) {
|
||||
let io = self.io_mut();
|
||||
io.MouseDown = states;
|
||||
io.mouse_down = states;
|
||||
}
|
||||
pub fn set_mouse_wheel(&mut self, value: f32) {
|
||||
let io = self.io_mut();
|
||||
io.MouseWheel = value;
|
||||
io.mouse_wheel = value;
|
||||
}
|
||||
/// Get mouse wheel delta
|
||||
pub fn mouse_wheel(&self) -> f32 {
|
||||
let io = self.io();
|
||||
io.MouseWheel
|
||||
io.mouse_wheel
|
||||
}
|
||||
pub fn mouse_drag_delta(&self, button: ImMouseButton) -> (f32, f32) {
|
||||
let delta = unsafe { sys::igGetMouseDragDelta_nonUDT2(button as c_int, -1.0) };
|
||||
@ -225,11 +214,11 @@ impl Context {
|
||||
/// If `false`, the OS cursor is used (default to `false`).
|
||||
pub fn set_mouse_draw_cursor(&mut self, value: bool) {
|
||||
let io = self.io_mut();
|
||||
io.MouseDrawCursor = value;
|
||||
io.mouse_draw_cursor = value;
|
||||
}
|
||||
pub fn mouse_draw_cursor(&self) -> bool {
|
||||
let io = self.io();
|
||||
io.MouseDrawCursor
|
||||
io.mouse_draw_cursor
|
||||
}
|
||||
/// Set currently displayed cursor.
|
||||
/// Requires support in the windowing back-end if OS cursor is used.
|
||||
@ -267,43 +256,43 @@ impl Context {
|
||||
}
|
||||
pub fn key_ctrl(&self) -> bool {
|
||||
let io = self.io();
|
||||
io.KeyCtrl
|
||||
io.key_ctrl
|
||||
}
|
||||
pub fn set_key_ctrl(&mut self, value: bool) {
|
||||
let io = self.io_mut();
|
||||
io.KeyCtrl = value;
|
||||
io.key_ctrl = value;
|
||||
}
|
||||
pub fn key_shift(&self) -> bool {
|
||||
let io = self.io();
|
||||
io.KeyShift
|
||||
io.key_shift
|
||||
}
|
||||
pub fn set_key_shift(&mut self, value: bool) {
|
||||
let io = self.io_mut();
|
||||
io.KeyShift = value;
|
||||
io.key_shift = value;
|
||||
}
|
||||
pub fn key_alt(&self) -> bool {
|
||||
let io = self.io();
|
||||
io.KeyAlt
|
||||
io.key_alt
|
||||
}
|
||||
pub fn set_key_alt(&mut self, value: bool) {
|
||||
let io = self.io_mut();
|
||||
io.KeyAlt = value;
|
||||
io.key_alt = value;
|
||||
}
|
||||
pub fn key_super(&self) -> bool {
|
||||
let io = self.io();
|
||||
io.KeySuper
|
||||
io.key_super
|
||||
}
|
||||
pub fn set_key_super(&mut self, value: bool) {
|
||||
let io = self.io_mut();
|
||||
io.KeySuper = value;
|
||||
io.key_super = value;
|
||||
}
|
||||
pub fn set_key(&mut self, key: u8, pressed: bool) {
|
||||
let io = self.io_mut();
|
||||
io.KeysDown[key as usize] = pressed;
|
||||
io.keys_down[key as usize] = pressed;
|
||||
}
|
||||
pub fn set_imgui_key(&mut self, key: ImGuiKey, mapping: u8) {
|
||||
let io = self.io_mut();
|
||||
io.KeyMap[key as usize] = i32::from(mapping);
|
||||
io.key_map[key as usize] = u32::from(mapping);
|
||||
}
|
||||
/// Map [`ImGuiKey`] values into user's key index
|
||||
pub fn get_key_index(&self, key: ImGuiKey) -> usize {
|
||||
@ -338,7 +327,7 @@ impl Context {
|
||||
let mut buf = [0; 5];
|
||||
character.encode_utf8(&mut buf);
|
||||
unsafe {
|
||||
sys::ImGuiIO_AddInputCharactersUTF8(self.io_mut(), buf.as_ptr() as *const _);
|
||||
sys::ImGuiIO_AddInputCharactersUTF8(self.io_mut().raw_mut(), buf.as_ptr() as *const _);
|
||||
}
|
||||
}
|
||||
pub fn get_time(&self) -> f64 {
|
||||
@ -348,16 +337,16 @@ impl Context {
|
||||
unsafe { sys::igGetFrameCount() }
|
||||
}
|
||||
pub fn get_frame_rate(&self) -> f32 {
|
||||
self.io().Framerate
|
||||
self.io().framerate
|
||||
}
|
||||
pub fn frame<'ui, 'a: 'ui>(&'a mut self, frame_size: FrameSize, delta_time: f32) -> Ui<'ui> {
|
||||
{
|
||||
let io = self.io_mut();
|
||||
io.DisplaySize.x = frame_size.logical_size.0 as c_float;
|
||||
io.DisplaySize.y = frame_size.logical_size.1 as c_float;
|
||||
io.DisplayFramebufferScale.x = frame_size.hidpi_factor as c_float;
|
||||
io.DisplayFramebufferScale.y = frame_size.hidpi_factor as c_float;
|
||||
io.DeltaTime = delta_time;
|
||||
io.display_size[0] = frame_size.logical_size.0 as c_float;
|
||||
io.display_size[1] = frame_size.logical_size.1 as c_float;
|
||||
io.display_framebuffer_scale[0] = frame_size.hidpi_factor as c_float;
|
||||
io.display_framebuffer_scale[1] = frame_size.hidpi_factor as c_float;
|
||||
io.delta_time = delta_time;
|
||||
}
|
||||
unsafe {
|
||||
sys::igNewFrame();
|
||||
@ -465,11 +454,11 @@ impl<'ui> Ui<'ui> {
|
||||
}
|
||||
pub fn want_capture_mouse(&self) -> bool {
|
||||
let io = self.imgui.io();
|
||||
io.WantCaptureMouse
|
||||
io.want_capture_mouse
|
||||
}
|
||||
pub fn want_capture_keyboard(&self) -> bool {
|
||||
let io = self.imgui.io();
|
||||
io.WantCaptureKeyboard
|
||||
io.want_capture_keyboard
|
||||
}
|
||||
pub fn set_keyboard_focus_here(&self, offset: i32) {
|
||||
unsafe {
|
||||
@ -478,19 +467,19 @@ impl<'ui> Ui<'ui> {
|
||||
}
|
||||
pub fn framerate(&self) -> f32 {
|
||||
let io = self.imgui.io();
|
||||
io.Framerate
|
||||
io.framerate
|
||||
}
|
||||
pub fn metrics_render_vertices(&self) -> i32 {
|
||||
let io = self.imgui.io();
|
||||
io.MetricsRenderVertices
|
||||
io.metrics_render_vertices
|
||||
}
|
||||
pub fn metrics_render_indices(&self) -> i32 {
|
||||
let io = self.imgui.io();
|
||||
io.MetricsRenderIndices
|
||||
io.metrics_render_indices
|
||||
}
|
||||
pub fn metrics_active_windows(&self) -> i32 {
|
||||
let io = self.imgui.io();
|
||||
io.MetricsActiveWindows
|
||||
io.metrics_active_windows
|
||||
}
|
||||
pub fn render<F, E>(self, f: F) -> Result<(), E>
|
||||
where
|
||||
|
||||
@ -10,6 +10,6 @@ lazy_static! {
|
||||
pub fn test_ctx() -> (ReentrantMutexGuard<'static, ()>, Context) {
|
||||
let guard = TEST_MUTEX.lock();
|
||||
let mut ctx = Context::create();
|
||||
ctx.io_mut().IniFilename = ptr::null();
|
||||
ctx.io_mut().ini_filename = ptr::null();
|
||||
(guard, ctx)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user