summaryrefslogtreecommitdiff
path: root/indra/llui/llui.cpp
blob: 4e93066608f8b9229dfa84dfd7c15e0adbca7146 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
/**
 * @file llui.cpp
 * @brief UI implementation
 *
 * $LicenseInfo:firstyear=2001&license=viewerlgpl$
 * Second Life Viewer Source Code
 * Copyright (C) 2010, Linden Research, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation;
 * version 2.1 of the License only.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 * $/LicenseInfo$
 */

// Utilities functions the user interface needs

#include "linden_common.h"

#include <string>
#include <map>

// Linden library includes
#include "v2math.h"
#include "m3math.h"
#include "v4color.h"
#include "llrender.h"
#include "llrect.h"
#include "lldir.h"
#include "llgl.h"
#include "llsd.h"

// Project includes
#include "llcommandmanager.h"
#include "llcontrol.h"
#include "llui.h"
#include "lluicolortable.h"
#include "llview.h"
#include "lllineeditor.h"
#include "llfloater.h"
#include "llfloaterreg.h"
#include "llmenugl.h"
#include "llmenubutton.h"
#include "llloadingindicator.h"
#include "llwindow.h"

// for registration
#include "llfiltereditor.h"
#include "llflyoutbutton.h"
#include "llsearcheditor.h"
#include "lltoolbar.h"
#include "llcleanup.h"

// for XUIParse
#include "llquaternion.h"
#include <boost/tokenizer.hpp>
#include <boost/algorithm/string/find_iterator.hpp>
#include <boost/algorithm/string/finder.hpp>

//
// Globals
//

// Language for UI construction
std::map<std::string, std::string> gTranslation;
std::list<std::string> gUntranslated;

// register filter editor here
static LLDefaultChildRegistry::Register<LLFilterEditor> register_filter_editor("filter_editor");
static LLDefaultChildRegistry::Register<LLFlyoutButton> register_flyout_button("flyout_button");
static LLDefaultChildRegistry::Register<LLSearchEditor> register_search_editor("search_editor");

// register other widgets which otherwise may not be linked in
static LLDefaultChildRegistry::Register<LLLoadingIndicator> register_loading_indicator("loading_indicator");
static LLDefaultChildRegistry::Register<LLToolBar> register_toolbar("toolbar");

//
// Functions
//

LLUUID find_ui_sound(const char * namep)
{
    std::string name = ll_safe_string(namep);
    LLUUID uuid = LLUUID(NULL);
    LLUI *ui_inst = LLUI::getInstance();
    if (!ui_inst->mSettingGroups["config"]->controlExists(name))
    {
        LL_WARNS() << "tried to make UI sound for unknown sound name: " << name << LL_ENDL;
    }
    else
    {
        uuid = LLUUID(ui_inst->mSettingGroups["config"]->getString(name));
        if (uuid.isNull())
        {
            if (ui_inst->mSettingGroups["config"]->getString(name) == LLUUID::null.asString())
            {
                if (ui_inst->mSettingGroups["config"]->getBOOL("UISndDebugSpamToggle"))
                {
                    LL_INFOS() << "UI sound name: " << name << " triggered but silent (null uuid)" << LL_ENDL;
                }
            }
            else
            {
                LL_WARNS() << "UI sound named: " << name << " does not translate to a valid uuid" << LL_ENDL;
            }
        }
        else if (ui_inst->mAudioCallback != NULL)
        {
            if (ui_inst->mSettingGroups["config"]->getBOOL("UISndDebugSpamToggle"))
            {
                LL_INFOS() << "UI sound name: " << name << LL_ENDL;
            }
        }
    }

    return uuid;
}

void make_ui_sound(const char* namep)
{
    LLUUID soundUUID = find_ui_sound(namep);
    if(soundUUID.notNull())
    {
        LLUI::getInstance()->mAudioCallback(soundUUID);
    }
}

