浏览代码

PixelPaint: Debounce ImageEditor on_modified_change event

This limits the frequency of updates performed by the histogram and
vectorscope widgets.
Tim Ledbetter 2 年之前
父节点
当前提交
53133b4359
共有 1 个文件被更改,包括 3 次插入2 次删除
  1. 3 2
      Userland/Applications/PixelPaint/MainWidget.cpp

+ 3 - 2
Userland/Applications/PixelPaint/MainWidget.cpp

@@ -1075,12 +1075,13 @@ ImageEditor& MainWidget::create_new_editor(NonnullRefPtr<Image> image)
         m_tab_widget->set_tab_title(image_editor, title);
         m_tab_widget->set_tab_title(image_editor, title);
     };
     };
 
 
-    image_editor.on_modified_change = [&](auto const modified) {
+    image_editor.on_modified_change = Core::debounce([&](auto const modified) {
         m_tab_widget->set_tab_modified(image_editor, modified);
         m_tab_widget->set_tab_modified(image_editor, modified);
         update_window_modified();
         update_window_modified();
         m_histogram_widget->image_changed();
         m_histogram_widget->image_changed();
         m_vectorscope_widget->image_changed();
         m_vectorscope_widget->image_changed();
-    };
+    },
+        100);
 
 
     image_editor.on_image_mouse_position_change = [&](auto const& mouse_position) {
     image_editor.on_image_mouse_position_change = [&](auto const& mouse_position) {
         auto const& image_size = current_image_editor()->image().size();
         auto const& image_size = current_image_editor()->image().size();