LibGUI: Mass coding style fixes.

This commit is contained in:
Andreas Kling 2019-01-21 00:46:08 +01:00
parent 6c4f1bad09
commit d66b0f7dd8
Notes: sideshowbarker 2024-07-19 15:59:43 +09:00
15 changed files with 178 additions and 178 deletions

View file

@ -4,7 +4,7 @@
GButton::GButton(GWidget* parent)
: GWidget(parent)
{
setFillWithBackgroundColor(false);
set_fill_with_background_color(false);
}
GButton::~GButton()
@ -19,11 +19,11 @@ void GButton::set_caption(String&& caption)
update();
}
void GButton::paintEvent(GPaintEvent&)
void GButton::paint_event(GPaintEvent&)
{
Color buttonColor = Color::LightGray;
Color highlightColor = Color::White;
Color shadowColor = Color(96, 96, 96);
Color button_color = Color::LightGray;
Color highlight_color = Color::White;
Color shadow_color = Color(96, 96, 96);
Painter painter(*this);
@ -34,26 +34,26 @@ void GButton::paintEvent(GPaintEvent&)
if (m_being_pressed) {
// Base
painter.fill_rect({ 1, 1, width() - 2, height() - 2 }, buttonColor);
painter.fill_rect({ 1, 1, width() - 2, height() - 2 }, button_color);
// Sunken shadow
painter.draw_line({ 1, 1 }, { width() - 2, 1 }, shadowColor);
painter.draw_line({ 1, 2 }, {1, height() - 2 }, shadowColor);
painter.draw_line({ 1, 1 }, { width() - 2, 1 }, shadow_color);
painter.draw_line({ 1, 2 }, {1, height() - 2 }, shadow_color);
} else {
// Base
painter.fill_rect({ 3, 3, width() - 5, height() - 5 }, buttonColor);
painter.fill_rect({ 3, 3, width() - 5, height() - 5 }, button_color);
// White highlight
painter.draw_line({ 1, 1 }, { width() - 2, 1 }, highlightColor);
painter.draw_line({ 1, 2 }, { width() - 3, 2 }, highlightColor);
painter.draw_line({ 1, 3 }, { 1, height() - 2 }, highlightColor);
painter.draw_line({ 2, 3 }, { 2, height() - 3 }, highlightColor);
painter.draw_line({ 1, 1 }, { width() - 2, 1 }, highlight_color);
painter.draw_line({ 1, 2 }, { width() - 3, 2 }, highlight_color);
painter.draw_line({ 1, 3 }, { 1, height() - 2 }, highlight_color);
painter.draw_line({ 2, 3 }, { 2, height() - 3 }, highlight_color);
// Gray shadow
painter.draw_line({ width() - 2, 1 }, { width() - 2, height() - 4 }, shadowColor);
painter.draw_line({ width() - 3, 2 }, { width() - 3, height() - 4 }, shadowColor);
painter.draw_line({ 1, height() - 2 }, { width() - 2, height() - 2 }, shadowColor);
painter.draw_line({ 2, height() - 3 }, { width() - 2, height() - 3 }, shadowColor);
painter.draw_line({ width() - 2, 1 }, { width() - 2, height() - 4 }, shadow_color);
painter.draw_line({ width() - 3, 2 }, { width() - 3, height() - 4 }, shadow_color);
painter.draw_line({ 1, height() - 2 }, { width() - 2, height() - 2 }, shadow_color);
painter.draw_line({ 2, height() - 3 }, { width() - 2, height() - 3 }, shadow_color);
}
if (!caption().is_empty()) {
@ -64,24 +64,24 @@ void GButton::paintEvent(GPaintEvent&)
}
}
void GButton::mouseDownEvent(GMouseEvent& event)
void GButton::mousedown_event(GMouseEvent& event)
{
dbgprintf("Button::mouseDownEvent: x=%d, y=%d, button=%u\n", event.x(), event.y(), (unsigned)event.button());
m_being_pressed = true;
update();
GWidget::mouseDownEvent(event);
GWidget::mousedown_event(event);
}
void GButton::mouseUpEvent(GMouseEvent& event)
void GButton::mouseup_event(GMouseEvent& event)
{
dbgprintf("Button::mouseUpEvent: x=%d, y=%d, button=%u\n", event.x(), event.y(), (unsigned)event.button());
m_being_pressed = false;
update();
GWidget::mouseUpEvent(event);
GWidget::mouseup_event(event);
if (on_click)
on_click(*this);

View file

@ -15,9 +15,9 @@ public:
Function<void(GButton&)> on_click;
private:
virtual void paintEvent(GPaintEvent&) override;
virtual void mouseDownEvent(GMouseEvent&) override;
virtual void mouseUpEvent(GMouseEvent&) override;
virtual void paint_event(GPaintEvent&) override;
virtual void mousedown_event(GMouseEvent&) override;
virtual void mouseup_event(GMouseEvent&) override;
virtual const char* class_name() const override { return "GButton"; }

View file

@ -11,7 +11,7 @@ GCheckBox::~GCheckBox()
{
}
void GCheckBox::setCaption(String&& caption)
void GCheckBox::set_caption(String&& caption)
{
if (caption == m_caption)
return;
@ -19,11 +19,11 @@ void GCheckBox::setCaption(String&& caption)
update();
}
void GCheckBox::setIsChecked(bool b)
void GCheckBox::set_checked(bool b)
{
if (m_isChecked == b)
if (m_checked == b)
return;
m_isChecked = b;
m_checked = b;
update();
}
@ -72,10 +72,10 @@ static const char* checkedBitmap = {
"###########"
};
void GCheckBox::paintEvent(GPaintEvent&)
void GCheckBox::paint_event(GPaintEvent&)
{
Painter painter(*this);
auto bitmap = CharacterBitmap::create_from_ascii(isChecked() ? checkedBitmap : uncheckedBitmap, 11, 11);
auto bitmap = CharacterBitmap::create_from_ascii(is_checked() ? checkedBitmap : uncheckedBitmap, 11, 11);
auto textRect = rect();
textRect.set_left(bitmap->width() + 4);
@ -85,18 +85,18 @@ void GCheckBox::paintEvent(GPaintEvent&)
bitmapPosition.set_x(2);
bitmapPosition.set_y(height() / 2 - bitmap->height() / 2 - 1);
painter.fill_rect(rect(), backgroundColor());
painter.draw_bitmap(bitmapPosition, *bitmap, foregroundColor());
painter.fill_rect(rect(), background_color());
painter.draw_bitmap(bitmapPosition, *bitmap, foreground_color());
if (!caption().is_empty()) {
painter.draw_text(textRect, caption(), Painter::TextAlignment::TopLeft, foregroundColor());
painter.draw_text(textRect, caption(), Painter::TextAlignment::TopLeft, foreground_color());
}
}
void GCheckBox::mouseDownEvent(GMouseEvent& event)
void GCheckBox::mousedown_event(GMouseEvent& event)
{
dbgprintf("GCheckBox::mouseDownEvent: x=%d, y=%d, button=%u\n", event.x(), event.y(), (unsigned)event.button());
setIsChecked(!isChecked());
set_checked(!is_checked());
}

View file

@ -9,18 +9,18 @@ public:
virtual ~GCheckBox() override;
String caption() const { return m_caption; }
void setCaption(String&&);
void set_caption(String&&);
bool isChecked() const { return m_isChecked; }
void setIsChecked(bool);
bool is_checked() const { return m_checked; }
void set_checked(bool);
private:
virtual void paintEvent(GPaintEvent&) override;
virtual void mouseDownEvent(GMouseEvent&) override;
virtual void paint_event(GPaintEvent&) override;
virtual void mousedown_event(GMouseEvent&) override;
virtual const char* class_name() const override { return "GCheckBox"; }
String m_caption;
bool m_isChecked { false };
bool m_checked { false };
};

