tdf#147067 Jump to clicked spot if left mouse click with Option key
[LibreOffice.git] / sd / source / ui / slidesorter / inc / controller / SlsInsertionIndicatorHandler.hxx
blob3109288822c899b7771e792242053dfb10699505
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 #pragma once
22 #include <controller/SlsAnimator.hxx>
24 #include <view/SlsLayouter.hxx>
26 namespace sd::slidesorter { class SlideSorter; }
27 namespace sd::slidesorter::view {
28 class InsertAnimator;
29 class InsertionIndicatorOverlay;
32 class SdTransferable;
34 namespace sd::slidesorter::controller {
36 /** Manage the visibility and location of the insertion indicator. Its
37 actual display is controlled by the InsertionIndicatorOverlay.
39 class InsertionIndicatorHandler
41 public:
42 InsertionIndicatorHandler (SlideSorter& rSlideSorter);
43 ~InsertionIndicatorHandler() COVERITY_NOEXCEPT_FALSE;
45 enum Mode { CopyMode, MoveMode, UnknownMode };
46 static Mode GetModeFromDndAction (const sal_Int8 nDndAction);
48 /** Activate the insertion marker at the given coordinates.
50 void Start (const bool bIsOverSourceView);
52 /** Deactivate the insertion marker.
54 void End (const controller::Animator::AnimationMode eMode);
56 /** This context make sure that the insertion indicator is shown
57 (provided that the clipboard is not empty) while the context is
58 alive. Typically used while a context menu is displayed.
60 class ForceShowContext
62 public:
63 ForceShowContext (std::shared_ptr<InsertionIndicatorHandler> pHandler);
64 ~ForceShowContext() COVERITY_NOEXCEPT_FALSE;
65 private:
66 const std::shared_ptr<InsertionIndicatorHandler> mpHandler;
69 /** Update the indicator icon from the current transferable (from the
70 clipboard or an active drag and drop operation.)
72 void UpdateIndicatorIcon (const SdTransferable* pTransferable);
74 /** Set the position of the insertion marker to the given coordinates.
76 void UpdatePosition (
77 const Point& rMouseModelPosition,
78 const Mode eMode);
79 void UpdatePosition (
80 const Point& rMouseModelPosition,
81 const sal_Int8 nDndAction);
83 /** Return whether the insertion marker is active.
85 bool IsActive() const { return mbIsActive;}
87 /** Return the insertion index that corresponds with the current
88 graphical location of the insertion indicator.
90 sal_Int32 GetInsertionPageIndex() const;
92 /** Determine whether moving the current selection to the current
93 position of the insertion marker would alter the document. This
94 would be the case when the selection is not consecutive or would be
95 moved to a position outside and not adjacent to the selection.
97 bool IsInsertionTrivial (
98 const sal_Int32 nInsertionIndex,
99 const Mode eMode) const;
100 /** This method is like the other variant. It operates implicitly
101 on the current insertion index as would be returned by
102 GetInsertionPageIndex().
104 bool IsInsertionTrivial (const sal_Int8 nDndAction);
106 private:
107 SlideSorter& mrSlideSorter;
108 std::shared_ptr<view::InsertAnimator> mpInsertAnimator;
109 std::shared_ptr<view::InsertionIndicatorOverlay> mpInsertionIndicatorOverlay;
110 view::InsertPosition maInsertPosition;
111 Mode meMode;
112 bool mbIsInsertionTrivial;
113 bool mbIsActive;
114 bool mbIsReadOnly;
115 bool mbIsOverSourceView;
116 Size maIconSize;
117 bool mbIsForcedShow;
119 void SetPosition (
120 const Point& rPoint,
121 const Mode eMode);
122 std::shared_ptr<view::InsertAnimator> const & GetInsertAnimator();
124 /** Make the insertion indicator visible (that is the show part) and
125 keep it visible, even when the mouse leaves the window (that is the
126 force part). We need this when a context menu is displayed (mouse
127 over the popup menu triggers a mouse leave event) while the
128 insertion indicator remains visible in the background.
130 In effect all calls to End() are ignored until ForceEnd() is called.
132 void ForceShow();
133 void ForceEnd();
136 } // end of namespace ::sd::slidesorter::controller
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */