More work on accordions, let params do lluiimages like upstream

This commit is contained in:
Inusaito Sayori
2015-09-30 20:05:40 -04:00
parent ed701f9c88
commit bc0709b9c6
4 changed files with 168 additions and 11 deletions

View File

@@ -152,3 +152,48 @@ void LLUIImage::onImageLoaded()
}
}
namespace LLInitParam
{
void ParamValue<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")
{
updateValue(NULL);
return;
}
LLUIImage* imagep = LLRender2D::getUIImage(name());
if (imagep)
{
updateValue(imagep);
}
}
void ParamValue<LLUIImage*>::updateBlockFromValue(bool make_block_authoritative)
{
if (getValue() == NULL)
{
name.set("none", make_block_authoritative);
}
else
{
name.set(getValue()->getName(), make_block_authoritative);
}
}
bool ParamCompare<LLUIImage*, false>::equals(
LLUIImage* const &a,
LLUIImage* const &b)
{
// force all LLUIImages for XML UI export to be "non-default"
if (!a && !b)
return false;
else
return (a == b);
}
}

View File

@@ -34,6 +34,7 @@
#include "llrect.h"
#include <boost/function.hpp>
#include <boost/signals2.hpp>
#include "llinitparam.h"
#include "lltexture.h"
extern const LLColor4 UI_VERTEX_COLOR;
@@ -88,6 +89,36 @@ protected:
BOOL mNoClip;
};
namespace LLInitParam
{
template<>
class ParamValue<LLUIImage*>
: public CustomParamValue<LLUIImage*>
{
typedef boost::add_reference<boost::add_const<LLUIImage*>::type>::type T_const_ref;
typedef CustomParamValue<LLUIImage*> super_t;
public:
Optional<std::string> name;
ParamValue(LLUIImage* const& image = NULL)
: super_t(image)
{
updateBlockFromValue(false);
addSynonym(name, "name");
}
void updateValueFromBlock();
void updateBlockFromValue(bool make_block_authoritative);
};
// Need custom comparison function for our test app, which only loads
// LLUIImage* as NULL.
template<>
struct ParamCompare<LLUIImage*, false>
{
static bool equals(LLUIImage* const &a, LLUIImage* const &b);
};
}
typedef LLPointer<LLUIImage> LLUIImagePtr;
#endif