Resolve several issues

1: Allow mouse scroll events to pass through to parent if the plot has not mouse scroll events to do. i.e. if scroll to zoom is disabled, and the graph is part of a scroll area, this allows scrolling the scroll area while the mouse is over the plot.

2: Fixed bug with resize timer resetting itself every time, rather than actually performing the countdown and calling the function.

3. Fixed bug with margins being calculated incorrectly, preventing the complete removal of margins from a plot.
This commit is contained in:
Jonathan 2024-11-21 16:44:32 -08:00
parent 5b647f24d1
commit aef6bb67b4
2 changed files with 11 additions and 6 deletions

View File

@ -916,20 +916,20 @@ void JKQTBasePlotter::calcPlotScaling(JKQTPEnhancedPainter& painter){
auto s=xAxis->getSize1(painter); auto s=xAxis->getSize1(painter);
internalPlotMargins[PlotMarginUse::muAxesOutside].bottom+=s.requiredSize; internalPlotMargins[PlotMarginUse::muAxesOutside].bottom+=s.requiredSize;
if (s.elongateMin>0) elongateLeft=qMax(elongateLeft,s.elongateMin); if (s.elongateMin>0) elongateLeft=qMax(elongateLeft,s.elongateMin);
if (s.elongateMax>0) elongateRight=qMax(elongateRight,s.elongateMax); if (s.elongateMax>0) elongateRight=qMin(elongateRight,s.elongateMax);
s=xAxis->getSize2(painter); s=xAxis->getSize2(painter);
if (s.elongateMin>0) elongateLeft=qMax(elongateLeft,s.elongateMin); if (s.elongateMin>0) elongateLeft=qMax(elongateLeft,s.elongateMin);
if (s.elongateMax>0) elongateRight=qMax(elongateRight,s.elongateMax); if (s.elongateMax>0) elongateRight=qMin(elongateRight,s.elongateMax);
internalPlotMargins[PlotMarginUse::muAxesOutside].top+=s.requiredSize; internalPlotMargins[PlotMarginUse::muAxesOutside].top+=s.requiredSize;
double elongateBottom=0,elongateTop=0; double elongateBottom=0,elongateTop=0;
s=yAxis->getSize1(painter); s=yAxis->getSize1(painter);
if (s.elongateMin>0) elongateBottom=qMax(elongateBottom,s.elongateMin); if (s.elongateMin>0) elongateBottom=qMax(elongateBottom,s.elongateMin);
if (s.elongateMax>0) elongateTop=qMax(elongateTop,s.elongateMax); if (s.elongateMax>0) elongateTop=qMin(elongateTop,s.elongateMax);
internalPlotMargins[PlotMarginUse::muAxesOutside].left+=s.requiredSize; internalPlotMargins[PlotMarginUse::muAxesOutside].left+=s.requiredSize;
s=yAxis->getSize2(painter); s=yAxis->getSize2(painter);
if (s.elongateMin>0) elongateBottom=qMax(elongateBottom,s.elongateMin); if (s.elongateMin>0) elongateBottom=qMax(elongateBottom,s.elongateMin);
if (s.elongateMax>0) elongateTop=qMax(elongateTop,s.elongateMax); if (s.elongateMax>0) elongateTop=qMin(elongateTop,s.elongateMax);
internalPlotMargins[PlotMarginUse::muAxesOutside].right+=s.requiredSize; internalPlotMargins[PlotMarginUse::muAxesOutside].right+=s.requiredSize;

View File

@ -1140,6 +1140,9 @@ void JKQTPlotter::wheelEvent ( QWheelEvent * event ) {
if (d.y()>=1 && d.y()<10) d.setY(10); if (d.y()>=1 && d.y()<10) d.setY(10);
if (d.y()<=-1 && d.y()>-10) d.setY(-10); if (d.y()<=-1 && d.y()>-10) d.setY(-10);
} }
}else{
event->ignore();
return;
} }
@ -1413,8 +1416,10 @@ void JKQTPlotter::resizeEvent(QResizeEvent *event) {
// Do this now // Do this now
delayedResizeEvent(); delayedResizeEvent();
} else { } else {
resizeTimer.setSingleShot(true); if(!resizeTimer.isActive()){
resizeTimer.start(jkqtp_RESIZE_DELAY); resizeTimer.setSingleShot(true);
resizeTimer.start(jkqtp_RESIZE_DELAY);
}
} }
} }