mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-25 05:55:13 +00:00
My needs are really quite simple, so I'm just going to add what I need as I go along. The first thing I needed was a simple box layout with widgets being able to say whether they prefer fixed or fill for both their vertical and horizontal sizes. I also made a simple GStatusBar so FileManager can show how many bytes worth of files are in the current directory.
35 lines
825 B
C++
35 lines
825 B
C++
#include <LibGUI/GStatusBar.h>
|
|
#include <LibGUI/GLabel.h>
|
|
#include <LibGUI/GBoxLayout.h>
|
|
#include <SharedGraphics/Painter.h>
|
|
|
|
GStatusBar::GStatusBar(GWidget* parent)
|
|
: GWidget(parent)
|
|
{
|
|
set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
|
set_preferred_size({ 0, 16 });
|
|
set_layout(make<GBoxLayout>(Orientation::Horizontal));
|
|
m_label = new GLabel(this);
|
|
m_label->set_fill_with_background_color(false);
|
|
}
|
|
|
|
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&)
|
|
{
|
|
Painter painter(*this);
|
|
painter.fill_rect({ 0, 1, width(), height() - 1 }, Color::LightGray);
|
|
painter.draw_line({ 0, 0 }, { width() - 1, 0 }, Color::DarkGray);
|
|
}
|