Align slot labels

This commit is contained in:
mars 2022-10-21 16:09:25 -06:00
parent 9318b59ac0
commit 1fb7f03468
1 changed files with 10 additions and 2 deletions

View File

@ -163,6 +163,7 @@ pub struct GraphStyle {
pub edge_control_offset: f32,
pub slot_radius: f32,
pub slot_spacing: f32,
pub slot_label_margin: f32,
pub slot_fill: Color32,
pub slot_stroke: Stroke,
}
@ -185,6 +186,7 @@ impl GraphStyle {
edge_control_offset: 200.0,
slot_radius: 7.0,
slot_spacing: 40.0,
slot_label_margin: 5.0,
slot_fill: style.visuals.widgets.noninteractive.bg_fill,
slot_stroke: style.visuals.widgets.noninteractive.bg_stroke,
}
@ -264,7 +266,10 @@ impl GraphLayout {
let wrap_width = f32::MAX;
let galley = ui.fonts().layout(text, label_font, label_color, wrap_width);
layout.texts.push(TextLayout {
pos: egui::pos2(position.x, position.y),
pos: egui::pos2(
position.x - galley.rect.left() + style.slot_radius + style.slot_label_margin,
position.y - galley.rect.bottom() + style.slot_radius,
),
galley,
});
@ -295,7 +300,10 @@ impl GraphLayout {
let wrap_width = f32::MAX;
let galley = ui.fonts().layout(text, label_font, label_color, wrap_width);
layout.texts.push(TextLayout {
pos: egui::pos2(position.x, position.y),
pos: egui::pos2(
position.x - galley.rect.right() - style.slot_radius - style.slot_label_margin,
position.y - galley.rect.bottom() + style.slot_radius,
),
galley,
});