mirror of
https://github.com/RGBCube/serenity
synced 2025-05-19 16:35:06 +00:00

In other words, if a surface stretches from the left side of the window all the way to the right side, skip shading and highlighting the sides. This makes widgets blend together just slightly with the window. :^)
40 lines
1 KiB
C++
40 lines
1 KiB
C++
#include <LibGUI/GStatusBar.h>
|
|
#include <LibGUI/GLabel.h>
|
|
#include <LibGUI/GBoxLayout.h>
|
|
#include <SharedGraphics/StylePainter.h>
|
|
#include <LibGUI/GPainter.h>
|
|
|
|
GStatusBar::GStatusBar(GWidget* parent)
|
|
: GWidget(parent)
|
|
{
|
|
set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
|
set_preferred_size({ 0, 20 });
|
|
set_layout(make<GBoxLayout>(Orientation::Horizontal));
|
|
layout()->set_margins({ 2, 2, 2, 2 });
|
|
m_label = new GLabel(this);
|
|
m_label->set_frame_shadow(GFrame::Shadow::Sunken);
|
|
m_label->set_frame_shape(GFrame::Shape::Panel);
|
|
m_label->set_frame_thickness(1);
|
|
m_label->set_text_alignment(TextAlignment::CenterLeft);
|
|
}
|
|
|
|
GStatusBar::~GStatusBar()
|
|
{
|
|
}
|
|
|
|
void GStatusBar::set_text(String&& text)
|
|
{
|
|
m_label->set_text(move(text));
|
|
}
|
|
|
|
String GStatusBar::text() const
|
|
{
|
|
return m_label->text();
|
|
}
|
|
|
|
void GStatusBar::paint_event(GPaintEvent& event)
|
|
{
|
|
GPainter painter(*this);
|
|
painter.set_clip_rect(event.rect());
|
|
StylePainter::the().paint_surface(painter, rect(), !spans_entire_window_horizontally());
|
|
}
|