コード例 #1
0
void LLMenuButton::toggleMenu()
{
	if(mMenuHandle.isDead()) return;

	LLToggleableMenu* menu = dynamic_cast<LLToggleableMenu*>(mMenuHandle.get());
	if (!menu) return;

	// Store the button rectangle to toggle menu visibility if a mouse event
	// occurred inside or outside the button rect.
	menu->setButtonRect(this);

	if (!menu->toggleVisibility() && mIsMenuShown)
	{
		setForcePressedState(false);
		mIsMenuShown = false;
	}
	else
	{
		menu->buildDrawLabels();
		menu->arrangeAndClear();
		menu->updateParent(LLMenuGL::sMenuContainer);

		updateMenuOrigin();

		LLMenuGL::showPopup(getParent(), menu, mX, mY);

		setForcePressedState(true);
		mIsMenuShown = true;
	}
}
コード例 #2
0
void LLPanelPlaces::onOverflowButtonClicked()
{
	LLToggleableMenu* menu;

	bool is_agent_place_info_visible = mPlaceInfoType == AGENT_INFO_TYPE;

	if ((is_agent_place_info_visible ||
		 mPlaceInfoType == REMOTE_PLACE_INFO_TYPE ||
		 mPlaceInfoType == TELEPORT_HISTORY_INFO_TYPE) && mPlaceMenu != NULL)
	{
		menu = mPlaceMenu;

		// Enable adding a landmark only for agent current parcel and if
		// there is no landmark already pointing to that parcel in agent's inventory.
		menu->getChild<LLMenuItemCallGL>("landmark")->setEnabled(is_agent_place_info_visible &&
																 !LLLandmarkActions::landmarkAlreadyExists());
	}
	else if (mPlaceInfoType == LANDMARK_INFO_TYPE && mLandmarkMenu != NULL)
	{
		menu = mLandmarkMenu;

		BOOL is_landmark_removable = FALSE;
		if (mItem.notNull())
		{
			const LLUUID& item_id = mItem->getUUID();
			const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH);
			is_landmark_removable = gInventory.isObjectDescendentOf(item_id, gInventory.getRootFolderID()) &&
									!gInventory.isObjectDescendentOf(item_id, trash_id);
		}

		menu->getChild<LLMenuItemCallGL>("delete")->setEnabled(is_landmark_removable);
	}
	else
	{
		return;
	}

	if (!menu->toggleVisibility())
		return;

	if (menu->getButtonRect().isEmpty())
	{
		menu->setButtonRect(mOverflowBtn);
	}
	menu->updateParent(LLMenuGL::sMenuContainer);
	LLRect rect = mOverflowBtn->getRect();
	LLMenuGL::showPopup(this, menu, rect.mRight, rect.mTop);
}