Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding pattern editor subwindow horizontal scaling #7409

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
43ba114
TrackContainerView_enable_horizontal_scrolling_in_constructor
szeli1 Jul 27, 2024
fe29e6e
TrackView_adding_get_width_functions
szeli1 Jul 30, 2024
69757b3
MidiClip_adding_getSteps_function
szeli1 Jul 30, 2024
f272067
TrackView_adding_get_width_functions_in_header
szeli1 Jul 30, 2024
864938c
MidiClipView_restore_to_master
szeli1 Jul 30, 2024
92190aa
MidiClipView_restore_to_master_2
szeli1 Jul 30, 2024
0b24be0
ClipView_adding_clip_width_value
szeli1 Jul 30, 2024
f96310a
TrackContainerView_implemented_resizing_changes
szeli1 Jul 30, 2024
9b4688b
TrackContainerView_removing_qDebug
szeli1 Aug 5, 2024
597b705
TrackContainerView_removing_comment
szeli1 Dec 23, 2024
0d19828
TrackView_removing_static
szeli1 Dec 23, 2024
19f6219
ClipView_adding_qDebug
szeli1 Dec 23, 2024
254b87d
TrackContainerView_fixing_minimum_size_issues
szeli1 Dec 29, 2024
30ab7a5
TrackContainerView_fixing_minimum_size_issues2
szeli1 Dec 29, 2024
1d869e2
ClipView_adding_debugging_code
szeli1 Dec 29, 2024
ec98c99
PatternEditor_adding_debugging_code
szeli1 Dec 29, 2024
6ef0110
TrackView_adding_debugging_code
szeli1 Dec 29, 2024
d36395c
TrackContentWidget_adding_sizing_method
szeli1 Dec 30, 2024
39a2184
TrackContainerView_removing_replaced_code
szeli1 Dec 30, 2024
abfb31e
ClipView_removing_qDebug
szeli1 Dec 30, 2024
5718320
PattenrEditor_removing_debug_code
szeli1 Dec 30, 2024
2f519c9
TrackView_removing_qDebug
szeli1 Dec 30, 2024
f3333dc
ClipView_removing_unused_variable
szeli1 Dec 30, 2024
711a1d4
ClipView_removing_min_size
szeli1 Dec 30, 2024
8af612e
TrackContentWidget_fixing_sizing_with_timesig
szeli1 Dec 30, 2024
8514e7a
TrackContentWidget_moving_method_to_private
szeli1 Dec 30, 2024
4334631
TrackContainerView_removing_include
szeli1 Dec 30, 2024
382a711
MidiClip_removing_getSteps
szeli1 Dec 30, 2024
122112c
TrackContainerView_removing_includes
szeli1 Dec 30, 2024
034a660
MidiClip_removing_getSteps
szeli1 Dec 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion include/MidiClip.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ class LMMS_EXPORT MidiClip : public Clip

bool empty();


gui::ClipView * createView( gui::TrackView * _tv ) override;


