Replace tLimit() with qBound() and remove templates.h (#5040)
* Replace tLimit() with qBound() * Remove templates.h
This commit is contained in:
@@ -39,7 +39,6 @@
|
||||
#include <math.h>
|
||||
|
||||
#include "lmms_basics.h"
|
||||
#include "templates.h"
|
||||
#include "lmms_constants.h"
|
||||
#include "interpolation.h"
|
||||
#include "MemoryManager.h"
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include "Engine.h"
|
||||
#include "Model.h"
|
||||
#include "JournallingObject.h"
|
||||
#include "templates.h"
|
||||
#include "ValueBuffer.h"
|
||||
|
||||
class ControllerDialog;
|
||||
@@ -112,7 +111,7 @@ public:
|
||||
|
||||
inline static float fittedValue( float _val )
|
||||
{
|
||||
return tLimit<float>( _val, 0.0f, 1.0f );
|
||||
return qBound<float>( 0.0f, _val, 1.0f );
|
||||
}
|
||||
|
||||
static long runningPeriods()
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#define DSP_EFFECT_LIBRARY_H
|
||||
|
||||
#include "lmms_math.h"
|
||||
#include "templates.h"
|
||||
#include "lmms_constants.h"
|
||||
#include "lmms_basics.h"
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include <QtCore/QPoint>
|
||||
|
||||
#include "AutomatableModelView.h"
|
||||
#include "templates.h"
|
||||
|
||||
|
||||
class QPixmap;
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
|
||||
#include "lmms_basics.h"
|
||||
#include "volume.h"
|
||||
#include "templates.h"
|
||||
#include "panning_constants.h"
|
||||
#include "Midi.h"
|
||||
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* templates.h - miscellanous templates and algorithms
|
||||
*
|
||||
* Copyright (c) 2004-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of LMMS - https://lmms.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this program (see COPYING); if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TEMPLATES_H
|
||||
#define TEMPLATES_H
|
||||
|
||||
#include <QtCore/QtAlgorithms>
|
||||
|
||||
|
||||
template<class T>
|
||||
inline T tLimit( const T x, const T x1, const T x2 )
|
||||
{
|
||||
return qBound( x1, x, x2 );
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -36,7 +36,6 @@
|
||||
#include "NotePlayHandle.h"
|
||||
#include "Oscillator.h"
|
||||
#include "PixmapButton.h"
|
||||
#include "templates.h"
|
||||
#include "ToolTip.h"
|
||||
#include "Song.h"
|
||||
#include "interpolation.h"
|
||||
|
||||
@@ -41,7 +41,6 @@
|
||||
#include "NotePlayHandle.h"
|
||||
#include "Oscillator.h"
|
||||
#include "PixmapButton.h"
|
||||
#include "templates.h"
|
||||
#include "ToolTip.h"
|
||||
#include "BandLimitedWave.h"
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include "Monstro.h"
|
||||
#include "Engine.h"
|
||||
#include "InstrumentTrack.h"
|
||||
#include "templates.h"
|
||||
#include "gui_templates.h"
|
||||
#include "ToolTip.h"
|
||||
#include "Song.h"
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include "Nes.h"
|
||||
#include "Engine.h"
|
||||
#include "InstrumentTrack.h"
|
||||
#include "templates.h"
|
||||
#include "ToolTip.h"
|
||||
#include "Song.h"
|
||||
#include "lmms_math.h"
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
#include "NotePlayHandle.h"
|
||||
#include "Oscillator.h"
|
||||
#include "PixmapButton.h"
|
||||
#include "templates.h"
|
||||
#include "ToolTip.h"
|
||||
|
||||
#include "embed.h"
|
||||
|
||||
@@ -45,7 +45,6 @@ float frnd(float range)
|
||||
#include "Knob.h"
|
||||
#include "NotePlayHandle.h"
|
||||
#include "PixmapButton.h"
|
||||
#include "templates.h"
|
||||
#include "ToolTip.h"
|
||||
#include "Song.h"
|
||||
#include "MidiEvent.h"
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include "CaptionMenu.h"
|
||||
#include "Oscillator.h"
|
||||
#include "string_container.h"
|
||||
#include "templates.h"
|
||||
#include "volume.h"
|
||||
#include "Song.h"
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include <math.h>
|
||||
|
||||
#include "vibrating_string.h"
|
||||
#include "templates.h"
|
||||
#include "interpolation.h"
|
||||
#include "Mixer.h"
|
||||
#include "Engine.h"
|
||||
@@ -145,9 +144,9 @@ void vibratingString::resample( float *_src, f_cnt_t _src_frames,
|
||||
_dst_frames;
|
||||
const float frac_pos = src_frame_float -
|
||||
static_cast<f_cnt_t>( src_frame_float );
|
||||
const f_cnt_t src_frame = tLimit<f_cnt_t>(
|
||||
static_cast<f_cnt_t>( src_frame_float ),
|
||||
1, _src_frames - 3 );
|
||||
const f_cnt_t src_frame = qBound<f_cnt_t>(
|
||||
1, static_cast<f_cnt_t>( src_frame_float ),
|
||||
_src_frames - 3 );
|
||||
m_impulse[frame] = cubicInterpolate(
|
||||
_src[src_frame - 1],
|
||||
_src[src_frame + 0],
|
||||
|
||||
@@ -60,7 +60,6 @@
|
||||
#include "MainWindow.h"
|
||||
#include "Mixer.h"
|
||||
#include "Song.h"
|
||||
#include "templates.h"
|
||||
#include "FileDialog.h"
|
||||
|
||||
#ifdef LMMS_BUILD_LINUX
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include "base64.h"
|
||||
#include "Engine.h"
|
||||
#include "InstrumentTrack.h"
|
||||
#include "templates.h"
|
||||
#include "ToolTip.h"
|
||||
#include "Song.h"
|
||||
#include "lmms_math.h"
|
||||
|
||||
@@ -439,7 +439,7 @@ void AutomatableModel::setStep( const float step )
|
||||
|
||||
float AutomatableModel::fittedValue( float value ) const
|
||||
{
|
||||
value = tLimit<float>( value, m_minValue, m_maxValue );
|
||||
value = qBound<float>( m_minValue, value, m_maxValue );
|
||||
|
||||
if( m_step != 0 && m_hasStrictStepSize )
|
||||
{
|
||||
|
||||
@@ -936,7 +936,7 @@ void SampleBuffer::visualize( QPainter & _p, const QRect & _dr,
|
||||
const float y_space = h*0.5f;
|
||||
const int nb_frames = focus_on_range ? _to_frame - _from_frame : m_frames;
|
||||
|
||||
const int fpp = tLimit<int>( nb_frames / w, 1, 20 );
|
||||
const int fpp = qBound<int>( 1, nb_frames / w, 20 );
|
||||
QPointF * l = new QPointF[nb_frames / fpp + 1];
|
||||
QPointF * r = new QPointF[nb_frames / fpp + 1];
|
||||
int n = 0;
|
||||
|
||||
@@ -37,10 +37,10 @@
|
||||
|
||||
|
||||
AudioAlsa::AudioAlsa( bool & _success_ful, Mixer* _mixer ) :
|
||||
AudioDevice( tLimit<ch_cnt_t>(
|
||||
AudioDevice( qBound<ch_cnt_t>(
|
||||
DEFAULT_CHANNELS,
|
||||
ConfigManager::inst()->value( "audioalsa", "channels" ).toInt(),
|
||||
DEFAULT_CHANNELS, SURROUND_CHANNELS ),
|
||||
_mixer ),
|
||||
SURROUND_CHANNELS ), _mixer ),
|
||||
m_handle( NULL ),
|
||||
m_hwParams( NULL ),
|
||||
m_swParams( NULL ),
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
|
||||
#include "Engine.h"
|
||||
#include "GuiApplication.h"
|
||||
#include "templates.h"
|
||||
#include "gui_templates.h"
|
||||
#include "ConfigManager.h"
|
||||
#include "LcdSpinBox.h"
|
||||
@@ -44,10 +43,10 @@
|
||||
|
||||
|
||||
AudioJack::AudioJack( bool & _success_ful, Mixer* _mixer ) :
|
||||
AudioDevice( tLimit<int>( ConfigManager::inst()->value(
|
||||
"audiojack", "channels" ).toInt(),
|
||||
DEFAULT_CHANNELS, SURROUND_CHANNELS ),
|
||||
_mixer ),
|
||||
AudioDevice( qBound<int>(
|
||||
DEFAULT_CHANNELS,
|
||||
ConfigManager::inst()->value( "audiojack", "channels" ).toInt(),
|
||||
SURROUND_CHANNELS ), _mixer ),
|
||||
m_client( NULL ),
|
||||
m_active( false ),
|
||||
m_midiClient( NULL ),
|
||||
|
||||
@@ -69,10 +69,10 @@
|
||||
|
||||
|
||||
AudioOss::AudioOss( bool & _success_ful, Mixer* _mixer ) :
|
||||
AudioDevice( tLimit<ch_cnt_t>(
|
||||
AudioDevice( qBound<ch_cnt_t>(
|
||||
DEFAULT_CHANNELS,
|
||||
ConfigManager::inst()->value( "audiooss", "channels" ).toInt(),
|
||||
DEFAULT_CHANNELS, SURROUND_CHANNELS ),
|
||||
_mixer ),
|
||||
SURROUND_CHANNELS ), _mixer ),
|
||||
m_convertEndian( false )
|
||||
{
|
||||
_success_ful = false;
|
||||
|
||||
@@ -48,16 +48,15 @@ void AudioPortAudioSetupUtil::updateChannels()
|
||||
#include "Engine.h"
|
||||
#include "ConfigManager.h"
|
||||
#include "gui_templates.h"
|
||||
#include "templates.h"
|
||||
#include "ComboBox.h"
|
||||
#include "Mixer.h"
|
||||
|
||||
|
||||
AudioPortAudio::AudioPortAudio( bool & _success_ful, Mixer * _mixer ) :
|
||||
AudioDevice( tLimit<ch_cnt_t>(
|
||||
AudioDevice( qBound<ch_cnt_t>(
|
||||
DEFAULT_CHANNELS,
|
||||
ConfigManager::inst()->value( "audioportaudio", "channels" ).toInt(),
|
||||
DEFAULT_CHANNELS, SURROUND_CHANNELS ),
|
||||
_mixer ),
|
||||
SURROUND_CHANNELS ), _mixer ),
|
||||
m_paStream( NULL ),
|
||||
m_wasPAInitError( false ),
|
||||
m_outBuf( new surroundSampleFrame[mixer()->framesPerPeriod()] ),
|
||||
|
||||
@@ -45,10 +45,10 @@ static void stream_write_callback(pa_stream *s, size_t length, void *userdata)
|
||||
|
||||
|
||||
AudioPulseAudio::AudioPulseAudio( bool & _success_ful, Mixer* _mixer ) :
|
||||
AudioDevice( tLimit<ch_cnt_t>(
|
||||
AudioDevice( qBound<ch_cnt_t>(
|
||||
DEFAULT_CHANNELS,
|
||||
ConfigManager::inst()->value( "audiopa", "channels" ).toInt(),
|
||||
DEFAULT_CHANNELS, SURROUND_CHANNELS ),
|
||||
_mixer ),
|
||||
SURROUND_CHANNELS ), _mixer ),
|
||||
m_s( NULL ),
|
||||
m_quit( false ),
|
||||
m_convertEndian( false )
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
#include "Mixer.h"
|
||||
#include "Engine.h"
|
||||
#include "gui_templates.h"
|
||||
#include "templates.h"
|
||||
|
||||
#ifdef LMMS_HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
@@ -50,10 +49,11 @@
|
||||
|
||||
|
||||
AudioSndio::AudioSndio(bool & _success_ful, Mixer * _mixer) :
|
||||
AudioDevice( tLimit<ch_cnt_t>(
|
||||
ConfigManager::inst()->value( "audiosndio", "channels" ).toInt(),
|
||||
DEFAULT_CHANNELS, SURROUND_CHANNELS ), _mixer ),
|
||||
m_convertEndian ( false )
|
||||
AudioDevice( qBound<ch_cnt_t>(
|
||||
DEFAULT_CHANNELS,
|
||||
ConfigManager::inst()->value( "audiosndio", "channels" ).toInt(),
|
||||
SURROUND_CHANNELS ), _mixer ),
|
||||
m_convertEndian ( false )
|
||||
{
|
||||
_success_ful = false;
|
||||
|
||||
|
||||
@@ -33,14 +33,14 @@
|
||||
#include "debug.h"
|
||||
#include "ConfigManager.h"
|
||||
#include "gui_templates.h"
|
||||
#include "templates.h"
|
||||
#include "ComboBox.h"
|
||||
#include "Mixer.h"
|
||||
|
||||
AudioSoundIo::AudioSoundIo( bool & outSuccessful, Mixer * _mixer ) :
|
||||
AudioDevice( tLimit<ch_cnt_t>(
|
||||
ConfigManager::inst()->value( "audiosoundio", "channels" ).toInt(), DEFAULT_CHANNELS, SURROUND_CHANNELS ),
|
||||
_mixer )
|
||||
AudioDevice( qBound<ch_cnt_t>(
|
||||
DEFAULT_CHANNELS,
|
||||
ConfigManager::inst()->value( "audiosoundio", "channels" ).toInt(),
|
||||
SURROUND_CHANNELS ), _mixer )
|
||||
{
|
||||
outSuccessful = false;
|
||||
m_soundio = NULL;
|
||||
|
||||
@@ -355,7 +355,7 @@ int PianoView::getKeyFromMouse( const QPoint & _p ) const
|
||||
}
|
||||
|
||||
// some range-checking-stuff
|
||||
return tLimit( key_num, 0, NumKeys - 1 );
|
||||
return qBound( 0, key_num, NumKeys - 1 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
|
||||
#include "embed.h"
|
||||
#include "Engine.h"
|
||||
#include "templates.h"
|
||||
#include "gui_templates.h"
|
||||
#include "StringPairDrag.h"
|
||||
#include "PluginFactory.h"
|
||||
@@ -231,7 +230,7 @@ void PluginDescWidget::paintEvent( QPaintEvent * )
|
||||
style()->drawPrimitive( QStyle::PE_Widget, &o, &p, this );
|
||||
|
||||
// Draw the rest
|
||||
const int s = 16 + ( 32 * ( tLimit( height(), 24, 60 ) - 24 ) ) /
|
||||
const int s = 16 + ( 32 * ( qBound( 24, height(), 60 ) - 24 ) ) /
|
||||
( 60 - 24 );
|
||||
const QSize logo_size( s, s );
|
||||
QPixmap logo = m_logo.scaled( logo_size, Qt::KeepAspectRatio,
|
||||
|
||||
@@ -709,7 +709,7 @@ void PianoRoll::setCurrentPattern( Pattern* newPattern )
|
||||
{
|
||||
central_key = central_key / total_notes -
|
||||
( KeysPerOctave * NumOctaves - m_totalKeysToScroll ) / 2;
|
||||
m_startKey = tLimit( central_key, 0, NumOctaves * KeysPerOctave );
|
||||
m_startKey = qBound( 0, central_key, NumOctaves * KeysPerOctave );
|
||||
}
|
||||
|
||||
// resizeEvent() does the rest for us (scrolling, range-checking
|
||||
@@ -2215,9 +2215,9 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me )
|
||||
else if( m_action == ActionResizeNoteEditArea )
|
||||
{
|
||||
// change m_notesEditHeight and then repaint
|
||||
m_notesEditHeight = tLimit<int>(
|
||||
m_oldNotesEditHeight - ( me->y() - m_moveStartY ),
|
||||
m_notesEditHeight = qBound<int>(
|
||||
NOTE_EDIT_MIN_HEIGHT,
|
||||
m_oldNotesEditHeight - ( me->y() - m_moveStartY ),
|
||||
height() - PR_TOP_MARGIN - NOTE_EDIT_RESIZE_BAR -
|
||||
PR_BOTTOM_MARGIN - KEY_AREA_MIN_HEIGHT );
|
||||
|
||||
@@ -2299,16 +2299,18 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me )
|
||||
|
||||
if( me->buttons() & Qt::LeftButton )
|
||||
{
|
||||
vol = tLimit<int>( MinVolume +
|
||||
vol = qBound<int>( MinVolume,
|
||||
MinVolume +
|
||||
( ( (float)noteEditBottom() ) - ( (float)me->y() ) ) /
|
||||
( (float)( noteEditBottom() - noteEditTop() ) ) *
|
||||
( MaxVolume - MinVolume ),
|
||||
MinVolume, MaxVolume );
|
||||
pan = tLimit<int>( PanningLeft +
|
||||
MaxVolume );
|
||||
pan = qBound<int>( PanningLeft,
|
||||
PanningLeft +
|
||||
( (float)( noteEditBottom() - me->y() ) ) /
|
||||
( (float)( noteEditBottom() - noteEditTop() ) ) *
|
||||
( (float)( PanningRight - PanningLeft ) ),
|
||||
PanningLeft, PanningRight);
|
||||
PanningRight);
|
||||
}
|
||||
|
||||
if( m_noteEditMode == NoteEditVolume )
|
||||
@@ -3513,7 +3515,7 @@ void PianoRoll::wheelEvent(QWheelEvent * we )
|
||||
{
|
||||
for ( Note * n : nv )
|
||||
{
|
||||
volume_t vol = tLimit<int>( n->getVolume() + step, MinVolume, MaxVolume );
|
||||
volume_t vol = qBound<int>( MinVolume, n->getVolume() + step, MaxVolume );
|
||||
n->setVolume( vol );
|
||||
}
|
||||
bool allVolumesEqual = std::all_of( nv.begin(), nv.end(),
|
||||
@@ -3532,7 +3534,7 @@ void PianoRoll::wheelEvent(QWheelEvent * we )
|
||||
{
|
||||
for ( Note * n : nv )
|
||||
{
|
||||
panning_t pan = tLimit<int>( n->getPanning() + step, PanningLeft, PanningRight );
|
||||
panning_t pan = qBound<int>( PanningLeft, n->getPanning() + step, PanningRight );
|
||||
n->setPanning( pan );
|
||||
}
|
||||
bool allPansEqual = std::all_of( nv.begin(), nv.end(),
|
||||
|
||||
@@ -592,7 +592,7 @@ int InstrumentTrack::masterKey( int _midi_key ) const
|
||||
{
|
||||
|
||||
int key = baseNote();
|
||||
return tLimit<int>( _midi_key - ( key - DefaultKey ), 0, NumKeys );
|
||||
return qBound<int>( 0, _midi_key - ( key - DefaultKey ), NumKeys );
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user