From: Soeren Apel Date: Fri, 22 Sep 2017 06:24:17 +0000 (+0200) Subject: TraceView: Make header resize state determination reliable X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=9510aea0fca1c7438be30a4f43988c001b5f0b11;p=pulseview.git TraceView: Make header resize state determination reliable --- diff --git a/pv/views/trace/view.cpp b/pv/views/trace/view.cpp index f63401e6..52a13255 100644 --- a/pv/views/trace/view.cpp +++ b/pv/views/trace/view.cpp @@ -129,6 +129,7 @@ View::View(Session &session, bool is_main_view, QWidget *parent) : offset_(0), updating_scroll_(false), settings_restored_(false), + header_was_shrunk_(false), sticky_scrolling_(false), // Default setting is set in MainWindow::setup_ui() always_zoom_to_fit_(false), tick_period_(0), @@ -886,7 +887,7 @@ void View::set_scroll_default() set_v_offset(extents.first); } -bool View::header_was_shrunk() const +void View::determine_if_header_was_shrunk() { const int header_pane_width = splitter_->sizes().front(); const int header_width = header_->extended_size_hint().width(); @@ -894,7 +895,7 @@ bool View::header_was_shrunk() const // Allow for a slight margin of error so that we also accept // slight differences when e.g. a label name change increased // the overall width - return (header_pane_width < (header_width - 10)); + header_was_shrunk_ = (header_pane_width < (header_width - 10)); } void View::expand_header_to_fit() @@ -1103,13 +1104,16 @@ void View::extents_changed(bool horz, bool vert) void View::on_signal_name_changed() { - if (!header_was_shrunk()) + if (!header_was_shrunk_) expand_header_to_fit(); } void View::on_splitter_moved() { - if (!header_was_shrunk()) + // The header can only shrink when the splitter is moved manually + determine_if_header_was_shrunk(); + + if (!header_was_shrunk_) expand_header_to_fit(); } diff --git a/pv/views/trace/view.hpp b/pv/views/trace/view.hpp index 2b7e4a45..b73e7828 100644 --- a/pv/views/trace/view.hpp +++ b/pv/views/trace/view.hpp @@ -323,7 +323,7 @@ private: void set_scroll_default(); - bool header_was_shrunk() const; + void determine_if_header_was_shrunk(); void expand_header_to_fit(); @@ -432,6 +432,7 @@ private: bool updating_scroll_; bool settings_restored_; + bool header_was_shrunk_; bool sticky_scrolling_; bool coloured_bg_;