diff options
author | 2020-04-10 23:16:21 +0200 | |
---|---|---|
committer | 2020-04-10 23:16:21 +0200 | |
commit | e941eab4ab58da4473dd4473215bc4f36684dafb (patch) | |
tree | eae9d2bd0880e46c9f7c5fe93282951c8ecd36d3 /wgpu/src/renderer.rs | |
parent | 19f6a5e2fd685c76a06576e45c64e7c9e3b3a57f (diff) | |
parent | 47d44af348db79735233e408b1560661b9f96960 (diff) | |
download | iced-e941eab4ab58da4473dd4473215bc4f36684dafb.tar.gz iced-e941eab4ab58da4473dd4473215bc4f36684dafb.tar.bz2 iced-e941eab4ab58da4473dd4473215bc4f36684dafb.zip |
Merge pull request #281 from hecrj/fix/canvas-text-alignment
Align text in `iced_wgpu` on a case-by-case basis
Diffstat (limited to 'wgpu/src/renderer.rs')
-rw-r--r-- | wgpu/src/renderer.rs | 25 |
1 files changed, 4 insertions, 21 deletions
diff --git a/wgpu/src/renderer.rs b/wgpu/src/renderer.rs index e847cb64..c886bed0 100644 --- a/wgpu/src/renderer.rs +++ b/wgpu/src/renderer.rs @@ -152,31 +152,14 @@ impl Renderer { horizontal_alignment, vertical_alignment, } => { - let x = match horizontal_alignment { - iced_native::HorizontalAlignment::Left => bounds.x, - iced_native::HorizontalAlignment::Center => { - bounds.x + bounds.width / 2.0 - } - iced_native::HorizontalAlignment::Right => { - bounds.x + bounds.width - } - }; - - let y = match vertical_alignment { - iced_native::VerticalAlignment::Top => bounds.y, - iced_native::VerticalAlignment::Center => { - bounds.y + bounds.height / 2.0 - } - iced_native::VerticalAlignment::Bottom => { - bounds.y + bounds.height - } - }; - let layer = layers.last_mut().unwrap(); layer.text.push(wgpu_glyph::Section { text: &content, - screen_position: (x + translation.x, y + translation.y), + screen_position: ( + bounds.x + translation.x, + bounds.y + translation.y, + ), bounds: (bounds.width, bounds.height), scale: wgpu_glyph::Scale { x: *size, y: *size }, color: color.into_linear(), |