1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include <sal/config.h>
26 #include <vcl/transfer.hxx>
27 #include <vcl/weld.hxx>
28 #include <CustomAnimationEffect.hxx>
30 namespace com::sun::star::drawing
{ class XShape
; }
36 typedef std::shared_ptr
< CustomAnimationEffect
> CustomAnimationEffectPtr
;
38 class ICustomAnimationListController
41 virtual void onSelect() = 0;
42 virtual void onDoubleClick() = 0;
43 virtual void onContextMenu(const OUString
&rIdent
) = 0;
44 virtual void onDragNDropComplete( std::vector
< CustomAnimationEffectPtr
> pEffectsDragged
, CustomAnimationEffectPtr pEffectInsertBefore
) = 0;
45 virtual ~ICustomAnimationListController() {}
48 class CustomAnimationList
;
49 class CustomAnimationListEntryItem
;
51 class CustomAnimationListDropTarget
: public DropTargetHelper
54 CustomAnimationList
& m_rTreeView
;
56 virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& rEvt
) override
;
57 virtual sal_Int8
ExecuteDrop( const ExecuteDropEvent
& rEvt
) override
;
60 CustomAnimationListDropTarget(CustomAnimationList
& rTreeView
);
63 class CustomAnimationList
: public ISequenceListener
65 friend class CustomAnimationListEntryItem
;
66 friend struct stl_append_effect_func
;
69 explicit CustomAnimationList(std::unique_ptr
<weld::TreeView
> xTreeView
,
70 std::unique_ptr
<weld::Label
> xLabel
,
71 std::unique_ptr
<weld::Widget
> xScrolledWindow
);
72 virtual ~CustomAnimationList();
76 /** selects or deselects the given effect.
77 Selections of other effects are not changed */
78 void select( const CustomAnimationEffectPtr
& pEffect
);
80 /** populates the list with all effects from the given MainSequence */
81 void update( const MainSequencePtr
& pMainSequence
);
85 EffectSequence
getSelection() const;
88 void onSelectionChanged(const css::uno::Any
& rSelection
);
92 virtual void notify_change() override
;
94 bool isExpanded( const CustomAnimationEffectPtr
& pEffect
) const;
95 bool isVisible( const CustomAnimationEffectPtr
& pEffect
) const;
97 // clears all entries from the listbox
100 void setController( ICustomAnimationListController
* pController
)
102 mpController
= pController
;
105 sal_Int8
AcceptDrop(const AcceptDropEvent
& rEvt
);
106 sal_Int8
ExecuteDrop(const ExecuteDropEvent
& rEvt
);
108 void set_sensitive(bool bSensitive
) { mxTreeView
->set_sensitive(bSensitive
); }
109 int get_height_rows(int nRows
) { return mxTreeView
->get_height_rows(nRows
); }
110 int get_approximate_digit_width() const { return mxTreeView
->get_approximate_digit_width(); }
111 void set_size_request(int nWidth
, int nHeight
)
113 mxTreeView
->set_size_request(nWidth
, nHeight
);
114 mxEmptyLabel
->set_size_request(nWidth
, nHeight
);
116 void unselect_all() { mxTreeView
->unselect_all(); }
117 weld::TreeView
& get_widget() { return *mxTreeView
; }
119 DECL_LINK(KeyInputHdl
, const KeyEvent
&, bool);
120 DECL_LINK(ExpandHdl
, const weld::TreeIter
&, bool);
121 DECL_LINK(PostExpandHdl
, void*, void);
122 DECL_LINK(CollapseHdl
, const weld::TreeIter
&, bool);
123 DECL_LINK(PostCollapseHdl
, void*, void);
126 std::unique_ptr
<weld::TreeView
> mxTreeView
;
127 CustomAnimationListDropTarget maDropTargetHelper
;
128 std::unique_ptr
<weld::Label
> mxEmptyLabel
;
129 std::unique_ptr
<weld::Widget
> mxEmptyLabelParent
;
130 std::vector
<std::unique_ptr
<CustomAnimationListEntryItem
>> mxEntries
;
131 std::vector
<std::unique_ptr
<weld::TreeIter
>> lastSelectedEntries
;
135 DECL_LINK(SelectHdl
, weld::TreeView
&, void);
136 DECL_LINK(CommandHdl
, const CommandEvent
&, bool);
137 DECL_LINK(DoubleClickHdl
, weld::TreeView
&, bool);
138 DECL_LINK(DragBeginHdl
, bool&, bool);
139 DECL_STATIC_LINK(CustomAnimationList
, CustomRenderHdl
, weld::TreeView::render_args
, void);
140 DECL_STATIC_LINK(CustomAnimationList
, CustomGetSizeHdl
, weld::TreeView::get_size_args
, Size
);
142 void ExecuteContextMenuAction(const OUString
& rSelectedPopupEntry
);
144 /** appends the given effect to the list*/
145 void append( CustomAnimationEffectPtr pEffect
);
147 ICustomAnimationListController
* mpController
;
149 MainSequencePtr mpMainSequence
;
151 css::uno::Reference
< css::drawing::XShape
> mxLastTargetShape
;
152 sal_Int32 mnLastGroupId
;
153 ImplSVEvent
* mnPostExpandEvent
;
154 ImplSVEvent
* mnPostCollapseEvent
;
156 std::unique_ptr
<weld::TreeIter
> mxLastParentEntry
;
159 std::unique_ptr
<weld::TreeIter
> mxDndEffectDragging
;
160 std::vector
<std::unique_ptr
<weld::TreeIter
>> mDndEffectsSelected
;
163 OUString
getPropertyName( sal_Int32 nPropertyType
);
165 OUString
getShapeDescription( const css::uno::Reference
< css::drawing::XShape
>& xShape
, bool bWithText
);
169 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */