summaryrefslogtreecommitdiff
path: root/indra/llui/lliconctrl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui/lliconctrl.cpp')
-rw-r--r--indra/llui/lliconctrl.cpp128
1 files changed, 32 insertions, 96 deletions
diff --git a/indra/llui/lliconctrl.cpp b/indra/llui/lliconctrl.cpp
index cb3b2a3a62..eddfc71284 100644
--- a/indra/llui/lliconctrl.cpp
+++ b/indra/llui/lliconctrl.cpp
@@ -40,65 +40,33 @@
#include "llcontrol.h"
#include "llui.h"
#include "lluictrlfactory.h"
+#include "lluiimage.h"
-const F32 RESOLUTION_BUMP = 1.f;
+static LLDefaultWidgetRegistry::Register<LLIconCtrl> r("icon");
-static LLRegisterWidget<LLIconCtrl> r("icon");
-
-LLIconCtrl::LLIconCtrl(const std::string& name, const LLRect &rect, const LLUUID &image_id)
-: LLUICtrl(name,
- rect,
- FALSE, // mouse opaque
- NULL, NULL,
- FOLLOWS_LEFT | FOLLOWS_TOP),
- mColor( LLColor4::white )
-{
- setImage( image_id );
- setTabStop(FALSE);
-}
-
-LLIconCtrl::LLIconCtrl(const std::string& name, const LLRect &rect, const std::string &image_name)
-: LLUICtrl(name,
- rect,
- FALSE, // mouse opaque
- NULL, NULL,
- FOLLOWS_LEFT | FOLLOWS_TOP),
- mColor( LLColor4::white ),
- mImageName(image_name)
-{
- setImage( image_name );
- setTabStop(FALSE);
-}
-
-
-LLIconCtrl::~LLIconCtrl()
+LLIconCtrl::Params::Params()
+: image("image_name"),
+ color("color"),
+ scale_image("scale_image")
{
- mImagep = NULL;
+ tab_stop = false;
+ mouse_opaque = false;
}
-
-void LLIconCtrl::setImage(const std::string& image_name)
+LLIconCtrl::LLIconCtrl(const LLIconCtrl::Params& p)
+: LLUICtrl(p),
+ mColor(p.color()),
+ mImagep(p.image)
{
- //RN: support UUIDs masquerading as strings
- if (LLUUID::validate(image_name))
- {
- mImageID = LLUUID(image_name);
-
- setImage(mImageID);
- }
- else
+ if (mImagep.notNull())
{
- mImageName = image_name;
- mImagep = LLUI::sImageProvider->getUIImage(image_name);
- mImageID.setNull();
+ LLUICtrl::setValue(mImagep->getName());
}
}
-void LLIconCtrl::setImage(const LLUUID& image_id)
+LLIconCtrl::~LLIconCtrl()
{
- mImageName.clear();
- mImagep = LLUI::sImageProvider->getUIImageByID(image_id);
- mImageID = image_id;
+ mImagep = NULL;
}
@@ -106,69 +74,37 @@ void LLIconCtrl::draw()
{
if( mImagep.notNull() )
{
- mImagep->draw(getLocalRect(), mColor );
+ mImagep->draw(getLocalRect(), mColor.get() );
}
LLUICtrl::draw();
}
// virtual
+// value might be a string or a UUID
void LLIconCtrl::setValue(const LLSD& value )
{
- if (value.isUUID())
+ LLSD tvalue(value);
+ if (value.isString() && LLUUID::validate(value.asString()))
{
- setImage(value.asUUID());
+ //RN: support UUIDs masquerading as strings
+ tvalue = LLSD(LLUUID(value.asString()));
}
- else
+ LLUICtrl::setValue(tvalue);
+ if (tvalue.isUUID())
{
- setImage(value.asString());
+ mImagep = LLUI::getUIImageByID(tvalue.asUUID());
}
-}
-
-// virtual
-LLSD LLIconCtrl::getValue() const
-{
- LLSD ret = getImage();
- return ret;
-}
-
-// virtual
-LLXMLNodePtr LLIconCtrl::getXML(bool save_children) const
-{
- LLXMLNodePtr node = LLUICtrl::getXML();
-
- if (mImageName != "")
+ else
{
- node->createChild("image_name", TRUE)->setStringValue(mImageName);
+ mImagep = LLUI::getUIImage(tvalue.asString());
}
-
- node->createChild("color", TRUE)->setFloatValue(4, mColor.mV);
-
- return node;
}
-LLView* LLIconCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
+std::string LLIconCtrl::getImageName() const
{
- std::string name("icon");
- node->getAttributeString("name", name);
-
- LLRect rect;
- createRect(node, rect, parent, LLRect());
-
- std::string image_name;
- if (node->hasAttribute("image_name"))
- {
- node->getAttributeString("image_name", image_name);
- }
-
- LLColor4 color(LLColor4::white);
- LLUICtrlFactory::getAttributeColor(node,"color", color);
-
- LLIconCtrl* icon = new LLIconCtrl(name, rect, image_name);
-
- icon->setColor(color);
-
- icon->initFromXML(node, parent);
-
- return icon;
+ if (getValue().isString())
+ return getValue().asString();
+ else
+ return std::string();
}