Skip to content

Commit bc0709b

Browse files
committed
More work on accordions, let params do lluiimages like upstream
1 parent ed701f9 commit bc0709b

File tree

4 files changed

+168
-11
lines changed

4 files changed

+168
-11
lines changed

indra/llrender/lluiimage.cpp

+45
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,48 @@ void LLUIImage::onImageLoaded()
152152
}
153153
}
154154

155+
156+
namespace LLInitParam
157+
{
158+
void ParamValue<LLUIImage*>::updateValueFromBlock()
159+
{
160+
// The keyword "none" is specifically requesting a null image
161+
// do not default to current value. Used to overwrite template images.
162+
if (name() == "none")
163+
{
164+
updateValue(NULL);
165+
return;
166+
}
167+
168+
LLUIImage* imagep = LLRender2D::getUIImage(name());
169+
if (imagep)
170+
{
171+
updateValue(imagep);
172+
}
173+
}
174+
175+
void ParamValue<LLUIImage*>::updateBlockFromValue(bool make_block_authoritative)
176+
{
177+
if (getValue() == NULL)
178+
{
179+
name.set("none", make_block_authoritative);
180+
}
181+
else
182+
{
183+
name.set(getValue()->getName(), make_block_authoritative);
184+
}
185+
}
186+
187+
188+
bool ParamCompare<LLUIImage*, false>::equals(
189+
LLUIImage* const &a,
190+
LLUIImage* const &b)
191+
{
192+
// force all LLUIImages for XML UI export to be "non-default"
193+
if (!a && !b)
194+
return false;
195+
else
196+
return (a == b);
197+
}
198+
}
199+

indra/llrender/lluiimage.h

+31
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "llrect.h"
3535
#include <boost/function.hpp>
3636
#include <boost/signals2.hpp>
37+
#include "llinitparam.h"
3738
#include "lltexture.h"
3839

3940
extern const LLColor4 UI_VERTEX_COLOR;
@@ -88,6 +89,36 @@ class LLUIImage : public LLRefCount
8889
BOOL mNoClip;
8990
};
9091

92+
namespace LLInitParam
93+
{
94+
template<>
95+
class ParamValue<LLUIImage*>
96+
: public CustomParamValue<LLUIImage*>
97+
{
98+
typedef boost::add_reference<boost::add_const<LLUIImage*>::type>::type T_const_ref;
99+
typedef CustomParamValue<LLUIImage*> super_t;
100+
public:
101+
Optional<std::string> name;
102+
103+
ParamValue(LLUIImage* const& image = NULL)
104+
: super_t(image)
105+
{
106+
updateBlockFromValue(false);
107+
addSynonym(name, "name");
108+
}
109+
110+
void updateValueFromBlock();
111+
void updateBlockFromValue(bool make_block_authoritative);
112+
};
113+
114+
// Need custom comparison function for our test app, which only loads
115+
// LLUIImage* as NULL.
116+
template<>
117+
struct ParamCompare<LLUIImage*, false>
118+
{
119+
static bool equals(LLUIImage* const &a, LLUIImage* const &b);
120+
};
121+
}
91122

92123
typedef LLPointer<LLUIImage> LLUIImagePtr;
93124
#endif