Expand Down
4 changes: 2 additions & 2 deletions include/TrackContainerView.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class TrackContainerView : public QWidget, public ModelView,
{
Q_OBJECT
public:
TrackContainerView( TrackContainer* tc );
TrackContainerView(TrackContainer* tc, bool canHorizontalScroll = false);
~TrackContainerView() override;

void saveSettings( QDomDocument & _doc, QDomElement & _this ) override;
Expand Down Expand Up @@ -175,7 +175,7 @@ public slots:
class scrollArea : public QScrollArea
{
public:
scrollArea( TrackContainerView* parent );
scrollArea(TrackContainerView* parent, bool canHorizontalScroll);
~scrollArea() override = default;

protected:
Expand Down
1 change: 1 addition & 0 deletions include/TrackContentWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public slots:
private:
Track * getTrack();
TimePos getPosition( int mouseX );
void setMinimumWidthBasedOnClips();

TrackView * m_trackView;

Expand Down
6 changes: 6 additions & 0 deletions include/TrackView.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ class TrackView : public QWidget, public ModelView, public JournallingObject
return m_action == Action::Move;
}

// returns getTrackFixedSettingsWidth() + getTrackFixedOperationsWidth()
static const int getTrackFixedWidth();
// returns the right compact or not compact width
static const int getTrackFixedSettingsWidth();
static const int getTrackFixedOperationsWidth();
Comment on lines +101 to +105
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can make this documentation better.

Also, I removed the "Fixed" part since I don't think callers of these functions care about if its a fixed width or not. It is simply the width of the thing. If you go through with this change, you'll also have to of course update the function declarations and definitions to reflect the new name.

Suggested change
// returns getTrackFixedSettingsWidth() + getTrackFixedOperationsWidth()
static const int getTrackFixedWidth();
// returns the right compact or not compact width
static const int getTrackFixedSettingsWidth();
static const int getTrackFixedOperationsWidth();
//! Returns the width of a track.
static const int getTrackWidth();
//! Returns the width of the settings portion of a track, based on whether or not the track is compacted.
static const int getTrackSettingsWidth();
//! Returns the fixed width of the operations portion of a track, based on whether or not the track is compacted.
static const int getTrackOperationsWidth();


virtual void update();

// Create a menu for assigning/creating channels for this track
Expand Down
2 changes: 1 addition & 1 deletion src/gui/clips/ClipView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ void ClipView::updateLength()
{
if( fixedClips() )
{
setFixedWidth( parentWidget()->width() );
setFixedWidth(parentWidget()->width());
}
else
{
Expand Down
15 changes: 5 additions & 10 deletions src/gui/editors/PatternEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace lmms::gui


PatternEditor::PatternEditor(PatternStore* ps) :
TrackContainerView(ps),
TrackContainerView(ps, true),
m_ps(ps)
{
setModel(ps);
Expand Down Expand Up @@ -79,6 +79,7 @@ void PatternEditor::removeSteps()
p->removeSteps();
}
}
realignTracks();
}


Expand Down Expand Up @@ -192,6 +193,7 @@ void PatternEditor::makeSteps( bool clone )
}
}
}
realignTracks();
}

// Creates a clone of the current pattern track with the same content, but no clips in the song editor
Expand Down Expand Up @@ -234,14 +236,7 @@ PatternEditorWindow::PatternEditorWindow(PatternStore* ps) :
connect(m_toolBar, SIGNAL(dropped(QDropEvent*)), m_editor, SLOT(dropEvent(QDropEvent*)));

// TODO: Use style sheet
if (ConfigManager::inst()->value("ui", "compacttrackbuttons").toInt())
{
setMinimumWidth(TRACK_OP_WIDTH_COMPACT + DEFAULT_SETTINGS_WIDGET_WIDTH_COMPACT + 2 * ClipView::BORDER_WIDTH + 384);
}
else
{
setMinimumWidth(TRACK_OP_WIDTH + DEFAULT_SETTINGS_WIDGET_WIDTH + 2 * ClipView::BORDER_WIDTH + 384);
}
setMinimumWidth(TrackView::getTrackFixedWidth() + 2 * ClipView::BORDER_WIDTH);

