return base_;
}
+bool Trace::is_selectable(QPoint pos) const
+{
+ // True if the header was clicked, false if the trace area was clicked
+ const View *view = owner_->view();
+ assert(view);
+
+ return (pos.x() <= view->header_width());
+}
+
+bool Trace::is_draggable() const
+{
+ // While the header label that belongs to this trace is draggable,
+ // the trace itself shall not be
+ return false;
+}
+
void Trace::set_segment_display_mode(SegmentDisplayMode mode)
{
segment_display_mode_ = mode;
QRectF Trace::hit_box_rect(const ViewItemPaintParams &pp) const
{
+ // This one is only for the trace itself, excluding the header area
+ const View *view = owner_->view();
+ assert(view);
+
pair<int, int> extents = v_extents();
const int top = pp.top() + get_visual_y() + extents.first;
const int height = extents.second - extents.first;
- return QRectF(pp.left(), top, pp.width(), height);
+
+ return QRectF(pp.left() + view->header_width(), top,
+ pp.width() - view->header_width(), height);
}
void Trace::set_current_segment(const int segment)
*/
shared_ptr<data::SignalBase> base() const;
+ /**
+ * Returns true if the item may be selected.
+ */
+ virtual bool is_selectable(QPoint pos) const;
+
+ /**
+ * Returns true if the item may be dragged/moved.
+ */
+ virtual bool is_draggable() const;
+
/**
* Configures the segment display mode to use.
*/
i->animate_to_layout_v_offset();
}
+int View::header_width() const
+{
+ return header_->extended_size_hint().width();
+}
+
void View::on_setting_changed(const QString &key, const QVariant &value)
{
if (key == GlobalSettings::Key_View_TriggerIsZeroTime)
void View::determine_if_header_was_shrunk()
{
const int header_pane_width = splitter_->sizes().front();
- const int header_width = header_->extended_size_hint().width();
// 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
- header_was_shrunk_ = (header_pane_width < (header_width - 10));
+ header_was_shrunk_ = (header_pane_width < (header_width() - 10));
}
void View::resize_header_to_fit()
namespace trace {
-class CursorHeader;
class DecodeTrace;
class Header;
class Ruler;
class Signal;
-class Trace;
class Viewport;
class TriggerMarker;
void restack_all_trace_tree_items();
+ int header_width() const;
+
void on_setting_changed(const QString &key, const QVariant &value);
Q_SIGNALS:
{
}
+bool ViewItem::is_selectable(QPoint pos) const
+{
+ (void)pos;
+ return true;
+}
+
bool ViewItem::selected() const
{
return selected_;
*/
virtual bool enabled() const = 0;
+ /**
+ * Returns true if the item may be selected.
+ */
+ virtual bool is_selectable(QPoint pos) const;
+
/**
* Returns true if the item has been selected by the user.
*/
clear_selection();
// Set the signal selection state if the item has been clicked
- if (mouse_down_item_) {
+ if (mouse_down_item_ && mouse_down_item_->is_selectable(event->pos())) {
if (ctrl_pressed)
mouse_down_item_->select(!mouse_down_item_->selected());
else