SLOT(on_view_showHoverMarker_changed(int)));
trace_view_layout->addRow(tr("Highlight mouse cursor using a vertical marker line"), cb);
+ QSpinBox *snap_distance_sb = new QSpinBox();
+ snap_distance_sb->setRange(0, 1000);
+ snap_distance_sb->setSuffix(tr(" pixels"));
+ snap_distance_sb->setValue(
+ settings.value(GlobalSettings::Key_View_SnapDistance).toInt());
+ connect(snap_distance_sb, SIGNAL(valueChanged(int)), this,
+ SLOT(on_view_snapDistance_changed(int)));
+ trace_view_layout->addRow(tr("Maximum distance from edges before cursors snap to them"), snap_distance_sb);
+
QComboBox *thr_disp_mode_cb = new QComboBox();
thr_disp_mode_cb->addItem(tr("None"), GlobalSettings::ConvThrDispMode_None);
thr_disp_mode_cb->addItem(tr("Background"), GlobalSettings::ConvThrDispMode_Background);
settings.setValue(GlobalSettings::Key_View_ShowHoverMarker, state ? true : false);
}
+void Settings::on_view_snapDistance_changed(int value)
+{
+ GlobalSettings settings;
+ settings.setValue(GlobalSettings::Key_View_SnapDistance, value);
+}
+
void Settings::on_view_conversionThresholdDispMode_changed(int state)
{
GlobalSettings settings;
void on_view_showSamplingPoints_changed(int state);
void on_view_showAnalogMinorGrid_changed(int state);
void on_view_showHoverMarker_changed(int state);
+ void on_view_snapDistance_changed(int value);
void on_view_conversionThresholdDispMode_changed(int state);
void on_view_defaultDivHeight_changed(int value);
void on_view_defaultLogicHeight_changed(int value);
const QString GlobalSettings::Key_View_DefaultDivHeight = "View_DefaultDivHeight";
const QString GlobalSettings::Key_View_DefaultLogicHeight = "View_DefaultLogicHeight";
const QString GlobalSettings::Key_View_ShowHoverMarker = "View_ShowHoverMarker";
+const QString GlobalSettings::Key_View_SnapDistance = "View_SnapDistance";
const QString GlobalSettings::Key_Dec_InitialStateConfigurable = "Dec_InitialStateConfigurable";
const QString GlobalSettings::Key_Dec_ExportFormat = "Dec_ExportFormat";
const QString GlobalSettings::Key_Log_BufferSize = "Log_BufferSize";
setValue(Key_View_DefaultLogicHeight,
2 * QFontMetrics(QApplication::font()).height());
+ if (!contains(Key_View_SnapDistance))
+ setValue(Key_View_SnapDistance, 15);
+
if (!contains(Key_Dec_ExportFormat))
setValue(Key_Dec_ExportFormat, "%s %d: %c: %1");
static const QString Key_View_DefaultDivHeight;
static const QString Key_View_DefaultLogicHeight;
static const QString Key_View_ShowHoverMarker;
+ static const QString Key_View_SnapDistance;
static const QString Key_Dec_InitialStateConfigurable;
static const QString Key_Dec_ExportFormat;
static const QString Key_Log_BufferSize;
// Set up settings and event handlers
GlobalSettings settings;
colored_bg_ = settings.value(GlobalSettings::Key_View_ColoredBG).toBool();
+ snap_distance_ = settings.value(GlobalSettings::Key_View_SnapDistance).toInt();
GlobalSettings::add_change_handler(this);
int64_t View::get_nearest_level_change(const QPoint &p) const
{
+ if (snap_distance_ == 0)
+ return -1;
+
shared_ptr<Signal> signal = signal_under_mouse_cursor_;
if (!signal)
int64_t nearest = -1;
// Only use closest left or right edge if they're close to the cursor
- if ((left_delta < right_delta) && (left_delta < 15))
+ if ((left_delta < right_delta) && (left_delta < snap_distance_))
nearest = edges.front().first;
- if ((left_delta >= right_delta) && (right_delta < 15))
+ if ((left_delta >= right_delta) && (right_delta < snap_distance_))
nearest = edges.back().first;
return nearest;
{
if (key == GlobalSettings::Key_View_TriggerIsZeroTime)
on_settingViewTriggerIsZeroTime_changed(value);
+
+ if (key == GlobalSettings::Key_View_SnapDistance) {
+ GlobalSettings settings;
+ snap_distance_ = settings.value(GlobalSettings::Key_View_SnapDistance).toInt();
+ }
}
void View::trigger_event(int segment_id, util::Timestamp location)
QPoint hover_point_;
shared_ptr<Signal> signal_under_mouse_cursor_;
+ uint16_t snap_distance_;
unsigned int sticky_events_;
QTimer lazy_event_handler_;