Hex label text alignment
This commit is contained in:
parent
39fd8ad9e9
commit
4b90241ea1
@ -459,7 +459,7 @@ impl canvas::Drawable for State {
|
|||||||
let box_height = frame.height() / 2.0 - pad;
|
let box_height = frame.height() / 2.0 - pad;
|
||||||
|
|
||||||
let mut text = canvas::Text::default();
|
let mut text = canvas::Text::default();
|
||||||
text.horizontal_alignment = HorizontalAlignment::Left;
|
text.horizontal_alignment = HorizontalAlignment::Center;
|
||||||
text.vertical_alignment = VerticalAlignment::Top;
|
text.vertical_alignment = VerticalAlignment::Top;
|
||||||
text.size = 15.0;
|
text.size = 15.0;
|
||||||
|
|
||||||
@ -530,13 +530,15 @@ impl canvas::Drawable for State {
|
|||||||
frame.fill_text(canvas::Text {
|
frame.fill_text(canvas::Text {
|
||||||
content: color_str(&self.theme[i], ColorFormat::Hex),
|
content: color_str(&self.theme[i], ColorFormat::Hex),
|
||||||
position: Point {
|
position: Point {
|
||||||
x: anchor.x,
|
x: anchor.x + box_width / 2.0,
|
||||||
y: box_height,
|
y: box_height,
|
||||||
},
|
},
|
||||||
..text
|
..text
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
text.vertical_alignment = VerticalAlignment::Bottom;
|
||||||
|
|
||||||
let hsl = Hsl::from(Srgb::from(self.color));
|
let hsl = Hsl::from(Srgb::from(self.color));
|
||||||
for i in 0..self.theme.len() {
|
for i in 0..self.theme.len() {
|
||||||
let pct = (i as f32 + 1.0) / (self.theme.len() as f32 + 1.0);
|
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 {
|
frame.fill_text(canvas::Text {
|
||||||
content: color_str(&color, ColorFormat::Hex),
|
content: color_str(&color, ColorFormat::Hex),
|
||||||
position: Point {
|
position: Point {
|
||||||
x: anchor.x,
|
x: anchor.x + box_width / 2.0,
|
||||||
y: box_height + 2.0 * pad - 15.0,
|
y: box_height + 2.0 * pad,
|
||||||
},
|
},
|
||||||
..text
|
..text
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user