serenity/LibGUI/GStatusBar.cpp
Andreas Kling ea9a39a9f2 LibGUI+WindowServer: Add a GResizeCorner widget.
This widget is automatically included in GStatusBar, but can be added in
any other place, too. When clicked (with the left button), it initiates a
window resize (using a WM request.)

In this patch I also fixed up some issues with override cursors being
cleared after the WindowServer finishes a drag or resize.
2019-05-03 01:38:24 +02:00

44 lines
1.1 KiB
C++

#include <LibGUI/GStatusBar.h>
#include <LibGUI/GLabel.h>
#include <LibGUI/GBoxLayout.h>
#include <SharedGraphics/StylePainter.h>
#include <LibGUI/GPainter.h>
#include <LibGUI/GResizeCorner.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 });
layout()->set_spacing(2);
m_label = new GLabel(this);
m_label->set_frame_shadow(FrameShadow::Sunken);
m_label->set_frame_shape(FrameShape::Panel);
m_label->set_frame_thickness(1);
m_label->set_text_alignment(TextAlignment::CenterLeft);
m_corner = new GResizeCorner(this);
}
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.add_clip_rect(event.rect());
StylePainter::paint_surface(painter, rect(), !spans_entire_window_horizontally());
}