예제 #1
0
void LLChicletBar::fitWithTopInfoBar()
{
	LLPanelTopInfoBar& top_info_bar = LLPanelTopInfoBar::instance();

	LLRect rect = getRect();
	S32 width = rect.getWidth();

	if (top_info_bar.getVisible())
	{
		S32 delta = top_info_bar.calcScreenRect().mRight - calcScreenRect().mLeft;
		if (delta < 0 && rect.mLeft < llabs(delta))
			delta = -rect.mLeft;
		rect.setLeftTopAndSize(rect.mLeft + delta, rect.mTop, rect.getWidth(), rect.getHeight());
		width = rect.getWidth() - delta;
	}
	else
	{
		LLView* parent = getParent();
		if (parent)
		{
			LLRect parent_rect = parent->getRect();
			rect.setLeftTopAndSize(0, rect.mTop, rect.getWidth(), rect.getHeight());
			width = parent_rect.getWidth();
		}
	}

	setRect(rect);
	LLPanel::reshape(width, rect.getHeight(), false);
}
//-----------------------------------------------------------------------------
// postBuild()
//-----------------------------------------------------------------------------
BOOL LLFloaterNameDesc::postBuild()
{
	LLRect r;

	std::string asset_name = mFilename;
	LLStringUtil::replaceNonstandardASCII( asset_name, '?' );
	LLStringUtil::replaceChar(asset_name, '|', '?');
	LLStringUtil::stripNonprintable(asset_name);
	LLStringUtil::trim(asset_name);

	asset_name = gDirUtilp->getBaseFileName(asset_name, true); // no extsntion

	setTitle(mFilename);

	centerWithin(gViewerWindow->getRootView()->getRect());

	S32 line_width = getRect().getWidth() - 2 * PREVIEW_HPAD;
	S32 y = getRect().getHeight() - PREVIEW_LINE_HEIGHT;

	r.setLeftTopAndSize( PREVIEW_HPAD, y, line_width, PREVIEW_LINE_HEIGHT );
	y -= PREVIEW_LINE_HEIGHT;

	r.setLeftTopAndSize( PREVIEW_HPAD, y, line_width, PREVIEW_LINE_HEIGHT );    

	getChild<LLUICtrl>("name_form")->setCommitCallback(boost::bind(&LLFloaterNameDesc::doCommit, this));
	getChild<LLUICtrl>("name_form")->setValue(LLSD(asset_name));

	LLLineEditor *NameEditor = getChild<LLLineEditor>("name_form");
	if (NameEditor)
	{
		NameEditor->setMaxTextLength(DB_INV_ITEM_NAME_STR_LEN);
		NameEditor->setPrevalidate(&LLTextValidate::validateASCIIPrintableNoPipe);
	}

	y -= llfloor(PREVIEW_LINE_HEIGHT * 1.2f);
	y -= PREVIEW_LINE_HEIGHT;

	r.setLeftTopAndSize( PREVIEW_HPAD, y, line_width, PREVIEW_LINE_HEIGHT );  
	getChild<LLUICtrl>("description_form")->setCommitCallback(boost::bind(&LLFloaterNameDesc::doCommit, this));
	LLLineEditor *DescEditor = getChild<LLLineEditor>("description_form");
	if (DescEditor)
	{
		DescEditor->setMaxTextLength(DB_INV_ITEM_DESC_STR_LEN);
		DescEditor->setPrevalidate(&LLTextValidate::validateASCIIPrintableNoPipe);
	}

	y -= llfloor(PREVIEW_LINE_HEIGHT * 1.2f);

	// Cancel button
	getChild<LLUICtrl>("cancel_btn")->setCommitCallback(boost::bind(&LLFloaterNameDesc::onBtnCancel, this));

	getChild<LLUICtrl>("ok_btn")->setLabelArg("[AMOUNT]", llformat("%d", LLGlobalEconomy::Singleton::getInstance()->getPriceUpload() ));
	
	std::string type_currency = LLGridManager::getInstance()->getCurrency();
	getChild<LLUICtrl>("ok_btn")->setLabelArg(std::string("[CUR]"), type_currency);
	setDefaultBtn("ok_btn");
	
	return TRUE;
}
예제 #3
0
void LLDebugView::init()
{
	LLRect r;
	LLRect rect = getLocalRect();

	// Rectangle to draw debug data in (full height, 3/4 width)
	r.set(10, rect.getHeight() - 100, ((rect.getWidth()*3)/4), 100);
	LLConsole::Params cp;
	cp.name("debug console");
	cp.max_lines(20);
	cp.rect(r);
	cp.font(LLFontGL::getFontMonospace());
	cp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_LEFT);
	cp.visible(false);
	mDebugConsolep = LLUICtrlFactory::create<LLConsole>(cp);
	addChild(mDebugConsolep);

	r.set(150 - 25, rect.getHeight() - 50, rect.getWidth()/2 - 25, rect.getHeight() - 450);

	r.setLeftTopAndSize(25, rect.getHeight() - 50, (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.75f), 
  									 (S32) (gViewerWindow->getWindowRectScaled().getHeight() * 0.75f));
	
	mFastTimerView = dynamic_cast<LLFastTimerView*>(LLFloaterReg::getInstance("fast_timers"));

	gSceneView = new LLSceneView(r);
	gSceneView->setFollowsTop();
	gSceneView->setFollowsLeft();
	gSceneView->setVisible(FALSE);
	addChild(gSceneView);
	gSceneView->setRect(rect);
	
	r.setLeftTopAndSize(25, rect.getHeight() - 50, (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.75f), 
									 (S32) (gViewerWindow->getWindowRectScaled().getHeight() * 0.75f));
	LLMemoryView::Params mp;
	mp.name("memory");
	mp.rect(r);
	mp.follows.flags(FOLLOWS_TOP | FOLLOWS_LEFT);
	mp.visible(false);
	mMemoryView = LLUICtrlFactory::create<LLMemoryView>(mp);
	addChild(mMemoryView);

	r.set(150, rect.getHeight() - 50, 820, 100);
	LLTextureView::Params tvp;
	tvp.name("gTextureView");
	tvp.rect(r);
	tvp.follows.flags(FOLLOWS_TOP|FOLLOWS_LEFT);
	tvp.visible(false);
	gTextureView = LLUICtrlFactory::create<LLTextureView>(tvp);
	addChild(gTextureView);
	//gTextureView->reshape(r.getWidth(), r.getHeight(), TRUE);
}
예제 #4
0
//---------------------------------------------------------------------------------
void LLSysWellWindow::reshapeWindow()
{
	// save difference between floater height and the list height to take it into account while calculating new window height
	// it includes height from floater top to list top and from floater bottom and list bottom
	static S32 parent_list_delta_height = getRect().getHeight() - mMessageList->getRect().getHeight();

	if (!mIsReshapedByUser) // Don't reshape Well window, if it ever was reshaped by user. See EXT-5715.
	{
		S32 notif_list_height = mMessageList->getItemsRect().getHeight() + 2 * mMessageList->getBorderWidth();

		LLRect curRect = getRect();

		S32 new_window_height = notif_list_height + parent_list_delta_height;

		if (new_window_height > MAX_WINDOW_HEIGHT)
		{
			new_window_height = MAX_WINDOW_HEIGHT;
		}
		S32 newY = curRect.mTop + new_window_height - curRect.getHeight();
		S32 newWidth = curRect.getWidth() < MIN_WINDOW_WIDTH ? MIN_WINDOW_WIDTH
			: curRect.getWidth();
		curRect.setLeftTopAndSize(curRect.mLeft, newY, newWidth, new_window_height);
		reshape(curRect.getWidth(), curRect.getHeight(), TRUE);
		setRect(curRect);
	}

	// update notification channel state
	// update on a window reshape is important only when a window is visible and docked
	if(mChannel && getVisible() && isDocked())
	{
		mChannel->updateShowToastsState();
	}
}
예제 #5
0
LLView* LLPanel::fromXML(LLXMLNodePtr node, LLView* parent, LLUICtrlFactory *factory)
{
	std::string name("panel");
	node->getAttributeString("name", name);

	LLPanel* panelp = factory->createFactoryPanel(name);
	// Fall back on a default panel, if there was no special factory.
	if (!panelp)
	{
		LLRect rect;
		createRect(node, rect, parent, LLRect());
		// create a new panel without a border, by default
		panelp = new LLPanel(name, rect, FALSE);
		panelp->initPanelXML(node, parent, factory);
		// preserve panel's width and height, but override the location
		const LLRect& panelrect = panelp->getRect();
		S32 w = panelrect.getWidth();
		S32 h = panelrect.getHeight();
		rect.setLeftTopAndSize(rect.mLeft, rect.mTop, w, h);
		panelp->setRect(rect);
	}
	else
	{
		panelp->initPanelXML(node, parent, factory);
	}

	return panelp;
}
예제 #6
0
// static
LLPreviewGesture* LLPreviewGesture::show(const std::string& title, const LLUUID& item_id, const LLUUID& object_id, BOOL take_focus)
{
	LLPreviewGesture* previewp = (LLPreviewGesture*)LLPreview::find(item_id);
	if (previewp)
	{
		previewp->open();   /*Flawfinder: ignore*/
		if (take_focus)
		{
			previewp->setFocus(TRUE);
		}
		return previewp;
	}

	LLPreviewGesture* self = new LLPreviewGesture();

	// Finish internal construction
	self->init(item_id, object_id);

	// Builds and adds to gFloaterView
	gUICtrlFactory->buildFloater(self, "floater_preview_gesture.xml");
	self->setTitle(title);

	// Move window to top-left of screen
	LLMultiFloater* hostp = self->getHost();
	if (hostp == NULL)
	{
		LLRect r = self->getRect();
		LLRect screen = gFloaterView->getRect();
		r.setLeftTopAndSize(0, screen.getHeight(), r.getWidth(), r.getHeight());
		self->setRect(r);
	}
	else
	{
		// re-add to host to update title
		hostp->addFloater(self, TRUE);
	}

	// this will call refresh when we have everything.
	LLViewerInventoryItem* item = (LLViewerInventoryItem*)self->getItem();
	if(item && !item->isComplete())
	{
		LLInventoryGestureAvailable* observer;
		observer = new LLInventoryGestureAvailable();
		observer->watchItem(item_id);
		gInventory.addObserver(observer);
		item->fetchFromServer();
	}
	else
	{
		// not sure this is necessary.
		self->refresh();
	}

	if (take_focus)
	{
		self->setFocus(TRUE);
	}

	return self;
}
예제 #7
0
void LLFloaterAvatarPicker::chkcards()
{
	if(init_cards == FALSE)
	{
		LLPanel* active_panel = childGetVisibleTab("ResidentChooserTabs");

		if(active_panel == getChild<LLPanel>("CallingCardsPanel"))
		{
			init_cards = TRUE;
			/*<inventory_panel allow_multi_select="false" border="true" bottom_delta="-117"
			     follows="left|top|right|bottom" height="110" left="10" mouse_opaque="true"
			     name="InventoryPanel" sort_order="AvatarPickerSortOrder" width="115" />*/
			LLRect rect = active_panel->getRect();
			rect.mLeft += 10;
			rect.setLeftTopAndSize(rect.mLeft,rect.mTop,rect.getWidth(),110);
			LLInventoryPanel* panel = new LLInventoryPanel("InventoryPanel", "AvatarPickerSortOrder",
								 rect, &gInventory,
								 FALSE, active_panel);
			panel->setFollowsAll();
			panel->reshape(rect.getWidth(), rect.getHeight());
			panel->postBuild();
			active_panel->addChild(panel);
			LLInventoryPanel* inventory_panel = getChild<LLInventoryPanel>("InventoryPanel");
			inventory_panel->setFilterTypes(0x1 << LLInventoryType::IT_CALLINGCARD);
			inventory_panel->setFollowsAll();
			inventory_panel->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS);
			inventory_panel->openDefaultFolderForType(LLAssetType::AT_CALLINGCARD);
			inventory_panel->setSelectCallback(LLFloaterAvatarPicker::onCallingCardSelectionChange, this);
		}
	}
}
예제 #8
0
void LLMultiFloater::updateResizeLimits()
{
	// initialize minimum size constraint to the original xml values.
	S32 new_min_width = mOrigMinWidth;
	S32 new_min_height = mOrigMinHeight;

	computeResizeLimits(new_min_width, new_min_height);

	setResizeLimits(new_min_width, new_min_height);

	S32 cur_height = getRect().getHeight();
	S32 new_width = llmax(getRect().getWidth(), new_min_width);
	S32 new_height = llmax(getRect().getHeight(), new_min_height);

	if (isMinimized())
	{
		const LLRect& expanded = getExpandedRect();
		LLRect newrect;
		newrect.setLeftTopAndSize(expanded.mLeft, expanded.mTop, llmax(expanded.getWidth(), new_width), llmax(expanded.getHeight(), new_height));
		setExpandedRect(newrect);
	}
	else
	{
		reshape(new_width, new_height);

		// make sure upper left corner doesn't move
		translate(0, cur_height - getRect().getHeight());

		// make sure this window is visible on screen when it has been modified
		// (tab added, etc)
		gFloaterView->adjustToFitScreen(this, TRUE);
	}
}
예제 #9
0
void LLScrollingPanelList::clearPanels()
{
    deleteAllChildren();
    mPanelList.clear();

    LLRect rc = getRect();
    rc.setLeftTopAndSize(rc.mLeft, rc.mTop, 1, 1);
    setRect(rc);

    notifySizeChanged(rc.getHeight());
}
예제 #10
0
LLView* LLPanel::fromXML(LLXMLNodePtr node, LLView* parent, LLUICtrlFactory *factory)
{
	std::string name("panel");
	node->getAttributeString("name", name);

	LLPanel* panelp = factory->createFactoryPanel(name);
	LLFastTimer _(FTM_PANEL_CONSTRUCTION);
	// Fall back on a default panel, if there was no special factory.
	if (!panelp)
	{
		LLRect rect;
		createRect(node, rect, parent, LLRect());
		// create a new panel without a border, by default
		panelp = new LLPanel(name, rect, FALSE);
		// for local registry callbacks; define in constructor, referenced in XUI or postBuild
		panelp->mCommitCallbackRegistrar.pushScope(); 
		panelp->mEnableCallbackRegistrar.pushScope();
		panelp->initPanelXML(node, parent, factory);
		panelp->mCommitCallbackRegistrar.popScope();
		panelp->mEnableCallbackRegistrar.popScope();
		// preserve panel's width and height, but override the location
		const LLRect& panelrect = panelp->getRect();
		S32 w = panelrect.getWidth();
		S32 h = panelrect.getHeight();
		rect.setLeftTopAndSize(rect.mLeft, rect.mTop, w, h);
		panelp->setRect(rect);
	}
	else
	{
		if(!factory->builtPanel(panelp))
		{
			// for local registry callbacks; define in constructor, referenced in XUI or postBuild
			panelp->mCommitCallbackRegistrar.pushScope(); 
			panelp->mEnableCallbackRegistrar.pushScope();
			panelp->initPanelXML(node, parent, factory);
			panelp->mCommitCallbackRegistrar.popScope();
			panelp->mEnableCallbackRegistrar.popScope();
		}
		else
		{
			LLRect new_rect = panelp->getRect();
			// override rectangle with embedding parameters as provided
			panelp->createRect(node, new_rect, parent);
			panelp->setOrigin(new_rect.mLeft, new_rect.mBottom);
			panelp->setShape(new_rect);
			// optionally override follows flags from including nodes
			panelp->parseFollowsFlags(node);
		}
	}

	return panelp;
}
예제 #11
0
LLDebugView::LLDebugView(const std::string& name, const LLRect &rect)
:	LLView(name, rect, FALSE)
{
	LLRect r;

	r.set(10, rect.getHeight() - 100, rect.getWidth()/2, 100);
	mDebugConsolep = new LLConsole("debug console", 20, r, -1, 0.f );
	mDebugConsolep->setFollowsBottom();
	mDebugConsolep->setFollowsLeft();
	mDebugConsolep->setVisible( FALSE );
	addChild(mDebugConsolep);

	r.set(150 - 25, rect.getHeight() - 50, rect.getWidth()/2 - 25, rect.getHeight() - 450);
	mFrameStatView = new LLFrameStatView("frame stat", r);
	mFrameStatView->setFollowsTop();
	mFrameStatView->setFollowsLeft();
	mFrameStatView->setVisible(FALSE);			// start invisible
	addChild(mFrameStatView);

	r.set(25, rect.getHeight() - 50, (S32) (gViewerWindow->getVirtualWindowRect().getWidth() * 0.75f), 
  									 (S32) (gViewerWindow->getVirtualWindowRect().getHeight() * 0.75f));
	mFastTimerView = new LLFastTimerView("fast timers", r);
	mFastTimerView->setFollowsTop();
	mFastTimerView->setFollowsLeft();
	mFastTimerView->setVisible(FALSE);			// start invisible
	addChild(mFastTimerView);

	r.set(25, rect.getHeight() - 50, rect.getWidth()/2, rect.getHeight() - 450);
	mMemoryView = new LLMemoryView("memory", r);
	mMemoryView->setFollowsTop();
	mMemoryView->setFollowsLeft();
	mMemoryView->setVisible(FALSE);			// start invisible
	addChild(mMemoryView);

	r.set(150, rect.getHeight() - 50, 820, 100);
	gTextureView = new LLTextureView("gTextureView", r);
	gTextureView->setRect(r);
	gTextureView->setFollowsBottom();
	gTextureView->setFollowsLeft();
	addChild(gTextureView);
	//gTextureView->reshape(r.getWidth(), r.getHeight(), TRUE);

	const S32 VELOCITY_LEFT = 10; // 370;
	const S32 VELOCITY_WIDTH = 500;
	const S32 VELOCITY_TOP = 140;
	const S32 VELOCITY_HEIGHT = 45;
	r.setLeftTopAndSize( VELOCITY_LEFT, VELOCITY_TOP, VELOCITY_WIDTH, VELOCITY_HEIGHT );
	gVelocityBar = new LLVelocityBar("Velocity Bar", r);
	gVelocityBar->setFollowsBottom();
	gVelocityBar->setFollowsLeft();
	addChild(gVelocityBar);
}
예제 #12
0
void LLAccordionCtrlTab::reshape(S32 width, S32 height, BOOL called_from_parent /* = TRUE */)
{
	LLRect headerRect;

	headerRect.setLeftTopAndSize(
		0,height,width,HEADER_HEIGHT);
	mHeader->setRect(headerRect);
	mHeader->reshape(headerRect.getWidth(), headerRect.getHeight());

	if(!mDisplayChildren)
		return;

	LLRect childRect;

	childRect.setLeftTopAndSize(
		getPaddingLeft(),
		height - getHeaderHeight() - getPaddingTop(),
		width - getPaddingLeft() - getPaddingRight(), 
		height - getHeaderHeight() - getPaddingTop() - getPaddingBottom() );

	adjustContainerPanel(childRect);
}
예제 #13
0
void LLIMToastNotifyPanel::reshape(S32 width, S32 height, BOOL called_from_parent /* = TRUE */)
{
	S32 text_height = mTextBox->getTextBoundingRect().getHeight();
	S32 widget_height = mTextBox->getRect().getHeight();
	S32 delta = text_height - widget_height;
	LLRect rc = getRect();

	rc.setLeftTopAndSize(rc.mLeft, rc.mTop, width, height + delta);
	height = rc.getHeight();
	width = rc.getWidth();

	LLToastPanel::reshape(width, height, called_from_parent);
}
예제 #14
0
LLMultiPreview::LLMultiPreview()
	: LLMultiFloater(LLSD())
{
	// start with a rect in the top-left corner ; will get resized
	LLRect rect;
	rect.setLeftTopAndSize(0, gViewerWindow->getWindowHeightScaled(), 200, 400);
	setRect(rect);

	LLFloater* last_floater = LLFloaterReg::getLastFloaterInGroup("preview");
	if (last_floater)
	{
		stackWith(*last_floater);
	}
	setTitle(LLTrans::getString("MultiPreviewTitle"));
	buildTabContainer();
	setCanResize(TRUE);
	mAutoResize = FALSE;
}
예제 #15
0
void LLScrollingPanelList::removePanel( U32 panel_index )
{
    if ( mPanelList.empty() || panel_index >= mPanelList.size() )
    {
        LL_WARNS() << "Panel index " << panel_index << " is out of range!" << LL_ENDL;
        return;
    }
    else
    {
        removeChild( mPanelList.at(panel_index) );
        mPanelList.erase( mPanelList.begin() + panel_index );
    }

    const S32 GAP_BETWEEN_PANELS = 6;

    // Resize this view
    S32 total_height = 0;
    S32 max_width = 0;
    S32 cur_gap = 0;
    for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin();
            iter != mPanelList.end(); ++iter)
    {
        LLScrollingPanel *childp = *iter;
        total_height += childp->getRect().getHeight() + cur_gap;
        max_width = llmax( max_width, childp->getRect().getWidth() );
        cur_gap = GAP_BETWEEN_PANELS;
    }
    LLRect rc = getRect();
    rc.setLeftTopAndSize(rc.mLeft, rc.mTop, max_width, total_height);
    setRect(rc);

    notifySizeChanged(rc.getHeight());

    // Reposition each of the child views
    S32 cur_y = total_height;
    for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin();
            iter != mPanelList.end(); ++iter)
    {
        LLScrollingPanel *childp = *iter;
        cur_y -= childp->getRect().getHeight();
        childp->translate( -childp->getRect().mLeft, cur_y - childp->getRect().mBottom);
        cur_y -= GAP_BETWEEN_PANELS;
    }
}
예제 #16
0
void LLSideTrayTab::reshape		(S32 width, S32 height, BOOL called_from_parent )
{
	LLPanel::reshape(width, height, called_from_parent);
	LLView* title_panel = findChildView(TAB_PANEL_CAPTION_NAME, true);
	if (!title_panel)
	{
		// not fully constructed yet
		return;
	}

	S32 title_height = title_panel->getRect().getHeight();
	title_panel->setOrigin( 0, height - title_height );
	title_panel->reshape(width,title_height);

	LLRect sRect;
	sRect.setLeftTopAndSize( splitter_margin, height - title_height - splitter_margin, 
							width - 2*splitter_margin, height - title_height - 2*splitter_margin);
	mMainPanel->setShape(sRect);
}
LLMultiProperties::LLMultiProperties()
	: LLMultiFloater(LLSD())
{
	// *TODO: There should be a .xml file for this
	const LLRect& nextrect = LLFloaterReg::getFloaterRect("properties"); // place where the next properties should show up
	if (nextrect.getWidth() > 0)
	{
		setRect(nextrect);
	}
	else
	{
		// start with a small rect in the top-left corner ; will get resized
		LLRect rect;
		rect.setLeftTopAndSize(0, gViewerWindow->getWindowHeightScaled(), 20, 20);
		setRect(rect);
	}
	setTitle(LLTrans::getString("MultiPropertiesTitle"));
	buildTabContainer();
}
void LLToastScriptQuestion::createButtons()
{
	LLNotificationFormPtr form = mNotification->getForm();
	int num_elements = form->getNumElements();
	int buttons_width = 0;

	for (int i = 0; i < num_elements; ++i)
	{
		LLSD form_element = form->getElement(i);
		if ("button" == form_element["type"].asString())
		{
			LLButton::Params p;
			const LLFontGL* font = LLFontGL::getFontSansSerif();
			p.name(form_element["name"].asString());
			p.label(form_element["text"].asString());
			p.layout("topleft");
			p.font(font);
			p.rect.height(BUTTON_HEIGHT);
			p.click_callback.function(boost::bind(&LLToastScriptQuestion::onButtonClicked, this, form_element["name"].asString()));
			p.rect.left = LEFT_PAD;
			p.rect.width = font->getWidth(form_element["text"].asString());
			p.auto_resize = true;
			p.follows.flags(FOLLOWS_LEFT | FOLLOWS_BOTTOM);
			p.image_color(LLUIColorTable::instance().getColor("ButtonCautionImageColor"));
			p.image_color_disabled(LLUIColorTable::instance().getColor("ButtonCautionImageColor"));

			LLButton* button = LLUICtrlFactory::create<LLButton>(p);
			button->autoResize();
			getChild<LLPanel>("buttons_panel")->addChild(button);

			LLRect rect = button->getRect();
			rect.setLeftTopAndSize(buttons_width, rect.mTop, rect.getWidth(), rect.getHeight());
			button->setRect(rect);

			buttons_width += rect.getWidth() + LEFT_PAD;
		}
	}
}
예제 #19
0
void LLMultiFloater::growToFit(S32 content_width, S32 content_height)
{
	static LLUICachedControl<S32> tabcntr_close_btn_size ("UITabCntrCloseBtnSize", 0);
	const LLFloater::Params& default_params = LLFloater::getDefaultParams();
	S32 floater_header_size = default_params.header_height;
	S32 tabcntr_header_height = LLPANEL_BORDER_WIDTH + tabcntr_close_btn_size;
	S32 new_width = llmax(getRect().getWidth(), content_width + LLPANEL_BORDER_WIDTH * 2);
	S32 new_height = llmax(getRect().getHeight(), content_height + floater_header_size + tabcntr_header_height);

    if (isMinimized())
    {
        LLRect newrect;
        newrect.setLeftTopAndSize(getExpandedRect().mLeft, getExpandedRect().mTop, new_width, new_height);
        setExpandedRect(newrect);
    }
	else
	{
		S32 old_height = getRect().getHeight();
		reshape(new_width, new_height);
		// keep top left corner in same position
		translate(0, old_height - new_height);
	}
}
void LLIMToastNotifyPanel::reshape(S32 width, S32 height, BOOL called_from_parent /* = TRUE */)
{
	S32 text_height = mTextBox->getTextBoundingRect().getHeight();
	S32 widget_height = mTextBox->getRect().getHeight();
	S32 delta = text_height - widget_height;
	LLRect rc = getRect();

	rc.setLeftTopAndSize(rc.mLeft, rc.mTop, width, height + delta);
	height = rc.getHeight();
	width = rc.getWidth();

	bool is_width_changed = width != getRect().getWidth();

	LLToastPanel::reshape(width, height, called_from_parent);

	// Notification height required to display the text message depends on
	// the width of the text box thus if panel width is changed the text box
	// width is also changed then reshape() is called to adjust proper height.
	if (is_width_changed)
	{
		reshape(width, height, called_from_parent);
	}
}
예제 #21
0
void LLToolPlacerPanel::addButton( const LLString& up_state, const LLString& down_state, LLPCode* pcode )
{
    const S32 TOOL_SIZE = 32;
    const S32 HORIZ_SPACING = TOOL_SIZE + 5;
    const S32 VERT_SPACING = TOOL_SIZE + 5;
    const S32 VPAD = 10;
    const S32 HPAD = 7;

    S32 row = sButtonsAdded / 4;
    S32 column = sButtonsAdded % 4;

    LLRect help_rect = gSavedSettings.getRect("ToolHelpRect");

    // Build the rectangle, recalling the origin is at lower left
    // and we want the icons to build down from the top.
    LLRect rect;
    rect.setLeftTopAndSize(
        HPAD + (column * HORIZ_SPACING),
        help_rect.mBottom - VPAD - (row * VERT_SPACING),
        TOOL_SIZE,
        TOOL_SIZE );

    LLButton* btn = new LLButton(
        "ToolPlacerOptBtn",
        rect,
        up_state,
        down_state,
        "", &LLToolPlacerPanel::setObjectType,
        pcode,
        LLFontGL::sSansSerif);
    btn->setFollowsBottom();
    btn->setFollowsLeft();
    addChild(btn);

    sButtons[sButtonsAdded] = btn;
    sButtonsAdded++;
}
예제 #22
0
S32 LLScrollingPanelList::addPanel( LLScrollingPanel* panel )
{
    addChildInBack( panel );
    mPanelList.push_front( panel );

    // Resize this view
    S32 total_height = 0;
    S32 max_width = 0;
    S32 cur_gap = 0;
    for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin();
            iter != mPanelList.end(); ++iter)
    {
        LLScrollingPanel *childp = *iter;
        total_height += childp->getRect().getHeight() + cur_gap;
        max_width = llmax( max_width, childp->getRect().getWidth() );
        cur_gap = GAP_BETWEEN_PANELS;
    }
    LLRect rc = getRect();
    rc.setLeftTopAndSize(rc.mLeft, rc.mTop, max_width, total_height);
    setRect(rc);

    notifySizeChanged(rc.getHeight());

    // Reposition each of the child views
    S32 cur_y = total_height;
    for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin();
            iter != mPanelList.end(); ++iter)
    {
        LLScrollingPanel *childp = *iter;
        cur_y -= childp->getRect().getHeight();
        childp->translate( -childp->getRect().mLeft, cur_y - childp->getRect().mBottom);
        cur_y -= GAP_BETWEEN_PANELS;
    }

    return total_height;
}
예제 #23
0
void LLTabContainer::removeTabPanel(LLPanel* child)
{
	if (mIsVertical)
	{
		// Fix-up button sizes
		S32 tab_count = 0;
		for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter)
		{
			LLTabTuple* tuple = *iter;
			LLRect rect;
			rect.setLeftTopAndSize(TABCNTRV_PAD + LLPANEL_BORDER_WIDTH + 2,	// JC - Fudge factor
								   (getRect().getHeight() - LLPANEL_BORDER_WIDTH - 1) - ((BTN_HEIGHT + TABCNTRV_PAD) * (tab_count)),
								   mMinTabWidth,
								   BTN_HEIGHT);
			if (tuple->mPlaceholderText)
			{
				tuple->mPlaceholderText->setRect(rect);
			}
			else
			{
				tuple->mButton->setRect(rect);
			}
			tab_count++;
		}
	}
	else
	{
		// Adjust the total tab width.
		for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter)
		{
			LLTabTuple* tuple = *iter;
			if( tuple->mTabPanel == child )
			{
				mTotalTabWidth -= tuple->mButton->getRect().getWidth();
				break;
			}
		}
	}
	
	BOOL has_focus = gFocusMgr.childHasKeyboardFocus(this);

	// If the tab being deleted is the selected one, select a different tab.
	for(std::vector<LLTabTuple*>::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter)
	{
		LLTabTuple* tuple = *iter;
		if( tuple->mTabPanel == child )
		{
 			removeChild( tuple->mButton );
 			delete tuple->mButton;

 			removeChild( tuple->mTabPanel );
// 			delete tuple->mTabPanel;
			
			mTabList.erase( iter );
			delete tuple;

			break;
		}
	}

	// make sure we don't have more locked tabs than we have tabs
	mLockedTabCount = llmin(getTabCount(), mLockedTabCount);

	if (mCurrentTabIdx >= (S32)mTabList.size())
	{
		mCurrentTabIdx = mTabList.size()-1;
	}
	selectTab(mCurrentTabIdx);
	if (has_focus)
	{
		LLPanel* panelp = getPanelByIndex(mCurrentTabIdx);
		if (panelp)
		{
			panelp->setFocus(TRUE);
		}
	}

	updateMaxScrollPos();
}
예제 #24
0
LLToastAlertPanel::LLToastAlertPanel( LLNotificationPtr notification, bool modal)
	  : LLToastPanel(notification),
		mDefaultOption( 0 ),
		mCheck(NULL),
		mCaution(notification->getPriority() >= NOTIFICATION_PRIORITY_HIGH),
		mLabel(notification->getName()),
		mLineEditor(NULL)
{
	const LLFontGL* font = LLFontGL::getFontSansSerif();
	const S32 LINE_HEIGHT = llfloor(font->getLineHeight() + 0.99f);
	const S32 EDITOR_HEIGHT = 20;

	LLNotificationFormPtr form = mNotification->getForm();
	std::string edit_text_name;
	std::string edit_text_contents;
	S32 edit_text_max_chars = 0;
	bool is_password = false;

	LLToastPanel::setBackgroundVisible(FALSE);
	LLToastPanel::setBackgroundOpaque(TRUE);


	typedef std::vector<std::pair<std::string, std::string> > options_t;
	options_t supplied_options;

	// for now, get LLSD to iterator over form elements
	LLSD form_sd = form->asLLSD();

	S32 option_index = 0;
	for (LLSD::array_const_iterator it = form_sd.beginArray(); it != form_sd.endArray(); ++it)
	{
		std::string type = (*it)["type"].asString();
		if (type == "button")
		{
			if((*it)["default"])
			{
				mDefaultOption = option_index;
			}

			supplied_options.push_back(std::make_pair((*it)["name"].asString(), (*it)["text"].asString()));

			ButtonData data;
			if (option_index == mNotification->getURLOption())
			{
				data.mURL = mNotification->getURL();
				data.mURLExternal = mNotification->getURLOpenExternally();
			}

			mButtonData.push_back(data);
			option_index++;
		}
		else if (type == "text")
		{
			edit_text_contents = (*it)["value"].asString();
			edit_text_name = (*it)["name"].asString();
			edit_text_max_chars = (*it)["max_length_chars"].asInteger();
		}
		else if (type == "password")
		{
			edit_text_contents = (*it)["value"].asString();
			edit_text_name = (*it)["name"].asString();
			is_password = true;
		}
	}

	// Buttons
	options_t options;
	if (supplied_options.empty())
	{
		options.push_back(std::make_pair(std::string("close"), LLNotifications::instance().getGlobalString("implicitclosebutton")));

		// add data for ok button.
		ButtonData ok_button;
		mButtonData.push_back(ok_button);
		mDefaultOption = 0;
	}
	else
	{
		options = supplied_options;
	}

	S32 num_options = options.size();

	// Calc total width of buttons
	S32 button_width = 0;
	S32 sp = font->getWidth(std::string("OO"));
	for( S32 i = 0; i < num_options; i++ )
	{
		S32 w = S32(font->getWidth( options[i].second ) + 0.99f) + sp + 2 * LLBUTTON_H_PAD;
		button_width = llmax( w, button_width );
	}
	S32 btn_total_width = button_width;
	if( num_options > 1 )
	{
		btn_total_width = (num_options * button_width) + ((num_options - 1) * BTN_HPAD);
	}

	// Message: create text box using raw string, as text has been structure deliberately
	// Use size of created text box to generate dialog box size
	std::string msg = mNotification->getMessage();
	llwarns << "Alert: " << msg << llendl;
	LLTextBox::Params params;
	params.name("Alert message");
	params.font(font);
	params.tab_stop(false);
	params.wrap(true);
	params.follows.flags(FOLLOWS_LEFT | FOLLOWS_TOP);
	params.allow_scroll(true);

	LLTextBox * msg_box = LLUICtrlFactory::create<LLTextBox> (params);
	// Compute max allowable height for the dialog text, so we can allocate
	// space before wrapping the text to fit.
	S32 max_allowed_msg_height = 
			gFloaterView->getRect().getHeight()
			- LINE_HEIGHT			// title bar
			- 3*VPAD - BTN_HEIGHT;
	// reshape to calculate real text width and height
	msg_box->reshape( MAX_ALLOWED_MSG_WIDTH, max_allowed_msg_height );
	msg_box->setValue(msg);

	S32 pixel_width = msg_box->getTextPixelWidth();
	S32 pixel_height = msg_box->getTextPixelHeight();

	// We should use some space to prevent set textbox's scroller visible when it is unnecessary.
	msg_box->reshape( llmin(MAX_ALLOWED_MSG_WIDTH,pixel_width + 2 * msg_box->getHPad() + HPAD),
		llmin(max_allowed_msg_height,pixel_height + 2 * msg_box->getVPad())  ) ;

	const LLRect& text_rect = msg_box->getRect();
	S32 dialog_width = llmax( btn_total_width, text_rect.getWidth() ) + 2 * HPAD;
	S32 dialog_height = text_rect.getHeight() + 3 * VPAD + BTN_HEIGHT;

	if (hasTitleBar())
	{
		dialog_height += LINE_HEIGHT; // room for title bar
	}

	// it's ok for the edit text body to be empty, but we want the name to exist if we're going to draw it
	if (!edit_text_name.empty())
	{
		dialog_height += EDITOR_HEIGHT + VPAD;
		dialog_width = llmax(dialog_width, (S32)(font->getWidth( edit_text_contents ) + 0.99f));
	}

	if (mCaution)
	{
		// Make room for the caution icon.
		dialog_width += 32 + HPAD;
	}

	LLToastPanel::reshape( dialog_width, dialog_height, FALSE );

	S32 msg_y = LLToastPanel::getRect().getHeight() - VPAD;
	S32 msg_x = HPAD;
	if (hasTitleBar())
	{
		msg_y -= LINE_HEIGHT; // room for title
	}

	static LLUIColor alert_caution_text_color = LLUIColorTable::instance().getColor("AlertCautionTextColor");
	if (mCaution)
	{
		LLIconCtrl* icon = LLUICtrlFactory::getInstance()->createFromFile<LLIconCtrl>("alert_icon.xml", this, LLPanel::child_registry_t::instance());
		if(icon)
		{
			icon->setRect(LLRect(msg_x, msg_y, msg_x+32, msg_y-32));
			LLToastPanel::addChild(icon);
		}
		
		msg_x += 32 + HPAD;
		msg_box->setColor( alert_caution_text_color );
	}

	LLRect rect;
	rect.setLeftTopAndSize( msg_x, msg_y, text_rect.getWidth(), text_rect.getHeight() );
	msg_box->setRect( rect );
	LLToastPanel::addChild(msg_box);

	// (Optional) Edit Box	
	if (!edit_text_name.empty())
	{
		S32 y = VPAD + BTN_HEIGHT + VPAD/2;
		mLineEditor = LLUICtrlFactory::getInstance()->createFromFile<LLLineEditor>("alert_line_editor.xml", this, LLPanel::child_registry_t::instance());
	
		if (mLineEditor)
		{
			LLRect leditor_rect = LLRect( HPAD, y+EDITOR_HEIGHT, dialog_width-HPAD, y);
			mLineEditor->setName(edit_text_name);
			mLineEditor->reshape(leditor_rect.getWidth(), leditor_rect.getHeight());
			mLineEditor->setRect(leditor_rect);
			mLineEditor->setMaxTextChars(edit_text_max_chars);
			mLineEditor->setText(edit_text_contents);

			// decrease limit of line editor of teleport offer dialog to avoid truncation of
			// location URL in invitation message, see EXT-6891
			if ("OfferTeleport" == mNotification->getName())
			{
				mLineEditor->setMaxTextLength(gSavedSettings.getS32(
						"teleport_offer_invitation_max_length"));
			}
			else
			{
				mLineEditor->setMaxTextLength(STD_STRING_STR_LEN - 1);
			}

			LLToastPanel::addChild(mLineEditor);

			mLineEditor->setDrawAsterixes(is_password);

			setEditTextArgs(notification->getSubstitutions());

			mLineEditor->setFollowsLeft();
			mLineEditor->setFollowsRight();

			// find form text input field
			LLSD form_text;
			for (LLSD::array_const_iterator it = form_sd.beginArray(); it != form_sd.endArray(); ++it)
			{
				std::string type = (*it)["type"].asString();
				if (type == "text")
				{
					form_text = (*it);
				}
			}

			// if form text input field has width attribute
			if (form_text.has("width"))
			{
				// adjust floater width to fit line editor
				S32 editor_width = form_text["width"];
				LLRect editor_rect =  mLineEditor->getRect();
				U32 width_delta = editor_width  - editor_rect.getWidth();
				LLRect toast_rect = getRect();
				reshape(toast_rect.getWidth() +  width_delta, toast_rect.getHeight());
			}
		}
	}

	// Buttons
	S32 button_left = (LLToastPanel::getRect().getWidth() - btn_total_width) / 2;

	for( S32 i = 0; i < num_options; i++ )
	{
		LLRect button_rect;

		LLButton* btn = LLUICtrlFactory::getInstance()->createFromFile<LLButton>("alert_button.xml", this, LLPanel::child_registry_t::instance());
		if(btn)
		{
			btn->setName(options[i].first);
			btn->setRect(button_rect.setOriginAndSize( button_left, VPAD, button_width, BTN_HEIGHT ));
			btn->setLabel(options[i].second);
			btn->setFont(font);

			btn->setClickedCallback(boost::bind(&LLToastAlertPanel::onButtonPressed, this, _2, i));

			mButtonData[i].mButton = btn;

			LLToastPanel::addChild(btn);

			if( i == mDefaultOption )
			{
				btn->setFocus(TRUE);
			}
		}
		button_left += button_width + BTN_HPAD;
	}

	std::string ignore_label;

	if (form->getIgnoreType() == LLNotificationForm::IGNORE_WITH_DEFAULT_RESPONSE)
	{
		setCheckBox(LLNotifications::instance().getGlobalString("skipnexttime"), ignore_label);
	}
	else if (form->getIgnoreType() == LLNotificationForm::IGNORE_WITH_LAST_RESPONSE)
	{
		setCheckBox(LLNotifications::instance().getGlobalString("alwayschoose"), ignore_label);
	}

	// *TODO: check necessity of this code
	//gFloaterView->adjustToFitScreen(this, FALSE);
	if (mLineEditor)
	{
		mLineEditor->selectAll();
	}
	if(mDefaultOption >= 0)
	{
		// delay before enabling default button
		mDefaultBtnTimer.start();
		mDefaultBtnTimer.setTimerExpirySec(DEFAULT_BUTTON_DELAY);
	}

	LLTransientFloaterMgr::instance().addControlView(
			LLTransientFloaterMgr::GLOBAL, this);
}
예제 #25
0
void LLDockControl::moveDockable()
{
	// calculate new dockable position
	LLRect dockRect = mDockWidget->calcScreenRect();
	LLRect rootRect;
	mGetAllowedRectCallback(rootRect);

	bool use_tongue = false;
	LLDockableFloater* dockable_floater =
			dynamic_cast<LLDockableFloater*> (mDockableFloater);
	if (dockable_floater != NULL)
	{
		use_tongue = dockable_floater->getUseTongue();
	}

	LLRect dockableRect = mDockableFloater->calcScreenRect();
	S32 x = 0;
	S32 y = 0;
	LLRect dockParentRect;
	switch (mDockAt)
	{
	case LEFT:
		x = dockRect.mLeft;
		y = dockRect.mTop + mDockTongue->getHeight() + dockableRect.getHeight();
		// check is dockable inside root view rect
		if (x < rootRect.mLeft)
		{
			x = rootRect.mLeft;
		}
		if (x + dockableRect.getWidth() > rootRect.mRight)
		{
			x = rootRect.mRight - dockableRect.getWidth();
		}
		
		mDockTongueX = x + dockableRect.getWidth()/2 - mDockTongue->getWidth() / 2;
		
		mDockTongueY = dockRect.mTop;
		break;

	case TOP:
		x = dockRect.getCenterX() - dockableRect.getWidth() / 2;
		y = dockRect.mTop + dockableRect.getHeight();
		// unique docking used with dock tongue, so add tongue height o the Y coordinate
		if (use_tongue)
		{
			y += mDockTongue->getHeight();
		}

		// check is dockable inside root view rect
		if (x < rootRect.mLeft)
		{
			x = rootRect.mLeft;
		}
		if (x + dockableRect.getWidth() > rootRect.mRight)
		{
			x = rootRect.mRight - dockableRect.getWidth();
		}


		// calculate dock tongue position
		dockParentRect = mDockWidget->getParent()->calcScreenRect();
		if (dockRect.getCenterX() < dockParentRect.mLeft)
		{
			mDockTongueX = dockParentRect.mLeft - mDockTongue->getWidth() / 2;
		}
		else if (dockRect.getCenterX() > dockParentRect.mRight)
		{
			mDockTongueX = dockParentRect.mRight - mDockTongue->getWidth() / 2;;
		}
		else
		{
			mDockTongueX = dockRect.getCenterX() - mDockTongue->getWidth() / 2;
		}
		mDockTongueY = dockRect.mTop;

		break;
	case BOTTOM:
		x = dockRect.getCenterX() - dockableRect.getWidth() / 2;
		y = dockRect.mBottom;
		// unique docking used with dock tongue, so add tongue height o the Y coordinate
		if (use_tongue)
		{
			y -= mDockTongue->getHeight();
		}

		// check is dockable inside root view rect
		if (x < rootRect.mLeft)
		{
			x = rootRect.mLeft;
		}
		if (x + dockableRect.getWidth() > rootRect.mRight)
		{
			x = rootRect.mRight - dockableRect.getWidth();
		}

		// calculate dock tongue position
		dockParentRect = mDockWidget->getParent()->calcScreenRect();
		if (dockRect.getCenterX() < dockParentRect.mLeft)
		{
			mDockTongueX = dockParentRect.mLeft - mDockTongue->getWidth() / 2;
		}
		else if (dockRect.getCenterX() > dockParentRect.mRight)
		{
			mDockTongueX = dockParentRect.mRight - mDockTongue->getWidth() / 2;;
		}
		else
		{
			mDockTongueX = dockRect.getCenterX() - mDockTongue->getWidth() / 2;
		}
		mDockTongueY = dockRect.mBottom - mDockTongue->getHeight();

		break;
	}

	// move dockable
	dockableRect.setLeftTopAndSize(x, y, dockableRect.getWidth(),
			dockableRect.getHeight());
	LLRect localDocableParentRect;
	mDockableFloater->getParent()->screenRectToLocal(dockableRect,
			&localDocableParentRect);
	mDockableFloater->setRect(localDocableParentRect);

	mDockableFloater->screenPointToLocal(mDockTongueX, mDockTongueY,
			&mDockTongueX, &mDockTongueY);

}
예제 #26
0
void LLDockControl::moveDockable()
{
	// calculate new dockable position
	LLRect dockRect = mDockWidget->calcScreenRect();
	LLRect rootRect;
	mGetAllowedRectCallback(rootRect);

	bool use_tongue = false;
	LLDockableFloater* dockable_floater =
			dynamic_cast<LLDockableFloater*> (mDockableFloater);
	if (dockable_floater != NULL)
	{
		use_tongue = dockable_floater->getUseTongue();
	}

	LLRect dockableRect = mDockableFloater->calcScreenRect();
	S32 x = 0;
	S32 y = 0;
	LLRect dockParentRect;
	switch (mDockAt)
	{
	case LEFT:

		x = dockRect.mLeft - dockableRect.getWidth();
		y = dockRect.getCenterY() + dockableRect.getHeight() / 2;
		
		if (use_tongue)
		{
			x -= mDockTongue->getWidth();
		}

		mDockTongueX = dockableRect.mRight;
		mDockTongueY = dockableRect.getCenterY() - mDockTongue->getHeight() / 2;
		
		break;

	case RIGHT:

		x = dockRect.mRight;
		y = dockRect.getCenterY() + dockableRect.getHeight() / 2;

		if (use_tongue)
		{
			x += mDockTongue->getWidth();
		}

		mDockTongueX = dockRect.mRight;
		mDockTongueY = dockableRect.getCenterY() - mDockTongue->getHeight() / 2;

		break;

	case TOP:
		x = dockRect.getCenterX() - dockableRect.getWidth() / 2;
		y = dockRect.mTop + dockableRect.getHeight();
		// unique docking used with dock tongue, so add tongue height to the Y coordinate
		if (use_tongue)
		{
			y += mDockTongue->getHeight();

			if ( y > rootRect.mTop)
			{
				y = rootRect.mTop;
			}
		}

		// check is dockable inside root view rect
		if (x < rootRect.mLeft)
		{
			x = rootRect.mLeft;
		}
		if (x + dockableRect.getWidth() > rootRect.mRight)
		{
			x = rootRect.mRight - dockableRect.getWidth();
		}


		// calculate dock tongue position
		dockParentRect = mDockWidget->getParent()->calcScreenRect();
		if (dockRect.getCenterX() < dockParentRect.mLeft)
		{
			mDockTongueX = dockParentRect.mLeft - mDockTongue->getWidth() / 2;
		}
		else if (dockRect.getCenterX() > dockParentRect.mRight)
		{
			mDockTongueX = dockParentRect.mRight - mDockTongue->getWidth() / 2;;
		}
		else
		{
			mDockTongueX = dockRect.getCenterX() - mDockTongue->getWidth() / 2;
		}
		mDockTongueY = dockRect.mTop;

		break;
	case BOTTOM:
		x = dockRect.getCenterX() - dockableRect.getWidth() / 2;
		y = dockRect.mBottom;
		// unique docking used with dock tongue, so add tongue height to the Y coordinate
		if (use_tongue)
		{
			y -= mDockTongue->getHeight();
		}

		// check is dockable inside root view rect
		if (x < rootRect.mLeft)
		{
			x = rootRect.mLeft;
		}
		if (x + dockableRect.getWidth() > rootRect.mRight)
		{
			x = rootRect.mRight - dockableRect.getWidth();
		}

		// calculate dock tongue position
		dockParentRect = mDockWidget->getParent()->calcScreenRect();
		if (dockRect.getCenterX() < dockParentRect.mLeft)
		{
			mDockTongueX = dockParentRect.mLeft - mDockTongue->getWidth() / 2;
		}
		else if (dockRect.getCenterX() > dockParentRect.mRight)
		{
			mDockTongueX = dockParentRect.mRight - mDockTongue->getWidth() / 2;;
		}
		else
		{
			mDockTongueX = dockRect.getCenterX() - mDockTongue->getWidth() / 2;
		}
		mDockTongueY = dockRect.mBottom - mDockTongue->getHeight();

		break;
	}

	S32 max_available_height = rootRect.getHeight() - (rootRect.mBottom -  mDockTongueY) - mDockTongue->getHeight();

	// A floater should be shrunk so it doesn't cover a part of its docking tongue and
	// there is a space between a dockable floater and a control to which it is docked.
	if (use_tongue && dockableRect.getHeight() >= max_available_height)
	{
		dockableRect.setLeftTopAndSize(x, y, dockableRect.getWidth(), max_available_height);
		mDockableFloater->reshape(dockableRect.getWidth(), dockableRect.getHeight());
	}
	else
	{
		// move dockable
		dockableRect.setLeftTopAndSize(x, y, dockableRect.getWidth(),
				dockableRect.getHeight());
	}

	LLRect localDocableParentRect;

	mDockableFloater->getParent()->screenRectToLocal(dockableRect, &localDocableParentRect);
	mDockableFloater->setRect(localDocableParentRect);
	mDockableFloater->screenPointToLocal(mDockTongueX, mDockTongueY, &mDockTongueX, &mDockTongueY);

}
예제 #27
0
void LLDebugView::init()
{
	LLRect r;
	LLRect rect = getLocalRect();

	r.set(10, rect.getHeight() - 100, rect.getWidth()/2, 100);
	LLConsole::Params cp;
	cp.name("debug console");
	cp.max_lines(20);
	cp.rect(r);
	cp.font(LLFontGL::getFontMonospace());
	cp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_LEFT);
	cp.visible(false);
	mDebugConsolep = LLUICtrlFactory::create<LLConsole>(cp);
	addChild(mDebugConsolep);

	r.set(150 - 25, rect.getHeight() - 50, rect.getWidth()/2 - 25, rect.getHeight() - 450);

	r.setLeftTopAndSize(25, rect.getHeight() - 50, (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.75f), 
  									 (S32) (gViewerWindow->getWindowRectScaled().getHeight() * 0.75f));
	
	mFastTimerView = new LLFastTimerView(r);
	mFastTimerView->setFollowsTop();
	mFastTimerView->setFollowsLeft();
	mFastTimerView->setVisible(FALSE);			// start invisible
	addChild(mFastTimerView);
	mFastTimerView->setRect(rect);

	r.setLeftTopAndSize(25, rect.getHeight() - 50, (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.75f), 
									 (S32) (gViewerWindow->getWindowRectScaled().getHeight() * 0.75f));
	LLMemoryView::Params mp;
	mp.name("memory");
	mp.rect(r);
	mp.follows.flags(FOLLOWS_TOP | FOLLOWS_LEFT);
	mp.visible(false);
	mMemoryView = LLUICtrlFactory::create<LLMemoryView>(mp);
	addChild(mMemoryView);

	r.set(150, rect.getHeight() - 50, 820, 100);
	LLTextureView::Params tvp;
	tvp.name("gTextureView");
	tvp.rect(r);
	tvp.follows.flags(FOLLOWS_BOTTOM|FOLLOWS_LEFT);
	tvp.visible(false);
	gTextureView = LLUICtrlFactory::create<LLTextureView>(tvp);
	addChild(gTextureView);
	//gTextureView->reshape(r.getWidth(), r.getHeight(), TRUE);

	if(gAuditTexture)
	{
		r.set(150, rect.getHeight() - 50, 900 + LLImageGL::sTextureLoadedCounter.size() * 30, 100);
		LLTextureSizeView::Params tsv ;
		tsv.name("gTextureSizeView");
		tsv.rect(r);
		tsv.follows.flags(FOLLOWS_BOTTOM|FOLLOWS_LEFT);
		tsv.visible(false);
		gTextureSizeView = LLUICtrlFactory::create<LLTextureSizeView>(tsv);
		addChild(gTextureSizeView);
		gTextureSizeView->setType(LLTextureSizeView::TEXTURE_MEM_OVER_SIZE) ;

		r.set(150, rect.getHeight() - 50, 900 + LLViewerTexture::getTotalNumOfCategories() * 30, 100);
		LLTextureSizeView::Params tcv ;
		tcv.name("gTextureCategoryView");
		tcv.rect(r);
		tcv.follows.flags(FOLLOWS_BOTTOM|FOLLOWS_LEFT);
		tcv.visible(false);
		gTextureCategoryView = LLUICtrlFactory::create<LLTextureSizeView>(tcv);
		gTextureCategoryView->setType(LLTextureSizeView::TEXTURE_MEM_OVER_CATEGORY);
		addChild(gTextureCategoryView);
	}
}
예제 #28
0
// static
LLPreviewGesture* LLPreviewGesture::show(const std::string& title, const LLUUID& item_id, const LLUUID& object_id, BOOL take_focus)
{
	LLPreviewGesture* previewp = (LLPreviewGesture*)LLPreview::find(item_id);
	if (previewp)
	{
		previewp->open();   /*Flawfinder: ignore*/
		if (take_focus)
		{
			previewp->setFocus(TRUE);
		}
		return previewp;
	}

	LLPreviewGesture* self = new LLPreviewGesture();

	// Finish internal construction
	self->init(item_id, object_id);

	// Builds and adds to gFloaterView
	LLUICtrlFactory::getInstance()->buildFloater(self, "floater_preview_gesture.xml");
	self->setTitle(title);

	// Move window to top-left of screen
	LLMultiFloater* hostp = self->getHost();
	if (hostp == NULL)
	{
		LLRect r = self->getRect();
		LLRect screen = gFloaterView->getRect();
		r.setLeftTopAndSize(0, screen.getHeight(), r.getWidth(), r.getHeight());
		self->setRect(r);
	}
	else
	{
		// re-add to host to update title
		hostp->addFloater(self, TRUE);
	}

	// Start speculative download of sounds and animations
	const LLUUID animation_folder_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_ANIMATION);
	LLInventoryModelBackgroundFetch::instance().start(animation_folder_id);

	const LLUUID sound_folder_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_SOUND);
	LLInventoryModelBackgroundFetch::instance().start(sound_folder_id);

	// this will call refresh when we have everything.
	LLViewerInventoryItem* item = (LLViewerInventoryItem*)self->getItem();
	if(item && !item->isFinished())
	{
		LLInventoryGestureAvailable* observer;
		observer = new LLInventoryGestureAvailable();
		observer->watchItem(item_id);
		gInventory.addObserver(observer);
		item->fetchFromServer();
	}
	else
	{
		// not sure this is necessary.
		self->refresh();
	}

	if (take_focus)
	{
		self->setFocus(TRUE);
	}

	return self;
}
예제 #29
0
LLAlertDialog::LLAlertDialog( LLNotificationPtr notification, bool modal)
	:	LLModalDialog( notification->getLabel(), 100, 100, modal ),  // dummy size.  Will reshape below.
		LLInstanceTracker<LLAlertDialog, LLUUID>(notification->getID()),
		mDefaultButton( NULL ),
		mCheck(NULL),
		mCaution(notification->getPriority() >= NOTIFICATION_PRIORITY_HIGH),
		mLabel(notification->getName()),
		mLineEditor(NULL),
		mNote(notification)
{
	const LLFontGL* font = LLResMgr::getInstance()->getRes( FONT_NAME );
	const S32 LINE_HEIGHT = llfloor(font->getLineHeight() + 0.99f);
	const S32 EDITOR_HEIGHT = 20;

	LLNotificationFormPtr form = mNote->getForm();
	std::string edit_text_name;
	std::string edit_text_contents;
	bool is_password = false;

	setBackgroundVisible(TRUE);
	setBackgroundOpaque(TRUE);

	typedef std::list<ButtonData> options_t;
	options_t options;

	// for now, get LLSD to iterator over form elements
	LLSD form_sd = form->asLLSD();

	for (LLSD::array_const_iterator it = form_sd.beginArray(); it != form_sd.endArray(); ++it)
	{
		std::string type = (*it)["type"].asString();
		if (type == "button")
		{
			options.push_back(ButtonData());
			ButtonData& button_data = options.back();
			button_data.mName = (*it)["name"].asString();
			button_data.mText = (*it)["text"].asString();
			button_data.mDefault = (*it)["default"].asBoolean();
			if(options.size()-1 == mNote->getURLOption())
				button_data.mUrl = mNote->getURL();
		}
		else if (type == "text")
		{
			edit_text_contents = (*it)["value"].asString();
			edit_text_name = (*it)["name"].asString();
		}
		else if (type == "password")
		{
			edit_text_contents = (*it)["value"].asString();
			edit_text_name = (*it)["name"].asString();
			is_password = true;
		}
	}
	// Buttons
	if (options.empty())
	{
		options.push_back(ButtonData());
		ButtonData& button_data = options.back();
		button_data.mName = "close";
		button_data.mText = "Close";
		button_data.mDefault = true;
	}

	S32 num_options = options.size();

	// Calc total width of buttons
	S32 button_width = 0;
	S32 sp = font->getWidth(std::string("OO"));
	for( options_t::iterator it = options.begin(); it != options.end(); it++ )
	{
		S32 w = S32(font->getWidth( it->mText ) + 0.99f) + sp + 2 * LLBUTTON_H_PAD;
		button_width = llmax( w, button_width );
	}
	S32 btn_total_width = button_width;
	if( num_options > 1 )
	{
		btn_total_width = (num_options * button_width) + ((num_options - 1) * BTN_HPAD);
	}

	// Message: create text box using raw string, as text has been structure deliberately
	// Use size of created text box to generate dialog box size
	std::string msg = mNote->getMessage();
	llwarns << "Alert: " << msg << llendl;
	LLTextBox* msg_box = new LLTextBox( std::string("Alert message"), msg, (F32)MAX_ALLOWED_MSG_WIDTH, font );

	const LLRect& text_rect = msg_box->getRect();
	S32 dialog_width = llmax( btn_total_width, text_rect.getWidth() ) + 2 * HPAD;
	S32 dialog_height = text_rect.getHeight() + 3 * VPAD + BTN_HEIGHT;

	if (hasTitleBar())
	{
		dialog_height += LINE_HEIGHT; // room for title bar
	}

	// it's ok for the edit text body to be empty, but we want the name to exist if we're going to draw it
	if (!edit_text_name.empty())
	{
		dialog_height += EDITOR_HEIGHT + VPAD;
		dialog_width = llmax(dialog_width, (S32)(font->getWidth( edit_text_contents ) + 0.99f));
	}

	if (mCaution)
	{
		// Make room for the caution icon.
		dialog_width += 32 + HPAD;
	}

	reshape( dialog_width, dialog_height, FALSE );

	S32 msg_y = getRect().getHeight() - VPAD;
	S32 msg_x = HPAD;
	if (hasTitleBar())
	{
		msg_y -= LINE_HEIGHT; // room for title
	}

	if (mCaution)
	{
		LLIconCtrl* icon = new LLIconCtrl(std::string("icon"), LLRect(msg_x, msg_y, msg_x+32, msg_y-32), std::string("notify_caution_icon.tga"));
		icon->setMouseOpaque(FALSE);
		addChild(icon);
		msg_x += 32 + HPAD;
		msg_box->setColor( LLUI::sColorsGroup->getColor( "AlertCautionTextColor" ) );
	}
	else
	{
		msg_box->setColor( LLUI::sColorsGroup->getColor( "AlertTextColor" ) );
	}

	LLRect rect;
	rect.setLeftTopAndSize( msg_x, msg_y, text_rect.getWidth(), text_rect.getHeight() );
	msg_box->setRect( rect );
	addChild(msg_box);

	// Buttons	
	S32 button_left = (getRect().getWidth() - btn_total_width) / 2;

	for( options_t::iterator it = options.begin(); it != options.end(); it++ )
	{
		LLRect button_rect;
		button_rect.setOriginAndSize( button_left, VPAD, button_width, BTN_HEIGHT );

		ButtonData& button_data = *it;

		LLButton* btn = new LLButton(
			button_data.mName, button_rect,
			"","", "", 
			NULL,
			font,
			button_data.mText, 
			button_data.mText);

		btn->setClickedCallback(boost::bind(&LLAlertDialog::onButtonPressed, this, _1, button_data.mUrl));

		addChild(btn);

		if(!mDefaultButton || button_data.mDefault)
		{
			mDefaultButton = btn;
		}

		button_left += button_width + BTN_HPAD;
	}

	llassert(mDefaultButton); //'options' map should never be empty, thus mDefaultButton should always get set in the above loop.
	mDefaultButton->setFocus(TRUE);


	// (Optional) Edit Box	
	if (!edit_text_name.empty())
	{
		S32 y = VPAD + BTN_HEIGHT + VPAD/2;
		mLineEditor = new LLLineEditor(edit_text_name,
			LLRect( HPAD, y+EDITOR_HEIGHT, dialog_width-HPAD, y),
			edit_text_contents,
			LLFontGL::getFontSansSerif(),
			STD_STRING_STR_LEN);

		// make sure all edit keys get handled properly (DEV-22396)
		mLineEditor->setHandleEditKeysDirectly(TRUE);

		addChild(mLineEditor);
	}
	
	if (mLineEditor)
	{
		mLineEditor->setDrawAsterixes(is_password);

		setEditTextArgs(notification->getSubstitutions());
	}

	std::string ignore_label;

	if (form->getIgnoreType() == LLNotificationForm::IGNORE_WITH_DEFAULT_RESPONSE)
	{
		setCheckBox(LLNotificationTemplates::instance().getGlobalString("skipnexttime"), ignore_label);
	}
	else if (form->getIgnoreType() == LLNotificationForm::IGNORE_WITH_LAST_RESPONSE)
	{
		setCheckBox(LLNotificationTemplates::instance().getGlobalString("alwayschoose"), ignore_label);
	}
}
예제 #30
0
void LLComboBox::showList()
{
	// Make sure we don't go off top of screen.
	LLCoordWindow window_size;
	getWindow()->getSize(&window_size);
	//HACK: shouldn't have to know about scale here
	mList->fitContents( 192, llfloor((F32)window_size.mY / LLUI::sGLScaleFactor.mV[VY]) - 50 );

	// Make sure that we can see the whole list
	LLRect root_view_local;
	LLView* root_view = getRootView();
	root_view->localRectToOtherView(root_view->getLocalRect(), &root_view_local, this);
	
	LLRect rect = mList->getRect();

	S32 min_width = getRect().getWidth();
	S32 max_width = llmax(min_width, MAX_COMBO_WIDTH);
	// make sure we have up to date content width metrics
	mList->calcColumnWidths();
	S32 list_width = llclamp(mList->getMaxContentWidth(), min_width, max_width);

	if (mListPosition == BELOW)
	{
		if (rect.getHeight() <= -root_view_local.mBottom)
		{
			// Move rect so it hangs off the bottom of this view
			rect.setLeftTopAndSize(0, 0, list_width, rect.getHeight() );
		}
		else
		{	
			// stack on top or bottom, depending on which has more room
			if (-root_view_local.mBottom > root_view_local.mTop - getRect().getHeight())
			{
				// Move rect so it hangs off the bottom of this view
				rect.setLeftTopAndSize(0, 0, list_width, llmin(-root_view_local.mBottom, rect.getHeight()));
			}
			else
			{
				// move rect so it stacks on top of this view (clipped to size of screen)
				rect.setOriginAndSize(0, getRect().getHeight(), list_width, llmin(root_view_local.mTop - getRect().getHeight(), rect.getHeight()));
			}
		}
	}
	else // ABOVE
	{
		if (rect.getHeight() <= root_view_local.mTop - getRect().getHeight())
		{
			// move rect so it stacks on top of this view (clipped to size of screen)
			rect.setOriginAndSize(0, getRect().getHeight(), list_width, llmin(root_view_local.mTop - getRect().getHeight(), rect.getHeight()));
		}
		else
		{
			// stack on top or bottom, depending on which has more room
			if (-root_view_local.mBottom > root_view_local.mTop - getRect().getHeight())
			{
				// Move rect so it hangs off the bottom of this view
				rect.setLeftTopAndSize(0, 0, list_width, llmin(-root_view_local.mBottom, rect.getHeight()));
			}
			else
			{
				// move rect so it stacks on top of this view (clipped to size of screen)
				rect.setOriginAndSize(0, getRect().getHeight(), list_width, llmin(root_view_local.mTop - getRect().getHeight(), rect.getHeight()));
			}
		}

	}
	mList->setOrigin(rect.mLeft, rect.mBottom);
	mList->reshape(rect.getWidth(), rect.getHeight());
	mList->translateIntoRect(root_view_local, FALSE);

	// Make sure we didn't go off bottom of screen
	S32 x, y;
	mList->localPointToScreen(0, 0, &x, &y);

	if (y < 0)
	{
		mList->translate(0, -y);
	}

	// NB: this call will trigger the focuslost callback which will hide the list, so do it first
	// before finally showing the list

	mList->setFocus(TRUE);

	// register ourselves as a "top" control
	// effectively putting us into a special draw layer
	// and not affecting the bounding rectangle calculation
	gFocusMgr.setTopCtrl(this);

	// Show the list and push the button down
	mButton->setToggleState(TRUE);
	mList->setVisible(TRUE);
	
	setUseBoundingRect(TRUE);
}