diff --git a/AK/QuickSort.h b/AK/QuickSort.h index 2d196d2977..71611ad7e3 100644 --- a/AK/QuickSort.h +++ b/AK/QuickSort.h @@ -1,5 +1,7 @@ #pragma once +#include + namespace AK { template diff --git a/LibGUI/GAbstractView.cpp b/LibGUI/GAbstractView.cpp index 654566f244..36b10818ad 100644 --- a/LibGUI/GAbstractView.cpp +++ b/LibGUI/GAbstractView.cpp @@ -1,9 +1,9 @@ +#include #include #include -#include #include +#include #include -#include GAbstractView::GAbstractView(GWidget* parent) : GScrollableWidget(parent) @@ -84,7 +84,7 @@ void GAbstractView::begin_editing(const GModelIndex& index) void GAbstractView::stop_editing() { - m_edit_index = { }; + m_edit_index = {}; delete m_edit_widget; m_edit_widget = nullptr; } diff --git a/LibGUI/GAction.cpp b/LibGUI/GAction.cpp index 2eebd748a8..3e701d485a 100644 --- a/LibGUI/GAction.cpp +++ b/LibGUI/GAction.cpp @@ -29,7 +29,6 @@ GAction::GAction(const StringView& text, const GShortcut& shortcut, Function&& icon, Function on_activation_callback, GWidget* widget) : on_activation(move(on_activation_callback)) , m_text(text) @@ -99,10 +98,10 @@ void GAction::set_enabled(bool enabled) if (m_enabled == enabled) return; m_enabled = enabled; - for_each_toolbar_button([enabled] (GButton& button) { + for_each_toolbar_button([enabled](GButton& button) { button.set_enabled(enabled); }); - for_each_menu_item([enabled] (GMenuItem& item) { + for_each_menu_item([enabled](GMenuItem& item) { item.set_enabled(enabled); }); } @@ -112,10 +111,10 @@ void GAction::set_checked(bool checked) if (m_checked == checked) return; m_checked = checked; - for_each_toolbar_button([checked] (GButton& button) { + for_each_toolbar_button([checked](GButton& button) { button.set_checked(checked); }); - for_each_menu_item([checked] (GMenuItem& item) { + for_each_menu_item([checked](GMenuItem& item) { item.set_checked(checked); }); } diff --git a/LibGUI/GApplication.cpp b/LibGUI/GApplication.cpp index ef632b4d0e..072021eb4a 100644 --- a/LibGUI/GApplication.cpp +++ b/LibGUI/GApplication.cpp @@ -1,10 +1,10 @@ +#include #include #include -#include -#include -#include #include +#include #include +#include #include static GApplication* s_the; diff --git a/LibGUI/GButton.cpp b/LibGUI/GButton.cpp index ff8bc9172d..21b9f39043 100644 --- a/LibGUI/GButton.cpp +++ b/LibGUI/GButton.cpp @@ -1,9 +1,9 @@ #include "GButton.h" +#include +#include +#include #include #include -#include -#include -#include GButton::GButton(GWidget* parent) : GAbstractButton(parent) @@ -18,7 +18,7 @@ GButton::GButton(const StringView& text, GWidget* parent) GButton::~GButton() { if (m_action) - m_action->unregister_button({ }, *this); + m_action->unregister_button({}, *this); } void GButton::paint_event(GPaintEvent& event) @@ -67,7 +67,7 @@ void GButton::click() void GButton::set_action(GAction& action) { m_action = action.make_weak_ptr(); - action.register_button({ }, *this); + action.register_button({}, *this); set_enabled(action.is_enabled()); set_checkable(action.is_checkable()); if (action.is_checkable()) diff --git a/LibGUI/GCheckBox.cpp b/LibGUI/GCheckBox.cpp index 7be710fbb3..2bd5067bc9 100644 --- a/LibGUI/GCheckBox.cpp +++ b/LibGUI/GCheckBox.cpp @@ -1,8 +1,8 @@ +#include #include #include #include #include -#include static const char* s_checked_bitmap_data = { " " diff --git a/LibGUI/GClipboard.cpp b/LibGUI/GClipboard.cpp index 2c4d38b4da..fc02b3b623 100644 --- a/LibGUI/GClipboard.cpp +++ b/LibGUI/GClipboard.cpp @@ -1,7 +1,7 @@ +#include #include #include #include -#include GClipboard& GClipboard::the() { @@ -21,15 +21,15 @@ String GClipboard::data() const request.type = WSAPI_ClientMessage::Type::GetClipboardContents; auto response = GEventLoop::current().sync_request(request, WSAPI_ServerMessage::Type::DidGetClipboardContents); if (response.clipboard.shared_buffer_id < 0) - return { }; + return {}; auto shared_buffer = SharedBuffer::create_from_shared_buffer_id(response.clipboard.shared_buffer_id); if (!shared_buffer) { dbgprintf("GClipboard::data() failed to attach to the shared buffer\n"); - return { }; + return {}; } if (response.clipboard.contents_size > shared_buffer->size()) { dbgprintf("GClipboard::data() clipping contents size is greater than shared buffer size\n"); - return { }; + return {}; } return String((const char*)shared_buffer->data(), response.clipboard.contents_size); } diff --git a/LibGUI/GDialog.cpp b/LibGUI/GDialog.cpp index d72b73c198..4de55f8c95 100644 --- a/LibGUI/GDialog.cpp +++ b/LibGUI/GDialog.cpp @@ -1,6 +1,6 @@ +#include #include #include -#include GDialog::GDialog(CObject* parent) : GWindow(parent) diff --git a/LibGUI/GDirectoryModel.cpp b/LibGUI/GDirectoryModel.cpp index e1a9c34d66..ee5ddcd39b 100644 --- a/LibGUI/GDirectoryModel.cpp +++ b/LibGUI/GDirectoryModel.cpp @@ -1,15 +1,15 @@ #include "GDirectoryModel.h" -#include -#include -#include -#include -#include #include #include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include static CLockable>>& thumbnail_cache() { @@ -94,13 +94,20 @@ int GDirectoryModel::column_count(const GModelIndex&) const String GDirectoryModel::column_name(int column) const { switch (column) { - case Column::Icon: return ""; - case Column::Name: return "Name"; - case Column::Size: return "Size"; - case Column::Owner: return "Owner"; - case Column::Group: return "Group"; - case Column::Permissions: return "Mode"; - case Column::Inode: return "Inode"; + case Column::Icon: + return ""; + case Column::Name: + return "Name"; + case Column::Size: + return "Size"; + case Column::Owner: + return "Owner"; + case Column::Group: + return "Group"; + case Column::Permissions: + return "Mode"; + case Column::Inode: + return "Inode"; } ASSERT_NOT_REACHED(); } @@ -108,13 +115,20 @@ String GDirectoryModel::column_name(int column) const GModel::ColumnMetadata GDirectoryModel::column_metadata(int column) const { switch (column) { - case Column::Icon: return { 16, TextAlignment::Center }; - case Column::Name: return { 120, TextAlignment::CenterLeft }; - case Column::Size: return { 80, TextAlignment::CenterRight }; - case Column::Owner: return { 50, TextAlignment::CenterLeft }; - case Column::Group: return { 50, TextAlignment::CenterLeft }; - case Column::Permissions: return { 80, TextAlignment::CenterLeft }; - case Column::Inode: return { 80, TextAlignment::CenterRight }; + case Column::Icon: + return { 16, TextAlignment::Center }; + case Column::Name: + return { 120, TextAlignment::CenterLeft }; + case Column::Size: + return { 80, TextAlignment::CenterRight }; + case Column::Owner: + return { 50, TextAlignment::CenterLeft }; + case Column::Group: + return { 50, TextAlignment::CenterLeft }; + case Column::Permissions: + return { 80, TextAlignment::CenterLeft }; + case Column::Inode: + return { 80, TextAlignment::CenterRight }; } ASSERT_NOT_REACHED(); } @@ -175,8 +189,7 @@ static String permission_string(mode_t mode) mode & S_IWGRP ? 'w' : '-', mode & S_ISGID ? 's' : (mode & S_IXGRP ? 'x' : '-'), mode & S_IROTH ? 'r' : '-', - mode & S_IWOTH ? 'w' : '-' - ); + mode & S_IWOTH ? 'w' : '-'); if (mode & S_ISVTX) builder.append("t"); @@ -207,31 +220,45 @@ GVariant GDirectoryModel::data(const GModelIndex& index, Role role) const auto& entry = this->entry(index.row()); if (role == Role::Sort) { switch (index.column()) { - case Column::Icon: return entry.is_directory() ? 0 : 1; - case Column::Name: return entry.name; - case Column::Size: return (int)entry.size; - case Column::Owner: return name_for_uid(entry.uid); - case Column::Group: return name_for_gid(entry.gid); - case Column::Permissions: return permission_string(entry.mode); - case Column::Inode: return (int)entry.inode; + case Column::Icon: + return entry.is_directory() ? 0 : 1; + case Column::Name: + return entry.name; + case Column::Size: + return (int)entry.size; + case Column::Owner: + return name_for_uid(entry.uid); + case Column::Group: + return name_for_gid(entry.gid); + case Column::Permissions: + return permission_string(entry.mode); + case Column::Inode: + return (int)entry.inode; } ASSERT_NOT_REACHED(); } if (role == Role::Display) { switch (index.column()) { - case Column::Icon: return icon_for(entry); - case Column::Name: return entry.name; - case Column::Size: return (int)entry.size; - case Column::Owner: return name_for_uid(entry.uid); - case Column::Group: return name_for_gid(entry.gid); - case Column::Permissions: return permission_string(entry.mode); - case Column::Inode: return (int)entry.inode; + case Column::Icon: + return icon_for(entry); + case Column::Name: + return entry.name; + case Column::Size: + return (int)entry.size; + case Column::Owner: + return name_for_uid(entry.uid); + case Column::Group: + return name_for_gid(entry.gid); + case Column::Permissions: + return permission_string(entry.mode); + case Column::Inode: + return (int)entry.inode; } } if (role == Role::Icon) { return icon_for(entry); } - return { }; + return {}; } void GDirectoryModel::update() diff --git a/LibGUI/GEventLoop.cpp b/LibGUI/GEventLoop.cpp index 127adbfead..ffa5b02c3b 100644 --- a/LibGUI/GEventLoop.cpp +++ b/LibGUI/GEventLoop.cpp @@ -1,24 +1,23 @@ -#include #include "GEventLoop.h" #include "GEvent.h" #include "GWindow.h" -#include -#include -#include -#include -#include -#include -#include -#include +#include #include +#include +#include #include -#include #include #include #include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include //#define GEVENTLOOP_DEBUG @@ -156,20 +155,42 @@ void GEventLoop::handle_mouse_event(const WSAPI_ServerMessage& event, GWindow& w #endif GMouseEvent::Type type; switch (event.type) { - case WSAPI_ServerMessage::Type::MouseMove: type = GEvent::MouseMove; break; - case WSAPI_ServerMessage::Type::MouseUp: type = GEvent::MouseUp; break; - case WSAPI_ServerMessage::Type::MouseDown: type = GEvent::MouseDown; break; - case WSAPI_ServerMessage::Type::MouseDoubleClick: type = GEvent::MouseDoubleClick; break; - case WSAPI_ServerMessage::Type::MouseWheel: type = GEvent::MouseWheel; break; - default: ASSERT_NOT_REACHED(); break; + case WSAPI_ServerMessage::Type::MouseMove: + type = GEvent::MouseMove; + break; + case WSAPI_ServerMessage::Type::MouseUp: + type = GEvent::MouseUp; + break; + case WSAPI_ServerMessage::Type::MouseDown: + type = GEvent::MouseDown; + break; + case WSAPI_ServerMessage::Type::MouseDoubleClick: + type = GEvent::MouseDoubleClick; + break; + case WSAPI_ServerMessage::Type::MouseWheel: + type = GEvent::MouseWheel; + break; + default: + ASSERT_NOT_REACHED(); + break; } GMouseButton button { GMouseButton::None }; switch (event.mouse.button) { - case WSAPI_MouseButton::NoButton: button = GMouseButton::None; break; - case WSAPI_MouseButton::Left: button = GMouseButton::Left; break; - case WSAPI_MouseButton::Right: button = GMouseButton::Right; break; - case WSAPI_MouseButton::Middle: button = GMouseButton::Middle; break; - default: ASSERT_NOT_REACHED(); break; + case WSAPI_MouseButton::NoButton: + button = GMouseButton::None; + break; + case WSAPI_MouseButton::Left: + button = GMouseButton::Left; + break; + case WSAPI_MouseButton::Right: + button = GMouseButton::Right; + break; + case WSAPI_MouseButton::Middle: + button = GMouseButton::Middle; + break; + default: + ASSERT_NOT_REACHED(); + break; } post_event(window, make(type, event.mouse.position, event.mouse.buttons, button, event.mouse.modifiers, event.mouse.wheel_delta)); } diff --git a/LibGUI/GFilePicker.cpp b/LibGUI/GFilePicker.cpp index 76587d9223..a6382cd695 100644 --- a/LibGUI/GFilePicker.cpp +++ b/LibGUI/GFilePicker.cpp @@ -57,19 +57,19 @@ GFilePicker::GFilePicker(const StringView& path, CObject* parent) clear_preview(); }; - auto open_parent_directory_action = GAction::create("Open parent directory", { Mod_Alt, Key_Up }, GraphicsBitmap::load_from_file("/res/icons/16x16/open-parent-directory.png"), [this] (const GAction&) { + auto open_parent_directory_action = GAction::create("Open parent directory", { Mod_Alt, Key_Up }, GraphicsBitmap::load_from_file("/res/icons/16x16/open-parent-directory.png"), [this](const GAction&) { m_model->open(String::format("%s/..", m_model->path().characters())); clear_preview(); }); toolbar->add_action(*open_parent_directory_action); - auto mkdir_action = GAction::create("New directory...", GraphicsBitmap::load_from_file("/res/icons/16x16/mkdir.png"), [this] (const GAction&) { + auto mkdir_action = GAction::create("New directory...", GraphicsBitmap::load_from_file("/res/icons/16x16/mkdir.png"), [this](const GAction&) { GInputBox input_box("Enter name:", "New directory", this); if (input_box.exec() == GInputBox::ExecOK && !input_box.text_value().is_empty()) { auto new_dir_path = FileSystemPath(String::format("%s/%s", - m_model->path().characters(), - input_box.text_value().characters() - )).string(); + m_model->path().characters(), + input_box.text_value().characters())) + .string(); int rc = mkdir(new_dir_path.characters(), 0777); if (rc < 0) { GMessageBox::show(String::format("mkdir(\"%s\") failed: %s", new_dir_path.characters(), strerror(errno)), "Error", GMessageBox::Type::Error, this); @@ -96,7 +96,7 @@ GFilePicker::GFilePicker(const StringView& path, CObject* parent) filename_label->set_preferred_size({ 60, 0 }); auto* filename_textbox = new GTextBox(filename_container); - m_view->on_activation = [this, filename_textbox] (auto& index) { + m_view->on_activation = [this, filename_textbox](auto& index) { auto& filter_model = (GSortingProxyModel&)*m_view->model(); auto local_index = filter_model.map_to_target(index); const GDirectoryModel::Entry& entry = m_model->entry(local_index.row()); @@ -125,7 +125,7 @@ GFilePicker::GFilePicker(const StringView& path, CObject* parent) cancel_button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); cancel_button->set_preferred_size({ 80, 0 }); cancel_button->set_text("Cancel"); - cancel_button->on_click = [this] (auto&) { + cancel_button->on_click = [this](auto&) { done(ExecCancel); }; @@ -133,7 +133,7 @@ GFilePicker::GFilePicker(const StringView& path, CObject* parent) ok_button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); ok_button->set_preferred_size({ 80, 0 }); ok_button->set_text("OK"); - ok_button->on_click = [this, filename_textbox] (auto&) { + ok_button->on_click = [this, filename_textbox](auto&) { FileSystemPath path(String::format("%s/%s", m_model->path().characters(), filename_textbox->text().characters())); m_selected_file = path; done(ExecOK); diff --git a/LibGUI/GFileSystemModel.cpp b/LibGUI/GFileSystemModel.cpp index d56fd4777c..d39a6ef67c 100644 --- a/LibGUI/GFileSystemModel.cpp +++ b/LibGUI/GFileSystemModel.cpp @@ -1,17 +1,22 @@ -#include -#include #include #include -#include +#include +#include #include -#include #include +#include +#include struct GFileSystemModel::Node { String name; Node* parent { nullptr }; Vector children; - enum Type { Unknown, Directory, File }; + enum Type + { + Unknown, + Directory, + File + }; Type type { Unknown }; bool has_traversed { false }; @@ -111,15 +116,15 @@ GModelIndex GFileSystemModel::index(const StringView& path) const } } if (!found) - return { }; + return {}; } - return { }; + return {}; } String GFileSystemModel::path(const GModelIndex& index) const { if (!index.is_valid()) - return { }; + return {}; auto& node = *(Node*)index.internal_data(); node.reify_if_needed(*this); return node.full_path(*this); @@ -172,11 +177,11 @@ GModelIndex GFileSystemModel::index(int row, int column, const GModelIndex& pare GModelIndex GFileSystemModel::parent_index(const GModelIndex& index) const { if (!index.is_valid()) - return { }; + return {}; auto& node = *(const Node*)index.internal_data(); if (!node.parent) { ASSERT(&node == m_root); - return { }; + return {}; } return node.parent->index(*this); } @@ -184,7 +189,7 @@ GModelIndex GFileSystemModel::parent_index(const GModelIndex& index) const GVariant GFileSystemModel::data(const GModelIndex& index, Role role) const { if (!index.is_valid()) - return { }; + return {}; auto& node = *(const Node*)index.internal_data(); if (role == GModel::Role::Display) return node.name; @@ -196,7 +201,7 @@ GVariant GFileSystemModel::data(const GModelIndex& index, Role role) const } return m_file_icon; } - return { }; + return {}; } int GFileSystemModel::column_count(const GModelIndex&) const diff --git a/LibGUI/GFontDatabase.cpp b/LibGUI/GFontDatabase.cpp index 7359df0994..b676c71016 100644 --- a/LibGUI/GFontDatabase.cpp +++ b/LibGUI/GFontDatabase.cpp @@ -1,5 +1,5 @@ -#include #include +#include #include #include #include diff --git a/LibGUI/GFrame.cpp b/LibGUI/GFrame.cpp index 8048ce7791..418fe40492 100644 --- a/LibGUI/GFrame.cpp +++ b/LibGUI/GFrame.cpp @@ -1,6 +1,6 @@ #include -#include #include +#include GFrame::GFrame(GWidget* parent) : GWidget(parent) diff --git a/LibGUI/GInputBox.cpp b/LibGUI/GInputBox.cpp index 9474f91617..089003dbb9 100644 --- a/LibGUI/GInputBox.cpp +++ b/LibGUI/GInputBox.cpp @@ -1,7 +1,7 @@ -#include #include -#include #include +#include +#include #include #include @@ -55,7 +55,7 @@ void GInputBox::build() m_cancel_button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); m_cancel_button->set_preferred_size({ 0, 20 }); m_cancel_button->set_text("Cancel"); - m_cancel_button->on_click = [this] (auto&) { + m_cancel_button->on_click = [this](auto&) { dbgprintf("GInputBox: Cancel button clicked\n"); done(ExecCancel); }; @@ -64,7 +64,7 @@ void GInputBox::build() m_ok_button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); m_ok_button->set_preferred_size({ 0, 20 }); m_ok_button->set_text("OK"); - m_ok_button->on_click = [this] (auto&) { + m_ok_button->on_click = [this](auto&) { dbgprintf("GInputBox: OK button clicked\n"); m_text_value = m_text_editor->text(); done(ExecOK); diff --git a/LibGUI/GItemView.cpp b/LibGUI/GItemView.cpp index 71b0791f91..d5d9af0a6c 100644 --- a/LibGUI/GItemView.cpp +++ b/LibGUI/GItemView.cpp @@ -1,8 +1,8 @@ +#include #include #include -#include #include -#include +#include GItemView::GItemView(GWidget* parent) : GAbstractView(parent) @@ -38,7 +38,7 @@ void GItemView::did_update_model() void GItemView::update_content_size() { if (!model()) - return set_content_size({ }); + return set_content_size({}); m_visual_column_count = available_size().width() / effective_item_size().width(); if (m_visual_column_count) @@ -55,7 +55,7 @@ void GItemView::update_content_size() Rect GItemView::item_rect(int item_index) const { if (!m_visual_row_count || !m_visual_column_count) - return { }; + return {}; int visual_row_index = item_index / m_visual_column_count; int visual_column_index = item_index % m_visual_column_count; return { @@ -79,7 +79,7 @@ void GItemView::mousedown_event(GMouseEvent& event) return; } } - model()->set_selected_index({ }); + model()->set_selected_index({}); update(); } } @@ -100,7 +100,7 @@ void GItemView::paint_event(GPaintEvent& event) GPainter painter(*this); painter.add_clip_rect(widget_inner_rect()); - painter.add_clip_rect(event.rect()); + painter.add_clip_rect(event.rect()); painter.fill_rect(event.rect(), Color::White); painter.translate(-horizontal_scrollbar().value(), -vertical_scrollbar().value()); diff --git a/LibGUI/GLayout.cpp b/LibGUI/GLayout.cpp index 1aaa660ecc..13a547e4c0 100644 --- a/LibGUI/GLayout.cpp +++ b/LibGUI/GLayout.cpp @@ -54,7 +54,7 @@ void GLayout::add_widget(GWidget& widget) void GLayout::remove_widget(GWidget& widget) { - m_entries.remove_first_matching([&] (auto& entry) { + m_entries.remove_first_matching([&](auto& entry) { return entry.widget == &widget; }); if (m_owner) diff --git a/LibGUI/GListView.cpp b/LibGUI/GListView.cpp index b3b28a1ce7..bcf33a8fb4 100644 --- a/LibGUI/GListView.cpp +++ b/LibGUI/GListView.cpp @@ -1,7 +1,7 @@ -#include -#include -#include #include +#include +#include +#include GListView::GListView(GWidget* parent) : GAbstractView(parent) @@ -18,7 +18,7 @@ GListView::~GListView() void GListView::update_content_size() { if (!model()) - return set_content_size({ }); + return set_content_size({}); int content_width = 0; for (int row = 0, row_count = model()->row_count(); row < row_count; ++row) { @@ -76,7 +76,7 @@ void GListView::mousedown_event(GMouseEvent& event) update(); return; } - model()->set_selected_index({ }); + model()->set_selected_index({}); update(); } diff --git a/LibGUI/GMenu.cpp b/LibGUI/GMenu.cpp index 039ac8ab5c..cb5902adba 100644 --- a/LibGUI/GMenu.cpp +++ b/LibGUI/GMenu.cpp @@ -1,7 +1,7 @@ -#include -#include -#include #include +#include +#include +#include //#define GMENU_DEBUG @@ -81,8 +81,8 @@ int GMenu::realize_menu() ASSERT(m_menu_id > 0); for (int i = 0; i < m_items.size(); ++i) { auto& item = *m_items[i]; - item.set_menu_id({ }, m_menu_id); - item.set_identifier({ }, i); + item.set_menu_id({}, m_menu_id); + item.set_identifier({}, i); if (item.type() == GMenuItem::Separator) { WSAPI_ClientMessage request; request.type = WSAPI_ClientMessage::Type::AddMenuSeparator; diff --git a/LibGUI/GMenuBar.cpp b/LibGUI/GMenuBar.cpp index 1622d09fa0..19c736d8bc 100644 --- a/LibGUI/GMenuBar.cpp +++ b/LibGUI/GMenuBar.cpp @@ -1,5 +1,5 @@ -#include #include +#include GMenuBar::GMenuBar() { diff --git a/LibGUI/GMenuItem.cpp b/LibGUI/GMenuItem.cpp index e721d051a5..cfd38e778d 100644 --- a/LibGUI/GMenuItem.cpp +++ b/LibGUI/GMenuItem.cpp @@ -1,6 +1,6 @@ -#include #include #include +#include #include GMenuItem::GMenuItem(unsigned menu_id, Type type) @@ -14,7 +14,7 @@ GMenuItem::GMenuItem(unsigned menu_id, Retained&& action) , m_menu_id(menu_id) , m_action(move(action)) { - m_action->register_menu_item({ }, *this); + m_action->register_menu_item({}, *this); m_enabled = m_action->is_enabled(); m_checkable = m_action->is_checkable(); if (m_checkable) @@ -24,7 +24,7 @@ GMenuItem::GMenuItem(unsigned menu_id, Retained&& action) GMenuItem::~GMenuItem() { if (m_action) - m_action->unregister_menu_item({ }, *this); + m_action->unregister_menu_item({}, *this); } void GMenuItem::set_enabled(bool enabled) diff --git a/LibGUI/GMessageBox.cpp b/LibGUI/GMessageBox.cpp index 6e70771ab1..c628997069 100644 --- a/LibGUI/GMessageBox.cpp +++ b/LibGUI/GMessageBox.cpp @@ -1,7 +1,7 @@ -#include #include -#include #include +#include +#include #include void GMessageBox::show(const StringView& text, const StringView& title, Type type, CObject* parent) @@ -73,7 +73,7 @@ void GMessageBox::build() button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed); button->set_preferred_size({ 100, 20 }); button->set_text("OK"); - button->on_click = [this] (auto&) { + button->on_click = [this](auto&) { dbgprintf("GMessageBox: OK button clicked\n"); done(0); }; diff --git a/LibGUI/GModel.cpp b/LibGUI/GModel.cpp index 454d9996d5..46e1037c29 100644 --- a/LibGUI/GModel.cpp +++ b/LibGUI/GModel.cpp @@ -1,5 +1,5 @@ -#include #include +#include GModel::GModel() { @@ -29,7 +29,7 @@ void GModel::did_update() { if (on_model_update) on_model_update(*this); - for_each_view([] (auto& view) { + for_each_view([](auto& view) { view.did_update_model(); }); } @@ -41,7 +41,7 @@ void GModel::set_selected_index(const GModelIndex& index) m_selected_index = index; if (on_selection_changed) on_selection_changed(index); - for_each_view([] (auto& view) { + for_each_view([](auto& view) { view.did_update_selection(); }); } @@ -54,9 +54,9 @@ GModelIndex GModel::create_index(int row, int column, void* data) const GModelIndex GModel::sibling(int row, int column, const GModelIndex& parent) const { if (!parent.is_valid()) - return { }; + return {}; int row_count = this->row_count(parent); if (row < 0 || row > row_count) - return { }; + return {}; return index(row, column, parent); } diff --git a/LibGUI/GProgressBar.cpp b/LibGUI/GProgressBar.cpp index 1c60904cba..72c778242a 100644 --- a/LibGUI/GProgressBar.cpp +++ b/LibGUI/GProgressBar.cpp @@ -1,6 +1,6 @@ -#include -#include #include +#include +#include GProgressBar::GProgressBar(GWidget* parent) : GFrame(parent) diff --git a/LibGUI/GRadioButton.cpp b/LibGUI/GRadioButton.cpp index e88954dc97..59cab6d904 100644 --- a/LibGUI/GRadioButton.cpp +++ b/LibGUI/GRadioButton.cpp @@ -1,5 +1,5 @@ -#include #include +#include #include static RetainPtr s_unfilled_circle_bitmap; @@ -55,7 +55,7 @@ void GRadioButton::for_each_in_group(Callback callback) { if (!parent()) return; - parent()->for_each_child_of_type([&] (auto& child) { + parent()->for_each_child_of_type([&](auto& child) { return callback(static_cast(child)); }); } @@ -64,7 +64,7 @@ void GRadioButton::click() { if (!is_enabled()) return; - for_each_in_group([this] (auto& button) { + for_each_in_group([this](auto& button) { if (&button != this) button.set_checked(false); return IterationDecision::Continue; diff --git a/LibGUI/GResizeCorner.cpp b/LibGUI/GResizeCorner.cpp index 91407a509f..1dfba8b786 100644 --- a/LibGUI/GResizeCorner.cpp +++ b/LibGUI/GResizeCorner.cpp @@ -1,5 +1,5 @@ -#include #include +#include #include #include #include diff --git a/LibGUI/GScrollBar.cpp b/LibGUI/GScrollBar.cpp index d1834c82f4..dabd4649e9 100644 --- a/LibGUI/GScrollBar.cpp +++ b/LibGUI/GScrollBar.cpp @@ -1,8 +1,8 @@ +#include #include -#include #include #include -#include +#include static const char* s_up_arrow_bitmap_data = { " " @@ -28,7 +28,6 @@ static const char* s_down_arrow_bitmap_data = { " " }; - static const char* s_left_arrow_bitmap_data = { " " " # " @@ -146,7 +145,7 @@ Rect GScrollBar::increment_gutter_rect() const { auto scrubber_rect = this->scrubber_rect(); if (orientation() == Orientation::Vertical) - return { 0, scrubber_rect.bottom() + 1, button_width(), height() - button_height() - scrubber_rect.bottom() - 1}; + return { 0, scrubber_rect.bottom() + 1, button_width(), height() - button_height() - scrubber_rect.bottom() - 1 }; else return { scrubber_rect.right() + 1, 0, width() - button_width() - scrubber_rect.right() - 1, button_width() }; } @@ -174,7 +173,7 @@ int GScrollBar::scrubber_size() const Rect GScrollBar::scrubber_rect() const { if (!has_scrubber()) - return { }; + return {}; float x_or_y; if (m_value == m_min) x_or_y = button_size(); diff --git a/LibGUI/GScrollableWidget.cpp b/LibGUI/GScrollableWidget.cpp index 9ae217e792..906572f26e 100644 --- a/LibGUI/GScrollableWidget.cpp +++ b/LibGUI/GScrollableWidget.cpp @@ -1,12 +1,12 @@ -#include #include +#include GScrollableWidget::GScrollableWidget(GWidget* parent) : GFrame(parent) { m_vertical_scrollbar = new GScrollBar(Orientation::Vertical, this); m_vertical_scrollbar->set_step(4); - m_vertical_scrollbar->on_change = [this] (int) { + m_vertical_scrollbar->on_change = [this](int) { did_scroll(); update(); }; @@ -14,7 +14,7 @@ GScrollableWidget::GScrollableWidget(GWidget* parent) m_horizontal_scrollbar = new GScrollBar(Orientation::Horizontal, this); m_horizontal_scrollbar->set_step(4); m_horizontal_scrollbar->set_big_step(30); - m_horizontal_scrollbar->on_change = [this] (int) { + m_horizontal_scrollbar->on_change = [this](int) { did_scroll(); update(); }; diff --git a/LibGUI/GShortcut.cpp b/LibGUI/GShortcut.cpp index 871bf1c99c..07bf1f7524 100644 --- a/LibGUI/GShortcut.cpp +++ b/LibGUI/GShortcut.cpp @@ -1,114 +1,218 @@ -#include #include +#include static String to_string(KeyCode key) { switch (key) { - case Key_Escape: return "Escape"; - case Key_Tab: return "Tab"; - case Key_Backspace: return "Backspace"; - case Key_Return: return "Return"; - case Key_Insert: return "Insert"; - case Key_Delete: return "Delete"; - case Key_PrintScreen: return "PrintScreen"; - case Key_SysRq: return "SysRq"; - case Key_Home: return "Home"; - case Key_End: return "End"; - case Key_Left: return "Left"; - case Key_Up: return "Up"; - case Key_Right: return "Right"; - case Key_Down: return "Down"; - case Key_PageUp: return "PageUp"; - case Key_PageDown: return "PageDown"; - case Key_Shift: return "Shift"; - case Key_Control: return "Control"; - case Key_Alt: return "Alt"; - case Key_CapsLock: return "CapsLock"; - case Key_NumLock: return "NumLock"; - case Key_ScrollLock: return "ScrollLock"; - case Key_F1: return "F1"; - case Key_F2: return "F2"; - case Key_F3: return "F3"; - case Key_F4: return "F4"; - case Key_F5: return "F5"; - case Key_F6: return "F6"; - case Key_F7: return "F7"; - case Key_F8: return "F8"; - case Key_F9: return "F9"; - case Key_F10: return "F10"; - case Key_F11: return "F11"; - case Key_F12: return "F12"; - case Key_Space: return "Space"; - case Key_ExclamationPoint: return "!"; - case Key_DoubleQuote: return "\""; - case Key_Hashtag: return "#"; - case Key_Dollar: return "$"; - case Key_Percent: return "%"; - case Key_Ampersand: return "&"; - case Key_Apostrophe: return "'"; - case Key_LeftParen: return "("; - case Key_RightParen: return ")"; - case Key_Asterisk: return "*"; - case Key_Plus: return "+"; - case Key_Comma: return ","; - case Key_Minus: return "-"; - case Key_Period: return ","; - case Key_Slash: return "/"; - case Key_0: return "0"; - case Key_1: return "1"; - case Key_2: return "2"; - case Key_3: return "3"; - case Key_4: return "4"; - case Key_5: return "5"; - case Key_6: return "6"; - case Key_7: return "7"; - case Key_8: return "8"; - case Key_9: return "9"; - case Key_Colon: return ":"; - case Key_Semicolon: return ";"; - case Key_LessThan: return "<"; - case Key_Equal: return "="; - case Key_GreaterThan: return ">"; - case Key_QuestionMark: return "?"; - case Key_AtSign: return "@"; - case Key_A: return "A"; - case Key_B: return "B"; - case Key_C: return "C"; - case Key_D: return "D"; - case Key_E: return "E"; - case Key_F: return "F"; - case Key_G: return "G"; - case Key_H: return "H"; - case Key_I: return "I"; - case Key_J: return "J"; - case Key_K: return "K"; - case Key_L: return "L"; - case Key_M: return "M"; - case Key_N: return "N"; - case Key_O: return "O"; - case Key_P: return "P"; - case Key_Q: return "Q"; - case Key_R: return "R"; - case Key_S: return "S"; - case Key_T: return "T"; - case Key_U: return "U"; - case Key_V: return "V"; - case Key_W: return "W"; - case Key_X: return "X"; - case Key_Y: return "Y"; - case Key_Z: return "Z"; - case Key_LeftBracket: return "["; - case Key_RightBracket: return "]"; - case Key_Backslash: return "\\"; - case Key_Circumflex: return "^"; - case Key_Underscore: return "_"; - case Key_LeftBrace: return "{"; - case Key_RightBrace: return "}"; - case Key_Pipe: return "|"; - case Key_Tilde: return "~"; - case Key_Backtick: return "`"; + case Key_Escape: + return "Escape"; + case Key_Tab: + return "Tab"; + case Key_Backspace: + return "Backspace"; + case Key_Return: + return "Return"; + case Key_Insert: + return "Insert"; + case Key_Delete: + return "Delete"; + case Key_PrintScreen: + return "PrintScreen"; + case Key_SysRq: + return "SysRq"; + case Key_Home: + return "Home"; + case Key_End: + return "End"; + case Key_Left: + return "Left"; + case Key_Up: + return "Up"; + case Key_Right: + return "Right"; + case Key_Down: + return "Down"; + case Key_PageUp: + return "PageUp"; + case Key_PageDown: + return "PageDown"; + case Key_Shift: + return "Shift"; + case Key_Control: + return "Control"; + case Key_Alt: + return "Alt"; + case Key_CapsLock: + return "CapsLock"; + case Key_NumLock: + return "NumLock"; + case Key_ScrollLock: + return "ScrollLock"; + case Key_F1: + return "F1"; + case Key_F2: + return "F2"; + case Key_F3: + return "F3"; + case Key_F4: + return "F4"; + case Key_F5: + return "F5"; + case Key_F6: + return "F6"; + case Key_F7: + return "F7"; + case Key_F8: + return "F8"; + case Key_F9: + return "F9"; + case Key_F10: + return "F10"; + case Key_F11: + return "F11"; + case Key_F12: + return "F12"; + case Key_Space: + return "Space"; + case Key_ExclamationPoint: + return "!"; + case Key_DoubleQuote: + return "\""; + case Key_Hashtag: + return "#"; + case Key_Dollar: + return "$"; + case Key_Percent: + return "%"; + case Key_Ampersand: + return "&"; + case Key_Apostrophe: + return "'"; + case Key_LeftParen: + return "("; + case Key_RightParen: + return ")"; + case Key_Asterisk: + return "*"; + case Key_Plus: + return "+"; + case Key_Comma: + return ","; + case Key_Minus: + return "-"; + case Key_Period: + return ","; + case Key_Slash: + return "/"; + case Key_0: + return "0"; + case Key_1: + return "1"; + case Key_2: + return "2"; + case Key_3: + return "3"; + case Key_4: + return "4"; + case Key_5: + return "5"; + case Key_6: + return "6"; + case Key_7: + return "7"; + case Key_8: + return "8"; + case Key_9: + return "9"; + case Key_Colon: + return ":"; + case Key_Semicolon: + return ";"; + case Key_LessThan: + return "<"; + case Key_Equal: + return "="; + case Key_GreaterThan: + return ">"; + case Key_QuestionMark: + return "?"; + case Key_AtSign: + return "@"; + case Key_A: + return "A"; + case Key_B: + return "B"; + case Key_C: + return "C"; + case Key_D: + return "D"; + case Key_E: + return "E"; + case Key_F: + return "F"; + case Key_G: + return "G"; + case Key_H: + return "H"; + case Key_I: + return "I"; + case Key_J: + return "J"; + case Key_K: + return "K"; + case Key_L: + return "L"; + case Key_M: + return "M"; + case Key_N: + return "N"; + case Key_O: + return "O"; + case Key_P: + return "P"; + case Key_Q: + return "Q"; + case Key_R: + return "R"; + case Key_S: + return "S"; + case Key_T: + return "T"; + case Key_U: + return "U"; + case Key_V: + return "V"; + case Key_W: + return "W"; + case Key_X: + return "X"; + case Key_Y: + return "Y"; + case Key_Z: + return "Z"; + case Key_LeftBracket: + return "["; + case Key_RightBracket: + return "]"; + case Key_Backslash: + return "\\"; + case Key_Circumflex: + return "^"; + case Key_Underscore: + return "_"; + case Key_LeftBrace: + return "{"; + case Key_RightBrace: + return "}"; + case Key_Pipe: + return "|"; + case Key_Tilde: + return "~"; + case Key_Backtick: + return "`"; - case Key_Invalid: return "Invalid"; + case Key_Invalid: + return "Invalid"; default: ASSERT_NOT_REACHED(); } diff --git a/LibGUI/GSlider.cpp b/LibGUI/GSlider.cpp index 97546c8f82..66adb04cf1 100644 --- a/LibGUI/GSlider.cpp +++ b/LibGUI/GSlider.cpp @@ -1,5 +1,5 @@ -#include #include +#include #include GSlider::GSlider(GWidget* parent) diff --git a/LibGUI/GSortingProxyModel.cpp b/LibGUI/GSortingProxyModel.cpp index 0661fd3e9d..7897503ffd 100644 --- a/LibGUI/GSortingProxyModel.cpp +++ b/LibGUI/GSortingProxyModel.cpp @@ -1,13 +1,13 @@ -#include #include -#include +#include #include +#include GSortingProxyModel::GSortingProxyModel(Retained&& target) : m_target(move(target)) , m_key_column(-1) { - m_target->on_model_update = [this] (GModel&) { + m_target->on_model_update = [this](GModel&) { resort(); }; } @@ -29,9 +29,9 @@ int GSortingProxyModel::column_count(const GModelIndex& index) const GModelIndex GSortingProxyModel::map_to_target(const GModelIndex& index) const { if (!index.is_valid()) - return { }; + return {}; if (index.row() >= m_row_mappings.size() || index.column() >= column_count()) - return { }; + return {}; return target().index(m_row_mappings[index.row()], index.column()); } @@ -82,7 +82,7 @@ void GSortingProxyModel::resort() did_update(); return; } - quick_sort(m_row_mappings.begin(), m_row_mappings.end(), [&] (auto row1, auto row2) -> bool { + quick_sort(m_row_mappings.begin(), m_row_mappings.end(), [&](auto row1, auto row2) -> bool { auto data1 = target().data(target().index(row1, m_key_column), GModel::Role::Sort); auto data2 = target().data(target().index(row2, m_key_column), GModel::Role::Sort); if (data1 == data2) diff --git a/LibGUI/GSpinBox.cpp b/LibGUI/GSpinBox.cpp index 891d98a218..f7a6d4b38d 100644 --- a/LibGUI/GSpinBox.cpp +++ b/LibGUI/GSpinBox.cpp @@ -1,5 +1,5 @@ -#include #include +#include #include GSpinBox::GSpinBox(GWidget* parent) @@ -16,10 +16,10 @@ GSpinBox::GSpinBox(GWidget* parent) }; m_increment_button = new GButton(this); m_increment_button->set_text("\xf6"); - m_increment_button->on_click = [this] (GButton&) { set_value(m_value + 1); }; + m_increment_button->on_click = [this](GButton&) { set_value(m_value + 1); }; m_decrement_button = new GButton(this); m_decrement_button->set_text("\xf7"); - m_decrement_button->on_click = [this] (GButton&) { set_value(m_value - 1); }; + m_decrement_button->on_click = [this](GButton&) { set_value(m_value - 1); }; } GSpinBox::~GSpinBox() diff --git a/LibGUI/GSplitter.cpp b/LibGUI/GSplitter.cpp index 567dfb4693..2544541aef 100644 --- a/LibGUI/GSplitter.cpp +++ b/LibGUI/GSplitter.cpp @@ -1,5 +1,5 @@ -#include #include +#include #include GSplitter::GSplitter(Orientation orientation, GWidget* parent) @@ -40,7 +40,7 @@ void GSplitter::mousedown_event(GMouseEvent& event) GWidget* first_resizee { nullptr }; GWidget* second_resizee { nullptr }; int fudge = layout()->spacing(); - for_each_child_widget([&] (auto& child) { + for_each_child_widget([&](auto& child) { int child_start = m_orientation == Orientation::Horizontal ? child.relative_rect().left() : child.relative_rect().top(); int child_end = m_orientation == Orientation::Horizontal ? child.relative_rect().right() : child.relative_rect().bottom(); if (x_or_y > child_end && (x_or_y - fudge) <= child_end) @@ -65,7 +65,8 @@ void GSplitter::mousemove_event(GMouseEvent& event) if (!m_first_resizee || !m_second_resizee) { // One or both of the resizees were deleted during an ongoing resize, screw this. m_resizing = false; - return;; + return; + ; } int minimum_size = 0; auto new_first_resizee_size = m_first_resizee_start_size; @@ -112,5 +113,4 @@ void GSplitter::mouseup_event(GMouseEvent& event) m_resizing = false; if (!rect().contains(event.position())) window()->set_override_cursor(GStandardCursor::None); - } diff --git a/LibGUI/GStackWidget.cpp b/LibGUI/GStackWidget.cpp index 312938d66d..33b6af25eb 100644 --- a/LibGUI/GStackWidget.cpp +++ b/LibGUI/GStackWidget.cpp @@ -1,5 +1,5 @@ -#include #include +#include GStackWidget::GStackWidget(GWidget* parent) : GWidget(parent) @@ -28,7 +28,7 @@ void GStackWidget::resize_event(GResizeEvent& event) { if (!m_active_widget) return; - m_active_widget->set_relative_rect({ { }, event.size() }); + m_active_widget->set_relative_rect({ {}, event.size() }); } void GStackWidget::child_event(CChildEvent& event) @@ -44,7 +44,7 @@ void GStackWidget::child_event(CChildEvent& event) } else if (event.type() == GEvent::ChildRemoved) { if (m_active_widget == &child) { GWidget* new_active_widget = nullptr; - for_each_child_widget([&] (auto& new_child) { + for_each_child_widget([&](auto& new_child) { new_active_widget = &new_child; return IterationDecision::Abort; }); diff --git a/LibGUI/GStatusBar.cpp b/LibGUI/GStatusBar.cpp index 70e2552037..e219035e32 100644 --- a/LibGUI/GStatusBar.cpp +++ b/LibGUI/GStatusBar.cpp @@ -1,9 +1,9 @@ -#include -#include #include -#include +#include #include #include +#include +#include GStatusBar::GStatusBar(GWidget* parent) : GWidget(parent) diff --git a/LibGUI/GTabWidget.cpp b/LibGUI/GTabWidget.cpp index a465bac9e1..55b1aaa143 100644 --- a/LibGUI/GTabWidget.cpp +++ b/LibGUI/GTabWidget.cpp @@ -1,6 +1,6 @@ -#include #include #include +#include #include GTabWidget::GTabWidget(GWidget* parent) @@ -61,7 +61,7 @@ void GTabWidget::child_event(CChildEvent& event) } else if (event.type() == GEvent::ChildRemoved) { if (m_active_widget == &child) { GWidget* new_active_widget = nullptr; - for_each_child_widget([&] (auto& new_child) { + for_each_child_widget([&](auto& new_child) { new_active_widget = &new_child; return IterationDecision::Abort; }); diff --git a/LibGUI/GTableView.cpp b/LibGUI/GTableView.cpp index e4b49af9e5..8e096f3b43 100644 --- a/LibGUI/GTableView.cpp +++ b/LibGUI/GTableView.cpp @@ -1,13 +1,13 @@ -#include +#include +#include +#include +#include #include -#include #include +#include +#include #include #include -#include -#include -#include -#include GTableView::GTableView(GWidget* parent) : GAbstractView(parent) @@ -24,7 +24,7 @@ GTableView::~GTableView() void GTableView::update_content_size() { if (!model()) - return set_content_size({ }); + return set_content_size({}); int content_width = 0; int column_count = model()->column_count(); @@ -80,9 +80,9 @@ int GTableView::column_width(int column_index) const Rect GTableView::header_rect(int column_index) const { if (!model()) - return { }; + return {}; if (is_column_hidden(column_index)) - return { }; + return {}; int x_offset = 0; for (int i = 0; i < column_index; ++i) { if (is_column_hidden(i)) @@ -100,7 +100,7 @@ Point GTableView::adjusted_position(const Point& position) Rect GTableView::column_resize_grabbable_rect(int column) const { if (!model()) - return { }; + return {}; auto header_rect = this->header_rect(column); return { header_rect.right() - 1, header_rect.top(), 4, header_rect.height() }; } @@ -148,7 +148,7 @@ void GTableView::mousedown_event(GMouseEvent& event) return; } } - model()->set_selected_index({ }); + model()->set_selected_index({}); update(); } @@ -427,7 +427,7 @@ GMenu& GTableView::ensure_header_context_menu() for (int column = 0; column < model()->column_count(); ++column) { auto& column_data = this->column_data(column); auto name = model()->column_name(column); - column_data.visibility_action = GAction::create(name, [this, column] (GAction& action) { + column_data.visibility_action = GAction::create(name, [this, column](GAction& action) { action.set_checked(!action.is_checked()); set_column_hidden(column, !action.is_checked()); }); diff --git a/LibGUI/GTextEditor.cpp b/LibGUI/GTextEditor.cpp index d06d3e7d40..a21159c36a 100644 --- a/LibGUI/GTextEditor.cpp +++ b/LibGUI/GTextEditor.cpp @@ -1,17 +1,17 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include -#include +#include GTextEditor::GTextEditor(Type type, GWidget* parent) : GScrollableWidget(parent) @@ -35,29 +35,35 @@ GTextEditor::~GTextEditor() void GTextEditor::create_actions() { - m_undo_action = GAction::create("Undo", { Mod_Ctrl, Key_Z }, GraphicsBitmap::load_from_file("/res/icons/16x16/undo.png"), [&] (const GAction&) { + m_undo_action = GAction::create("Undo", { Mod_Ctrl, Key_Z }, GraphicsBitmap::load_from_file("/res/icons/16x16/undo.png"), [&](const GAction&) { // FIXME: Undo - }, this); + }, + this); - m_redo_action = GAction::create("Redo", { Mod_Ctrl, Key_Y }, GraphicsBitmap::load_from_file("/res/icons/16x16/redo.png"), [&] (const GAction&) { + m_redo_action = GAction::create("Redo", { Mod_Ctrl, Key_Y }, GraphicsBitmap::load_from_file("/res/icons/16x16/redo.png"), [&](const GAction&) { // FIXME: Redo - }, this); + }, + this); - m_cut_action = GAction::create("Cut", { Mod_Ctrl, Key_X }, GraphicsBitmap::load_from_file("/res/icons/cut16.png"), [&] (const GAction&) { + m_cut_action = GAction::create("Cut", { Mod_Ctrl, Key_X }, GraphicsBitmap::load_from_file("/res/icons/cut16.png"), [&](const GAction&) { cut(); - }, this); + }, + this); - m_copy_action = GAction::create("Copy", { Mod_Ctrl, Key_C }, GraphicsBitmap::load_from_file("/res/icons/16x16/edit-copy.png"), [&] (const GAction&) { + m_copy_action = GAction::create("Copy", { Mod_Ctrl, Key_C }, GraphicsBitmap::load_from_file("/res/icons/16x16/edit-copy.png"), [&](const GAction&) { copy(); - }, this); + }, + this); - m_paste_action = GAction::create("Paste", { Mod_Ctrl, Key_V }, GraphicsBitmap::load_from_file("/res/icons/paste16.png"), [&] (const GAction&) { + m_paste_action = GAction::create("Paste", { Mod_Ctrl, Key_V }, GraphicsBitmap::load_from_file("/res/icons/paste16.png"), [&](const GAction&) { paste(); - }, this); + }, + this); - m_delete_action = GAction::create("Delete", { 0, Key_Delete }, GraphicsBitmap::load_from_file("/res/icons/16x16/delete.png"), [&] (const GAction&) { + m_delete_action = GAction::create("Delete", { 0, Key_Delete }, GraphicsBitmap::load_from_file("/res/icons/16x16/delete.png"), [&](const GAction&) { do_delete(); - }, this); + }, + this); } void GTextEditor::set_text(const StringView& text) @@ -69,7 +75,7 @@ void GTextEditor::set_text(const StringView& text) m_lines.clear(); int start_of_current_line = 0; - auto add_line = [&] (int current_position) { + auto add_line = [&](int current_position) { int line_length = current_position - start_of_current_line; auto line = make(); if (line_length) @@ -189,7 +195,7 @@ void GTextEditor::mousedown_event(GMouseEvent& event) if (event.modifiers() & Mod_Shift) { if (!has_selection()) - m_selection.set(m_cursor, { }); + m_selection.set(m_cursor, {}); } else { m_selection.clear(); } @@ -200,7 +206,7 @@ void GTextEditor::mousedown_event(GMouseEvent& event) if (!(event.modifiers() & Mod_Shift)) { if (!has_selection()) - m_selection.set(m_cursor, { }); + m_selection.set(m_cursor, {}); } if (m_selection.start().is_valid() && m_selection.start() != m_cursor) @@ -243,7 +249,7 @@ int GTextEditor::ruler_width() const Rect GTextEditor::ruler_content_rect(int line_index) const { if (!m_ruler_visible) - return { }; + return {}; return { 0 - ruler_width() + horizontal_scrollbar().value(), line_index * line_height(), @@ -263,7 +269,7 @@ void GTextEditor::paint_event(GPaintEvent& event) painter.translate(frame_thickness(), frame_thickness()); - Rect ruler_rect { 0, 0, ruler_width(), height() - height_occupied_by_horizontal_scrollbar()}; + Rect ruler_rect { 0, 0, ruler_width(), height() - height_occupied_by_horizontal_scrollbar() }; if (m_ruler_visible) { painter.fill_rect(ruler_rect, Color::LightGray); @@ -289,8 +295,7 @@ void GTextEditor::paint_event(GPaintEvent& event) String::format("%u", i), is_current_line ? Font::default_bold_font() : font(), TextAlignment::CenterRight, - is_current_line ? Color::DarkGray : Color::MidGray - ); + is_current_line ? Color::DarkGray : Color::MidGray); } } @@ -310,7 +315,8 @@ void GTextEditor::paint_event(GPaintEvent& event) int selection_end_column_on_line = selection.end().line() == i ? selection.end().column() : line.length(); int selection_left = content_x_for_position({ i, selection_start_column_on_line }); - int selection_right = content_x_for_position({ i, selection_end_column_on_line });; + int selection_right = content_x_for_position({ i, selection_end_column_on_line }); + ; Rect selection_rect { selection_left, line_rect.y(), selection_right - selection_left, line_rect.height() }; painter.fill_rect(selection_rect, Color::from_rgb(0x955233)); @@ -325,7 +331,7 @@ void GTextEditor::paint_event(GPaintEvent& event) void GTextEditor::toggle_selection_if_needed_for_event(const GKeyEvent& event) { if (event.shift() && !m_selection.is_valid()) { - m_selection.set(m_cursor, { }); + m_selection.set(m_cursor, {}); did_update_selection(); update(); return; @@ -654,7 +660,7 @@ int GTextEditor::content_x_for_position(const GTextPosition& position) const Rect GTextEditor::cursor_content_rect() const { if (!m_cursor.is_valid()) - return { }; + return {}; ASSERT(!m_lines.is_empty()); ASSERT(m_cursor.column() <= (current_line().length() + 1)); @@ -662,7 +668,7 @@ Rect GTextEditor::cursor_content_rect() const if (is_single_line()) { Rect cursor_rect { cursor_x, 0, 1, font().glyph_height() + 2 }; - cursor_rect.center_vertically_within({ { }, frame_inner_rect().size() }); + cursor_rect.center_vertically_within({ {}, frame_inner_rect().size() }); return cursor_rect; } return { cursor_x, m_cursor.line() * line_height(), 1, line_height() }; @@ -694,7 +700,7 @@ Rect GTextEditor::line_content_rect(int line_index) const auto& line = *m_lines[line_index]; if (is_single_line()) { Rect line_rect = { content_x_for_position({ line_index, 0 }), 0, line.length() * glyph_width(), font().glyph_height() + 2 }; - line_rect.center_vertically_within({ { }, frame_inner_rect().size() }); + line_rect.center_vertically_within({ {}, frame_inner_rect().size() }); return line_rect; } return { @@ -887,7 +893,7 @@ void GTextEditor::clear() String GTextEditor::selected_text() const { if (!has_selection()) - return { }; + return {}; auto selection = normalized_selection(); StringBuilder builder; @@ -1005,7 +1011,7 @@ void GTextEditor::did_change() update_content_size(); if (!m_have_pending_change_notification) { m_have_pending_change_notification = true; - deferred_invoke([this] (auto&) { + deferred_invoke([this](auto&) { if (on_change) on_change(); m_have_pending_change_notification = false; diff --git a/LibGUI/GToolBar.cpp b/LibGUI/GToolBar.cpp index 8b0fa64aaa..5aa6f469c2 100644 --- a/LibGUI/GToolBar.cpp +++ b/LibGUI/GToolBar.cpp @@ -1,8 +1,8 @@ -#include +#include #include #include -#include #include +#include GToolBar::GToolBar(GWidget* parent) : GWidget(parent) @@ -32,7 +32,7 @@ void GToolBar::add_action(Retained&& action) button->set_icon(item->action->icon()); else button->set_text(item->action->text()); - button->on_click = [raw_action_ptr] (const GButton&) { + button->on_click = [raw_action_ptr](const GButton&) { raw_action_ptr->activate(); }; @@ -54,7 +54,7 @@ public: set_background_color(Color::White); set_preferred_size({ 8, 22 }); } - virtual ~SeparatorWidget() override { } + virtual ~SeparatorWidget() override {} virtual void paint_event(GPaintEvent& event) override { diff --git a/LibGUI/GTreeView.cpp b/LibGUI/GTreeView.cpp index 0b7203deb5..618b966f07 100644 --- a/LibGUI/GTreeView.cpp +++ b/LibGUI/GTreeView.cpp @@ -1,6 +1,6 @@ -#include #include #include +#include //#define DEBUG_ITEM_RECTS @@ -39,9 +39,9 @@ GModelIndex GTreeView::index_at_content_position(const Point& position, bool& is { is_toggle = false; if (!model()) - return { }; + return {}; GModelIndex result; - traverse_in_paint_order([&] (const GModelIndex& index, const Rect& rect, const Rect& toggle_rect, int) { + traverse_in_paint_order([&](const GModelIndex& index, const Rect& rect, const Rect& toggle_rect, int) { if (rect.contains(position)) { result = index; return IterationDecision::Abort; @@ -88,7 +88,7 @@ void GTreeView::traverse_in_paint_order(Callback callback) const int indent_level = 0; int y_offset = 0; - Function traverse_index = [&] (const GModelIndex& index) { + Function traverse_index = [&](const GModelIndex& index) { int row_count_at_index = model.row_count(index); if (index.is_valid()) { auto& metadata = ensure_metadata_for_index(index); @@ -139,7 +139,7 @@ void GTreeView::paint_event(GPaintEvent& event) auto& model = *this->model(); auto visible_content_rect = this->visible_content_rect(); - traverse_in_paint_order([&] (const GModelIndex& index, const Rect& rect, const Rect& toggle_rect, int indent_level) { + traverse_in_paint_order([&](const GModelIndex& index, const Rect& rect, const Rect& toggle_rect, int indent_level) { if (!rect.intersects(visible_content_rect)) return IterationDecision::Continue; #ifdef DEBUG_ITEM_RECTS @@ -202,7 +202,7 @@ void GTreeView::scroll_into_view(const GModelIndex& a_index, Orientation orienta if (!a_index.is_valid()) return; Rect found_rect; - traverse_in_paint_order([&] (const GModelIndex& index, const Rect& rect, const Rect&, int) { + traverse_in_paint_order([&](const GModelIndex& index, const Rect& rect, const Rect&, int) { if (index == a_index) { found_rect = rect; return IterationDecision::Abort; @@ -251,7 +251,7 @@ void GTreeView::update_content_size() { int height = 0; int width = 0; - traverse_in_paint_order([&] (const GModelIndex&, const Rect& rect, const Rect&, int) { + traverse_in_paint_order([&](const GModelIndex&, const Rect& rect, const Rect&, int) { width = max(width, rect.right()); height += rect.height(); return IterationDecision::Continue; @@ -267,7 +267,7 @@ void GTreeView::keydown_event(GKeyEvent& event) if (event.key() == KeyCode::Key_Up) { GModelIndex previous_index; GModelIndex found_index; - traverse_in_paint_order([&] (const GModelIndex& index, const Rect&, const Rect&, int) { + traverse_in_paint_order([&](const GModelIndex& index, const Rect&, const Rect&, int) { if (index == cursor_index) { found_index = previous_index; return IterationDecision::Abort; @@ -284,7 +284,7 @@ void GTreeView::keydown_event(GKeyEvent& event) if (event.key() == KeyCode::Key_Down) { GModelIndex previous_index; GModelIndex found_index; - traverse_in_paint_order([&] (const GModelIndex& index, const Rect&, const Rect&, int) { + traverse_in_paint_order([&](const GModelIndex& index, const Rect&, const Rect&, int) { if (previous_index == cursor_index) { found_index = index; return IterationDecision::Abort; diff --git a/LibGUI/GVariant.cpp b/LibGUI/GVariant.cpp index e8c07e98e9..bad6f9d3b6 100644 --- a/LibGUI/GVariant.cpp +++ b/LibGUI/GVariant.cpp @@ -252,4 +252,3 @@ String GVariant::to_string() const } ASSERT_NOT_REACHED(); } - diff --git a/LibGUI/GWidget.cpp b/LibGUI/GWidget.cpp index 30f4284a46..d0ac2161b0 100644 --- a/LibGUI/GWidget.cpp +++ b/LibGUI/GWidget.cpp @@ -2,13 +2,13 @@ #include "GEvent.h" #include "GEventLoop.h" #include "GWindow.h" -#include #include -#include #include -#include #include +#include #include +#include +#include #include GWidget::GWidget(GWidget* parent) @@ -116,7 +116,7 @@ void GWidget::handle_paint_event(GPaintEvent& event) #endif } paint_event(event); - for_each_child_widget([&] (auto& child) { + for_each_child_widget([&](auto& child) { if (!child.is_visible()) return IterationDecision::Continue; if (child.relative_rect().intersects(event.rect())) { @@ -418,7 +418,7 @@ void GWidget::invalidate_layout() if (m_layout_dirty) return; m_layout_dirty = true; - deferred_invoke([this] (auto&) { + deferred_invoke([this](auto&) { m_layout_dirty = false; auto* w = window(); if (!w) @@ -472,7 +472,7 @@ void GWidget::move_to_front() return; if (parent->children().size() == 1) return; - parent->children().remove_first_matching([this] (auto& entry) { + parent->children().remove_first_matching([this](auto& entry) { return entry == this; }); parent->children().append(this); @@ -486,7 +486,7 @@ void GWidget::move_to_back() return; if (parent->children().size() == 1) return; - parent->children().remove_first_matching([this] (auto& entry) { + parent->children().remove_first_matching([this](auto& entry) { return entry == this; }); parent->children().prepend(this); diff --git a/LibGUI/GWindow.cpp b/LibGUI/GWindow.cpp index 190f1e9cd2..13aa292d34 100644 --- a/LibGUI/GWindow.cpp +++ b/LibGUI/GWindow.cpp @@ -2,12 +2,12 @@ #include "GEvent.h" #include "GEventLoop.h" #include "GWidget.h" -#include -#include +#include #include #include #include -#include +#include +#include //#define UPDATE_COALESCING_DEBUG @@ -235,7 +235,7 @@ void GWindow::event(CEvent& event) auto rect = rects.first(); if (rect.is_empty() || created_new_backing_store) { rects.clear(); - rects.append({ { }, paint_event.window_size() }); + rects.append({ {}, paint_event.window_size() }); } for (auto& rect : rects) @@ -294,10 +294,10 @@ void GWindow::event(CEvent& event) m_back_bitmap = nullptr; if (!m_pending_paint_event_rects.is_empty()) { m_pending_paint_event_rects.clear_with_capacity(); - m_pending_paint_event_rects.append({ { }, new_size }); + m_pending_paint_event_rects.append({ {}, new_size }); } - m_rect_when_windowless = { { }, new_size }; - m_main_widget->set_relative_rect({ { }, new_size }); + m_rect_when_windowless = { {}, new_size }; + m_main_widget->set_relative_rect({ {}, new_size }); return; } @@ -326,7 +326,7 @@ void GWindow::update(const Rect& a_rect) } if (m_pending_paint_event_rects.is_empty()) { - deferred_invoke([this] (auto&) { + deferred_invoke([this](auto&) { auto rects = move(m_pending_paint_event_rects); if (rects.is_empty()) return; @@ -357,7 +357,7 @@ void GWindow::set_main_widget(GWidget* widget) if (m_main_widget->vertical_size_policy() == SizePolicy::Fixed) new_window_rect.set_height(m_main_widget->preferred_size().height()); set_rect(new_window_rect); - m_main_widget->set_relative_rect({ { }, new_window_rect.size() }); + m_main_widget->set_relative_rect({ {}, new_window_rect.size() }); m_main_widget->set_window(this); if (m_main_widget->accepts_focus()) m_main_widget->set_focus(true); @@ -530,14 +530,14 @@ void GWindow::start_wm_resize() Vector GWindow::focusable_widgets() const { if (!m_main_widget) - return { }; + return {}; Vector collected_widgets; - Function collect_focusable_widgets = [&] (GWidget& widget) { + Function collect_focusable_widgets = [&](GWidget& widget) { if (widget.accepts_focus()) collected_widgets.append(&widget); - widget.for_each_child_widget([&] (auto& child) { + widget.for_each_child_widget([&](auto& child) { if (!child.is_visible()) return IterationDecision::Continue; if (!child.is_enabled())