LMMS
Loading...
Searching...
No Matches
lmms::gui::ClipView Class Reference

#include <ClipView.h>

Inheritance diagram for lmms::gui::ClipView:
lmms::gui::selectableObject lmms::gui::ModelView lmms::gui::AutomationClipView lmms::gui::MidiClipView lmms::gui::PatternClipView lmms::gui::SampleClipView

Public Slots

virtual bool close ()
 Close a ClipView.
void remove ()
 Removes a ClipView from its track view.
void update () override
 Update a ClipView.
void selectColor ()
void randomizeColor ()
void resetColor ()
Public Slots inherited from lmms::gui::selectableObject
virtual void update ()

Public Member Functions

 ClipView (Clip *clip, TrackView *tv)
 Create a new ClipView.
 ~ClipView () override
 Destroy a ClipView.
bool fixedClips ()
 Does this ClipView have a fixed Clip?
ClipgetClip ()
TrackViewgetTrackView ()
QColor mutedColor () const
 CSS theming qproperty access method.
QColor mutedBackgroundColor () const
QColor selectedColor () const
QColor textColor () const
QColor textBackgroundColor () const
QColor textShadowColor () const
QColor patternClipBackground () const
QColor markerColor () const
bool gradient () const
void setMutedColor (const QColor &c)
 CSS theming qproperty access method.
void setMutedBackgroundColor (const QColor &c)
void setSelectedColor (const QColor &c)
void setTextColor (const QColor &c)
void setTextBackgroundColor (const QColor &c)
void setTextShadowColor (const QColor &c)
void setPatternClipBackground (const QColor &c)
void setGradient (const bool &b)
void setMarkerColor (const QColor &c)
bool needsUpdate ()
void setNeedsUpdate (bool b)
QVector< ClipView * > getClickedClips ()
void copy (QVector< ClipView * > clipvs)
void cut (QVector< ClipView * > clipvs)
void paste ()
void toggleSelectedAutoResize ()
QColor getColorForDisplay (QColor)
void setMarkerPos (int x)
void setMarkerEnabled (bool e)
Public Member Functions inherited from lmms::gui::selectableObject
 selectableObject (QWidget *_parent)
 ~selectableObject () override=default
void setSelected (bool selected)
bool isSelected () const
Public Member Functions inherited from lmms::gui::ModelView
 ModelView (Model *model, QWidget *widget)
virtual ~ModelView ()
virtual void setModel (Model *model, bool isOldModelValid=true)
virtual void unsetModel ()
Modelmodel ()
const Modelmodel () const
template<class T>
T * castModel ()
template<class T>
const T * castModel () const

Static Public Member Functions

static void remove (QVector< ClipView * > clipvs)
static void toggleMute (QVector< ClipView * > clipvs)

Static Public Attributes

static const int BORDER_WIDTH = 2

Protected Types

enum class  ContextMenuAction {
  Remove , Cut , Copy , Paste ,
  Mute
}

Protected Slots

void updateLength ()
 Updates a ClipView's length.
void updatePosition ()
 Updates a ClipView's position.

Protected Member Functions

virtual void constructContextMenu (QMenu *)
void contextMenuEvent (QContextMenuEvent *cme) override
 Set up the context menu for this ClipView.
void contextMenuAction (ContextMenuAction action)
void dragEnterEvent (QDragEnterEvent *dee) override
 Change the ClipView's display when something being dragged enters it.
void dropEvent (QDropEvent *de) override
 Handle something being dropped on this ClipObjectView.
void mousePressEvent (QMouseEvent *me) override
 Handle a mouse press on this ClipView.
void mouseMoveEvent (QMouseEvent *me) override
 Handle a mouse movement (drag) on this ClipView.
void mouseReleaseEvent (QMouseEvent *me) override
 Handle a mouse release on this ClipView.
void resizeEvent (QResizeEvent *re) override
bool unquantizedModHeld (QMouseEvent *me)
TimePos quantizeSplitPos (TimePos)
float pixelsPerBar ()
 How many pixels a bar takes for this ClipView.
DataFile createClipDataFiles (const QVector< ClipView * > &clips) const
 Create a DataFile suitable for copying multiple clips.
virtual void paintTextLabel (QString const &text, QPainter &painter)
auto hasCustomColor () const -> bool
Protected Member Functions inherited from lmms::gui::ModelView
virtual void modelChanged ()
QWidget * widget ()
virtual void doConnections ()

