Improve stats update times for buffer switches and toolbar toggles.

This commit is contained in:
Pavel Sanda 2024-04-05 22:59:07 +02:00
parent 6f8b944d39
commit 77273303a5
3 changed files with 24 additions and 0 deletions

View File

@ -303,6 +303,7 @@ struct BufferView::Private
int stats_ref_value_w_ = 0; int stats_ref_value_w_ = 0;
int stats_ref_value_c_ = 0; int stats_ref_value_c_ = 0;
int stats_ref_value_nb_ = 0; int stats_ref_value_nb_ = 0;
bool stats_update_trigger_ = false;
}; };
@ -2032,6 +2033,7 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
break; break;
case LFUN_STATISTICS_REFERENCE_CLAMP: { case LFUN_STATISTICS_REFERENCE_CLAMP: {
d->stats_update_trigger_ = true;
if (cmd.argument() == "reset") { if (cmd.argument() == "reset") {
d->stats_ref_value_w_ = d->stats_ref_value_c_ = d->stats_ref_value_nb_ = 0; d->stats_ref_value_w_ = d->stats_ref_value_c_ = d->stats_ref_value_nb_ = 0;
break; break;
@ -3936,4 +3938,14 @@ bool BufferView::clickableInset() const
return d->clickable_inset_; return d->clickable_inset_;
} }
bool BufferView::stats_update_trigger()
{
if (d->stats_update_trigger_) {
d->stats_update_trigger_ = false;
return true;
}
return false;
}
} // namespace lyx } // namespace lyx

View File

@ -406,6 +406,8 @@ public:
int stats_ref_value_w() const; int stats_ref_value_w() const;
int stats_ref_value_c() const; int stats_ref_value_c() const;
int stats_ref_value_nb() const; int stats_ref_value_nb() const;
//signals need for update in gui
bool stats_update_trigger();
private: private:
/// noncopyable /// noncopyable

View File

@ -555,6 +555,8 @@ public:
bool already_in_selection_ = false; bool already_in_selection_ = false;
/// Maximum size of "short" selection for which we can update with faster timer_rate /// Maximum size of "short" selection for which we can update with faster timer_rate
int const max_sel_chars = 5000; int const max_sel_chars = 5000;
/// equivalent time_to_update = 0; but better to see it the code
bool stats_update_trigger_ = false;
}; };
@ -1454,6 +1456,12 @@ void GuiView::showStats()
return; return;
} }
// UI toggle, buffer change, etc
if (bv->stats_update_trigger() || d.stats_update_trigger_) {
d.stats_update_trigger_ = false;
d.time_to_update = 0;
}
Cursor const & cur = bv->cursor(); Cursor const & cur = bv->cursor();
// we start new selection and need faster update // we start new selection and need faster update
@ -1587,6 +1595,7 @@ void GuiView::onBufferViewChanged()
&& zoom_slider_->value() < zoom_slider_->maximum()); && zoom_slider_->value() < zoom_slider_->maximum());
zoom_out_->setEnabled(currentBufferView() zoom_out_->setEnabled(currentBufferView()
&& zoom_slider_->value() > zoom_slider_->minimum()); && zoom_slider_->value() > zoom_slider_->minimum());
d.stats_update_trigger_ = true;
} }
@ -5162,6 +5171,7 @@ bool GuiView::lfunUiToggle(string const & ui_component)
} else } else
return false; return false;
stat_counts_->setVisible(statsEnabled()); stat_counts_->setVisible(statsEnabled());
d.stats_update_trigger_ = true;
return true; return true;
} }