mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:18:11 +00:00
LibGUI: Add a GPainter class that inherits from Painter.
This gets rid of the last little piece of LibGUI knowledge in Painter.
This commit is contained in:
parent
326c6fd607
commit
9fa21fa585
27 changed files with 75 additions and 78 deletions
|
@ -7,7 +7,7 @@
|
||||||
#include <AK/FileSystemPath.h>
|
#include <AK/FileSystemPath.h>
|
||||||
#include <AK/StringBuilder.h>
|
#include <AK/StringBuilder.h>
|
||||||
#include <SharedGraphics/GraphicsBitmap.h>
|
#include <SharedGraphics/GraphicsBitmap.h>
|
||||||
#include <SharedGraphics/Painter.h>
|
#include <LibGUI/GPainter.h>
|
||||||
#include <LibGUI/GLock.h>
|
#include <LibGUI/GLock.h>
|
||||||
|
|
||||||
static GLockable<HashMap<String, RetainPtr<GraphicsBitmap>>>& thumbnail_cache()
|
static GLockable<HashMap<String, RetainPtr<GraphicsBitmap>>>& thumbnail_cache()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "FontEditor.h"
|
#include "FontEditor.h"
|
||||||
#include <SharedGraphics/Painter.h>
|
#include <LibGUI/GPainter.h>
|
||||||
#include <LibGUI/GButton.h>
|
#include <LibGUI/GButton.h>
|
||||||
#include <LibGUI/GLabel.h>
|
#include <LibGUI/GLabel.h>
|
||||||
#include <LibGUI/GTextBox.h>
|
#include <LibGUI/GTextBox.h>
|
||||||
|
@ -158,7 +158,7 @@ Rect GlyphMapWidget::get_outer_rect(byte glyph) const
|
||||||
|
|
||||||
void GlyphMapWidget::paint_event(GPaintEvent&)
|
void GlyphMapWidget::paint_event(GPaintEvent&)
|
||||||
{
|
{
|
||||||
Painter painter(*this);
|
GPainter painter(*this);
|
||||||
painter.set_font(font());
|
painter.set_font(font());
|
||||||
painter.fill_rect(rect(), Color::White);
|
painter.fill_rect(rect(), Color::White);
|
||||||
painter.draw_rect(rect(), Color::Black);
|
painter.draw_rect(rect(), Color::Black);
|
||||||
|
@ -219,7 +219,7 @@ void GlyphEditorWidget::set_glyph(byte glyph)
|
||||||
|
|
||||||
void GlyphEditorWidget::paint_event(GPaintEvent&)
|
void GlyphEditorWidget::paint_event(GPaintEvent&)
|
||||||
{
|
{
|
||||||
Painter painter(*this);
|
GPainter painter(*this);
|
||||||
painter.fill_rect(rect(), Color::White);
|
painter.fill_rect(rect(), Color::White);
|
||||||
painter.draw_rect(rect(), Color::Black);
|
painter.draw_rect(rect(), Color::Black);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "MemoryStatsWidget.h"
|
#include "MemoryStatsWidget.h"
|
||||||
#include <SharedGraphics/Painter.h>
|
#include <LibGUI/GPainter.h>
|
||||||
#include <LibGUI/GBoxLayout.h>
|
#include <LibGUI/GBoxLayout.h>
|
||||||
#include <LibGUI/GLabel.h>
|
#include <LibGUI/GLabel.h>
|
||||||
#include <LibGUI/GStyle.h>
|
#include <LibGUI/GStyle.h>
|
||||||
|
@ -104,7 +104,7 @@ void MemoryStatsWidget::timer_event(GTimerEvent&)
|
||||||
|
|
||||||
void MemoryStatsWidget::paint_event(GPaintEvent& event)
|
void MemoryStatsWidget::paint_event(GPaintEvent& event)
|
||||||
{
|
{
|
||||||
Painter painter(*this);
|
GPainter painter(*this);
|
||||||
painter.set_clip_rect(event.rect());
|
painter.set_clip_rect(event.rect());
|
||||||
GStyle::the().paint_surface(painter, rect());
|
GStyle::the().paint_surface(painter, rect());
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include <AK/AKString.h>
|
#include <AK/AKString.h>
|
||||||
#include <AK/StringBuilder.h>
|
#include <AK/StringBuilder.h>
|
||||||
#include <SharedGraphics/Font.h>
|
#include <SharedGraphics/Font.h>
|
||||||
#include <SharedGraphics/Painter.h>
|
#include <LibGUI/GPainter.h>
|
||||||
#include <AK/StdLibExtras.h>
|
#include <AK/StdLibExtras.h>
|
||||||
#include <LibGUI/GApplication.h>
|
#include <LibGUI/GApplication.h>
|
||||||
#include <LibGUI/GWindow.h>
|
#include <LibGUI/GWindow.h>
|
||||||
|
@ -761,7 +761,7 @@ void Terminal::keydown_event(GKeyEvent& event)
|
||||||
|
|
||||||
void Terminal::paint_event(GPaintEvent&)
|
void Terminal::paint_event(GPaintEvent&)
|
||||||
{
|
{
|
||||||
Painter painter(*this);
|
GPainter painter(*this);
|
||||||
|
|
||||||
if (m_needs_background_fill) {
|
if (m_needs_background_fill) {
|
||||||
m_needs_background_fill = false;
|
m_needs_background_fill = false;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include <LibGUI/GAbstractView.h>
|
#include <LibGUI/GAbstractView.h>
|
||||||
#include <LibGUI/GModel.h>
|
#include <LibGUI/GModel.h>
|
||||||
#include <LibGUI/GScrollBar.h>
|
#include <LibGUI/GScrollBar.h>
|
||||||
#include <SharedGraphics/Painter.h>
|
#include <LibGUI/GPainter.h>
|
||||||
#include <Kernel/KeyCode.h>
|
#include <Kernel/KeyCode.h>
|
||||||
|
|
||||||
GAbstractView::GAbstractView(GWidget* parent)
|
GAbstractView::GAbstractView(GWidget* parent)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "GButton.h"
|
#include "GButton.h"
|
||||||
#include <SharedGraphics/Painter.h>
|
#include <LibGUI/GPainter.h>
|
||||||
#include <LibGUI/GStyle.h>
|
#include <LibGUI/GStyle.h>
|
||||||
|
|
||||||
//#define GBUTTON_DEBUG
|
//#define GBUTTON_DEBUG
|
||||||
|
@ -23,7 +23,7 @@ void GButton::set_caption(const String& caption)
|
||||||
|
|
||||||
void GButton::paint_event(GPaintEvent& event)
|
void GButton::paint_event(GPaintEvent& event)
|
||||||
{
|
{
|
||||||
Painter painter(*this);
|
GPainter painter(*this);
|
||||||
painter.set_clip_rect(event.rect());
|
painter.set_clip_rect(event.rect());
|
||||||
|
|
||||||
GStyle::the().paint_button(painter, rect(), m_button_style, m_being_pressed, m_hovered);
|
GStyle::the().paint_button(painter, rect(), m_button_style, m_being_pressed, m_hovered);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "GCheckBox.h"
|
#include "GCheckBox.h"
|
||||||
#include <SharedGraphics/Painter.h>
|
#include <LibGUI/GPainter.h>
|
||||||
#include <SharedGraphics/CharacterBitmap.h>
|
#include <SharedGraphics/CharacterBitmap.h>
|
||||||
#include <Kernel/KeyCode.h>
|
#include <Kernel/KeyCode.h>
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ void GCheckBox::set_checked(bool b)
|
||||||
|
|
||||||
void GCheckBox::paint_event(GPaintEvent& event)
|
void GCheckBox::paint_event(GPaintEvent& event)
|
||||||
{
|
{
|
||||||
Painter painter(*this);
|
GPainter painter(*this);
|
||||||
painter.set_clip_rect(event.rect());
|
painter.set_clip_rect(event.rect());
|
||||||
|
|
||||||
auto text_rect = rect();
|
auto text_rect = rect();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include <LibGUI/GFrame.h>
|
#include <LibGUI/GFrame.h>
|
||||||
#include <LibGUI/GStyle.h>
|
#include <LibGUI/GStyle.h>
|
||||||
#include <SharedGraphics/Painter.h>
|
#include <LibGUI/GPainter.h>
|
||||||
|
|
||||||
GFrame::GFrame(GWidget* parent)
|
GFrame::GFrame(GWidget* parent)
|
||||||
: GWidget(parent)
|
: GWidget(parent)
|
||||||
|
@ -16,7 +16,7 @@ void GFrame::paint_event(GPaintEvent& event)
|
||||||
if (m_shape == Shape::NoFrame)
|
if (m_shape == Shape::NoFrame)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Painter painter(*this);
|
GPainter painter(*this);
|
||||||
painter.set_clip_rect(event.rect());
|
painter.set_clip_rect(event.rect());
|
||||||
|
|
||||||
auto rect = this->rect();
|
auto rect = this->rect();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include <LibGUI/GItemView.h>
|
#include <LibGUI/GItemView.h>
|
||||||
#include <LibGUI/GModel.h>
|
#include <LibGUI/GModel.h>
|
||||||
#include <LibGUI/GScrollBar.h>
|
#include <LibGUI/GScrollBar.h>
|
||||||
#include <SharedGraphics/Painter.h>
|
#include <LibGUI/GPainter.h>
|
||||||
#include <Kernel/KeyCode.h>
|
#include <Kernel/KeyCode.h>
|
||||||
|
|
||||||
GItemView::GItemView(GWidget* parent)
|
GItemView::GItemView(GWidget* parent)
|
||||||
|
@ -98,7 +98,7 @@ void GItemView::paint_event(GPaintEvent& event)
|
||||||
{
|
{
|
||||||
GFrame::paint_event(event);
|
GFrame::paint_event(event);
|
||||||
|
|
||||||
Painter painter(*this);
|
GPainter painter(*this);
|
||||||
painter.set_clip_rect(widget_inner_rect());
|
painter.set_clip_rect(widget_inner_rect());
|
||||||
painter.set_clip_rect(event.rect());
|
painter.set_clip_rect(event.rect());
|
||||||
painter.fill_rect(event.rect(), Color::White);
|
painter.fill_rect(event.rect(), Color::White);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "GLabel.h"
|
#include "GLabel.h"
|
||||||
#include <SharedGraphics/Painter.h>
|
#include <LibGUI/GPainter.h>
|
||||||
#include <SharedGraphics/GraphicsBitmap.h>
|
#include <SharedGraphics/GraphicsBitmap.h>
|
||||||
|
|
||||||
GLabel::GLabel(GWidget* parent)
|
GLabel::GLabel(GWidget* parent)
|
||||||
|
@ -34,7 +34,7 @@ void GLabel::paint_event(GPaintEvent& event)
|
||||||
{
|
{
|
||||||
GFrame::paint_event(event);
|
GFrame::paint_event(event);
|
||||||
|
|
||||||
Painter painter(*this);
|
GPainter painter(*this);
|
||||||
painter.set_clip_rect(event.rect());
|
painter.set_clip_rect(event.rect());
|
||||||
|
|
||||||
if (m_icon) {
|
if (m_icon) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "GListBox.h"
|
#include "GListBox.h"
|
||||||
#include <SharedGraphics/Font.h>
|
#include <SharedGraphics/Font.h>
|
||||||
#include <SharedGraphics/Painter.h>
|
#include <LibGUI/GPainter.h>
|
||||||
|
|
||||||
GListBox::GListBox(GWidget* parent)
|
GListBox::GListBox(GWidget* parent)
|
||||||
: GWidget(parent)
|
: GWidget(parent)
|
||||||
|
@ -19,7 +19,7 @@ Rect GListBox::item_rect(int index) const
|
||||||
|
|
||||||
void GListBox::paint_event(GPaintEvent& event)
|
void GListBox::paint_event(GPaintEvent& event)
|
||||||
{
|
{
|
||||||
Painter painter(*this);
|
GPainter painter(*this);
|
||||||
painter.set_clip_rect(event.rect());
|
painter.set_clip_rect(event.rect());
|
||||||
|
|
||||||
painter.fill_rect({ rect().x() + 1, rect().y() + 1, rect().width() - 2, rect().height() - 2 }, background_color());
|
painter.fill_rect({ rect().x() + 1, rect().y() + 1, rect().width() - 2, rect().height() - 2 }, background_color());
|
||||||
|
|
19
LibGUI/GPainter.cpp
Normal file
19
LibGUI/GPainter.cpp
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
#include <LibGUI/GPainter.h>
|
||||||
|
#include <LibGUI/GWidget.h>
|
||||||
|
#include <LibGUI/GWindow.h>
|
||||||
|
|
||||||
|
GPainter::GPainter(GraphicsBitmap& bitmap)
|
||||||
|
: Painter(bitmap)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
GPainter::GPainter(GWidget& widget)
|
||||||
|
: Painter(*widget.window()->back_bitmap())
|
||||||
|
{
|
||||||
|
state().font = &widget.font();
|
||||||
|
auto origin_rect = widget.window_relative_rect();
|
||||||
|
state().translation = origin_rect.location();
|
||||||
|
state().clip_rect = origin_rect;
|
||||||
|
m_clip_origin = origin_rect;
|
||||||
|
state().clip_rect.intersect(m_target->rect());
|
||||||
|
}
|
12
LibGUI/GPainter.h
Normal file
12
LibGUI/GPainter.h
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <SharedGraphics/Painter.h>
|
||||||
|
|
||||||
|
class GWidget;
|
||||||
|
class GraphicsBitmap;
|
||||||
|
|
||||||
|
class GPainter : public Painter {
|
||||||
|
public:
|
||||||
|
explicit GPainter(GWidget&);
|
||||||
|
explicit GPainter(GraphicsBitmap&);
|
||||||
|
};
|
|
@ -1,5 +1,5 @@
|
||||||
#include <LibGUI/GProgressBar.h>
|
#include <LibGUI/GProgressBar.h>
|
||||||
#include <SharedGraphics/Painter.h>
|
#include <LibGUI/GPainter.h>
|
||||||
#include <AK/StringBuilder.h>
|
#include <AK/StringBuilder.h>
|
||||||
|
|
||||||
GProgressBar::GProgressBar(GWidget* parent)
|
GProgressBar::GProgressBar(GWidget* parent)
|
||||||
|
@ -32,7 +32,7 @@ void GProgressBar::set_range(int min, int max)
|
||||||
|
|
||||||
void GProgressBar::paint_event(GPaintEvent& event)
|
void GProgressBar::paint_event(GPaintEvent& event)
|
||||||
{
|
{
|
||||||
Painter painter(*this);
|
GPainter painter(*this);
|
||||||
painter.set_clip_rect(event.rect());
|
painter.set_clip_rect(event.rect());
|
||||||
|
|
||||||
// First we fill the entire widget with the gradient. This incurs a bit of
|
// First we fill the entire widget with the gradient. This incurs a bit of
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include <LibGUI/GStyle.h>
|
#include <LibGUI/GStyle.h>
|
||||||
#include <SharedGraphics/CharacterBitmap.h>
|
#include <SharedGraphics/CharacterBitmap.h>
|
||||||
#include <SharedGraphics/GraphicsBitmap.h>
|
#include <SharedGraphics/GraphicsBitmap.h>
|
||||||
#include <SharedGraphics/Painter.h>
|
#include <LibGUI/GPainter.h>
|
||||||
|
|
||||||
//#define GUTTER_DOES_PAGEUP_PAGEDOWN
|
//#define GUTTER_DOES_PAGEUP_PAGEDOWN
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ Rect GScrollBar::scrubber_rect() const
|
||||||
|
|
||||||
void GScrollBar::paint_event(GPaintEvent& event)
|
void GScrollBar::paint_event(GPaintEvent& event)
|
||||||
{
|
{
|
||||||
Painter painter(*this);
|
GPainter painter(*this);
|
||||||
painter.set_clip_rect(event.rect());
|
painter.set_clip_rect(event.rect());
|
||||||
|
|
||||||
painter.fill_rect(rect(), Color(164, 164, 164));
|
painter.fill_rect(rect(), Color(164, 164, 164));
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include <LibGUI/GLabel.h>
|
#include <LibGUI/GLabel.h>
|
||||||
#include <LibGUI/GBoxLayout.h>
|
#include <LibGUI/GBoxLayout.h>
|
||||||
#include <LibGUI/GStyle.h>
|
#include <LibGUI/GStyle.h>
|
||||||
#include <SharedGraphics/Painter.h>
|
#include <LibGUI/GPainter.h>
|
||||||
|
|
||||||
GStatusBar::GStatusBar(GWidget* parent)
|
GStatusBar::GStatusBar(GWidget* parent)
|
||||||
: GWidget(parent)
|
: GWidget(parent)
|
||||||
|
@ -34,7 +34,7 @@ String GStatusBar::text() const
|
||||||
|
|
||||||
void GStatusBar::paint_event(GPaintEvent& event)
|
void GStatusBar::paint_event(GPaintEvent& event)
|
||||||
{
|
{
|
||||||
Painter painter(*this);
|
GPainter painter(*this);
|
||||||
painter.set_clip_rect(event.rect());
|
painter.set_clip_rect(event.rect());
|
||||||
GStyle::the().paint_surface(painter, rect());
|
GStyle::the().paint_surface(painter, rect());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include <LibGUI/GStyle.h>
|
#include <LibGUI/GStyle.h>
|
||||||
#include <SharedGraphics/Painter.h>
|
#include <LibGUI/GPainter.h>
|
||||||
|
|
||||||
static GStyle* s_the;
|
static GStyle* s_the;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include <LibGUI/GTableView.h>
|
#include <LibGUI/GTableView.h>
|
||||||
#include <LibGUI/GModel.h>
|
#include <LibGUI/GModel.h>
|
||||||
#include <LibGUI/GScrollBar.h>
|
#include <LibGUI/GScrollBar.h>
|
||||||
#include <SharedGraphics/Painter.h>
|
#include <LibGUI/GPainter.h>
|
||||||
#include <Kernel/KeyCode.h>
|
#include <Kernel/KeyCode.h>
|
||||||
|
|
||||||
GTableView::GTableView(GWidget* parent)
|
GTableView::GTableView(GWidget* parent)
|
||||||
|
@ -100,7 +100,7 @@ void GTableView::paint_event(GPaintEvent& event)
|
||||||
{
|
{
|
||||||
GFrame::paint_event(event);
|
GFrame::paint_event(event);
|
||||||
|
|
||||||
Painter painter(*this);
|
GPainter painter(*this);
|
||||||
painter.set_clip_rect(frame_inner_rect());
|
painter.set_clip_rect(frame_inner_rect());
|
||||||
painter.set_clip_rect(event.rect());
|
painter.set_clip_rect(event.rect());
|
||||||
painter.save();
|
painter.save();
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include <AK/StdLibExtras.h>
|
#include <AK/StdLibExtras.h>
|
||||||
#include <SharedGraphics/CharacterBitmap.h>
|
#include <SharedGraphics/CharacterBitmap.h>
|
||||||
#include <SharedGraphics/Font.h>
|
#include <SharedGraphics/Font.h>
|
||||||
#include <SharedGraphics/Painter.h>
|
#include <LibGUI/GPainter.h>
|
||||||
#include <Kernel/KeyCode.h>
|
#include <Kernel/KeyCode.h>
|
||||||
|
|
||||||
GTextBox::GTextBox(GWidget* parent)
|
GTextBox::GTextBox(GWidget* parent)
|
||||||
|
@ -73,7 +73,7 @@ Point GTextBox::cursor_content_position() const
|
||||||
|
|
||||||
void GTextBox::paint_event(GPaintEvent& event)
|
void GTextBox::paint_event(GPaintEvent& event)
|
||||||
{
|
{
|
||||||
Painter painter(*this);
|
GPainter painter(*this);
|
||||||
painter.set_clip_rect(event.rect());
|
painter.set_clip_rect(event.rect());
|
||||||
|
|
||||||
painter.fill_rect(rect().shrunken(2, 2), background_color());
|
painter.fill_rect(rect().shrunken(2, 2), background_color());
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include <LibGUI/GScrollBar.h>
|
#include <LibGUI/GScrollBar.h>
|
||||||
#include <LibGUI/GFontDatabase.h>
|
#include <LibGUI/GFontDatabase.h>
|
||||||
#include <LibGUI/GClipboard.h>
|
#include <LibGUI/GClipboard.h>
|
||||||
#include <SharedGraphics/Painter.h>
|
#include <LibGUI/GPainter.h>
|
||||||
#include <Kernel/KeyCode.h>
|
#include <Kernel/KeyCode.h>
|
||||||
#include <AK/StringBuilder.h>
|
#include <AK/StringBuilder.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -152,7 +152,7 @@ void GTextEditor::paint_event(GPaintEvent& event)
|
||||||
{
|
{
|
||||||
GFrame::paint_event(event);
|
GFrame::paint_event(event);
|
||||||
|
|
||||||
Painter painter(*this);
|
GPainter painter(*this);
|
||||||
painter.set_clip_rect(widget_inner_rect());
|
painter.set_clip_rect(widget_inner_rect());
|
||||||
painter.set_clip_rect(event.rect());
|
painter.set_clip_rect(event.rect());
|
||||||
painter.fill_rect(event.rect(), Color::White);
|
painter.fill_rect(event.rect(), Color::White);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include <LibGUI/GBoxLayout.h>
|
#include <LibGUI/GBoxLayout.h>
|
||||||
#include <LibGUI/GButton.h>
|
#include <LibGUI/GButton.h>
|
||||||
#include <LibGUI/GAction.h>
|
#include <LibGUI/GAction.h>
|
||||||
#include <SharedGraphics/Painter.h>
|
#include <LibGUI/GPainter.h>
|
||||||
|
|
||||||
GToolBar::GToolBar(GWidget* parent)
|
GToolBar::GToolBar(GWidget* parent)
|
||||||
: GWidget(parent)
|
: GWidget(parent)
|
||||||
|
@ -56,7 +56,7 @@ public:
|
||||||
|
|
||||||
virtual void paint_event(GPaintEvent& event) override
|
virtual void paint_event(GPaintEvent& event) override
|
||||||
{
|
{
|
||||||
Painter painter(*this);
|
GPainter painter(*this);
|
||||||
painter.set_clip_rect(event.rect());
|
painter.set_clip_rect(event.rect());
|
||||||
painter.translate(rect().center().x() - 1, 0);
|
painter.translate(rect().center().x() - 1, 0);
|
||||||
painter.draw_line({ 0, 0 }, { 0, rect().bottom() }, Color::MidGray);
|
painter.draw_line({ 0, 0 }, { 0, rect().bottom() }, Color::MidGray);
|
||||||
|
@ -77,7 +77,7 @@ void GToolBar::add_separator()
|
||||||
|
|
||||||
void GToolBar::paint_event(GPaintEvent& event)
|
void GToolBar::paint_event(GPaintEvent& event)
|
||||||
{
|
{
|
||||||
Painter painter(*this);
|
GPainter painter(*this);
|
||||||
painter.set_clip_rect(event.rect());
|
painter.set_clip_rect(event.rect());
|
||||||
GStyle::the().paint_surface(painter, rect());
|
GStyle::the().paint_surface(painter, rect());
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include <LibGUI/GLayout.h>
|
#include <LibGUI/GLayout.h>
|
||||||
#include <AK/Assertions.h>
|
#include <AK/Assertions.h>
|
||||||
#include <SharedGraphics/GraphicsBitmap.h>
|
#include <SharedGraphics/GraphicsBitmap.h>
|
||||||
#include <SharedGraphics/Painter.h>
|
#include <LibGUI/GPainter.h>
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
@ -85,13 +85,13 @@ void GWidget::handle_paint_event(GPaintEvent& event)
|
||||||
{
|
{
|
||||||
ASSERT(is_visible());
|
ASSERT(is_visible());
|
||||||
if (fill_with_background_color()) {
|
if (fill_with_background_color()) {
|
||||||
Painter painter(*this);
|
GPainter painter(*this);
|
||||||
painter.fill_rect(event.rect(), background_color());
|
painter.fill_rect(event.rect(), background_color());
|
||||||
} else {
|
} else {
|
||||||
#ifdef DEBUG_WIDGET_UNDERDRAW
|
#ifdef DEBUG_WIDGET_UNDERDRAW
|
||||||
// FIXME: This is a bit broken.
|
// FIXME: This is a bit broken.
|
||||||
// If the widget is not opaque, let's not mess it up with debugging color.
|
// If the widget is not opaque, let's not mess it up with debugging color.
|
||||||
Painter painter(*this);
|
GPainter painter(*this);
|
||||||
painter.fill_rect(rect(), Color::Red);
|
painter.fill_rect(rect(), Color::Red);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include "GEventLoop.h"
|
#include "GEventLoop.h"
|
||||||
#include "GWidget.h"
|
#include "GWidget.h"
|
||||||
#include <SharedGraphics/GraphicsBitmap.h>
|
#include <SharedGraphics/GraphicsBitmap.h>
|
||||||
#include <SharedGraphics/Painter.h>
|
#include <LibGUI/GPainter.h>
|
||||||
#include <LibC/stdio.h>
|
#include <LibC/stdio.h>
|
||||||
#include <LibC/stdlib.h>
|
#include <LibC/stdlib.h>
|
||||||
#include <LibC/unistd.h>
|
#include <LibC/unistd.h>
|
||||||
|
|
|
@ -8,6 +8,7 @@ SHAREDGRAPHICS_OBJS = \
|
||||||
../SharedGraphics/PNGLoader.o
|
../SharedGraphics/PNGLoader.o
|
||||||
|
|
||||||
LIBGUI_OBJS = \
|
LIBGUI_OBJS = \
|
||||||
|
GPainter.o \
|
||||||
GIODevice.o \
|
GIODevice.o \
|
||||||
GFile.o \
|
GFile.o \
|
||||||
GButton.o \
|
GButton.o \
|
||||||
|
|
|
@ -4,16 +4,6 @@
|
||||||
#include <SharedGraphics/CharacterBitmap.h>
|
#include <SharedGraphics/CharacterBitmap.h>
|
||||||
#include <AK/Assertions.h>
|
#include <AK/Assertions.h>
|
||||||
#include <AK/StdLibExtras.h>
|
#include <AK/StdLibExtras.h>
|
||||||
|
|
||||||
#ifdef LIBGUI
|
|
||||||
#include <LibGUI/GWidget.h>
|
|
||||||
#include <LibGUI/GWindow.h>
|
|
||||||
#include <LibGUI/GEventLoop.h>
|
|
||||||
#include <LibC/stdio.h>
|
|
||||||
#include <LibC/errno.h>
|
|
||||||
#include <LibC/string.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
Painter::Painter(GraphicsBitmap& bitmap)
|
Painter::Painter(GraphicsBitmap& bitmap)
|
||||||
|
@ -25,22 +15,6 @@ Painter::Painter(GraphicsBitmap& bitmap)
|
||||||
m_clip_origin = state().clip_rect;
|
m_clip_origin = state().clip_rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LIBGUI
|
|
||||||
Painter::Painter(GWidget& widget)
|
|
||||||
: m_window(widget.window())
|
|
||||||
, m_target(*m_window->back_bitmap())
|
|
||||||
{
|
|
||||||
m_state_stack.append(State());
|
|
||||||
state().font = &widget.font();
|
|
||||||
|
|
||||||
auto origin_rect = widget.window_relative_rect();
|
|
||||||
state().translation = origin_rect.location();
|
|
||||||
state().clip_rect = origin_rect;
|
|
||||||
m_clip_origin = origin_rect;
|
|
||||||
state().clip_rect.intersect(m_target->rect());
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Painter::~Painter()
|
Painter::~Painter()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,16 +12,8 @@ class GlyphBitmap;
|
||||||
class GraphicsBitmap;
|
class GraphicsBitmap;
|
||||||
class Font;
|
class Font;
|
||||||
|
|
||||||
#ifdef USERLAND
|
|
||||||
class GWidget;
|
|
||||||
class GWindow;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class Painter {
|
class Painter {
|
||||||
public:
|
public:
|
||||||
#ifdef USERLAND
|
|
||||||
explicit Painter(GWidget&);
|
|
||||||
#endif
|
|
||||||
explicit Painter(GraphicsBitmap&);
|
explicit Painter(GraphicsBitmap&);
|
||||||
~Painter();
|
~Painter();
|
||||||
void fill_rect(const Rect&, Color);
|
void fill_rect(const Rect&, Color);
|
||||||
|
@ -64,7 +56,7 @@ public:
|
||||||
void save() { m_state_stack.append(m_state_stack.last()); }
|
void save() { m_state_stack.append(m_state_stack.last()); }
|
||||||
void restore() { ASSERT(m_state_stack.size() > 1); m_state_stack.take_last(); }
|
void restore() { ASSERT(m_state_stack.size() > 1); m_state_stack.take_last(); }
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
void set_pixel_with_draw_op(dword& pixel, const Color&);
|
void set_pixel_with_draw_op(dword& pixel, const Color&);
|
||||||
void fill_rect_with_draw_op(const Rect&, Color);
|
void fill_rect_with_draw_op(const Rect&, Color);
|
||||||
void blit_with_alpha(const Point&, const GraphicsBitmap&, const Rect& src_rect);
|
void blit_with_alpha(const Point&, const GraphicsBitmap&, const Rect& src_rect);
|
||||||
|
@ -80,7 +72,6 @@ private:
|
||||||
const State& state() const { return m_state_stack.last(); }
|
const State& state() const { return m_state_stack.last(); }
|
||||||
|
|
||||||
Rect m_clip_origin;
|
Rect m_clip_origin;
|
||||||
GWindow* m_window { nullptr };
|
|
||||||
Retained<GraphicsBitmap> m_target;
|
Retained<GraphicsBitmap> m_target;
|
||||||
Vector<State> m_state_stack;
|
Vector<State> m_state_stack;
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <Kernel/Syscall.h>
|
#include <Kernel/Syscall.h>
|
||||||
#include <SharedGraphics/GraphicsBitmap.h>
|
#include <SharedGraphics/GraphicsBitmap.h>
|
||||||
#include <SharedGraphics/Painter.h>
|
#include <LibGUI/GPainter.h>
|
||||||
#include <LibGUI/GWindow.h>
|
#include <LibGUI/GWindow.h>
|
||||||
#include <LibGUI/GWidget.h>
|
#include <LibGUI/GWidget.h>
|
||||||
#include <LibGUI/GLabel.h>
|
#include <LibGUI/GLabel.h>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue