diff --git a/uppsrc/ScatterCtrl/ScatterCtrl.cpp b/uppsrc/ScatterCtrl/ScatterCtrl.cpp index f61a736f7..79bc76519 100644 --- a/uppsrc/ScatterCtrl/ScatterCtrl.cpp +++ b/uppsrc/ScatterCtrl/ScatterCtrl.cpp @@ -58,7 +58,16 @@ void ScatterCtrl::SaveToClipboard(bool) void ScatterCtrl::Paint(Draw& w) { + if (IsNull(highlight_0) && highlighting) { + highlighting = false; + KillTimeCallback(); + } + if (!IsNull(highlight_0) && !highlighting) { + highlighting = true; + SetTimeCallback(-200, THISBACK(TimerCallback)); + } TimeStop t; + lastRefresh0_ms = GetTickCount(); if (mode == MD_DRAW) { ScatterCtrl::SetDrawing(w, GetSize(), 1); PlotTexts(w, GetSize(), 1); @@ -74,6 +83,10 @@ void ScatterCtrl::Paint(Draw& w) lastRefresh_ms = t.Elapsed(); } +void ScatterCtrl::TimerCallback() { + Refresh(); +} + void ScatterCtrl::ProcessPopUp(const Point & pt) { double _x = (popLT.x - hPlotLeft)*xRange/(GetSize().cx - (hPlotLeft + hPlotRight)-1) + xMin; @@ -288,35 +301,17 @@ void ScatterCtrl::MouseWheel(Point pt, int zdelta, dword keyFlags) void ScatterCtrl::MouseMove(Point pt, dword) { if (isScrolling) { + double factorX = 0, factorY = 0; int shiftX = pt.x - butDownX; - if (mouseHandlingX && shiftX != 0) { - double factorX = double(shiftX)/(GetSize().cx - (hPlotLeft + hPlotRight) - 1); - double deltaX = factorX*xRange; - xMin -= deltaX; - xMinUnit += deltaX; - AdjustMinUnitX(); - butDownX = pt.x; - } + if (mouseHandlingX && shiftX != 0) + factorX = double(shiftX)/(GetSize().cx - (hPlotLeft + hPlotRight) - 1); int shiftY = pt.y - butDownY; - if (mouseHandlingY && shiftY != 0) { - double factorY = double(shiftY)/(GetSize().cy - (vPlotTop + vPlotBottom) - 1); - double deltaY = -factorY*yRange; - yMin -= deltaY; - yMinUnit += deltaY; - AdjustMinUnitY(); - if (drawY2Reticle) { - double deltaY2 = -factorY*yRange2; - yMin2 -= deltaY2; - yMinUnit2 += deltaY2; - AdjustMinUnitY2(); - } - butDownY = pt.y; - } - if ((mouseHandlingX && shiftX != 0) || (mouseHandlingY && shiftY != 0)) { - WhenSetXYMin(); - Refresh(); - WhenZoomScroll(); - } + if (mouseHandlingY && shiftY != 0) + factorY = double(shiftY)/(GetSize().cy - (vPlotTop + vPlotBottom) - 1); + butDownX = pt.x; + butDownY = pt.y; + if ((mouseHandlingX && shiftX != 0) || (mouseHandlingY && shiftY != 0)) + ScatterDraw::Scroll(factorX, -factorY); } if(isLabelPopUp) { if (paintInfo && hPlotLeft <= pt.x && pt.x <= GetSize().cx - hPlotRight && @@ -341,7 +336,15 @@ void ScatterCtrl::MouseLeave() void ScatterCtrl::MouseZoom(int zdelta, bool hor, bool ver) { double scale = zdelta > 0 ? zdelta/100. : -100./zdelta; - if (((lastxRange < xRange*scale) || (lastyRange < yRange*scale)) && (lastRefresh_ms > maxRefresh_ms)) +// if (hor && (lastxRange < xRange*scale)) +// return; +// if (ver && (lastyRange < yRange*scale)) +// return; + if (lastRefresh_sign != ((scale >= 0) ? 1 : -1)) + lastRefresh_ms = Null; // Change of scale sign resets lastRefresh check + if (GetTickCount() - lastRefresh0_ms > 1000) + lastRefresh_ms = Null; // 1 sec resets lastRefresh check + if (!IsNull(lastRefresh_ms) && (lastRefresh_ms > maxRefresh_ms)) return; Zoom(scale, mouseHandlingX, mouseHandlingY); } @@ -366,8 +369,8 @@ void ScatterCtrl::ContextMenu(Bar& bar) bar.Add(t_("Fit to data"), ScatterImg::ShapeHandles(), THISBACK1(FitToData, mouseHandlingY)); bar.Add(t_("Zoom +"), ScatterImg::ZoomPlus(), THISBACK3(Zoom, 1/1.2, true, mouseHandlingY)); bar.Add(t_("Zoom -"), ScatterImg::ZoomMinus(), THISBACK3(Zoom, 1.2, true, mouseHandlingY)); - bar.Add(t_("Scroll Left"), ScatterImg::LeftArrow(), THISBACK2(ScatterDraw::Scroll, -0.2, 0)); - bar.Add(t_("Scroll Right"), ScatterImg::RightArrow(), THISBACK2(ScatterDraw::Scroll, 0.2, 0)); + bar.Add(t_("Scroll Left"), ScatterImg::LeftArrow(), THISBACK2(ScatterDraw::Scroll, 0.2, 0)); + bar.Add(t_("Scroll Right"), ScatterImg::RightArrow(), THISBACK2(ScatterDraw::Scroll, -0.2, 0)); if (mouseHandlingY) { bar.Add(t_("Scroll Up"), ScatterImg::UpArrow(), THISBACK2(ScatterDraw::Scroll, 0, -0.2)); bar.Add(t_("Scroll Down"), ScatterImg::DownArrow(), THISBACK2(ScatterDraw::Scroll, 0, 0.2)); @@ -435,6 +438,7 @@ ScatterCtrl::ScatterCtrl() : offset(10,12), copyRatio(1) SetMouseBehavior(defaultMouse); lastRefresh_ms = Null; maxRefresh_ms = 500; + highlighting = false; } END_UPP_NAMESPACE \ No newline at end of file diff --git a/uppsrc/ScatterCtrl/ScatterCtrl.h b/uppsrc/ScatterCtrl/ScatterCtrl.h index 249e1e89c..c9bcd34e5 100644 --- a/uppsrc/ScatterCtrl/ScatterCtrl.h +++ b/uppsrc/ScatterCtrl/ScatterCtrl.h @@ -191,8 +191,11 @@ private: bool showPropDlg; int lastRefresh_ms; + dword lastRefresh0_ms; int maxRefresh_ms; + bool highlighting; + MouseBehaviour *mouseBehavior; void ProcessPopUp(const Point & pt); @@ -220,7 +223,8 @@ private: virtual Image CursorImage(Point p, dword keyflags); template - void SetDrawing(T& w, const Size &size, int scale); + void SetDrawing(T& w, const Size &size, int scale); + void TimerCallback(); }; template diff --git a/uppsrc/ScatterCtrl/src.tpp/ScatterCtrl$en-us.tpp b/uppsrc/ScatterCtrl/src.tpp/ScatterCtrl$en-us.tpp index 2f00a0130..2987b058d 100644 --- a/uppsrc/ScatterCtrl/src.tpp/ScatterCtrl$en-us.tpp +++ b/uppsrc/ScatterCtrl/src.tpp/ScatterCtrl$en-us.tpp @@ -1200,6 +1200,13 @@ in ScatterCtrl.&] or].&] [s1; &] [s6;%- &] +[s5;:ScatterCtrl`:`:SetMouseHandling`(bool`,bool`):%- [_^ScatterCtrl^ ScatterCtrl][@(0.0.255) `& +]_[* SetMouseHandling]([@(0.0.255) bool]_[*@3 valx]_`=_[@(0.0.255) true], +[@(0.0.255) bool]_[*@3 valy]_`=_[@(0.0.255) false])&] +[s3; If [%-*@3 valx] mouse can scroll or zoom in X axis.&] +[s3; If [%-*@3 valy] mouse can scroll or zoom in Y axis.&] +[s1; &] +[s6;%- &] [s5;:ScatterCtrl`:`:ShowContextMenu`(bool`):%- [_^ScatterCtrl^ ScatterCtrl][@(0.0.255) `& ]_[* ShowContextMenu]([@(0.0.255) bool]_[*@3 show]_`=_[@(0.0.255) true])&] [s3; If [%-*@3 show] is true the context menu can be opened (right