Modernized lluictrl. Added LLViewModel. Fixed focus callbacks being called excessively. Updated LLButton, and implemented boost::signals2 to replace old callback handling.

This commit is contained in:
Shyotl
2012-03-02 16:57:33 -06:00
parent fb10af2723
commit 500135941a
48 changed files with 1359 additions and 961 deletions

View File

@@ -501,15 +501,13 @@ BOOL LLPanelGroupSubTab::postBuild()
mSearchButton = getChild<LLButton>("search_button", recurse);
if (!mSearchButton) return FALSE;
mSearchButton->setClickedCallback(onClickSearch);
mSearchButton->setCallbackUserData(this);
mSearchButton->setClickedCallback(boost::bind(&LLPanelGroupSubTab::onClickSearch,this));
mSearchButton->setEnabled(FALSE);
mShowAllButton = getChild<LLButton>("show_all_button", recurse);
if (!mShowAllButton) return FALSE;
mShowAllButton->setClickedCallback(onClickShowAll);
mShowAllButton->setCallbackUserData(this);
mShowAllButton->setClickedCallback(boost::bind(&LLPanelGroupSubTab::onClickShowAll,this));
mShowAllButton->setEnabled(FALSE);
// Get icons for later use.
@@ -665,8 +663,7 @@ bool LLPanelGroupSubTab::matchesActionSearchFilter(std::string action)
void LLPanelGroupSubTab::buildActionsList(LLScrollListCtrl* ctrl,
U64 allowed_by_some,
U64 allowed_by_all,
icon_map_t& icons,
void (*commit_callback)(LLUICtrl*,void*),
LLUICtrl::commit_callback_t commit_callback,
BOOL show_all,
BOOL filter,
BOOL is_owner_role)
@@ -686,7 +683,6 @@ void LLPanelGroupSubTab::buildActionsList(LLScrollListCtrl* ctrl,
allowed_by_some,
allowed_by_all,
(*ras_it),
icons,
commit_callback,
show_all,
filter,
@@ -698,8 +694,7 @@ void LLPanelGroupSubTab::buildActionCategory(LLScrollListCtrl* ctrl,
U64 allowed_by_some,
U64 allowed_by_all,
LLRoleActionSet* action_set,
icon_map_t& icons,
void (*commit_callback)(LLUICtrl*,void*),
LLUICtrl::commit_callback_t commit_callback,
BOOL show_all,
BOOL filter,
BOOL is_owner_role)
@@ -712,10 +707,11 @@ void LLPanelGroupSubTab::buildActionCategory(LLScrollListCtrl* ctrl,
LLSD row;
row["columns"][0]["column"] = "icon";
icon_map_t::iterator iter = icons.find("folder");
if (iter != icons.end())
row["columns"][0]["type"] = "icon";
icon_map_t::iterator iter = mActionIcons.find("folder");
if (iter != mActionIcons.end())
{
row["columns"][0]["type"] = "icon";
row["columns"][0]["value"] = (*iter).second;
}
@@ -777,8 +773,8 @@ void LLPanelGroupSubTab::buildActionCategory(LLScrollListCtrl* ctrl,
{
if (show_full_strength)
{
icon_map_t::iterator iter = icons.find("full");
if (iter != icons.end())
icon_map_t::iterator iter = mActionIcons.find("full");
if (iter != mActionIcons.end())
{
row["columns"][column_index]["column"] = "checkbox";
row["columns"][column_index]["type"] = "icon";
@@ -788,8 +784,8 @@ void LLPanelGroupSubTab::buildActionCategory(LLScrollListCtrl* ctrl,
}
else
{
icon_map_t::iterator iter = icons.find("partial");
if (iter != icons.end())
icon_map_t::iterator iter = mActionIcons.find("partial");
if (iter != mActionIcons.end())
{
row["columns"][column_index]["column"] = "checkbox";
row["columns"][column_index]["type"] = "icon";
@@ -813,7 +809,6 @@ void LLPanelGroupSubTab::buildActionCategory(LLScrollListCtrl* ctrl,
LLCheckBoxCtrl* check = check_cell->getCheckBox();
check->setEnabled(can_change_actions);
check->setCommitCallback(commit_callback);
check->setCallbackUserData(ctrl->getCallbackUserData());
check->setToolTip( check->getLabel() );
if (show_all)
@@ -912,16 +907,14 @@ BOOL LLPanelGroupMembersSubTab::postBuildSubTab(LLView* root)
LLButton* button = parent->getChild<LLButton>("member_invite", recurse);
if ( button )
{
button->setClickedCallback(onInviteMember);
button->setCallbackUserData(this);
button->setClickedCallback(boost::bind(&LLPanelGroupMembersSubTab::onInviteMember,this));
button->setEnabled(gAgent.hasPowerInGroup(mGroupID, GP_MEMBER_INVITE));
}
mEjectBtn = parent->getChild<LLButton>("member_eject", recurse);
if ( mEjectBtn )
{
mEjectBtn->setClickedCallback(onEjectMembers);
mEjectBtn->setCallbackUserData(this);
mEjectBtn->setClickedCallback(boost::bind(&LLPanelGroupMembersSubTab::onEjectMembers,this));
mEjectBtn->setEnabled(FALSE);
}
@@ -956,7 +949,7 @@ void LLPanelGroupMembersSubTab::handleMemberSelect()
if (selection.empty()) return;
// Build a vector of all selected members, and gather allowed actions.
std::vector<LLUUID> selected_members;
uuid_vec_t selected_members;
U64 allowed_by_all = 0xffffffffffffLL;
U64 allowed_by_some = 0;
@@ -964,10 +957,12 @@ void LLPanelGroupMembersSubTab::handleMemberSelect()
for (itor = selection.begin();
itor != selection.end(); ++itor)
{
selected_members.push_back( (*itor)->getUUID() );
LLUUID member_id = (*itor)->getUUID();
selected_members.push_back( member_id );
// Get this member's power mask including any unsaved changes
U64 powers = getAgentPowersBasedOnRoleChanges((*itor)->getUUID());
U64 powers = getAgentPowersBasedOnRoleChanges( member_id );
allowed_by_all &= powers;
allowed_by_some |= powers;
@@ -980,7 +975,6 @@ void LLPanelGroupMembersSubTab::handleMemberSelect()
buildActionsList(mAllowedActionsList,
allowed_by_some,
allowed_by_all,
mActionIcons,
NULL,
FALSE,
FALSE,
@@ -1021,8 +1015,8 @@ void LLPanelGroupMembersSubTab::handleMemberSelect()
if (cb_enable && (count > 0) && role_id == gdatap->mOwnerRole)
{
// Check if any owners besides this agent are selected.
std::vector<LLUUID>::const_iterator member_iter;
std::vector<LLUUID>::const_iterator member_end =
uuid_vec_t::const_iterator member_iter;
uuid_vec_t::const_iterator member_end =
selected_members.end();
for (member_iter = selected_members.begin();
member_iter != member_end;
@@ -1048,7 +1042,7 @@ void LLPanelGroupMembersSubTab::handleMemberSelect()
//now see if there are any role changes for the selected
//members and remember to include them
std::vector<LLUUID>::iterator sel_mem_iter = selected_members.begin();
uuid_vec_t::iterator sel_mem_iter = selected_members.begin();
for (; sel_mem_iter != selected_members.end(); sel_mem_iter++)
{
LLRoleMemberChangeType type;
@@ -1106,7 +1100,7 @@ void LLPanelGroupMembersSubTab::handleMemberSelect()
check->setTentative(
(0 != count)
&& (selected_members.size() !=
(std::vector<LLUUID>::size_type)count));
(uuid_vec_t::size_type)count));
//NOTE: as of right now a user can break the group
//by removing himself from a role if he is the
@@ -1281,7 +1275,6 @@ void LLPanelGroupMembersSubTab::handleRoleCheck(const LLUUID& role_id,
buildActionsList(mAllowedActionsList,
powers_some_have,
powers_all_have,
mActionIcons,
NULL,
FALSE,
FALSE,
@@ -1778,8 +1771,7 @@ BOOL LLPanelGroupRolesSubTab::postBuildSubTab(LLView* root)
parent->getChild<LLButton>("role_create", recurse);
if ( mCreateRoleButton )
{
mCreateRoleButton->setCallbackUserData(this);
mCreateRoleButton->setClickedCallback(onCreateRole);
mCreateRoleButton->setClickedCallback(boost::bind(&LLPanelGroupRolesSubTab::onCreateRole,this));
mCreateRoleButton->setEnabled(FALSE);
}
@@ -1787,8 +1779,7 @@ BOOL LLPanelGroupRolesSubTab::postBuildSubTab(LLView* root)
parent->getChild<LLButton>("role_delete", recurse);
if ( mDeleteRoleButton )
{
mDeleteRoleButton->setCallbackUserData(this);
mDeleteRoleButton->setClickedCallback(onDeleteRole);
mDeleteRoleButton->setClickedCallback(boost::bind(&LLPanelGroupRolesSubTab::onDeleteRole,this));
mDeleteRoleButton->setEnabled(FALSE);
}
@@ -2062,8 +2053,7 @@ void LLPanelGroupRolesSubTab::handleRoleSelect()
buildActionsList(mAllowedActionsList,
rd.mRolePowers,
0LL,
mActionIcons,
onActionCheck,
boost::bind(&LLPanelGroupRolesSubTab::handleActionCheck, this, _1, false),
TRUE,
FALSE,
is_owner_role);
@@ -2160,24 +2150,18 @@ void LLPanelGroupRolesSubTab::buildMembersList()
}
}
// static
void LLPanelGroupRolesSubTab::onActionCheck(LLUICtrl* ctrl, void* user_data)
{
LLPanelGroupRolesSubTab* self = static_cast<LLPanelGroupRolesSubTab*>(user_data);
LLCheckBoxCtrl* check = static_cast<LLCheckBoxCtrl*>(ctrl);
if (!check || !self) return;
self->handleActionCheck(check);
}
struct ActionCBData
{
LLPanelGroupRolesSubTab* mSelf;
LLCheckBoxCtrl* mCheck;
};
void LLPanelGroupRolesSubTab::handleActionCheck(LLCheckBoxCtrl* check, bool force)
void LLPanelGroupRolesSubTab::handleActionCheck(LLUICtrl* ctrl, bool force)
{
LLCheckBoxCtrl* check = dynamic_cast<LLCheckBoxCtrl*>(ctrl);
if (!check)
return;
lldebugs << "LLPanelGroupRolesSubTab::handleActionSelect()" << llendl;
LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID);
@@ -2473,7 +2457,7 @@ BOOL LLPanelGroupActionsSubTab::postBuildSubTab(LLView* root)
mActionList->setCallbackUserData(this);
mActionList->setCommitOnSelectionChange(TRUE);
mActionList->setCommitCallback(onActionSelect);
mActionList->setCommitCallback(boost::bind(&LLPanelGroupActionsSubTab::handleActionSelect, this));
mActionMembers->setCallbackUserData(this);
mActionRoles->setCallbackUserData(this);
@@ -2529,20 +2513,12 @@ void LLPanelGroupActionsSubTab::update(LLGroupChange gc)
buildActionsList(mActionList,
GP_ALL_POWERS,
GP_ALL_POWERS,
mActionIcons,
NULL,
FALSE,
TRUE,
FALSE);
}
// static
void LLPanelGroupActionsSubTab::onActionSelect(LLUICtrl* scroll, void* data)
{
LLPanelGroupActionsSubTab* self = static_cast<LLPanelGroupActionsSubTab*>(data);
self->handleActionSelect();
}
void LLPanelGroupActionsSubTab::handleActionSelect()
{
mActionMembers->deleteAllItems();