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 #include "precompiled_sd.hxx" 25 26 #include "model/SlsVisualState.hxx" 27 #include "model/SlsPageDescriptor.hxx" 28 #include "controller/SlsAnimator.hxx" 29 30 namespace sd { namespace slidesorter { namespace model { 31 32 VisualState::VisualState (const sal_Int32 nPageId) 33 : mnPageId(nPageId), 34 meCurrentVisualState(VS_None), 35 meOldVisualState(VS_None), 36 mnVisualStateBlend(1.0), 37 mnStateAnimationId(controller::Animator::NotAnAnimationId), 38 maLocationOffset(0,0), 39 mnLocationAnimationId(controller::Animator::NotAnAnimationId), 40 mnButtonAlpha(1.0), 41 mnButtonBarAlpha(1.0), 42 mnButtonAlphaAnimationId(controller::Animator::NotAnAnimationId) 43 { 44 } 45 46 47 48 49 VisualState::~VisualState (void) 50 { 51 if (mnStateAnimationId != controller::Animator::NotAnAnimationId 52 || mnLocationAnimationId != controller::Animator::NotAnAnimationId) 53 { 54 OSL_ASSERT(mnStateAnimationId == controller::Animator::NotAnAnimationId); 55 OSL_ASSERT(mnLocationAnimationId == controller::Animator::NotAnAnimationId); 56 } 57 } 58 59 60 61 62 VisualState::State VisualState::GetCurrentVisualState (void) const 63 { 64 return meCurrentVisualState; 65 } 66 67 68 69 70 VisualState::State VisualState::GetOldVisualState (void) const 71 { 72 return meOldVisualState; 73 } 74 75 76 77 78 void VisualState::SetVisualState (const State eState) 79 { 80 meOldVisualState = meCurrentVisualState; 81 meCurrentVisualState = eState; 82 mnVisualStateBlend = 1.0; 83 } 84 85 86 87 88 double VisualState::GetVisualStateBlend (void) const 89 { 90 return mnVisualStateBlend; 91 } 92 93 94 95 96 void VisualState::SetVisualStateBlend (const double nBlend) 97 { 98 mnVisualStateBlend = nBlend; 99 } 100 101 102 103 104 void VisualState::UpdateVisualState (const PageDescriptor& rDescriptor) 105 { 106 if (rDescriptor.HasState(PageDescriptor::ST_Excluded)) 107 SetVisualState(VS_Excluded); 108 else if (rDescriptor.HasState(PageDescriptor::ST_Current)) 109 SetVisualState(VS_Current); 110 else if (rDescriptor.HasState(PageDescriptor::ST_Focused)) 111 SetVisualState(VS_Focused); 112 else if (rDescriptor.HasState(PageDescriptor::ST_Selected)) 113 SetVisualState(VS_Selected); 114 else 115 SetVisualState(VS_None); 116 117 SetMouseOverState(rDescriptor.HasState(PageDescriptor::ST_MouseOver)); 118 } 119 120 121 122 123 void VisualState::SetMouseOverState (const bool bIsMouseOver) 124 { 125 mbOldMouseOverState = mbCurrentMouseOverState; 126 mbCurrentMouseOverState = bIsMouseOver; 127 } 128 129 130 131 132 sal_Int32 VisualState::GetStateAnimationId (void) const 133 { 134 return mnStateAnimationId; 135 } 136 137 138 139 140 void VisualState::SetStateAnimationId (const sal_Int32 nAnimationId) 141 { 142 mnStateAnimationId = nAnimationId; 143 } 144 145 146 147 148 Point VisualState::GetLocationOffset (void) const 149 { 150 return maLocationOffset; 151 } 152 153 154 155 156 bool VisualState::SetLocationOffset (const Point& rOffset) 157 { 158 if (maLocationOffset != rOffset) 159 { 160 maLocationOffset = rOffset; 161 return true; 162 } 163 else 164 return false; 165 } 166 167 168 169 170 sal_Int32 VisualState::GetLocationAnimationId (void) const 171 { 172 return mnLocationAnimationId; 173 } 174 175 176 177 178 void VisualState::SetLocationAnimationId (const sal_Int32 nAnimationId) 179 { 180 mnLocationAnimationId = nAnimationId; 181 } 182 183 184 185 186 double VisualState::GetButtonAlpha (void) const 187 { 188 return mnButtonAlpha; 189 } 190 191 192 193 194 void VisualState::SetButtonAlpha (const double nAlpha) 195 { 196 mnButtonAlpha = nAlpha; 197 } 198 199 200 201 202 double VisualState::GetButtonBarAlpha (void) const 203 { 204 return mnButtonBarAlpha; 205 } 206 207 208 209 210 void VisualState::SetButtonBarAlpha (const double nAlpha) 211 { 212 mnButtonBarAlpha = nAlpha; 213 } 214 215 216 217 218 sal_Int32 VisualState::GetButtonAlphaAnimationId (void) const 219 { 220 return mnButtonAlphaAnimationId; 221 } 222 223 224 225 226 void VisualState::SetButtonAlphaAnimationId (const sal_Int32 nAnimationId) 227 { 228 mnButtonAlphaAnimationId = nAnimationId; 229 } 230 231 232 } } } // end of namespace ::sd::slidesorter::model 233