Protected Attributes

TrackViewm_trackView
TimePos m_initialClipPos
TimePos m_initialClipEnd
bool m_marker = false
int m_markerPos = 0

Properties

QColor mutedColor
QColor mutedBackgroundColor
QColor selectedColor
QColor textColor
QColor textBackgroundColor
QColor textShadowColor
QColor patternClipBackground
bool gradient
QColor markerColor

Private Types

enum class  Action {
  None , Move , MoveSelection , Resize ,
  ResizeLeft , Split , CopySelection , ToggleSelected
}

Private Member Functions

void setInitialPos (QPoint pos)
void setInitialOffsets ()
 Save the offsets between all selected tracks and a clicked track.
bool mouseMovedDistance (QMouseEvent *me, int distance)
 Detect whether the mouse moved more than n pixels on screen.
TimePos draggedClipPos (QMouseEvent *me)
 Calculate the new position of a dragged Clip from a mouse event.
int knifeMarkerPos (QMouseEvent *me)
void setColor (const std::optional< QColor > &color)
 Change color of all selected clips.
virtual bool isResizableBeforeStart ()
 Returns whether the user can left-resize this clip so that the start of the clip bounds is before the start of the clip content.
bool splitClip (const TimePos pos)
virtual bool destructiveSplitClip (const TimePos pos)
void updateCursor (QMouseEvent *me)

Private Attributes

Clipm_clip
Action m_action
QPoint m_initialMousePos
QPoint m_initialMouseGlobalPos
QVector< TimePosm_initialOffsets
TextFloatm_hint
QColor m_mutedColor
QColor m_mutedBackgroundColor
QColor m_selectedColor
QColor m_textColor
QColor m_textBackgroundColor
QColor m_textShadowColor
QColor m_patternClipBackground
bool m_gradient
QColor m_markerColor
bool m_needsUpdate

Static Private Attributes

static TextFloats_textFloat = nullptr

Member Enumeration Documentation

◆ Action

enum class lmms::gui::ClipView::Action
strongprivate
Enumerator
None 
Move 
MoveSelection 
Resize 
ResizeLeft 
Split 
CopySelection 
ToggleSelected 

◆ ContextMenuAction

enum class lmms::gui::ClipView::ContextMenuAction
strongprotected
Enumerator
Remove 
Cut 
Copy 
Paste 
Mute 

Constructor & Destructor Documentation

◆ ClipView()

lmms::gui::ClipView::ClipView ( Clip * clip,
TrackView * tv )

Create a new ClipView.

Creates a new clip view for the given clip in the given track view.

Parameters
_clipThe clip to be displayed
_tvThe track view that will contain the new object

◆ ~ClipView()

lmms::gui::ClipView::~ClipView ( )
override

Destroy a ClipView.

Destroys the given ClipView.

Member Function Documentation

◆ close

bool lmms::gui::ClipView::close ( )
virtualslot

Close a ClipView.

Closes a ClipView by asking the track view to remove us and then asking the QWidget to close us.

Returns
Boolean state of whether the QWidget was able to close.

◆ constructContextMenu()

virtual void lmms::gui::ClipView::constructContextMenu ( QMenu * )
inlineprotectedvirtual

◆ contextMenuAction()

void lmms::gui::ClipView::contextMenuAction ( ContextMenuAction action)
protected

◆ contextMenuEvent()

void lmms::gui::ClipView::contextMenuEvent ( QContextMenuEvent * cme)
overrideprotected

Set up the context menu for this ClipView.

Set up the various context menu events that can apply to a ClipView.

Parameters
cmeThe QContextMenuEvent to add the actions to.

◆ copy()

void lmms::gui::ClipView::copy ( QVector< ClipView * > clipvs)

◆ createClipDataFiles()

DataFile lmms::gui::ClipView::createClipDataFiles ( const QVector< ClipView * > & clipViews) const
protected

Create a DataFile suitable for copying multiple clips.

Clips in the vector are written to the "clips" node in the

DataFile. The ClipView's initial mouse position is written to the "initialMouseX" node in the DataFile. When dropped on a track, this is used to create copies of the Clips.

Parameters
clipsThe trackContectObjects to save in a DataFile

◆ cut()

