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 .
22 #include <model/SlsPageDescriptor.hxx>
23 #include <model/SlsSharedPageDescriptor.hxx>
24 #include <view/SlsLayouter.hxx>
25 #include <view/SlsILayerPainter.hxx>
26 #include <o3tl/deleter.hxx>
29 #include <tools/gen.hxx>
30 #include <vcl/region.hxx>
33 namespace sd::slidesorter::cache
{ class PageCache
; }
34 namespace sd::slidesorter::model
{ class SlideSorterModel
; }
35 namespace sd
{ class Window
; }
36 namespace sd::slidesorter
{ class SlideSorter
; }
37 namespace sd::slidesorter::view
{
40 class PageObjectPainter
;
43 class SlideSorterView final
48 /** Create a new view for the slide sorter.
50 This reference is simply passed to the base class and not used
54 explicit SlideSorterView (SlideSorter
& rSlideSorter
);
57 virtual ~SlideSorterView() override
;
60 SlideSorterView(const SlideSorterView
&) = delete;
61 SlideSorterView
& operator=(const SlideSorterView
&) = delete;
63 /** Set the general way of layouting the page objects. Note that this
64 method does not trigger any repaints or layouts.
66 bool SetOrientation (const Layouter::Orientation eOrientation
);
67 Layouter::Orientation
GetOrientation() const { return meOrientation
;}
69 void RequestRepaint();
70 void RequestRepaint (const model::SharedPageDescriptor
& rDescriptor
);
71 void RequestRepaint (const ::tools::Rectangle
& rRepaintBox
);
72 void RequestRepaint (const vcl::Region
& rRepaintRegion
);
74 ::tools::Rectangle
GetModelArea() const;
76 /** Return the index of the page that is rendered at the given position.
78 The position is expected to be in pixel coordinates.
80 The returned index is -1 when there is no page object at the
83 sal_Int32
GetPageIndexAtPoint (const Point
& rPosition
) const;
85 view::Layouter
& GetLayouter();
87 virtual void ModelHasChanged() override
;
89 /** This method is typically called before a model change takes place.
90 All references to model data are released. PostModelChange() has to
91 be called to complete the handling of the model change. When the
92 calls to Pre- and PostModelChange() are very close to each other you
93 may call HandleModelChange() instead.
95 void PreModelChange();
97 /** This method is typically called after a model change took place.
98 References to model data are re-allocated. Call this method only
99 after PreModelChange() has been called.
101 void PostModelChange();
103 /** This method is a convenience function that simply calls
104 PreModelChange() and then PostModelChange().
106 void HandleModelChange();
108 void HandleDrawModeChange();
111 virtual void CompleteRedraw (
112 OutputDevice
* pDevice
,
113 const vcl::Region
& rPaintArea
,
114 sdr::contact::ViewObjectContactRedirector
* pRedirector
= nullptr) override
;
115 void Paint (OutputDevice
& rDevice
, const ::tools::Rectangle
& rRepaintArea
);
117 virtual void ConfigurationChanged (
118 utl::ConfigurationBroadcaster
* pBroadcaster
,
119 ConfigurationHints nHint
) override
;
121 void HandleDataChangeEvent();
124 /** This tells the view that it has to re-determine the visibility of
125 the page objects before painting them the next time.
127 void InvalidatePageObjectVisibilities();
129 std::shared_ptr
<cache::PageCache
> const & GetPreviewCache();
131 /** Return the range of currently visible page objects including the
132 first and last one in that range.
134 The returned pair of page object indices is empty when the
135 second index is lower than the first.
137 Range
const & GetVisiblePageRange();
139 /** Add a shape to the page. Typically used from inside
142 // void AddSdrObject (SdrObject& rObject);
144 /** Add a listener that is called when the set of visible slides.
146 When this method is called multiple times for the same listener
147 the second and all following calls are ignored. Each listener
150 void AddVisibilityChangeListener (const Link
<LinkParamNone
*,void>& rListener
);
152 /** Remove a listener that is called when the set of visible slides changes.
154 It is safe to pass a listener that was not added or has been
155 removed previously. Such calls are ignored.
157 void RemoveVisibilityChangeListener (const Link
<LinkParamNone
*,void>& rListener
);
159 /** The page under the mouse is not highlighted in some contexts. Call
160 this method on context changes.
162 void UpdatePageUnderMouse ();
163 void UpdatePageUnderMouse (const Point
& rMousePosition
);
164 void SetPageUnderMouse (const model::SharedPageDescriptor
& rpDescriptor
);
167 const model::SharedPageDescriptor
& rpDescriptor
,
168 const model::PageDescriptor::State eState
,
169 const bool bStateValue
);
171 void UpdateOrientation();
173 std::shared_ptr
<PageObjectPainter
> const & GetPageObjectPainter();
174 const std::shared_ptr
<LayeredDevice
>& GetLayeredDevice() const { return mpLayeredDevice
;}
179 DrawLock (SlideSorter
const & rSlideSorter
);
181 /** When the DrawLock is disposed then it will not request a repaint
186 view::SlideSorterView
& mrView
;
187 VclPtr
<sd::Window
> mpWindow
;
190 ToolTip
& GetToolTip() const;
192 virtual void DragFinished (sal_Int8 nDropAction
) override
;
195 SlideSorter
& mrSlideSorter
;
196 model::SlideSorterModel
& mrModel
;
198 ::std::unique_ptr
<Layouter
> mpLayouter
;
199 bool mbPageObjectVisibilitiesValid
;
200 std::shared_ptr
<cache::PageCache
> mpPreviewCache
;
201 std::shared_ptr
<LayeredDevice
> mpLayeredDevice
;
202 Range maVisiblePageRange
;
204 bool mbPreciousFlagUpdatePending
;
205 Layouter::Orientation meOrientation
;
206 model::SharedPageDescriptor mpPageUnderMouse
;
207 std::shared_ptr
<PageObjectPainter
> mpPageObjectPainter
;
208 vcl::Region maRedrawRegion
;
209 SharedILayerPainter mpBackgroundPainter
;
210 std::unique_ptr
<ToolTip
, o3tl::default_delete
<ToolTip
>> mpToolTip
;
211 bool mbIsRearrangePending
;
212 ::std::vector
<Link
<LinkParamNone
*,void>> maVisibilityChangeListeners
;
214 /** Determine the visibility of all page objects.
216 void DeterminePageObjectVisibilities();
218 void UpdatePreciousFlags();
219 void RequestRearrange();
223 } // end of namespace ::sd::slidesorter::view
225 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */