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 .
20 #ifndef INCLUDED_SD_SOURCE_UI_SLIDESORTER_INC_CONTROLLER_SLSINSERTIONINDICATORHANDLER_HXX
21 #define INCLUDED_SD_SOURCE_UI_SLIDESORTER_INC_CONTROLLER_SLSINSERTIONINDICATORHANDLER_HXX
23 #include "view/SlsInsertAnimator.hxx"
25 #include "view/SlsLayouter.hxx"
28 namespace sd
{ namespace slidesorter
{ class SlideSorter
; } }
29 namespace sd
{ namespace slidesorter
{ namespace view
{
31 class InsertionIndicatorOverlay
;
34 namespace sd
{ namespace slidesorter
{ namespace controller
{
38 /** Manage the visibility and location of the insertion indicator. Its
39 actual display is controlled by the InsertionIndicatorOverlay.
41 class InsertionIndicatorHandler
44 InsertionIndicatorHandler (SlideSorter
& rSlideSorter
);
45 ~InsertionIndicatorHandler();
47 enum Mode
{ CopyMode
, MoveMode
, UnknownMode
};
48 static Mode
GetModeFromDndAction (const sal_Int8 nDndAction
);
50 /** Activate the insertion marker at the given coordinates.
52 void Start (const bool bIsOverSourceView
);
54 /** Deactivate the insertion marker.
56 void End (const controller::Animator::AnimationMode eMode
);
58 /** This context make sure that the insertion indicator is shown
59 (provided that the clipboard is not empty) while the context is
60 alive. Typically used while a context menu is displayed.
62 class ForceShowContext
65 ForceShowContext (const ::boost::shared_ptr
<InsertionIndicatorHandler
>& rpHandler
);
68 const ::boost::shared_ptr
<InsertionIndicatorHandler
> mpHandler
;
71 /** Update the indicator icon from the current transferable (from the
72 clipboard or an active drag and drop operation.)
74 void UpdateIndicatorIcon (const SdTransferable
* pTransferable
);
76 /** Set the position of the insertion marker to the given coordinates.
79 const Point
& rMouseModelPosition
,
82 const Point
& rMouseModelPosition
,
83 const sal_Int8 nDndAction
);
85 /** Return whether the insertion marker is active.
87 bool IsActive() const { return mbIsActive
;}
89 /** Return the insertion index that corresponds with the current
90 graphical location of the insertion indicator.
92 sal_Int32
GetInsertionPageIndex() const;
94 /** Determine whether moving the current selection to the current
95 position of the insertion marker would alter the document. This
96 would be the case when the selection is not consecutive or would be
97 moved to a position outside and not adjacent to the selection.
99 bool IsInsertionTrivial (
100 const sal_Int32 nInsertionIndex
,
101 const Mode eMode
) const;
102 /** This method is like the other variant. It operates implicitly
103 on the current insertion index as would be returned by
104 GetInsertionPageIndex().
106 bool IsInsertionTrivial (const sal_Int8 nDndAction
);
109 SlideSorter
& mrSlideSorter
;
110 ::boost::shared_ptr
<view::InsertAnimator
> mpInsertAnimator
;
111 ::boost::shared_ptr
<view::InsertionIndicatorOverlay
> mpInsertionIndicatorOverlay
;
112 view::InsertPosition maInsertPosition
;
114 bool mbIsInsertionTrivial
;
117 bool mbIsOverSourceView
;
124 ::boost::shared_ptr
<view::InsertAnimator
> GetInsertAnimator();
126 /** Make the insertion indicator visible (that is the show part) and
127 keep it visible, even when the mouse leaves the window (that is the
128 force part). We need this when a context menu is displayed (mouse
129 over the popup menu triggers a mouse leave event) while the
130 insertion indicator remains visible in the background.
132 In effect all calls to End() are ignored until ForceEnd() is called.
138 } } } // end of namespace ::sd::slidesorter::controller
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */