+ view_(parent),
+ dragging_(false)
+{
+ setAttribute(Qt::WA_NoSystemBackground, true);
+ setFocusPolicy(Qt::ClickFocus);
+ setMouseTracking(true);
+}
+
+void MarginWidget::show_popup(const shared_ptr<ViewItem> &item)
+{
+ pv::widgets::Popup *const p = item->create_popup(this);
+ if (p)
+ p->show();
+}
+
+void MarginWidget::mouse_left_press_event(QMouseEvent *event)
+{
+ (void)event;
+
+ const bool ctrl_pressed =
+ QApplication::keyboardModifiers() & Qt::ControlModifier;
+
+ // Clear selection if control is not pressed and this item is unselected
+ if ((!mouse_down_item_ || !mouse_down_item_->selected()) &&
+ !ctrl_pressed)
+ clear_selection();
+
+ // Set the signal selection state if the item has been clicked
+ if (mouse_down_item_) {
+ if (ctrl_pressed)
+ mouse_down_item_->select(!mouse_down_item_->selected());
+ else
+ mouse_down_item_->select(true);
+ }
+
+ // Save the offsets of any signals which will be dragged
+ const auto items = this->items();
+ for (auto &i : items)
+ if (i->selected())
+ i->drag();
+
+ selection_changed();
+ update();
+}
+
+void MarginWidget::mousePressEvent(QMouseEvent *event)