EXP-273 FIXED Add button/tray for avatar picker
made "toggleable" radio groupmeow-7.2.2
parent
50e77faaf7
commit
20e9dbf40b
|
|
@ -88,27 +88,19 @@ LLCheckBoxCtrl::LLCheckBoxCtrl(const LLCheckBoxCtrl::Params& p)
|
|||
tbparams.font(p.font);
|
||||
}
|
||||
mLabel = LLUICtrlFactory::create<LLTextBox> (tbparams);
|
||||
mLabel->reshapeToFitText();
|
||||
addChild(mLabel);
|
||||
|
||||
S32 text_width = mLabel->getTextBoundingRect().getWidth();
|
||||
S32 text_height = llround(mFont->getLineHeight());
|
||||
LLRect label_rect;
|
||||
label_rect.setOriginAndSize(
|
||||
llcheckboxctrl_hpad + llcheckboxctrl_btn_size + llcheckboxctrl_spacing,
|
||||
llcheckboxctrl_vpad + 1, // padding to get better alignment
|
||||
text_width + llcheckboxctrl_hpad,
|
||||
text_height );
|
||||
mLabel->setShape(label_rect);
|
||||
|
||||
LLRect label_rect = mLabel->getRect();
|
||||
|
||||
// Button
|
||||
// Note: button cover the label by extending all the way to the right.
|
||||
LLRect btn_rect;
|
||||
LLRect btn_rect = p.check_button.rect();
|
||||
btn_rect.setOriginAndSize(
|
||||
llcheckboxctrl_hpad,
|
||||
llcheckboxctrl_vpad,
|
||||
llcheckboxctrl_btn_size + llcheckboxctrl_spacing + text_width + llcheckboxctrl_hpad,
|
||||
llmax( text_height, llcheckboxctrl_btn_size() ) + llcheckboxctrl_vpad);
|
||||
btn_rect.mLeft,
|
||||
btn_rect.mBottom,
|
||||
llmax(btn_rect.mRight, label_rect.mRight - btn_rect.mLeft),
|
||||
llmax( label_rect.getHeight(), btn_rect.mTop));
|
||||
std::string active_true_id, active_false_id;
|
||||
std::string inactive_true_id, inactive_false_id;
|
||||
|
||||
|
|
@ -174,31 +166,20 @@ void LLCheckBoxCtrl::clear()
|
|||
|
||||
void LLCheckBoxCtrl::reshape(S32 width, S32 height, BOOL called_from_parent)
|
||||
{
|
||||
//stretch or shrink bounding rectangle of label when rebuilding UI at new scale
|
||||
static LLUICachedControl<S32> llcheckboxctrl_spacing ("UICheckboxctrlSpacing", 0);
|
||||
static LLUICachedControl<S32> llcheckboxctrl_hpad ("UICheckboxctrlHPad", 0);
|
||||
static LLUICachedControl<S32> llcheckboxctrl_vpad ("UICheckboxctrlVPad", 0);
|
||||
static LLUICachedControl<S32> llcheckboxctrl_btn_size ("UICheckboxctrlBtnSize", 0);
|
||||
|
||||
S32 text_width = mLabel->getTextBoundingRect().getWidth();
|
||||
S32 text_height = llround(mFont->getLineHeight());
|
||||
LLRect label_rect;
|
||||
label_rect.setOriginAndSize(
|
||||
llcheckboxctrl_hpad + llcheckboxctrl_btn_size + llcheckboxctrl_spacing,
|
||||
llcheckboxctrl_vpad,
|
||||
text_width,
|
||||
text_height );
|
||||
mLabel->setShape(label_rect);
|
||||
mLabel->reshapeToFitText();
|
||||
|
||||
LLRect btn_rect;
|
||||
LLRect label_rect = mLabel->getRect();
|
||||
|
||||
// Button
|
||||
// Note: button cover the label by extending all the way to the right.
|
||||
LLRect btn_rect = mButton->getRect();
|
||||
btn_rect.setOriginAndSize(
|
||||
llcheckboxctrl_hpad,
|
||||
llcheckboxctrl_vpad,
|
||||
llcheckboxctrl_btn_size + llcheckboxctrl_spacing + text_width,
|
||||
llmax( text_height, llcheckboxctrl_btn_size() ) );
|
||||
mButton->setShape( btn_rect );
|
||||
|
||||
LLUICtrl::reshape(width, height, called_from_parent);
|
||||
btn_rect.mLeft,
|
||||
btn_rect.mBottom,
|
||||
llmax(btn_rect.mRight, label_rect.mRight - btn_rect.mLeft),
|
||||
llmax( label_rect.getHeight(), btn_rect.mTop));
|
||||
mButton->setShape(btn_rect);
|
||||
}
|
||||
|
||||
//virtual
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ protected:
|
|||
static LLWidgetNameRegistry::StaticRegistrar register_radio_item(&typeid(LLRadioGroup::ItemParams), "radio_item");
|
||||
|
||||
LLRadioGroup::Params::Params()
|
||||
: has_border("draw_border"),
|
||||
: allow_deselect("allow_deselect"),
|
||||
items("item")
|
||||
{
|
||||
addSynonym(items, "radio_item");
|
||||
|
|
@ -85,18 +85,8 @@ LLRadioGroup::LLRadioGroup(const LLRadioGroup::Params& p)
|
|||
: LLUICtrl(p),
|
||||
mFont(p.font.isProvided() ? p.font() : LLFontGL::getFontSansSerifSmall()),
|
||||
mSelectedIndex(-1),
|
||||
mHasBorder(p.has_border)
|
||||
{
|
||||
if (mHasBorder)
|
||||
{
|
||||
LLViewBorder::Params params;
|
||||
params.name("radio group border");
|
||||
params.rect(LLRect(0, getRect().getHeight(), getRect().getWidth(), 0));
|
||||
params.bevel_style(LLViewBorder::BEVEL_NONE);
|
||||
LLViewBorder * vb = LLUICtrlFactory::create<LLViewBorder> (params);
|
||||
addChild (vb);
|
||||
}
|
||||
}
|
||||
mAllowDeselect(p.allow_deselect)
|
||||
{}
|
||||
|
||||
void LLRadioGroup::initFromParams(const Params& p)
|
||||
{
|
||||
|
|
@ -184,7 +174,7 @@ void LLRadioGroup::setIndexEnabled(S32 index, BOOL enabled)
|
|||
|
||||
BOOL LLRadioGroup::setSelectedIndex(S32 index, BOOL from_event)
|
||||
{
|
||||
if (index < 0 || (S32)mRadioButtons.size() <= index )
|
||||
if ((S32)mRadioButtons.size() <= index )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -202,13 +192,16 @@ BOOL LLRadioGroup::setSelectedIndex(S32 index, BOOL from_event)
|
|||
|
||||
mSelectedIndex = index;
|
||||
|
||||
LLRadioCtrl* radio_item = mRadioButtons[mSelectedIndex];
|
||||
radio_item->setTabStop(true);
|
||||
radio_item->setValue( TRUE );
|
||||
|
||||
if (hasFocus())
|
||||
if (mSelectedIndex >= 0)
|
||||
{
|
||||
mRadioButtons[mSelectedIndex]->focusFirstItem(FALSE, FALSE);
|
||||
LLRadioCtrl* radio_item = mRadioButtons[mSelectedIndex];
|
||||
radio_item->setTabStop(true);
|
||||
radio_item->setValue( TRUE );
|
||||
|
||||
if (hasFocus())
|
||||
{
|
||||
radio_item->focusFirstItem(FALSE, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
if (!from_event)
|
||||
|
|
@ -307,8 +300,15 @@ void LLRadioGroup::onClickButton(LLUICtrl* ctrl)
|
|||
LLRadioCtrl* radio = *iter;
|
||||
if (radio == clicked_radio)
|
||||
{
|
||||
// llinfos << "clicked button " << index << llendl;
|
||||
setSelectedIndex(index);
|
||||
if (index == mSelectedIndex && mAllowDeselect)
|
||||
{
|
||||
// don't select anything
|
||||
setSelectedIndex(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
setSelectedIndex(index);
|
||||
}
|
||||
|
||||
// BUG: Calls click callback even if button didn't actually change
|
||||
onCommit();
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public:
|
|||
|
||||
struct Params : public LLInitParam::Block<Params, LLUICtrl::Params>
|
||||
{
|
||||
Optional<bool> has_border;
|
||||
Optional<bool> allow_deselect;
|
||||
Multiple<ItemParams, AtLeast<1> > items;
|
||||
Params();
|
||||
};
|
||||
|
|
@ -73,7 +73,6 @@ public:
|
|||
void setIndexEnabled(S32 index, BOOL enabled);
|
||||
// return the index value of the selected item
|
||||
S32 getSelectedIndex() const { return mSelectedIndex; }
|
||||
|
||||
// set the index value programatically
|
||||
BOOL setSelectedIndex(S32 index, BOOL from_event = FALSE);
|
||||
|
||||
|
|
@ -103,12 +102,13 @@ public:
|
|||
/*virtual*/ BOOL operateOnAll(EOperation op);
|
||||
|
||||
private:
|
||||
const LLFontGL* mFont;
|
||||
S32 mSelectedIndex;
|
||||
typedef std::vector<class LLRadioCtrl*> button_list_t;
|
||||
button_list_t mRadioButtons;
|
||||
const LLFontGL* mFont;
|
||||
S32 mSelectedIndex;
|
||||
|
||||
BOOL mHasBorder;
|
||||
typedef std::vector<class LLRadioCtrl*> button_list_t;
|
||||
button_list_t mRadioButtons;
|
||||
|
||||
bool mAllowDeselect; // user can click on an already selected option to deselect it
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -586,6 +586,17 @@
|
|||
<key>Value</key>
|
||||
<integer>2</integer>
|
||||
</map>
|
||||
<key>AvatarPickerURL</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>Avatar picker contents</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>String</string>
|
||||
<key>Value</key>
|
||||
<string>http://interest.secondlife.com/viewer/avatar</string>
|
||||
</map>
|
||||
<key>AvatarBakedTextureUploadTimeout</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
|
|
|
|||
|
|
@ -844,36 +844,30 @@ class LLAdvancedCheckFeature : public view_listener_t
|
|||
}
|
||||
};
|
||||
|
||||
void LLDestinationGuideToggle()
|
||||
void LLDestinationAndAvatarShow(const LLSD& value)
|
||||
{
|
||||
LLView* destination_guide = gViewerWindow->getRootView()->getChildView("destination_guide_container");
|
||||
LLView* avatar_picker = gViewerWindow->getRootView()->getChildView("avatar_picker_container");
|
||||
S32 panel_idx = value.isDefined() ? value.asInteger() : -1;
|
||||
LLView* container = gViewerWindow->getRootView()->getChildView("avatar_picker_and_destination_guide_container");
|
||||
LLMediaCtrl* destinations = container->findChild<LLMediaCtrl>("destination_guide_contents");
|
||||
LLMediaCtrl* avatar_picker = container->findChild<LLMediaCtrl>("avatar_picker_contents");
|
||||
|
||||
if ( destination_guide->getVisible() )
|
||||
switch(panel_idx)
|
||||
{
|
||||
destination_guide->setVisible( FALSE );
|
||||
}
|
||||
else
|
||||
{
|
||||
LLFirstUse::notUsingDestinationGuide(false);
|
||||
destination_guide->setVisible( true );
|
||||
avatar_picker->setVisible( false );
|
||||
}
|
||||
};
|
||||
|
||||
void LLAvatarPickerToggle()
|
||||
{
|
||||
LLView* avatar_picker = gViewerWindow->getRootView()->getChildView("avatar_picker_container");
|
||||
LLView* destination_guide = gViewerWindow->getRootView()->getChildView("destination_guide_container");
|
||||
if ( avatar_picker->getVisible() )
|
||||
{
|
||||
avatar_picker->setVisible( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
LLFirstUse::notUsingAvatarPicker(false);
|
||||
avatar_picker->setVisible( true );
|
||||
destination_guide->setVisible( false );
|
||||
case 0:
|
||||
container->setVisible(true);
|
||||
destinations->setVisible(true);
|
||||
avatar_picker->setVisible(false);
|
||||
break;
|
||||
case 1:
|
||||
container->setVisible(true);
|
||||
destinations->setVisible(false);
|
||||
avatar_picker->setVisible(true);
|
||||
break;
|
||||
default:
|
||||
container->setVisible(false);
|
||||
destinations->setVisible(false);
|
||||
avatar_picker->setVisible(false);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -8309,6 +8303,5 @@ void initialize_menus()
|
|||
|
||||
view_listener_t::addMenu(new LLToggleUIHints(), "ToggleUIHints");
|
||||
|
||||
commit.add("DestinationGuide.toggle", boost::bind(&LLDestinationGuideToggle));
|
||||
commit.add("AvatarPicker.toggle", boost::bind(&LLAvatarPickerToggle));
|
||||
commit.add("DestinationAndAvatar.show", boost::bind(&LLDestinationAndAvatarShow, _2));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1699,12 +1699,19 @@ void LLViewerWindow::initWorldUI()
|
|||
buttons_panel->setFollowsAll();
|
||||
buttons_panel_container->addChild(buttons_panel);
|
||||
|
||||
LLView* destination_guide = gViewerWindow->getRootView()->getChild<LLView>("destination_guide_container");
|
||||
LLMediaCtrl* destinations = destination_guide->findChild<LLMediaCtrl>("destination_guide_contents");
|
||||
LLView* avatar_picker_destination_guide_container = gViewerWindow->getRootView()->getChild<LLView>("avatar_picker_and_destination_guide_container");
|
||||
LLMediaCtrl* destinations = avatar_picker_destination_guide_container->findChild<LLMediaCtrl>("destination_guide_contents");
|
||||
LLMediaCtrl* avatar_picker = avatar_picker_destination_guide_container->findChild<LLMediaCtrl>("avatar_picker_contents");
|
||||
if (destinations)
|
||||
{
|
||||
destinations->navigateTo(gSavedSettings.getString("DestinationGuideURL"));
|
||||
destinations->navigateTo(gSavedSettings.getString("DestinationGuideURL"), "text/html");
|
||||
}
|
||||
|
||||
if (avatar_picker)
|
||||
{
|
||||
avatar_picker->navigateTo(gSavedSettings.getString("AvatarPickerURL"), "text/html");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Destroy the UI
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
image_color="ButtonImageColor"
|
||||
image_color_disabled="ButtonImageColor"
|
||||
flash_color="ButtonFlashBgColor"
|
||||
font="SansSerifSmall"
|
||||
font="SansSerifSmall"
|
||||
hover_glow_amount="0.15"
|
||||
halign="center"
|
||||
pad_bottom="3"
|
||||
|
|
|
|||
|
|
@ -2,9 +2,17 @@
|
|||
<check_box font="SansSerifSmall"
|
||||
follows="left|top">
|
||||
<check_box.label_text name="checkbox label"
|
||||
left="20"
|
||||
bottom="3"
|
||||
width="0"
|
||||
height="0"
|
||||
text_color="LabelTextColor"
|
||||
text_readonly_color="LabelDisabledColor"/>
|
||||
<check_box.check_button name="CheckboxCtrl Button"
|
||||
left="2"
|
||||
bottom="2"
|
||||
width="13"
|
||||
height="13"
|
||||
commit_on_return="false"
|
||||
label=""
|
||||
is_toggle="true"
|
||||
|
|
|
|||
Loading…
Reference in New Issue