View file

@ -10,7 +10,7 @@ GLabel::~GLabel()
{
}
void GLabel::setText(String&& text)
void GLabel::set_text(String&& text)
{
if (text == m_text)
return;
@ -18,11 +18,11 @@ void GLabel::setText(String&& text)
update();
}
void GLabel::paintEvent(GPaintEvent&)
void GLabel::paint_event(GPaintEvent&)
{
Painter painter(*this);
if (fillWithBackgroundColor())
painter.fill_rect({ 0, 0, width(), height() }, backgroundColor());
if (fill_with_background_color())
painter.fill_rect({ 0, 0, width(), height() }, background_color());
if (!text().is_empty())
painter.draw_text({ 4, 4, width(), height() }, text(), Painter::TextAlignment::TopLeft, foregroundColor());
painter.draw_text({ 4, 4, width(), height() }, text(), Painter::TextAlignment::TopLeft, foreground_color());
}

View file

@ -9,10 +9,10 @@ public:
virtual ~GLabel() override;
String text() const { return m_text; }
void setText(String&&);
void set_text(String&&);
private:
virtual void paintEvent(GPaintEvent&) override;
virtual void paint_event(GPaintEvent&) override;
virtual const char* class_name() const override { return "GLabel"; }

View file

@ -17,7 +17,7 @@ Rect GListBox::item_rect(int index) const
return Rect { 2, 2 + (index * item_height), width() - 4, item_height };
}
void GListBox::paintEvent(GPaintEvent&)
void GListBox::paint_event(GPaintEvent&)
{
Painter painter(*this);
@ -25,32 +25,32 @@ void GListBox::paintEvent(GPaintEvent&)
painter.fill_rect(rect(), Color::White);
painter.draw_rect(rect(), Color::Black);
if (isFocused())
if (is_focused())
painter.draw_focus_rect(rect());
for (int i = m_scrollOffset; i < static_cast<int>(m_items.size()); ++i) {
auto itemRect = item_rect(i);
Rect textRect(itemRect.x() + 1, itemRect.y() + 1, itemRect.width() - 2, itemRect.height() - 2);
for (int i = m_scroll_offset; i < static_cast<int>(m_items.size()); ++i) {
auto item_rect = this->item_rect(i);
Rect text_rect(item_rect.x() + 1, item_rect.y() + 1, item_rect.width() - 2, item_rect.height() - 2);
Color itemTextColor = foregroundColor();
if (m_selectedIndex == i) {
if (isFocused())
painter.fill_rect(itemRect, Color(0, 32, 128));
Color item_text_color = foreground_color();
if (m_selected_index == i) {
if (is_focused())
painter.fill_rect(item_rect, Color(0, 32, 128));
else
painter.fill_rect(itemRect, Color(96, 96, 96));
itemTextColor = Color::White;
painter.fill_rect(item_rect, Color(96, 96, 96));
item_text_color = Color::White;
}
painter.draw_text(textRect, m_items[i], Painter::TextAlignment::TopLeft, itemTextColor);
painter.draw_text(item_rect, m_items[i], Painter::TextAlignment::TopLeft, item_text_color);
}
}
void GListBox::mouseDownEvent(GMouseEvent& event)
void GListBox::mousedown_event(GMouseEvent& event)
{
dbgprintf("GListBox::mouseDownEvent %d,%d\n", event.x(), event.y());
for (int i = m_scrollOffset; i < static_cast<int>(m_items.size()); ++i) {
auto itemRect = item_rect(i);
if (itemRect.contains(event.position())) {
m_selectedIndex = i;
for (int i = m_scroll_offset; i < static_cast<int>(m_items.size()); ++i) {
auto item_rect = this->item_rect(i);
if (item_rect.contains(event.position())) {
m_selected_index = i;
dbgprintf("GListBox: selected item %u (\"%s\")\n", i, m_items[i].characters());
update();
return;
@ -58,10 +58,10 @@ void GListBox::mouseDownEvent(GMouseEvent& event)
}
}
void GListBox::addItem(String&& item)
void GListBox::add_item(String&& item)
{
m_items.append(move(item));
if (m_selectedIndex == -1)
m_selectedIndex = 0;
if (m_selected_index == -1)
m_selected_index = 0;
}

View file

@ -7,18 +7,18 @@ public:
explicit GListBox(GWidget* parent);
virtual ~GListBox() override;
void addItem(String&&);
int selectedIndex() const { return m_selectedIndex; }
void add_item(String&&);
int selected_index() const { return m_selected_index; }
private:
virtual void paintEvent(GPaintEvent&) override;
virtual void mouseDownEvent(GMouseEvent&) override;
virtual void paint_event(GPaintEvent&) override;
virtual void mousedown_event(GMouseEvent&) override;
virtual const char* class_name() const override { return "GListBox"; }
Rect item_rect(int index) const;
int m_scrollOffset { 0 };
int m_selectedIndex { -1 };
int m_scroll_offset { 0 };
int m_selected_index { -1 };
Vector<String> m_items;
};

View file

@ -14,22 +14,22 @@ GTextBox::~GTextBox()
{
}
void GTextBox::setText(String&& text)
void GTextBox::set_text(String&& text)
{
m_text = move(text);
m_cursorPosition = m_text.length();
update();
}
void GTextBox::paintEvent(GPaintEvent&)
void GTextBox::paint_event(GPaintEvent&)
{
Painter painter(*this);
// FIXME: Reduce overdraw.
painter.fill_rect(rect(), backgroundColor());
painter.draw_rect(rect(), foregroundColor());
painter.fill_rect(rect(), background_color());
painter.draw_rect(rect(), foreground_color());
if (isFocused())
if (is_focused())
painter.draw_focus_rect(rect());
Rect innerRect = rect();
@ -54,18 +54,18 @@ void GTextBox::paintEvent(GPaintEvent&)
painter.draw_bitmap({x, y}, *bitmap, Color::Black);
}
if (isFocused() && m_cursorBlinkState) {
if (is_focused() && m_cursorBlinkState) {
unsigned visibleCursorPosition = m_cursorPosition - firstVisibleChar;
Rect cursorRect(innerRect.x() + visibleCursorPosition * font().glyph_width(), innerRect.y(), 1, innerRect.height());
painter.fill_rect(cursorRect, foregroundColor());
painter.fill_rect(cursorRect, foreground_color());
}
}
void GTextBox::mouseDownEvent(GMouseEvent&)
void GTextBox::mousedown_event(GMouseEvent&)
{
}
void GTextBox::handleBackspace()
void GTextBox::handle_backspace()
{
if (m_cursorPosition == 0)
return;
@ -88,7 +88,7 @@ void GTextBox::handleBackspace()
update();
}
void GTextBox::keyDownEvent(GKeyEvent& event)
void GTextBox::keydown_event(GKeyEvent& event)
{
switch (event.key()) {
case GKeyboardKey::LeftArrow:
@ -104,7 +104,7 @@ void GTextBox::keyDownEvent(GKeyEvent& event)
update();
return;
case GKeyboardKey::Backspace:
return handleBackspace();
return handle_backspace();
case GKeyboardKey::Return:
if (onReturnPressed)
onReturnPressed(*this);
@ -131,7 +131,7 @@ void GTextBox::keyDownEvent(GKeyEvent& event)
void GTextBox::timerEvent(GTimerEvent&)
{
// FIXME: Disable the timer when not focused.
if (!isFocused())
if (!is_focused())
return;
m_cursorBlinkState = !m_cursorBlinkState;

View file

@ -9,18 +9,18 @@ public:
virtual ~GTextBox() override;
String text() const { return m_text; }
void setText(String&&);
void set_text(String&&);
Function<void(GTextBox&)> onReturnPressed;
private:
virtual const char* class_name() const override { return "GTextBox"; }
virtual void paintEvent(GPaintEvent&) override;
virtual void mouseDownEvent(GMouseEvent&) override;
virtual void keyDownEvent(GKeyEvent&) override;
virtual void paint_event(GPaintEvent&) override;
virtual void mousedown_event(GMouseEvent&) override;
virtual void keydown_event(GKeyEvent&) override;
virtual void timerEvent(GTimerEvent&) override;
void handleBackspace();
void handle_backspace();
String m_text;
unsigned m_cursorPosition { 0 };

View file

@ -9,19 +9,19 @@
GWidget::GWidget(GWidget* parent)
: GObject(parent)
{
setFont(nullptr);
m_backgroundColor = Color::White;
m_foregroundColor = Color::Black;
set_font(nullptr);
m_background_color = Color::White;
m_foreground_color = Color::Black;
}
GWidget::~GWidget()
{
}
void GWidget::setWindowRelativeRect(const Rect& rect, bool should_update)
void GWidget::set_relative_rect(const Rect& rect, bool should_update)
{
// FIXME: Make some kind of event loop driven ResizeEvent?
m_relativeRect = rect;
m_relative_rect = rect;
if (should_update)
update();
}
@ -35,33 +35,33 @@ void GWidget::event(GEvent& event)
{
switch (event.type()) {
case GEvent::Paint:
m_hasPendingPaintEvent = false;
return paintEvent(static_cast<GPaintEvent&>(event));
m_has_pending_paint_event = false;
return paint_event(static_cast<GPaintEvent&>(event));
case GEvent::Show:
return showEvent(static_cast<GShowEvent&>(event));
return show_event(static_cast<GShowEvent&>(event));
case GEvent::Hide:
return hideEvent(static_cast<GHideEvent&>(event));
return hide_event(static_cast<GHideEvent&>(event));
case GEvent::KeyDown:
return keyDownEvent(static_cast<GKeyEvent&>(event));
return keydown_event(static_cast<GKeyEvent&>(event));
case GEvent::KeyUp:
return keyUpEvent(static_cast<GKeyEvent&>(event));
return keyup_event(static_cast<GKeyEvent&>(event));
case GEvent::MouseMove:
return mouseMoveEvent(static_cast<GMouseEvent&>(event));
return mousemove_event(static_cast<GMouseEvent&>(event));
case GEvent::MouseDown:
// FIXME: Focus self if needed.
return mouseDownEvent(static_cast<GMouseEvent&>(event));
return mousedown_event(static_cast<GMouseEvent&>(event));
case GEvent::MouseUp:
return mouseUpEvent(static_cast<GMouseEvent&>(event));
return mouseup_event(static_cast<GMouseEvent&>(event));
default:
return GObject::event(event);
}
}
void GWidget::paintEvent(GPaintEvent& event)
void GWidget::paint_event(GPaintEvent& event)
{
if (fillWithBackgroundColor()) {
if (fill_with_background_color()) {
Painter painter(*this);
painter.fill_rect(event.rect(), backgroundColor());
painter.fill_rect(event.rect(), background_color());
}
for (auto* ch : children()) {
auto* child = (GWidget*)ch;
@ -69,31 +69,31 @@ void GWidget::paintEvent(GPaintEvent& event)
}
}
void GWidget::showEvent(GShowEvent&)
void GWidget::show_event(GShowEvent&)
{
}
void GWidget::hideEvent(GHideEvent&)
void GWidget::hide_event(GHideEvent&)
{
}
void GWidget::keyDownEvent(GKeyEvent&)
void GWidget::keydown_event(GKeyEvent&)
{
}
void GWidget::keyUpEvent(GKeyEvent&)
void GWidget::keyup_event(GKeyEvent&)
{
}
void GWidget::mouseDownEvent(GMouseEvent&)
void GWidget::mousedown_event(GMouseEvent&)
{
}
void GWidget::mouseUpEvent(GMouseEvent&)
void GWidget::mouseup_event(GMouseEvent&)
{
}
void GWidget::mouseMoveEvent(GMouseEvent&)
void GWidget::mousemove_event(GMouseEvent&)
{
}
@ -102,19 +102,19 @@ void GWidget::update()
auto* w = window();
if (!w)
return;
if (m_hasPendingPaintEvent)
if (m_has_pending_paint_event)
return;
m_hasPendingPaintEvent = true;
GEventLoop::main().post_event(w, make<GPaintEvent>(relativeRect()));
m_has_pending_paint_event = true;
GEventLoop::main().post_event(w, make<GPaintEvent>(relative_rect()));
}
GWidget::HitTestResult GWidget::hitTest(int x, int y)
GWidget::HitTestResult GWidget::hit_test(int x, int y)
{
// FIXME: Care about z-order.
for (auto* ch : children()) {
auto* child = (GWidget*)ch;
if (child->relativeRect().contains(x, y)) {
return child->hitTest(x - child->relativeRect().x(), y - child->relativeRect().y());
if (child->relative_rect().contains(x, y)) {
return child->hit_test(x - child->relative_rect().x(), y - child->relative_rect().y());
}
}
return { this, x, y };
@ -127,20 +127,20 @@ void GWidget::set_window(GWindow* window)
m_window = window;
}
bool GWidget::isFocused() const
bool GWidget::is_focused() const
{
// FIXME: Implement.
return false;
}
void GWidget::setFocus(bool focus)
void GWidget::set_focus(bool focus)
{
if (focus == isFocused())
if (focus == is_focused())
return;
// FIXME: Implement.
}
void GWidget::setFont(RetainPtr<Font>&& font)
void GWidget::set_font(RetainPtr<Font>&& font)
{
if (!font)
m_font = Font::default_font();

View file

@ -13,87 +13,87 @@ class GWindow;
class GWidget : public GObject {
public:
explicit GWidget(GWidget* parent = nullptr);
virtual ~GWidget();
virtual ~GWidget() override;
virtual void event(GEvent&) override;
virtual void paintEvent(GPaintEvent&);
virtual void showEvent(GShowEvent&);
virtual void hideEvent(GHideEvent&);
virtual void keyDownEvent(GKeyEvent&);
virtual void keyUpEvent(GKeyEvent&);
virtual void mouseMoveEvent(GMouseEvent&);
virtual void mouseDownEvent(GMouseEvent&);
virtual void mouseUpEvent(GMouseEvent&);
virtual void paint_event(GPaintEvent&);
virtual void show_event(GShowEvent&);
virtual void hide_event(GHideEvent&);
virtual void keydown_event(GKeyEvent&);
virtual void keyup_event(GKeyEvent&);
virtual void mousemove_event(GMouseEvent&);
virtual void mousedown_event(GMouseEvent&);
virtual void mouseup_event(GMouseEvent&);
Rect relativeRect() const { return m_relativeRect; }
Point relativePosition() const { return m_relativeRect.location(); }
Rect relative_rect() const { return m_relative_rect; }
Point relative_position() const { return m_relative_rect.location(); }
int x() const { return m_relativeRect.x(); }
int y() const { return m_relativeRect.y(); }
int width() const { return m_relativeRect.width(); }
int height() const { return m_relativeRect.height(); }
int x() const { return m_relative_rect.x(); }
int y() const { return m_relative_rect.y(); }
int width() const { return m_relative_rect.width(); }
int height() const { return m_relative_rect.height(); }
Rect rect() const { return { 0, 0, width(), height() }; }
Size size() const { return m_relativeRect.size(); }
Size size() const { return m_relative_rect.size(); }
void update();
void repaint(const Rect&);
bool isFocused() const;
void setFocus(bool);
bool is_focused() const;
void set_focus(bool);
struct HitTestResult {
GWidget* widget { nullptr };
int localX { 0 };
int localY { 0 };
};
HitTestResult hitTest(int x, int y);
HitTestResult hit_test(int x, int y);
virtual const char* class_name() const override { return "GWidget"; }
void setWindowRelativeRect(const Rect&, bool should_update = true);
void set_relative_rect(const Rect&, bool should_update = true);
Color backgroundColor() const { return m_backgroundColor; }
Color foregroundColor() const { return m_foregroundColor; }
Color background_color() const { return m_background_color; }
Color foreground_color() const { return m_foreground_color; }
void setBackgroundColor(Color color) { m_backgroundColor = color; }
void setForegroundColor(Color color) { m_foregroundColor = color; }
void set_background_color(Color color) { m_background_color = color; }
void set_foreground_color(Color color) { m_foreground_color = color; }
GWindow* window()
{
if (auto* pw = parentWidget())
if (auto* pw = parent_widget())
return pw->window();
return m_window;
}
const GWindow* window() const
{
if (auto* pw = parentWidget())
if (auto* pw = parent_widget())
return pw->window();
return m_window;
}
void set_window(GWindow*);
GWidget* parentWidget() { return static_cast<GWidget*>(parent()); }
const GWidget* parentWidget() const { return static_cast<const GWidget*>(parent()); }
GWidget* parent_widget() { return static_cast<GWidget*>(parent()); }
const GWidget* parent_widget() const { return static_cast<const GWidget*>(parent()); }
void setFillWithBackgroundColor(bool b) { m_fillWithBackgroundColor = b; }
bool fillWithBackgroundColor() const { return m_fillWithBackgroundColor; }
void set_fill_with_background_color(bool b) { m_fill_with_background_color = b; }
bool fill_with_background_color() const { return m_fill_with_background_color; }
const Font& font() const { return *m_font; }
void setFont(RetainPtr<Font>&&);
void set_font(RetainPtr<Font>&&);
GraphicsBitmap* backing();
private:
GWindow* m_window { nullptr };
Rect m_relativeRect;
Color m_backgroundColor { 0xffffff };
Color m_foregroundColor { 0x000000 };
Rect m_relative_rect;
Color m_background_color { 0xffffff };
Color m_foreground_color { 0x000000 };
RetainPtr<Font> m_font;
bool m_hasPendingPaintEvent { false };
bool m_fillWithBackgroundColor { true };
bool m_has_pending_paint_event { false };
bool m_fill_with_background_color { true };
};

View file

@ -91,7 +91,7 @@ void GWindow::event(GEvent& event)
return;
auto& mouse_event = static_cast<GMouseEvent&>(event);
if (m_main_widget) {
auto result = m_main_widget->hitTest(mouse_event.x(), mouse_event.y());
auto result = m_main_widget->hit_test(mouse_event.x(), mouse_event.y());
auto local_event = make<GMouseEvent>(event.type(), Point { result.localX, result.localY }, mouse_event.buttons(), mouse_event.button());
ASSERT(result.widget);
return result.widget->event(*local_event);

View file

@ -25,13 +25,13 @@ Painter::Painter(GWidget& widget)
m_target = widget.backing();
ASSERT(m_target);
m_window = widget.window();
m_translation.move_by(widget.relativePosition());
m_translation.move_by(widget.relative_position());
// NOTE: m_clip_rect is in Window coordinates since we are painting into its backing store.
m_clip_rect = widget.relativeRect();
m_clip_rect = widget.relative_rect();
#ifdef DEBUG_WIDGET_UNDERDRAW
// If the widget is not opaque, let's not mess it up with debugging color.
if (widget.fillWithBackgroundColor() && m_window->main_widget() != &widget)
if (widget.fill_with_background_color() && m_window->main_widget() != &widget)
fill_rect(widget.rect(), Color::Red);
#endif
}

View file

@ -36,23 +36,23 @@ GWindow* make_font_test_window()
auto* widget = new GWidget;
window->set_main_widget(widget);
widget->setWindowRelativeRect({ 0, 0, 300, 80 });
widget->set_relative_rect({ 0, 0, 300, 80 });
auto* l1 = new GLabel(widget);
l1->setWindowRelativeRect({ 0, 0, 300, 20 });
l1->setText("0123456789");
l1->set_relative_rect({ 0, 0, 300, 20 });
l1->set_text("0123456789");
auto* l2 = new GLabel(widget);
l2->setWindowRelativeRect({ 0, 20, 300, 20 });
l2->setText("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
l2->set_relative_rect({ 0, 20, 300, 20 });
l2->set_text("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
auto* l3 = new GLabel(widget);
l3->setWindowRelativeRect({ 0, 40, 300, 20 });
l3->setText("abcdefghijklmnopqrstuvwxyz");
l3->set_relative_rect({ 0, 40, 300, 20 });
l3->set_text("abcdefghijklmnopqrstuvwxyz");
auto* l4 = new GLabel(widget);
l4->setWindowRelativeRect({ 0, 60, 300, 20 });
l4->setText("!\"#$%&'()*+,-./:;<=>?@[\\]^_{|}~");
l4->set_relative_rect({ 0, 60, 300, 20 });
l4->set_text("!\"#$%&'()*+,-./:;<=>?@[\\]^_{|}~");
return window;
}
@ -65,14 +65,14 @@ GWindow* make_launcher_window()
auto* widget = new GWidget;
window->set_main_widget(widget);
widget->setWindowRelativeRect({ 0, 0, 80, 200 });
widget->set_relative_rect({ 0, 0, 80, 200 });
auto* label = new GLabel(widget);
label->setWindowRelativeRect({ 0, 0, 80, 20 });
label->setText("Apps");
label->set_relative_rect({ 0, 0, 80, 20 });
label->set_text("Apps");
auto* button = new GButton(widget);
button->setWindowRelativeRect({ 5, 20, 70, 20 });
button->set_relative_rect({ 5, 20, 70, 20 });
button->set_caption("Terminal");
button->on_click = [] (GButton&) {