From 666f7ea38c167cac3c7c94e833a832dacdbeaacc Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 14 Sep 2021 20:08:48 +0200 Subject: [PATCH] WX_GRID::EnsureColLabelsVisible(): avoid updating column label size when not needed. Updating column label size generates a UI event and if EnsureColLabelsVisible() is called inside a UI event, this is a bit annoying. --- common/widgets/wx_grid.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/widgets/wx_grid.cpp b/common/widgets/wx_grid.cpp index 1ef1f9b175..5621e6fb78 100644 --- a/common/widgets/wx_grid.cpp +++ b/common/widgets/wx_grid.cpp @@ -295,6 +295,7 @@ void WX_GRID::EnsureColLabelsVisible() // TODO: use a better way to evaluate the text size, for bold font int line_height = int( GetTextExtent( "Mj" ).y * 1.1 ) + 3; int row_height = GetColLabelSize(); + int initial_row_height = row_height; // Headers can be multiline. Fix the Column Label Height to show the full header // However GetTextExtent does not work on multiline strings, @@ -311,5 +312,8 @@ void WX_GRID::EnsureColLabelsVisible() } } - SetColLabelSize( row_height ); + // Update the column label size, but only if needed, to avoid generating useless + // and perhaps annoying UI events when the size does not change + if( initial_row_height != row_height ) + SetColLabelSize( row_height ); }