void make_ui_sound_deferred(const char* namep)
{
    LLUUID soundUUID = find_ui_sound(namep);
    if(soundUUID.notNull())
    {
        LLUI::getInstance()->mDeferredAudioCallback(soundUUID);
    }
}

LLUI::LLUI(const settings_map_t& settings,
                 LLImageProviderInterface* image_provider,
                 LLUIAudioCallback audio_callback,
                 LLUIAudioCallback deferred_audio_callback)
: mSettingGroups(settings),
mAudioCallback(audio_callback),
mDeferredAudioCallback(deferred_audio_callback),
mWindow(NULL), // set later in startup
mRootView(NULL),
mHelpImpl(NULL)
{
    LLRender2D::initParamSingleton(image_provider);

    if ((get_ptr_in_map(mSettingGroups, std::string("config")) == NULL) ||
        (get_ptr_in_map(mSettingGroups, std::string("floater")) == NULL) ||
        (get_ptr_in_map(mSettingGroups, std::string("ignores")) == NULL))
    {
        LL_ERRS() << "Failure to initialize configuration groups" << LL_ENDL;
    }

    LLFontGL::sShadowColor = LLUIColorTable::instance().getColor("ColorDropShadow");

    LLUICtrl::CommitRegistrarHelper reg(LLUICtrl::CommitCallbackRegistry::defaultRegistrar());
    // Callbacks for associating controls with floater visibility:
    reg.add("Floater.Toggle", boost::bind(&LLFloaterReg::toggleInstance, _2, LLSD()));
    reg.add("Floater.ToggleOrBringToFront", boost::bind(&LLFloaterReg::toggleInstanceOrBringToFront, _2, LLSD()));
    reg.add("Floater.Show", boost::bind(&LLFloaterReg::showInstance, _2, LLSD(), false));
    reg.add("Floater.ShowOrBringToFront", boost::bind(&LLFloaterReg::showInstanceOrBringToFront, _2, LLSD()));
    reg.add("Floater.Hide", boost::bind(&LLFloaterReg::hideInstance, _2, LLSD()));

    // Button initialization callback for toggle buttons
    reg.add("Button.SetFloaterToggle", boost::bind(&LLButton::setFloaterToggle, _1, _2));

    // Button initialization callback for toggle buttons on dockable floaters
    reg.add("Button.SetDockableFloaterToggle", boost::bind(&LLButton::setDockableFloaterToggle, _1, _2));

    // Display the help topic for the current context
    reg.add("Button.ShowHelp", boost::bind(&LLButton::showHelp, _1, _2));

    // Currently unused, but kept for reference:
    reg.add("Button.ToggleFloater", boost::bind(&LLButton::toggleFloaterAndSetToggleState, _1, _2));

    // Used by menus along with Floater.Toggle to display visibility as a check-mark
    LLUICtrl::EnableCallbackRegistry::defaultRegistrar().add("Floater.Visible", boost::bind(&LLFloaterReg::instanceVisible, _2, LLSD()));
    LLUICtrl::EnableCallbackRegistry::defaultRegistrar().add("Floater.IsOpen", boost::bind(&LLFloaterReg::instanceVisible, _2, LLSD()));

    // Parse the master list of commands
    LLCommandManager::load();
}

void LLUI::setPopupFuncs(const add_popup_t& add_popup, const remove_popup_t& remove_popup,  const clear_popups_t& clear_popups)
{
    mAddPopupFunc = add_popup;
    mRemovePopupFunc = remove_popup;
    mClearPopupsFunc = clear_popups;
}

void LLUI::setMousePositionScreen(S32 x, S32 y)
{
#if defined(LL_DARWIN)
    S32 screen_x = ll_round(((F32)x * getScaleFactor().mV[VX]) / LLView::getWindow()->getSystemUISize());
    S32 screen_y = ll_round(((F32)y * getScaleFactor().mV[VY]) / LLView::getWindow()->getSystemUISize());
#else
    S32 screen_x = ll_round((F32)x * getScaleFactor().mV[VX]);
    S32 screen_y = ll_round((F32)y * getScaleFactor().mV[VY]);
#endif

    LLView::getWindow()->setCursorPosition(LLCoordGL(screen_x, screen_y).convert());
}

