Fix SNIPaddingTop for sideways bar

This commit is contained in:
scorpion-26 2023-07-21 01:24:25 +02:00
parent f78758c4ee
commit 42a0710551

View file

@ -533,15 +533,28 @@ void Texture::Draw(cairo_t* cr)
double scaleX = q.size / m_Width; double scaleX = q.size / m_Width;
double scaleY = q.size / m_Height; double scaleY = q.size / m_Height;
double paddingX, paddingY;
if (m_Angle == 90)
{
// Hack for sideways bars
paddingX = -m_Padding;
paddingY = 0;
}
else
{
paddingX = 0;
paddingY = m_Padding;
}
// Rotate around center of Quad // Rotate around center of Quad
cairo_rectangle(cr, q.x, q.y + m_Padding, q.size, q.size); cairo_translate(cr, q.x + paddingX + q.size / 2, q.y + paddingY + q.size / 2);
cairo_translate(cr, q.x + q.size / 2, q.y + m_Padding + q.size / 2);
cairo_rotate(cr, m_Angle * M_PI / 180.0); cairo_rotate(cr, m_Angle * M_PI / 180.0);
cairo_translate(cr, -(q.x + q.size / 2), -(q.y + m_Padding + q.size / 2)); cairo_translate(cr, -(q.x + paddingX + q.size / 2), -(q.y + paddingY + q.size / 2));
cairo_rectangle(cr, q.x + paddingX, q.y + paddingY, q.size, q.size);
cairo_scale(cr, scaleX, scaleY); cairo_scale(cr, scaleX, scaleY);
gdk_cairo_set_source_pixbuf(cr, m_Pixbuf, q.x, (q.y + m_Padding) * (1.f / scaleY)); gdk_cairo_set_source_pixbuf(cr, m_Pixbuf, (q.x + paddingX) * (1.0 / scaleY), (q.y + paddingY) * (1.0 / scaleY));
cairo_fill(cr); cairo_fill(cr);
} }