PageRenderTime 33ms CodeModel.GetById 19ms app.highlight 9ms RepoModel.GetById 2ms app.codeStats 0ms

/indra/llui/llloadingindicator.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 104 lines | 40 code | 18 blank | 46 comment | 0 complexity | f84122a35ccdcdb103ac4d22e71432d8 MD5 | raw file
  1/** 
  2 * @file llloadingindicator.h
  3 * @brief Perpetual loading indicator
  4 *
  5 * $LicenseInfo:firstyear=2010&license=viewerlgpl$
  6 * Second Life Viewer Source Code
  7 * Copyright (C) 2010, Linden Research, Inc.
  8 * 
  9 * This library is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU Lesser General Public
 11 * License as published by the Free Software Foundation;
 12 * version 2.1 of the License only.
 13 * 
 14 * This library is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 * Lesser General Public License for more details.
 18 * 
 19 * You should have received a copy of the GNU Lesser General Public
 20 * License along with this library; if not, write to the Free Software
 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22 * 
 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 24 * $/LicenseInfo$
 25 */
 26
 27#ifndef LL_LLLOADINGINDICATOR_H
 28#define LL_LLLOADINGINDICATOR_H
 29
 30#include "lluictrl.h"
 31#include "lluiimage.h"
 32
 33///////////////////////////////////////////////////////////////////////////////
 34// class LLLoadingIndicator
 35///////////////////////////////////////////////////////////////////////////////
 36
 37/**
 38 * Perpetual loading indicator (a la MacOSX or YouTube)
 39 * 
 40 * Number of rotations per second can be overridden
 41 * with the "images_per_sec" parameter.
 42 * 
 43 * Can start/stop spinning.
 44 * 
 45 * @see start()
 46 * @see stop()
 47 */
 48class LLLoadingIndicator
 49: public LLUICtrl
 50{
 51	LOG_CLASS(LLLoadingIndicator);
 52public:
 53
 54	struct Images : public LLInitParam::BatchBlock<Images>
 55	{
 56		Multiple<LLUIImage*>	image;
 57
 58		Images()
 59		:	image("image")
 60		{}
 61	};
 62
 63	struct Params : public LLInitParam::Block<Params, LLUICtrl::Params>
 64	{
 65		Optional<F32>			images_per_sec;
 66		Optional<Images>		images;
 67
 68		Params()
 69		:	images_per_sec("images_per_sec", 1.0f),
 70			images("images")
 71		{}
 72	};
 73
 74	virtual ~LLLoadingIndicator() {}
 75
 76	// llview overrides
 77	virtual void draw();
 78
 79	/**
 80	 * Stop spinning.
 81	 */
 82	void stop();
 83
 84	/**
 85	 * Start spinning.
 86	 */
 87	void start();
 88
 89	void reset() { mCurImageIdx = 0; }
 90
 91private:
 92	LLLoadingIndicator(const Params&);
 93	void initFromParams(const Params&);
 94
 95	friend class LLUICtrlFactory;
 96
 97	F32						mImagesPerSec;
 98	S8						mCurImageIdx;
 99	LLFrameTimer			mImageSwitchTimer;
100
101	std::vector<LLUIImagePtr> mImages;
102};
103
104#endif // LL_LLLOADINGINDICATOR_H