void LLUI::getMousePositionScreen(S32 *x, S32 *y)
{
    LLCoordWindow cursor_pos_window;
    getWindow()->getCursorPosition(&cursor_pos_window);
    LLCoordGL cursor_pos_gl(cursor_pos_window.convert());
    *x = ll_round((F32)cursor_pos_gl.mX / getScaleFactor().mV[VX]);
    *y = ll_round((F32)cursor_pos_gl.mY / getScaleFactor().mV[VY]);
}

void LLUI::setMousePositionLocal(const LLView* viewp, S32 x, S32 y)
{
    S32 screen_x, screen_y;
    viewp->localPointToScreen(x, y, &screen_x, &screen_y);

    setMousePositionScreen(screen_x, screen_y);
}

void LLUI::getMousePositionLocal(const LLView* viewp, S32 *x, S32 *y)
{
    S32 screen_x, screen_y;
    getMousePositionScreen(&screen_x, &screen_y);
    viewp->screenPointToLocal(screen_x, screen_y, x, y);
}


// On Windows, the user typically sets the language when they install the
// app (by running it with a shortcut that sets InstallLanguage).  On Mac,
// or on Windows if the SecondLife.exe executable is run directly, the
// language follows the OS language.  In all cases the user can override
// the language manually in preferences. JC
std::string LLUI::getUILanguage()
{
    std::string language = "en";
    if (mSettingGroups["config"])
    {
        language = mSettingGroups["config"]->getString("Language");
        if (language.empty() || language == "default")
        {
            language = mSettingGroups["config"]->getString("InstallLanguage");
        }
        if (language.empty() || language == "default")
        {
            language = mSettingGroups["config"]->getString("SystemLanguage");
        }
        if (language.empty() || language == "default")
        {
            language = "en";
        }
    }
    return language;
}

// static
std::string LLUI::getLanguage()
{
    // Note: lldateutil_test redefines this function
    return LLUI::getInstance()->getUILanguage();
}

struct SubDir : public LLInitParam::Block<SubDir>
{
    Mandatory<std::string> value;

    SubDir()
    :   value("value")
    {}
};

struct Directory : public LLInitParam::Block<Directory>
{
    Multiple<SubDir, AtLeast<1> > subdirs;

    Directory()
    :   subdirs("subdir")
    {}
};

struct Paths : public LLInitParam::Block<Paths>
{
    Multiple<Directory, AtLeast<1> > directories;

    Paths()
    :   directories("directory")
    {}
};


//static
std::string LLUI::locateSkin(const std::string& filename)
{
    std::string found_file = filename;
    if (gDirUtilp->fileExists(found_file))
    {
        return found_file;
    }

    found_file = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, filename); // Should be CUSTOM_SKINS?
    if (gDirUtilp->fileExists(found_file))
    {
        return found_file;
    }

    found_file = gDirUtilp->findSkinnedFilename(LLDir::XUI, filename);
    if (! found_file.empty())
    {
        return found_file;
    }

    found_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, filename);
    if (gDirUtilp->fileExists(found_file))
    {
        return found_file;
    }
    LL_WARNS("LLUI") << "Can't find '" << filename
                     << "' in user settings, any skin directory or app_settings" << LL_ENDL;
    return "";
}

LLVector2 LLUI::getWindowSize()
{
    LLCoordWindow window_rect;
    mWindow->getSize(&window_rect);

    return LLVector2(window_rect.mX / getScaleFactor().mV[VX], window_rect.mY / getScaleFactor().mV[VY]);
}

void LLUI::screenPointToGL(S32 screen_x, S32 screen_y, S32 *gl_x, S32 *gl_y)
{
    *gl_x = ll_round((F32)screen_x * getScaleFactor().mV[VX]);
    *gl_y = ll_round((F32)screen_y * getScaleFactor().mV[VY]);
}

