aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui/lliconctrl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llui/lliconctrl.cpp')
-rw-r--r--linden/indra/llui/lliconctrl.cpp59
1 files changed, 38 insertions, 21 deletions
diff --git a/linden/indra/llui/lliconctrl.cpp b/linden/indra/llui/lliconctrl.cpp
index 6a1d77c..f35de85 100644
--- a/linden/indra/llui/lliconctrl.cpp
+++ b/linden/indra/llui/lliconctrl.cpp
@@ -42,14 +42,15 @@
42 42
43const F32 RESOLUTION_BUMP = 1.f; 43const F32 RESOLUTION_BUMP = 1.f;
44 44
45static LLRegisterWidget<LLIconCtrl> r("icon");
46
45LLIconCtrl::LLIconCtrl(const LLString& name, const LLRect &rect, const LLUUID &image_id) 47LLIconCtrl::LLIconCtrl(const LLString& name, const LLRect &rect, const LLUUID &image_id)
46: LLUICtrl(name, 48: LLUICtrl(name,
47 rect, 49 rect,
48 FALSE, // mouse opaque 50 FALSE, // mouse opaque
49 NULL, NULL, 51 NULL, NULL,
50 FOLLOWS_LEFT | FOLLOWS_TOP), 52 FOLLOWS_LEFT | FOLLOWS_TOP),
51 mColor( LLColor4::white ), 53 mColor( LLColor4::white )
52 mImageName("")
53{ 54{
54 setImage( image_id ); 55 setImage( image_id );
55 setTabStop(FALSE); 56 setTabStop(FALSE);
@@ -64,9 +65,7 @@ LLIconCtrl::LLIconCtrl(const LLString& name, const LLRect &rect, const LLString
64 mColor( LLColor4::white ), 65 mColor( LLColor4::white ),
65 mImageName(image_name) 66 mImageName(image_name)
66{ 67{
67 LLUUID image_id; 68 setImage( image_name );
68 image_id.set(LLUI::sAssetsGroup->getString( image_name ));
69 setImage( image_id );
70 setTabStop(FALSE); 69 setTabStop(FALSE);
71} 70}
72 71
@@ -77,32 +76,52 @@ LLIconCtrl::~LLIconCtrl()
77} 76}
78 77
79 78
80void LLIconCtrl::setImage(const LLUUID &image_id) 79void LLIconCtrl::setImage(const LLString& image_name)
81{ 80{
82 mImageID = image_id; 81 //RN: support UUIDs masquerading as strings
82 if (LLUUID::validate(image_name))
83 {
84 mImageID = LLUUID(image_name);
85
86 setImage(mImageID);
87 }
88 else
89 {
90 mImageName = image_name;
91 mImagep = LLUI::sImageProvider->getUIImage(image_name);
92 mImageID.setNull();
93 }
94}
95
96void LLIconCtrl::setImage(const LLUUID& image_id)
97{
98 mImageName.clear();
83 mImagep = LLUI::sImageProvider->getUIImageByID(image_id); 99 mImagep = LLUI::sImageProvider->getUIImageByID(image_id);
100 mImageID = image_id;
84} 101}
85 102
86 103
87void LLIconCtrl::draw() 104void LLIconCtrl::draw()
88{ 105{
89 if( getVisible() ) 106 if( mImagep.notNull() )
90 { 107 {
91 if( mImagep.notNull() ) 108 mImagep->draw(getLocalRect(), mColor );
92 {
93 mImagep->draw(0, 0,
94 getRect().getWidth(), getRect().getHeight(),
95 mColor );
96 }
97
98 LLUICtrl::draw();
99 } 109 }
110
111 LLUICtrl::draw();
100} 112}
101 113
102// virtual 114// virtual
103void LLIconCtrl::setValue(const LLSD& value ) 115void LLIconCtrl::setValue(const LLSD& value )
104{ 116{
105 setImage(value.asUUID()); 117 if (value.isUUID())
118 {
119 setImage(value.asUUID());
120 }
121 else
122 {
123 setImage(value.asString());
124 }
106} 125}
107 126
108// virtual 127// virtual
@@ -135,18 +154,16 @@ LLView* LLIconCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *
135 LLRect rect; 154 LLRect rect;
136 createRect(node, rect, parent, LLRect()); 155 createRect(node, rect, parent, LLRect());
137 156
138 LLUUID image_id; 157 LLString image_name;
139 if (node->hasAttribute("image_name")) 158 if (node->hasAttribute("image_name"))
140 { 159 {
141 LLString image_name;
142 node->getAttributeString("image_name", image_name); 160 node->getAttributeString("image_name", image_name);
143 image_id.set(LLUI::sAssetsGroup->getString( image_name ));
144 } 161 }
145 162
146 LLColor4 color(LLColor4::white); 163 LLColor4 color(LLColor4::white);
147 LLUICtrlFactory::getAttributeColor(node,"color", color); 164 LLUICtrlFactory::getAttributeColor(node,"color", color);
148 165
149 LLIconCtrl* icon = new LLIconCtrl(name, rect, image_id); 166 LLIconCtrl* icon = new LLIconCtrl(name, rect, image_name);
150 167
151 icon->setColor(color); 168 icon->setColor(color);
152 169