49 return ACCELERATING_ZOOM_CONTROLLER::CLOCK::now();
56 m_accTimeout( aAccTimeout ),
76 const double minStep = 1.05;
79 auto timeDiff = std::chrono::duration_cast<TIMEOUT>( timestamp -
m_prevTimestamp );
84 wxString::Format(
"Rot %d, time diff: %ldms", aRotation, (
long)timeDiff.count() ) );
95 zoomScale = std::max( zoomScale, minStep );
98 zoomScale = 1.0 / zoomScale;
102 zoomScale = ( aRotation > 0 ) ? minStep : 1 / minStep;
106 wxLogTrace(
traceZoomScroll, wxString::Format(
" Zoom factor: %f", zoomScale ) );
127 wxLogTrace(
traceZoomScroll, wxString::Format(
"Rot %d", aRotation ) );
129 aRotation = ( aRotation > 0 ) ? std::min( aRotation, 100 ) : std::max( aRotation, -100 );
131 double dscale = aRotation *
m_scale;
133 double zoom_scale = ( aRotation > 0 ) ? ( 1 + dscale ) : 1 / ( 1 - dscale );
135 wxLogTrace(
traceZoomScroll, wxString::Format(
" Zoom factor: %f", zoom_scale ) );
virtual TIME_PT GetTimestamp()=0
std::chrono::time_point< CLOCK > TIME_PT
The default timeout, after which a another scroll will not be accelerated.
std::chrono::milliseconds TIMEOUT
The clock used for the timestamp (guaranteed to be monotonic).
static constexpr TIMEOUT DEFAULT_TIMEOUT
The default minimum step factor for accelerating controller.
TIME_PT m_prevTimestamp
The timeout value.
bool m_prevRotationPositive
Previous rotation was positive.
double m_scale
A multiplier for the minimum zoom step size.
TIMESTAMP_PROVIDER * m_timestampProv
< The timestamp provider to use (might be provided externally).
double GetScaleForRotation(int aRotation) override
Get the scale factor produced by a given mousewheel rotation.
ACCELERATING_ZOOM_CONTROLLER(double aScale=DEFAULT_ACCELERATION_SCALE, const TIMEOUT &aAccTimeout=DEFAULT_TIMEOUT, TIMESTAMP_PROVIDER *aTimestampProv=nullptr)
std::unique_ptr< TIMESTAMP_PROVIDER > m_ownTimestampProv
The timestamp of the previous event.
double GetScaleForRotation(int aRotation) override
A suitable (magic) scale factor for GTK3 systems.
double m_scale
< The scale factor set by the constructor.
CONSTANT_ZOOM_CONTROLLER(double aScale)
static constexpr double MSW_SCALE
A suitable (magic) scale factor for Windows systems.
A very simple timestamper that uses the KIGFX::ACCELERATING_ZOOM_CONTROLLER::CLOCK to provide a times...
ACCELERATING_ZOOM_CONTROLLER::TIME_PT GetTimestamp() override
const wxChar *const traceZoomScroll
Flag to enable debug output of zoom-scrolling calculations in KIGFX::ZOOM_CONTROLLER and derivatives.
The Cairo implementation of the graphics abstraction layer.
wxLogTrace helper definitions.
ZOOM_CONTROLLER class definition.