1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SD_SLIDESORTER_VISIBLE_AREA_MANAGER_HXX
25 #define SD_SLIDESORTER_VISIBLE_AREA_MANAGER_HXX
26 
27 #include "controller/SlsAnimator.hxx"
28 #include "model/SlsSharedPageDescriptor.hxx"
29 #include <boost/noncopyable.hpp>
30 #include <boost/optional.hpp>
31 
32 namespace sd { namespace slidesorter { namespace controller {
33 
34 
35 /** Manage requests for scrolling page objects into view.
36 */
37 class VisibleAreaManager
38     : public ::boost::noncopyable
39 {
40 public:
41     VisibleAreaManager (SlideSorter& rSlideSorter);
42     ~VisibleAreaManager (void);
43 
44     void ActivateCurrentSlideTracking (void);
45     void DeactivateCurrentSlideTracking (void);
46     bool IsCurrentSlideTrackingActive (void) const;
47 
48     /** Request the current slide to be moved into the visible area.
49         This request is only obeyed when the current slide tracking is
50         active.
51         @see ActivateCurrentSlideTracking() and DeactivateCurrentSlideTracking()
52     */
53     void RequestCurrentSlideVisible (void);
54 
55     /** Request to make the specified page object visible.
56     */
57     void RequestVisible (
58         const model::SharedPageDescriptor& rpDescriptor,
59         const bool bForce = false);
60 
61     /** Temporarily disable the update of the visible area.
62     */
63     class TemporaryDisabler
64     {
65     public:
66         TemporaryDisabler (SlideSorter& rSlideSorter);
67         ~TemporaryDisabler (void);
68     private:
69         VisibleAreaManager& mrVisibleAreaManager;
70     };
71 
72 private:
73     SlideSorter& mrSlideSorter;
74 
75     /** List of rectangle that someone wants to be moved into the visible
76         area.
77         Cleared on every call to ForgetVisibleRequests() and MakeVisible().
78     */
79     ::std::vector<Rectangle> maVisibleRequests;
80 
81     /** Animation id for a scroll animation that sets the top
82         and left of the visible area to maRequestedVisibleTopLeft.
83     */
84     Animator::AnimationId mnScrollAnimationId;
85     Point maRequestedVisibleTopLeft;
86     Animator::AnimationMode meRequestedAnimationMode;
87     bool mbIsCurrentSlideTrackingActive;
88     int mnDisableCount;
89 
90     void MakeVisible (void);
91     ::boost::optional<Point> GetRequestedTopLeft (void) const;
92 };
93 
94 
95 } } } // end of namespace ::sd::slidesorter::view
96 
97 #endif
98