Updates for Kludgine text refactor

This commit is contained in:
Jonathan Johnson 2023-10-27 14:23:42 -07:00
parent 5b94d37b6f
commit 90593e1938
No known key found for this signature in database
GPG key ID: A66D6A34D6620579
4 changed files with 174 additions and 81 deletions

226
Cargo.lock generated
View file

@ -447,7 +447,7 @@ dependencies = [
[[package]] [[package]]
name = "figures" name = "figures"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/khonsulabs/figures#825e46a75e6897638f5a02cc1f47ea62a4ef6e7e" source = "git+https://github.com/khonsulabs/figures#5b00ee6772e8b59067bc69f2f4eeb06cc0cc62b7"
dependencies = [ dependencies = [
"bytemuck", "bytemuck",
"euclid", "euclid",
@ -464,6 +464,18 @@ dependencies = [
"num-traits", "num-traits",
] ]
[[package]]
name = "flume"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181"
dependencies = [
"futures-core",
"futures-sink",
"nanorand",
"spin",
]
[[package]] [[package]]
name = "fnv" name = "fnv"
version = "1.0.7" version = "1.0.7"
@ -535,6 +547,18 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b"
[[package]]
name = "futures-core"
version = "0.3.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c"
[[package]]
name = "futures-sink"
version = "0.3.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817"
[[package]] [[package]]
name = "gethostname" name = "gethostname"
version = "0.3.0" version = "0.3.0"
@ -545,6 +569,19 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "getrandom"
version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427"
dependencies = [
"cfg-if",
"js-sys",
"libc",
"wasi",
"wasm-bindgen",
]
[[package]] [[package]]
name = "gimli" name = "gimli"
version = "0.28.0" version = "0.28.0"
@ -552,10 +589,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0"
[[package]] [[package]]
name = "glow" name = "gl_generator"
version = "0.12.3" version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca0fe580e4b60a8ab24a868bc08e2f03cbcb20d3d676601fa909386713333728" checksum = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d"
dependencies = [
"khronos_api",
"log",
"xml-rs",
]
[[package]]
name = "glow"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "886c2a30b160c4c6fec8f987430c26b526b7988ca71f664e6a699ddf6f9601e4"
dependencies = [ dependencies = [
"js-sys", "js-sys",
"slotmap", "slotmap",
@ -563,6 +611,15 @@ dependencies = [
"web-sys", "web-sys",
] ]
[[package]]
name = "glutin_wgl_sys"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c8098adac955faa2d31079b65dc48841251f69efd3ac25477903fc424362ead"
dependencies = [
"gl_generator",
]
[[package]] [[package]]
name = "gooey" name = "gooey"
version = "0.1.0" version = "0.1.0"
@ -593,12 +650,13 @@ dependencies = [
[[package]] [[package]]
name = "gpu-allocator" name = "gpu-allocator"
version = "0.22.0" version = "0.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce95f9e2e11c2c6fadfce42b5af60005db06576f231f5c92550fdded43c423e8" checksum = "40fe17c8a05d60c38c0a4e5a3c802f2f1ceb66b76c67d96ffb34bef0475a7fad"
dependencies = [ dependencies = [
"backtrace", "backtrace",
"log", "log",
"presser",
"thiserror", "thiserror",
"winapi", "winapi",
"windows", "windows",
@ -612,7 +670,7 @@ checksum = "cc11df1ace8e7e564511f53af41f3e42ddc95b56fd07b3f4445d2a6048bc682c"
dependencies = [ dependencies = [
"bitflags 2.4.1", "bitflags 2.4.1",
"gpu-descriptor-types", "gpu-descriptor-types",
"hashbrown 0.14.2", "hashbrown",
] ]
[[package]] [[package]]
@ -624,12 +682,6 @@ dependencies = [
"bitflags 2.4.1", "bitflags 2.4.1",
] ]
[[package]]
name = "hashbrown"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
version = "0.14.2" version = "0.14.2"
@ -691,16 +743,6 @@ dependencies = [
"num-traits", "num-traits",
] ]
[[package]]
name = "indexmap"
version = "1.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
dependencies = [
"autocfg",
"hashbrown 0.12.3",
]
[[package]] [[package]]
name = "indexmap" name = "indexmap"
version = "2.0.2" version = "2.0.2"
@ -708,7 +750,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897"
dependencies = [ dependencies = [
"equivalent", "equivalent",
"hashbrown 0.14.2", "hashbrown",
] ]
[[package]] [[package]]
@ -770,19 +812,25 @@ dependencies = [
[[package]] [[package]]
name = "khronos-egl" name = "khronos-egl"
version = "4.1.0" version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c2352bd1d0bceb871cb9d40f24360c8133c11d7486b68b5381c1dd1a32015e3" checksum = "6aae1df220ece3c0ada96b8153459b67eebe9ae9212258bb0134ae60416fdf76"
dependencies = [ dependencies = [
"libc", "libc",
"libloading 0.7.4", "libloading 0.8.1",
"pkg-config", "pkg-config",
] ]
[[package]]
name = "khronos_api"
version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
[[package]] [[package]]
name = "kludgine" name = "kludgine"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/khonsulabs/kludgine#80d722cbf4fbb1e1819f2b5ab8cb52bb331e9cf4" source = "git+https://github.com/khonsulabs/kludgine#713200714daa16a273eed9fcaee476613e894116"
dependencies = [ dependencies = [
"ahash", "ahash",
"alot", "alot",
@ -943,9 +991,9 @@ dependencies = [
[[package]] [[package]]
name = "metal" name = "metal"
version = "0.26.0" version = "0.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "623b5e6cefd76e58f774bd3cc0c6f5c7615c58c03a97815245a25c3c9bdee318" checksum = "c43f73953f8cbe511f021b58f18c3ce1c3d1ae13fe953293e13345bf83217f25"
dependencies = [ dependencies = [
"bitflags 2.4.1", "bitflags 2.4.1",
"block", "block",
@ -973,15 +1021,15 @@ dependencies = [
[[package]] [[package]]
name = "naga" name = "naga"
version = "0.13.0" version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1ceaaa4eedaece7e4ec08c55c640ba03dbb73fb812a6570a59bcf1930d0f70e" checksum = "61d829abac9f5230a85d8cc83ec0879b4c09790208ae25b5ea031ef84562e071"
dependencies = [ dependencies = [
"bit-set", "bit-set",
"bitflags 2.4.1", "bitflags 2.4.1",
"codespan-reporting", "codespan-reporting",
"hexf-parse", "hexf-parse",
"indexmap 1.9.3", "indexmap",
"log", "log",
"num-traits", "num-traits",
"rustc-hash", "rustc-hash",
@ -991,6 +1039,15 @@ dependencies = [
"unicode-xid", "unicode-xid",
] ]
[[package]]
name = "nanorand"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a51313c5820b0b02bd422f4b44776fbf47961755c74ce64afc73bfad10226c3"
dependencies = [
"getrandom",
]
[[package]] [[package]]
name = "ndk" name = "ndk"
version = "0.8.0" version = "0.8.0"
@ -1089,18 +1146,18 @@ dependencies = [
[[package]] [[package]]
name = "num_enum" name = "num_enum"
version = "0.7.0" version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70bf6736f74634d299d00086f02986875b3c2d924781a6a2cb6c201e73da0ceb" checksum = "683751d591e6d81200c39fb0d1032608b77724f34114db54f571ff1317b337c0"
dependencies = [ dependencies = [
"num_enum_derive", "num_enum_derive",
] ]
[[package]] [[package]]
name = "num_enum_derive" name = "num_enum_derive"
version = "0.7.0" version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56ea360eafe1022f7cc56cd7b869ed57330fb2453d0c7831d99b74c65d2f5597" checksum = "6c11e44798ad209ccdd91fc192f0526a369a01234f7373e1b141c96d7cee4f0e"
dependencies = [ dependencies = [
"proc-macro-crate", "proc-macro-crate",
"proc-macro2", "proc-macro2",
@ -1230,12 +1287,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22686f4785f02a4fcc856d3b3bb19bf6c8160d103f7a99cc258bddd0251dc7f2" checksum = "22686f4785f02a4fcc856d3b3bb19bf6c8160d103f7a99cc258bddd0251dc7f2"
[[package]] [[package]]
name = "proc-macro-crate" name = "presser"
version = "1.3.1" version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" checksum = "e8cf8e6a8aa66ce33f63993ffc4ea4271eb5b0530a9002db8455ea6050c77bfa"
[[package]]
name = "proc-macro-crate"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8"
dependencies = [ dependencies = [
"once_cell",
"toml_edit", "toml_edit",
] ]
@ -1343,9 +1405,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]] [[package]]
name = "rustix" name = "rustix"
version = "0.38.20" version = "0.38.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67ce50cb2e16c2903e30d1cbccfd8387a74b9d4c938b6a4c5ec6cc7556f7a8a0" checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3"
dependencies = [ dependencies = [
"bitflags 2.4.1", "bitflags 2.4.1",
"errno", "errno",
@ -1413,18 +1475,18 @@ checksum = "4c309e515543e67811222dbc9e3dd7e1056279b782e1dacffe4242b718734fb6"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.189" version = "1.0.190"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e422a44e74ad4001bdc8eede9a4570ab52f71190e9c076d14369f38b9200537" checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.189" version = "1.0.190"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5" checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1485,6 +1547,15 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "spin"
version = "0.9.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
dependencies = [
"lock_api",
]
[[package]] [[package]]
name = "spirv" name = "spirv"
version = "0.2.0+1.5.4" version = "0.2.0+1.5.4"
@ -1614,11 +1685,11 @@ checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1"
[[package]] [[package]]
name = "toml_edit" name = "toml_edit"
version = "0.19.15" version = "0.20.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81"
dependencies = [ dependencies = [
"indexmap 2.0.2", "indexmap",
"toml_datetime", "toml_datetime",
"winnow", "winnow",
] ]
@ -1717,6 +1788,12 @@ dependencies = [
"winapi-util", "winapi-util",
] ]
[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]] [[package]]
name = "wasm-bindgen" name = "wasm-bindgen"
version = "0.2.87" version = "0.2.87"
@ -1892,12 +1969,13 @@ dependencies = [
[[package]] [[package]]
name = "wgpu" name = "wgpu"
version = "0.17.1" version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed547920565c56c7a29afb4538ac5ae5048865a5d2f05bff3ad4fbeb921a9a2c" checksum = "30e7d227c9f961f2061c26f4cb0fbd4df0ef37e056edd0931783599d6c94ef24"
dependencies = [ dependencies = [
"arrayvec", "arrayvec",
"cfg-if", "cfg-if",
"flume",
"js-sys", "js-sys",
"log", "log",
"naga", "naga",
@ -1916,9 +1994,9 @@ dependencies = [
[[package]] [[package]]
name = "wgpu-core" name = "wgpu-core"
version = "0.17.1" version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f8a44dd301a30ceeed3c27d8c0090433d3da04d7b2a4042738095a424d12ae7" checksum = "837e02ddcdc6d4a9b56ba4598f7fd4202a7699ab03f6ef4dcdebfad2c966aea6"
dependencies = [ dependencies = [
"arrayvec", "arrayvec",
"bit-vec", "bit-vec",
@ -1939,9 +2017,9 @@ dependencies = [
[[package]] [[package]]
name = "wgpu-hal" name = "wgpu-hal"
version = "0.17.2" version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a80bf0e3c77399bb52850cb0830af9bad073d5cfcb9dd8253bef8125c42db17" checksum = "1e30b9a8155c83868e82a8c5d3ce899de6c3961d2ef595de8fc168a1677fc2d8"
dependencies = [ dependencies = [
"android_system_properties", "android_system_properties",
"arrayvec", "arrayvec",
@ -1952,6 +2030,7 @@ dependencies = [
"core-graphics-types", "core-graphics-types",
"d3d12", "d3d12",
"glow", "glow",
"glutin_wgl_sys",
"gpu-alloc", "gpu-alloc",
"gpu-allocator", "gpu-allocator",
"gpu-descriptor", "gpu-descriptor",
@ -1964,6 +2043,7 @@ dependencies = [
"metal", "metal",
"naga", "naga",
"objc", "objc",
"once_cell",
"parking_lot", "parking_lot",
"profiling", "profiling",
"range-alloc", "range-alloc",
@ -1980,9 +2060,9 @@ dependencies = [
[[package]] [[package]]
name = "wgpu-types" name = "wgpu-types"
version = "0.17.0" version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee64d7398d0c2f9ca48922c902ef69c42d000c759f3db41e355f4a570b052b67" checksum = "0d5ed5f0edf0de351fe311c53304986315ce866f394a2e6df0c4b3c70774bcdd"
dependencies = [ dependencies = [
"bitflags 2.4.1", "bitflags 2.4.1",
"js-sys", "js-sys",
@ -2037,11 +2117,21 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]] [[package]]
name = "windows" name = "windows"
version = "0.44.0" version = "0.51.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e745dab35a0c4c77aa3ce42d595e13d2003d6902d6b08c9ef5fc326d08da12b" checksum = "ca229916c5ee38c2f2bc1e9d8f04df975b4bd93f9955dc69fabb5d91270045c9"
dependencies = [ dependencies = [
"windows-targets 0.42.2", "windows-core",
"windows-targets 0.48.5",
]
[[package]]
name = "windows-core"
version = "0.51.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64"
dependencies = [
"windows-targets 0.48.5",
] ]
[[package]] [[package]]
@ -2297,6 +2387,12 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "054a8e68b76250b253f671d1268cb7f1ae089ec35e195b2efb2a4e9a836d0621" checksum = "054a8e68b76250b253f671d1268cb7f1ae089ec35e195b2efb2a4e9a836d0621"
[[package]]
name = "xml-rs"
version = "0.8.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fcb9cbac069e033553e8bb871be2fbdffcab578eb25bd0f7c508cedc6dcd75a"
[[package]] [[package]]
name = "xmlparser" name = "xmlparser"
version = "0.13.6" version = "0.13.6"
@ -2317,18 +2413,18 @@ checksum = "dd15f8e0dbb966fd9245e7498c7e9e5055d9e5c8b676b95bd67091cd11a1e697"
[[package]] [[package]]
name = "zerocopy" name = "zerocopy"
version = "0.7.15" version = "0.7.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81ba595b9f2772fbee2312de30eeb80ec773b4cb2f1e8098db024afadda6c06f" checksum = "ede7d7c7970ca2215b8c1ccf4d4f354c4733201dfaaba72d44ae5b37472e4901"
dependencies = [ dependencies = [
"zerocopy-derive", "zerocopy-derive",
] ]
[[package]] [[package]]
name = "zerocopy-derive" name = "zerocopy-derive"
version = "0.7.15" version = "0.7.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "772666c41fb6dceaf520b564b962d738a8e1a83b41bd48945f50837aed78bb1d" checksum = "4b27b1bb92570f989aac0ab7e9cbfbacdd65973f7ee920d9f0e71ebac878fd0b"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",

View file

@ -3,6 +3,7 @@ use gooey::Run;
use kludgine::figures::units::Px; use kludgine::figures::units::Px;
use kludgine::figures::{Angle, IntoSigned, Point, Rect, Size}; use kludgine::figures::{Angle, IntoSigned, Point, Rect, Size};
use kludgine::shapes::Shape; use kludgine::shapes::Shape;
use kludgine::text::{Text, TextOrigin};
use kludgine::Color; use kludgine::Color;
fn main() -> gooey::Result<()> { fn main() -> gooey::Result<()> {
@ -12,13 +13,11 @@ fn main() -> gooey::Result<()> {
let center = Point::from(context.graphics.size()).into_signed() / 2; let center = Point::from(context.graphics.size()).into_signed() / 2;
context.graphics.draw_text( context.graphics.draw_text(
"Canvas exposes the full power of Kludgine", Text::new("Canvas exposes the full power of Kludgine", Color::WHITE)
Color::WHITE, .origin(TextOrigin::Center),
kludgine::text::TextOrigin::Center,
center - Point::new(Px(0), Px(100)), center - Point::new(Px(0), Px(100)),
None, None,
None, None,
None,
); );
context.graphics.draw_shape( context.graphics.draw_shape(
&Shape::filled_rect( &Shape::filled_rect(

View file

@ -6,6 +6,7 @@ use kludgine::app::winit::keyboard::KeyCode;
use kludgine::figures::units::{Px, UPx}; use kludgine::figures::units::{Px, UPx};
use kludgine::figures::{IntoUnsigned, Point, Rect, Size}; use kludgine::figures::{IntoUnsigned, Point, Rect, Size};
use kludgine::shapes::Shape; use kludgine::shapes::Shape;
use kludgine::text::Text;
use kludgine::Color; use kludgine::Color;
use crate::context::{EventContext, GraphicsContext}; use crate::context::{EventContext, GraphicsContext};
@ -81,13 +82,12 @@ impl Widget for Button {
let width = context.graphics.size().width; let width = context.graphics.size().width;
self.label.map(|label| { self.label.map(|label| {
context.graphics.draw_text( context.graphics.draw_text(
label, Text::new(label, styles.get_or_default(&TextColor))
styles.get_or_default(&TextColor), .origin(kludgine::text::TextOrigin::Center)
kludgine::text::TextOrigin::Center, .wrap_at(width),
center, center,
None, None,
None, None,
Some(width),
); );
}); });
} }
@ -170,7 +170,7 @@ impl Widget for Button {
self.label.map(|label| { self.label.map(|label| {
let measured = context let measured = context
.graphics .graphics
.measure_text::<Px>(label, Color::WHITE, Some(width)); .measure_text::<Px>(Text::from(label).wrap_at(width));
let mut size = measured.size.into_unsigned(); let mut size = measured.size.into_unsigned();
size.height = size.height.max(measured.line_height.into_unsigned()); size.height = size.height.max(measured.line_height.into_unsigned());

View file

@ -1,7 +1,6 @@
use kludgine::figures::units::{Px, UPx}; use kludgine::figures::units::{Px, UPx};
use kludgine::figures::{Point, Size}; use kludgine::figures::{Point, Size};
use kludgine::text::TextOrigin; use kludgine::text::{Text, TextOrigin};
use kludgine::Color;
use crate::context::GraphicsContext; use crate::context::GraphicsContext;
use crate::styles::TextColor; use crate::styles::TextColor;
@ -29,13 +28,12 @@ impl Widget for Label {
let width = context.graphics.size().width; let width = context.graphics.size().width;
self.contents.map(|contents| { self.contents.map(|contents| {
context.graphics.draw_text( context.graphics.draw_text(
contents, Text::new(contents, styles.get_or_default(&TextColor))
styles.get_or_default(&TextColor), .origin(TextOrigin::Center)
TextOrigin::Center, .wrap_at(width),
center, center,
None, None,
None, None,
Some(width),
); );
}); });
} }
@ -49,7 +47,7 @@ impl Widget for Label {
self.contents.map(|contents| { self.contents.map(|contents| {
context context
.graphics .graphics
.measure_text(contents, Color::RED, Some(width)) .measure_text(Text::from(contents).wrap_at(width))
.size .size
.try_cast() .try_cast()
.unwrap_or_default() .unwrap_or_default()