void lmms::gui::ClipView::cut ( QVector< ClipView * > clipvs)

◆ destructiveSplitClip()

virtual bool lmms::gui::ClipView::destructiveSplitClip ( const TimePos pos)
inlineprivatevirtual

Destructively split this Clip into two clips. If the clip type does not implement this feature, it will default to normal splitting.

Parameters
posthe position of the split, relative to the start of the clip
Returns
true if the clip could be split

Reimplemented in lmms::gui::MidiClipView.

◆ dragEnterEvent()

void lmms::gui::ClipView::dragEnterEvent ( QDragEnterEvent * dee)
overrideprotected

Change the ClipView's display when something being dragged enters it.

We need to notify Qt to change our display if something being dragged has entered our 'airspace'.

Parameters
deeThe QDragEnterEvent to watch.

◆ draggedClipPos()

TimePos lmms::gui::ClipView::draggedClipPos ( QMouseEvent * me)
private

Calculate the new position of a dragged Clip from a mouse event.

Parameters
meThe QMouseEvent

◆ dropEvent()

void lmms::gui::ClipView::dropEvent ( QDropEvent * de)
overrideprotected

Handle something being dropped on this ClipObjectView.

When something has been dropped on this ClipView, and it's a clip, then use an instance of our dataFile reader to take the xml of the clip and turn it into something we can write over our current state.

Parameters
deThe QDropEvent to handle.

◆ fixedClips()

bool lmms::gui::ClipView::fixedClips ( )

Does this ClipView have a fixed Clip?

Returns whether the containing trackView has fixed Clips.

Todo
In what circumstance are they fixed?

◆ getClickedClips()

QVector< ClipView * > lmms::gui::ClipView::getClickedClips ( )

◆ getClip()

Clip * lmms::gui::ClipView::getClip ( )
inline

◆ getColorForDisplay()

QColor lmms::gui::ClipView::getColorForDisplay ( QColor defaultColor)

◆ getTrackView()

TrackView * lmms::gui::ClipView::getTrackView ( )
inline

◆ gradient()

bool lmms::gui::ClipView::gradient ( ) const

◆ hasCustomColor()

auto lmms::gui::ClipView::hasCustomColor ( ) const -> bool
protected

◆ isResizableBeforeStart()

virtual bool lmms::gui::ClipView::isResizableBeforeStart ( )
inlineprivatevirtual

Returns whether the user can left-resize this clip so that the start of the clip bounds is before the start of the clip content.

Reimplemented in lmms::gui::AutomationClipView, and lmms::gui::MidiClipView.

◆ knifeMarkerPos()

int lmms::gui::ClipView::knifeMarkerPos ( QMouseEvent * me)
private

◆ markerColor()

QColor lmms::gui::ClipView::markerColor ( ) const

◆ mouseMovedDistance()

bool lmms::gui::ClipView::mouseMovedDistance ( QMouseEvent * me,
int distance )
private

Detect whether the mouse moved more than n pixels on screen.

Parameters
_meThe QMouseEvent.
distanceThe threshold distance that the mouse has moved to return true.

◆ mouseMoveEvent()

void lmms::gui::ClipView::mouseMoveEvent ( QMouseEvent * me)
overrideprotected

Handle a mouse movement (drag) on this ClipView.

Handles the various ways in which a ClipView can be used with a mouse drag.

  • If in move mode, move ourselves in the track,
  • or if in move-selection mode, move the entire selection,
  • or if in resize mode, resize ourselves,
  • otherwise ???
Parameters
meThe QMouseEvent to handle.
Todo
what does the final else case do here?

◆ mousePressEvent()

void lmms::gui::ClipView::mousePressEvent ( QMouseEvent * me)
overrideprotected

Handle a mouse press on this ClipView.

Handles the various ways in which a ClipView can be used with a click of a mouse button.

  • If our container supports rubber band selection then handle selection events.
  • or if shift-left button, add this object to the selection
  • or if ctrl-left button, start a drag-copy event
  • or if just plain left button, resize if we're resizeable
  • or if ctrl-middle button, mute the clip
  • or if middle button, maybe delete the clip.
Parameters
meThe QMouseEvent to handle.

◆ mouseReleaseEvent()

void lmms::gui::ClipView::mouseReleaseEvent ( QMouseEvent * me)
overrideprotected

Handle a mouse release on this ClipView.

