1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #include "precompiled_sd.hxx" 29 30 #include "model/SlsVisualState.hxx" 31 #include "model/SlsPageDescriptor.hxx" 32 #include "controller/SlsAnimator.hxx" 33 34 namespace sd { namespace slidesorter { namespace model { 35 36 VisualState::VisualState (const sal_Int32 nPageId) 37 : mnPageId(nPageId), 38 meCurrentVisualState(VS_None), 39 meOldVisualState(VS_None), 40 mnVisualStateBlend(1.0), 41 mnStateAnimationId(controller::Animator::NotAnAnimationId), 42 maLocationOffset(0,0), 43 mnLocationAnimationId(controller::Animator::NotAnAnimationId), 44 mnButtonAlpha(1.0), 45 mnButtonBarAlpha(1.0), 46 mnButtonAlphaAnimationId(controller::Animator::NotAnAnimationId) 47 { 48 } 49 50 51 52 53 VisualState::~VisualState (void) 54 { 55 if (mnStateAnimationId != controller::Animator::NotAnAnimationId 56 || mnLocationAnimationId != controller::Animator::NotAnAnimationId) 57 { 58 OSL_ASSERT(mnStateAnimationId == controller::Animator::NotAnAnimationId); 59 OSL_ASSERT(mnLocationAnimationId == controller::Animator::NotAnAnimationId); 60 } 61 } 62 63 64 65 66 VisualState::State VisualState::GetCurrentVisualState (void) const 67 { 68 return meCurrentVisualState; 69 } 70 71 72 73 74 VisualState::State VisualState::GetOldVisualState (void) const 75 { 76 return meOldVisualState; 77 } 78 79 80 81 82 void VisualState::SetVisualState (const State eState) 83 { 84 meOldVisualState = meCurrentVisualState; 85 meCurrentVisualState = eState; 86 mnVisualStateBlend = 1.0; 87 } 88 89 90 91 92 double VisualState::GetVisualStateBlend (void) const 93 { 94 return mnVisualStateBlend; 95 } 96 97 98 99 100 void VisualState::SetVisualStateBlend (const double nBlend) 101 { 102 mnVisualStateBlend = nBlend; 103 } 104 105 106 107 108 void VisualState::UpdateVisualState (const PageDescriptor& rDescriptor) 109 { 110 if (rDescriptor.HasState(PageDescriptor::ST_Excluded)) 111 SetVisualState(VS_Excluded); 112 else if (rDescriptor.HasState(PageDescriptor::ST_Current)) 113 SetVisualState(VS_Current); 114 else if (rDescriptor.HasState(PageDescriptor::ST_Focused)) 115 SetVisualState(VS_Focused); 116 else if (rDescriptor.HasState(PageDescriptor::ST_Selected)) 117 SetVisualState(VS_Selected); 118 else 119 SetVisualState(VS_None); 120 121 SetMouseOverState(rDescriptor.HasState(PageDescriptor::ST_MouseOver)); 122 } 123 124 125 126 127 void VisualState::SetMouseOverState (const bool bIsMouseOver) 128 { 129 mbOldMouseOverState = mbCurrentMouseOverState; 130 mbCurrentMouseOverState = bIsMouseOver; 131 } 132 133 134 135 136 sal_Int32 VisualState::GetStateAnimationId (void) const 137 { 138 return mnStateAnimationId; 139 } 140 141 142 143 144 void VisualState::SetStateAnimationId (const sal_Int32 nAnimationId) 145 { 146 mnStateAnimationId = nAnimationId; 147 } 148 149 150 151 152 Point VisualState::GetLocationOffset (void) const 153 { 154 return maLocationOffset; 155 } 156 157 158 159 160 bool VisualState::SetLocationOffset (const Point& rOffset) 161 { 162 if (maLocationOffset != rOffset) 163 { 164 maLocationOffset = rOffset; 165 return true; 166 } 167 else 168 return false; 169 } 170 171 172 173 174 sal_Int32 VisualState::GetLocationAnimationId (void) const 175 { 176 return mnLocationAnimationId; 177 } 178 179 180 181 182 void VisualState::SetLocationAnimationId (const sal_Int32 nAnimationId) 183 { 184 mnLocationAnimationId = nAnimationId; 185 } 186 187 188 189 190 double VisualState::GetButtonAlpha (void) const 191 { 192 return mnButtonAlpha; 193 } 194 195 196 197 198 void VisualState::SetButtonAlpha (const double nAlpha) 199 { 200 mnButtonAlpha = nAlpha; 201 } 202 203 204 205 206 double VisualState::GetButtonBarAlpha (void) const 207 { 208 return mnButtonBarAlpha; 209 } 210 211 212 213 214 void VisualState::SetButtonBarAlpha (const double nAlpha) 215 { 216 mnButtonBarAlpha = nAlpha; 217 } 218 219 220 221 222 sal_Int32 VisualState::GetButtonAlphaAnimationId (void) const 223 { 224 return mnButtonAlphaAnimationId; 225 } 226 227 228 229 230 void VisualState::SetButtonAlphaAnimationId (const sal_Int32 nAnimationId) 231 { 232 mnButtonAlphaAnimationId = nAnimationId; 233 } 234 235 236 } } } // end of namespace ::sd::slidesorter::model 237