indra/llui/llaccordionctrl.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,11 @@ S32 LLAccordionCtrl::calcExpandedTabHeight(S32 tab_index /* = 0 */, S32 availabl
899899
LLView* LLAccordionCtrl::fromXML(LLXMLNodePtr node, LLView* parent, LLUICtrlFactory* factory)
900900
{
901901
LLAccordionCtrl* ctrl = new LLAccordionCtrl();
902-
ctrl->initFromXML(node, parent);
902+
ctrl->mCommitCallbackRegistrar.pushScope();
903+
ctrl->mEnableCallbackRegistrar.pushScope();
904+
ctrl->initPanelXML(node, parent, factory);
905+
ctrl->mCommitCallbackRegistrar.popScope();
906+
ctrl->mEnableCallbackRegistrar.popScope();
903907
return ctrl;
904908
}
905909

indra/llui/llaccordionctrltab.cpp

+87-10
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@ class LLAccordionCtrlTab::LLAccordionCtrlTabHeader : public LLUICtrl
5555
public:
5656
friend class LLUICtrlFactory;
5757

58-
struct Params : public LLInitParam::Block<Params, LLAccordionCtrlTab::Params>
58+
struct Params : public LLAccordionCtrlTab::Params //LLInitParam::Block<Params, LLAccordionCtrlTab::Params>
5959
{
6060
Params();
61+
Params(const LLAccordionCtrlTab::Params& p) : LLAccordionCtrlTab::Params(p) {}
6162
};
6263

6364
LLAccordionCtrlTabHeader(const LLAccordionCtrlTabHeader::Params& p);
@@ -357,7 +358,7 @@ LLAccordionCtrlTab::LLAccordionCtrlTab(const LLAccordionCtrlTab::Params&p)
357358
mWasStateStored = false;
358359

359360
mDropdownBGColor = LLColor4::white;
360-
LLAccordionCtrlTabHeader::Params headerParams;
361+
LLAccordionCtrlTabHeader::Params headerParams(p);
361362
headerParams.name(DD_HEADER_NAME);
362363
headerParams.title(p.title);
363364
mHeader = LLUICtrlFactory::create<LLAccordionCtrlTabHeader>(headerParams);
@@ -1051,150 +1052,226 @@ BOOL LLAccordionCtrlTab::handleScrollWheel ( S32 x, S32 y, S32 clicks )
10511052
LLView* LLAccordionCtrlTab::fromXML(LLXMLNodePtr node, LLView* parent, LLUICtrlFactory* factory)
10521053
{
10531054
Params p;
1055+
// Singu TODO: Widgets folder for defaults instead of shoving into params here where noted
10541056
if (node->hasAttribute("title"))
10551057
{
10561058
std::string title;
10571059
node->getAttributeString("title", title);
10581060
p.title(title);
10591061
}
1062+
10601063
if (node->hasAttribute("expanded"))
10611064
{
10621065
bool display_children;
10631066
node->getAttribute_bool("expanded", display_children);
10641067
p.display_children(display_children);
10651068
}
1069+
10661070
if (node->hasAttribute("header_height"))
10671071
{
10681072
S32 header_height;
10691073
node->getAttributeS32("header_height", header_height);
10701074
p.header_height(header_height);
10711075
}
1076+
10721077
if (node->hasAttribute("min_width"))
10731078
{
10741079
S32 min_width;
10751080
node->getAttributeS32("min_width", min_width);
10761081
p.min_width(min_width);
10771082
}
1083+
10781084
if (node->hasAttribute("min_width"))
10791085
{
10801086
S32 min_height;
10811087
node->getAttributeS32("min_height", min_height);
10821088
p.min_height(min_height);
10831089
}
1090+
10841091
if (node->hasAttribute("collapsible"))
10851092
{
10861093
bool collapsible;
10871094
node->getAttribute_bool("collapsible", collapsible);
10881095
p.collapsible(collapsible);
10891096
}
1097+
10901098
if (node->hasAttribute("header_bg_color"))
10911099
{
10921100
LLColor4 color;
10931101
node->getAttributeColor("header_bg_color", color);
10941102
p.header_bg_color(color);
10951103
}
1104+
else // widget
1105+
{
1106+
p.header_bg_color(LLUI::sColorsGroup->getColor("ButtonUnselectedBgColor")); // was DkGray2
1107+
}
1108+
10961109
if (node->hasAttribute("dropdown_bg_color"))
10971110
{
10981111
LLColor4 color;
10991112
node->getAttributeColor("dropdown_bg_color", color);
11001113
p.dropdown_bg_color(color);
11011114
}
1115+
11021116
if (node->hasAttribute("header_visible"))
11031117
{
11041118
bool header_visible;
11051119
node->getAttribute_bool("header_visible", header_visible);
11061120
p.header_visible(header_visible);
11071121
}
1122+
11081123
if (node->hasAttribute("padding_left"))
11091124
{
11101125
S32 padding_left;
11111126
node->getAttributeS32("padding_left", padding_left);
11121127
p.padding_left(padding_left);
11131128
}
1129+
11141130
if (node->hasAttribute("padding_right"))
11151131
{
11161132
S32 padding_right;
11171133
node->getAttributeS32("padding_right", padding_right);
11181134
p.padding_right(padding_right);
11191135
}
1136+
11201137
if (node->hasAttribute("padding_top"))
11211138
{
11221139
S32 padding_top;
11231140
node->getAttributeS32("padding_top", padding_top);
11241141
p.padding_top(padding_top);
11251142
}
1143+
11261144
if (node->hasAttribute("padding_bottom"))
11271145
{
11281146
S32 padding_bottom;
11291147
node->getAttributeS32("padding_bottom", padding_bottom);
11301148
p.padding_bottom(padding_bottom);
11311149
}
1150+
11321151
if (node->hasAttribute("header_expand_img"))
11331152
{
11341153
std::string image;
11351154
node->getAttributeString("header_expand_img", image);
1136-
p.header_expand_img(LLUI::getUIImage(image));
1155+
p.header_expand_img.name(image);
1156+
}
1157+
else // widget
1158+
{
1159+
p.header_expand_img.name("Accordion_ArrowOpened_Off");
11371160
}
1161+
11381162
if (node->hasAttribute("header_expand_img_pressed"))
11391163
{
11401164
std::string image;
11411165
node->getAttributeString("header_expand_img_pressed", image);
1142-
p.header_expand_img_pressed(LLUI::getUIImage(image));
1166+
p.header_expand_img_pressed.name(image);
1167+
}
1168+
else // widget
1169+
{
1170+
p.header_expand_img_pressed.name("Accordion_ArrowOpened_Press");
11431171
}
1172+
11441173
if (node->hasAttribute("header_collapse_img"))
11451174
{
11461175
std::string image;
11471176
node->getAttributeString("header_collapse_img", image);
1148-
p.header_collapse_img(LLUI::getUIImage(image));
1177+
p.header_collapse_img.name(image);
1178+
}
1179+
else // widget
1180+
{
1181+
p.header_collapse_img.name("Accordion_ArrowClosed_Off");
11491182
}
1183+
11501184
if (node->hasAttribute("header_collapse_img_pressed"))
11511185
{
11521186
std::string image;
11531187
node->getAttributeString("header_collapse_img_pressed", image);
1154-
p.header_collapse_img_pressed(LLUI::getUIImage(image));
1188+
p.header_collapse_img_pressed.name(image);
11551189
}
1190+
else // widget
1191+
{
1192+
p.header_collapse_img_pressed.name("Accordion_ArrowClosed_Press");
1193+
}
1194+
11561195
if (node->hasAttribute("header_image"))
11571196
{
11581197
std::string image;
11591198
node->getAttributeString("header_image", image);
1160-
p.header_image(LLUI::getUIImage(image));
1199+
p.header_image.name(image);
1200+
}
1201+
else // widget
1202+
{
1203+
p.header_image.name("Accordion_Off");
11611204
}
1205+
11621206
if (node->hasAttribute("header_image_over"))
11631207
{
11641208
std::string image;
11651209
node->getAttributeString("header_image_over", image);
1166-
p.header_image_over(LLUI::getUIImage(image));
1210+
p.header_image_over.name(image);
1211+
}
1212+
else // widget
1213+
{
1214+
p.header_image_over.name("Accordion_Over");
11671215
}
1216+
11681217
if (node->hasAttribute("header_image_pressed"))
11691218
{
11701219
std::string image;
11711220
node->getAttributeString("header_image_pressed", image);
1172-
p.header_image_pressed(LLUI::getUIImage(image));
1221+
p.header_image_pressed.name(image);
1222+
}
1223+
else // widget
1224+
{
1225+
p.header_image_pressed.name("Accordion_Press");
11731226
}
1227+
11741228
if (node->hasAttribute("header_image_focused"))
11751229
{
11761230
std::string image;
11771231
node->getAttributeString("header_image_focused", image);
1178-
p.header_image_focused(LLUI::getUIImage(image));
1232+
p.header_image_focused.name(image);
1233+
}
1234+
else // widget
1235+
{
1236+
p.header_image_focused.name("Accordion_Selected");
11791237
}
1238+
11801239
if (node->hasAttribute("header_text_color"))
11811240
{
11821241
LLColor4 color;
11831242
node->getAttributeColor("header_text_color", color);
11841243
p.header_text_color(color);
11851244
}
1245+
else // widget
1246+
{
1247+
p.header_text_color(LLUI::sColorsGroup->getColor("ButtonLabelColor")); // AccordionHeaderTextColor
1248+
}
1249+
11861250
if (node->hasAttribute("fit_panel"))
11871251
{
11881252
bool fit_panel;
11891253
node->getAttribute_bool("fit_panel", fit_panel);
11901254
p.fit_panel(fit_panel);
11911255
}
1256+
11921257
if (node->hasAttribute("selection_enabled"))
11931258
{
11941259
bool selection_enabled;
11951260
node->getAttribute_bool("selection_enabled", selection_enabled);
11961261
p.selection_enabled(selection_enabled);
11971262
}
1263+
1264+
if (node->hasAttribute("font"))
1265+
{
1266+
std::string font;
1267+
node->getAttributeString("font", font);
1268+
p.font.name(font);
1269+
}
1270+
else // widget
1271+
{
1272+
p.font.name("SansSerif");
1273+
}
1274+
11981275
LLAccordionCtrlTab* ctrl = new LLAccordionCtrlTab(p);
11991276
ctrl->initFromXML(node, parent);
12001277
return ctrl;

0 commit comments

Comments
 (0)