LibCore+Applications: Put timeout parameter first in debounce()

This matches the parameter order for Core::Timer's factory methods,
stops clang-format freaking out so much, and just seems nicer to
me. :^)
This commit is contained in:
Sam Atkins 2023-06-14 14:54:46 +01:00 committed by Andreas Kling
parent 4c349165f2
commit 08edc872aa
Notes: sideshowbarker 2024-07-16 22:22:13 +09:00
5 changed files with 10 additions and 14 deletions

View File

@ -190,7 +190,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
};
text_box.on_change = Core::debounce([&]() {
text_box.on_change = Core::debounce(5, [&]() {
{
Threading::MutexLocker locker(app_state.lock);
if (app_state.last_query == text_box.text())
@ -200,8 +200,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
db.search(text_box.text());
},
5);
});
text_box.on_return_pressed = [&]() {
if (!app_state.selected_index.has_value())
return;

View File

@ -62,7 +62,7 @@ CharacterSearchWidget::CharacterSearchWidget()
m_search_input->on_up_pressed = [this] { m_results_table->move_cursor(GUI::AbstractView::CursorMovement::Up, GUI::AbstractView::SelectionUpdate::Set); };
m_search_input->on_down_pressed = [this] { m_results_table->move_cursor(GUI::AbstractView::CursorMovement::Down, GUI::AbstractView::SelectionUpdate::Set); };
m_search_input->on_change = Core::debounce([this] { search(); }, 100);
m_search_input->on_change = Core::debounce(100, [this] { search(); });
m_results_table->horizontal_scrollbar().set_visible(false);
m_results_table->set_column_headers_visible(false);

View File

@ -1299,13 +1299,12 @@ ImageEditor& MainWidget::create_new_editor(NonnullRefPtr<Image> image)
m_tab_widget->set_tab_title(image_editor, title);
};
image_editor.on_modified_change = Core::debounce([&](auto const modified) {
image_editor.on_modified_change = Core::debounce(100, [&](auto const modified) {
m_tab_widget->set_tab_modified(image_editor, modified);
update_window_modified();
m_histogram_widget->image_changed();
m_vectorscope_widget->image_changed();
},
100);
});
image_editor.on_image_mouse_position_change = [&](auto const& mouse_position) {
auto const& image_size = current_image_editor()->image().size();
@ -1340,11 +1339,10 @@ ImageEditor& MainWidget::create_new_editor(NonnullRefPtr<Image> image)
m_show_rulers_action->set_checked(show_rulers);
};
image_editor.on_scale_change = Core::debounce([this](float scale) {
image_editor.on_scale_change = Core::debounce(100, [this](float scale) {
m_zoom_combobox->set_text(DeprecatedString::formatted("{}%", roundf(scale * 100)));
current_image_editor()->update_tool_cursor();
},
100);
});
image_editor.on_primary_color_change = [&](Color color) {
m_palette_widget->set_primary_color(color);

View File

@ -70,10 +70,9 @@ MainWidget::MainWidget()
if (font_entry != "default")
m_editor->set_font(Gfx::FontDatabase::the().get_by_name(font_entry));
m_editor->on_change = Core::debounce([this] {
m_editor->on_change = Core::debounce(100, [this] {
update_preview();
},
100);
});
m_editor->on_modified_change = [this](bool modified) {
window()->set_modified(modified);

View File

@ -11,7 +11,7 @@
namespace Core {
template<typename TFunction>
auto debounce(TFunction function, int timeout)
auto debounce(int timeout, TFunction function)
{
RefPtr<Core::Timer> timer;
return [=]<typename... T>(T... args) mutable {