Only enable buttons when selections can be acted upon

Cinders 2013-11-29 21:04:15 -07:00
parent 09b02cb0bc
commit 7e44b29927
3 changed files with 16 additions and 4 deletions

View File

@ -62,12 +62,23 @@ BOOL NACLFloaterExploreSounds::postBuild()
getChild<LLButton>("bl_btn")->setClickedCallback(boost::bind(&NACLFloaterExploreSounds::blacklistSound, this));
mHistoryScroller = getChild<LLScrollListCtrl>("sound_list");
mHistoryScroller->setCommitCallback(boost::bind(&NACLFloaterExploreSounds::handleSelection, this));
mHistoryScroller->setDoubleClickCallback(boost::bind(&NACLFloaterExploreSounds::handlePlayLocally, this));
mHistoryScroller->sortByColumn("playing", TRUE);
return TRUE;
}
void NACLFloaterExploreSounds::handleSelection()
{
S32 num_selected = mHistoryScroller->getAllSelected().size();
bool multiple = (num_selected > 1);
childSetEnabled("look_at_btn", (num_selected && !multiple));
childSetEnabled("play_locally_btn", num_selected);
childSetEnabled("stop_btn", num_selected);
childSetEnabled("bl_btn", num_selected);
}
LLSoundHistoryItem NACLFloaterExploreSounds::getItem(LLUUID itemID)
{
if(gSoundHistory.find(itemID) != gSoundHistory.end())

View File

@ -27,6 +27,7 @@ private:
void handlePlayLocally();
void handleLookAt();
void handleStop();
void handleSelection();
void blacklistSound();
LLScrollListCtrl* mHistoryScroller;

View File

@ -49,9 +49,9 @@
<columns dynamicwidth="true" label="Owner" name="owner" />
<columns dynamicwidth="false" width="0" label="Sound" name="sound" />
</scroll_list>
<button bottom_delta="25" follows="left|bottom" height="20" label="Play Locally" name="play_locally_btn" left="10" width="95"/>
<button bottom_delta="0" follows="left|bottom" height="20" label="Look At" name="look_at_btn" left_delta="100" width="95"/>
<button bottom_delta="25" follows="left|bottom" height="20" label="Play Locally" name="play_locally_btn" left="10" width="95" enabled="false"/>
<button bottom_delta="0" follows="left|bottom" height="20" label="Look At" name="look_at_btn" left_delta="100" width="95" enabled="false"/>
<button bottom_delta="0" follows="left|bottom" height="20" label="Stop" name="stop_btn" right="-10" width="95"/>
<button bottom_delta="0" follows="left|bottom" height="20" label="Blacklist" name="bl_btn" right="-110" width="95"/>
<button bottom_delta="0" follows="left|bottom" height="20" label="Stop" name="stop_btn" right="-10" width="95" enabled="false"/>
<button bottom_delta="0" follows="left|bottom" height="20" label="Blacklist" name="bl_btn" right="-110" width="95" enabled="false"/>
</floater>