KiCad PCB EDA Suite
|
Class that zooms faster if scroll events happen very close together. More...
#include <zoom_controller.h>
Classes | |
class | TIMESTAMP_PROVIDER |
Public Types | |
using | TIMEOUT = std::chrono::milliseconds |
The clock used for the timestamp (guaranteed to be monotonic). | |
using | CLOCK = std::chrono::steady_clock |
The type of the time stamps. | |
using | TIME_PT = std::chrono::time_point< CLOCK > |
The default timeout, after which a another scroll will not be accelerated. | |
Public Member Functions | |
ACCELERATING_ZOOM_CONTROLLER (double aScale=DEFAULT_ACCELERATION_SCALE, const TIMEOUT &aAccTimeout=DEFAULT_TIMEOUT, TIMESTAMP_PROVIDER *aTimestampProv=nullptr) | |
double | GetScaleForRotation (int aRotation) override |
Get the scale factor produced by a given mousewheel rotation. | |
TIMEOUT | GetTimeout () const |
void | SetTimeout (const TIMEOUT &aNewTimeout) |
Static Public Attributes | |
static constexpr TIMEOUT | DEFAULT_TIMEOUT = std::chrono::milliseconds( 500 ) |
The default minimum step factor for accelerating controller. | |
static constexpr double | DEFAULT_ACCELERATION_SCALE = 5.0 |
Private Attributes | |
TIMESTAMP_PROVIDER * | m_timestampProv |
< The timestamp provider to use (might be provided externally). | |
std::unique_ptr< TIMESTAMP_PROVIDER > | m_ownTimestampProv |
The timestamp of the previous event. | |
TIME_PT | m_prevTimestamp |
The timeout value. | |
TIMEOUT | m_accTimeout |
bool | m_prevRotationPositive = false |
Previous rotation was positive. | |
double | m_scale |
A multiplier for the minimum zoom step size. | |
Class that zooms faster if scroll events happen very close together.
Definition at line 62 of file zoom_controller.h.
using KIGFX::ACCELERATING_ZOOM_CONTROLLER::CLOCK = std::chrono::steady_clock |
The type of the time stamps.
Definition at line 69 of file zoom_controller.h.
using KIGFX::ACCELERATING_ZOOM_CONTROLLER::TIME_PT = std::chrono::time_point<CLOCK> |
The default timeout, after which a another scroll will not be accelerated.
Definition at line 72 of file zoom_controller.h.
using KIGFX::ACCELERATING_ZOOM_CONTROLLER::TIMEOUT = std::chrono::milliseconds |
The clock used for the timestamp (guaranteed to be monotonic).
Definition at line 66 of file zoom_controller.h.
ACCELERATING_ZOOM_CONTROLLER::ACCELERATING_ZOOM_CONTROLLER | ( | double | aScale = DEFAULT_ACCELERATION_SCALE , |
const TIMEOUT & | aAccTimeout = DEFAULT_TIMEOUT , |
||
TIMESTAMP_PROVIDER * | aTimestampProv = nullptr |
||
) |
aAccTimeout | the timeout - if a scroll happens within this timeframe, the zoom will be faster |
aTimestampProv | a provider for timestamps. If null, a default will be provided, which is the main steady_clock (this is probably what you want for real usage) |
Definition at line 54 of file zoom_controller.cpp.
References KIGFX::ACCELERATING_ZOOM_CONTROLLER::TIMESTAMP_PROVIDER::GetTimestamp(), m_ownTimestampProv, m_prevTimestamp, and m_timestampProv.
|
overridevirtual |
Get the scale factor produced by a given mousewheel rotation.
aRotation | rotation of the mouse wheel (this comes from wxMouseEvent::GetWheelRotation()). |
Implements KIGFX::ZOOM_CONTROLLER.
Definition at line 73 of file zoom_controller.cpp.
References KIGFX::ACCELERATING_ZOOM_CONTROLLER::TIMESTAMP_PROVIDER::GetTimestamp(), m_accTimeout, m_prevRotationPositive, m_prevTimestamp, m_scale, m_timestampProv, and traceZoomScroll.
Referenced by BOOST_AUTO_TEST_CASE().
|
inline |
Definition at line 107 of file zoom_controller.h.
|
inline |
Definition at line 112 of file zoom_controller.h.
|
staticconstexpr |
Definition at line 78 of file zoom_controller.h.
Referenced by BOOST_AUTO_TEST_CASE().
|
staticconstexpr |
The default minimum step factor for accelerating controller.
Definition at line 75 of file zoom_controller.h.
|
private |
Definition at line 128 of file zoom_controller.h.
Referenced by GetScaleForRotation().
|
private |
The timestamp of the previous event.
Definition at line 122 of file zoom_controller.h.
Referenced by ACCELERATING_ZOOM_CONTROLLER().
|
private |
Previous rotation was positive.
Definition at line 131 of file zoom_controller.h.
Referenced by GetScaleForRotation().
|
private |
The timeout value.
Definition at line 125 of file zoom_controller.h.
Referenced by ACCELERATING_ZOOM_CONTROLLER(), and GetScaleForRotation().
|
private |
A multiplier for the minimum zoom step size.
Definition at line 134 of file zoom_controller.h.
Referenced by GetScaleForRotation().
|
private |
< The timestamp provider to use (might be provided externally).
Any provider owned by this class (the default one, if used).
Definition at line 119 of file zoom_controller.h.
Referenced by ACCELERATING_ZOOM_CONTROLLER(), and GetScaleForRotation().