#include "viewport.hpp"
#include "pv/session.hpp"
+#include "pv/globalsettings.hpp"
#include "pv/devices/device.hpp"
#include "pv/data/logic.hpp"
#include "pv/data/logicsegment.hpp"
saved_v_offset_(0),
size_finalized_(false)
{
+ GlobalSettings settings;
+ coloured_bg_ = settings.value(GlobalSettings::Key_View_ColouredBG).toBool();
+
connect(scrollarea_.horizontalScrollBar(), SIGNAL(valueChanged(int)),
this, SLOT(h_scroll_value_changed(int)));
connect(scrollarea_.verticalScrollBar(), SIGNAL(valueChanged(int)),
sticky_scrolling_ = state;
}
+void View::toggle_sticky_scrolling(void)
+{
+ sticky_scrolling_ = !sticky_scrolling_;
+}
+
void View::enable_coloured_bg(bool state)
{
const vector<shared_ptr<TraceTreeItem>> items(
const QSize areaSize = viewport_->size();
- // Special case: when starting up and the window isn't visible yet,
- // areaSize is [0, 0]. In this case we want to be called again later
- if ((areaSize.height() == 0) || (!size_finalized_)) {
- scroll_needs_defaults_ = true;
- return;
- } else {
- scroll_needs_defaults_ = false;
- }
-
const pair<int, int> extents = v_extents();
const int trace_height = extents.second - extents.first;
else
// Put the first trace at the top, letting the bottom ones overflow
set_v_offset(extents.first);
+
+ // If we're not sure whether setting the defaults worked as
+ // the window wasn't set up entirely yet, we want to be called
+ // again later to make sure
+ scroll_needs_defaults_ = !size_finalized_;
}
void View::update_layout()
}
// Add and position the pending top levels items
+ int offset = v_extents().second;
for (auto item : new_top_level_items) {
add_child_item(item);
// Position the item after the last item or at the top if there is none
- int offset = v_extents().second;
const pair<int, int> extents = item->v_extents();
if (item->enabled())
set_time_unit(util::TimeUnit::Samples);
trigger_markers_.clear();
+
+ // Activate "always zoom to fit" if the setting is enabled
+ GlobalSettings settings;
+ bool state = settings.value(GlobalSettings::Key_View_AlwaysZoomToFit).toBool();
+ if (state) {
+ always_zoom_to_fit_ = true;
+ always_zoom_to_fit_changed(always_zoom_to_fit_);
+ }
}
if (state == Session::Stopped) {
// Reset "always zoom to fit", the acquisition has stopped
if (always_zoom_to_fit_) {
always_zoom_to_fit_ = false;
- always_zoom_to_fit_changed(false);
+ always_zoom_to_fit_changed(always_zoom_to_fit_);
}
}
}