void LLUI::glPointToScreen(S32 gl_x, S32 gl_y, S32 *screen_x, S32 *screen_y)
{
    *screen_x = ll_round((F32)gl_x / getScaleFactor().mV[VX]);
    *screen_y = ll_round((F32)gl_y / getScaleFactor().mV[VY]);
}

void LLUI::screenRectToGL(const LLRect& screen, LLRect *gl)
{
    screenPointToGL(screen.mLeft, screen.mTop, &gl->mLeft, &gl->mTop);
    screenPointToGL(screen.mRight, screen.mBottom, &gl->mRight, &gl->mBottom);
}

void LLUI::glRectToScreen(const LLRect& gl, LLRect *screen)
{
    glPointToScreen(gl.mLeft, gl.mTop, &screen->mLeft, &screen->mTop);
    glPointToScreen(gl.mRight, gl.mBottom, &screen->mRight, &screen->mBottom);
}


LLControlGroup& LLUI::getControlControlGroup (const std::string& controlname)
{
    for (settings_map_t::iterator itor = mSettingGroups.begin();
         itor != mSettingGroups.end(); ++itor)
    {
        LLControlGroup* control_group = itor->second;
        if(control_group != NULL)
        {
            if (control_group->controlExists(controlname))
                return *control_group;
        }
    }

    return *mSettingGroups["config"]; // default group
}

void LLUI::addPopup(LLView* viewp)
{
    if (mAddPopupFunc)
    {
        mAddPopupFunc(viewp);
    }
}

void LLUI::removePopup(LLView* viewp)
{
    if (mRemovePopupFunc)
    {
        mRemovePopupFunc(viewp);
    }
}

void LLUI::clearPopups()
{
    if (mClearPopupsFunc)
    {
        mClearPopupsFunc();
    }
}

void LLUI::reportBadKeystroke()
{
    make_ui_sound("UISndBadKeystroke");
}

// spawn_x and spawn_y are top left corner of view in screen GL coordinates
void LLUI::positionViewNearMouse(LLView* view, S32 spawn_x, S32 spawn_y)
{
    const S32 CURSOR_HEIGHT = 16;       // Approximate "normal" cursor size
    const S32 CURSOR_WIDTH = 8;

    LLView* parent = view->getParent();

    S32 mouse_x;
    S32 mouse_y;
    getMousePositionScreen(&mouse_x, &mouse_y);

    // If no spawn location provided, use mouse position
    if (spawn_x == S32_MAX || spawn_y == S32_MAX)
    {
        spawn_x = mouse_x + CURSOR_WIDTH;
        spawn_y = mouse_y - CURSOR_HEIGHT;
    }

    LLRect virtual_window_rect = parent->getLocalRect();

    LLRect mouse_rect;
    const S32 MOUSE_CURSOR_PADDING = 1;
    mouse_rect.setLeftTopAndSize(mouse_x - MOUSE_CURSOR_PADDING,
                                mouse_y + MOUSE_CURSOR_PADDING,
                                CURSOR_WIDTH + MOUSE_CURSOR_PADDING * 2,
                                CURSOR_HEIGHT + MOUSE_CURSOR_PADDING * 2);

    S32 local_x, local_y;
    // convert screen coordinates to tooltip view-local coordinates
    parent->screenPointToLocal(spawn_x, spawn_y, &local_x, &local_y);

    // Start at spawn position (using left/top)
    view->setOrigin( local_x, local_y - view->getRect().getHeight());
    // Make sure we're on-screen and not overlapping the mouse
    view->translateIntoRectWithExclusion( virtual_window_rect, mouse_rect );
}

LLView* LLUI::resolvePath(LLView* context, const std::string& path)
{
    // Nothing about resolvePath() should require non-const LLView*. If caller
    // wants non-const, call the const flavor and then cast away const-ness.
    return const_cast<LLView*>(resolvePath(const_cast<const LLView*>(context), path));
}

