Add in LLLoadingIndicator

This commit is contained in:
Lirusaito
2019-01-21 12:08:39 -05:00
parent c8d95e58c3
commit bde8782328
16 changed files with 223 additions and 0 deletions

View File

@@ -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

View File

@@ -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<LLLoadingIndicator> 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);
}

View File

@@ -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<Images>
{
Multiple<LLUIImage*> image;
Images()
: image("image")
{}
};
struct Params : public LLInitParam::Block<Params, LLUICtrl::Params>
{
Optional<F32> images_per_sec;
Optional<Atomic<Images> > 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<LLUIImagePtr> mImages;
};
#endif // LL_LLLOADINGINDICATOR_H

Binary file not shown.

After

Width:  |  Height:  |  Size: 470 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 461 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 475 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 455 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 453 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 454 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 454 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 468 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 462 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 454 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 B

View File

@@ -119,6 +119,19 @@ with the same filename but different name
<texture name="default_profile_picture.j2c"/>
<texture name="locked_image.j2c"/>
<texture name="Progress_1" file_name="icons/Progress_1.png" preload="true" />
<texture name="Progress_2" file_name="icons/Progress_2.png" preload="true" />
<texture name="Progress_3" file_name="icons/Progress_3.png" preload="true" />
<texture name="Progress_4" file_name="icons/Progress_4.png" preload="true" />
<texture name="Progress_5" file_name="icons/Progress_5.png" preload="true" />
<texture name="Progress_6" file_name="icons/Progress_6.png" preload="true" />
<texture name="Progress_7" file_name="icons/Progress_7.png" preload="true" />
<texture name="Progress_8" file_name="icons/Progress_8.png" preload="true" />
<texture name="Progress_9" file_name="icons/Progress_9.png" preload="true" />
<texture name="Progress_10" file_name="icons/Progress_10.png" preload="true" />
<texture name="Progress_11" file_name="icons/Progress_11.png" preload="true" />
<texture name="Progress_12" file_name="icons/Progress_12.png" preload="true" />
<!-- Images that have since been renamed to something else in v3 and need updating. Alphabetical. -->
<texture name="Flag.png" file_name="Flag.png" preload="false" />
<texture name="Inv_WaterLight.png" preload="true"/>