m_playAction->setToolTip(tr("Play/pause current pattern (Space)"));
m_stopAction->setToolTip(tr("Stop playback of current pattern (Space)"));
Expand Down Expand Up @@ -323,4 +318,4 @@ void PatternEditorWindow::stop()
}


} // namespace lmms::gui
} // namespace lmms::gui
9 changes: 3 additions & 6 deletions src/gui/editors/SongEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ SongEditor::SongEditor( Song * song ) :
m_rubberBandStartTrackview(0),
m_rubberbandStartTimePos(0),
m_rubberbandPixelsPerBar(DEFAULT_PIXELS_PER_BAR),
m_trackHeadWidth(ConfigManager::inst()->value("ui", "compacttrackbuttons").toInt()==1
? DEFAULT_SETTINGS_WIDGET_WIDTH_COMPACT + TRACK_OP_WIDTH_COMPACT
: DEFAULT_SETTINGS_WIDGET_WIDTH + TRACK_OP_WIDTH),
m_trackHeadWidth(TrackView::getTrackFixedWidth()),
m_selectRegion(false)
{
m_zoomingModel->setParent(this);
Expand Down Expand Up @@ -756,9 +754,8 @@ static inline void animateScroll( QScrollBar *scrollBar, int newVal, bool smooth

void SongEditor::updatePosition( const TimePos & t )
{
const bool compactTrackButtons = ConfigManager::inst()->value("ui", "compacttrackbuttons").toInt();
const auto widgetWidth = compactTrackButtons ? DEFAULT_SETTINGS_WIDGET_WIDTH_COMPACT : DEFAULT_SETTINGS_WIDGET_WIDTH;
const auto trackOpWidth = compactTrackButtons ? TRACK_OP_WIDTH_COMPACT : TRACK_OP_WIDTH;
const auto widgetWidth = TrackView::getTrackFixedSettingsWidth();
const auto trackOpWidth = TrackView::getTrackFixedOperationsWidth();

if ((m_song->isPlaying() && m_song->m_playMode == Song::PlayMode::Song)
|| m_scrollBack)
Expand Down
11 changes: 7 additions & 4 deletions src/gui/editors/TrackContainerView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ void InstrumentLoaderThread::run()
namespace gui
{

TrackContainerView::TrackContainerView( TrackContainer * _tc ) :
TrackContainerView::TrackContainerView(TrackContainer * _tc, bool canHorizontalScroll) :
QWidget(),
ModelView( nullptr, this ),
JournallingObject(),
SerializingObjectHook(),
m_currentPosition( 0, 0 ),
m_tc( _tc ),
m_trackViews(),
m_scrollArea( new scrollArea( this ) ),
m_scrollArea(new scrollArea(this, canHorizontalScroll)),
m_ppb( DEFAULT_PIXELS_PER_BAR ),
m_rubberBand( new RubberBand( m_scrollArea ) )
{
Expand Down Expand Up @@ -456,12 +456,15 @@ RubberBand *TrackContainerView::rubberBand() const



TrackContainerView::scrollArea::scrollArea( TrackContainerView * _parent ) :
TrackContainerView::scrollArea::scrollArea(TrackContainerView * _parent, bool canHorizontalScroll) :
QScrollArea( _parent ),
m_trackContainerView( _parent )
{
setFrameStyle( QFrame::NoFrame );
setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
if (canHorizontalScroll == false)
{
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
}
}


Expand Down
4 changes: 1 addition & 3 deletions src/gui/tracks/SampleTrackView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,7 @@ void SampleTrackView::dropEvent(QDropEvent *de)

if (type == "samplefile")
{
int trackHeadWidth = ConfigManager::inst()->value("ui", "compacttrackbuttons").toInt()==1
? DEFAULT_SETTINGS_WIDGET_WIDTH_COMPACT + TRACK_OP_WIDTH_COMPACT
: DEFAULT_SETTINGS_WIDGET_WIDTH + TRACK_OP_WIDTH;
int trackHeadWidth = TrackView::getTrackFixedWidth();

int xPos = de->pos().x() < trackHeadWidth
? trackHeadWidth
Expand Down
21 changes: 20 additions & 1 deletion src/gui/tracks/TrackContentWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,18 @@

#include "AutomationClip.h"
#include "Clipboard.h"
#include "ClipView.h"
#include "DataFile.h"
#include "Engine.h"
#include "GuiApplication.h"
#include "MidiClip.h"
#include "MidiClipView.h"
#include "PatternEditor.h"
#include "PatternStore.h"
#include "Song.h"
#include "SongEditor.h"
#include "StringPairDrag.h"
#include "TrackContainerView.h"
#include "ClipView.h"
#include "TrackView.h"

namespace lmms::gui
Expand Down Expand Up @@ -211,6 +213,7 @@ void TrackContentWidget::removeClipView( ClipView * clipv )
*/
void TrackContentWidget::update()
{
setMinimumWidthBasedOnClips();
for (const auto& clipView : m_clipViews)
{
clipView->setFixedHeight(height() - 1);
Expand Down Expand Up @@ -636,13 +639,29 @@ void TrackContentWidget::paintEvent( QPaintEvent * pe )



void TrackContentWidget::setMinimumWidthBasedOnClips()
{
// if this is in the pattern editor
if (m_trackView->trackContainerView()->fixedClips())
{
if (m_clipViews.size() > 0)
{
auto minWidth = static_cast<size_t>(m_clipViews[0]->getClip()->length().getTicks());
setMinimumWidth(minWidth);
//auto minWidth = static_cast<size_t>(m_clipViews[0]->getClip()->length().nextFullBar());
//setMinimumWidth(minWidth * m_trackView->trackContainerView()->pixelsPerBar());
}
Comment on lines +644 to +653
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would personally rewrite it like this and remove the commented out code.

Suggested change
// if this is in the pattern editor
if (m_trackView->trackContainerView()->fixedClips())
{
if (m_clipViews.size() > 0)
{
auto minWidth = static_cast<size_t>(m_clipViews[0]->getClip()->length().getTicks());
setMinimumWidth(minWidth);
//auto minWidth = static_cast<size_t>(m_clipViews[0]->getClip()->length().nextFullBar());
//setMinimumWidth(minWidth * m_trackView->trackContainerView()->pixelsPerBar());
}
if (!m_trackView->trackContainerView()->fixedClips()) { return; }
if (m_clipViews.empty()) { return; }
const auto minimumWidth = static_cast<size_t>(m_clipViews.first()->getClip()->length().getTicks());
setMinimumWidth(minimumWidth);

}
}

/*! \brief Updates the background tile pixmap on size changes.
*
* \param resizeEvent the resize event to pass to base class
*/
void TrackContentWidget::resizeEvent( QResizeEvent * resizeEvent )
{
setMinimumWidthBasedOnClips();

// Update backgroud
updateBackground();
// Force redraw
Expand Down
37 changes: 27 additions & 10 deletions src/gui/tracks/TrackView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,23 +130,40 @@ TrackView::TrackView( Track * track, TrackContainerView * tcv ) :
*/
void TrackView::resizeEvent( QResizeEvent * re )
{
if( ConfigManager::inst()->value( "ui",
"compacttrackbuttons" ).toInt() )
m_trackOperationsWidget.setFixedSize(getTrackFixedOperationsWidth(), height() - 1);
m_trackSettingsWidget.setFixedSize(getTrackFixedSettingsWidth(), height() - 1);
m_trackContentWidget.setFixedHeight(height());
}


const int TrackView::getTrackFixedWidth()
{
return getTrackFixedSettingsWidth() + getTrackFixedOperationsWidth();
}

const int TrackView::getTrackFixedSettingsWidth()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function can be rewritten like this. The comments are also very unnecessary IMO: The code is clear enough that one can already tell what is happening.

const int TrackView::getTrackFixedSettingsWidth()
{
	const auto isCompact = ConfigManager::inst()->value("ui", "compacttrackbuttons").toInt();
	return isCompact ? DEFAULT_SETTINGS_WIDTH_COMPACT : DEFAULT_SETTINGS_WIDGET_WIDTH;
}

{
if(ConfigManager::inst()->value("ui", "compacttrackbuttons").toInt())
{
m_trackOperationsWidget.setFixedSize( TRACK_OP_WIDTH_COMPACT, height() - 1 );
m_trackSettingsWidget.setFixedSize( DEFAULT_SETTINGS_WIDGET_WIDTH_COMPACT, height() - 1 );
// if compact size
return DEFAULT_SETTINGS_WIDGET_WIDTH_COMPACT;
}
else
// if not compact
return DEFAULT_SETTINGS_WIDGET_WIDTH;
}

const int TrackView::getTrackFixedOperationsWidth()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same with this one:

const int TrackView::getTrackFixedOperationsWidth()
{
	const auto isCompact = ConfigManager::inst()->value("ui", "compacttrackbuttons").toInt();
	return isCompact ? TRACK_OP_WIDTH_COMPACT : TRACK_OP_WIDTH;
}

{
if(ConfigManager::inst()->value("ui", "compacttrackbuttons").toInt())
{
m_trackOperationsWidget.setFixedSize( TRACK_OP_WIDTH, height() - 1 );
m_trackSettingsWidget.setFixedSize( DEFAULT_SETTINGS_WIDGET_WIDTH, height() - 1 );
// if compact size
return TRACK_OP_WIDTH_COMPACT;
}
m_trackContentWidget.setFixedHeight( height() );
// if not compact
return TRACK_OP_WIDTH;
}




/*! \brief Update this track View and all its content objects.
*
*/
Expand Down
1 change: 0 additions & 1 deletion src/tracks/MidiClip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,6 @@ void MidiClip::removeSteps()




gui::ClipView * MidiClip::createView( gui::TrackView * _tv )
{
return new gui::MidiClipView( this, _tv );
Expand Down
Loading