mirror of
https://github.com/scorpion-26/gBar.git
synced 2024-11-22 03:02:49 +00:00
SNI: Proper alignment for the icons
This commit is contained in:
parent
8e953f985b
commit
d4ffac395b
2 changed files with 10 additions and 3 deletions
|
@ -41,13 +41,14 @@ namespace SNI
|
||||||
parentBox->RemoveChild(iconBox);
|
parentBox->RemoveChild(iconBox);
|
||||||
|
|
||||||
auto container = Widget::Create<Box>();
|
auto container = Widget::Create<Box>();
|
||||||
|
container->SetSpacing({4, false});
|
||||||
iconBox = container.get();
|
iconBox = container.get();
|
||||||
for (auto& item : items)
|
for (auto& item : items)
|
||||||
{
|
{
|
||||||
if (item.iconData)
|
if (item.iconData)
|
||||||
{
|
{
|
||||||
auto texture = Widget::Create<Texture>();
|
auto texture = Widget::Create<Texture>();
|
||||||
texture->SetHorizontalTransform({32, true, Alignment::Fill});
|
texture->SetHorizontalTransform({0, true, Alignment::Fill});
|
||||||
texture->SetBuf(item.w, item.h, item.iconData);
|
texture->SetBuf(item.w, item.h, item.iconData);
|
||||||
iconBox->AddChild(std::move(texture));
|
iconBox->AddChild(std::move(texture));
|
||||||
}
|
}
|
||||||
|
|
|
@ -515,8 +515,14 @@ void Texture::SetBuf(size_t width, size_t height, uint8_t* buf)
|
||||||
|
|
||||||
void Texture::Draw(cairo_t* cr)
|
void Texture::Draw(cairo_t* cr)
|
||||||
{
|
{
|
||||||
// TODO: W + H
|
GtkAllocation dim;
|
||||||
cairo_rectangle(cr, 0.f, 0.f, 32.f, 32.f);
|
gtk_widget_get_allocation(m_Widget, &dim);
|
||||||
|
double ratio = (double)m_Width / (double)m_Height;
|
||||||
|
gtk_widget_set_size_request(m_Widget, dim.height * ratio, dim.height);
|
||||||
|
|
||||||
|
double scale = (double)dim.height / (double)m_Height;
|
||||||
|
cairo_scale(cr, scale, scale);
|
||||||
|
cairo_rectangle(cr, 0.f, 0.f, m_Width, m_Height);
|
||||||
gdk_cairo_set_source_pixbuf(cr, m_Pixbuf, 0, 0);
|
gdk_cairo_set_source_pixbuf(cr, m_Pixbuf, 0, 0);
|
||||||
cairo_fill(cr);
|
cairo_fill(cr);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue