]> sigrok.org Git - pulseview.git/commitdiff
TraceView: Make header resize state determination reliable
authorSoeren Apel <redacted>
Fri, 22 Sep 2017 06:24:17 +0000 (08:24 +0200)
committerSoeren Apel <redacted>
Fri, 22 Sep 2017 19:13:48 +0000 (21:13 +0200)
pv/views/trace/view.cpp
pv/views/trace/view.hpp

index f63401e61ed496f114ea0173cb985ea204c034f3..52a13255cef585253b747812dac554d0b7349772 100644 (file)
@@ -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();
 }
 
index 2b7e4a45c6ef3c71ee08e88f4695b19a5b801a55..b73e78280a28eeed1628957c431e75913574ed65 100644 (file)
@@ -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_;