diff --git a/indra/llui/CMakeLists.txt b/indra/llui/CMakeLists.txt index 1ee716cb8..b00081882 100644 --- a/indra/llui/CMakeLists.txt +++ b/indra/llui/CMakeLists.txt @@ -44,6 +44,7 @@ set(llui_SOURCE_FILES llkeywords.cpp lllayoutstack.cpp lllineeditor.cpp + llloadingindicator.cpp lllocalcliprect.cpp llmenugl.cpp llmodaldialog.cpp @@ -122,6 +123,7 @@ set(llui_HEADER_FILES llkeywords.h lllayoutstack.h lllineeditor.h + llloadingindicator.h lllocalcliprect.h llmemberlistener.h llmenugl.h diff --git a/indra/llui/llloadingindicator.cpp b/indra/llui/llloadingindicator.cpp new file mode 100644 index 000000000..915571874 --- /dev/null +++ b/indra/llui/llloadingindicator.cpp @@ -0,0 +1,104 @@ +// This is an open source non-commercial project. Dear PVS-Studio, please check it. +// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com +/** + * @file llloadingindicator.cpp + * @brief Perpetual loading indicator + * + * $LicenseInfo:firstyear=2010&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "linden_common.h" + +#include "llloadingindicator.h" + +// Linden library includes +#include "llsingleton.h" + +// Project includes +#include "lluictrlfactory.h" +#include "lluiimage.h" + +static LLRegisterWidget r("loading_indicator"); + +/////////////////////////////////////////////////////////////////////////////// +// LLLoadingIndicator class +/////////////////////////////////////////////////////////////////////////////// + +LLLoadingIndicator::LLLoadingIndicator(const Params& p) +: LLUICtrl(p), + mImagesPerSec(p.images_per_sec > 0 ? p.images_per_sec : 1.0f), + mCurImageIdx(0) +{ +} + +void LLLoadingIndicator::initFromParams(const Params& p) +{ + for (LLUIImage* image : p.images().image) + { + mImages.push_back(image); + } + + if (mImages.empty()) // Singu Note: We don't have default widgets yet, so let's just handle this here + for (int i = 1; i <= 12; ++i) + mImages.push_back(LLUI::getUIImage(llformat("Progress_%d", i))); + + // Start timer for switching images. + start(); +} + +void LLLoadingIndicator::draw() +{ + // Time to switch to the next image? + if (mImageSwitchTimer.getStarted() && mImageSwitchTimer.hasExpired()) + { + // Switch to the next image. + if (!mImages.empty()) + { + mCurImageIdx = (mCurImageIdx + 1) % mImages.size(); + } + + // Restart timer. + start(); + } + + LLUIImagePtr cur_image = mImages.empty() ? LLUIImagePtr(NULL) : mImages[mCurImageIdx]; + + // Draw current image. + if( cur_image.notNull() ) + { + cur_image->draw(getLocalRect(), LLColor4::white % getDrawContext().mAlpha); + } + + LLUICtrl::draw(); +} + +void LLLoadingIndicator::stop() +{ + mImageSwitchTimer.stop(); +} + +void LLLoadingIndicator::start() +{ + mImageSwitchTimer.start(); + F32 period = 1.0f / (mImages.size() * mImagesPerSec); + mImageSwitchTimer.setTimerExpirySec(period); +} diff --git a/indra/llui/llloadingindicator.h b/indra/llui/llloadingindicator.h new file mode 100644 index 000000000..b5e86c0ac --- /dev/null +++ b/indra/llui/llloadingindicator.h @@ -0,0 +1,104 @@ +/** + * @file llloadingindicator.h + * @brief Perpetual loading indicator + * + * $LicenseInfo:firstyear=2010&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLLOADINGINDICATOR_H +#define LL_LLLOADINGINDICATOR_H + +#include "lluictrl.h" +#include "lluiimage.h" + +/////////////////////////////////////////////////////////////////////////////// +// class LLLoadingIndicator +/////////////////////////////////////////////////////////////////////////////// + +/** + * Perpetual loading indicator (a la MacOSX or YouTube) + * + * Number of rotations per second can be overridden + * with the "images_per_sec" parameter. + * + * Can start/stop spinning. + * + * @see start() + * @see stop() + */ +class LLLoadingIndicator +: public LLUICtrl +{ + LOG_CLASS(LLLoadingIndicator); +public: + + struct Images : public LLInitParam::Block + { + Multiple image; + + Images() + : image("image") + {} + }; + + struct Params : public LLInitParam::Block + { + Optional images_per_sec; + Optional > images; + + Params() + : images_per_sec("images_per_sec", 1.0f), + images("images") + {} + }; + + virtual ~LLLoadingIndicator() {} + + // llview overrides + void draw() override; + + /** + * Stop spinning. + */ + void stop(); + + /** + * Start spinning. + */ + void start(); + + void reset() { mCurImageIdx = 0; } + +private: + LLLoadingIndicator(const Params&); + void initFromParams(const Params&); + + friend class LLUICtrlFactory; + + F32 mImagesPerSec; + S8 mCurImageIdx; + LLFrameTimer mImageSwitchTimer; + + std::vector mImages; +}; + +#endif // LL_LLLOADINGINDICATOR_H diff --git a/indra/newview/skins/default/textures/Progress_1.png b/indra/newview/skins/default/textures/Progress_1.png new file mode 100644 index 000000000..5d6efbfa2 Binary files /dev/null and b/indra/newview/skins/default/textures/Progress_1.png differ diff --git a/indra/newview/skins/default/textures/Progress_10.png b/indra/newview/skins/default/textures/Progress_10.png new file mode 100644 index 000000000..28203324f Binary files /dev/null and b/indra/newview/skins/default/textures/Progress_10.png differ diff --git a/indra/newview/skins/default/textures/Progress_11.png b/indra/newview/skins/default/textures/Progress_11.png new file mode 100644 index 000000000..6b87be0c3 Binary files /dev/null and b/indra/newview/skins/default/textures/Progress_11.png differ diff --git a/indra/newview/skins/default/textures/Progress_12.png b/indra/newview/skins/default/textures/Progress_12.png new file mode 100644 index 000000000..089d58b09 Binary files /dev/null and b/indra/newview/skins/default/textures/Progress_12.png differ diff --git a/indra/newview/skins/default/textures/Progress_2.png b/indra/newview/skins/default/textures/Progress_2.png new file mode 100644 index 000000000..94cb73b1f Binary files /dev/null and b/indra/newview/skins/default/textures/Progress_2.png differ diff --git a/indra/newview/skins/default/textures/Progress_3.png b/indra/newview/skins/default/textures/Progress_3.png new file mode 100644 index 000000000..a04a5b526 Binary files /dev/null and b/indra/newview/skins/default/textures/Progress_3.png differ diff --git a/indra/newview/skins/default/textures/Progress_4.png b/indra/newview/skins/default/textures/Progress_4.png new file mode 100644 index 000000000..a467098d8 Binary files /dev/null and b/indra/newview/skins/default/textures/Progress_4.png differ diff --git a/indra/newview/skins/default/textures/Progress_5.png b/indra/newview/skins/default/textures/Progress_5.png new file mode 100644 index 000000000..ea64f1d90 Binary files /dev/null and b/indra/newview/skins/default/textures/Progress_5.png differ diff --git a/indra/newview/skins/default/textures/Progress_6.png b/indra/newview/skins/default/textures/Progress_6.png new file mode 100644 index 000000000..fe4447935 Binary files /dev/null and b/indra/newview/skins/default/textures/Progress_6.png differ diff --git a/indra/newview/skins/default/textures/Progress_7.png b/indra/newview/skins/default/textures/Progress_7.png new file mode 100644 index 000000000..64fa29477 Binary files /dev/null and b/indra/newview/skins/default/textures/Progress_7.png differ diff --git a/indra/newview/skins/default/textures/Progress_8.png b/indra/newview/skins/default/textures/Progress_8.png new file mode 100644 index 000000000..a1c9a7f2e Binary files /dev/null and b/indra/newview/skins/default/textures/Progress_8.png differ diff --git a/indra/newview/skins/default/textures/Progress_9.png b/indra/newview/skins/default/textures/Progress_9.png new file mode 100644 index 000000000..f3e972318 Binary files /dev/null and b/indra/newview/skins/default/textures/Progress_9.png differ diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml index fcafe9efb..b9d30eb02 100644 --- a/indra/newview/skins/default/textures/textures.xml +++ b/indra/newview/skins/default/textures/textures.xml @@ -119,6 +119,19 @@ with the same filename but different name + + + + + + + + + + + + +