1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-23 18:15:06 +00:00

LibGUI: Mass coding style fixes.

This commit is contained in:
Andreas Kling 2019-01-21 00:46:08 +01:00
parent 6c4f1bad09
commit d66b0f7dd8
15 changed files with 178 additions and 178 deletions

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;
}