summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLibravatar Clark Moody <clark@clarkmoody.com>2020-04-10 14:59:57 -0500
committerLibravatar Clark Moody <clark@clarkmoody.com>2020-04-24 15:13:22 -0500
commit4b90241ea1d2139464587ce8475aeebbf283abc7 (patch)
tree5674a9251523b9eb4200146091e61038aaef7eaa /examples
parent39fd8ad9e973b8f6ec9e4e4d08f4e8aca72b069e (diff)
downloadiced-4b90241ea1d2139464587ce8475aeebbf283abc7.tar.gz
iced-4b90241ea1d2139464587ce8475aeebbf283abc7.tar.bz2
iced-4b90241ea1d2139464587ce8475aeebbf283abc7.zip
Hex label text alignment
Diffstat (limited to 'examples')
-rw-r--r--examples/color_palette/src/main.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/examples/color_palette/src/main.rs b/examples/color_palette/src/main.rs
index fc733787..b80db299 100644
--- a/examples/color_palette/src/main.rs
+++ b/examples/color_palette/src/main.rs
@@ -459,7 +459,7 @@ impl canvas::Drawable for State {
let box_height = frame.height() / 2.0 - pad;
let mut text = canvas::Text::default();
- text.horizontal_alignment = HorizontalAlignment::Left;
+ text.horizontal_alignment = HorizontalAlignment::Center;
text.vertical_alignment = VerticalAlignment::Top;
text.size = 15.0;
@@ -530,13 +530,15 @@ impl canvas::Drawable for State {
frame.fill_text(canvas::Text {
content: color_str(&self.theme[i], ColorFormat::Hex),
position: Point {
- x: anchor.x,
+ x: anchor.x + box_width / 2.0,
y: box_height,
},
..text
});
}
+ text.vertical_alignment = VerticalAlignment::Bottom;
+
let hsl = Hsl::from(Srgb::from(self.color));
for i in 0..self.theme.len() {
let pct = (i as f32 + 1.0) / (self.theme.len() as f32 + 1.0);
@@ -570,8 +572,8 @@ impl canvas::Drawable for State {
frame.fill_text(canvas::Text {
content: color_str(&color, ColorFormat::Hex),
position: Point {
- x: anchor.x,
- y: box_height + 2.0 * pad - 15.0,
+ x: anchor.x + box_width / 2.0,
+ y: box_height + 2.0 * pad,
},
..text
});