const LLView* LLUI::resolvePath(const LLView* context, const std::string& path)
{
    // Create an iterator over slash-separated parts of 'path'. Dereferencing
    // this iterator returns an iterator_range over the substring. Unlike
    // LLStringUtil::getTokens(), this split_iterator doesn't combine adjacent
    // delimiters: leading/trailing slash produces an empty substring, double
    // slash produces an empty substring. That's what we need.
    boost::split_iterator<std::string::const_iterator> ti(path, boost::first_finder("/")), tend;

    if (ti == tend)
    {
        // 'path' is completely empty, no navigation
        return context;
    }

    // leading / means "start at root"
    if (ti->empty())
    {
        context = getRootView();
        ++ti;
    }

    bool recurse = false;
    for (; ti != tend && context; ++ti)
    {
        if (ti->empty())
        {
            recurse = true;
        }
        else
        {
            std::string part(ti->begin(), ti->end());
            context = context->findChildView(LLURI::unescape(part), recurse);
            recurse = false;
        }
    }

    return context;
}

//static
LLVector2& LLUI::getScaleFactor()
{
    return LLRender::sUIGLScaleFactor;
}

//static
void LLUI::setScaleFactor(const LLVector2& scale_factor)
{
    LLRender::sUIGLScaleFactor = scale_factor;
}


// LLLocalClipRect and LLScreenClipRect moved to lllocalcliprect.h/cpp

namespace LLInitParam
{
    ParamValue<LLUIColor>::ParamValue(const LLUIColor& color)
    :   super_t(color),
        red("red"),
        green("green"),
        blue("blue"),
        alpha("alpha"),
        control("")
    {
        updateBlockFromValue(false);
    }

    void ParamValue<LLUIColor>::updateValueFromBlock()
    {
        if (control.isProvided() && !control().empty())
        {
            updateValue(LLUIColorTable::instance().getColor(control));
        }
        else
        {
            updateValue(LLColor4(red, green, blue, alpha));
        }
    }

    void ParamValue<LLUIColor>::updateBlockFromValue(bool make_block_authoritative)
    {
        LLColor4 color = getValue();
        red.set(color.mV[VRED], make_block_authoritative);
        green.set(color.mV[VGREEN], make_block_authoritative);
        blue.set(color.mV[VBLUE], make_block_authoritative);
        alpha.set(color.mV[VALPHA], make_block_authoritative);
        control.set("", make_block_authoritative);
    }

    bool ParamCompare<const LLFontGL*, false>::equals(const LLFontGL* a, const LLFontGL* b)
    {
        return !(a->getFontDesc() < b->getFontDesc())
            && !(b->getFontDesc() < a->getFontDesc());
    }

    ParamValue<const LLFontGL*>::ParamValue(const LLFontGL* fontp)
    :   super_t(fontp),
        name("name"),
        size("size"),
        style("style")
    {
        if (!fontp)
        {
            updateValue(LLFontGL::getFontDefault());
        }
        addSynonym(name, "");
        updateBlockFromValue(false);
    }

    void ParamValue<const LLFontGL*>::updateValueFromBlock()
    {
        const LLFontGL* res_fontp = LLFontGL::getFontByName(name);
        if (res_fontp)
        {
            updateValue(res_fontp);
            return;
        }

        U8 fontstyle = 0;
        fontstyle = LLFontGL::getStyleFromString(style());
        LLFontDescriptor desc(name(), size(), fontstyle);
        const LLFontGL* fontp = LLFontGL::getFont(desc);
        if (fontp)
        {
            updateValue(fontp);
        }
        else
        {
            updateValue(LLFontGL::getFontDefault());
        }
    }

