EXP-648 FIX As a developer, I want to be able to specify param blocks that use Multiple<LLUIImage> for a sequence of images

Factored out param block data classes so that specialized param block types, such as LLUIImage, LLFontGL, LLRect, etc. can be stored in a Multiple<T> context
Converted loading_indicator to take image sequence from XUI
deprecated name-value pairs for LLUIColor values, and put them in colors.xml
master
Richard Linden 2011-04-19 16:16:54 -07:00
parent 08fa1c613a
commit 1dedd3de05
13 changed files with 886 additions and 802 deletions

View File

@ -38,57 +38,25 @@
// registered in llui.cpp to avoid being left out by MS linker
//static LLDefaultChildRegistry::Register<LLLoadingIndicator> r("loading_indicator");
///////////////////////////////////////////////////////////////////////////////
// LLLoadingIndicator::Data class
///////////////////////////////////////////////////////////////////////////////
/**
* Pre-loaded images shared by all instances of the widget
*/
class LLLoadingIndicator::Data: public LLSingleton<LLLoadingIndicator::Data>
{
public:
/*virtual*/ void initSingleton(); // from LLSingleton
LLPointer<LLUIImage> getNextImage(S8& idx) const;
U8 getImagesCount() const { return NIMAGES; }
private:
static const U8 NIMAGES = 12;
LLPointer<LLUIImage> mImages[NIMAGES];
};
// virtual
// Called right after the instance gets constructed.
void LLLoadingIndicator::Data::initSingleton()
{
// Load images.
for (U8 i = 0; i < NIMAGES; ++i)
{
std::string img_name = llformat("Progress_%d", i+1);
mImages[i] = LLUI::getUIImage(img_name, 0);
llassert(mImages[i]);
}
}
LLPointer<LLUIImage> LLLoadingIndicator::Data::getNextImage(S8& idx) const
{
// Calculate next index, performing array bounds checking.
idx = (idx >= NIMAGES || idx < 0) ? 0 : (idx + 1) % NIMAGES;
return mImages[idx];
}
///////////////////////////////////////////////////////////////////////////////
// LLLoadingIndicator class
///////////////////////////////////////////////////////////////////////////////
LLLoadingIndicator::LLLoadingIndicator(const Params& p)
: LLUICtrl(p)
, mRotationsPerSec(p.rotations_per_sec > 0 ? p.rotations_per_sec : 1.0f)
, mCurImageIdx(-1)
: LLUICtrl(p),
mImagesPerSec(p.images_per_sec > 0 ? p.images_per_sec : 1.0f),
mCurImageIdx(0)
{
// Select initial image.
mCurImagep = Data::instance().getNextImage(mCurImageIdx);
}
void LLLoadingIndicator::initFromParams(const Params& p)
{
for (LLInitParam::ParamIterator<LLUIImage*>::const_iterator it = p.images().image.begin(), end_it = p.images().image.end();
it != end_it;
++it)
{
mImages.push_back(it->getValue());
}
// Start timer for switching images.
start();
@ -100,16 +68,21 @@ void LLLoadingIndicator::draw()
if (mImageSwitchTimer.getStarted() && mImageSwitchTimer.hasExpired())
{
// Switch to the next image.
mCurImagep = Data::instance().getNextImage(mCurImageIdx);
if (!mImages.empty())
{
mCurImageIdx = (mCurImageIdx + 1) % mImages.size();
}
// Restart timer.
start();
}
LLUIImagePtr cur_image = mImages.empty() ? NULL : mImages[mCurImageIdx];
// Draw current image.
if( mCurImagep.notNull() )
if( cur_image.notNull() )
{
mCurImagep->draw(getLocalRect(), LLColor4::white % getDrawContext().mAlpha);
cur_image->draw(getLocalRect(), LLColor4::white % getDrawContext().mAlpha);
}
LLUICtrl::draw();
@ -123,6 +96,6 @@ void LLLoadingIndicator::stop()
void LLLoadingIndicator::start()
{
mImageSwitchTimer.start();
F32 period = 1.0f / (Data::instance().getImagesCount() * mRotationsPerSec);
F32 period = 1.0f / (mImages.size() * mImagesPerSec);
mImageSwitchTimer.setTimerExpirySec(period);
}

View File

@ -36,8 +36,8 @@
/**
* Perpetual loading indicator (a la MacOSX or YouTube)
*
* Number of rotations per second can be overriden
* with the "roations_per_sec" parameter.
* Number of rotations per second can be overridden
* with the "images_per_sec" parameter.
*
* Can start/stop spinning.
*
@ -49,11 +49,24 @@ class LLLoadingIndicator
{
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> rotations_per_sec;
Optional<F32> images_per_sec;
Batch<Images> images;
Params()
: rotations_per_sec("rotations_per_sec", 1.0f)
: images_per_sec("images_per_sec", 1.0f),
images("images")
{}
};
@ -74,14 +87,15 @@ public:
private:
LLLoadingIndicator(const Params&);
void initFromParams(const Params&);
friend class LLUICtrlFactory;
class Data;
F32 mRotationsPerSec;
F32 mImagesPerSec;
S8 mCurImageIdx;
LLPointer<LLUIImage> mCurImagep;
LLFrameTimer mImageSwitchTimer;
std::vector<LLUIImagePtr> mImages;
};
#endif // LL_LLLOADINGINDICATOR_H

View File

@ -1626,8 +1626,8 @@ void LLUI::cleanupClass()
{
if(sImageProvider)
{
sImageProvider->cleanUp();
}
sImageProvider->cleanUp();
}
}
void LLUI::setPopupFuncs(const add_popup_t& add_popup, const remove_popup_t& remove_popup, const clear_popups_t& clear_popups)
@ -2074,32 +2074,32 @@ const LLView* LLUI::resolvePath(const LLView* context, const std::string& path)
namespace LLInitParam
{
TypedParam<LLUIColor >::TypedParam(BlockDescriptor& descriptor, const char* name, const LLUIColor& value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count)
: super_t(descriptor, name, value, func, min_count, max_count),
ParamValue<LLUIColor, TypeValues<LLUIColor> >::ParamValue(const LLUIColor& color)
: super_t(color),
red("red"),
green("green"),
blue("blue"),
alpha("alpha"),
control("")
{
setBlockFromValue();
updateBlockFromValue();
}
void TypedParam<LLUIColor>::setValueFromBlock() const
void ParamValue<LLUIColor, TypeValues<LLUIColor> >::updateValueFromBlock()
{
if (control.isProvided())
{
mData.mValue = LLUIColorTable::instance().getColor(control);
updateValue(LLUIColorTable::instance().getColor(control));
}
else
{
mData.mValue = LLColor4(red, green, blue, alpha);
updateValue(LLColor4(red, green, blue, alpha));
}
}
void TypedParam<LLUIColor>::setBlockFromValue()
void ParamValue<LLUIColor, TypeValues<LLUIColor> >::updateBlockFromValue()
{
LLColor4 color = mData.mValue.get();
LLColor4 color = getValue();
red.set(color.mV[VRED], false);
green.set(color.mV[VGREEN], false);
blue.set(color.mV[VBLUE], false);
@ -2107,38 +2107,32 @@ namespace LLInitParam
control.set("", false);
}
void TypeValues<LLUIColor>::declareValues()
{
declare("white", LLColor4::white);
declare("black", LLColor4::black);
declare("red", LLColor4::red);
declare("green", LLColor4::green);
declare("blue", LLColor4::blue);
}
bool ParamCompare<const LLFontGL*, false>::equals(const LLFontGL* a, const LLFontGL* b)
{
return !(a->getFontDesc() < b->getFontDesc())
&& !(b->getFontDesc() < a->getFontDesc());
}
TypedParam<const LLFontGL*>::TypedParam(BlockDescriptor& descriptor, const char* _name, const LLFontGL*const value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count)
: super_t(descriptor, _name, value, func, min_count, max_count),
ParamValue<const LLFontGL*, TypeValues<const LLFontGL*> >::ParamValue(const LLFontGL* fontp)
: super_t(fontp),
name("name"),
size("size"),
style("style")
{
setBlockFromValue();
if (!fontp)
{
updateValue(LLFontGL::getFontDefault());
}
addSynonym(name, "");
setBlockFromValue();
updateBlockFromValue();
}
void TypedParam<const LLFontGL*>::setValueFromBlock() const
void ParamValue<const LLFontGL*, TypeValues<const LLFontGL*> >::updateValueFromBlock()
{
const LLFontGL* res_fontp = LLFontGL::getFontByName(name);
if (res_fontp)
{
mData.mValue = res_fontp;
updateValue(res_fontp);
return;
}
@ -2148,22 +2142,26 @@ namespace LLInitParam
const LLFontGL* fontp = LLFontGL::getFont(desc);
if (fontp)
{
mData.mValue = fontp;
}
updateValue(fontp);
}
else
{
updateValue(LLFontGL::getFontDefault());
}
}
void TypedParam<const LLFontGL*>::setBlockFromValue()
void ParamValue<const LLFontGL*, TypeValues<const LLFontGL*> >::updateBlockFromValue()
{
if (mData.mValue)
if (getValue())
{
name.set(LLFontGL::nameFromFont(mData.mValue), false);
size.set(LLFontGL::sizeFromFont(mData.mValue), false);
style.set(LLFontGL::getStringFromStyle(mData.mValue->getFontDesc().getStyle()), false);
name.set(LLFontGL::nameFromFont(getValue()), false);
size.set(LLFontGL::sizeFromFont(getValue()), false);
style.set(LLFontGL::getStringFromStyle(getValue()->getFontDesc().getStyle()), false);
}
}
TypedParam<LLRect>::TypedParam(BlockDescriptor& descriptor, const char* name, const LLRect& value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count)
: super_t(descriptor, name, value, func, min_count, max_count),
ParamValue<LLRect, TypeValues<LLRect> >::ParamValue(const LLRect& rect)
: super_t(rect),
left("left"),
top("top"),
right("right"),
@ -2171,10 +2169,10 @@ namespace LLInitParam
width("width"),
height("height")
{
setBlockFromValue();
updateBlockFromValue();
}
void TypedParam<LLRect>::setValueFromBlock() const
void ParamValue<LLRect, TypeValues<LLRect> >::updateValueFromBlock()
{
LLRect rect;
@ -2235,40 +2233,41 @@ namespace LLInitParam
rect.mBottom = bottom;
rect.mTop = top;
}
mData.mValue = rect;
updateValue(rect);
}
void TypedParam<LLRect>::setBlockFromValue()
void ParamValue<LLRect, TypeValues<LLRect> >::updateBlockFromValue()
{
// because of the ambiguity in specifying a rect by position and/or dimensions
// we clear the "provided" flag so that values from xui/etc have priority
// over those calculated from the rect object
left.set(mData.mValue.mLeft, false);
right.set(mData.mValue.mRight, false);
bottom.set(mData.mValue.mBottom, false);
top.set(mData.mValue.mTop, false);
width.set(mData.mValue.getWidth(), false);
height.set(mData.mValue.getHeight(), false);
LLRect& value = getValue();
left.set(value.mLeft, false);
right.set(value.mRight, false);
bottom.set(value.mBottom, false);
top.set(value.mTop, false);
width.set(value.getWidth(), false);
height.set(value.getHeight(), false);
}
TypedParam<LLCoordGL>::TypedParam(BlockDescriptor& descriptor, const char* name, LLCoordGL value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count)
: super_t(descriptor, name, value, func, min_count, max_count),
ParamValue<LLCoordGL, TypeValues<LLCoordGL> >::ParamValue(const LLCoordGL& coord)
: super_t(coord),
x("x"),
y("y")
{
setBlockFromValue();
updateBlockFromValue();
}
void TypedParam<LLCoordGL>::setValueFromBlock() const
void ParamValue<LLCoordGL, TypeValues<LLCoordGL> >::updateValueFromBlock()
{
mData.mValue.set(x, y);
updateValue(LLCoordGL(x, y));
}
void TypedParam<LLCoordGL>::setBlockFromValue()
void ParamValue<LLCoordGL, TypeValues<LLCoordGL> >::updateBlockFromValue()
{
x.set(mData.mValue.mX, false);
y.set(mData.mValue.mY, false);
x.set(getValue().mX, false);
y.set(getValue().mY, false);
}

View File

@ -398,10 +398,10 @@ public:
namespace LLInitParam
{
template<>
class TypedParam<LLRect>
: public BlockValue<LLRect>
class ParamValue<LLRect, TypeValues<LLRect> >
: public CustomParamValue<LLRect>
{
typedef BlockValue<LLRect> super_t;
typedef CustomParamValue<LLRect> super_t;
public:
Optional<S32> left,
top,
@ -410,62 +410,43 @@ namespace LLInitParam
width,
height;
TypedParam(BlockDescriptor& descriptor, const char* name, const LLRect& value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count);
ParamValue(const LLRect& value);
void setValueFromBlock() const;
void setBlockFromValue();
void updateValueFromBlock();
void updateBlockFromValue();
};
template<>
struct TypeValues<LLUIColor> : public TypeValuesHelper<LLUIColor>
class ParamValue<LLUIColor, TypeValues<LLUIColor> >
: public CustomParamValue<LLUIColor>
{
static void declareValues();
};
typedef CustomParamValue<LLUIColor> super_t;
template<>
class TypedParam<LLUIColor>
: public BlockValue<LLUIColor>
{
typedef BlockValue<LLUIColor> super_t;
public:
Optional<F32> red,
green,
blue,
alpha;
Optional<std::string> control;
Optional<F32> red,
green,
blue,
alpha;
Optional<std::string> control;
TypedParam(BlockDescriptor& descriptor, const char* name, const LLUIColor& value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count);
void setValueFromBlock() const;
void setBlockFromValue();
ParamValue(const LLUIColor& color);
void updateValueFromBlock();
void updateBlockFromValue();
};
// provide a better default for Optional<const LLFontGL*> than NULL
template <>
struct DefaultInitializer<const LLFontGL*>
{
// return reference to a single default instance of T
// built-in types will be initialized to zero, default constructor otherwise
static const LLFontGL* get()
{
static const LLFontGL* sDefaultFont = LLFontGL::getFontDefault();
return sDefaultFont;
}
};
template<>
class TypedParam<const LLFontGL*>
: public BlockValue<const LLFontGL*>
class ParamValue<const LLFontGL*, TypeValues<const LLFontGL*> >
: public CustomParamValue<const LLFontGL* >
{
typedef BlockValue<const LLFontGL*> super_t;
typedef CustomParamValue<const LLFontGL*> super_t;
public:
Optional<std::string> name,
size,
style;
TypedParam(BlockDescriptor& descriptor, const char* name, const LLFontGL* const value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count);
void setValueFromBlock() const;
void setBlockFromValue();
ParamValue(const LLFontGL* value);
void updateValueFromBlock();
void updateBlockFromValue();
};
template<>
@ -494,17 +475,17 @@ namespace LLInitParam
template<>
class TypedParam<LLCoordGL>
: public BlockValue<LLCoordGL>
class ParamValue<LLCoordGL, TypeValues<LLCoordGL> >
: public CustomParamValue<LLCoordGL>
{
typedef BlockValue<LLCoordGL> super_t;
typedef CustomParamValue<LLCoordGL> super_t;
public:
Optional<S32> x,
y;
TypedParam(BlockDescriptor& descriptor, const char* name, LLCoordGL value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count);
void setValueFromBlock() const;
void setBlockFromValue();
ParamValue(const LLCoordGL& val);
void updateValueFromBlock();
void updateBlockFromValue();
};
}

View File

@ -155,32 +155,32 @@ void LLUIImage::onImageLoaded()
namespace LLInitParam
{
void TypedParam<LLUIImage*>::setValueFromBlock() const
void ParamValue<LLUIImage*, TypeValues<LLUIImage*> >::updateValueFromBlock()
{
// The keyword "none" is specifically requesting a null image
// do not default to current value. Used to overwrite template images.
if (name() == "none")
{
mData.mValue = NULL;
updateValue(NULL);
return;
}
LLUIImage* imagep = LLUI::getUIImage(name());
if (imagep)
{
mData.mValue = imagep;
updateValue(imagep);
}
}
void TypedParam<LLUIImage*>::setBlockFromValue()
void ParamValue<LLUIImage*, TypeValues<LLUIImage*> >::updateBlockFromValue()
{
if (mData.mValue == NULL)
if (getValue() == NULL)
{
name.set("none", false);
}
else
{
name.set(mData.mValue->getName(), false);
name.set(getValue()->getName(), false);
}
}

View File

@ -92,22 +92,23 @@ protected:
namespace LLInitParam
{
template<>
class TypedParam<LLUIImage*, TypeValues<LLUIImage*>, false>
: public BlockValue<LLUIImage*>
class ParamValue<LLUIImage*, TypeValues<LLUIImage*> >
: public CustomParamValue<LLUIImage*>
{
typedef boost::add_reference<boost::add_const<LLUIImage*>::type>::type T_const_ref;
typedef BlockValue<LLUIImage*> super_t;
typedef CustomParamValue<LLUIImage*> super_t;
public:
Optional<std::string> name;
TypedParam(BlockDescriptor& descriptor, const char* name, super_t::value_assignment_t value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count)
: super_t(descriptor, name, value, func, min_count, max_count)
ParamValue(LLUIImage* const& image)
: super_t(image)
{
setBlockFromValue();
updateBlockFromValue();
addSynonym(name, "name");
}
void setValueFromBlock() const;
void setBlockFromValue();
void updateValueFromBlock();
void updateBlockFromValue();
};
// Need custom comparison function for our test app, which only loads

View File

@ -114,29 +114,30 @@ namespace LLInitParam
const U8* block_addr = reinterpret_cast<const U8*>(enclosing_block);
mEnclosingBlockOffset = (U16)(my_addr - block_addr);
}
void BaseBlock::setLastChangedParam(const Param& last_param, bool user_provided) {}
void BaseBlock::paramChanged(const Param& last_param, bool user_provided) {}
void BaseBlock::addParam(BlockDescriptor& block_data, const ParamDescriptor& in_param, const char* char_name){}
void BaseBlock::addParam(BlockDescriptor& block_data, const ParamDescriptorPtr in_param, const char* char_name){}
void BaseBlock::addSynonym(Param& param, const std::string& synonym) {}
param_handle_t BaseBlock::getHandleFromParam(const Param* param) const {return 0;}
void BaseBlock::init(BlockDescriptor& descriptor, BlockDescriptor& base_descriptor, size_t block_size)
{
descriptor.mCurrentBlockPtr = this;
}
bool BaseBlock::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack){ return true; }
bool BaseBlock::serializeBlock(Parser& parser, Parser::name_stack_t name_stack, const LLInitParam::BaseBlock* diff_block) const { return true; }
bool BaseBlock::inspectBlock(Parser& parser, Parser::name_stack_t name_stack) const { return true; }
bool BaseBlock::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack, S32 generation){ return true; }
void BaseBlock::serializeBlock(Parser& parser, Parser::name_stack_t name_stack, const LLInitParam::BaseBlock* diff_block) const {}
bool BaseBlock::inspectBlock(Parser& parser, Parser::name_stack_t name_stack, S32 min_value, S32 max_value) const { return true; }
bool BaseBlock::merge(BlockDescriptor& block_data, const BaseBlock& other, bool overwrite) { return true; }
bool BaseBlock::validateBlock(bool emit_errors) const { return true; }
TypedParam<LLUIColor >::TypedParam(BlockDescriptor& descriptor, const char* name, const LLUIColor& value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count)
: super_t(descriptor, name, value, func, min_count, max_count)
ParamValue<LLUIColor, TypeValues<LLUIColor> >::ParamValue(const LLUIColor& color)
: super_t(color)
{}
void TypedParam<LLUIColor>::setValueFromBlock() const
void ParamValue<LLUIColor, TypeValues<LLUIColor> >::updateValueFromBlock()
{}
void TypedParam<LLUIColor>::setBlockFromValue()
void ParamValue<LLUIColor, TypeValues<LLUIColor> >::updateBlockFromValue()
{}
void TypeValues<LLUIColor>::declareValues()
@ -147,14 +148,14 @@ namespace LLInitParam
return false;
}
TypedParam<const LLFontGL*>::TypedParam(BlockDescriptor& descriptor, const char* _name, const LLFontGL*const value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count)
: super_t(descriptor, _name, value, func, min_count, max_count)
ParamValue<const LLFontGL*, TypeValues<const LLFontGL*> >::ParamValue(const LLFontGL* fontp)
: super_t(fontp)
{}
void TypedParam<const LLFontGL*>::setValueFromBlock() const
void ParamValue<const LLFontGL*, TypeValues<const LLFontGL*> >::updateValueFromBlock()
{}
void TypedParam<const LLFontGL*>::setBlockFromValue()
void ParamValue<const LLFontGL*, TypeValues<const LLFontGL*> >::updateBlockFromValue()
{}
void TypeValues<LLFontGL::HAlign>::declareValues()
@ -166,10 +167,10 @@ namespace LLInitParam
void TypeValues<LLFontGL::ShadowType>::declareValues()
{}
void TypedParam<LLUIImage*>::setValueFromBlock() const
void ParamValue<LLUIImage*, TypeValues<LLUIImage*> >::updateValueFromBlock()
{}
void TypedParam<LLUIImage*>::setBlockFromValue()
void ParamValue<LLUIImage*, TypeValues<LLUIImage*> >::updateBlockFromValue()
{}

View File

@ -70,6 +70,22 @@ S32 LLUIImage::getHeight() const
return 0;
}
namespace LLInitParam
{
S32 Parser::sNextParseGeneration = 0;
BlockDescriptor::BlockDescriptor() {}
ParamDescriptor::ParamDescriptor(param_handle_t p,
merge_func_t merge_func,
deserialize_func_t deserialize_func,
serialize_func_t serialize_func,
validation_func_t validation_func,
inspect_func_t inspect_func,
S32 min_count,
S32 max_count){}
ParamDescriptor::~ParamDescriptor() {}
}
namespace tut
{
struct LLUrlEntryData

View File

@ -66,11 +66,25 @@ namespace LLInitParam
BaseBlock::BaseBlock() {}
BaseBlock::~BaseBlock() {}
void BaseBlock::setLastChangedParam(const Param& last_param, bool user_provided) {}
S32 Parser::sNextParseGeneration = 0;
void BaseBlock::addParam(BlockDescriptor& block_data, const ParamDescriptor& in_param, const char* char_name){}
BlockDescriptor::BlockDescriptor() {}
ParamDescriptor::ParamDescriptor(param_handle_t p,
merge_func_t merge_func,
deserialize_func_t deserialize_func,
serialize_func_t serialize_func,
validation_func_t validation_func,
inspect_func_t inspect_func,
S32 min_count,
S32 max_count){}
ParamDescriptor::~ParamDescriptor() {}
void BaseBlock::paramChanged(const Param& last_param, bool user_provided) {}
void BaseBlock::addParam(BlockDescriptor& block_data, const ParamDescriptorPtr in_param, const char* char_name){}
param_handle_t BaseBlock::getHandleFromParam(const Param* param) const {return 0;}
void BaseBlock::addSynonym(Param& param, const std::string& synonym) {}
void BaseBlock::init(BlockDescriptor& descriptor, BlockDescriptor& base_descriptor, size_t block_size)
{
descriptor.mCurrentBlockPtr = this;
@ -84,20 +98,20 @@ namespace LLInitParam
mEnclosingBlockOffset = (U16)(my_addr - block_addr);
}
bool BaseBlock::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack){ return true; }
bool BaseBlock::serializeBlock(Parser& parser, Parser::name_stack_t name_stack, const LLInitParam::BaseBlock* diff_block) const { return true; }
bool BaseBlock::inspectBlock(Parser& parser, Parser::name_stack_t name_stack) const { return true; }
bool BaseBlock::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack, S32 generation){ return true; }
void BaseBlock::serializeBlock(Parser& parser, Parser::name_stack_t name_stack, const LLInitParam::BaseBlock* diff_block) const {}
bool BaseBlock::inspectBlock(Parser& parser, Parser::name_stack_t name_stack, S32 min_count, S32 max_count) const { return true; }
bool BaseBlock::merge(BlockDescriptor& block_data, const BaseBlock& other, bool overwrite) { return true; }
bool BaseBlock::validateBlock(bool emit_errors) const { return true; }
TypedParam<LLUIColor >::TypedParam(BlockDescriptor& descriptor, const char* name, const LLUIColor& value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count)
: super_t(descriptor, name, value, func, min_count, max_count)
ParamValue<LLUIColor, TypeValues<LLUIColor> >::ParamValue(const LLUIColor& color)
: super_t(color)
{}
void TypedParam<LLUIColor>::setValueFromBlock() const
void ParamValue<LLUIColor, TypeValues<LLUIColor> >::updateValueFromBlock()
{}
void TypedParam<LLUIColor>::setBlockFromValue()
void ParamValue<LLUIColor, TypeValues<LLUIColor> >::updateBlockFromValue()
{}
void TypeValues<LLUIColor>::declareValues()
@ -108,14 +122,15 @@ namespace LLInitParam
return false;
}
TypedParam<const LLFontGL*>::TypedParam(BlockDescriptor& descriptor, const char* _name, const LLFontGL*const value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count)
: super_t(descriptor, _name, value, func, min_count, max_count)
ParamValue<const LLFontGL*, TypeValues<const LLFontGL*> >::ParamValue(const LLFontGL* fontp)
: super_t(fontp)
{}
void TypedParam<const LLFontGL*>::setValueFromBlock() const
void ParamValue<const LLFontGL*, TypeValues<const LLFontGL*> >::updateValueFromBlock()
{}
void TypedParam<const LLFontGL*>::setBlockFromValue()
void ParamValue<const LLFontGL*, TypeValues<const LLFontGL*> >::updateBlockFromValue()
{}
void TypeValues<LLFontGL::HAlign>::declareValues()
@ -127,10 +142,10 @@ namespace LLInitParam
void TypeValues<LLFontGL::ShadowType>::declareValues()
{}
void TypedParam<LLUIImage*>::setValueFromBlock() const
void ParamValue<LLUIImage*, TypeValues<LLUIImage*> >::updateValueFromBlock()
{}
void TypedParam<LLUIImage*>::setBlockFromValue()
void ParamValue<LLUIImage*, TypeValues<LLUIImage*> >::updateBlockFromValue()
{}
bool ParamCompare<LLUIImage*, false>::equals(

View File

@ -43,9 +43,52 @@ namespace LLInitParam
mEnclosingBlockOffset = (U16)(my_addr - block_addr);
}
//
// ParamDescriptor
//
ParamDescriptor::ParamDescriptor(param_handle_t p,
merge_func_t merge_func,
deserialize_func_t deserialize_func,
serialize_func_t serialize_func,
validation_func_t validation_func,
inspect_func_t inspect_func,
S32 min_count,
S32 max_count)
: mParamHandle(p),
mMergeFunc(merge_func),
mDeserializeFunc(deserialize_func),
mSerializeFunc(serialize_func),
mValidationFunc(validation_func),
mInspectFunc(inspect_func),
mMinCount(min_count),
mMaxCount(max_count),
mGeneration(0),
mUserData(NULL)
{}
ParamDescriptor::ParamDescriptor()
: mParamHandle(0),
mMergeFunc(NULL),
mDeserializeFunc(NULL),
mSerializeFunc(NULL),
mValidationFunc(NULL),
mInspectFunc(NULL),
mMinCount(0),
mMaxCount(0),
mGeneration(0),
mUserData(NULL)
{}
ParamDescriptor::~ParamDescriptor()
{
delete mUserData;
}
//
// Parser
//
S32 Parser::sNextParseGeneration = 0;
Parser::~Parser()
{}
@ -73,6 +116,12 @@ namespace LLInitParam
std::copy(src_block_data.mAllParams.begin(), src_block_data.mAllParams.end(), std::back_inserter(mAllParams));
}
BlockDescriptor::BlockDescriptor()
: mMaxParamOffset(0),
mInitializationState(UNINITIALIZED),
mCurrentBlockPtr(NULL)
{}
//
// BaseBlock
//
@ -115,7 +164,7 @@ namespace LLInitParam
bool BaseBlock::submitValue(const Parser::name_stack_t& name_stack, Parser& p, bool silent)
{
if (!deserializeBlock(p, std::make_pair(name_stack.begin(), name_stack.end())))
if (!deserializeBlock(p, std::make_pair(name_stack.begin(), name_stack.end()), -1))
{
if (!silent)
{
@ -145,7 +194,7 @@ namespace LLInitParam
return true;
}
bool BaseBlock::serializeBlock(Parser& parser, Parser::name_stack_t name_stack, const LLInitParam::BaseBlock* diff_block) const
void BaseBlock::serializeBlock(Parser& parser, Parser::name_stack_t name_stack, const LLInitParam::BaseBlock* diff_block) const
{
// named param is one like LLView::Params::follows
// unnamed param is like LLView::Params::rect - implicit
@ -212,11 +261,9 @@ namespace LLInitParam
name_stack.pop_back();
}
}
return true;
}
bool BaseBlock::inspectBlock(Parser& parser, Parser::name_stack_t name_stack) const
bool BaseBlock::inspectBlock(Parser& parser, Parser::name_stack_t name_stack, S32 min_count, S32 max_count) const
{
// named param is one like LLView::Params::follows
// unnamed param is like LLView::Params::rect - implicit
@ -273,11 +320,13 @@ namespace LLInitParam
return true;
}
bool BaseBlock::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack)
bool BaseBlock::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack, S32 parent_generation)
{
BlockDescriptor& block_data = mostDerivedBlockDescriptor();
bool names_left = name_stack.first != name_stack.second;
S32 parse_generation = name_stack.first == name_stack.second ? -1 : name_stack.first->second;
if (names_left)
{
const std::string& top_name = name_stack.first->first;
@ -294,7 +343,7 @@ namespace LLInitParam
Parser::name_stack_range_t new_name_stack(name_stack.first, name_stack.second);
++new_name_stack.first;
return deserialize_func(*paramp, p, new_name_stack, name_stack.first == name_stack.second ? -1 : name_stack.first->second);
return deserialize_func(*paramp, p, new_name_stack, parse_generation);
}
}
@ -306,7 +355,7 @@ namespace LLInitParam
Param* paramp = getParamFromHandle((*it)->mParamHandle);
ParamDescriptor::deserialize_func_t deserialize_func = (*it)->mDeserializeFunc;
if (deserialize_func && deserialize_func(*paramp, p, name_stack, name_stack.first == name_stack.second ? -1 : name_stack.first->second))
if (deserialize_func && deserialize_func(*paramp, p, name_stack, parse_generation))
{
return true;
}
@ -324,32 +373,32 @@ namespace LLInitParam
}
//static
void BaseBlock::addParam(BlockDescriptor& block_data, const ParamDescriptor& in_param, const char* char_name)
void BaseBlock::addParam(BlockDescriptor& block_data, const ParamDescriptorPtr in_param, const char* char_name)
{
// create a copy of the paramdescriptor in allparams
// so other data structures can store a pointer to it
block_data.mAllParams.push_back(in_param);
ParamDescriptor& param(block_data.mAllParams.back());
ParamDescriptorPtr param(block_data.mAllParams.back());
std::string name(char_name);
if ((size_t)param.mParamHandle > block_data.mMaxParamOffset)
if ((size_t)param->mParamHandle > block_data.mMaxParamOffset)
{
llerrs << "Attempted to register param with block defined for parent class, make sure to derive from LLInitParam::Block<YOUR_CLASS, PARAM_BLOCK_BASE_CLASS>" << llendl;
}
if (name.empty())
{
block_data.mUnnamedParams.push_back(&param);
block_data.mUnnamedParams.push_back(param);
}
else
{
// don't use insert, since we want to overwrite existing entries
block_data.mNamedParams[name] = &param;
block_data.mNamedParams[name] = param;
}
if (param.mValidationFunc)
if (param->mValidationFunc)
{
block_data.mValidationList.push_back(std::make_pair(param.mParamHandle, param.mValidationFunc));
block_data.mValidationList.push_back(std::make_pair(param->mParamHandle, param->mValidationFunc));
}
}
@ -367,7 +416,7 @@ namespace LLInitParam
llerrs << "Attempted to register param with block defined for parent class, make sure to derive from LLInitParam::Block<YOUR_CLASS, PARAM_BLOCK_BASE_CLASS>" << llendl;
}
ParamDescriptor* param_descriptor = findParamDescriptor(handle);
ParamDescriptorPtr param_descriptor = findParamDescriptor(param);
if (param_descriptor)
{
if (synonym.empty())
@ -382,7 +431,7 @@ namespace LLInitParam
}
}
void BaseBlock::setLastChangedParam(const Param& last_param, bool user_provided)
void BaseBlock::paramChanged(const Param& changed_param, bool user_provided)
{
if (user_provided)
{
@ -404,17 +453,18 @@ namespace LLInitParam
return LLStringUtil::null;
}
ParamDescriptor* BaseBlock::findParamDescriptor(param_handle_t handle)
ParamDescriptorPtr BaseBlock::findParamDescriptor(const Param& param)
{
param_handle_t handle = getHandleFromParam(&param);
BlockDescriptor& descriptor = mostDerivedBlockDescriptor();
BlockDescriptor::all_params_list_t::iterator end_it = descriptor.mAllParams.end();
for (BlockDescriptor::all_params_list_t::iterator it = descriptor.mAllParams.begin();
it != end_it;
++it)
{
if (it->mParamHandle == handle) return &(*it);
if ((*it)->mParamHandle == handle) return *it;
}
return NULL;
return ParamDescriptorPtr();
}
// take all provided params from other and apply to self
@ -427,19 +477,14 @@ namespace LLInitParam
it != end_it;
++it)
{
const Param* other_paramp = other.getParamFromHandle(it->mParamHandle);
ParamDescriptor::merge_func_t merge_func = it->mMergeFunc;
const Param* other_paramp = other.getParamFromHandle((*it)->mParamHandle);
ParamDescriptor::merge_func_t merge_func = (*it)->mMergeFunc;
if (merge_func)
{
Param* paramp = getParamFromHandle(it->mParamHandle);
Param* paramp = getParamFromHandle((*it)->mParamHandle);
some_param_changed |= merge_func(*paramp, *other_paramp, overwrite);
}
}
return some_param_changed;
}
bool ParamCompare<LLSD, false>::equals(const LLSD &a, const LLSD &b)
{
return false;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -763,4 +763,21 @@
<color
name="MenuBarProjectBgColor"
reference="MdBlue" />
<!-- Generic color names (legacy) -->
<color
name="white"
value="1 1 1 1"/>
<color
name="black"
value="0 0 0 1"/>
<color
name="red"
value="1 0 0 1"/>
<color
name="green"
value="0 1 0 1"/>
<color
name="blue"
value="0 0 1 1"/>
</colors>

View File

@ -3,6 +3,20 @@
follows="left|top"
mouse_opaque="false"
name="loading_indicator"
rotations_per_sec="1.0"
tab_stop="false"
/>
images_per_sec="1.0"
tab_stop="false">
<images>
<image name="Progress_1"/>
<image name="Progress_2"/>
<image name="Progress_3"/>
<image name="Progress_4"/>
<image name="Progress_5"/>
<image name="Progress_6"/>
<image name="Progress_7"/>
<image name="Progress_8"/>
<image name="Progress_9"/>
<image name="Progress_10"/>
<image name="Progress_11"/>
<image name="Progress_12"/>
</images>
</loading_indicator>