bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / slidesorter / inc / view / SlsLayouter.hxx
bloba57b3a7ece3850a2c773a54df3e508a8111be56c
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_SLSLAYOUTER_HXX
21 #define INCLUDED_SD_SOURCE_UI_SLIDESORTER_INC_VIEW_SLSLAYOUTER_HXX
23 #include <vcl/vclptr.hxx>
24 #include <tools/gen.hxx>
25 #include <sal/types.h>
26 #include <memory>
28 namespace sd { class Window; }
29 namespace sd { namespace slidesorter { namespace model { class SlideSorterModel; } } }
30 namespace sd { namespace slidesorter { namespace view { class PageObjectLayouter; } } }
31 namespace sd { namespace slidesorter { namespace view { class Theme; } } }
33 namespace sd { namespace slidesorter { namespace view {
35 class InsertPosition;
37 /** Calculate the size and position of page objects displayed by a slide
38 sorter. The layouter takes into account various input values:
39 1.) Size of the window in which the slide sorter is displayed.
40 2.) Desired and minimal and maximal widths of page objects.
41 3.) Minimal and maximal number of columns.
42 4.) Vertical and horizontal gaps between objects in adjacent columns.
43 5.) Borders around every page object.
44 6.) Vertical and horizontal borders between enclosing page and outer
45 page objects.
46 From these, it calculates various output values:
47 1.) The width of page objects.
48 2.) The number of columns.
49 3.) The size of the enclosing page.
51 <p>Sizes and lengths are all in pixel except where explicitly stated
52 otherwise.</p>
54 <p>The GetIndex... methods may return indices that are larger than or
55 equal to (zero based) the number of pages. This is so because the
56 number of pages is not known to the class instances. Indices are
57 calculated with reference to the general grid layout of page
58 objects.</p>
60 class Layouter
62 public:
63 enum Orientation { HORIZONTAL, VERTICAL, GRID };
65 Layouter (
66 sd::Window *rpWindow,
67 const std::shared_ptr<Theme>& rpTheme);
68 ~Layouter();
70 std::shared_ptr<PageObjectLayouter> const & GetPageObjectLayouter() const;
71 /** Set the interval of valid column counts. When nMinimalColumnCount
72 <= nMaximalColumnCount is not fulfilled then the call is ignored.
73 @param nMinimalColumnCount
74 The default value is 1. The question whether higher values make
75 any sense is left to the caller.
76 @param nMaximalColumnCount
77 The default value is 5.
79 void SetColumnCount (sal_Int32 nMinimalColumnCount,
80 sal_Int32 nMaximalColumnCount);
82 /** Central method of this class. It takes the input values and
83 calculates the output values. Both given sizes must not be 0 in any
84 dimension or the call is ignored.
85 @param eOrientation
86 This defines the generally layout and specifies whether there may
87 be more than one row or more than one column.
88 @param rWindowSize
89 The size of the window in pixels that the slide sorter is
90 displayed in. This can differ from the size of mpWindow during
91 detection of whether or not the scroll bars should be visible.
92 @param rPreviewModelSize
93 Size of each page in model coordinates.
94 @param rpWindow
95 The map mode of this window is adapted to the new layout of the
96 page objects.
97 @return
98 The return value indicates whether the Get... methods can be
99 used to obtain valid values (<TRUE/>).
101 bool Rearrange (
102 const Orientation eOrientation,
103 const Size& rWindowSize,
104 const Size& rPreviewModelSize,
105 const sal_uInt32 nPageCount);
107 /** Return the number of columns.
109 sal_Int32 GetColumnCount() const;
111 sal_Int32 GetIndex (const sal_Int32 nRow, const sal_Int32 nColumn) const;
113 Size const & GetPageObjectSize() const;
115 /** Return the bounding box in window coordinates of the nIndex-th page
116 object.
118 ::tools::Rectangle GetPageObjectBox (
119 const sal_Int32 nIndex,
120 const bool bIncludeBorderAndGap) const;
122 /** Return the bounding box in model coordinates of the page that
123 contains the given amount of page objects.
125 ::tools::Rectangle GetTotalBoundingBox() const;
127 /** Return the index of the first fully or partially visible page
128 object. This takes into account only the vertical dimension.
129 @return
130 The second index may be larger than the number of existing
131 page objects.
133 Range GetRangeOfVisiblePageObjects (const ::tools::Rectangle& rVisibleArea) const;
135 /** Return the index of the page object that is rendered at the given
136 point.
137 @param rPosition
138 The position is expected to be in model coordinates relative to
139 the page origin.
140 @param bIncludePageBorders
141 When <TRUE/> then include the page borders into the calculation,
142 i.e. when a point lies in the border of a page object but not on
143 the actual page area the index of that page is returned;
144 otherwise -1 would be returned to indicate that no page object
145 has been hit.
146 @param bClampToValidRange
147 When <TRUE/> then values outside the valid range [0,mnPageCount)
148 are mapped to 0 (when smaller than 0) or mnPageCount-1 when
149 equal to or larger than mnPageCount.
150 When <FALSE/> then -1 is returned for values outside the valid range.
151 @return
152 The returned index may be larger than the number of existing
153 page objects.
155 sal_Int32 GetIndexAtPoint (
156 const Point& rModelPosition,
157 const bool bIncludePageBorders,
158 const bool bClampToValidRange = true) const;
160 /** Return an object that describes the logical and visual properties of
161 where to do an insert operation when the user would release the
162 mouse button at the given position after a drag operation and of
163 where and how to display an insertion indicator.
164 @param rModelPosition
165 The position in the model coordinate system for which to
166 determine the insertion page index. The position does not have
167 to be over a page object to return a valid value.
168 @param rIndicatorSize
169 The size of the insertion indicator. This size is used to adapt
170 the location when at the left or right of a row or at the top or
171 bottom of a column.
172 @param rModel
173 The model is used to get access to the selection states of the
174 pages. This in turn is used to determine the visual bounding
175 boxes.
177 InsertPosition GetInsertPosition (
178 const Point& rModelPosition,
179 const Size& rIndicatorSize,
180 model::SlideSorterModel const & rModel) const;
182 Range GetValidHorizontalSizeRange() const;
183 Range GetValidVerticalSizeRange() const;
185 class Implementation;
187 private:
188 std::unique_ptr<Implementation> mpImplementation;
189 VclPtr<sd::Window> mpWindow;
192 /** Collect all values concerning the logical and visual properties of the
193 insertion position that is used for drag-and-drop and copy-and-paste.
195 class InsertPosition
197 public:
198 InsertPosition();
199 bool operator== (const InsertPosition& rInsertPosition) const;
200 bool operator!= (const InsertPosition& rInsertPosition) const;
202 void SetLogicalPosition (
203 const sal_Int32 nRow,
204 const sal_Int32 nColumn,
205 const sal_Int32 nIndex,
206 const bool bIsAtRunStart,
207 const bool bIsAtRunEnd,
208 const bool bIsExtraSpaceNeeded);
209 void SetGeometricalPosition(
210 const Point& rLocation,
211 const Point& rLeadingOffset,
212 const Point& rTrailingOffset);
214 sal_Int32 GetRow() const { return mnRow; }
215 sal_Int32 GetColumn() const { return mnColumn; }
216 sal_Int32 GetIndex() const { return mnIndex; }
217 const Point& GetLocation() const { return maLocation; }
218 const Point& GetLeadingOffset() const { return maLeadingOffset; }
219 const Point& GetTrailingOffset() const { return maTrailingOffset; }
220 bool IsAtRunStart() const { return mbIsAtRunStart; }
221 bool IsAtRunEnd() const { return mbIsAtRunEnd; }
222 bool IsExtraSpaceNeeded() const { return mbIsExtraSpaceNeeded; }
224 private:
225 sal_Int32 mnRow;
226 sal_Int32 mnColumn;
227 sal_Int32 mnIndex;
228 bool mbIsAtRunStart : 1;
229 bool mbIsAtRunEnd : 1;
230 bool mbIsExtraSpaceNeeded : 1;
231 Point maLocation;
232 Point maLeadingOffset;
233 Point maTrailingOffset;
236 } } } // end of namespace ::sd::slidesorter::view
238 #endif
240 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */