bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / slidesorter / inc / controller / SlsInsertionIndicatorHandler.hxx
blobb16e3d3e67fd5d3f0c0ef37c5be3c6b0c61a8ec1
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 <controller/SlsAnimator.hxx>
25 #include <view/SlsLayouter.hxx>
27 namespace sd { namespace slidesorter { class SlideSorter; } }
28 namespace sd { namespace slidesorter { namespace view {
29 class InsertAnimator;
30 class InsertionIndicatorOverlay;
31 } } }
33 class SdTransferable;
35 namespace sd { namespace slidesorter { namespace controller {
37 /** Manage the visibility and location of the insertion indicator. Its
38 actual display is controlled by the InsertionIndicatorOverlay.
40 class InsertionIndicatorHandler
42 public:
43 InsertionIndicatorHandler (SlideSorter& rSlideSorter);
44 ~InsertionIndicatorHandler() COVERITY_NOEXCEPT_FALSE;
46 enum Mode { CopyMode, MoveMode, UnknownMode };
47 static Mode GetModeFromDndAction (const sal_Int8 nDndAction);
49 /** Activate the insertion marker at the given coordinates.
51 void Start (const bool bIsOverSourceView);
53 /** Deactivate the insertion marker.
55 void End (const controller::Animator::AnimationMode eMode);
57 /** This context make sure that the insertion indicator is shown
58 (provided that the clipboard is not empty) while the context is
59 alive. Typically used while a context menu is displayed.
61 class ForceShowContext
63 public:
64 ForceShowContext (const std::shared_ptr<InsertionIndicatorHandler>& rpHandler);
65 ~ForceShowContext() COVERITY_NOEXCEPT_FALSE;
66 private:
67 const std::shared_ptr<InsertionIndicatorHandler> mpHandler;
70 /** Update the indicator icon from the current transferable (from the
71 clipboard or an active drag and drop operation.)
73 void UpdateIndicatorIcon (const SdTransferable* pTransferable);
75 /** Set the position of the insertion marker to the given coordinates.
77 void UpdatePosition (
78 const Point& rMouseModelPosition,
79 const Mode eMode);
80 void UpdatePosition (
81 const Point& rMouseModelPosition,
82 const sal_Int8 nDndAction);
84 /** Return whether the insertion marker is active.
86 bool IsActive() const { return mbIsActive;}
88 /** Return the insertion index that corresponds with the current
89 graphical location of the insertion indicator.
91 sal_Int32 GetInsertionPageIndex() const;
93 /** Determine whether moving the current selection to the current
94 position of the insertion marker would alter the document. This
95 would be the case when the selection is not consecutive or would be
96 moved to a position outside and not adjacent to the selection.
98 bool IsInsertionTrivial (
99 const sal_Int32 nInsertionIndex,
100 const Mode eMode) const;
101 /** This method is like the other variant. It operates implicitly
102 on the current insertion index as would be returned by
103 GetInsertionPageIndex().
105 bool IsInsertionTrivial (const sal_Int8 nDndAction);
107 private:
108 SlideSorter& mrSlideSorter;
109 std::shared_ptr<view::InsertAnimator> mpInsertAnimator;
110 std::shared_ptr<view::InsertionIndicatorOverlay> mpInsertionIndicatorOverlay;
111 view::InsertPosition maInsertPosition;
112 Mode meMode;
113 bool mbIsInsertionTrivial;
114 bool mbIsActive;
115 bool mbIsReadOnly;
116 bool mbIsOverSourceView;
117 Size maIconSize;
118 bool mbIsForcedShow;
120 void SetPosition (
121 const Point& rPoint,
122 const Mode eMode);
123 std::shared_ptr<view::InsertAnimator> const & GetInsertAnimator();
125 /** Make the insertion indicator visible (that is the show part) and
126 keep it visible, even when the mouse leaves the window (that is the
127 force part). We need this when a context menu is displayed (mouse
128 over the popup menu triggers a mouse leave event) while the
129 insertion indicator remains visible in the background.
131 In effect all calls to End() are ignored until ForceEnd() is called.
133 void ForceShow();
134 void ForceEnd();
137 } } } // end of namespace ::sd::slidesorter::controller
139 #endif
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */