1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:28:10 +00:00

LibGUI: Improve GStatusBar and GToolBar and share some code via GStyle.

This commit is contained in:
Andreas Kling 2019-03-04 10:47:54 +01:00
parent ac2a3f7fdf
commit 4ea7a51ecd
4 changed files with 18 additions and 11 deletions

View file

@ -1,15 +1,16 @@
#include <LibGUI/GStatusBar.h>
#include <LibGUI/GLabel.h>
#include <LibGUI/GBoxLayout.h>
#include <LibGUI/GStyle.h>
#include <SharedGraphics/Painter.h>
GStatusBar::GStatusBar(GWidget* parent)
: GWidget(parent)
{
set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
set_preferred_size({ 0, 18 });
set_preferred_size({ 0, 20 });
set_layout(make<GBoxLayout>(Orientation::Horizontal));
layout()->set_margins({ 1, 1, 1, 1 });
layout()->set_margins({ 4, 2, 4, 2 });
m_label = new GLabel(this);
m_label->set_text_alignment(TextAlignment::CenterLeft);
m_label->set_fill_with_background_color(false);
@ -33,7 +34,5 @@ void GStatusBar::paint_event(GPaintEvent& event)
{
Painter painter(*this);
painter.set_clip_rect(event.rect());
painter.fill_rect({ 0, 1, width(), height() - 1 }, Color::LightGray);
painter.draw_line({ 0, 0 }, { width() - 1, 0 }, Color::White);
painter.draw_line({ 0, rect().bottom() }, { width() - 1, rect().bottom() }, Color::DarkGray);
GStyle::the().paint_surface(painter, rect());
}