Skip to content

Commit

Permalink
add x and y text alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
kayhhh committed Sep 15, 2024
1 parent 2de7d02 commit 49dfa40
Show file tree
Hide file tree
Showing 8 changed files with 263 additions and 130 deletions.
168 changes: 104 additions & 64 deletions wasm/example-unavi-ui/src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2934,12 +2934,32 @@ pub mod unavi {
}
impl Text {
#[allow(unused_unsafe, clippy::all)]
pub fn alignment(&self) -> Alignment {
pub fn align_x(&self) -> Alignment {
unsafe {
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "unavi:ui/text")]
extern "C" {
#[link_name = "[method]text.align-x"]
fn wit_import(_: i32) -> i32;
}

#[cfg(not(target_arch = "wasm32"))]
fn wit_import(_: i32) -> i32 {
unreachable!()
}
let ret = wit_import((self).handle() as i32);
super::super::super::unavi::layout::container::Alignment::_lift(ret as u8)
}
}
}
impl Text {
#[allow(unused_unsafe, clippy::all)]
pub fn align_y(&self) -> Alignment {
unsafe {
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "unavi:ui/text")]
extern "C" {
#[link_name = "[method]text.alignment"]
#[link_name = "[method]text.align-y"]
fn wit_import(_: i32) -> i32;
}

Expand All @@ -2954,12 +2974,31 @@ pub mod unavi {
}
impl Text {
#[allow(unused_unsafe, clippy::all)]
pub fn set_alignment(&self, value: Alignment) {
pub fn set_align_x(&self, value: Alignment) {
unsafe {
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "unavi:ui/text")]
extern "C" {
#[link_name = "[method]text.set-align-x"]
fn wit_import(_: i32, _: i32);
}

#[cfg(not(target_arch = "wasm32"))]
fn wit_import(_: i32, _: i32) {
unreachable!()
}
wit_import((self).handle() as i32, value.clone() as i32);
}
}
}
impl Text {
#[allow(unused_unsafe, clippy::all)]
pub fn set_align_y(&self, value: Alignment) {
unsafe {
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "unavi:ui/text")]
extern "C" {
#[link_name = "[method]text.set-alignment"]
#[link_name = "[method]text.set-align-y"]
fn wit_import(_: i32, _: i32);
}

Expand Down Expand Up @@ -9304,8 +9343,8 @@ pub(crate) use __export_script_impl as export;
#[cfg(target_arch = "wasm32")]
#[link_section = "component-type:wit-bindgen:0.25.0:script:encoded world"]
#[doc(hidden)]
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 12472] = *b"\
\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xbb`\x01A\x02\x01A5\x01\
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 12522] = *b"\
\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xed`\x01A\x02\x01A5\x01\
B\x10\x01r\x02\x01xv\x01yv\x04\0\x04vec2\x03\0\0\x01r\x03\x01xv\x01yv\x01zv\x04\0\
\x04vec3\x03\0\x02\x01r\x04\x01xv\x01yv\x01zv\x01wv\x04\0\x04quat\x03\0\x04\x01r\
\x03\x08rotation\x05\x05scale\x03\x0btranslation\x03\x04\0\x09transform\x03\0\x06\
Expand Down Expand Up @@ -9471,7 +9510,7 @@ ut-handler\x03\0\x02\x04\0\x06button\x03\x01\x01i\x01\x01i\x04\x01@\x01\x04root\
\0\x06\x04\0\x13[constructor]button\x01\x07\x01h\x04\x01@\x01\x04self\x08\0\x05\x04\
\0\x13[method]button.root\x01\x09\x01@\x01\x04self\x08\0\x7f\x04\0\x16[method]bu\
tton.hovered\x01\x0a\x04\0\x16[method]button.pressed\x01\x0a\x03\x01\x0funavi:ui\
/button\x05\x17\x02\x03\0\x0a\x09alignment\x01B@\x02\x03\x02\x01\x18\x04\0\x09al\
/button\x05\x17\x02\x03\0\x0a\x09alignment\x01BB\x02\x03\x02\x01\x18\x04\0\x09al\
ignment\x03\0\0\x02\x03\x02\x01\x16\x04\0\x09container\x03\0\x02\x02\x03\x02\x01\
\x02\x04\0\x08material\x03\0\x04\x02\x03\x02\x01\x0a\x04\0\x04mesh\x03\0\x06\x02\
\x03\x02\x01\x10\x04\0\x04node\x03\0\x08\x04\0\x04text\x03\x01\x01m\x02\x09chara\
Expand All @@ -9480,63 +9519,64 @@ cter\x04word\x04\0\x09word-wrap\x03\0\x0b\x04\0\x08text-box\x03\x01\x01i\x0a\x01
f\x10\0\x0e\x04\0\x10[method]text.ref\x01\x11\x01p}\x01k\x12\x01@\x02\x04self\x10\
\x05value\x13\x01\0\x04\0\x15[method]text.set-font\x01\x14\x01@\x01\x04self\x10\0\
s\x04\0\x11[method]text.text\x01\x15\x01@\x02\x04self\x10\x05values\x01\0\x04\0\x15\
[method]text.set-text\x01\x16\x01@\x01\x04self\x10\0\x01\x04\0\x16[method]text.a\
lignment\x01\x17\x01@\x02\x04self\x10\x05value\x01\x01\0\x04\0\x1a[method]text.s\
et-alignment\x01\x18\x01@\x01\x04self\x10\0v\x04\0\x16[method]text.font-size\x01\
\x19\x01@\x02\x04self\x10\x05valuev\x01\0\x04\0\x1a[method]text.set-font-size\x01\
\x1a\x04\0\x16[method]text.thickness\x01\x19\x04\0\x1a[method]text.set-thickness\
\x01\x1a\x01i\x05\x01k\x1b\x01@\x01\x04self\x10\0\x1c\x04\0\x15[method]text.mate\
rial\x01\x1d\x01h\x05\x01k\x1e\x01@\x02\x04self\x10\x05value\x1f\x01\0\x04\0\x19\
[method]text.set-material\x01\x20\x01i\x07\x01@\x01\x04self\x10\0!\x04\0\x11[met\
hod]text.mesh\x01\"\x01i\x03\x01i\x0d\x01@\x01\x04root#\0$\x04\0\x15[constructor\
]text-box\x01%\x01h\x0d\x01@\x01\x04self&\0#\x04\0\x15[method]text-box.root\x01'\
\x01@\x01\x04self&\0\x0e\x04\0\x15[method]text-box.text\x01(\x01@\x02\x04self&\x05\
values\x01\0\x04\0\x19[method]text-box.set-text\x01)\x01@\x01\x04self&\0\x0c\x04\
\0\x15[method]text-box.wrap\x01*\x01@\x02\x04self&\x05value\x0c\x01\0\x04\0\x19[\
method]text-box.set-wrap\x01+\x03\x01\x0dunavi:ui/text\x05\x19\x01B\x04\x01m\x04\
\x05debug\x04info\x04warn\x05error\x04\0\x09log-level\x03\0\0\x01@\x02\x05level\x01\
\x07messages\x01\0\x04\0\x03log\x01\x02\x03\x01\x0dwired:log/api\x05\x1a\x01B\x11\
\x02\x03\x02\x01\x10\x04\0\x04node\x03\0\0\x01i\x01\x01r\x14\x04hips\x02\x05spin\
e\x02\x05chest\x02\x0bupper-chest\x02\x04neck\x02\x04head\x02\x0dleft-shoulder\x02\
\x0eleft-upper-arm\x02\x0eleft-lower-arm\x02\x09left-hand\x02\x0eright-shoulder\x02\
\x0fright-upper-arm\x02\x0fright-lower-arm\x02\x0aright-hand\x02\x0eleft-upper-l\
eg\x02\x0eleft-lower-leg\x02\x09left-foot\x02\x0fright-upper-leg\x02\x0fright-lo\
wer-leg\x02\x0aright-foot\x02\x04\0\x08skeleton\x03\0\x03\x04\0\x06player\x03\x01\
\x01h\x05\x01@\x01\x04self\x06\0\x02\x04\0\x13[method]player.root\x01\x07\x01@\x01\
\x04self\x06\0\x04\x04\0\x17[method]player.skeleton\x01\x08\x01i\x05\x01p\x09\x01\
@\0\0\x0a\x04\0\x0clist-players\x01\x0b\x01@\0\0\x09\x04\0\x0clocal-player\x01\x0c\
\x03\x01\x10wired:player/api\x05\x1b\x01B\x15\x02\x03\x02\x01\x10\x04\0\x04node\x03\
\0\0\x04\0\x05scene\x03\x01\x01i\x02\x01@\0\0\x03\x04\0\x12[constructor]scene\x01\
\x04\x01h\x02\x01@\x01\x04self\x05\0y\x04\0\x10[method]scene.id\x01\x06\x01@\x01\
\x04self\x05\0s\x04\0\x12[method]scene.name\x01\x07\x01@\x02\x04self\x05\x05valu\
es\x01\0\x04\0\x16[method]scene.set-name\x01\x08\x01i\x01\x01p\x09\x01@\x01\x04s\
elf\x05\0\x0a\x04\0\x13[method]scene.nodes\x01\x0b\x01h\x01\x01@\x02\x04self\x05\
\x05value\x0c\x01\0\x04\0\x16[method]scene.add-node\x01\x0d\x04\0\x19[method]sce\
ne.remove-node\x01\x0d\x03\x01\x11wired:scene/scene\x05\x1c\x02\x03\0\x0f\x05sce\
ne\x01B5\x02\x03\x02\x01\x02\x04\0\x08material\x03\0\0\x02\x03\x02\x01\x0a\x04\0\
\x04mesh\x03\0\x02\x02\x03\x02\x01\x10\x04\0\x04node\x03\0\x04\x02\x03\x02\x01\x1d\
\x04\0\x05scene\x03\0\x06\x04\0\x04gltf\x03\x01\x01i\x08\x01@\0\0\x09\x04\0\x11[\
constructor]gltf\x01\x0a\x01h\x08\x01i\x01\x01p\x0c\x01@\x01\x04self\x0b\0\x0d\x04\
\0\x1b[method]gltf.list-materials\x01\x0e\x01h\x01\x01@\x02\x04self\x0b\x05value\
\x0f\x01\0\x04\0\x19[method]gltf.add-material\x01\x10\x04\0\x1c[method]gltf.remo\
ve-material\x01\x10\x01i\x03\x01p\x11\x01@\x01\x04self\x0b\0\x12\x04\0\x18[metho\
d]gltf.list-meshes\x01\x13\x01h\x03\x01@\x02\x04self\x0b\x05value\x14\x01\0\x04\0\
\x15[method]gltf.add-mesh\x01\x15\x04\0\x18[method]gltf.remove-mesh\x01\x15\x01i\
\x05\x01p\x16\x01@\x01\x04self\x0b\0\x17\x04\0\x17[method]gltf.list-nodes\x01\x18\
\x01h\x05\x01@\x02\x04self\x0b\x05value\x19\x01\0\x04\0\x15[method]gltf.add-node\
\x01\x1a\x04\0\x18[method]gltf.remove-node\x01\x1a\x01i\x07\x01p\x1b\x01@\x01\x04\
self\x0b\0\x1c\x04\0\x18[method]gltf.list-scenes\x01\x1d\x01h\x07\x01@\x02\x04se\
lf\x0b\x05value\x1e\x01\0\x04\0\x16[method]gltf.add-scene\x01\x1f\x04\0\x19[meth\
od]gltf.remove-scene\x01\x1f\x01k\x1b\x01@\x01\x04self\x0b\0\x20\x04\0\x19[metho\
d]gltf.active-scene\x01!\x01k\x1e\x01@\x02\x04self\x0b\x05value\"\x01\0\x04\0\x1d\
[method]gltf.set-active-scene\x01#\x04\0\x1a[method]gltf.default-scene\x01!\x04\0\
\x1e[method]gltf.set-default-scene\x01\x1f\x03\x01\x10wired:scene/gltf\x05\x1e\x02\
\x03\0\x10\x04gltf\x01Bt\x02\x03\x02\x01\x1f\x04\0\x04gltf\x03\0\0\x02\x03\x02\x01\
\x10\x04\0\x04node\x03\0\x02\x02\x03\x02\x01\x0c\x04\0\x09transform\x03\0\x04\x04\
\0\x04glxf\x03\x01\x04\0\x0aasset-gltf\x03\x01\x04\0\x0aasset-glxf\x03\x01\x01i\x07\
\x01i\x08\x01q\x02\x04gltf\x01\x09\0\x04glxf\x01\x0a\0\x04\0\x05asset\x03\0\x0b\x01\
h\x07\x01h\x08\x01q\x02\x04gltf\x01\x0d\0\x04glxf\x01\x0e\0\x04\0\x0casset-borro\
w\x03\0\x0f\x04\0\x09glxf-node\x03\x01\x01i\x11\x01p\x12\x01q\x02\x05asset\x01\x0c\
[method]text.set-text\x01\x16\x01@\x01\x04self\x10\0\x01\x04\0\x14[method]text.a\
lign-x\x01\x17\x04\0\x14[method]text.align-y\x01\x17\x01@\x02\x04self\x10\x05val\
ue\x01\x01\0\x04\0\x18[method]text.set-align-x\x01\x18\x04\0\x18[method]text.set\
-align-y\x01\x18\x01@\x01\x04self\x10\0v\x04\0\x16[method]text.font-size\x01\x19\
\x01@\x02\x04self\x10\x05valuev\x01\0\x04\0\x1a[method]text.set-font-size\x01\x1a\
\x04\0\x16[method]text.thickness\x01\x19\x04\0\x1a[method]text.set-thickness\x01\
\x1a\x01i\x05\x01k\x1b\x01@\x01\x04self\x10\0\x1c\x04\0\x15[method]text.material\
\x01\x1d\x01h\x05\x01k\x1e\x01@\x02\x04self\x10\x05value\x1f\x01\0\x04\0\x19[met\
hod]text.set-material\x01\x20\x01i\x07\x01@\x01\x04self\x10\0!\x04\0\x11[method]\
text.mesh\x01\"\x01i\x03\x01i\x0d\x01@\x01\x04root#\0$\x04\0\x15[constructor]tex\
t-box\x01%\x01h\x0d\x01@\x01\x04self&\0#\x04\0\x15[method]text-box.root\x01'\x01\
@\x01\x04self&\0\x0e\x04\0\x15[method]text-box.text\x01(\x01@\x02\x04self&\x05va\
lues\x01\0\x04\0\x19[method]text-box.set-text\x01)\x01@\x01\x04self&\0\x0c\x04\0\
\x15[method]text-box.wrap\x01*\x01@\x02\x04self&\x05value\x0c\x01\0\x04\0\x19[me\
thod]text-box.set-wrap\x01+\x03\x01\x0dunavi:ui/text\x05\x19\x01B\x04\x01m\x04\x05\
debug\x04info\x04warn\x05error\x04\0\x09log-level\x03\0\0\x01@\x02\x05level\x01\x07\
messages\x01\0\x04\0\x03log\x01\x02\x03\x01\x0dwired:log/api\x05\x1a\x01B\x11\x02\
\x03\x02\x01\x10\x04\0\x04node\x03\0\0\x01i\x01\x01r\x14\x04hips\x02\x05spine\x02\
\x05chest\x02\x0bupper-chest\x02\x04neck\x02\x04head\x02\x0dleft-shoulder\x02\x0e\
left-upper-arm\x02\x0eleft-lower-arm\x02\x09left-hand\x02\x0eright-shoulder\x02\x0f\
right-upper-arm\x02\x0fright-lower-arm\x02\x0aright-hand\x02\x0eleft-upper-leg\x02\
\x0eleft-lower-leg\x02\x09left-foot\x02\x0fright-upper-leg\x02\x0fright-lower-le\
g\x02\x0aright-foot\x02\x04\0\x08skeleton\x03\0\x03\x04\0\x06player\x03\x01\x01h\
\x05\x01@\x01\x04self\x06\0\x02\x04\0\x13[method]player.root\x01\x07\x01@\x01\x04\
self\x06\0\x04\x04\0\x17[method]player.skeleton\x01\x08\x01i\x05\x01p\x09\x01@\0\
\0\x0a\x04\0\x0clist-players\x01\x0b\x01@\0\0\x09\x04\0\x0clocal-player\x01\x0c\x03\
\x01\x10wired:player/api\x05\x1b\x01B\x15\x02\x03\x02\x01\x10\x04\0\x04node\x03\0\
\0\x04\0\x05scene\x03\x01\x01i\x02\x01@\0\0\x03\x04\0\x12[constructor]scene\x01\x04\
\x01h\x02\x01@\x01\x04self\x05\0y\x04\0\x10[method]scene.id\x01\x06\x01@\x01\x04\
self\x05\0s\x04\0\x12[method]scene.name\x01\x07\x01@\x02\x04self\x05\x05values\x01\
\0\x04\0\x16[method]scene.set-name\x01\x08\x01i\x01\x01p\x09\x01@\x01\x04self\x05\
\0\x0a\x04\0\x13[method]scene.nodes\x01\x0b\x01h\x01\x01@\x02\x04self\x05\x05val\
ue\x0c\x01\0\x04\0\x16[method]scene.add-node\x01\x0d\x04\0\x19[method]scene.remo\
ve-node\x01\x0d\x03\x01\x11wired:scene/scene\x05\x1c\x02\x03\0\x0f\x05scene\x01B\
5\x02\x03\x02\x01\x02\x04\0\x08material\x03\0\0\x02\x03\x02\x01\x0a\x04\0\x04mes\
h\x03\0\x02\x02\x03\x02\x01\x10\x04\0\x04node\x03\0\x04\x02\x03\x02\x01\x1d\x04\0\
\x05scene\x03\0\x06\x04\0\x04gltf\x03\x01\x01i\x08\x01@\0\0\x09\x04\0\x11[constr\
uctor]gltf\x01\x0a\x01h\x08\x01i\x01\x01p\x0c\x01@\x01\x04self\x0b\0\x0d\x04\0\x1b\
[method]gltf.list-materials\x01\x0e\x01h\x01\x01@\x02\x04self\x0b\x05value\x0f\x01\
\0\x04\0\x19[method]gltf.add-material\x01\x10\x04\0\x1c[method]gltf.remove-mater\
ial\x01\x10\x01i\x03\x01p\x11\x01@\x01\x04self\x0b\0\x12\x04\0\x18[method]gltf.l\
ist-meshes\x01\x13\x01h\x03\x01@\x02\x04self\x0b\x05value\x14\x01\0\x04\0\x15[me\
thod]gltf.add-mesh\x01\x15\x04\0\x18[method]gltf.remove-mesh\x01\x15\x01i\x05\x01\
p\x16\x01@\x01\x04self\x0b\0\x17\x04\0\x17[method]gltf.list-nodes\x01\x18\x01h\x05\
\x01@\x02\x04self\x0b\x05value\x19\x01\0\x04\0\x15[method]gltf.add-node\x01\x1a\x04\
\0\x18[method]gltf.remove-node\x01\x1a\x01i\x07\x01p\x1b\x01@\x01\x04self\x0b\0\x1c\
\x04\0\x18[method]gltf.list-scenes\x01\x1d\x01h\x07\x01@\x02\x04self\x0b\x05valu\
e\x1e\x01\0\x04\0\x16[method]gltf.add-scene\x01\x1f\x04\0\x19[method]gltf.remove\
-scene\x01\x1f\x01k\x1b\x01@\x01\x04self\x0b\0\x20\x04\0\x19[method]gltf.active-\
scene\x01!\x01k\x1e\x01@\x02\x04self\x0b\x05value\"\x01\0\x04\0\x1d[method]gltf.\
set-active-scene\x01#\x04\0\x1a[method]gltf.default-scene\x01!\x04\0\x1e[method]\
gltf.set-default-scene\x01\x1f\x03\x01\x10wired:scene/gltf\x05\x1e\x02\x03\0\x10\
\x04gltf\x01Bt\x02\x03\x02\x01\x1f\x04\0\x04gltf\x03\0\0\x02\x03\x02\x01\x10\x04\
\0\x04node\x03\0\x02\x02\x03\x02\x01\x0c\x04\0\x09transform\x03\0\x04\x04\0\x04g\
lxf\x03\x01\x04\0\x0aasset-gltf\x03\x01\x04\0\x0aasset-glxf\x03\x01\x01i\x07\x01\
i\x08\x01q\x02\x04gltf\x01\x09\0\x04glxf\x01\x0a\0\x04\0\x05asset\x03\0\x0b\x01h\
\x07\x01h\x08\x01q\x02\x04gltf\x01\x0d\0\x04glxf\x01\x0e\0\x04\0\x0casset-borrow\
\x03\0\x0f\x04\0\x09glxf-node\x03\x01\x01i\x11\x01p\x12\x01q\x02\x05asset\x01\x0c\
\0\x05nodes\x01\x13\0\x04\0\x08children\x03\0\x14\x01h\x11\x01p\x16\x01q\x02\x05\
asset\x01\x10\0\x05nodes\x01\x17\0\x04\0\x0fchildren-borrow\x03\0\x18\x04\0\x0ag\
lxf-scene\x03\x01\x01i\x06\x01@\0\0\x1b\x04\0\x11[constructor]glxf\x01\x1c\x01h\x06\
Expand Down
1 change: 0 additions & 1 deletion wasm/unavi-layout/wit/world.wit
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ interface container {
align-x: func() -> alignment;
align-y: func() -> alignment;
align-z: func() -> alignment;

set-align-x: func(value: alignment);
set-align-y: func(value: alignment);
set-align-z: func(value: alignment);
Expand Down
Loading

0 comments on commit 49dfa40

Please sign in to comment.