forked from Ivasoft/DSView
fix: The cursor moved out of range
This commit is contained in:
@@ -219,7 +219,15 @@ void Ruler::mouseMoveEvent(QMouseEvent *e)
|
||||
(void)e;
|
||||
|
||||
if (_grabbed_marker) {
|
||||
_grabbed_marker->set_index(_view.pixel2index(_view.hover_point().x()));
|
||||
int msx = _view.hover_point().x();
|
||||
if (msx < 0)
|
||||
msx = 0;
|
||||
int body_width = _view.get_body_width();
|
||||
if (msx > body_width)
|
||||
msx = body_width;
|
||||
|
||||
uint64_t index = _view.pixel2index(msx);
|
||||
_grabbed_marker->set_index(index);
|
||||
_view.cursor_moving();
|
||||
_curs_moved = true;
|
||||
}
|
||||
@@ -280,10 +288,18 @@ void Ruler::mouseReleaseEvent(QMouseEvent *event)
|
||||
if (!_cursor_go_visible) {
|
||||
if (!_cursor_sel_visible) {
|
||||
_cursor_sel_x = event->pos().x();
|
||||
_cursor_sel_visible = true;
|
||||
_cursor_sel_visible = true;
|
||||
}
|
||||
else {
|
||||
int overCursor;
|
||||
int msx = _cursor_sel_x;
|
||||
if (msx < 0)
|
||||
msx = 0;
|
||||
|
||||
int body_width = _view.get_body_width();
|
||||
if (msx > body_width)
|
||||
msx = body_width;
|
||||
|
||||
auto &cursor_list = _view.get_cursorList();
|
||||
uint64_t index = _view.pixel2index(_cursor_sel_x);
|
||||
overCursor = in_cursor_sel_rect(event->pos());
|
||||
|
||||
@@ -74,7 +74,7 @@ uint64_t TimeMarker::index()
|
||||
|
||||
void TimeMarker::set_index(uint64_t index)
|
||||
{
|
||||
_index = index;
|
||||
_index = index;
|
||||
time_changed();
|
||||
}
|
||||
|
||||
|
||||
@@ -1243,5 +1243,19 @@ void View::auto_set_max_scale()
|
||||
set_scale(_maxscale);
|
||||
}
|
||||
|
||||
int View::get_body_width()
|
||||
{
|
||||
if (_time_viewport != NULL)
|
||||
return _time_viewport->width();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int View::get_body_height()
|
||||
{
|
||||
if (_time_viewport != NULL)
|
||||
return _time_viewport->height();
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace view
|
||||
} // namespace pv
|
||||
|
||||
@@ -400,9 +400,8 @@ public:
|
||||
void show_wait_trigger();
|
||||
void set_device();
|
||||
void set_receive_len(uint64_t len);
|
||||
|
||||
private:
|
||||
|
||||
int get_body_width();
|
||||
int get_body_height();
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -811,10 +811,16 @@ void Viewport::mouseMoveEvent(QMouseEvent *event)
|
||||
while (i != xcursor_list.end()) {
|
||||
if ((*i)->grabbed() != XCursor::XCur_None) {
|
||||
if ((*i)->grabbed() == XCursor::XCur_Y) {
|
||||
double rate = (_view.hover_point().x() - xrect.left()) * 1.0 / xrect.width();
|
||||
double rate = (_view.hover_point().x() - xrect.left()) * 1.0 / xrect.width();
|
||||
(*i)->set_value((*i)->grabbed(), min(rate, 1.0));
|
||||
} else {
|
||||
double rate = (_view.hover_point().y() - xrect.top()) * 1.0 / xrect.height();
|
||||
}
|
||||
else {
|
||||
int msy = _view.hover_point().y();
|
||||
int body_y = _view.get_body_height();
|
||||
if (msy > body_y)
|
||||
msy = body_y;
|
||||
|
||||
double rate = (msy - xrect.top()) * 1.0 / xrect.height();
|
||||
(*i)->set_value((*i)->grabbed(), max(rate, 0.0));
|
||||
}
|
||||
_xcurs_moved = true;
|
||||
@@ -1087,7 +1093,7 @@ void Viewport::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
|
||||
int mode = _view.session().get_device()->get_work_mode();
|
||||
|
||||
if (mode == LOGIC)// && _view.session().is_stopped_status())
|
||||
if (mode == LOGIC)
|
||||
{
|
||||
if (event->button() == Qt::RightButton) {
|
||||
if (_view.scale() == _view.get_maxscale())
|
||||
|
||||
Reference in New Issue
Block a user