If we're in move or resize mode, journal the change as appropriate. Then tidy up.

Parameters
meThe QMouseEvent to handle.

◆ mutedBackgroundColor()

QColor lmms::gui::ClipView::mutedBackgroundColor ( ) const

◆ mutedColor()

QColor lmms::gui::ClipView::mutedColor ( ) const

CSS theming qproperty access method.

◆ needsUpdate()

bool lmms::gui::ClipView::needsUpdate ( )

◆ paintTextLabel()

void lmms::gui::ClipView::paintTextLabel ( QString const & text,
QPainter & painter )
protectedvirtual

◆ paste()

void lmms::gui::ClipView::paste ( )

◆ patternClipBackground()

QColor lmms::gui::ClipView::patternClipBackground ( ) const

◆ pixelsPerBar()

float lmms::gui::ClipView::pixelsPerBar ( )
protected

How many pixels a bar takes for this ClipView.

Returns
the number of pixels per bar.

◆ quantizeSplitPos()

TimePos lmms::gui::ClipView::quantizeSplitPos ( TimePos midiPos)
protected

◆ randomizeColor

void lmms::gui::ClipView::randomizeColor ( )
slot

◆ remove [1/2]

void lmms::gui::ClipView::remove ( )
slot

Removes a ClipView from its track view.

Like the close() method, this asks the track view to remove this ClipView. However, the clip is scheduled for later deletion rather than closed immediately.

◆ remove() [2/2]

void lmms::gui::ClipView::remove ( QVector< ClipView * > clipvs)
static

◆ resetColor

void lmms::gui::ClipView::resetColor ( )
slot

◆ resizeEvent()

void lmms::gui::ClipView::resizeEvent ( QResizeEvent * re)
inlineoverrideprotected

◆ selectColor

void lmms::gui::ClipView::selectColor ( )
slot

◆ selectedColor()

QColor lmms::gui::ClipView::selectedColor ( ) const

◆ setColor()

void lmms::gui::ClipView::setColor ( const std::optional< QColor > & color)
private

Change color of all selected clips.

Parameters
colorThe new color.

◆ setGradient()

void lmms::gui::ClipView::setGradient ( const bool & b)

◆ setInitialOffsets()

void lmms::gui::ClipView::setInitialOffsets ( )
private

Save the offsets between all selected tracks and a clicked track.

◆ setInitialPos()

void lmms::gui::ClipView::setInitialPos ( QPoint pos)
inlineprivate

◆ setMarkerColor()

void lmms::gui::ClipView::setMarkerColor ( const QColor & c)

◆ setMarkerEnabled()

void lmms::gui::ClipView::setMarkerEnabled ( bool e)
inline

◆ setMarkerPos()

void lmms::gui::ClipView::setMarkerPos ( int x)
inline

◆ setMutedBackgroundColor()

void lmms::gui::ClipView::setMutedBackgroundColor ( const QColor & c)

◆ setMutedColor()

void lmms::gui::ClipView::setMutedColor ( const QColor & c)

CSS theming qproperty access method.

◆ setNeedsUpdate()

void lmms::gui::ClipView::setNeedsUpdate ( bool b)

◆ setPatternClipBackground()

void lmms::gui::ClipView::setPatternClipBackground ( const QColor & c)

◆ setSelectedColor()

void lmms::gui::ClipView::setSelectedColor ( const QColor & c)

◆ setTextBackgroundColor()

void lmms::gui::ClipView::setTextBackgroundColor ( const QColor & c)

◆ setTextColor()

void lmms::gui::ClipView::setTextColor ( const QColor & c)

◆ setTextShadowColor()

void lmms::gui::ClipView::setTextShadowColor ( const QColor & c)

◆ splitClip()

bool lmms::gui::ClipView::splitClip ( const TimePos pos)
private

Split this Clip into two clips

Parameters
posthe position of the split, relative to the start of the clip
Returns
true if the clip could be split

◆ textBackgroundColor()

QColor lmms::gui::ClipView::textBackgroundColor ( ) const

◆ textColor()

QColor lmms::gui::ClipView::textColor ( ) const

◆ textShadowColor()

QColor lmms::gui::ClipView::textShadowColor ( ) const

◆ toggleMute()

void lmms::gui::ClipView::toggleMute ( QVector< ClipView * > clipvs)
static

◆ toggleSelectedAutoResize()

void lmms::gui::ClipView::toggleSelectedAutoResize ( )

◆ unquantizedModHeld()

bool lmms::gui::ClipView::unquantizedModHeld ( QMouseEvent * me)
protected

◆ update

void lmms::gui::ClipView::update ( )
overrideslot

Update a ClipView.

Clip's get drawn only when needed, and when a Clip is updated, it needs to be redrawn.

◆ updateCursor()

void lmms::gui::ClipView::updateCursor ( QMouseEvent * me)
private

◆ updateLength

void lmms::gui::ClipView::updateLength ( )
protectedslot

Updates a ClipView's length.

If this ClipView has a fixed Clip, then we must keep the width of our parent. Otherwise, calculate our width from the clip's length in pixels adding in the border.

◆ updatePosition

void lmms::gui::ClipView::updatePosition ( )
protectedslot

Updates a ClipView's position.

Ask our track view to change our position. Then make sure that the track view is updated in case this position has changed the track view's length.

Member Data Documentation

◆ BORDER_WIDTH

const int lmms::gui::ClipView::BORDER_WIDTH = 2
static

◆ m_action

Action lmms::gui::ClipView::m_action
private

◆ m_clip

Clip* lmms::gui::ClipView::m_clip
private

◆ m_gradient

bool lmms::gui::ClipView::m_gradient
private

◆ m_hint

TextFloat* lmms::gui::ClipView::m_hint
private

◆ m_initialClipEnd

TimePos lmms::gui::ClipView::m_initialClipEnd
protected

◆ m_initialClipPos

TimePos lmms::gui::ClipView::m_initialClipPos
protected

◆ m_initialMouseGlobalPos

QPoint lmms::gui::ClipView::m_initialMouseGlobalPos
private

◆ m_initialMousePos

QPoint lmms::gui::ClipView::m_initialMousePos
private

◆ m_initialOffsets

QVector<TimePos> lmms::gui::ClipView::m_initialOffsets
private

◆ m_marker

bool lmms::gui::ClipView::m_marker = false
protected

◆ m_markerColor

QColor lmms::gui::ClipView::m_markerColor
private

◆ m_markerPos

int lmms::gui::ClipView::m_markerPos = 0
protected

◆ m_mutedBackgroundColor

QColor lmms::gui::ClipView::m_mutedBackgroundColor
private

◆ m_mutedColor

QColor lmms::gui::ClipView::m_mutedColor
private

◆ m_needsUpdate

bool lmms::gui::ClipView::m_needsUpdate
private

◆ m_patternClipBackground

QColor lmms::gui::ClipView::m_patternClipBackground
private

◆ m_selectedColor

QColor lmms::gui::ClipView::m_selectedColor
private

◆ m_textBackgroundColor

QColor lmms::gui::ClipView::m_textBackgroundColor
private

◆ m_textColor

QColor lmms::gui::ClipView::m_textColor
private

◆ m_textShadowColor

QColor lmms::gui::ClipView::m_textShadowColor
private

◆ m_trackView

TrackView* lmms::gui::ClipView::m_trackView
protected

◆ s_textFloat

TextFloat * lmms::gui::ClipView::s_textFloat = nullptr
staticprivate

A pointer for that text bubble used when moving segments, etc.

In a number of situations, LMMS displays a floating text bubble beside the cursor as you move or resize elements of a track about. This pointer keeps track of it, as you only ever need one at a time.

Property Documentation

◆ gradient

bool lmms::gui::ClipView::gradient
readwrite

◆ markerColor

QColor lmms::gui::ClipView::markerColor
readwrite

◆ mutedBackgroundColor

QColor lmms::gui::ClipView::mutedBackgroundColor
readwrite

◆ mutedColor

QColor lmms::gui::ClipView::mutedColor
readwrite

◆ patternClipBackground

QColor lmms::gui::ClipView::patternClipBackground
readwrite

◆ selectedColor

QColor lmms::gui::ClipView::selectedColor
readwrite

◆ textBackgroundColor

QColor lmms::gui::ClipView::textBackgroundColor
readwrite

◆ textColor

QColor lmms::gui::ClipView::textColor
readwrite

◆ textShadowColor

QColor lmms::gui::ClipView::textShadowColor
readwrite

The documentation for this class was generated from the following files: