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 a11a4db8b2
commit 7e2c1dca36
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_c_ = 0;
int stats_ref_value_nb_ = 0;
bool stats_update_trigger_ = false;
};
@ -2026,6 +2027,7 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
break;
case LFUN_STATISTICS_REFERENCE_CLAMP: {
d->stats_update_trigger_ = true;
if (cmd.argument() == "reset") {
d->stats_ref_value_w_ = d->stats_ref_value_c_ = d->stats_ref_value_nb_ = 0;
break;
@ -3921,4 +3923,14 @@ bool BufferView::clickableInset() const
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

View File

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

View File

@ -555,6 +555,8 @@ public:
bool already_in_selection_ = false;
/// Maximum size of "short" selection for which we can update with faster timer_rate
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;
}
// 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();
// we start new selection and need faster update
@ -1587,6 +1595,7 @@ void GuiView::onBufferViewChanged()
&& zoom_slider_->value() < zoom_slider_->maximum());
zoom_out_->setEnabled(currentBufferView()
&& zoom_slider_->value() > zoom_slider_->minimum());
d.stats_update_trigger_ = true;
}
@ -5162,6 +5171,7 @@ bool GuiView::lfunUiToggle(string const & ui_component)
} else
return false;
stat_counts_->setVisible(statsEnabled());
d.stats_update_trigger_ = true;
return true;
}