Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_SD_SOURCE_UI_SLIDESORTER_INC_CONTROLLER_SLSINSERTIONINDICATORHANDLER_HXX
21 : #define INCLUDED_SD_SOURCE_UI_SLIDESORTER_INC_CONTROLLER_SLSINSERTIONINDICATORHANDLER_HXX
22 :
23 : #include "view/SlsInsertAnimator.hxx"
24 :
25 : #include "view/SlsLayouter.hxx"
26 : #include "sdxfer.hxx"
27 :
28 : namespace sd { namespace slidesorter { class SlideSorter; } }
29 : namespace sd { namespace slidesorter { namespace view {
30 : class InsertAnimator;
31 : class InsertionIndicatorOverlay;
32 : } } }
33 :
34 : namespace sd { namespace slidesorter { namespace controller {
35 :
36 : class Transferable;
37 :
38 : /** Manage the visibility and location of the insertion indicator. Its
39 : actual display is controlled by the InsertionIndicatorOverlay.
40 : */
41 : class InsertionIndicatorHandler
42 : {
43 : public:
44 : InsertionIndicatorHandler (SlideSorter& rSlideSorter);
45 : ~InsertionIndicatorHandler (void);
46 :
47 : enum Mode { CopyMode, MoveMode, UnknownMode };
48 : static Mode GetModeFromDndAction (const sal_Int8 nDndAction);
49 :
50 : /** Activate the insertion marker at the given coordinates.
51 : */
52 : void Start (const bool bIsOverSourceView);
53 :
54 : /** Deactivate the insertion marker.
55 : */
56 : void End (const controller::Animator::AnimationMode eMode);
57 :
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.
61 : */
62 : class ForceShowContext
63 : {
64 : public:
65 : ForceShowContext (const ::boost::shared_ptr<InsertionIndicatorHandler>& rpHandler);
66 : ~ForceShowContext (void);
67 : private:
68 : const ::boost::shared_ptr<InsertionIndicatorHandler> mpHandler;
69 : };
70 :
71 : /** Update the indicator icon from the current transferable (from the
72 : clipboard or an active drag and drop operation.)
73 : */
74 : void UpdateIndicatorIcon (const SdTransferable* pTransferable);
75 :
76 : /** Set the position of the insertion marker to the given coordinates.
77 : */
78 : void UpdatePosition (
79 : const Point& rMouseModelPosition,
80 : const Mode eMode);
81 : void UpdatePosition (
82 : const Point& rMouseModelPosition,
83 : const sal_Int8 nDndAction);
84 :
85 : /** Return whether the insertion marker is active.
86 : */
87 0 : bool IsActive (void) const { return mbIsActive;}
88 :
89 : /** Return the insertion index that corresponds with the current
90 : graphical location of the insertion indicator.
91 : */
92 : sal_Int32 GetInsertionPageIndex (void) const;
93 :
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.
98 : */
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().
105 : */
106 : bool IsInsertionTrivial (const sal_Int8 nDndAction);
107 :
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;
120 :
121 : void SetPosition (
122 : const Point& rPoint,
123 : const Mode eMode);
124 : ::boost::shared_ptr<view::InsertAnimator> GetInsertAnimator (void);
125 :
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.
131 :
132 : In effect all calls to End() are ignored until ForceEnd() is called.
133 : */
134 : void ForceShow (void);
135 : void ForceEnd (void);
136 : };
137 :
138 : } } } // end of namespace ::sd::slidesorter::controller
139 :
140 : #endif
141 :
142 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|