X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fviews%2Ftrace%2Fview.cpp;h=52a13255cef585253b747812dac554d0b7349772;hb=9510aea0fca1c7438be30a4f43988c001b5f0b11;hp=269768669a5a44b8c94ac30c8ee7cbc9d2a2252f;hpb=00c518d66a61f28609b0eeddd0ce375d0002da94;p=pulseview.git diff --git a/pv/views/trace/view.cpp b/pv/views/trace/view.cpp index 2697686..52a1325 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,11 +895,19 @@ 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() { + // Setting the maximum width of the header widget doesn't work as + // expected because the splitter would allow the user to make the + // pane wider than that, creating empty space as a result. + // To make this work, we stricly enforce the maximum width by + // expanding the header unless the user shrunk it on purpose. + // As we're then setting the width of the header pane, we set the + // splitter to the maximum allowed position. + int splitter_area_width = 0; for (int w : splitter_->sizes()) splitter_area_width += w; @@ -1095,20 +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() { - // Setting the maximum width of the header widget doesn't work as - // expected because the splitter would allow the user to make the - // pane wider than that, creating empty space as a result. - // To make this work, we stricly enforce the maximum width by - // expanding the header unless the user shrunk it on purpose. - // As we're then setting the width of the header pane, we set the - // splitter to the maximum allowed position. - 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(); }