1*5b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*5b190011SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*5b190011SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*5b190011SAndrew Rist * distributed with this work for additional information
6*5b190011SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*5b190011SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*5b190011SAndrew Rist * "License"); you may not use this file except in compliance
9*5b190011SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*5b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*5b190011SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*5b190011SAndrew Rist * software distributed under the License is distributed on an
15*5b190011SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5b190011SAndrew Rist * KIND, either express or implied. See the License for the
17*5b190011SAndrew Rist * specific language governing permissions and limitations
18*5b190011SAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*5b190011SAndrew Rist *************************************************************/
21*5b190011SAndrew Rist
22*5b190011SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #include "precompiled_sd.hxx"
25cdf0e10cSrcweir
26cdf0e10cSrcweir #include "model/SlsVisualState.hxx"
27cdf0e10cSrcweir #include "model/SlsPageDescriptor.hxx"
28cdf0e10cSrcweir #include "controller/SlsAnimator.hxx"
29cdf0e10cSrcweir
30cdf0e10cSrcweir namespace sd { namespace slidesorter { namespace model {
31cdf0e10cSrcweir
VisualState(const sal_Int32 nPageId)32cdf0e10cSrcweir VisualState::VisualState (const sal_Int32 nPageId)
33cdf0e10cSrcweir : mnPageId(nPageId),
34cdf0e10cSrcweir meCurrentVisualState(VS_None),
35cdf0e10cSrcweir meOldVisualState(VS_None),
36cdf0e10cSrcweir mnVisualStateBlend(1.0),
37cdf0e10cSrcweir mnStateAnimationId(controller::Animator::NotAnAnimationId),
38cdf0e10cSrcweir maLocationOffset(0,0),
39cdf0e10cSrcweir mnLocationAnimationId(controller::Animator::NotAnAnimationId),
40cdf0e10cSrcweir mnButtonAlpha(1.0),
41cdf0e10cSrcweir mnButtonBarAlpha(1.0),
42cdf0e10cSrcweir mnButtonAlphaAnimationId(controller::Animator::NotAnAnimationId)
43cdf0e10cSrcweir {
44cdf0e10cSrcweir }
45cdf0e10cSrcweir
46cdf0e10cSrcweir
47cdf0e10cSrcweir
48cdf0e10cSrcweir
~VisualState(void)49cdf0e10cSrcweir VisualState::~VisualState (void)
50cdf0e10cSrcweir {
51cdf0e10cSrcweir if (mnStateAnimationId != controller::Animator::NotAnAnimationId
52cdf0e10cSrcweir || mnLocationAnimationId != controller::Animator::NotAnAnimationId)
53cdf0e10cSrcweir {
54cdf0e10cSrcweir OSL_ASSERT(mnStateAnimationId == controller::Animator::NotAnAnimationId);
55cdf0e10cSrcweir OSL_ASSERT(mnLocationAnimationId == controller::Animator::NotAnAnimationId);
56cdf0e10cSrcweir }
57cdf0e10cSrcweir }
58cdf0e10cSrcweir
59cdf0e10cSrcweir
60cdf0e10cSrcweir
61cdf0e10cSrcweir
GetCurrentVisualState(void) const62cdf0e10cSrcweir VisualState::State VisualState::GetCurrentVisualState (void) const
63cdf0e10cSrcweir {
64cdf0e10cSrcweir return meCurrentVisualState;
65cdf0e10cSrcweir }
66cdf0e10cSrcweir
67cdf0e10cSrcweir
68cdf0e10cSrcweir
69cdf0e10cSrcweir
GetOldVisualState(void) const70cdf0e10cSrcweir VisualState::State VisualState::GetOldVisualState (void) const
71cdf0e10cSrcweir {
72cdf0e10cSrcweir return meOldVisualState;
73cdf0e10cSrcweir }
74cdf0e10cSrcweir
75cdf0e10cSrcweir
76cdf0e10cSrcweir
77cdf0e10cSrcweir
SetVisualState(const State eState)78cdf0e10cSrcweir void VisualState::SetVisualState (const State eState)
79cdf0e10cSrcweir {
80cdf0e10cSrcweir meOldVisualState = meCurrentVisualState;
81cdf0e10cSrcweir meCurrentVisualState = eState;
82cdf0e10cSrcweir mnVisualStateBlend = 1.0;
83cdf0e10cSrcweir }
84cdf0e10cSrcweir
85cdf0e10cSrcweir
86cdf0e10cSrcweir
87cdf0e10cSrcweir
GetVisualStateBlend(void) const88cdf0e10cSrcweir double VisualState::GetVisualStateBlend (void) const
89cdf0e10cSrcweir {
90cdf0e10cSrcweir return mnVisualStateBlend;
91cdf0e10cSrcweir }
92cdf0e10cSrcweir
93cdf0e10cSrcweir
94cdf0e10cSrcweir
95cdf0e10cSrcweir
SetVisualStateBlend(const double nBlend)96cdf0e10cSrcweir void VisualState::SetVisualStateBlend (const double nBlend)
97cdf0e10cSrcweir {
98cdf0e10cSrcweir mnVisualStateBlend = nBlend;
99cdf0e10cSrcweir }
100cdf0e10cSrcweir
101cdf0e10cSrcweir
102cdf0e10cSrcweir
103cdf0e10cSrcweir
UpdateVisualState(const PageDescriptor & rDescriptor)104cdf0e10cSrcweir void VisualState::UpdateVisualState (const PageDescriptor& rDescriptor)
105cdf0e10cSrcweir {
106cdf0e10cSrcweir if (rDescriptor.HasState(PageDescriptor::ST_Excluded))
107cdf0e10cSrcweir SetVisualState(VS_Excluded);
108cdf0e10cSrcweir else if (rDescriptor.HasState(PageDescriptor::ST_Current))
109cdf0e10cSrcweir SetVisualState(VS_Current);
110cdf0e10cSrcweir else if (rDescriptor.HasState(PageDescriptor::ST_Focused))
111cdf0e10cSrcweir SetVisualState(VS_Focused);
112cdf0e10cSrcweir else if (rDescriptor.HasState(PageDescriptor::ST_Selected))
113cdf0e10cSrcweir SetVisualState(VS_Selected);
114cdf0e10cSrcweir else
115cdf0e10cSrcweir SetVisualState(VS_None);
116cdf0e10cSrcweir
117cdf0e10cSrcweir SetMouseOverState(rDescriptor.HasState(PageDescriptor::ST_MouseOver));
118cdf0e10cSrcweir }
119cdf0e10cSrcweir
120cdf0e10cSrcweir
121cdf0e10cSrcweir
122cdf0e10cSrcweir
SetMouseOverState(const bool bIsMouseOver)123cdf0e10cSrcweir void VisualState::SetMouseOverState (const bool bIsMouseOver)
124cdf0e10cSrcweir {
125cdf0e10cSrcweir mbOldMouseOverState = mbCurrentMouseOverState;
126cdf0e10cSrcweir mbCurrentMouseOverState = bIsMouseOver;
127cdf0e10cSrcweir }
128cdf0e10cSrcweir
129cdf0e10cSrcweir
130cdf0e10cSrcweir
131cdf0e10cSrcweir
GetStateAnimationId(void) const132cdf0e10cSrcweir sal_Int32 VisualState::GetStateAnimationId (void) const
133cdf0e10cSrcweir {
134cdf0e10cSrcweir return mnStateAnimationId;
135cdf0e10cSrcweir }
136cdf0e10cSrcweir
137cdf0e10cSrcweir
138cdf0e10cSrcweir
139cdf0e10cSrcweir
SetStateAnimationId(const sal_Int32 nAnimationId)140cdf0e10cSrcweir void VisualState::SetStateAnimationId (const sal_Int32 nAnimationId)
141cdf0e10cSrcweir {
142cdf0e10cSrcweir mnStateAnimationId = nAnimationId;
143cdf0e10cSrcweir }
144cdf0e10cSrcweir
145cdf0e10cSrcweir
146cdf0e10cSrcweir
147cdf0e10cSrcweir
GetLocationOffset(void) const148cdf0e10cSrcweir Point VisualState::GetLocationOffset (void) const
149cdf0e10cSrcweir {
150cdf0e10cSrcweir return maLocationOffset;
151cdf0e10cSrcweir }
152cdf0e10cSrcweir
153cdf0e10cSrcweir
154cdf0e10cSrcweir
155cdf0e10cSrcweir
SetLocationOffset(const Point & rOffset)156cdf0e10cSrcweir bool VisualState::SetLocationOffset (const Point& rOffset)
157cdf0e10cSrcweir {
158cdf0e10cSrcweir if (maLocationOffset != rOffset)
159cdf0e10cSrcweir {
160cdf0e10cSrcweir maLocationOffset = rOffset;
161cdf0e10cSrcweir return true;
162cdf0e10cSrcweir }
163cdf0e10cSrcweir else
164cdf0e10cSrcweir return false;
165cdf0e10cSrcweir }
166cdf0e10cSrcweir
167cdf0e10cSrcweir
168cdf0e10cSrcweir
169cdf0e10cSrcweir
GetLocationAnimationId(void) const170cdf0e10cSrcweir sal_Int32 VisualState::GetLocationAnimationId (void) const
171cdf0e10cSrcweir {
172cdf0e10cSrcweir return mnLocationAnimationId;
173cdf0e10cSrcweir }
174cdf0e10cSrcweir
175cdf0e10cSrcweir
176cdf0e10cSrcweir
177cdf0e10cSrcweir
SetLocationAnimationId(const sal_Int32 nAnimationId)178cdf0e10cSrcweir void VisualState::SetLocationAnimationId (const sal_Int32 nAnimationId)
179cdf0e10cSrcweir {
180cdf0e10cSrcweir mnLocationAnimationId = nAnimationId;
181cdf0e10cSrcweir }
182cdf0e10cSrcweir
183cdf0e10cSrcweir
184cdf0e10cSrcweir
185cdf0e10cSrcweir
GetButtonAlpha(void) const186cdf0e10cSrcweir double VisualState::GetButtonAlpha (void) const
187cdf0e10cSrcweir {
188cdf0e10cSrcweir return mnButtonAlpha;
189cdf0e10cSrcweir }
190cdf0e10cSrcweir
191cdf0e10cSrcweir
192cdf0e10cSrcweir
193cdf0e10cSrcweir
SetButtonAlpha(const double nAlpha)194cdf0e10cSrcweir void VisualState::SetButtonAlpha (const double nAlpha)
195cdf0e10cSrcweir {
196cdf0e10cSrcweir mnButtonAlpha = nAlpha;
197cdf0e10cSrcweir }
198cdf0e10cSrcweir
199cdf0e10cSrcweir
200cdf0e10cSrcweir
201cdf0e10cSrcweir
GetButtonBarAlpha(void) const202cdf0e10cSrcweir double VisualState::GetButtonBarAlpha (void) const
203cdf0e10cSrcweir {
204cdf0e10cSrcweir return mnButtonBarAlpha;
205cdf0e10cSrcweir }
206cdf0e10cSrcweir
207cdf0e10cSrcweir
208cdf0e10cSrcweir
209cdf0e10cSrcweir
SetButtonBarAlpha(const double nAlpha)210cdf0e10cSrcweir void VisualState::SetButtonBarAlpha (const double nAlpha)
211cdf0e10cSrcweir {
212cdf0e10cSrcweir mnButtonBarAlpha = nAlpha;
213cdf0e10cSrcweir }
214cdf0e10cSrcweir
215cdf0e10cSrcweir
216cdf0e10cSrcweir
217cdf0e10cSrcweir
GetButtonAlphaAnimationId(void) const218cdf0e10cSrcweir sal_Int32 VisualState::GetButtonAlphaAnimationId (void) const
219cdf0e10cSrcweir {
220cdf0e10cSrcweir return mnButtonAlphaAnimationId;
221cdf0e10cSrcweir }
222cdf0e10cSrcweir
223cdf0e10cSrcweir
224cdf0e10cSrcweir
225cdf0e10cSrcweir
SetButtonAlphaAnimationId(const sal_Int32 nAnimationId)226cdf0e10cSrcweir void VisualState::SetButtonAlphaAnimationId (const sal_Int32 nAnimationId)
227cdf0e10cSrcweir {
228cdf0e10cSrcweir mnButtonAlphaAnimationId = nAnimationId;
229cdf0e10cSrcweir }
230cdf0e10cSrcweir
231cdf0e10cSrcweir
232cdf0e10cSrcweir } } } // end of namespace ::sd::slidesorter::model
233