bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / slidesorter / inc / view / SlideSorterView.hxx
blobe1444a5868310579513bf7896903e4694b28837e
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_VIEW_SLIDESORTERVIEW_HXX
21 #define INCLUDED_SD_SOURCE_UI_SLIDESORTER_INC_VIEW_SLIDESORTERVIEW_HXX
23 #include <model/SlsPageDescriptor.hxx>
24 #include <model/SlsSharedPageDescriptor.hxx>
25 #include <view/SlsLayouter.hxx>
26 #include <view/SlsILayerPainter.hxx>
27 #include <o3tl/deleter.hxx>
29 #include <View.hxx>
30 #include <tools/gen.hxx>
31 #include <vcl/region.hxx>
32 #include <memory>
34 namespace sd { namespace slidesorter { namespace cache {
35 class PageCache;
36 } } }
38 namespace sd { namespace slidesorter { namespace model {
39 class SlideSorterModel;
40 } } }
42 namespace sd { class Window; }
43 namespace sd { namespace slidesorter { class SlideSorter; } }
45 namespace sd { namespace slidesorter { namespace view {
47 class LayeredDevice;
48 class PageObjectPainter;
49 class ToolTip;
51 class SlideSorterView
52 : public sd::View
54 public:
56 /** Create a new view for the slide sorter.
57 @param rViewShell
58 This reference is simply passed to the base class and not used
59 by this class.
62 explicit SlideSorterView (SlideSorter& rSlideSorter);
63 void Init();
65 virtual ~SlideSorterView() override;
66 void Dispose();
68 SlideSorterView(const SlideSorterView&) = delete;
69 SlideSorterView& operator=(const SlideSorterView&) = delete;
71 /** Set the general way of layouting the page objects. Note that this
72 method does not trigger any repaints or layouts.
74 bool SetOrientation (const Layouter::Orientation eOrientation);
75 Layouter::Orientation GetOrientation() const { return meOrientation;}
77 void RequestRepaint();
78 void RequestRepaint (const model::SharedPageDescriptor& rDescriptor);
79 void RequestRepaint (const ::tools::Rectangle& rRepaintBox);
80 void RequestRepaint (const vcl::Region& rRepaintRegion);
82 ::tools::Rectangle GetModelArea();
84 /** Return the index of the page that is rendered at the given position.
85 @param rPosition
86 The position is expected to be in pixel coordinates.
87 @return
88 The returned index is -1 when there is no page object at the
89 given position.
91 sal_Int32 GetPageIndexAtPoint (const Point& rPosition) const;
93 view::Layouter& GetLayouter();
95 virtual void ModelHasChanged() override;
97 /** This method is typically called before a model change takes place.
98 All references to model data are released. PostModelChange() has to
99 be called to complete the handling of the model change. When the
100 calls to Pre- and PostModelChange() are very close to each other you
101 may call HandleModelChange() instead.
103 void PreModelChange();
105 /** This method is typically called after a model change took place.
106 References to model data are re-allocated. Call this method only
107 after PreModelChange() has been called.
109 void PostModelChange();
111 /** This method is a convenience function that simply calls
112 PreModelChange() and then PostModelChange().
114 void HandleModelChange();
116 void HandleDrawModeChange();
118 void Resize();
119 virtual void CompleteRedraw (
120 OutputDevice* pDevice,
121 const vcl::Region& rPaintArea,
122 sdr::contact::ViewObjectContactRedirector* pRedirector = nullptr) override;
123 void Paint (OutputDevice& rDevice, const ::tools::Rectangle& rRepaintArea);
125 virtual void ConfigurationChanged (
126 utl::ConfigurationBroadcaster* pBroadcaster,
127 ConfigurationHints nHint) override;
129 void HandleDataChangeEvent();
131 void Layout();
132 /** This tells the view that it has to re-determine the visibility of
133 the page objects before painting them the next time.
135 void InvalidatePageObjectVisibilities();
137 std::shared_ptr<cache::PageCache> const & GetPreviewCache();
139 /** Return the range of currently visible page objects including the
140 first and last one in that range.
141 @return
142 The returned pair of page object indices is empty when the
143 second index is lower than the first.
145 Range const & GetVisiblePageRange();
147 /** Add a shape to the page. Typically used from inside
148 PostModelChange().
150 // void AddSdrObject (SdrObject& rObject);
152 /** Add a listener that is called when the set of visible slides.
153 @param rListener
154 When this method is called multiple times for the same listener
155 the second and all following calls are ignored. Each listener
156 is added only once.
158 void AddVisibilityChangeListener (const Link<LinkParamNone*,void>& rListener);
160 /** Remove a listener that is called when the set of visible slides changes.
161 @param rListener
162 It is safe to pass a listener that was not added or has been
163 removed previously. Such calls are ignored.
165 void RemoveVisibilityChangeListener (const Link<LinkParamNone*,void>& rListener);
167 /** The page under the mouse is not highlighted in some contexts. Call
168 this method on context changes.
170 void UpdatePageUnderMouse ();
171 void UpdatePageUnderMouse (const Point& rMousePosition);
172 void SetPageUnderMouse (const model::SharedPageDescriptor& rpDescriptor);
174 bool SetState (
175 const model::SharedPageDescriptor& rpDescriptor,
176 const model::PageDescriptor::State eState,
177 const bool bStateValue);
179 void UpdateOrientation();
181 std::shared_ptr<PageObjectPainter> const & GetPageObjectPainter();
182 const std::shared_ptr<LayeredDevice>& GetLayeredDevice() const { return mpLayeredDevice;}
184 class DrawLock
186 public:
187 DrawLock (SlideSorter const & rSlideSorter);
188 ~DrawLock();
189 /** When the DrawLock is disposed then it will not request a repaint
190 on destruction.
192 void Dispose();
193 private:
194 view::SlideSorterView& mrView;
195 VclPtr<sd::Window> mpWindow;
198 ToolTip& GetToolTip() const;
200 virtual void DragFinished (sal_Int8 nDropAction) override;
202 private:
203 SlideSorter& mrSlideSorter;
204 model::SlideSorterModel& mrModel;
205 bool mbIsDisposed;
206 ::std::unique_ptr<Layouter> mpLayouter;
207 bool mbPageObjectVisibilitiesValid;
208 std::shared_ptr<cache::PageCache> mpPreviewCache;
209 std::shared_ptr<LayeredDevice> mpLayeredDevice;
210 Range maVisiblePageRange;
211 Size maPreviewSize;
212 bool mbPreciousFlagUpdatePending;
213 Layouter::Orientation meOrientation;
214 model::SharedPageDescriptor mpPageUnderMouse;
215 std::shared_ptr<PageObjectPainter> mpPageObjectPainter;
216 vcl::Region maRedrawRegion;
217 SharedILayerPainter const mpBackgroundPainter;
218 std::unique_ptr<ToolTip, o3tl::default_delete<ToolTip>> mpToolTip;
219 bool mbIsRearrangePending;
220 ::std::vector<Link<LinkParamNone*,void>> maVisibilityChangeListeners;
222 /** Determine the visibility of all page objects.
224 void DeterminePageObjectVisibilities();
226 void UpdatePreciousFlags();
227 void RequestRearrange();
228 void Rearrange();
231 } } } // end of namespace ::sd::slidesorter::view
233 #endif
235 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */