Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
VLMC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
luyikei
VLMC
Commits
b951d8b1
Commit
b951d8b1
authored
Dec 11, 2009
by
Hugo Beauzee-Luyssen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Undo redo is functionnal for clip resizing
parent
89874426
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
106 additions
and
22 deletions
+106
-22
src/Actions/StackedAction.hpp
src/Actions/StackedAction.hpp
+22
-0
src/Commands/Commands.cpp
src/Commands/Commands.cpp
+20
-11
src/Commands/Commands.h
src/Commands/Commands.h
+24
-6
src/GUI/AbstractGraphicsMediaItem.cpp
src/GUI/AbstractGraphicsMediaItem.cpp
+11
-2
src/GUI/TracksView.cpp
src/GUI/TracksView.cpp
+7
-0
src/GUI/TracksView.h
src/GUI/TracksView.h
+2
-0
src/Media/Clip.cpp
src/Media/Clip.cpp
+2
-0
src/Renderer/WorkflowRenderer.cpp
src/Renderer/WorkflowRenderer.cpp
+11
-2
src/Renderer/WorkflowRenderer.h
src/Renderer/WorkflowRenderer.h
+6
-1
src/Workflow/MainWorkflow.h
src/Workflow/MainWorkflow.h
+1
-0
No files found.
src/Actions/StackedAction.hpp
View file @
b951d8b1
...
...
@@ -39,6 +39,7 @@ namespace Action
Resize
,
Remove
,
Add
,
Move
,
};
Generic
(
Type
type
)
:
m_type
(
type
)
{}
virtual
~
Generic
(){}
...
...
@@ -108,6 +109,27 @@ namespace Action
QUuid
m_uuid
;
};
class
MoveClip
:
public
Track
{
public:
MoveClip
(
MainWorkflow
*
mainWorkflow
,
const
QUuid
&
uuid
,
uint32_t
oldTrack
,
uint32_t
newTrack
,
qint64
newPos
,
MainWorkflow
::
TrackType
trackType
,
bool
undoRedoAction
)
:
Track
(
mainWorkflow
,
oldTrack
,
trackType
,
Move
),
m_uuid
(
uuid
),
m_newTrack
(
newTrack
),
m_newPos
(
newPos
),
m_undoRedoAction
(
undoRedoAction
)
{
}
void
execute
()
{
m_mainWorkflow
->
moveClip
(
m_uuid
,
m_trackId
,
m_newTrack
,
m_newPos
,
m_trackType
,
m_undoRedoAction
);
}
private:
QUuid
m_uuid
;
uint32_t
m_newTrack
;
qint64
m_newPos
;
bool
m_undoRedoAction
;
};
class
ResizeClip
:
public
Generic
{
public:
...
...
src/Commands/Commands.cpp
View file @
b951d8b1
...
...
@@ -102,28 +102,37 @@ void Commands::MainWorkflow::RemoveClips::undo()
m_renderer
->
addClip
(
m_clips
.
at
(
i
).
clip
,
m_clips
.
at
(
i
).
trackNumber
,
m_clips
.
at
(
i
).
pos
,
m_clips
.
at
(
i
).
trackType
);
}
Commands
::
MainWorkflow
::
ResizeClip
::
ResizeClip
(
::
MainWorkflow
*
mainWorkflow
,
const
QUuid
&
uuid
,
unsigned
int
trackId
,
qint64
newBegin
,
qint64
newEnd
,
::
MainWorkflow
::
TrackType
trackType
)
:
m_mainWorkflow
(
mainWorkflow
),
Commands
::
MainWorkflow
::
ResizeClip
::
ResizeClip
(
WorkflowRenderer
*
renderer
,
const
QUuid
&
uuid
,
qint64
newBegin
,
qint64
newEnd
,
qint64
oldBegin
,
qint64
oldEnd
,
qint64
newPos
,
qint64
oldPos
,
uint32_t
trackId
,
::
MainWorkflow
::
TrackType
trackType
)
:
m_renderer
(
renderer
),
m_uuid
(
uuid
),
m_newBegin
(
newBegin
),
m_newEnd
(
newEnd
),
m_trackType
(
trackType
)
m_oldBegin
(
oldBegin
),
m_oldEnd
(
oldEnd
),
m_newPos
(
newPos
),
m_oldPos
(
oldPos
),
m_trackId
(
trackId
),
m_trackType
(
trackType
),
m_undoRedoAction
(
false
)
{
m_clip
=
mainWorkflow
->
getClip
(
uuid
,
trackId
,
m_trackType
);
m_oldBegin
=
m_clip
->
getBegin
();
m_oldEnd
=
m_clip
->
getEnd
();
m_clip
=
::
MainWorkflow
::
getInstance
()
->
getClip
(
uuid
,
trackId
,
m_trackType
);
setText
(
QObject
::
tr
(
"Resizing clip"
)
);
}
void
Commands
::
MainWorkflow
::
ResizeClip
::
redo
()
{
m_
clip
->
setBegin
(
m_newBegi
n
);
m_
clip
->
setEnd
(
m_newEnd
)
;
m_
renderer
->
resizeClip
(
m_clip
,
m_newBegin
,
m_newEnd
,
m_newPos
,
m_trackId
,
m_trackType
,
m_undoRedoActio
n
);
m_
undoRedoAction
=
true
;
}
void
Commands
::
MainWorkflow
::
ResizeClip
::
undo
()
{
m_clip
->
setBegin
(
m_oldBegin
);
m_clip
->
setEnd
(
m_oldEnd
);
m_renderer
->
resizeClip
(
m_clip
,
m_oldBegin
,
m_oldEnd
,
m_oldPos
,
m_trackId
,
m_trackType
,
m_undoRedoAction
);
}
Commands
::
MainWorkflow
::
SplitClip
::
SplitClip
(
WorkflowRenderer
*
renderer
,
Clip
*
toSplit
,
uint32_t
trackId
,
...
...
src/Commands/Commands.h
View file @
b951d8b1
...
...
@@ -95,22 +95,40 @@ namespace Commands
QVector
<
ClipActionInfo
>
m_clips
;
};
/**
* \brief This command is used to resize a clip.
* \param renderer: The workflow renderer
* \param uuid: The clip's uuid
* \param newBegin: The clip's new beginning
* \param newEnd: The clip's new end
* \param newPos: if the clip was resized from the beginning, it is moved
* so we have to know its new position
* \param trackId:The track in which the modification occurs. This is only
* used when the clip is resized from the beginning.
* \param trackType: The track's type (Audio or Video)
*/
NEW_COMMAND
(
ResizeClip
)
{
public:
ResizeClip
(
::
MainWorkflow
*
mainWorkflow
,
const
QUuid
&
uuid
,
unsigned
int
trackId
,
qint64
newBegin
,
qint64
newEnd
,
::
MainWorkflow
::
TrackType
trackType
);
ResizeClip
(
WorkflowRenderer
*
renderer
,
const
QUuid
&
uuid
,
qint64
newBegin
,
qint64
newEnd
,
qint64
oldBegin
,
qint64
oldEnd
,
qint64
newPos
,
qint64
oldPos
,
uint32_t
trackId
,
::
MainWorkflow
::
TrackType
trackType
);
virtual
void
redo
();
virtual
void
undo
();
private:
::
MainWorkflow
*
m_mainWorkflow
;
qint64
m_oldBegin
;
qint64
m_oldEnd
;
WorkflowRenderer
*
m_renderer
;
QUuid
m_uuid
;
qint64
m_newBegin
;
qint64
m_newEnd
;
qint64
m_oldBegin
;
qint64
m_oldEnd
;
qint64
m_newPos
;
qint64
m_oldPos
;
uint32_t
m_trackId
;
Clip
*
m_clip
;
::
MainWorkflow
::
TrackType
m_trackType
;
bool
m_undoRedoAction
;
};
NEW_COMMAND
(
SplitClip
)
...
...
src/GUI/AbstractGraphicsMediaItem.cpp
View file @
b951d8b1
...
...
@@ -21,6 +21,9 @@
*****************************************************************************/
#include "AbstractGraphicsMediaItem.h"
#include "TracksView.h"
#include "Commands.h"
AbstractGraphicsMediaItem
::
AbstractGraphicsMediaItem
()
:
oldTrackNumber
(
-
1
),
oldPosition
(
-
1
),
m_tracksView
(
NULL
),
...
...
@@ -106,7 +109,11 @@ void AbstractGraphicsMediaItem::resize( qint64 size, From from )
if
(
size
<
0
)
return
;
if
(
from
==
BEGINNING
)
clip
()
->
setEnd
(
clip
()
->
getBegin
()
+
size
);
{
// clip()->setEnd( clip()->getBegin() + size );
tracksView
()
->
getRenderer
()
->
resizeClip
(
clip
(),
clip
()
->
getBegin
(),
clip
()
->
getBegin
()
+
size
,
boundingRect
().
x
(),
trackNumber
(),
MainWorkflow
::
VideoTrack
);
}
else
{
qint64
oldLength
=
clip
()
->
getLength
();
...
...
@@ -115,7 +122,9 @@ void AbstractGraphicsMediaItem::resize( qint64 size, From from )
qWarning
(
"Warning: resizing a region with a size below 0"
);
size
+=
clip
()
->
getEnd
()
-
size
;
}
clip
()
->
setBegin
(
qMax
(
clip
()
->
getEnd
()
-
size
,
(
qint64
)
0
)
);
// clip()->setBegin( qMax( clip()->getEnd() - size, (qint64)0 ) );
tracksView
()
->
getRenderer
()
->
resizeClip
(
clip
(),
qMax
(
clip
()
->
getEnd
()
-
size
,
(
qint64
)
0
),
clip
()
->
getEnd
(),
startPos
()
+
(
oldLength
-
size
),
trackNumber
(),
MainWorkflow
::
VideoTrack
);
setStartPos
(
startPos
()
+
(
oldLength
-
size
)
);
}
...
...
src/GUI/TracksView.cpp
View file @
b951d8b1
...
...
@@ -569,6 +569,7 @@ void TracksView::mousePressEvent( QMouseEvent* event )
m_actionResize
=
true
;
m_actionResizeStart
=
mapToScene
(
event
->
pos
()
).
x
();
m_actionResizeBase
=
item
->
clip
()
->
getLength
();
m_actionResizeOldBegin
=
item
->
clip
()
->
getBegin
();
m_actionItem
=
item
;
}
else
if
(
item
->
moveable
()
)
...
...
@@ -627,6 +628,12 @@ void TracksView::mouseReleaseEvent( QMouseEvent* event )
}
else
if
(
m_actionResize
)
{
Clip
*
clip
=
m_actionItem
->
clip
();
//This is a "pointless action". The resize already occured. However, by doing this
//we can have an undo action.
Commands
::
trigger
(
new
Commands
::
MainWorkflow
::
ResizeClip
(
m_renderer
,
clip
->
getUuid
(),
clip
->
getBegin
(),
clip
->
getEnd
(),
m_actionResizeOldBegin
,
m_actionResizeOldBegin
+
m_actionResizeBase
,
m_actionItem
->
pos
().
x
(),
m_actionResizeStart
,
m_actionItem
->
trackNumber
(),
MainWorkflow
::
VideoTrack
)
);
updateDuration
();
}
...
...
src/GUI/TracksView.h
View file @
b951d8b1
...
...
@@ -61,6 +61,7 @@ public:
void
removeMediaItem
(
const
QList
<
AbstractGraphicsMediaItem
*>&
items
);
void
setTool
(
ToolButtons
button
);
ToolButtons
tool
()
{
return
m_tool
;
}
WorkflowRenderer
*
getRenderer
()
{
return
m_renderer
;
}
public
slots
:
void
clear
();
...
...
@@ -112,6 +113,7 @@ private:
bool
m_actionResize
;
qint64
m_actionResizeStart
;
qint64
m_actionResizeBase
;
qint64
m_actionResizeOldBegin
;
AbstractGraphicsMediaItem
::
From
m_actionResizeType
;
int
m_actionRelativeX
;
AbstractGraphicsMediaItem
*
m_actionItem
;
...
...
src/Media/Clip.cpp
View file @
b951d8b1
...
...
@@ -184,6 +184,8 @@ void Clip::setEnd( qint64 end )
void
Clip
::
setBoundaries
(
qint64
newBegin
,
qint64
newEnd
)
{
Q_ASSERT
(
newBegin
<
newEnd
);
if
(
newBegin
==
m_begin
&&
m_end
==
newEnd
)
return
;
m_begin
=
newBegin
;
m_end
=
newEnd
;
computeLength
();
...
...
src/Renderer/WorkflowRenderer.cpp
View file @
b951d8b1
...
...
@@ -312,16 +312,25 @@ void WorkflowRenderer::unsplit( Clip* origin, Clip* splitted, uint32_t trackI
}
}
void
WorkflowRenderer
::
resizeClip
(
Clip
*
clip
,
qint64
newBegin
,
qint64
newEnd
)
void
WorkflowRenderer
::
resizeClip
(
Clip
*
clip
,
qint64
newBegin
,
qint64
newEnd
,
qint64
newPos
,
uint32_t
trackId
,
MainWorkflow
::
TrackType
trackType
,
bool
undoRedoAction
/*= false*/
)
{
if
(
m_isRendering
==
true
)
{
Action
::
Generic
*
act
=
new
Action
::
ResizeClip
(
clip
,
newBegin
,
newEnd
);
Action
::
Generic
*
act
=
new
Action
::
ResizeClip
(
clip
,
newBegin
,
newEnd
);
Action
::
Generic
*
act2
=
new
Action
::
MoveClip
(
m_mainWorkflow
,
clip
->
getUuid
(),
trackId
,
trackId
,
newPos
,
trackType
,
undoRedoAction
);
QMutexLocker
lock
(
m_actionsMutex
);
m_actions
.
addAction
(
act
);
m_actions
.
addAction
(
act2
);
}
else
{
if
(
newBegin
!=
clip
->
getBegin
()
)
{
m_mainWorkflow
->
moveClip
(
clip
->
getUuid
(),
trackId
,
trackId
,
newPos
,
trackType
,
undoRedoAction
);
}
clip
->
setBoundaries
(
newBegin
,
newEnd
);
}
}
/////////////////////////////////////////////////////////////////////
...
...
src/Renderer/WorkflowRenderer.h
View file @
b951d8b1
...
...
@@ -53,7 +53,12 @@ class WorkflowRenderer : public GenericRenderer
void
removeClip
(
const
QUuid
&
uuid
,
uint32_t
trackId
,
MainWorkflow
::
TrackType
trackType
);
Clip
*
split
(
Clip
*
toSplit
,
uint32_t
trackId
,
qint64
newClipPos
,
qint64
newClipBegin
,
MainWorkflow
::
TrackType
trackType
);
void
unsplit
(
Clip
*
origin
,
Clip
*
splitted
,
uint32_t
trackId
,
qint64
oldEnd
,
MainWorkflow
::
TrackType
trackType
);
void
resizeClip
(
Clip
*
clip
,
qint64
newBegin
,
qint64
newEnd
);
/**
* \param undoRedoAction: if true, the potential move resulting from the resize will be emmited to the GUI.
* if this is not an undo redo action, the GUI is already aware of the move.
*/
void
resizeClip
(
Clip
*
clip
,
qint64
newBegin
,
qint64
newEnd
,
qint64
newPos
,
uint32_t
trackId
,
MainWorkflow
::
TrackType
trackType
,
bool
undoRedoAction
=
false
);
static
void
*
lock
(
void
*
datas
);
static
void
*
lockAudio
(
void
*
datas
);
...
...
src/Workflow/MainWorkflow.h
View file @
b951d8b1
...
...
@@ -99,6 +99,7 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
void
previousFrame
();
Clip
*
removeClip
(
const
QUuid
&
uuid
,
unsigned
int
trackId
,
MainWorkflow
::
TrackType
trackType
);
void
moveClip
(
const
QUuid
&
uuid
,
unsigned
int
oldTrack
,
unsigned
int
newTrack
,
qint64
pos
,
MainWorkflow
::
TrackType
trackType
,
bool
undoRedoCommand
=
false
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment