KiCad PCB EDA Suite
Loading...
Searching...
No Matches
KIGFX::ACCELERATING_ZOOM_CONTROLLER Class Reference

Class that zooms faster if scroll events happen very close together. More...

#include <zoom_controller.h>

Inheritance diagram for KIGFX::ACCELERATING_ZOOM_CONTROLLER:
KIGFX::ZOOM_CONTROLLER

Classes

class  TIMESTAMP_PROVIDER
 

Public Types

using TIMEOUT = std::chrono::milliseconds
 The clock used for the timestamp (guaranteed to be monotonic). More...
 
using CLOCK = std::chrono::steady_clock
 The type of the time stamps. More...
 
using TIME_PT = std::chrono::time_point< CLOCK >
 The default timeout, after which a another scroll will not be accelerated. More...
 

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. More...
 
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. More...
 
static constexpr double DEFAULT_ACCELERATION_SCALE = 5.0
 

Private Attributes

TIMESTAMP_PROVIDERm_timestampProv
 < The timestamp provider to use (might be provided externally). More...
 
std::unique_ptr< TIMESTAMP_PROVIDERm_ownTimestampProv
 The timestamp of the previous event. More...
 
TIME_PT m_prevTimestamp
 The timeout value. More...
 
TIMEOUT m_accTimeout
 
bool m_prevRotationPositive = false
 Previous rotation was positive. More...
 
double m_scale
 A multiplier for the minimum zoom step size. More...
 

Detailed Description

Class that zooms faster if scroll events happen very close together.

Definition at line 62 of file zoom_controller.h.

Member Typedef Documentation

◆ CLOCK

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.

◆ TIME_PT

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.

◆ TIMEOUT

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.

Constructor & Destructor Documentation

◆ ACCELERATING_ZOOM_CONTROLLER()

ACCELERATING_ZOOM_CONTROLLER::ACCELERATING_ZOOM_CONTROLLER ( double  aScale = DEFAULT_ACCELERATION_SCALE,
const TIMEOUT aAccTimeout = DEFAULT_TIMEOUT,
TIMESTAMP_PROVIDER aTimestampProv = nullptr 
)
Parameters
aAccTimeoutthe timeout - if a scroll happens within this timeframe, the zoom will be faster
aTimestampProva 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.

Member Function Documentation

◆ GetScaleForRotation()

double ACCELERATING_ZOOM_CONTROLLER::GetScaleForRotation ( int  aRotation)
overridevirtual

Get the scale factor produced by a given mousewheel rotation.

Parameters
aRotationrotation of the mouse wheel (this comes from wxMouseEvent::GetWheelRotation()).
Returns
the scale factor to scroll by.

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().

◆ GetTimeout()

TIMEOUT KIGFX::ACCELERATING_ZOOM_CONTROLLER::GetTimeout ( ) const
inline

Definition at line 107 of file zoom_controller.h.

◆ SetTimeout()

void KIGFX::ACCELERATING_ZOOM_CONTROLLER::SetTimeout ( const TIMEOUT aNewTimeout)
inline

Definition at line 112 of file zoom_controller.h.

Member Data Documentation

◆ DEFAULT_ACCELERATION_SCALE

constexpr double KIGFX::ACCELERATING_ZOOM_CONTROLLER::DEFAULT_ACCELERATION_SCALE = 5.0
staticconstexpr

Definition at line 78 of file zoom_controller.h.

Referenced by BOOST_AUTO_TEST_CASE().

◆ DEFAULT_TIMEOUT

constexpr TIMEOUT KIGFX::ACCELERATING_ZOOM_CONTROLLER::DEFAULT_TIMEOUT = std::chrono::milliseconds( 500 )
staticconstexpr

The default minimum step factor for accelerating controller.

Definition at line 75 of file zoom_controller.h.

◆ m_accTimeout

TIMEOUT KIGFX::ACCELERATING_ZOOM_CONTROLLER::m_accTimeout
private

Definition at line 128 of file zoom_controller.h.

Referenced by GetScaleForRotation().

◆ m_ownTimestampProv

std::unique_ptr<TIMESTAMP_PROVIDER> KIGFX::ACCELERATING_ZOOM_CONTROLLER::m_ownTimestampProv
private

The timestamp of the previous event.

Definition at line 122 of file zoom_controller.h.

Referenced by ACCELERATING_ZOOM_CONTROLLER().

◆ m_prevRotationPositive

bool KIGFX::ACCELERATING_ZOOM_CONTROLLER::m_prevRotationPositive = false
private

Previous rotation was positive.

Definition at line 131 of file zoom_controller.h.

Referenced by GetScaleForRotation().

◆ m_prevTimestamp

TIME_PT KIGFX::ACCELERATING_ZOOM_CONTROLLER::m_prevTimestamp
private

The timeout value.

Definition at line 125 of file zoom_controller.h.

Referenced by ACCELERATING_ZOOM_CONTROLLER(), and GetScaleForRotation().

◆ m_scale

double KIGFX::ACCELERATING_ZOOM_CONTROLLER::m_scale
private

A multiplier for the minimum zoom step size.

Definition at line 134 of file zoom_controller.h.

Referenced by GetScaleForRotation().

◆ m_timestampProv

TIMESTAMP_PROVIDER* KIGFX::ACCELERATING_ZOOM_CONTROLLER::m_timestampProv
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().


The documentation for this class was generated from the following files: