1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef BACKENDS_NETWORKING_CURL_CLOUDICON_H 24 #define BACKENDS_NETWORKING_CURL_CLOUDICON_H 25 26 #include "graphics/surface.h" 27 28 namespace Cloud { 29 30 class CloudIcon { 31 public: 32 CloudIcon(); 33 ~CloudIcon(); 34 35 /** 36 * The type of cloud icon to show 37 */ 38 enum Type { 39 kNone, /** Hide the currently shown icon if any */ 40 kSyncing, /** Cloud syncing icon */ 41 kDisabled /** Cloud syncing not available icon */ 42 }; 43 44 /** 45 * Select the icon to show on the OSD 46 * 47 * @param icon Icon type to show. Use kNone to hide the current icon if any. 48 * @param duration Duration in milliseconds the icon stays visible on screen. 0 means the icon stays indefinitely. 49 */ 50 void show(Type icon, int duration = 0); 51 52 /** The currently visible icon. kNone means no icon is shown. */ 53 Type getShownType() const; 54 55 /** Returns true if the icon state needs to be checked for changes */ 56 bool needsUpdate() const; 57 58 /** Update the icon visible on the OSD */ 59 void update(); 60 61 private: 62 static const float ALPHA_SPEED, ALPHA_MAX, ALPHA_MIN; 63 static const int UPDATE_DELAY_MIN_MILLIS = 10; 64 65 enum State { 66 kHidden, 67 kShown, 68 kGoingToHide 69 }; 70 71 State _state; 72 Type _type; 73 74 Graphics::Surface _icon, _disabledIcon, _alphaIcon; 75 float _currentAlpha; 76 bool _alphaRising; 77 78 uint32 _hideTime; 79 uint32 _lastUpdateTime; 80 81 void initIcons(); 82 void loadIcon(Graphics::Surface &icon, byte *data, uint32 size); 83 void makeAlphaIcon(const Graphics::Surface &icon, float alpha); 84 85 void hide(); 86 }; 87 88 } // End of namespace Cloud 89 90 #endif 91