    void ParamValue<const LLFontGL*>::updateBlockFromValue(bool make_block_authoritative)
    {
        if (getValue())
        {
            name.set(LLFontGL::nameFromFont(getValue()), make_block_authoritative);
            size.set(LLFontGL::sizeFromFont(getValue()), make_block_authoritative);
            style.set(LLFontGL::getStringFromStyle(getValue()->getFontDesc().getStyle()), make_block_authoritative);
        }
    }

    ParamValue<LLRect>::ParamValue(const LLRect& rect)
    :   super_t(rect),
        left("left"),
        top("top"),
        right("right"),
        bottom("bottom"),
        width("width"),
        height("height")
    {
        updateBlockFromValue(false);
    }

    void ParamValue<LLRect>::updateValueFromBlock()
    {
        LLRect rect;

        //calculate from params
        // prefer explicit left and right
        if (left.isProvided() && right.isProvided())
        {
            rect.mLeft = left;
            rect.mRight = right;
        }
        // otherwise use width along with specified side, if any
        else if (width.isProvided())
        {
            // only right + width provided
            if (right.isProvided())
            {
                rect.mRight = right;
                rect.mLeft = right - width;
            }
            else // left + width, or just width
            {
                rect.mLeft = left;
                rect.mRight = left + width;
            }
        }
        // just left, just right, or none
        else
        {
            rect.mLeft = left;
            rect.mRight = right;
        }

        // prefer explicit bottom and top
        if (bottom.isProvided() && top.isProvided())
        {
            rect.mBottom = bottom;
            rect.mTop = top;
        }
        // otherwise height along with specified side, if any
        else if (height.isProvided())
        {
            // top + height provided
            if (top.isProvided())
            {
                rect.mTop = top;
                rect.mBottom = top - height;
            }
            // bottom + height or just height
            else
            {
                rect.mBottom = bottom;
                rect.mTop = bottom + height;
            }
        }
        // just bottom, just top, or none
        else
        {
            rect.mBottom = bottom;
            rect.mTop = top;
        }
        updateValue(rect);
    }

    void ParamValue<LLRect>::updateBlockFromValue(bool make_block_authoritative)
    {
        // because of the ambiguity in specifying a rect by position and/or dimensions
        // we use the lowest priority pairing so that any valid pairing in xui
        // will override those calculated from the rect object
        // in this case, that is left+width and bottom+height
        LLRect& value = getValue();

        right.set(value.mRight, false);
        left.set(value.mLeft, make_block_authoritative);
        width.set(value.getWidth(), make_block_authoritative);

        top.set(value.mTop, false);
        bottom.set(value.mBottom, make_block_authoritative);
        height.set(value.getHeight(), make_block_authoritative);
    }

    ParamValue<LLCoordGL>::ParamValue(const LLCoordGL& coord)
    :   super_t(coord),
        x("x"),
        y("y")
    {
        updateBlockFromValue(false);
    }

    void ParamValue<LLCoordGL>::updateValueFromBlock()
    {
        updateValue(LLCoordGL(x, y));
    }

    void ParamValue<LLCoordGL>::updateBlockFromValue(bool make_block_authoritative)
    {
        x.set(getValue().mX, make_block_authoritative);
        y.set(getValue().mY, make_block_authoritative);
    }


    void TypeValues<LLFontGL::HAlign>::declareValues()
    {
        declare("left", LLFontGL::LEFT);
        declare("right", LLFontGL::RIGHT);
        declare("center", LLFontGL::HCENTER);
    }

    void TypeValues<LLFontGL::VAlign>::declareValues()
    {
        declare("top", LLFontGL::TOP);
        declare("center", LLFontGL::VCENTER);
        declare("baseline", LLFontGL::BASELINE);
        declare("bottom", LLFontGL::BOTTOM);
    }

    void TypeValues<LLFontGL::ShadowType>::declareValues()
    {
        declare("none", LLFontGL::NO_SHADOW);
        declare("hard", LLFontGL::DROP_SHADOW);
        declare("soft", LLFontGL::DROP_SHADOW_SOFT);
    }
}