Kaydet (Commit) 759ee18f authored tarafından Brian Fraser's avatar Brian Fraser Kaydeden (comit) Thorsten Behrens

tdf#37483 Add drag'n'drop to reorder custom Impress animations

- Support drag'n'drop of single items. If the animation is collapsed,
  it will move its collapsed sub-animations as well.
- Sub-lists remain expanded when its parent animation is moved, or
  a sub animation becomes the new parent of the text group (due to moving).
- Maintain the cursor between custom animation list redraws.
- Don't change selection on collapse after custom animation list
  rebuild.

Change-Id: I92d96e9a01c6884ef739612e456cc541218b6ebb
Reviewed-on: https://gerrit.libreoffice.org/62342Reviewed-by: 's avatarThorsten Behrens <Thorsten.Behrens@CIB.de>
Tested-by: 's avatarThorsten Behrens <Thorsten.Behrens@CIB.de>
üst 525ed5d1
......@@ -277,6 +277,7 @@ public:
SAL_DLLPRIVATE void replace( const CustomAnimationEffectPtr& pEffect, const CustomAnimationPresetPtr& pDescriptor, double fDuration );
SAL_DLLPRIVATE void replace( const CustomAnimationEffectPtr& pEffect, const CustomAnimationPresetPtr& pDescriptor, const OUString& rPresetSubType, double fDuration );
SAL_DLLPRIVATE void remove( const CustomAnimationEffectPtr& pEffect );
SAL_DLLPRIVATE void moveToBeforeEffect( const CustomAnimationEffectPtr& pEffect, const CustomAnimationEffectPtr& pInsertBefore);
SAL_DLLPRIVATE void create( const css::uno::Reference< css::animations::XAnimationNode >& xNode );
SAL_DLLPRIVATE void createEffectsequence( const css::uno::Reference< css::animations::XAnimationNode >& xNode );
......
......@@ -1790,6 +1790,20 @@ void EffectSequenceHelper::remove( const CustomAnimationEffectPtr& pEffect )
rebuild();
}
void EffectSequenceHelper::moveToBeforeEffect( const CustomAnimationEffectPtr& pEffect, const CustomAnimationEffectPtr& pInsertBefore)
{
if ( pEffect.get() )
{
maEffects.remove( pEffect );
EffectSequence::iterator aInsertIter( find( pInsertBefore ) );
// aInsertIter being end() is OK: pInsertBefore could be null, so put at end.
maEffects.insert( aInsertIter, pEffect );
rebuild();
}
}
void EffectSequenceHelper::rebuild()
{
implRebuild();
......
......@@ -40,6 +40,7 @@ public:
virtual void onSelect() = 0;
virtual void onDoubleClick() = 0;
virtual void onContextMenu(const OString &rIdent) = 0;
virtual void onDragNDropComplete( CustomAnimationEffectPtr pEffectDragged, CustomAnimationEffectPtr pEffectInsertBefore ) = 0;
virtual ~ICustomAnimationListController() {}
};
......@@ -83,8 +84,9 @@ public:
virtual void notify_change() override;
bool isExpanded( const CustomAnimationEffectPtr& pEffect ) const;
bool isVisible( const CustomAnimationEffectPtr& pEffect ) const;
/// clears all entries from the listbox
// clears all entries from the listbox
void clear();
void setController( ICustomAnimationListController* pController )
......@@ -92,6 +94,15 @@ public:
mpController = pController;
};
protected:
// drag & drop
virtual DragDropMode NotifyStartDrag( TransferDataContainer& rData, SvTreeListEntry* pEntry ) override;
virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override;
virtual void ReorderEffectsInUiDuringDragOver( SvTreeListEntry* pOverEntry);
virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override;
virtual void DragFinished( sal_Int8 nDropAction ) override;
private:
std::unique_ptr<VclBuilder> mxBuilder;
VclPtr<PopupMenu> mxMenu;
......@@ -109,6 +120,9 @@ private:
sal_Int32 mnLastGroupId;
SvTreeListEntry* mpLastParentEntry;
// drag & drop
SvTreeListEntry* mpDndEffectDragging;
SvTreeListEntry* mpDndEffectInsertBefore;
};
OUString getPropertyName( sal_Int32 nPropertyType );
......
......@@ -2509,6 +2509,39 @@ void CustomAnimationPane::onSelect()
}
}
// ICustomAnimationListController
// pEffectInsertBefore may be null if moving to end of list.
void CustomAnimationPane::onDragNDropComplete(CustomAnimationEffectPtr pEffectDragged, CustomAnimationEffectPtr pEffectInsertBefore)
{
if ( mpMainSequence.get() )
{
addUndo();
MainSequenceRebuildGuard aGuard( mpMainSequence );
// Move the dragged effect and any hidden sub-effects
EffectSequence::iterator aIter = mpMainSequence->find( pEffectDragged );
const EffectSequence::iterator aEnd( mpMainSequence->getEnd() );
while( aIter != aEnd )
{
CustomAnimationEffectPtr pEffect = (*aIter++);
// Update model with new location (function triggers a rebuild)
// target may be null, which will insert at the end.
mpMainSequence->moveToBeforeEffect( pEffect, pEffectInsertBefore );
// Done moving effect and its hidden sub-effects when *next* effect is visible.
if ( mpCustomAnimationList->isVisible( *aIter ) )
break;
}
updateControls();
mrBase.GetDocShell()->SetModified();
}
}
void CustomAnimationPane::updatePathFromMotionPathTag( const rtl::Reference< MotionPathTag >& xTag )
{
MainSequenceRebuildGuard aGuard( mpMainSequence );
......
......@@ -88,6 +88,7 @@ public:
virtual void onSelect() override;
virtual void onDoubleClick() override;
virtual void onContextMenu(const OString& rIdent) override;
virtual void onDragNDropComplete( CustomAnimationEffectPtr pEffectDragged, CustomAnimationEffectPtr pEffectInsertBefore ) override;
// Window
virtual void DataChanged (const DataChangedEvent& rEvent) override;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment