|
Krotos Modules 3
|
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} |
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
| void krotos::ScrollAndZoomManager::drag | ( | int | diff | ) |
Move the zoom window side to side by specifying an offset in samples.
| int krotos::ScrollAndZoomManager::getLength | ( | ) |
Return the overall length of the buffer.
| Range< float > krotos::ScrollAndZoomManager::getZoomWindowNormalisedToLimits | ( | ) |
Get the current range of the zoom window, normalised to the zoom limits (the entire buffer).
| Range< float > krotos::ScrollAndZoomManager::getZoomWindowNormalisedToRange | ( | ) |
Get the current range of the zoom window, normalised to the zoom range.
| Range< int > krotos::ScrollAndZoomManager::getZoomWindowRelativeToRange | ( | ) |
Get the current range of the zoom window, relative to the zoom range.
| void krotos::ScrollAndZoomManager::initialise | ( | int | length | ) |
Initialse the class using the length of the buffer we wish to navigate.
| bool krotos::ScrollAndZoomManager::isSelectionEnabled | ( | ) |
Return a bool indicating whether or not waveform range selection is enabled.
| bool krotos::ScrollAndZoomManager::isZoomScrollEnabled | ( | ) |
Return a bool indicating whether or not waveform zooming and scrolling is enabled.
| int krotos::ScrollAndZoomManager::percentMouseXToSampleXAbsolute | ( | float | percentX | ) |
Convert a normalised position within the zoom window into an absolute sample position.
| int krotos::ScrollAndZoomManager::percentMouseXToSampleXRelative | ( | float | percentX | ) |
Convert a normalised position within the zoom window into a sample position relative to the zoom window.
| int krotos::ScrollAndZoomManager::pixelsToSamples | ( | int | pixels, |
| int | waveformScreenWidth ) |
Convert a size in pixels to the equivalent in buffer samples.
| void krotos::ScrollAndZoomManager::repositionZoomWindow | ( | float | newStart | ) |
Move the zoom window by specifying a new normalised start position.
| void krotos::ScrollAndZoomManager::resetZoomRange | ( | ) |
Zoom fully out so the zoom window sees the entire buffer.
| void krotos::ScrollAndZoomManager::setSelectionEnabled | ( | bool | newState | ) |
Set whether or not we require waveform range selection to be enabled.
| void krotos::ScrollAndZoomManager::setZoomRange | ( | Range< int > | newRange | ) |
Sets the zoom to a specific range.
| newRange | The range to set the zoom to. |
| void krotos::ScrollAndZoomManager::setZoomScrollEnabled | ( | bool | newState | ) |
Set whether or not we require waveform zooming and scrolling to be enabled.
| void krotos::ScrollAndZoomManager::zoom | ( | int | center, |
| float | amount ) |
Zoom by a specified fractional amount, centered around a specified buffer position in samples.
|
private |
|
private |
|
private |
|
private |
The range of the entire sound buffer, always starts at zero.
|
private |
The range we wish to be able to zoom and scroll within.
|
private |
|
private |
The zoomed and scrolled window into the buffer.