+ saved_v_offset_(0)
+{
+ QVBoxLayout *root_layout = new QVBoxLayout(this);
+ root_layout->setContentsMargins(0, 0, 0, 0);
+ root_layout->addWidget(splitter_);
+
+ viewport_ = new Viewport(*this);
+ scrollarea_ = new CustomScrollArea(splitter_);
+ scrollarea_->setViewport(viewport_);
+ scrollarea_->setFrameShape(QFrame::NoFrame);
+
+ ruler_ = new Ruler(*this);
+
+ header_ = new Header(*this);
+ header_->setMinimumWidth(10); // So that the arrow tips show at least
+
+ // We put the header into a simple layout so that we can add the top margin,
+ // allowing us to make it line up with the bottom of the ruler
+ QWidget *header_container = new QWidget();
+ header_container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ QVBoxLayout *header_layout = new QVBoxLayout(header_container);
+ header_layout->setContentsMargins(0, ruler_->sizeHint().height(), 0, 0);
+ header_layout->addWidget(header_);
+
+ // To let the ruler and scrollarea be on the same split pane, we need a layout
+ QWidget *trace_container = new QWidget();
+ trace_container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ QVBoxLayout *trace_layout = new QVBoxLayout(trace_container);
+ trace_layout->setSpacing(0); // We don't want space between the ruler and scrollarea
+ trace_layout->setContentsMargins(0, 0, 0, 0);
+ trace_layout->addWidget(ruler_);
+ trace_layout->addWidget(scrollarea_);
+
+ splitter_->addWidget(header_container);
+ splitter_->addWidget(trace_container);
+ splitter_->setHandleWidth(1); // Don't show a visible rubber band
+ splitter_->setCollapsible(0, false); // Prevent the header from collapsing
+ splitter_->setCollapsible(1, false); // Prevent the traces from collapsing
+ splitter_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+
+ viewport_->installEventFilter(this);
+ ruler_->installEventFilter(this);
+ header_->installEventFilter(this);
+
+ // Set up settings and event handlers