Krotos Modules 3
Loading...
Searching...
No Matches
krotos::ScrollAndZoomManager Class Reference

A class containing the logic to zoom and scroll within a timeline. More...

#include <HelperClasses.h>

Public Member Functions

void initialise (int length)
 
int getLength ()
 
void resetZoomRange ()
 
Range< float > getZoomWindowNormalisedToLimits ()
 
Range< int > getZoomWindowRelativeToRange ()
 
Range< float > getZoomWindowNormalisedToRange ()
 
void repositionZoomWindow (float newStart)
 
void zoom (int center, float amount)
 
void drag (int diff)
 
int percentMouseXToSampleXAbsolute (float percentX)
 
int percentMouseXToSampleXRelative (float percentX)
 
int pixelsToSamples (int pixels, int waveformScreenWidth)
 
bool isSelectionEnabled ()
 
bool isZoomScrollEnabled ()
 
void setZoomScrollEnabled (bool newState)
 
void setSelectionEnabled (bool newState)
 
void setZoomRange (Range< int > newRange)
 Sets the zoom to a specific range.
 

Private Attributes

Range< int > m_zoomLimits
 
Range< int > m_zoomRange
 
Range< int > m_zoomWindow
 
bool m_selectionEnabled {true}
 
bool m_zoomScrollEnabled {true}
 
const int m_minimumLength {32}
 
int m_length {0}
 

Detailed Description

A class containing the logic to zoom and scroll within a timeline.

Note, all zooming scrolling and associated range contraints are performed at an integer audio sample index level of precision. Performing these operations at a screen pixel level of accuracy would not work due to the fact that the waveform viewer may be showing a waveform which has many thousands of samples within the width of a single on-screen pixel, and the mouse moves in screen pixel increments. This accounts for the fact that the code contains a lot of casting between floats and ints, and is sometimes working in screen pixels, sometimes in sample indexes.

zoomLimits; // The range of the entire sound buffer, always starts at zero zoomRange; // The range we wish to be able to zoom and scroll within zoomWindow; // The zoomed and scrolled window into the buffer

Member Function Documentation

◆ drag()

void krotos::ScrollAndZoomManager::drag ( int diff)

Move the zoom window side to side by specifying an offset in samples.

◆ getLength()

int krotos::ScrollAndZoomManager::getLength ( )

Return the overall length of the buffer.

◆ getZoomWindowNormalisedToLimits()

Range< float > krotos::ScrollAndZoomManager::getZoomWindowNormalisedToLimits ( )

Get the current range of the zoom window, normalised to the zoom limits (the entire buffer).

◆ getZoomWindowNormalisedToRange()

Range< float > krotos::ScrollAndZoomManager::getZoomWindowNormalisedToRange ( )

Get the current range of the zoom window, normalised to the zoom range.

◆ getZoomWindowRelativeToRange()

Range< int > krotos::ScrollAndZoomManager::getZoomWindowRelativeToRange ( )

Get the current range of the zoom window, relative to the zoom range.

◆ initialise()

void krotos::ScrollAndZoomManager::initialise ( int length)

Initialse the class using the length of the buffer we wish to navigate.

◆ isSelectionEnabled()

bool krotos::ScrollAndZoomManager::isSelectionEnabled ( )

Return a bool indicating whether or not waveform range selection is enabled.

◆ isZoomScrollEnabled()

bool krotos::ScrollAndZoomManager::isZoomScrollEnabled ( )

Return a bool indicating whether or not waveform zooming and scrolling is enabled.

◆ percentMouseXToSampleXAbsolute()

int krotos::ScrollAndZoomManager::percentMouseXToSampleXAbsolute ( float percentX)

Convert a normalised position within the zoom window into an absolute sample position.

◆ percentMouseXToSampleXRelative()

int krotos::ScrollAndZoomManager::percentMouseXToSampleXRelative ( float percentX)

Convert a normalised position within the zoom window into a sample position relative to the zoom window.

◆ pixelsToSamples()

int krotos::ScrollAndZoomManager::pixelsToSamples ( int pixels,
int waveformScreenWidth )

Convert a size in pixels to the equivalent in buffer samples.

◆ repositionZoomWindow()

void krotos::ScrollAndZoomManager::repositionZoomWindow ( float newStart)

Move the zoom window by specifying a new normalised start position.

◆ resetZoomRange()

void krotos::ScrollAndZoomManager::resetZoomRange ( )

Zoom fully out so the zoom window sees the entire buffer.

◆ setSelectionEnabled()

void krotos::ScrollAndZoomManager::setSelectionEnabled ( bool newState)

Set whether or not we require waveform range selection to be enabled.

◆ setZoomRange()

void krotos::ScrollAndZoomManager::setZoomRange ( Range< int > newRange)

Sets the zoom to a specific range.

Parameters
newRangeThe range to set the zoom to.

◆ setZoomScrollEnabled()

void krotos::ScrollAndZoomManager::setZoomScrollEnabled ( bool newState)

Set whether or not we require waveform zooming and scrolling to be enabled.

◆ zoom()

void krotos::ScrollAndZoomManager::zoom ( int center,
float amount )

Zoom by a specified fractional amount, centered around a specified buffer position in samples.

Member Data Documentation

◆ m_length

int krotos::ScrollAndZoomManager::m_length {0}
private

◆ m_minimumLength

const int krotos::ScrollAndZoomManager::m_minimumLength {32}
private

◆ m_selectionEnabled

bool krotos::ScrollAndZoomManager::m_selectionEnabled {true}
private

◆ m_zoomLimits

Range<int> krotos::ScrollAndZoomManager::m_zoomLimits
private

The range of the entire sound buffer, always starts at zero.

◆ m_zoomRange

Range<int> krotos::ScrollAndZoomManager::m_zoomRange
private

The range we wish to be able to zoom and scroll within.

◆ m_zoomScrollEnabled

bool krotos::ScrollAndZoomManager::m_zoomScrollEnabled {true}
private

◆ m_zoomWindow

Range<int> krotos::ScrollAndZoomManager::m_zoomWindow
private

The zoomed and scrolled window into the buffer.


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