Skip to content

Commit

Permalink
Handle text_alignment in Milestone
Browse files Browse the repository at this point in the history
  • Loading branch information
kajuberdut committed Nov 5, 2023
1 parent 064e6fe commit 078fc67
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/roadmapper/milestone.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ def draw(self, painter: Painter) -> None:
self.diamond_height,
self.fill_colour,
)

text_width, _ = painter.get_text_dimension(text=self.text, font=self.font, font_size=self.font_size)
width = text_width * 2

# Text is already "centered" if we change nothing
# For "left" and "right", move text_x by 1/2 text_width.
if self.text_alignment == "right":
self.text_x = self.text_x + (text_width/2)
elif self.text_alignment == "left":
self.text_x = self.text_x - (text_width/2)

if (self.text_x != 0) and (self.text_y != 0):
painter.draw_text(
self.text_x,
Expand Down

0 comments on commit 078fc67

Please sign in to comment.