mirror of
https://github.com/LMMS/lmms.git
synced 2026-01-22 21:38:12 -05:00
master
17 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
71ce49d7ba |
Remove lots of useless/misplaced includes (#7999)
Follow-Up of
|
||
|
|
b6d6509068 |
Individual knob labels rendered using the widget's font size (#7525)
Adjust the `Knob` class so that it defaults to taking the font size of
the knob's font into account when rendering its label. This allows to
use labels of different sizes for different knobs. Previously all knob
labels throughout the whole application were rendered with the same fixed
font size. Hence it was not possible to adjust the label size for a
single knob because this would have affected all other knobs as well.
The new implementation also allows the knobs to pick up CSS rules.
To be able to control the knob behavior two new constructors have been
added to the `Knob` class. Both constructors are concerned with creating
knobs with labels and therefore they directly take the label text as a
parameter. This removes numerous explicit calls to `setLabel` in the
code.
There is only one constructor that allows to switch between the new
behavior of taking the widget's font size into account and the old legacy
behavior of always rendering with the same fixed font size of
`SMALL_FONT_SIZE`. The parameter was modelled as an enum to make it
easier to find the remaining knob instances that use the legacy behavior.
This makes it easier to find them in case they should be removed as well.
In that case the string `LegacyFixedFontSize` can be searched.
The other new constructor allows to directly set the knob's (and
therefore the label's) font size to a pixel value.
Corresponding constructors have been added to `TempoSyncKnob`. The
constructors of `KnobControl` and `CustomTextKnob` have been adjusted to
take advantage of the new constructors. An usused constructor was removed
in `CustomTextKnob`.
The method `Knob::setLabel` has been made protected because labels should
now be set through the new constructors.
A new property called `m_fixedFontSizeLabelRendering` was added to the
`Knob` class. It controls how the labels are rendered. Fixed font size
legacy rendering can be activated by calling the protected method
`setFixedFontSizeLabelRendering`. The current setting can be queried via
`fixedFontSizeLabelRendering`.
## Changes in the plugins
Some plugins have been switched to using layouts to organize their
widgets so that they can accommodate for knobs with label sizes set by
the application font.
The fixed font size (legacy) rendering mode is still used in the
following places:
* EnvelopeAndLfoView
* InstrumentSoundShapingView
* InstrumentFunctionViews
* EffectView
* InstrumentTrackView
* SampleTrackView
* Delay plugin
* Carla plugin
# individual commit messages
What follows are the individual commit messages of the commits that have been squashed into one commit. They might help in case of more detailed investigations of how things came to be.
* Knob with correct label rendering
Enable the knob to render the label correctly at arbitrary sizes if it's configured to do so. Otherwise it will render like before. The used mode is determined when a label is set for the knob because as long as the label is not set a knob does not have one anyway.
The painting code now always renders the label with the font that's set for the widget.
The are now two methods to set the label text. The new method `setLabelLegacy` renders the label as before albeit in a slightly adjusted implementation. It now sets the widget font to a fixed pixel size font and then calculates the new widget size as before, i.e. not really taking the size of the font into account. This might lead to overlaps if the font of the knob is large.
The method `setLabel` now has an additional (temporary) parameter called `legacyMode`. It is by default set to `true` so that all knobs still render like they did before. This is implemented by delegating to `setLabelLegacy` if it's set to `true`. Otherwise the method calculates the new size of the widget by taking the pixmap and the label with the current font into account.
Please note that as of now you must set the knob font before calling any of the methods that sets the label. This is because the new size is only calculated via these code paths. However, this is already much better than only being able to use one hard-coded label size for all knobs.
* Switch from `setLabel` to `setLabelLegacy`
Switch all callers of `setLabel` to `setLabelLegacy` so that it becomes
obvious in which places the old knob implementation is used.
* Remove parameter `legacyMode` from `setLabel`
Remove the parameter `legacyMode` from `setLabel`. Add the member
`m_legacyMode` as it is needed in `Knob::changeEvent` so that we do not
switch the behavior when the knob is enabled/disabled.
* Extract methods
Extract `setLegacyMode` and `updateFixedSize`. Also add the getter `legacyMode`.
* Introduce legacy knob builders
Introduce legacy knob builders and apply them to the plugins. There are three new methods which encapsulate how to create a corresponding legacy knob:
* `Knob::buildLegacyKnob`
* `CustomTextKnob::buildLegacyKnob`
* `TempoSyncKnob::buildLegacyKnob`
These methods set the knob they build to legacy mode and also set a label in legacy mode. The idea is to concentrate the relevant legacy code in these methods. They will later also be useful to quickly find all the places in the application where legacy knobs are used.
The three methods are applied to the plugins directory. Most plugins use the build methods to build their knobs which also enables the removal of the explicit calls to `setLabelLegacy` from their code.
For some plugins their implementations were adjusted so that they can deal with showing the labels in the applicaiton font, i.e. in the font size of the widget their are contained in. Most of the times this involved removing the fixed size and putting the elements in a layout (while also removing move calls). The following LMMS plugins use the application font now and are thus better readable:
* Amplifier
* BassBooster
* Dispersion
* Flanger
* Peak Controller
* ReverbSC
* StereoEnhancer Effect
The Vectorscope now shows the "Persist." label in the same size as the label of the check boxes.
Setting an empty label was removed for Lb302.
* Legacy knob builders in GUI
Apply the legacy knob builders in the GUI components. Most components use the legacy knobs until they can be redesigned:
* Effect view ("W/D", "DECAY", "GATE")
* LFO Controller
* Instrument window
Everything related to the instrument window is for now kept to use the legacy knobs and should be adjusted at a later point to be more flexible:
* Envelope and LFO
* Functions
* Sound Shaping
The Instrument and sample track both use the legacy knobs for the "VOL" and "PAN" knobs. This might be adjusted later.
The following components now render the labels of their knobs with the application font size:
* MIDI CC Rack
* The class `LadspaControlView`, which is not in used anymore
Some vertical spacing was added to the MIDI CC Rack for slightly improved separation of the elements. The knobs are center aligned in the layout so that the transition between element under and over "CC 100" is cleaner. Setting the models in an explicit loop was removed and is now done when the knobs are created.
## Technical details
Extend `Knob::buildLegacyKnob` with the option to also set the name of the knob. This is needed for some changes in this PR.
The method `KnobControl::setText` now needs to distinguish between legacy mode and non-legacy mode.
* Remove `Knob::setLabelLegacy`
Remove `Knob::setLabelLegacy`. Instead make sure that the `Knob` updates its size in the following situations:
* The label is set.
* The font changes.
* Legacy mode is set or unset (already implemented).
The handling of font changes has been added to `Knob::changeEvent`. The update in case of a changed label is added to `Knob::setLabel`.
Every client that called `setLabelLegacy` now also sets the legacy font in size `SMALL_FONT_SIZE` as this was previously done in `setLabelLegacy`. The label is set via `setLabel` now. Both actions should result in an up-to-date size.
The method `KnobControl::setText` now only sets the label via `setLabel`, assuming that the wrapped knob was already configured correctly to either be a legacy knob or not.
* Use descent to calculate base line
Use the descent of the font to calculate the distance of the base line from the bottom of the knob widget if we are not in legacy mode. In legacy mode we still assume the descent to have a value of 2, i.e. the base line will always have a distance of 2 from the bottom of the knob widget regardless of the used font.
Also refactor the code a bit to make it more manageable.
* Extract `Knob::drawLabel`
Extract the method `Knob::drawLabel` which draws the label. It is called from `paintEvent`.
* Use non-legacy knobs for instrument and sample track
Use non-legacy knobs for the "VOL" and "PAN" knobs of the instrument and sample track. This gives a bit more separation between the knob and the label but to make this work the font size had to be decreased by one pixel.
* Introduce `buildKnobWithSmallPixelFont`
Introduce the builder method `buildKnobWithSmallPixelFont` in `Knob` and `TempoSyncKnob`. It creates a non-legacy knob with a small pixel sized font, i.e. it still uses the small font but with a corrected size computation and corrected space between the knob and the label. It is mostly used in places with manual layouts where there's enough space to have the bit of extra space between the knob and the label.
The following plugins use these knobs:
* Bitcrush
* Crossover EQ
* Dual Filter
* Dynamics Processor
* Multitap Echo
* Spectrum analyzer
* Mallets
* Waveshaper
* ZynAddSubFx
The "IN" and "OUT" label of the Bitcrush plugin use the default fixed font size now because the plugin uses a pixel based layout. Using the point based application font looked off.
They are also used in the following component:
* Effect view, i.e. the "W/D", "DECAY", "GATE" knobs of an effect
* LFO Controller
* Non-legacy knobs for VSTs
Use non-legacy knobs with small pixel fonts for the parameter lists of VST instruments and effects.
This is accomplished by renaming `CustomTextKnob::buildLegacyKnob` to `buildKnobWithSmallPixelFont` and removing the call to `setLegacyMode`.
* Fix styled knobs
Fix the handling of styled knobs which are created in non-legacy mode. Styled knobs do not use pixmaps and have no labels. Their size is set from the outside and they are painted within these limits. Hence we should not compute a new size from a pixmap and/or label in `Knob::updateFixedSize`.
This fixes the following plugins:
* FreeBoy
* Kicker
* Monstro
* Nescaline
* Opulenz
* Organic
* Sf2 Player
* sfxr
* SID
* SlicerT
* Triple
* Watsyn
* Xpressive
The functionality broke with commit defa8c0180e.
An alternative would have been to check for a styled knob in the contructor or `initUI` method and to set the legacy flag for these.
The best solution would likely be to create an own class for styled knobs and to pull that functionality out of `Knob` because they somewhat clash in their handling.
* Code review changes
Parameter whitespaces in the builder methods of `Knob`.
Use `adjustedToPixelSize` in `InstrumentTrackView` and `SampleTrackView`.
* Code review changes
Make the code that computes the new fixed size in legacy more readable
even if it is just legacy code that's was not touched. Add some code
documentation.
Other cosmetic changes:
* Whitespace adjustments
* Remove unused parameter in `paintEvent`
* Rename `knob_num` to `knobNum`
* Add documentation for legacy mode
Add some documentation which explains what the effects of legacy mode
are.
* Code review
Remove unnecessary dereference.
Also remove unncessary code repetition by introducing
`currentParamModel`.
* Decrease the label size of some knobs
Decrease the size of the following knob labels to 8 pixels:
* "VOL" and "PAN" in the instrument and sample track views
* "W/D", "DECAY" and "GATE" in the effect view
Technically this is accomplished by introducing
`Knob::buildKnobWithFixedPixelFont` and
`TempoSyncKnob::buildKnobWithFixedPixelFont`.
Both versions of `buildKnobWithSmallPixelFont` now also delegate to
the new methods.
* Adjustments to CrossoverEQControlDialog
Commit the adjustments that were done to `CrossoverEQControlDialog` which I had forgotten to add after fixing the merge.
* Fix formatting of CrossoverEQControlDialog
Fix the formatting of `CrossoverEQControlDialog` which got messed up after copying the code from the current version on GitHub.
* Code review changes
Use `std::max` instead of `qMax`. Remove some unnecessary whitespace.
* Protected legacy mode methods
Make `legacyMode` and `setLegacyMode` protected to ensure that legacy knobs can only be built using the factory method `buildLegacyKnob`. In the long term legacy mode should be removed.
* Code review: remove indexed access
The original request in the code review was to use `size_t` instead of
`uint32_t` in the for-loop. However it is possible to completely remove
the indexed access and to turn it into a simple iterated for-loop.
Also remove code repetition in the calculation of the maximum knob width
of the group. Use std::max instead of manual management.
* Fix u_int16_t to uint16_t
This should hopefully fix the WIndows builds.
* Fix AudioFileProcessor knobs
Fix a problem with the `AudioFileProcessorWaveView::knob` which is caused
by the fact the this knob uses the pixmap based knob type `Bright26`
without a label. Most other knobs that inherit from `Knob` set their knob
type to `Styled` which means that no pixmap is used to render the knob.
In the specific case the knob instance is created and the contructor
runs. In the constructor the AFP knob is set to a fixed size of (37,47).
However, at a later point the method `Knob::changeEvent` is triggered by
Qt due to a font change. This in turn calls `Knob::updateFixedSize` which
then recomputes the fixed size and effectively changes the width of the
knob to the width of the pixmap which is 27. Because the knob previously
was rendered centered with a width of 37 this means that the knob is now
effectively shifted by five pixels to the left.
This commit counters this effect by moving the affected AFP knobs five
pixels to the right. A visual difference between the fixed version and
the current master showed no differences. So this should fix the problem.
Because setting the knob to a fixed size of (37,47) does not have any
lasting effect anyway the code is removed from the constructor of the AFP
knob.
* Use legacy knobs in EffectView
* Legacy knobs for instrument & sample
Use legacy knobs for the instrument and sample track view ("VOL", "PAN").
* Add documentation to Knob builder methods
Add some documentation to the `Knob` builder methods. Mark `buildLegacyKnob` as deprecated and note that it should not be used in new code.
* Ensure legancy rendering for legacy knobs
Ensure that legacy knobs are always rendered at a size of 12 pixels,
i.e. `SMALL_FONT_SIZE`.
The previous implementation used the font metrics of the knob's current
font to compute the new fixed size and to render the label. It assumed
that the knob was created using `Knob::buildLegacyKnob` and that
therefore the font is set to 12 pixels. However, this meant that legacy
knobs can still be affected by style sheet settings. The following CSS
rule for example resulted in legacy knobs with a larger font size:
```
* { font-size: 18px; }
```
The fix is to use a font with a size of `SMALL_FONT_SIZE` when
calculating the fixed size of the `Knob` widget and when rendering it if
we are in legacy mode. This ensures that a legacy knob is unaffected by
CSS rules.
The non-legacy knob still uses the widget's font size and therefore it is
affected by CSS rules. However, this is a feature and not a bug because
when for example using a rule like the one above the knob does exactly
what it's asked to do.
* Remove unused constructor
Remove an unused constructor from CustomTextKnob
* Remove Knob::buildKnobWithSmallPixelFont
Remove the builder method `Knob::buildKnobWithSmallPixelFont` and replace
it with an equivalent new contstructor which takes the same arguments as
the build method.
* Remove Knob::buildKnobWithFixedPixelFont
Remove `Knob::buildKnobWithFixedPixelFont` as it is not used anymore.
Previously it was delegated to by the now removed method
`Knob::buildKnobWithSmallPixelFont`.
* Constructor for knobs with pixel size labels
Remove `TempoSyncKnob::TempoSyncKnob` and add an equivalent constructor.
Make `buildKnobWithSmallPixelFont` use the new constructor.
* Remove TempoSyncKnob::buildKnobWithSmallPixelFont
Remove `TempoSyncKnob::buildKnobWithSmallPixelFont` and make clients use
the new constructor.
* Remove CustomTextKnob::buildKnobWithSmallPixelFont
Remove `CustomTextKnob::buildKnobWithSmallPixelFont` and extend the
constructor so that it also takes a label. Previously all constructions
went through the build method and now all constructions use the extended
constructor.
* Knob constructors whichKnob constructors which take labels
Add constructors for `Knob` and `TempoSyncKnob` which also take the label
text. Make setLabel protected as most knobs should know their labels at
construction time.
This prevents "chatty" code like the following example:
```
Knob* knob = new Knob(KnobType::Bright26, this);
knob->setLabel("My label");
```
This now becomes a simple a one-liner:
```
Knob* knob = new Knob(KnobType::Bright26, "My label", this);
```
The constructor of `KnobControl` also had to be extended with the label
text because it cannot access the setLabel of the Knob that it manages.
However, it can pass the text during construction. Its implementation of
the virtual method `Control::setText` becomes empty due to this. The
`KnobControl` is currently only used in `Lv2ViewProc::Lv2ViewProc`. Here
the `KnobControl` is created by passing the port name into the
constructor. However, the virtual method `setText` is still called in
line 91 for all other implementations.
Add documentation for the constructors.
* Remove Knob::buildLegacyKnob
Remove `Knob::buildLegacyKnob` by extending the very similar constructor
with an enum that indicates whether the constructed `Knob` should be in
legacy mode or not. The default is to build a non-legacy `Knob`.
Wherever `Knob::buildLegacyKnob` was called the constructor is now called
with `Knob::Mode::Legacy` as the parameter. In some places where the
onject name is set `Knob::Mode::NonLegacy` has to be added explicitly.
* Remove TempoSyncKnob::buildLegacyKnob
Remove `TempoSyncKnob::buildLegacyKnob` by extending the very similar
constructor with an enum that indicates whether the constructed
`TempoSyncKnob` should be in legacy mode or not. The default is to
build a non-legacy `TempoSyncKnob`.
Wherever `TempoSyncKnob::buildLegacyKnob` was called the constructor is
now called with `Knob::Mode::Legacy` as the parameter.
* Vertical spacing for Peak Controller
Add a vertical spacing of 10 pixel between the knobs of the Peak Controller.
* Peak Controller: use default margins
Remove the specific call to `setContentsMargins` from the Peak Controller so that the main layout uses Qt's default margins.
Also remove the spacing again.
* Rename the enum `Knob::Mode`
Rename the enum `Knob::Mode` and its values so that they better describe
what they influence.
`Knob::Mode` is renamed to `Knob::LabelRendering` to indicate that its
value affects the label rendering.
The value `NonLegacy` is now called `WidgetFont` to indicate that the
knob uses the font settings of the widget when rendering the label.
The value `Legacy` is now called `LegacyFixedFontSize` to indicate that
it's a legacy behavior which uses a fixed font size that does not adhere
to the font size that's set for the widget's font.
Adjust all callers accordingly.
* Add TempoSyncKnob documentation
Document the constructor of `TempoSyncKnob` that can be used to set the
label rendering to lecacy mode.
* Name adjustments and parameter removal
Rename `m_legacyMode` to `m_fixedFontSizeLabelRendering`.
Rename the method `legacyMode` to `fixedFontSizeLabelRendering`.
Rename `setLegacyMode` to `setFixedFontSizeLabelRendering`. Also remove
the boolean parameter from the method as it was only called with `true`
anyway.
|
||
|
|
8afe95aeaf |
Fix track operations button alignment, size, and style (#7779)
Make the track ops button consistently sized and style it and the solo & mute buttons using CSS instead of SVG assets |
||
|
|
953f6b7351 |
Rework Crossover EQ plugin GUI (#7781)
* Switches to SVG assets * Fixes layout issues * Refactors redundant code --------- Co-authored-by: Tres Finocchiaro <tres.finocchiaro@gmail.com> |
||
|
|
3c3441bb0c |
Faders with a dB scale (instead of linear/percentage) (#7636)
* Use dbFS scale for the faders
Make the faders use a linear dbFS scale. They now also change position on first click and can then be dragged.
The `Fader` class now has a new property called `m_faderMinDb`. It's the minimum value before the amplification drops down fully to 0. It is needed because we cannot represent a scale from -inf to maxDB.
Rename `knobPosY` to `calculateKnobPosYFromModel` and move the implementation into the cpp file. The method now first converts the model's current amplification value to dbFS and then computes a ratio based on that values and the minimum and maximum dbFS values.
Add the method `setVolumeByLocalPixelValue` which takes a local y coordinate of the widget and sets the amplification of the model based on a dbFS scale.
Adjust `mousePressEvent` and `mouseMoveEvent` so that they mostly take the local y coordinate of the event and use that to adjust the model via `setVolumeByLocalPixelValue`.
Remove `m_moveStartPoint` and `m_startValue` and they are not needed anymore.
* Apply curve to faders
Apply a curve, i.e. the cube function and its inverse, to the fader
positions to that we have more space to work with in the "interesting"
areas around 0 dB and less space in the area where we tend to "-inf dB".
Set the minimum dB value of the fader to -120 dB to increase the potential
headroom.
* Support for dB models
Add support for models that are in dB.
There's a new member `m_modelIsLinear` which can be set via the
constructor. The default value in the constructor is `true`.
Add the method `modelIsLinear` which can be used to query the parameter.
It is used in `calculateKnobPosYFromModel` and
`setVolumeByLocalPixelValue`. Both methods got extended to deal with
models in dB. They were also refactored to extract code that is common
for both cases.
Ensure that the constructor of `Fader` is called with `false` for
`CrossoverEQControlDialog` and `EqFader` because these use models that
are in dB.
* Show current dB value of fader in tool tip
Show the current value of the fader in its tool tip. Please note that
this value is always shown in dB because the goal should be to get rid
of the linear values for the faders.
Some of the code is extracted into the new method
`Fader::getModelValueAsDbString` which is shared by
`Fader::modelValueChanged` (also new) and `Fader::updateTextFloat`.
Please note that `getModelValueAsDbString` will use "dB" instead of
"dBFS" as the unit and that it will format "-inf dB" instead of "-∞ dB".
These changes will also be visible in the text float that is used to
show the new values as the fader is being dragged.
* Let users enter values in dB
Let users enter values in dB in the dialog that opens with a double
click.
The minimum value that can be entered is the minimum value that the
fader allows to set, i.e. -120 dB. The maximum value is the maximum
value of the model converted to dB. As of now this is ~6 dB. The
current value is converted to dB. If it corresponds to "-inf dB", i.e.
if the amplification is 0 then the minimum value is used.
* Remove option "Display volume as dBFS"
Remove the option "Display volume as dBFS" from the settings dialog and
the check box option "Volume as dBFS" from the "View" menu. Volumes are
now always treated as dB, i.e. all evaluations of the property
"displaydbfs" have been removed which results in assuming that this
option is always true.
The upgrade code in `ConfigManager::upgrade_1_1_91` was left as is.
However, a note was added which informs the reader that the value of
"displaydbfs" is not evaluated anymore.
* Extend Fader::wheelEvent
Extend `Fader::wheelEvent` for the case where the model is not a dB
model (`modelIsLinear() == true`), e.g. for the mixer faders. In that
case it works as follows. Each step increments or decrements by 1 dB if
no modifier is pressed. With "Shift" pressed the increment value is 3 dB.
With "STRG" ("CTRL") pressed the increment value is reduced to 0.1 dB. If
the value goes below the minimum positive dB value that is allowed by the
fader then the fader is set to "-inf dB", i.e. zero amplification. If the
fader is set to "-inf dB" and the users want to increase the value then
it is first set to the minimum positive value that is allowed by the
fader.
If the model is a dB model then the same behavior as before is used.
Although it should be considered to adjust this case as well. These
models are used by the faders of the Crossover Equalizer, Equalizer,
Compressor and Delay and they are not very usable with the mouse wheel.
* Adjust the wheel behavior for faders with dB models
Make the faders of the Crossover Equalizer, Equalizer, Compressor and
Delay behave like the mixer faders, i.e. step in sizes of 3 dB, 1dB and
0.1 dB depending on whether a modifier key is pressed or not.
Extract some common code to do so and add some `const` keywords.
* Less "jumpy" knobs
Implement a more stable knob behavior.
Remove the jumping behavior if the users directly click on a volume
knob. By storing the offset from the knob center and taking it into
account during the changes it now also feels like the users are
dragging the knob.
Changes to the amplification are now only applied when the mouse is
moved. This makes the double click behavior much more stable, i.e. if
users click on the knob when it is at 0 dB the dialog will also show
0 dB and not something like 0.3 dB because the first click is already
registered as a change of volume.
If the users click next to the knob the amplification will still be
changed immediately to that value.
## Technical details
To make the knobs more stable a variable called `m_knobCenterOffset` was
introduced. It stores the offset of the click from the knob center so
that this value can be taken into account for in the method
`setVolumeByLocalPixelValue`.
* Make MSVC happy
Add an indication that a float value is assigned to a float variable.
* Introduce constexpr for scaling exponent
Introduce the `constexpr c_dBScalingExponent` which describes the
scaling exponent that's used to scale the dB scale in both directions.
This will simplify potential adjustments by keeping the values
consistent everywhere.
* Draw fader ticks
Draw fader ticks in case the model is a linear one. This means that for
now they should only be painted for the mixer faders but not for the
faders of the Compressor, Delay, etc.
Extract the computation of the scaled ratio between the maximum model dB
value and the minimum supported fader dB value into the new private
method `computeScaledRatio`. This is necessary because it is needed to
paint the fader knob at the correct position (using the knob bottom as
the reference) and to paint the fader ticks at the correct position
(using the knob center).
Introduce the private method `paintFaderTicks` which paints the fader
ticks.
Note: to paint some non-evenly spaced fader ticks replace the `for`
expression in `paintFaderTicks` with something like the following:
```
for (auto & i : {6.f, 0.f, -6.f, -12.f, -24.f, -36.f, -48.f, -60.f, -72.f, -84.f, -96.f, -108.f, -120.f})
```
* Fader adjustments via keyboard
Allow the adjustment of the faders via the keyboard. Using the up or
plus key will increment the fader value whereas the down or minus key
will decrement it. The same key modifiers as for the wheel event apply:
* No modifier: adjust by 1 dB
* Shift: adjust by 3 dB
* Control: adjust by 0.1 dB
Due to the very similar behavior of the mouse wheel and key press
handling some common functionality was factored out:
* Determinination of the (absolute) adjustment delta value by
insprecting the modifier keys of an event. Factored into
`determineAdjustmentDelta`.
* Adjustment of the model by a given dB delta value. Factored into
`adjustModelByDBDelta`.
* Move the fader of the selected channel
Move the fader of the selected channel instead of the fader that has
focus when the up/plus or down/minus keys are pressed. Doing so also
feels more natural because users can already change the selected
channel via the left and right keys and now they can immediately adjust
the volume of the currently selected channel while doing so.
Key events are now handled in `MixerView::keyPressEvent` instead of
`Fader::keyPressEvent` and the latter is removed. `MixerChannelView`
now has a method called `fader` which provides the associated fader.
This is needed so that the event handler of `MixerView` can act upon
the currently selected fader.
## Changes in Fader
The `Fader` class provides two new public methods.
The `adjust` method takes the modifier key(s) and the adjustment
direction and then decides internally how the modifier keys are mapped
to increment values. This is done to keep the mapping between modifier
keys and increment values consistent across different clients, e.g. the
key event of the `MixerView` and the wheel event of the `Fader` itself.
The direction is provided by the client because the means to determine
the direction can differ between clients and cases, e.g. a wheel event
determines the direction differently than a key event does.
The method `adjustByDecibelDelta` simply adjusts the fader by the given
delta amount. It currently is not really used in a public way but it
still makes sense to provide this functionality in case a parent class
or client wants to manipulate the faders by its very own logic.
Because the `Fader` class does not react itself to key press events
anymore the call to `setFocusPolicy` is removed again.
* Enter fader value when space key pressed
Let the users enter the fader value via dialog when the space key is
pressed.
Extract the dialog logic into the new method `adjustByDialog` and call
it from `MixerView::keyPressEvent`.
Make `Fader::mouseDoubleClickEvent` delegate to `adjustByDialog` and
also fix the behavior by accepting the event.
* More prominent fader ticks around 0 dB
Make the fader ticks around 0 dB more prominent but drawing them
slightly wider and with a more opaque color.
* Work around a Qt bug
Work around a Qt bug in conjunction with the scroll wheel and the Alt
key. Simply return 0 for the fader delta as soon as Alt is pressed.
* Fix wheel events without any modifier
Fix the handling of wheel events without any modifier key being pressed.
Commit
|
||
|
|
ba4fda7c97 |
Scalable consistent faders with themeable gradients, marker at unity, dbFS by default (#7045)
* Render fader levels in code with a gradient Render the fader level in code using a gradient instead of using pixmaps. The problem with the pixmaps is that they don't "know" how a fader instance is configured with regards to the minimum and maximum value. This means that the display can give quite a wrong impression. The rendering of levels has been unified in the method `paintLevels`. It can render using dbFS and linear scale. The method `paintLinearLevels` has been removed completely, i.e. there's no more code that renders using pixmaps. Much of the previous code relied on the size of the background image `fader_background.png`, e.g. the initialization of the size. For now the `Fader` widget is initially resized to the size of that background image as it is present in the default and classic theme (see `Fader::init`). All rendering uses the size of the widget itself to determine where to draw what. This means that the widget is prepared to be resizable. The method `paintLevels` first renders the background of the level indicators and uses these as clipping paths for all other rendering operations, e.g. for the rendering of the levels themselves. Levels are rendered using a gradient which is defined with the following stops: * Two stops for the ok levels. * One stop for warning levels. * One stop for clipping levels. Peak indicators do not use the three distinct colors anymore but instead use the color of the gradient at that position of the peak. This makes everything look "smooth". The code now also renders a marker at unity position, i.e. at position 1.0 in linear levels and 0 dbFS in dbFS scale. The painting code makes lots of use of the class `PaintHelper`. This class is configured with a minimum and maximum value and can then return linear factors for given values. There are two supported modes: * Map min to 0 and max to 1 * Map min to 1 and max to 0 It can also compute rectangles that correspond to a given value. These methods can be given rectangles that are supposed to represent the span from min to max. The returned result is then a rectangle that fills the lower part of the source rectangle according to the given value with regards to min and max (`getMeterRect`). Another method returns a rectangle of height 1 which lies inside the given source rectangle at the corresponding level (`getPersistentPeakRect`). The method `paintLevels` uses a mapping function to map the amplitude values (current peak value, persistent peak, etc.) to the display values. There's one mapper that keeps the original value and it is used to display everything in a linear scale. Another mapper maps everything to dbFS and uses these values as display everything in a dbFS scale. The following values must be mapped for the left and right channel to make this work: * Min and max display values (min and max peak values) * The current peak value * The persistent peak value * The value for unity, i.e. 1.0 in linear levels and 0 dbFS in dbFS scale. Remove the method `calculateDisplayPeak` which was used in the old method to render linear levels. `Fader::setPeak` now uses `std::clamp` instead of doing "manual" comparisons. The LMMS plugins Compressor, EQ and Delay are still configured to use linear displays. It should be considered to switch them to dbFS/logarithmic displays as well and to remove the code that renders linearly. * Remove unused pixmaps from `Fader` Remove the now unused pixmaps for the background and the LEDs from the `Fader` class and remove the files from the default and classic theme directories. * Rename peak properties and use them to render levels Rename the peak properties as follows: * peakGreen -> peakOk * peakRed -> peakClip * peakYellow -> peakWarn The reasoning is that a style might for example use a different color than green to indicate levels that are ok. Use the properties to initialize the gradient that is used to render the levels. Initialize the properties to the colors of the current default theme so that it's not mandatory to set them in a style sheet. Up until now they have all been initialized as black. * Always render the knob in the middle of the fader Render the knob in the middle of the fader regardless of the width. The previous implementation was dependent on the fader pixmap having a matching width because it always rendered at x=0. * Set size policy of fader to minimum expanding Set the size policy of the fader to minimum expanding in both directions. This will make the fader grow in layouts if there is space. * Default dbFS levels and better peak values Default to dbFS levels for all faders and set some better minimum and maximum peak values. * Fix faders of Crossover EQ Fix the faders of the Crossover EQ which were initialized and rendered much too wide and with a line at unity. The large width also resulted in the knobs being rendered outside of view. Resize the fader to the minimum size so that it is constructed at a sane default. Introduce a property that allows to control if the unity line is rendered. The property is available in style sheets and defaults to the unity lines being rendered. Adjust the paint code to evaluate the property. Initialize the faders of the Crossover EQ such that the unity line is not drawn. * Remove EqFader constructor with pixmaps Remove the constructor of `EqFader` that takes the pixmaps to the fader background, leds and knob. The background and leds pixmaps are not used by the base class `Fader` for rendering anymore to make the `Fader` resizable. A pixmap is still used to render the knob but the constructor that takes the knob as an argument does not do anything meaningful with it, i.e. all faders are rendered with the default knob anyway. Remove the resources for the fader background, leds and knob as they are not used and the knob was the same image as the default knob anyway. Remove the static pixmaps from the constructor of `EqControlsDialog`. Switch the instantiations of the EQ's faders to use the remaining constructor of `EqFader`. This constructor sets a different fixed size of (23, 116) compared to the removed constructor which set a size of (23, 80). Therefore all faders that used the removed constructor are now set explicitly to a fixed size of (23, 80). The constructor that's now used also calls a different base constructor than the removed one. The difference between the two base constructors of `Fader` is that one of them sets the member `m_conversionFactor` to 100.0 whereas the other one keeps the default of 1.0. The adjusted faders in `EqControlsDialog` are thus now constructed with the conversion factor set to 100. However, all of them already call `setDisplayConversion` with `false` after construction which results in the conversion factor being reset to 1.0. So the result should be the same as before the changes. * Remove background and LEDs pixmap from Fader constructor Remove the parameters for the background and LEDs pixmap from the second `Fader` constructor. Make the knob pixmap parameter in the constructor a const reference. Assign the reference to the knob pixmap of the `Fader` itself. This enables clients to use their own fader knobs as is the case with the Crossover EQ. The EQ now renders using it's own knobs again. Make the second constructor delegate to the first one. This will additionally set the conversion factor to 100 but this is not a problem with the current code because the only user of the second constructor, the Crossover EQ, already calls `setDisplayConversion` with the parameter set to `false`, hence reinstating a conversion factor of 1. Remove the resources for the background and LEDs from the Crossover EQ as they are not used anymore. Remove the three QPixmap members from `CrossoverEQControlDialog` as they are not needed. The background and LEDs are not used anyway and the knob is passed in as a constant reference which is copied. Hence we can use a local variable in the constructor of `CrossoverEQControlDialog`. * Remove the init method from Fader Remove the `init` method from `Fader` as it is not needed anymore due to the constructor delegation. Tidy up the parameter lists and use of spaces in the constructor. * Introduce range with solid warn color Introduce a second point in the gradient for the warn colors so that we get a certain range with the full/solid warn color. The colors are distributed as follows now. The solid ok range goes from -inf dbFS to -12 dbFS. The warn range goes from -6 dbFS to 0 dbFS. In between the colors are interpolated. Values above 0 dbFS interpolate from the warn color to the clip color. This is now quite similar to the previous implementation. # Analysis of the previous pixmap implementation The pixmap implementation used pixmaps with a height of 116 pixels to map 51 dbFS (-42 dbFS to 9 dbFS) across the whole height. The pixels of the LED pixmap were distributed as follows along the Y-axis: * Margin: 4 * Red: 18 * Yellow: 14 * Green: 76 * Margin: 4 Due to the margins the actual red, yellow and green areas only represent a range of (1 - (4+4) / 116) * 51 ~ 47,48 dbFS. This range is distributed as follows across the colors: Red: 7.91 dbFS Yellow: 6.16 dbFS Green: 33.41 dbFS The borders between the colors are located along the following dbFS values: * Red/yellow: 9 - (4 + 18) / 116 * 51 dbFS ~ -0.67 dbFS * Yellow/green: 9 - (4 + 18 + 14) / 116 * 51 dbFS ~ -6.83 dbFS * The green marker is rendered for values above -40.24 dbFS. * Remove unused method Fader::clips * Fader: Correctly render arbitrary ranges Adjust the `Fader` so that it can correctly render arbitrary ranges of min and max peak values, e.g. that it would render a display range of [-12 dbFS, -42 dbFS] correctly. Until now the gradient was defined to start at the top of the levels rectangle and end at the bottom. As a result the top was always rendered in the "clip" color and the bottom in the "ok" color. However, this is wrong, e.g. if we configure the `Fader` with a max value of -12 dbFS and a min value of -42 dbFS. In that case the whole range of the fader should be rendered with the "ok" color. The fix is to compute the correct window coordinates of the start and end point of gradient using from the "window" of values that the `Fader` displays and then to map the in-between colors accordingly. See the added comments in the code for more details. Add the templated helper class `LinearMap` to `lmms_math.h`. The class defines a linear function/map which is initialized using two points. With the `map` function it is then possible to evaluate arbitrary X-coordinates. * Remove unused methods in PaintHelper Remove the now unused mapping methods from `PaintHelper`. Their functionality has been replaced with the usage of `LinearMap` in the code. * Fix some builds Include `cassert` for some builds that otherwise fail. * Opaque unity marker with styling option Make the unity marker opaque by default and enable to style it with the style sheets. None of the two style sheets uses this option though. * Darker default color for the unity line * Move code Move the computation of most mapped values at the top right after the definition of the mapper so that it is readily available in all phases of the painting code. * Render unity lines in background Render the unity lines before rendering the levels so that they get overdrawn and do not stick out when they are crossed. * Don't draw transparent white lines anymore Don't draw the transparent white lines anymore as they were mostly clipped anyway and only create "smudge". * Full on clip color at unity Adjust the gradient so that the full on clip color shows starting at unity. There is only a very short transition from the end of warning to clipping making it look like a solid color "standing" on top of a gradient. * Fix discrepancy between levels and unity markers This commit removes the helper class `PaintHelper` and now uses two lambdas to compute the rectangles for the peak indicators and levels. It uses the linear map which maps the peak values (in dbFS or linear) to window coordinates of the widget. The change fixes a discrepancy in the following implementation for which the full on clip rectangle rendered slightly below the unity marker. * Fix fader display for Equalizer shelves and peaks The peak values for the shelves and peaks of the Equalizer plugin are computed in `EqEffect::peakBand`. The previous implementation evaluated the bins of the corresponding frequency spectrum and determined the "loudest" one. The value of this bin was then converted to dbFS and mapped to the interval [0, inf[ where all values less or equal to -60 dbFS were mapped to 0 and a value of 40 dbFS was mapped to 1. So effectively everything was mapped somewhere into [0, 1] yet in a quite "distorted" way because a signal of 40 dbFS resulted in being displayed as unity in the fader. This commit directly returns the value of the maximum bin, i.e. it does not map first to dbFS and then linearize the result anymore. This should work because the `Fader` class assumes a "linear" input signal and if the value of the bin was previously mapped to dbFS it should have some "linear" character. Please note that this is still somewhat of a "proxy" value because ideally the summed amplitude of all relevant bins in the frequency range would be shown and not just the "loudest" one. ## Other changes Rename `peakBand` to `linearPeakBand` to make more clear that a linear value is returned. Handle a potential division by zero by checking the value of `fft->getEnergy()` before using it. Index into `fft->m_bands` so that no parallel incrementing of the pointer is needed. This also enables the removal of the local variable `b`. * Improve the rendering of the levels The levels rendering now more explicitly distinguished between the rendering of the level outline/border and the level meters. The level rectangles are "inset" with regards to the borders so that there is a margin between the level borders and the meter readings. This margin is now also applied to the top and bottom of the levels. Levels are now also rendered as rounded rectangles similar to the level borders. Only render the levels and peaks if their values are greater than the minimum level. Make the radius of the rounded rectangles more pronounced by increasing its value from 1 to 2. Decrease the margins so that the level readings become wider, i.e. so that they are rendered with more pixels. Add the lambda `computeLevelMarkerRect` so that the rendering of the level markers is more decoupled from the rendering of the peak markers. * Reduce code repetition Reduce code repetition in `EqEffect::setBandPeaks` by introducing a lambda. Adjust code formatting. * Code review changes Code review changes in `Fader.cpp`. Mostly whitespace adjustments. Split up the calculation of the meter width to make it more understandable. This also reduces the number of parentheses. * Use MEMBER instead of READ/WRITE Use `MEMBER` instead of `READ`/`WRITE` for some properties that are not called explicitly from outside of the class. * Use default member initializers for Fader Use default member initializers for the members in `Fader` that have previously been initialized in the constructor list. * Make code clearer Make code clearer in `Fader::FadermouseDoubleClickEvent`. Only divide if the dialog was accepted with OK. |
||
|
|
f10277715f | Classier enums (#6760) | ||
|
|
0b27497be2 |
clang-tidy: Apply modernize-use-auto everywhere (#6480)
Note: clang-tidy was run with `--format-style=file`. |
||
|
|
7227c89847 |
Namespace lmms (#6174)
This PR places all LMMS symbols into namespaces to eliminate any potential future name collisions between LMMS and third-party modules.
Also, this PR changes back `LmmsCore` to `Engine`, reverting
|
||
|
|
33b44ec9c7 |
Disable tooltips through event filter (#6192)
* Control tooltip visibility using an event filter ...removing the need for a ToolTip helper class * Remove whitespace |
||
|
|
54bee2272e |
Rename LedCheckbox to LedCheckBox in filenames
Justification: The class is named `LedCheckBox`, and other files follow the casing of the classes, too. |
||
|
|
7db3fa94a1 |
Improve includes (#6320)
* Update ringbuffer submodule to fix includes
* Remove cyclic includes
* Remove Qt include prefixes
* Include C++ versions of C headers
E.g.: assert.h -> cassert
* Move CLIP_BORDER_WIDTH into ClipView
This allows to remove includes to TrackView.h in ClipView cpp files.
* Elliminate useless includes
This improves the include structure by elliminating includes that are
not used. Most of this was done by using `include-what-you-use` with
`CMAKE_C_INCLUDE_WHAT_YOU_USE` and `CMAKE_CXX_INCLUDE_WHAT_YOU_USE`
set to (broken down here):
```
include-what-you-use;
-Xiwyu;--mapping_file=/usr/share/include-what-you-use/qt5_11.imp;
-Xiwyu;--keep=*/xmmintrin.h;
-Xiwyu;--keep=*/lmmsconfig.h;
-Xiwyu;--keep=*/weak_libjack.h;
-Xiwyu;--keep=*/sys/*;
-Xiwyu;--keep=*/debug.h;
-Xiwyu;--keep=*/SDL/*;
-Xiwyu;--keep=*/alsa/*;
-Xiwyu;--keep=*/FL/x.h;
-Xiwyu;--keep=*/MidiApple.h;
-Xiwyu;--keep=*/MidiWinMM.h;
-Xiwyu;--keep=*/AudioSoundIo.h
```
* Fixup: Remove empty #if-#ifdef pairs
* Remove LMMS_HAVE_STD(LIB|INT)_H
|
||
|
|
6d46bd473f | Remove "What's This?" and update tooltips (#4128) | ||
|
|
9e85d7c66e | update all copyright headers to the proper url (#3326) | ||
|
|
c9618961d6 |
dBV is actually mislabeled dBFS (#3095)
* Relabel "dBV" to "dBFS" in function names and GUI * Write a ConfigManager upgrade for older versions |
||
|
|
d2a5c496ab |
Redesign Crossover Equalizer (#2994)
* Redesign Crossover Equalizer * Make it all pixel perfect |
||
|
|
0789bae53a | Crossover EQ initial commit, also fix bugs in LR4 filter and Fader |