Skip to content

Commit

Permalink
Fixed|Client|UI|LabelWidget: Incorrect layout
Browse files Browse the repository at this point in the history
Omit gap between text and image if both are not present.
  • Loading branch information
skyjake committed Aug 10, 2013
1 parent 2db23e3 commit f90f838
Showing 1 changed file with 37 additions and 34 deletions.
71 changes: 37 additions & 34 deletions doomsday/client/src/ui/widgets/labelwidget.cpp
Expand Up @@ -280,49 +280,52 @@ public Font::RichFormat::IStyle
}
}

// By default the image and the text are centered over each other.
layout.image.move((Vector2f(layout.text.size()) - layout.image.size()) / 2);

// Determine the position of the image in relation to the text
// (keeping the image at its current position).
if(textAlign & AlignLeft)
{
layout.text.moveLeft(layout.image.left() - layout.text.width() - gap);
}
if(textAlign & AlignRight)
{
layout.text.moveLeft(layout.image.right() + gap);
}
if(textAlign & AlignTop)
{
layout.text.moveTop(layout.image.top() - layout.text.height() - gap);
}
if(textAlign & AlignBottom)
if(hasImage() && hasText())
{
layout.text.moveTop(layout.image.bottom() + gap);
}
// By default the image and the text are centered over each other.
layout.image.move((Vector2f(layout.text.size()) - layout.image.size()) / 2);

// Align the image in relation to the text on the other axis.
if(textAlign & (AlignLeft | AlignRight))
{
if(imageAlign & AlignTop)
// Determine the position of the image in relation to the text
// (keeping the image at its current position).
if(textAlign & AlignLeft)
{
layout.image.moveTop(layout.text.top());
layout.text.moveLeft(layout.image.left() - layout.text.width() - gap);
}
if(imageAlign & AlignBottom)
if(textAlign & AlignRight)
{
layout.image.moveTop(layout.text.bottom() - layout.image.height());
layout.text.moveLeft(layout.image.right() + gap);
}
}
if(textAlign & (AlignTop | AlignBottom))
{
if(imageAlign & AlignLeft)
if(textAlign & AlignTop)
{
layout.image.moveLeft(layout.text.left());
layout.text.moveTop(layout.image.top() - layout.text.height() - gap);
}
if(imageAlign & AlignRight)
if(textAlign & AlignBottom)
{
layout.image.moveLeft(layout.text.right() - layout.image.width());
layout.text.moveTop(layout.image.bottom() + gap);
}

// Align the image in relation to the text on the other axis.
if(textAlign & (AlignLeft | AlignRight))
{
if(imageAlign & AlignTop)
{
layout.image.moveTop(layout.text.top());
}
if(imageAlign & AlignBottom)
{
layout.image.moveTop(layout.text.bottom() - layout.image.height());
}
}
if(textAlign & (AlignTop | AlignBottom))
{
if(imageAlign & AlignLeft)
{
layout.image.moveLeft(layout.text.left());
}
if(imageAlign & AlignRight)
{
layout.image.moveLeft(layout.text.right() - layout.image.width());
}
}
}

Expand Down

0 comments on commit f90f838

Please sign in to comment.