예제 #1
0
	/*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask)
	{
		// We only handle the click if the click both started and ended within us
		if( !hasMouseCapture() ) return FALSE;

		S32 screen_x;
		S32 screen_y;
		localPointToScreen(x, y, &screen_x, &screen_y);

		S32 delta_x = screen_x - mDragLastScreenX;
		S32 delta_y = screen_y - mDragLastScreenY;

		LLSideTray* side_tray = LLSideTray::getInstance();

		// Check if the tab we are dragging is docked.
		if (!side_tray->isTabAttached(getName())) return FALSE;

		// Same value is hardcoded in LLDragHandle::handleHover().
		const S32 undock_threshold = 12;

		// Detach a tab if it has been pulled further than undock_threshold.
		if (delta_x <= -undock_threshold ||	delta_x >= undock_threshold	||
			delta_y <= -undock_threshold ||	delta_y >= undock_threshold)
		{
			LLSideTrayTab* tab = side_tray->getTab(getName());
			if (!tab) return FALSE;

			tab->toggleTabDocked();

			LLFloater* floater_tab = LLFloaterReg::getInstance("side_bar_tab", tab->getName());
			if (!floater_tab) return FALSE;

			LLRect original_rect = floater_tab->getRect();
			S32 header_snap_y = floater_tab->getHeaderHeight() / 2;
			S32 snap_x = screen_x - original_rect.mLeft - original_rect.getWidth() / 2;
			S32 snap_y = screen_y - original_rect.mTop + header_snap_y;

			// Move the floater to appear "under" the mouse pointer.
			floater_tab->setRect(original_rect.translate(snap_x, snap_y));

			// Snap the mouse pointer to the center of the floater header
			// and call 'mouse down' event handler to begin dragging.
			floater_tab->handleMouseDown(original_rect.getWidth() / 2,
										 original_rect.getHeight() - header_snap_y,
										 mask);

			return TRUE;
		}

		return FALSE;
	}
예제 #2
0
// Detach those tabs that were detached when the viewer exited last time.
void LLSideTray::detachTabs()
{
	// copy mTabs because LLSideTray::toggleTabDocked() modifies it.
	child_vector_t tabs = mTabs;

	for (child_vector_const_iter_t it = tabs.begin(); it != tabs.end(); ++it)
	{
		LLSideTrayTab* tab = *it;

		std::string floater_ctrl_name = LLFloater::getControlName("side_bar_tab", LLSD(tab->getName()));
		std::string vis_ctrl_name = LLFloaterReg::getVisibilityControlName(floater_ctrl_name);
		if (!LLFloater::getControlGroup()->controlExists(vis_ctrl_name)) continue;

		bool is_visible = LLFloater::getControlGroup()->getBOOL(vis_ctrl_name);
		if (!is_visible) continue;

		llassert(isTabAttached(tab->getName()));
		tab->toggleTabDocked();
	}
}