13 Commits

Author SHA1 Message Date
Johannes Lorenz
71ce49d7ba Remove lots of useless/misplaced includes (#7999)
Follow-Up of 7db3fa94a1 .

This was done by setting `CMAKE_C_INCLUDE_WHAT_YOU_USE` and
`CMAKE_CXX_INCLUDE_WHAT_YOU_USE` to (broken down into multiple lines here,
note, all below `FL/x.h` is not required for C):

```
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;
    -Xiwyu;--keep=*/OpulenZ/adplug/*;
    -Xiwyu;--keep=QPainterPath;
    -Xiwyu;--keep=QtTest
```

FAQ:

* Q: Does this speed-up a completely fresh compile?
* A: No, I measured it.

* Q: Does it speed up anything else?
* A: Yes. If you change one header, it can reduce the number of CPP files
     that your compiler needs to recompile, or your IDE has to re-scan.

* Q: What other reasons are for this PR?
* A: It's idiomatic to only include headers if you need them. Also, it will
     reduce output for those who want to use IWYU for new PRs.

Background:

This is just a remainder PR of what I planned. My original idea was to setup
a CI which warns you of useless includes (but not of all issues that IWYU
complains about). However, I could not see that this was favored on Discord.
A full IWYU CI also has the problem that it (possibly??) needs to compile
with `make -j 1`, which would make CI really slow.

However, for that plan, I had to fix the whole code base to be IWYU
compliant - which it now is.
2025-07-21 23:39:17 +02:00
Michael Gregorius
d5e1d9e853 Move icon determination into TrackLabelButton again (#7209)
Move icon determination into TrackLabelButton again

Fully undo the changes made in commit 88e0e94dcd because the intermediate revert made in commit 04ecf73395 seems to have led to a performance problem due to the icon being set over and over again in `TrackLabelButton::paintEvent`.

The original intention of the changes made in pull request #7114 was to remove the painting code that dynamically determines the icon over and over again. Ideally the icon that is used by an instrument should be somewhat of a "static" property that should be known very early on when an instrument view is created. There should not be any need to dynamically resolve the icon over and over, especially not in a button class very far down in the widget hierarchy. However, due to technical reasons this is not the case in the current code. See pull request #7132 for more details.
2024-04-17 19:21:23 +02:00
Michael Gregorius
04ecf73395 Fix missing icons for some instruments (#7132)
Revert some of the changes made in commit 88e0e94dcd. The underlying idea was that the `InstrumentTrackView` should be responsible for assigning the icon that's shown by its `TrackLabelButton`. However, this does not work because in some cases the `InstrumentTrack` that's passed into `InstrumentTrackView::determinePixmap` does not have an `Instrument` assigned. This in turn seems to be caused due to initalizations that are running in parallel in different threads.

Here are the steps to reproduce the threading problem (line numbers refer to commit 360254f):
1. Set a break point in line 1054 of `InstrumentTrack`, i.e. the line in `InstrumentTrack::loadInstrument` where `m_instrument` is being assigned to.
2. Set a break point in `InstrumentTrackView::determinePixmap`, e.g. inside of the first if statement.
3. Drop an instance of "Sf2 Player" onto the Song Editor.
4. The first break point in `InstrumentTrack` is hit in a thread called "lmms::Instrumen" (shown like that in my debugger). Try to step over it.
5. The second break point in `InstrumentTrackView` now gets hit before the code is stepped over. This time we are in the thread called "lmms". I guess this is the GUI main thread.
6. Continue execution.

If you now switch to the application then the icon is shown. I guess the debugger is halted long enough in the main thread so that the InstrumentTrack gets an instrument assigned in another thread.

If you delete/disable the break point in `InstrumentTrack::determinePixmap` and follow the coarse steps above then the icon is not shown because the track has no instrument.

The current fix still delegates to the `InstrumentTrackView` to determine the pixmap in hopes that one day there will be a better solution where the parent component can be fully responsible for its child component.

Fixes #7116.
2024-03-13 20:00:58 +01:00
Michael Gregorius
a81666a9f5 Track resizing behavior (#7114)
* Simplify TrackLabelButton

Remove the dependency to `Instrument` and `InstrumentTrack` from `TrackLabelButton`. The icon of an `InstrumentTrackView` is now determined in the class `InstrumentTrackView` itself using the new static method `determinePixmap`. This enables the removal of the overridden `paintEvent` method from `TrackLabelButton`.

It was also attempted to keep a non-static member function version and to use the `InstrumentTrackView`'s model with a cast. However, this did not work because 'setModel' is executed as the very last step in the constructor, i.e. the model is not already set when `determinePixmap` is called. Pulling it to the top is too risky right now.

* Add helper method isInCompactMode

Add the helper method `isInCompactMode` which knows how to use the `ConfigManager` to determine if the option for compact track buttons is enabled. This removes duplicate code with intricate knowledge of the keys under which compact mode is stored.

* Set song as modified when track name changes

Extend `Track::setName` to set the song as modified whenever the track name changes. This moves the update into a core class and enables the removal of the dependencies to `Engine` and `Song` from the GUI class `TrackLabelButton`.

Also add a check if the name is really changed and only perform the actions if that's the case.

To make this work the implementation of `setName` had to be moved from the header into the implementation file.

* Keep instrument and sample content at top on resize

Keep the content of the instrument and sample track at the top of the widget if the widget is resized. This is also fixes a bug where the `TrackLabelButton` does not react anymore when the size is increased.

Technically the layout with the actual widgets is put into another vertical layout with a spacer that consumes all remaining space at the bottom.

* Vertical track resizing via mouse wheel

Enable to vertically resize tracks using the mouse wheel. Scrolling the mouse wheel over the track view with the control key pressed will increase/decrease the height by one pixel per wheel event. Pressing the shift key will increase/decrease in steps of five pixels.

Extract code that can be shared between the existing and the new way to resize the track into the private helper method `resizeToHeight`.

* Render beat pattern step buttons at the top

Render the step buttons of beat patterns at the top instead of at the bottom so that they stay aligned with the other elements to the left of them (buttons, knobs, etc).

Set the y offset to 4 so that the step buttons are vertically aligned with the other elements. The previous calculation lead to a minimum offset of 6 which always made the step buttons look misaligned.

Introduce the new static variable `BeatStepButtonOffset` which ensures that the rendering and the evaluation of mouse clicks do not go out of sync.
2024-02-18 21:22:22 +01:00
saker
6b21dc7896 Use Qt layouts for mixer channels (#6591)
Use Qt layouts for the mixer channels. These changes will enable several other improvements, like for example making the mixer and faders resizable, adding peak indicators, etc.

This is a squash commit which consists of the following individual commits:

* Remove extra transparency in send/receive arrows
The extra transparency was conflicting with the positioning of
the arrows in the layout

* Begin reimplementing MixerChannelView

MixerChannelView is now a combination of the
MixerLine with the previous MixerChannelView

* Adjust SendButtonIndicator to use MixerChannelView

* Remove MixerLine
- Move MixerChannelView into src/gui

* Remove MixerView::MixerChannelView

* Remove header of MixerLine

* Change MixerView.h to use MixerChannelView
Change MixerView.h to use MixerChannelView rather than MixerLine
Also do some cleanup, such as removing an unused forward declaration
of QButtonGroup

* Create EffectRackView
+ Set height of sizeHint() using MIXER_CHANNEL_HEIGHT (287)

* Remove include of MixerLine
- Include MixerChannelView

* Phase 1: Adjust MixerView to use new MixerChannelView

* Move children wigets into header file

* Phase 2: Adjust MixerView to use new MixerChannelView

* Phase 3: Adjust MixerView to use new MixerChannelView

* Phase 4: Adjust MixerView to use new MixerChannelView

* Phase 5: Adjust MixerView to use new MixerChannelView

* Phase 5: Adjust MixerView to use new MixerChannelView

* Remove places where MixerChannelView is being deleted

Before, MixerChannelView was not inherited by QWidget,
meaning it could not have a parent and had to be deleted
when necessary. Since the MixerView owns the
new MixerChannelView, this is no longer necessary.

* Replace MixerLine with MixerChannelView
- Include MixerChannelView in MixerView

* Replace setCurrentMixerLine calls with setCurrentMixerChannel around codebase

* Add event handlers in MixerChannelView

* Implement MixerChannelView::eventFilter

* Update theme styles to use MixerChannelView

* Add QColor properties from style
- Set the Qt::WA_StyledBackground attribute on

* Add effect rack to rack layout when adding channel

* Set size for MixerChannelView
- Change nullptr to this for certain widgets
   - Some custom widgets may expect there to be a parent
- Add spacing in channel layout
- Increase size of mixer channel

* Retain size when widgets are hidden

* Implement paintEvent
- Rename states in SendReceiveState

* Implement send/receive arrow toggling
- Make maxTextHeight constexpr in elideName
- Remove background changing on mouse press
(is now handled in paintEvent)

* Implement renaming mixer channels

* Implement color functions

* Implement channel moving/removing functions

* Do some cleanup
Not sure if that connection with the mute model was needed, but removing
it did not seem to introduce any issues.

* Include cassert

* Replace references to MixerLine with MixerChannelView

* Reduce height
+ Make m_renameLineEdit transparent
+ Retain size when LCD is hidden
+ Remove stretch after renameLineEdit in layout

* Remove trailing whitespace

* Make m_renameLineEdit read only
+ Transpose m_renameLineEditView rectangle (with 5px offset)

* Set spacing in channel layout back to 0

* Remove sizeHint override and constant size

* Use sizeHint for mixerChannelSize
+ Leave auto fill background to false in MixerChannelView
+ Only set width for EffectRackView

* Set margins to 4 on all sides in MixerChannelView

* Move solo and mute closer to each other

Move the solo and mute buttons closer to each other in the mixer channels.

Technically this is accomplished by putting them into their own layout with minimal margins and spacing.

* Fixes for CodeFactor

* Code review changes

Mostly whitespace and formatting changes: remove tabs, remove spaces in parameter lists, remove underscores from parameter names.

Some lines have been shortened by introducing intermediate variables, e.g. in `MixerChannelView`.

`MixerView` has many changes but only related to whitespace. Spaces have been introduced for if and for statements. Whitespace at round braces has been removed everywhere in the implementation file even if a line was not touched by the intial changes.

Remove duplicate forward declaration of `MixerChannelView`.

* Adjust parameter order in MixerChannelView's constructor

Make the parent `QWidget` the first parameter as it is a Qt convention. The default parameter had to be removed due to this.

* Move styling of rename line edit into style sheets

Move the style of the `QGraphicsView` for the rename line edit from the code into the style sheets of the default and classic theme.

* More code review changes

Fix spaces between types and references/pointers, e.g. use `const QBrush& c` instead of `const QBrush & c`.
Remove underscores from parameter names.
Remove spaces near parentheses.
Replace tabs with spaces.
Introduce intermediate variable to resolve "hanging" + operator.
Replace the connection for the periodic fader updates with one that uses function pointers instead of `SIGNAL` and `SLOT`.

---------

Co-authored-by: Michael Gregorius <michael.gregorius.git@arcor.de>
2023-12-30 17:55:28 +01:00
saker
1e6a66f4ac Add mixer LCD channels for Instrument & Sample tracks (#6831)
* Add mixer channel LCD to SampleTrackView

* Increase sizes to compensate for LCD box
The DEFAULT_SETTINGS_WIDGET_WIDTH and
DEFAULT_SETTINGS_WIDGET_WIDTH_COMPACT
were both increased by +32 pixels. TRACK_OP_WIDTH
 and TRACK_OP_WIDTH_COMPACT were then changed
 relative to that increase.

* Use Qt layout in SampleTrackView

* Add mixer channel LCD to InstrumentTrackView

* Move LCD box to the right of the track label

* Revert changes to TRACK_OP_WIDTH and TRACK_OP_WIDTH_COMPACT
2023-08-28 13:14:19 -04:00
Dalton Messmer
2c6d88f799 Add GUARD_H closing comments 2023-01-05 17:58:49 -05:00
Dalton Messmer
fe6df8dbaf Add namespace prefix to include guards 2023-01-02 19:51:32 -05:00
Levin Oehlmann
5904b249c0 clang-tidy: Apply modernize-use-override everywhere (#6439)
... to mark overriding functions `override` instead of `virtual`.
2022-06-19 23:03:55 +02:00
Levin Oehlmann
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 c519921306 .

Co-authored-by: allejok96 <allejok96@gmail.com>
2022-06-19 20:08:46 +02:00
Johannes Lorenz
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
2022-03-02 13:30:43 +01:00
Yashraj Shinde
bf323d2024 Rename FxMixer to Mixer (#6239)
... as decided in #6089 and #5592.

This PR replaces every occurrence of "FX" where "Mixer Channel" is meant.
2022-01-09 08:15:23 +01:00
Alexandre Almeida
47cddcba75 Split InstrumentTrack (#6176)
Split InstrumentTrackView and InstrumentTrackWindow off of InstrumentTrack
2021-10-02 05:40:01 +02:00