bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / slidesorter / inc / controller / SlsInsertionIndicatorHandler.hxx
blobd4084e6cc90da615e6392a5c28e88c1f545b7c5c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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"
26 #include "sdxfer.hxx"
28 namespace sd { namespace slidesorter { class SlideSorter; } }
29 namespace sd { namespace slidesorter { namespace view {
30 class InsertAnimator;
31 class InsertionIndicatorOverlay;
32 } } }
34 namespace sd { namespace slidesorter { namespace controller {
36 class Transferable;
38 /** Manage the visibility and location of the insertion indicator. Its
39 actual display is controlled by the InsertionIndicatorOverlay.
41 class InsertionIndicatorHandler
43 public:
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
64 public:
65 ForceShowContext (const ::boost::shared_ptr<InsertionIndicatorHandler>& rpHandler);
66 ~ForceShowContext();
67 private:
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.
78 void UpdatePosition (
79 const Point& rMouseModelPosition,
80 const Mode eMode);
81 void UpdatePosition (
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);
108 private:
109 SlideSorter& mrSlideSorter;
110 ::boost::shared_ptr<view::InsertAnimator> mpInsertAnimator;
111 ::boost::shared_ptr<view::InsertionIndicatorOverlay> mpInsertionIndicatorOverlay;
112 view::InsertPosition maInsertPosition;
113 Mode meMode;
114 bool mbIsInsertionTrivial;
115 bool mbIsActive;
116 bool mbIsReadOnly;
117 bool mbIsOverSourceView;
118 Size maIconSize;
119 bool mbIsForcedShow;
121 void SetPosition (
122 const Point& rPoint,
123 const Mode eMode);
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.
134 void ForceShow();
135 void ForceEnd();
138 } } } // end of namespace ::sd::slidesorter::controller
140 #endif
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */