Ejemplo n.º 1
0
void LLAvatarListItem::updateChildren()
{
    LL_DEBUGS("AvatarItemReshape") << LL_ENDL;
    LL_DEBUGS("AvatarItemReshape") << "Updating for: " << getAvatarName() << LL_ENDL;

    S32 name_new_width = getRect().getWidth();
    S32 ctrl_new_left = name_new_width;
    S32 name_new_left = sLeftPadding;

    // iterate through all children and set them into correct position depend on each child visibility
    // assume that child indexes are in back order: the first in Enum is the last (right) in the item
    // iterate & set child views starting from right to left
    for (S32 i = 0; i < ALIC_COUNT; ++i)
    {
        // skip "name" textbox, it will be processed out of loop later
        if (ALIC_NAME == i) continue;

        LLView* control = getItemChildView((EAvatarListItemChildIndex)i);

        LL_DEBUGS("AvatarItemReshape") << "Processing control: " << control->getName() << LL_ENDL;
        // skip invisible views
        if (!control->getVisible()) continue;

        S32 ctrl_width = sChildrenWidths[i]; // including space between current & left controls
        // This one changes, so we can't cache it.
        if(ALIC_EXTRA_INFORMATION == i)
        {
            ctrl_width += mExtraInformation->getRect().getWidth();
        }

        // decrease available for
        name_new_width -= ctrl_width;
        LL_DEBUGS("AvatarItemReshape") << "width: " << ctrl_width << ", name_new_width: " << name_new_width << LL_ENDL;

        LLRect control_rect = control->getRect();
        LL_DEBUGS("AvatarItemReshape") << "rect before: " << control_rect << LL_ENDL;

        if (ALIC_ICON == i)
        {
            // assume that this is the last iteration,
            // so it is not necessary to save "ctrl_new_left" value calculated on previous iterations
            ctrl_new_left = sLeftPadding;
            name_new_left = ctrl_new_left + ctrl_width;
        }
        else
        {
            ctrl_new_left -= ctrl_width;
        }

        LL_DEBUGS("AvatarItemReshape") << "ctrl_new_left: " << ctrl_new_left << LL_ENDL;

        control_rect.setLeftTopAndSize(
            ctrl_new_left,
            control_rect.mTop,
            control_rect.getWidth(),
            control_rect.getHeight());

        LL_DEBUGS("AvatarItemReshape") << "rect after: " << control_rect << LL_ENDL;
        control->setShape(control_rect);
    }

    // set size and position of the "name" child
    LLView* name_view = getItemChildView(ALIC_NAME);
    LLRect name_view_rect = name_view->getRect();
    LL_DEBUGS("AvatarItemReshape") << "name rect before: " << name_view_rect << LL_ENDL;

    // apply paddings
    name_new_width -= sLeftPadding;
    name_new_width -= sNameRightPadding;

    name_view_rect.setLeftTopAndSize(
        name_new_left,
        name_view_rect.mTop,
        name_new_width,
        name_view_rect.getHeight());

    name_view->setShape(name_view_rect);

    LL_DEBUGS("AvatarItemReshape") << "name rect after: " << name_view_rect << LL_ENDL;
}
// [SL:KB] - Patch: UI-AvatarListDndShare | Checked: 2011-06-19 (Catznip-2.6.0c) | Added: Catznip-2.6.0c
BOOL LLAvatarListItem::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void *cargo_data,
        EAcceptance *accept, std::string& tooltip_msg)
{
    notifyParent(LLSD().with("select", mAvatarId));
    return LLToolDragAndDrop::handleGiveDragAndDrop(mAvatarId, LLUUID::null, drop, cargo_type, cargo_data, accept, getAvatarName());
}